@ons/design-system 56.0.1 → 57.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/components/button/_macro.njk +1 -1
- package/components/button/_macro.spec.js +0 -10
- package/components/checkboxes/_checkbox-macro.njk +2 -2
- package/components/checkboxes/_checkbox-macro.spec.js +2 -2
- package/components/checkboxes/checkbox-with-fieldset.js +7 -9
- package/components/checkboxes/checkboxes.dom.js +3 -3
- package/components/date-input/_macro.spec.js +1 -2
- package/components/duration/_macro.spec.js +1 -2
- package/components/error/_macro.njk +1 -2
- package/components/navigation/_macro.njk +6 -6
- package/components/navigation/_macro.spec.js +39 -20
- package/components/panel/_macro.njk +1 -1
- package/components/panel/_macro.spec.js +14 -7
- package/components/radios/_macro.njk +2 -2
- package/components/radios/_macro.spec.js +2 -2
- package/components/radios/radio-with-fieldset.js +29 -0
- package/components/radios/radios.dom.js +7 -8
- package/components/radios/radios.spec.js +185 -77
- package/components/section-navigation/_macro.njk +1 -1
- package/components/summary/_summary.scss +4 -4
- package/css/census.css +243 -3
- package/css/error.css +1 -1
- package/css/ids.css +243 -2
- package/css/main.css +243 -1
- package/css/print.css +1 -1
- package/img/UKOpenGovernmentLicence-grey.svg +4 -1
- package/img/UKOpenGovernmentLicence.svg +13 -1
- package/img/card-placeholder.svg +14 -1
- package/img/census-landscape.svg +4514 -1
- package/img/census-logo-stacked-pos-billingual.png +0 -0
- package/img/census-logo-stacked-pos-cy.png +0 -0
- package/img/census-logo-stacked-pos-en.png +0 -0
- package/img/census-promo-banner.svg +489 -1
- package/img/circle-lines.svg +31 -1
- package/img/dummy-brand-logo.svg +6 -1
- package/img/icons--check.svg +3 -1
- package/img/icons--chevron-down.svg +3 -1
- package/img/its-about-us--dark.svg +4 -1
- package/img/its-about-us--light.svg +4 -1
- package/img/logo.svg +77 -1
- package/img/ni-syn-cyfrif--dark.svg +3 -1
- package/img/ni-syn-cyfrif--light.svg +3 -1
- package/img/nisra-logo-black-en.svg +4 -1
- package/img/ogl.svg +10 -1
- package/img/ons-logo-black-cy.svg +4 -1
- package/img/ons-logo-black-en.svg +4 -1
- package/img/people-mob.png +0 -0
- package/img/people.png +0 -0
- package/img/rehearsal-areas.svg +11 -1
- package/package.json +1 -4
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
|
@@ -16,16 +16,6 @@ describe('macro: button', () => {
|
|
|
16
16
|
expect($('#example-id').length).toBe(1);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it('is an `a` element when `dsExample` is truthy', () => {
|
|
20
|
-
const $ = cheerio.load(
|
|
21
|
-
renderComponent('button', {
|
|
22
|
-
dsExample: true,
|
|
23
|
-
}),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
expect($('a').length).toBe(1);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
19
|
it('has additionally provided `attributes`', () => {
|
|
30
20
|
const $ = cheerio.load(
|
|
31
21
|
renderComponent('button', {
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"legend": params.other.legend,
|
|
77
77
|
"legendClasses": params.other.legendClasses,
|
|
78
78
|
"attributes": params.other.attributes,
|
|
79
|
-
"classes": "ons-js-other-fieldset",
|
|
79
|
+
"classes": "ons-js-other-fieldset-checkbox",
|
|
80
80
|
"checkboxes": params.other.checkboxes,
|
|
81
81
|
"autoSelect": params.other.autoSelect
|
|
82
82
|
})
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"legend": params.other.legend,
|
|
92
92
|
"legendClasses": params.other.legendClasses,
|
|
93
93
|
"attributes": params.other.attributes,
|
|
94
|
-
"classes": "ons-js-other-fieldset",
|
|
94
|
+
"classes": "ons-js-other-fieldset-checkbox",
|
|
95
95
|
"radios": params.other.radios
|
|
96
96
|
})
|
|
97
97
|
}}
|
|
@@ -390,7 +390,7 @@ describe('macro: checkboxes/checkbox', () => {
|
|
|
390
390
|
legend: 'Select preferred times of day',
|
|
391
391
|
legendClasses: 'extra-legend-class',
|
|
392
392
|
attributes: { a: 42 },
|
|
393
|
-
classes: 'ons-js-other-fieldset',
|
|
393
|
+
classes: 'ons-js-other-fieldset-checkbox',
|
|
394
394
|
checkboxes: EXAMPLE_CHECKBOXES_ITEM_CHECKBOXES.other.checkboxes,
|
|
395
395
|
autoSelect: EXAMPLE_CHECKBOXES_ITEM_CHECKBOXES.other.autoSelect,
|
|
396
396
|
});
|
|
@@ -412,7 +412,7 @@ describe('macro: checkboxes/checkbox', () => {
|
|
|
412
412
|
legend: 'Select preferred times of day',
|
|
413
413
|
legendClasses: 'extra-legend-class',
|
|
414
414
|
attributes: { a: 42 },
|
|
415
|
-
classes: 'ons-js-other-fieldset',
|
|
415
|
+
classes: 'ons-js-other-fieldset-checkbox',
|
|
416
416
|
radios: EXAMPLE_CHECKBOXES_ITEM_RADIOS.other.radios,
|
|
417
417
|
});
|
|
418
418
|
});
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
export default class CheckboxWithFieldset {
|
|
2
|
-
constructor(
|
|
3
|
-
this.
|
|
4
|
-
this.
|
|
5
|
-
this.
|
|
6
|
-
this.selectAllChildrenInput = this.
|
|
7
|
-
this.childInputs = [...this.fieldset.querySelectorAll('input')];
|
|
2
|
+
constructor(context) {
|
|
3
|
+
this.context = context;
|
|
4
|
+
this.checkbox = context.querySelector('.ons-js-checkbox');
|
|
5
|
+
this.childInputs = [...this.context.querySelectorAll('input')];
|
|
6
|
+
this.selectAllChildrenInput = this.context.querySelector('.ons-js-select-all-children');
|
|
8
7
|
|
|
9
8
|
if (this.selectAllChildrenInput) {
|
|
10
9
|
this.selectAllChildrenInput.addEventListener('change', this.checkChildInputsOnSelect.bind(this));
|
|
11
10
|
} else {
|
|
12
|
-
this.
|
|
11
|
+
this.checkbox.addEventListener('change', this.uncheckChildInputsOnDeselect.bind(this));
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
|
|
@@ -20,8 +19,7 @@ export default class CheckboxWithFieldset {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
uncheckChildInputsOnDeselect() {
|
|
23
|
-
|
|
24
|
-
if (isOther && isOther.checked === false) {
|
|
22
|
+
if (this.checkbox.checked === false) {
|
|
25
23
|
this.childInputs.forEach(input => {
|
|
26
24
|
input.checked = false;
|
|
27
25
|
});
|
|
@@ -15,12 +15,12 @@ domready(async () => {
|
|
|
15
15
|
new CheckCheckbox(checkboxInput, openOther);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const otherFieldsets = [...document.querySelectorAll('.ons-js-other-fieldset')];
|
|
18
|
+
const otherFieldsets = [...document.querySelectorAll('.ons-js-other-fieldset-checkbox')];
|
|
19
19
|
if (otherFieldsets) {
|
|
20
20
|
const CheckboxWithInnerFieldset = (await import('./checkbox-with-fieldset')).default;
|
|
21
|
-
|
|
22
21
|
otherFieldsets.forEach(otherFieldset => {
|
|
23
|
-
|
|
22
|
+
const context = otherFieldset.closest('.ons-checkbox');
|
|
23
|
+
new CheckboxWithInnerFieldset(context);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -274,12 +274,11 @@ describe('macro: date input', () => {
|
|
|
274
274
|
|
|
275
275
|
faker.renderComponent('date-input', {
|
|
276
276
|
...EXAMPLE_DATE_SINGLE_FIELD,
|
|
277
|
-
error: { text: 'Enter a date that is after 1 January 2019'
|
|
277
|
+
error: { text: 'Enter a date that is after 1 January 2019' },
|
|
278
278
|
});
|
|
279
279
|
|
|
280
280
|
expect(errorSpy.occurrences[0]).toEqual({
|
|
281
281
|
text: 'Enter a date that is after 1 January 2019',
|
|
282
|
-
dsExample: false,
|
|
283
282
|
});
|
|
284
283
|
});
|
|
285
284
|
});
|
|
@@ -236,12 +236,11 @@ describe('macro: duration', () => {
|
|
|
236
236
|
|
|
237
237
|
faker.renderComponent('duration', {
|
|
238
238
|
...EXAMPLE_DURATION_SINGLE_FIELD,
|
|
239
|
-
error: { text: 'Put something else'
|
|
239
|
+
error: { text: 'Put something else' },
|
|
240
240
|
});
|
|
241
241
|
|
|
242
242
|
expect(errorSpy.occurrences[0]).toEqual({
|
|
243
243
|
text: 'Put something else',
|
|
244
|
-
dsExample: false,
|
|
245
244
|
});
|
|
246
245
|
});
|
|
247
246
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
{% from "components/autosuggest/_macro.njk" import onsAutosuggest %}
|
|
4
4
|
<div class="ons-navigation-wrapper{% if params.variants == 'neutral' %} ons-navigation-wrapper--neutral{% endif %}">
|
|
5
5
|
<div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth or params.navigation.fullWidth }}{{ ' ons-container--wide' if params.wide or params.navigation.wide }}">
|
|
6
|
-
{% if params.navigation.siteSearchAutosuggest
|
|
6
|
+
{% if params.navigation.siteSearchAutosuggest %}
|
|
7
7
|
<div class="ons-navigation-search ons-js-navigation-search">
|
|
8
8
|
{% set autosuggestClasses = "ons-input-search ons-input-search--icon" %}
|
|
9
9
|
{% set autosuggestLabelClasses = "ons-u-pl-m" %}
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
<nav class="ons-navigation ons-navigation--main ons-js-navigation" id="{{ params.navigation.id }}" aria-label="{{ params.navigation.ariaLabel | default("Main menu") }}" data-analytics="header-navigation">
|
|
42
42
|
<ul class="ons-navigation__list">
|
|
43
43
|
{% for item in (params.navigation.itemsList if params.navigation.itemsList is iterable else params.navigation.itemsList.items()) %}
|
|
44
|
-
<li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (
|
|
45
|
-
|
|
44
|
+
<li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and item.url in params.navigation.currentPath) }}">
|
|
45
|
+
<a class="ons-navigation__link" href="{{ item.url }}" {% if item.id %}id="{{ item.id }}" {% endif %}{% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %}>{{ item.title }}</a>
|
|
46
46
|
</li>
|
|
47
47
|
{% endfor %}
|
|
48
48
|
</ul>
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
<div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.navigation.fullWidth }}{{ ' ons-container--wide' if params.navigation.wide }}">
|
|
55
55
|
<ul class="ons-navigation__list ons-navigation__list">
|
|
56
56
|
{% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
|
|
57
|
-
<li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.
|
|
57
|
+
<li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and item.url in params.navigation.currentPath) }}">
|
|
58
58
|
<a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
|
|
59
59
|
</li>
|
|
60
60
|
{% endfor %}
|
|
@@ -80,14 +80,14 @@
|
|
|
80
80
|
<a class="ons-navigation__link" href="{{ params.navigation.subNavigation.overviewURL }}">{{ params.navigation.subNavigation.overviewText | default('Overview') }}</a>
|
|
81
81
|
</li>
|
|
82
82
|
{% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
|
|
83
|
-
<li class="ons-navigation__item {{ ' ons-navigation__item--active' if (item.url == params.navigation.subNavigation.currentPath) or (item.url
|
|
83
|
+
<li class="ons-navigation__item {{ ' ons-navigation__item--active' if (item.url == params.navigation.subNavigation.currentPath) or (item.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and item.url in params.navigation.currentPath) }}">
|
|
84
84
|
<a class="ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}--mobile" {% endif %}>{{ item.title }}</a>
|
|
85
85
|
{% if item.sections %}
|
|
86
86
|
{% for section in item.sections %}
|
|
87
87
|
{% if section.sectionTitle %}<h3 class="ons-navigation__list-header">{{ section.sectionTitle }}</h3>{% endif %}
|
|
88
88
|
<ul class="ons-navigation__list ons-navigation__list--child ons-list--dashed ons-u-ml-s ons-u-mt-xs">
|
|
89
89
|
{% for child in section.children %}
|
|
90
|
-
<li class="ons-navigation__item ons-list__item {{ ' ons-navigation__item--active' if (child.url == params.navigation.
|
|
90
|
+
<li class="ons-navigation__item ons-list__item {{ ' ons-navigation__item--active' if (child.url == params.navigation.currentPath) or (params.navigation.currentPath is not string and child.url in params.navigation.currentPath) }}">
|
|
91
91
|
<a class="ons-navigation__link ons-navigation__link--section" href="{{ child.url }}" {% if child.ariaLabel %}aria-label="{{ child.ariaLabel }}" {% endif %} {% if child.id %}id="{{ child.id }}" {% endif %}>{{ child.title }}</a>
|
|
92
92
|
</li>
|
|
93
93
|
{% endfor %}
|
|
@@ -9,7 +9,7 @@ import { mapAll } from '../../tests/helpers/cheerio';
|
|
|
9
9
|
const PARAMS = {
|
|
10
10
|
id: 'main-nav',
|
|
11
11
|
ariaLabel: 'Main menu',
|
|
12
|
-
currentPath: '#1',
|
|
12
|
+
currentPath: ['#1', '/sub-item-1', '/sub-item-2/child-item-1'],
|
|
13
13
|
currentPageTitle: 'Main nav item 2',
|
|
14
14
|
itemsList: [
|
|
15
15
|
{
|
|
@@ -32,19 +32,18 @@ const PARAMS = {
|
|
|
32
32
|
overviewURL: '#overview',
|
|
33
33
|
overviewText: 'Overview',
|
|
34
34
|
ariaLabel: 'Section menu',
|
|
35
|
-
currentPath: '#1',
|
|
36
35
|
itemsList: [
|
|
37
36
|
{
|
|
38
37
|
title: 'Sub nav item 1',
|
|
39
38
|
ariaLabel: 'Sub nav ariaLabel 1',
|
|
40
|
-
url: '
|
|
39
|
+
url: '/sub-item-1',
|
|
41
40
|
classes: 'custom-class-sub-item-1',
|
|
42
41
|
id: 'sub-item-1',
|
|
43
42
|
},
|
|
44
43
|
{
|
|
45
44
|
title: 'Sub nav item 2',
|
|
46
45
|
ariaLabel: 'Sub nav ariaLabel 2',
|
|
47
|
-
url: '
|
|
46
|
+
url: '/sub-item-2',
|
|
48
47
|
classes: 'custom-class-sub-item-2',
|
|
49
48
|
id: 'sub-item-2',
|
|
50
49
|
sections: [
|
|
@@ -54,12 +53,14 @@ const PARAMS = {
|
|
|
54
53
|
{
|
|
55
54
|
title: 'Child item 1',
|
|
56
55
|
ariaLabel: 'Child item ariaLabel 1',
|
|
57
|
-
url: '
|
|
56
|
+
url: '/sub-item-2/child-item-1',
|
|
57
|
+
id: 'child-item-1',
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
title: 'Child item 2',
|
|
61
61
|
ariaLabel: 'Child item ariaLabel 2',
|
|
62
|
-
url: '
|
|
62
|
+
url: '/sub-item-2/child-item-2',
|
|
63
|
+
id: 'child-item-2',
|
|
63
64
|
},
|
|
64
65
|
],
|
|
65
66
|
},
|
|
@@ -233,7 +234,7 @@ describe('macro: navigation', () => {
|
|
|
233
234
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
234
235
|
|
|
235
236
|
const values = mapAll($('.ons-navigation--sub .ons-navigation__link'), node => node.attr('href'));
|
|
236
|
-
expect(values).toEqual(['
|
|
237
|
+
expect(values).toEqual(['/sub-item-1', '/sub-item-2']);
|
|
237
238
|
});
|
|
238
239
|
|
|
239
240
|
it('has the correct link text for each list item', () => {
|
|
@@ -268,12 +269,22 @@ describe('macro: navigation', () => {
|
|
|
268
269
|
);
|
|
269
270
|
});
|
|
270
271
|
|
|
271
|
-
it('has the active class on the correct item', () => {
|
|
272
|
+
it('has the active class on the correct item when a single current path is provided', () => {
|
|
273
|
+
const $ = cheerio.load(
|
|
274
|
+
renderComponent('navigation', {
|
|
275
|
+
navigation: {
|
|
276
|
+
...PARAMS,
|
|
277
|
+
currentPath: '/sub-item-1',
|
|
278
|
+
},
|
|
279
|
+
}),
|
|
280
|
+
);
|
|
281
|
+
expect($('#sub-nav .ons-navigation__item--active > #sub-item-1').length).toBe(1);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it('has the active class on the correct item when multiple current paths are provided', () => {
|
|
272
285
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
273
286
|
|
|
274
|
-
expect(
|
|
275
|
-
$('.ons-navigation--sub .ons-navigation__list .ons-navigation__item:last-child').hasClass('ons-navigation__item--active'),
|
|
276
|
-
).toBe(true);
|
|
287
|
+
expect($('#sub-nav .ons-navigation__item--active > #sub-item-1').length).toBe(1);
|
|
277
288
|
});
|
|
278
289
|
});
|
|
279
290
|
|
|
@@ -297,7 +308,7 @@ describe('macro: navigation', () => {
|
|
|
297
308
|
$('.ons-navigation__list--parent > li a').not('.ons-navigation__list--parent li .ons-navigation__list--child a'),
|
|
298
309
|
node => node.attr('href'),
|
|
299
310
|
);
|
|
300
|
-
expect(values).toEqual(['#overview', '
|
|
311
|
+
expect(values).toEqual(['#overview', '/sub-item-1', '/sub-item-2']);
|
|
301
312
|
});
|
|
302
313
|
|
|
303
314
|
it('has the correct link text for each list item', () => {
|
|
@@ -310,12 +321,22 @@ describe('macro: navigation', () => {
|
|
|
310
321
|
expect(values).toEqual(['Overview', 'Sub nav item 1', 'Sub nav item 2']);
|
|
311
322
|
});
|
|
312
323
|
|
|
313
|
-
it('has the active class on the correct item', () => {
|
|
324
|
+
it('has the active class on the correct item when a single current path is provided', () => {
|
|
325
|
+
const $ = cheerio.load(
|
|
326
|
+
renderComponent('navigation', {
|
|
327
|
+
navigation: {
|
|
328
|
+
...PARAMS,
|
|
329
|
+
currentPath: '/sub-item-1',
|
|
330
|
+
},
|
|
331
|
+
}),
|
|
332
|
+
);
|
|
333
|
+
expect($('#sub-nav--mobile .ons-navigation__item--active > #sub-item-1--mobile').length).toBe(1);
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('has the active class on the correct item when multiple current paths are provided', () => {
|
|
314
337
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
315
338
|
|
|
316
|
-
expect(
|
|
317
|
-
$('.ons-navigation--sub-mobile .ons-navigation__list .ons-navigation__item:last-child').hasClass('ons-navigation__item--active'),
|
|
318
|
-
).toBe(true);
|
|
339
|
+
expect($('#sub-nav--mobile .ons-navigation__item--active > #sub-item-1--mobile').length).toBe(1);
|
|
319
340
|
});
|
|
320
341
|
|
|
321
342
|
it('has the correct text for the child section title', () => {
|
|
@@ -328,7 +349,7 @@ describe('macro: navigation', () => {
|
|
|
328
349
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
329
350
|
|
|
330
351
|
const values = mapAll($('.ons-navigation__list--child > li a'), node => node.attr('href'));
|
|
331
|
-
expect(values).toEqual(['
|
|
352
|
+
expect(values).toEqual(['/sub-item-2/child-item-1', '/sub-item-2/child-item-2']);
|
|
332
353
|
});
|
|
333
354
|
|
|
334
355
|
it('has the correct link text for each child list item', () => {
|
|
@@ -341,9 +362,7 @@ describe('macro: navigation', () => {
|
|
|
341
362
|
it('has the active class on the correct child item', () => {
|
|
342
363
|
const $ = cheerio.load(renderComponent('navigation', { navigation: PARAMS }));
|
|
343
364
|
|
|
344
|
-
expect(
|
|
345
|
-
$('.ons-navigation--sub-mobile .ons-navigation__list .ons-navigation__item:last-child').hasClass('ons-navigation__item--active'),
|
|
346
|
-
).toBe(true);
|
|
365
|
+
expect($('#sub-nav--mobile .ons-navigation__item--active > #child-item-1').length).toBe(1);
|
|
347
366
|
});
|
|
348
367
|
});
|
|
349
368
|
});
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<div class="ons-container">
|
|
32
32
|
{% endif %}
|
|
33
33
|
|
|
34
|
-
<div {% if (params.type == 'error' and params.title) or params.type == 'success' %}aria-labelledby="alert" role="alert" tabindex="-1" {% if
|
|
34
|
+
<div {% if (params.type == 'error' and params.title) or params.type == 'success' %}aria-labelledby="alert" role="alert" tabindex="-1" {% if not isDesignSystemExample %}autofocus="autofocus" {% endif %}{% endif %}class="ons-panel{{ typeClass }}{{ iconClass }}{{ noTitleClass }}{{ spaciousClass }}{{ classes }}"{% if params and params.attributes %}{% for attribute, value in (params.attributes.items() if params and params.attributes is mapping and params.attributes.items else params.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}{% if params and params.id %} id="{{params.id}}"{% endif %}>
|
|
35
35
|
|
|
36
36
|
{% if params.type == "warn" or params.type == "warn-branded" %}
|
|
37
37
|
<span class="ons-panel__icon" aria-hidden="true">!</span>
|
|
@@ -264,14 +264,21 @@ describe('macro: panel', () => {
|
|
|
264
264
|
expect($('.ons-panel').attr('autofocus')).toBe('autofocus');
|
|
265
265
|
});
|
|
266
266
|
|
|
267
|
-
it('does not have the autofocus attribute set if `
|
|
267
|
+
it('does not have the autofocus attribute set if `isDesignSystemExample` is provided', () => {
|
|
268
|
+
const isDesignSystemExample = true;
|
|
269
|
+
|
|
268
270
|
const $ = cheerio.load(
|
|
269
|
-
renderComponent(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
271
|
+
renderComponent(
|
|
272
|
+
'panel',
|
|
273
|
+
{
|
|
274
|
+
...EXAMPLE_PANEL_BASIC,
|
|
275
|
+
title: 'Title',
|
|
276
|
+
type: panelType,
|
|
277
|
+
},
|
|
278
|
+
null,
|
|
279
|
+
null,
|
|
280
|
+
isDesignSystemExample,
|
|
281
|
+
),
|
|
275
282
|
);
|
|
276
283
|
|
|
277
284
|
expect($('.ons-panel').attr('autofocus')).toBe(undefined);
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"legend": radio.other.legend,
|
|
95
95
|
"legendClasses": radio.other.legendClasses,
|
|
96
96
|
"attributes": radio.other.attributes,
|
|
97
|
-
"classes": "ons-js-other-fieldset",
|
|
97
|
+
"classes": "ons-js-other-fieldset-radio",
|
|
98
98
|
"checkboxes": radio.other.checkboxes,
|
|
99
99
|
"autoSelect": radio.other.autoSelect,
|
|
100
100
|
"selectAllChildren": radio.other.selectAllChildren
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"legend": radio.other.legend,
|
|
111
111
|
"legendClasses": radio.other.legendClasses | default('') + ' ons-u-mb-xs',
|
|
112
112
|
"attributes": radio.other.attributes,
|
|
113
|
-
"classes": "ons-js-other-fieldset",
|
|
113
|
+
"classes": "ons-js-other-fieldset-radio",
|
|
114
114
|
"radios": radio.other.radios
|
|
115
115
|
})
|
|
116
116
|
}}
|
|
@@ -512,7 +512,7 @@ describe('macro: radios', () => {
|
|
|
512
512
|
legend: 'Select preferred times of day',
|
|
513
513
|
legendClasses: 'extra-legend-class',
|
|
514
514
|
attributes: { a: 42 },
|
|
515
|
-
classes: 'ons-js-other-fieldset',
|
|
515
|
+
classes: 'ons-js-other-fieldset-radio',
|
|
516
516
|
checkboxes: EXAMPLE_RADIO_ITEM_CHECKBOXES.other.checkboxes,
|
|
517
517
|
autoSelect: EXAMPLE_RADIO_ITEM_CHECKBOXES.other.autoSelect,
|
|
518
518
|
selectAllChildren: true,
|
|
@@ -535,7 +535,7 @@ describe('macro: radios', () => {
|
|
|
535
535
|
legend: 'Select preferred times of day',
|
|
536
536
|
legendClasses: 'extra-legend-class ons-u-mb-xs',
|
|
537
537
|
attributes: { a: 42 },
|
|
538
|
-
classes: 'ons-js-other-fieldset',
|
|
538
|
+
classes: 'ons-js-other-fieldset-radio',
|
|
539
539
|
radios: EXAMPLE_RADIO_ITEM_RADIOS.other.radios,
|
|
540
540
|
});
|
|
541
541
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default class RadioWithFieldset {
|
|
2
|
+
constructor(context) {
|
|
3
|
+
this.context = context;
|
|
4
|
+
this.radios = [...context.closest('.ons-radios__items').querySelectorAll('.ons-js-radio')];
|
|
5
|
+
this.childInputs = [...this.context.querySelectorAll('input')];
|
|
6
|
+
this.selectAllChildrenInput = this.context.querySelector('.ons-js-select-all-children');
|
|
7
|
+
|
|
8
|
+
if (this.selectAllChildrenInput) {
|
|
9
|
+
this.selectAllChildrenInput.addEventListener('change', this.checkChildInputsOnSelect.bind(this));
|
|
10
|
+
} else {
|
|
11
|
+
this.radios.forEach(radio => radio.addEventListener('change', this.uncheckChildInputsOnDeselect.bind(this)));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
checkChildInputsOnSelect() {
|
|
16
|
+
this.childInputs.forEach(input => {
|
|
17
|
+
input.checked = this.selectAllChildrenInput.checked === true ? true : false;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
uncheckChildInputsOnDeselect() {
|
|
22
|
+
const isOther = this.radios.find(radio => radio.classList.contains('ons-js-other'));
|
|
23
|
+
if (isOther && isOther.checked === false) {
|
|
24
|
+
this.childInputs.forEach(input => {
|
|
25
|
+
input.checked = false;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -25,14 +25,13 @@ domready(async () => {
|
|
|
25
25
|
new CheckRadios(radioInput, openOther);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
28
|
+
const otherFieldsets = [...document.querySelectorAll('.ons-js-other-fieldset-radio')];
|
|
29
|
+
if (otherFieldsets) {
|
|
30
|
+
const RadioWithInnerFieldset = (await import('./radio-with-fieldset')).default;
|
|
31
|
+
otherFieldsets.forEach(otherFieldset => {
|
|
32
|
+
const context = otherFieldset.closest('.ons-radio');
|
|
33
|
+
new RadioWithInnerFieldset(context);
|
|
34
|
+
});
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
});
|