@madgex/design-system 7.0.4 → 8.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/dist/_tokens/css/_tokens.css +1 -1
- package/dist/_tokens/js/_tokens-module.js +1 -1
- package/dist/assets/icons-inline.svg +1 -1
- package/dist/assets/icons.json +1 -1
- package/dist/assets/icons.svg +1 -1
- package/dist/css/index.css +1 -1
- package/dist/js/index.js +1 -1
- package/package.json +2 -2
- package/src/components/accordion/README.md +14 -23
- package/src/components/accordion/_template.njk +32 -66
- package/src/components/accordion/accordion.config.js +19 -49
- package/src/components/accordion/accordion.js +74 -241
- package/src/components/accordion/accordion.njk +17 -20
- package/src/components/accordion/accordion.scss +70 -32
- package/src/components/inputs/_form-elements.scss +18 -9
- package/src/components/inputs/checkbox-list/_template.njk +21 -24
- package/src/components/inputs/checkbox-list/checkbox-list.js +28 -0
- package/src/components/inputs/file-upload/file-upload.js +7 -0
- package/src/icons/triangle-down.svg +3 -0
- package/src/icons/triangle-right.svg +3 -0
- package/src/icons/triangle-up.svg +3 -0
- package/src/js/index.js +2 -0
- package/src/scss/constants/_sd-tokens.scss +1 -1
|
@@ -1,241 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const ariaLabel = triggerButton.getAttribute('aria-label');
|
|
76
|
-
const isNonClosing = accordionTrigger.classList.contains(accordionNonClosingClass);
|
|
77
|
-
|
|
78
|
-
// If accordion is non closing content first is redundant
|
|
79
|
-
const isContentFirst = accordionTrigger.classList.contains(accordionContentFirstClass) && !isNonClosing;
|
|
80
|
-
|
|
81
|
-
triggerContainer.classList.remove('mds-display-none');
|
|
82
|
-
if (accordionContent.nodeName.toLowerCase() !== 'fieldset') {
|
|
83
|
-
if (ariaLabel) {
|
|
84
|
-
accordionContent.setAttribute('aria-label', ariaLabel);
|
|
85
|
-
} else {
|
|
86
|
-
accordionContent.setAttribute('aria-label', labelText);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
triggerContainer.innerHTML = '';
|
|
91
|
-
triggerContainer.appendChild(triggerButton);
|
|
92
|
-
|
|
93
|
-
const accordionProperties = {
|
|
94
|
-
triggerContainer,
|
|
95
|
-
accordionContent,
|
|
96
|
-
isNonClosing,
|
|
97
|
-
isContentFirst,
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const toggleEvent = (e) => {
|
|
101
|
-
e.preventDefault();
|
|
102
|
-
accordion.toggleExpand(accordionProperties, toggleEvent, e);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
triggerButton.addEventListener('click', toggleEvent);
|
|
106
|
-
|
|
107
|
-
if (triggerContainer.dataset.expanded) {
|
|
108
|
-
accordion.toggleExpand(accordionProperties, toggleEvent);
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
createButton: (triggerContainer) => {
|
|
113
|
-
const accordionTriggerSpan = triggerContainer.querySelector(`.${accordionTriggerClass} > span`);
|
|
114
|
-
const accordionTriggerButton = document.createElement('button');
|
|
115
|
-
|
|
116
|
-
accordionTriggerButton.className = accordionTriggerButtonClass;
|
|
117
|
-
// can't use multiple arguments in classList.add() due to IE
|
|
118
|
-
accordionTriggerButton.classList.add('mds-button');
|
|
119
|
-
accordionTriggerButton.classList.add('mds-button--plain');
|
|
120
|
-
accordionTriggerButton.classList.add('mds-padding-x-b0');
|
|
121
|
-
accordionTriggerButton.setAttribute('aria-expanded', false);
|
|
122
|
-
accordionTriggerButton.setAttribute('type', 'button');
|
|
123
|
-
|
|
124
|
-
if (triggerContainer.dataset.arialabel) {
|
|
125
|
-
accordionTriggerButton.setAttribute('aria-label', triggerContainer.dataset.arialabel);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (accordionTriggerSpan) {
|
|
129
|
-
accordionTriggerButton.appendChild(accordionTriggerSpan);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return accordionTriggerButton;
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
cloneUnderButton: (triggerButton, triggerContainer, accordionContent, toggleEvent) => {
|
|
136
|
-
const underButton = triggerButton.cloneNode(true);
|
|
137
|
-
const triggerButtonLabel = underButton.querySelector(`.${accordionTriggerLabelClass}`);
|
|
138
|
-
|
|
139
|
-
if (triggerContainer.dataset.arialabeactive) {
|
|
140
|
-
underButton.setAttribute('aria-label', triggerContainer.dataset.arialabeactive);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
underButton.setAttribute('aria-expanded', true);
|
|
144
|
-
underButton.addEventListener('click', toggleEvent);
|
|
145
|
-
accordion.switchAriaLabel(underButton, triggerContainer);
|
|
146
|
-
accordion.switchLabel(triggerButtonLabel);
|
|
147
|
-
accordionContent.after(underButton);
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
switchLabel: (triggerButtonLabel) => {
|
|
151
|
-
if (triggerButtonLabel.dataset.labelinverse) {
|
|
152
|
-
const labelToInverse = triggerButtonLabel.textContent;
|
|
153
|
-
|
|
154
|
-
// eslint-disable-next-line no-param-reassign
|
|
155
|
-
triggerButtonLabel.textContent = triggerButtonLabel.dataset.labelinverse;
|
|
156
|
-
triggerButtonLabel.setAttribute(accordionLabelInverseData, labelToInverse);
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
switchAriaLabel: (triggerButton, triggerContainer) => {
|
|
161
|
-
if (triggerContainer.dataset.arialabelactive) {
|
|
162
|
-
const currentAriaLabel = triggerButton.getAttribute('aria-label');
|
|
163
|
-
|
|
164
|
-
if (currentAriaLabel === triggerContainer.dataset.arialabel) {
|
|
165
|
-
triggerButton.setAttribute('aria-label', triggerContainer.dataset.arialabelactive);
|
|
166
|
-
} else {
|
|
167
|
-
triggerButton.setAttribute('aria-label', triggerContainer.dataset.arialabel);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
toggleExpand: ({ triggerContainer, accordionContent, isNonClosing, isContentFirst }, toggleEvent, event) => {
|
|
173
|
-
let triggerButton;
|
|
174
|
-
|
|
175
|
-
if (event) {
|
|
176
|
-
triggerButton = event.target.closest(`.${accordionTriggerButtonClass}`);
|
|
177
|
-
} else {
|
|
178
|
-
triggerButton = triggerContainer.querySelector(`.${accordionTriggerButtonClass}`);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const triggerButtonLabel = triggerButton.querySelector(`.${accordionTriggerLabelClass}`);
|
|
182
|
-
|
|
183
|
-
// If closed
|
|
184
|
-
if (triggerButton.getAttribute('aria-expanded') === 'false') {
|
|
185
|
-
triggerButton.setAttribute('aria-expanded', true);
|
|
186
|
-
triggerContainer.classList.add(accordionTriggerExpandedClass);
|
|
187
|
-
accordionContent.classList.add(accordionContentExpandedClass);
|
|
188
|
-
|
|
189
|
-
if (isContentFirst) {
|
|
190
|
-
// triggerButton.focus();
|
|
191
|
-
accordion.cloneUnderButton(triggerButton, triggerContainer, accordionContent, toggleEvent);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (isNonClosing || isContentFirst) {
|
|
195
|
-
accordion.hideButton(triggerButton, toggleEvent);
|
|
196
|
-
} else {
|
|
197
|
-
accordion.switchLabel(triggerButtonLabel);
|
|
198
|
-
accordion.switchAriaLabel(triggerButton, triggerContainer);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// If open
|
|
202
|
-
} else if (!isNonClosing) {
|
|
203
|
-
triggerButton.setAttribute('aria-expanded', false);
|
|
204
|
-
triggerContainer.classList.remove(accordionTriggerExpandedClass);
|
|
205
|
-
accordionContent.classList.remove(accordionContentExpandedClass);
|
|
206
|
-
|
|
207
|
-
accordion.switchLabel(triggerButtonLabel);
|
|
208
|
-
accordion.switchAriaLabel(triggerButton, triggerContainer);
|
|
209
|
-
|
|
210
|
-
if (isContentFirst) {
|
|
211
|
-
// Find original button
|
|
212
|
-
const overButton = accordionContent.previousElementSibling.querySelector(`.${accordionTriggerButtonClass}`);
|
|
213
|
-
|
|
214
|
-
// Set up under button with correct properties
|
|
215
|
-
triggerButton.setAttribute('aria-expanded', false);
|
|
216
|
-
triggerButton.removeAttribute('aria-disabled');
|
|
217
|
-
triggerButton.setAttribute('tabIndex', '0');
|
|
218
|
-
|
|
219
|
-
// Replace original button
|
|
220
|
-
overButton.replaceWith(triggerButton);
|
|
221
|
-
triggerContainer.classList.remove('mds-visually-hidden');
|
|
222
|
-
triggerButton.focus();
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
hideButton: (button, toggleEvent) => {
|
|
228
|
-
/* Hiding parent element instead of trigger itself
|
|
229
|
-
* to avoid NVDA issue where it doesn't announce aria-expanded
|
|
230
|
-
*/
|
|
231
|
-
button.setAttribute('aria-disabled', true);
|
|
232
|
-
button.parentElement.classList.add('mds-visually-hidden');
|
|
233
|
-
/* the disabled trigger shouldn't be reachable to keyboard navigaton (as it's hidden from view)
|
|
234
|
-
* so adding tabindex='-1' to take it off the navigation flow
|
|
235
|
-
*/
|
|
236
|
-
button.setAttribute('tabIndex', '-1');
|
|
237
|
-
button.removeEventListener('click', toggleEvent);
|
|
238
|
-
},
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
export default accordion;
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
const accordionBreakpointClass = 'mds-accordion--breakpoint';
|
|
3
|
+
const accordionLabelClass = 'mds-accordion__label';
|
|
4
|
+
|
|
5
|
+
const accordion = {
|
|
6
|
+
init: () => {
|
|
7
|
+
// Breakpoint accordions
|
|
8
|
+
const breakpointAccordions = document.querySelectorAll(`.${accordionBreakpointClass}`);
|
|
9
|
+
const screenWidth = window.innerWidth;
|
|
10
|
+
|
|
11
|
+
breakpointAccordions.forEach((accordionElm) => {
|
|
12
|
+
const isAccordion = accordion.checkBreakpoint(accordionElm, screenWidth);
|
|
13
|
+
|
|
14
|
+
if (!isAccordion) {
|
|
15
|
+
accordionElm.open = true;
|
|
16
|
+
accordionElm.querySelector('summary').style.display = 'none';
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const accordionLabels = document.querySelectorAll(`.${accordionLabelClass}`);
|
|
21
|
+
|
|
22
|
+
accordionLabels.forEach((accordionLabel) => {
|
|
23
|
+
accordionLabel.addEventListener('click', ({ target }) => {
|
|
24
|
+
const details = target.closest('details');
|
|
25
|
+
const label = details.querySelector('summary');
|
|
26
|
+
|
|
27
|
+
details.open = false;
|
|
28
|
+
label.focus();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
checkBreakpoint: (element, screenWidth) => {
|
|
34
|
+
let breakpoint = 0;
|
|
35
|
+
|
|
36
|
+
if (element.dataset.bp) {
|
|
37
|
+
const breakpointValue = element.dataset.bp.replace(/\D/g, '');
|
|
38
|
+
const breakpointUnit = element.dataset.bp.replace(/[0-9]/g, '');
|
|
39
|
+
let fontSize;
|
|
40
|
+
let conversionValue;
|
|
41
|
+
|
|
42
|
+
switch (breakpointUnit) {
|
|
43
|
+
case 'px':
|
|
44
|
+
breakpoint = breakpointValue;
|
|
45
|
+
break;
|
|
46
|
+
|
|
47
|
+
case 'em':
|
|
48
|
+
fontSize = window.getComputedStyle(document.querySelector('body'))['font-size'];
|
|
49
|
+
conversionValue = breakpointValue * parseFloat(fontSize);
|
|
50
|
+
breakpoint = conversionValue;
|
|
51
|
+
break;
|
|
52
|
+
|
|
53
|
+
case 'rem':
|
|
54
|
+
fontSize = window.getComputedStyle(document.querySelector('body'))['font-size'];
|
|
55
|
+
conversionValue = breakpointValue * parseFloat(fontSize);
|
|
56
|
+
breakpoint = conversionValue;
|
|
57
|
+
break;
|
|
58
|
+
|
|
59
|
+
default:
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (screenWidth > breakpoint) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return true;
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default accordion;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
{% from "./accordion/_macro.njk" import MdsAccordion %}
|
|
2
2
|
|
|
3
3
|
<h3>{{ name }}</h3>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
ariaLabel: ariaLabel,
|
|
22
|
-
ariaLabelActive: ariaLabelActive
|
|
23
|
-
}) }}
|
|
4
|
+
<p>
|
|
5
|
+
{% call MdsAccordion({
|
|
6
|
+
label: label,
|
|
7
|
+
labelOpen: labelOpen,
|
|
8
|
+
labelClasses: labelClasses,
|
|
9
|
+
icon: icon,
|
|
10
|
+
iconOpen: iconOpen,
|
|
11
|
+
noIcon: noIcon,
|
|
12
|
+
startsOpen: startsOpen,
|
|
13
|
+
nonClosing: nonClosing,
|
|
14
|
+
breakpoint: breakpoint,
|
|
15
|
+
leftAligned: leftAligned,
|
|
16
|
+
contentFirst: contentFirst
|
|
17
|
+
}) -%}
|
|
18
|
+
{{ content | safe }}
|
|
19
|
+
{%- endcall %}
|
|
20
|
+
</p>
|
|
@@ -1,32 +1,70 @@
|
|
|
1
|
-
.
|
|
2
|
-
display:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
.mds-accordion > summary {
|
|
2
|
+
display: flex;
|
|
3
|
+
text-align: left;
|
|
4
|
+
list-style: none;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
|
|
7
|
+
// https://stackoverflow.com/a/66814239
|
|
8
|
+
&::marker,
|
|
9
|
+
&::-webkit-details-marker {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
> * {
|
|
14
|
+
display: inline;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Open/closed labels and icons
|
|
19
|
+
.mds-accordion {
|
|
20
|
+
.mds-accordion__icon--open,
|
|
21
|
+
.mds-accordion__label--open {
|
|
22
|
+
display: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&[open] {
|
|
26
|
+
.mds-accordion__icon,
|
|
27
|
+
.mds-accordion__label {
|
|
28
|
+
display: none;
|
|
29
|
+
}
|
|
30
|
+
.mds-accordion__icon--open,
|
|
31
|
+
.mds-accordion__label--open {
|
|
32
|
+
display: inline;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Non-closing accordion
|
|
38
|
+
.mds-accordion.mds-accordion--non-closing[open] > summary {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// label below content
|
|
43
|
+
.mds-accordion.mds-accordion--content-first {
|
|
44
|
+
> .mds-accordion__label {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&[open] {
|
|
49
|
+
> summary {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.js & > .mds-accordion__label {
|
|
54
|
+
display: initial;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Icon alignment
|
|
60
|
+
.mds-accordion {
|
|
61
|
+
.mds-icon {
|
|
62
|
+
margin: 0 0 0 0.5em;
|
|
63
|
+
order: 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&.mds-accordion--left-aligned .mds-icon {
|
|
67
|
+
margin: 0 0.5em 0 0;
|
|
68
|
+
order: 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -142,15 +142,6 @@
|
|
|
142
142
|
display: flex;
|
|
143
143
|
align-items: center;
|
|
144
144
|
flex-wrap: wrap;
|
|
145
|
-
|
|
146
|
-
& .mds-accordion-trigger__button {
|
|
147
|
-
border: none; // helps with vertical alignment
|
|
148
|
-
padding: 0; // default padding on button creates too much space with next item (UJD-2017)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
& .mds-accordion-content {
|
|
152
|
-
width: 100%;
|
|
153
|
-
}
|
|
154
145
|
}
|
|
155
146
|
|
|
156
147
|
.mds-form-check__label {
|
|
@@ -228,3 +219,21 @@
|
|
|
228
219
|
.js .mds-form-element__fallback {
|
|
229
220
|
display: none;
|
|
230
221
|
}
|
|
222
|
+
|
|
223
|
+
// Filedset Accordion
|
|
224
|
+
.mds-form-check-container--border .mds-form-check .mds-checkbox-accordion__content {
|
|
225
|
+
width: 100%;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
html:not(.js) .mds-checkbox-accordion__button,
|
|
229
|
+
.mds-checkbox-accordion__icon,
|
|
230
|
+
.mds-checkbox-accordion__icon--open,
|
|
231
|
+
.mds-checkbox-accordion__button[aria-expanded='false'] + .mds-checkbox-accordion__content {
|
|
232
|
+
display: none;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.mds-checkbox-accordion__button[aria-expanded='false'] .mds-checkbox-accordion__icon,
|
|
236
|
+
.mds-checkbox-accordion__button[aria-expanded='true'] .mds-checkbox-accordion__icon--open {
|
|
237
|
+
display: inline;
|
|
238
|
+
margin: 0 0 0 0.5em;
|
|
239
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{% from "../label/_macro.njk" import MdsInputLabel %}
|
|
2
2
|
{% from "../_message/_macro.njk" import MdsInputMessages %}
|
|
3
|
-
{% from "../../accordion/_macro.njk" import MdsAccordion %}
|
|
4
3
|
{% from "../../icons/_macro.njk" import MdsIcon %}
|
|
5
4
|
{% from "../_checkbox-elem/_macro.njk" import MdsCheckboxElem %}
|
|
6
5
|
|
|
@@ -64,29 +63,27 @@
|
|
|
64
63
|
optional: true
|
|
65
64
|
}) }}
|
|
66
65
|
{% if option.options and option.options.length %}
|
|
67
|
-
{%- set
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}) }}
|
|
76
|
-
</
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
isExpanded: accordionIsExpanded
|
|
89
|
-
}) }}
|
|
66
|
+
{%- set hiddenLabel %}{{ checkboxParams.i18n.accordionTrigger | default('Select options under {label}') | replace('{label}', option.labelText) | safe }}{% endset -%}
|
|
67
|
+
<button
|
|
68
|
+
class="mds-checkbox-accordion__button mds-button mds-button--plain mds-padding-b0
|
|
69
|
+
{%- if accordionIsExpanded %} mds-checkbox-accordion__button--open{% endif %}"
|
|
70
|
+
type="button"
|
|
71
|
+
>
|
|
72
|
+
<span class="mds-checkbox-accordion__label mds-visually-hidden">{{ hiddenLabel | safe }}</span>
|
|
73
|
+
{{- MdsIcon({ iconName: params.icon | default('chevron-right'), classes: "mds-checkbox-accordion__icon" }) -}}
|
|
74
|
+
{{- MdsIcon({ iconName: params.iconOpen | default('chevron-down'), classes: "mds-checkbox-accordion__icon--open" }) -}}
|
|
75
|
+
</button>
|
|
76
|
+
<fieldset class="mds-checkbox-accordion__content">
|
|
77
|
+
<legend class="mds-visually-hidden">{{ hiddenLabel | safe }}</legend>
|
|
78
|
+
<div class="mds-form-check__nested-container">
|
|
79
|
+
{{ createCheckboxes({
|
|
80
|
+
options: option.options,
|
|
81
|
+
selectedOptions: checkboxParams.selectedOptions,
|
|
82
|
+
name: checkboxParams.name,
|
|
83
|
+
disabled: checkboxParams.disabled
|
|
84
|
+
}) }}
|
|
85
|
+
</div>
|
|
86
|
+
</fieldset>
|
|
90
87
|
{% endif %}
|
|
91
88
|
</div>
|
|
92
89
|
{% endfor %}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const fieldsetAccordionClass = 'mds-checkbox-accordion__button';
|
|
2
|
+
const fieldsetAccordionExpandedClass = 'mds-checkbox-accordion__button--open';
|
|
3
|
+
|
|
4
|
+
const checkboxList = {
|
|
5
|
+
init: () => {
|
|
6
|
+
const fieldsetAccorions = document.querySelectorAll(`.${fieldsetAccordionClass}`);
|
|
7
|
+
|
|
8
|
+
fieldsetAccorions.forEach((label) => {
|
|
9
|
+
// Set initial expanded state
|
|
10
|
+
if (label.classList.contains(fieldsetAccordionExpandedClass)) {
|
|
11
|
+
label.setAttribute('aria-expanded', 'true');
|
|
12
|
+
} else {
|
|
13
|
+
label.setAttribute('aria-expanded', 'false');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Toggle expanded
|
|
17
|
+
label.addEventListener('click', () => {
|
|
18
|
+
if (label.getAttribute('aria-expanded') === 'true') {
|
|
19
|
+
label.setAttribute('aria-expanded', 'false');
|
|
20
|
+
} else {
|
|
21
|
+
label.setAttribute('aria-expanded', 'true');
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default checkboxList;
|
|
@@ -16,6 +16,13 @@ const fileUpload = {
|
|
|
16
16
|
const input = uploader.querySelector('input[type=file]');
|
|
17
17
|
const removeButton = uploader.querySelector(removeButtonClass);
|
|
18
18
|
|
|
19
|
+
document.addEventListener('readystatechange', () => {
|
|
20
|
+
if (input.files && input.files.length) {
|
|
21
|
+
fileNameContainer.textContent = input.files[0].name;
|
|
22
|
+
uploader.classList.add(selectedFileClass);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
19
26
|
input.addEventListener('change', () => {
|
|
20
27
|
if (input.files && input.files.length) {
|
|
21
28
|
fileNameContainer.textContent = input.files[0].name;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="32px" height="32px" viewBox="0 -3 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M30.904 4.33335C30.6691 3.92641 30.3308 3.58877 29.9234 3.35463C29.516 3.12049 29.0539 2.99816 28.584 3.00002H2.63736C2.17176 3.00514 1.71561 3.13208 1.3143 3.36822C0.912993 3.60436 0.580508 3.94146 0.349927 4.34599C0.119346 4.75051 -0.0012933 5.20837 1.04562e-05 5.67399C0.00131421 6.13962 0.124516 6.59679 0.357359 7.00002L13.3307 28.4267C13.5684 28.8185 13.9031 29.1425 14.3024 29.3674C14.7018 29.5922 15.1524 29.7103 15.6107 29.7103C16.069 29.7103 16.5196 29.5922 16.919 29.3674C17.3183 29.1425 17.653 28.8185 17.8907 28.4267L30.864 7.00002C31.1042 6.59816 31.2343 6.14015 31.2413 5.67205C31.2484 5.20394 31.132 4.74224 30.904 4.33335Z" fill="black"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="32px" height="32px" viewBox="0 -3 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M28.0799 13.72L6.66661 0.746667C6.2624 0.513287 5.80402 0.390086 5.33728 0.389377C4.87054 0.388668 4.41178 0.510475 4.00687 0.742626C3.60196 0.974776 3.26507 1.30914 3.02987 1.71229C2.79468 2.11544 2.66942 2.57327 2.66661 3.04V28.96C2.66238 29.4321 2.7836 29.8969 3.01786 30.3069C3.25212 30.7169 3.59102 31.0573 3.99994 31.2933C4.40784 31.5198 4.86672 31.6387 5.33328 31.6387C5.79984 31.6387 6.25871 31.5198 6.66661 31.2933L27.9999 18.32C28.3918 18.0823 28.7158 17.7476 28.9406 17.3483C29.1655 16.9489 29.2836 16.4983 29.2836 16.04C29.2836 15.5817 29.1655 15.1311 28.9406 14.7317C28.7158 14.3324 28.3918 13.9977 27.9999 13.76L28.0799 13.72Z" fill="black"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="32px" height="32px" viewBox="0 -3 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M31.2533 25.3333L18.28 3.90666C18.0423 3.5148 17.7076 3.19082 17.3082 2.96597C16.9089 2.74112 16.4583 2.623 16 2.623C15.5417 2.623 15.0911 2.74112 14.6917 2.96597C14.2923 3.19082 13.9577 3.5148 13.72 3.90666L0.746641 25.3333C0.513798 25.7366 0.390596 26.1937 0.389293 26.6594C0.387989 27.125 0.508629 27.5828 0.739209 27.9874C0.96979 28.3919 1.30227 28.729 1.70358 28.9651C2.10489 29.2013 2.56104 29.3282 3.02664 29.3333H28.9733C29.4389 29.3282 29.8951 29.2013 30.2964 28.9651C30.6977 28.729 31.0302 28.3919 31.2607 27.9874C31.4913 27.5828 31.612 27.125 31.6107 26.6594C31.6094 26.1937 31.4861 25.7366 31.2533 25.3333Z" fill="black"/>
|
|
3
|
+
</svg>
|
package/src/js/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import './webpack-public-path';
|
|
|
11
11
|
import './common';
|
|
12
12
|
import tabs from '../components/tabs/tabs';
|
|
13
13
|
import accordion from '../components/accordion/accordion';
|
|
14
|
+
import checkboxList from '../components/inputs/checkbox-list/checkbox-list';
|
|
14
15
|
import popovers from '../components/popover/popover';
|
|
15
16
|
import modals from '../components/modal/modal';
|
|
16
17
|
import fileUpload from '../components/inputs/file-upload/file-upload';
|
|
@@ -21,6 +22,7 @@ import prose from '../helpers/prose/prose';
|
|
|
21
22
|
document.addEventListener('DOMContentLoaded', () => {
|
|
22
23
|
tabs.init();
|
|
23
24
|
accordion.init();
|
|
25
|
+
checkboxList.init();
|
|
24
26
|
modals.init();
|
|
25
27
|
fileUpload.init();
|
|
26
28
|
characterCount.init();
|