@ons/design-system 45.0.0 → 45.1.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/accordion/_macro.njk +3 -1
- package/components/checkboxes/_macro.njk +7 -1
- package/components/collapsible/_collapsible.scss +10 -4
- package/components/collapsible/_macro.njk +14 -15
- package/components/collapsible/collapsible.js +2 -1
- package/components/field/_field.scss +10 -0
- package/components/field/_macro.njk +1 -1
- package/components/fieldset/_macro.njk +2 -2
- package/components/icons/_macro.njk +18 -18
- package/components/input/_macro.njk +4 -2
- package/components/lists/_macro.njk +73 -67
- package/components/question/_macro.njk +92 -20
- package/components/question/_question.scss +9 -1
- package/components/select/_macro.njk +2 -1
- package/components/summary/_macro.njk +3 -3
- package/components/table/_macro.njk +2 -2
- package/components/timeout-modal/_macro.njk +1 -1
- package/components/timeout-modal/timeout.dom.js +2 -1
- package/components/timeout-modal/timeout.js +9 -3
- package/css/census.css +1 -1
- package/css/main.css +1 -1
- package/js/abortable-fetch.js +55 -0
- package/js/analytics.js +70 -0
- package/js/cookies-functions.js +182 -0
- package/js/cookies-settings.dom.js +13 -0
- package/js/cookies-settings.js +105 -0
- package/js/domready.js +17 -0
- package/js/fetch.js +19 -0
- package/js/inpagelink.dom.js +13 -0
- package/js/inpagelink.js +31 -0
- package/js/main.js +27 -0
- package/js/polyfills.js +9 -0
- package/js/print-button.js +16 -0
- package/layout/_template.njk +242 -0
- package/package.json +5 -4
- package/scripts/main.es5.js +2 -2
- package/scripts/main.js +2 -2
- package/scss/objects/_spacing.scss +1 -3
- package/scss/utilities/_utilities.scss +1 -1
|
@@ -11,41 +11,78 @@
|
|
|
11
11
|
{% if params.readDescriptionFirst is defined and params.readDescriptionFirst == true %}
|
|
12
12
|
<div aria-hidden="true" {% if params.legendIsQuestionTitle is not defined %}class="ons-question__description"{% endif %}>{{ params.description | safe }}</div>
|
|
13
13
|
{% elif params.legendIsQuestionTitle is not defined %}
|
|
14
|
-
<div class="ons-question__description">{{ params.description | safe }}</div>
|
|
14
|
+
<div class="ons-question__description ons-u-mb-m">{{ params.description | safe }}</div>
|
|
15
15
|
{% else %}
|
|
16
16
|
{{ params.description | safe }}
|
|
17
17
|
{% endif %}
|
|
18
18
|
{% endset %}
|
|
19
19
|
|
|
20
20
|
{% set instHtml %}
|
|
21
|
-
<div class="ons-question__instruction ons-u-mb-
|
|
21
|
+
<div class="ons-question__instruction ons-u-mb-m">{{ params.instruction | safe }}</div>
|
|
22
|
+
{% endset %}
|
|
23
|
+
|
|
24
|
+
{% set questionDefinition %}
|
|
25
|
+
{% from "components/collapsible/_macro.njk" import onsCollapsible %}
|
|
26
|
+
{% call onsCollapsible({
|
|
27
|
+
"id": params.definition.id,
|
|
28
|
+
"titleTag": 'h2',
|
|
29
|
+
"classes": 'ons-u-mb-m',
|
|
30
|
+
"title": params.definition.title
|
|
31
|
+
}) %}
|
|
32
|
+
{% if params.definition.content %}
|
|
33
|
+
{{ params.definition.content | safe }}
|
|
34
|
+
{% endif %}
|
|
35
|
+
{% endcall %}
|
|
36
|
+
{% endset %}
|
|
37
|
+
|
|
38
|
+
{% set questionGuidance %}
|
|
39
|
+
{% from "components/panel/_macro.njk" import onsPanel %}
|
|
40
|
+
{% call onsPanel({
|
|
41
|
+
"classes": "ons-u-mb-m"
|
|
42
|
+
}) %}
|
|
43
|
+
{% if params.guidance.content is defined and params.guidance.content %}
|
|
44
|
+
{{ params.guidance.content | safe }}
|
|
45
|
+
{% endif %}
|
|
46
|
+
{% if params.guidance.lists is defined and params.guidance.lists %}
|
|
47
|
+
{%- for item in params.guidance.lists -%}
|
|
48
|
+
{% if item.listHeading is defined and item.listHeading %}
|
|
49
|
+
<h2 class="ons-u-fs-r--b">{{ item.listHeading }}</h2>
|
|
50
|
+
{% endif %}
|
|
51
|
+
{% if item.listLeadingLine is defined and item.listLeadingLine %}
|
|
52
|
+
<p>{{ item.listLeadingLine }}</h2>
|
|
53
|
+
{% endif %}
|
|
54
|
+
{% from "components/lists/_macro.njk" import onsList %}
|
|
55
|
+
{{
|
|
56
|
+
onsList({
|
|
57
|
+
"itemsList": item.itemsList
|
|
58
|
+
})
|
|
59
|
+
}}
|
|
60
|
+
{% endfor -%}
|
|
61
|
+
{% endif -%}
|
|
62
|
+
{% endcall %}
|
|
22
63
|
{% endset %}
|
|
23
64
|
|
|
24
65
|
<div
|
|
25
66
|
{% if params.id is defined and params.id %} id="{{ params.id }}"{% endif %}
|
|
26
|
-
class="ons-question{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}"
|
|
67
|
+
class="ons-question ons-u-mb-l{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}"
|
|
27
68
|
{% if params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
|
|
28
69
|
>
|
|
29
|
-
{% if params.legendIsQuestionTitle %}
|
|
70
|
+
{% if params.legendIsQuestionTitle is defined and params.legendIsQuestionTitle %}
|
|
30
71
|
{% from "components/fieldset/_macro.njk" import onsFieldset %}
|
|
31
72
|
|
|
32
73
|
{# Resolves caller issue in jijna: https://github.com/pallets/jinja/issues/371 #}
|
|
33
74
|
{% set content = caller() %}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{%
|
|
44
|
-
|
|
45
|
-
{% endif %}
|
|
46
|
-
|
|
47
|
-
{{ content }}
|
|
48
|
-
{% endcall %}
|
|
75
|
+
<div class="ons-question__answer ons-u-mb-m">
|
|
76
|
+
{% call onsFieldset({
|
|
77
|
+
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
78
|
+
"legend": titleHtml,
|
|
79
|
+
"description": descHtml if params.description is defined and params.description else '',
|
|
80
|
+
"legendClasses": params.legendClasses,
|
|
81
|
+
"legendTitleClasses": params.legendTitleClasses
|
|
82
|
+
}) %}
|
|
83
|
+
{{ content }}
|
|
84
|
+
{% endcall %}
|
|
85
|
+
</div>
|
|
49
86
|
|
|
50
87
|
{% else %}
|
|
51
88
|
<h1 id="question-title" class="ons-question__title">
|
|
@@ -60,8 +97,43 @@
|
|
|
60
97
|
{{- instHtml | safe -}}
|
|
61
98
|
{% endif %}
|
|
62
99
|
|
|
63
|
-
{
|
|
100
|
+
{% if params.definition is defined and params.definition %}
|
|
101
|
+
{{- questionDefinition | safe -}}
|
|
102
|
+
{% endif %}
|
|
103
|
+
|
|
104
|
+
{% if params.guidance is defined and params.guidance %}
|
|
105
|
+
{{- questionGuidance | safe -}}
|
|
106
|
+
{% endif %}
|
|
107
|
+
|
|
108
|
+
<div class="ons-question__answer ons-u-mb-m">
|
|
109
|
+
{{ caller () }}
|
|
110
|
+
</div>
|
|
64
111
|
{% endif %}
|
|
65
112
|
|
|
113
|
+
{% if params.justification is defined and params.justification %}
|
|
114
|
+
{% from "components/collapsible/_macro.njk" import onsCollapsible %}
|
|
115
|
+
{% call onsCollapsible({
|
|
116
|
+
"id": params.justification.id,
|
|
117
|
+
"titleTag": 'h2',
|
|
118
|
+
"classes": 'ons-u-mb-m',
|
|
119
|
+
"title": params.justification.title | default('Why we ask this question')
|
|
120
|
+
}) %}
|
|
121
|
+
{{ params.justification.content | safe }}
|
|
122
|
+
{% endcall %}
|
|
123
|
+
{% endif %}
|
|
66
124
|
</div>
|
|
125
|
+
|
|
126
|
+
{% if params.submitButton is defined and params.submitButton %}
|
|
127
|
+
{% from "components/button/_macro.njk" import onsButton %}
|
|
128
|
+
|
|
129
|
+
{{
|
|
130
|
+
onsButton({
|
|
131
|
+
"id": params.submitButton.id,
|
|
132
|
+
"submitType": params.submitButton.submitType,
|
|
133
|
+
"text": params.submitButton.text | default ('Save and continue'),
|
|
134
|
+
"classes": params.submitButton.classes,
|
|
135
|
+
"attributes": params.submitButton.attributes
|
|
136
|
+
})
|
|
137
|
+
}}
|
|
138
|
+
{% endif %}
|
|
67
139
|
{% endmacro %}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
margin: 1rem 0 0;
|
|
3
3
|
|
|
4
4
|
&__title {
|
|
5
|
-
|
|
5
|
+
@extend .ons-u-mb-m;
|
|
6
|
+
|
|
6
7
|
em,
|
|
7
8
|
.ons-highlight {
|
|
8
9
|
background-color: $color-highlight;
|
|
@@ -15,6 +16,13 @@
|
|
|
15
16
|
padding: 0 0.5rem;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
19
|
+
|
|
20
|
+
&__description {
|
|
21
|
+
p:last-of-type {
|
|
22
|
+
margin-bottom: 0 !important;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
&__instruction {
|
|
19
27
|
background-color: $color-instruction-tint;
|
|
20
28
|
border: 5px solid $color-instruction;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
{% endif %}
|
|
23
23
|
{% if group.headers is defined and group.headers and group.rows is defined and group.rows %}
|
|
24
24
|
<table class="ons-summary__items">
|
|
25
|
-
<thead class="ons-u-vh">
|
|
25
|
+
<thead {% if group.id is defined and group.id %}id="{{ group.id }}" {% endif %}class="ons-u-vh">
|
|
26
26
|
<tr>
|
|
27
27
|
{% for header in group.headers %}
|
|
28
28
|
<th>{{ header }}</th>
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
{% if row.error is defined and row.error %} {% set itemClass = " ons-summary__item--error" %}{% endif %}
|
|
36
36
|
{% if row.total is defined and row.total %} {% set itemClass = itemClass + " ons-summary__item--total" %}{% endif %}
|
|
37
37
|
|
|
38
|
-
<tbody class="ons-summary__item{{ itemClass }}">
|
|
38
|
+
<tbody {% if row.id is defined and row.id %}id="{{ row.id }}" {% endif %}class="ons-summary__item{{ itemClass }}">
|
|
39
39
|
{% if row.errorMessage is defined and row.errorMessage or (row.rowItems | length > 1 and row.rowTitle) %}
|
|
40
40
|
<tr class="ons-summary__row">
|
|
41
41
|
<th colspan="3" class="ons-summary__row-title ons-u-fs-r">{{ row.errorMessage or row.rowTitle }}</th>
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
{% endif %}
|
|
44
44
|
|
|
45
45
|
{% for rowItem in row.rowItems %}
|
|
46
|
-
<tr class="ons-summary__row{{ " ons-summary__row--has-values" if rowItem.valueList else "" }}">
|
|
46
|
+
<tr {% if rowItem.id is defined and rowItem.id %}id="{{ rowItem.id }}" {% endif %}class="ons-summary__row{{ " ons-summary__row--has-values" if rowItem.valueList else "" }}">
|
|
47
47
|
<td
|
|
48
48
|
class="ons-summary__item-title"
|
|
49
49
|
{% if rowItem.rowTitleAttributes is defined and rowItem.rowTitleAttributes %}{% for attribute, value in (rowItem.rowTitleAttributes.items() if rowItem.rowTitleAttributes is mapping and rowItem.rowTitleAttributes.items else rowItem.rowTitleAttributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<thead class="ons-table__head">
|
|
16
16
|
<tr class="ons-table__row">
|
|
17
17
|
{% for th in params.ths %}
|
|
18
|
-
<th scope="col" class="ons-table__header{{ '' +
|
|
18
|
+
<th scope="col" class="ons-table__header{{ ' ' + th.thClasses if th.thClasses is defined and th.thClasses }}{{ " ons-table__header--numeric" if th.numeric is defined and th.numeric }}"{% if th.ariaSort is defined and th.ariaSort %} aria-sort="{{- th.ariaSort | default('none') -}}"{% endif %}>
|
|
19
19
|
<span {% if 'sortable' in variants %}class="ons-u-vh"{% endif %}>{{- th.value -}}</span>
|
|
20
20
|
{% if 'sortable' in variants %}
|
|
21
21
|
{{
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
{% for tr in params.trs %}
|
|
34
34
|
<tr class="ons-table__row{{ " ons-table__row--highlight" if tr.highlight }}" {% if tr.name is defined and tr.name %} name="{{ tr.name }}"{% endif %} {% if tr.id is defined and tr.id %} id="{{ tr.id }}"{% endif %}>
|
|
35
35
|
{% for td in tr.tds %}
|
|
36
|
-
<td class="ons-table__cell
|
|
36
|
+
<td class="ons-table__cell{{ ' ' + td.tdClasses if td.tdClasses is defined and td.tdClasses }}{{ " ons-table__cell--numeric" if td.numeric is defined and td.numeric }}" {% if td.id is defined and td.id %} id="{{ td.id }}"{% endif %} {% if td.name is defined and td.name %} name="{{ td.name }}"{% endif %} {% if td.data is defined and td.data %} data-th="{{ td.data }}"{% endif %} {% if td.dataSort is defined and td.dataSort %} data-sort-value="{{ td.dataSort }}"{% endif %}>
|
|
37
37
|
{% if td.form is defined and td.form %}
|
|
38
38
|
<form action="{{ td.form.action }}" method="{{ td.form.method | default('POST')}}">
|
|
39
39
|
{{
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"classes": "ons-js-timeout-modal",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"data-redirect-url": params.redirectUrl,
|
|
9
|
-
"data-
|
|
9
|
+
"data-server-session-expires-at": params.sessionExpiresAt,
|
|
10
10
|
"data-show-modal-time": params.showModalTimeInSeconds,
|
|
11
11
|
"data-server-session-expiry-endpoint": params.serverSessionExpiryEndpoint,
|
|
12
12
|
"data-countdown-text": params.countdownText,
|
|
@@ -8,7 +8,8 @@ async function modals() {
|
|
|
8
8
|
|
|
9
9
|
timeouts.forEach(context => {
|
|
10
10
|
let url = context.getAttribute('data-server-session-expiry-endpoint');
|
|
11
|
-
|
|
11
|
+
let time = context.getAttribute('data-server-session-expires-at');
|
|
12
|
+
new Timeout(context, url, time);
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -34,7 +34,12 @@ export default class Timeout {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
async initialise() {
|
|
37
|
-
this.
|
|
37
|
+
if (this.initialExpiryTime && this.sessionExpiryEndpoint) {
|
|
38
|
+
this.expiryTime = this.initialExpiryTime;
|
|
39
|
+
} else {
|
|
40
|
+
this.expiryTime = await this.setNewExpiryTime();
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
this.expiryTimeInMilliseconds = this.convertTimeToMilliSeconds(this.expiryTime);
|
|
39
44
|
|
|
40
45
|
this.bindEventListeners();
|
|
@@ -164,7 +169,8 @@ export default class Timeout {
|
|
|
164
169
|
if (!canSetNewExpiry) {
|
|
165
170
|
this.redirect();
|
|
166
171
|
} else {
|
|
167
|
-
this.
|
|
172
|
+
const newExpiryTimeInMilliseconds = this.convertTimeToMilliSeconds(canSetNewExpiry).toString();
|
|
173
|
+
this.closeModalAndRestartTimeout(newExpiryTimeInMilliseconds);
|
|
168
174
|
}
|
|
169
175
|
}
|
|
170
176
|
}
|
|
@@ -202,7 +208,7 @@ export default class Timeout {
|
|
|
202
208
|
method: fetchMethod,
|
|
203
209
|
headers: { 'Cache-Control': 'no-cache', 'Content-type': 'application/json; charset=UTF-8' },
|
|
204
210
|
});
|
|
205
|
-
if (
|
|
211
|
+
if (response.status === 401) {
|
|
206
212
|
this.redirect();
|
|
207
213
|
return false;
|
|
208
214
|
}
|