@ons/design-system 45.2.0 → 46.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/address-input/autosuggest.address.js +93 -118
- package/components/autosuggest/autosuggest.js +3 -11
- package/components/autosuggest/autosuggest.ui.js +3 -10
- package/components/button/_button.scss +1 -1
- package/components/button/_macro.njk +4 -1
- package/components/fieldset/_macro.njk +20 -18
- package/components/footer/_footer.scss +6 -0
- package/components/footer/_macro.njk +5 -2
- package/components/header/_macro.njk +1 -1
- package/components/label/_macro.njk +15 -15
- package/components/lists/_macro.njk +9 -13
- package/components/pagination/_macro.njk +2 -2
- package/css/census.css +1 -1
- package/css/main.css +1 -1
- package/js/abortable-fetch.js +13 -38
- package/js/inpagelink.js +6 -8
- package/layout/_template.njk +32 -4
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +2 -2
- package/scss/main.scss +1 -1
- package/components/header-navigation/_macro.njk +0 -0
- package/components/highlight/_highlight.scss +0 -5
|
@@ -74,81 +74,68 @@ export default class AutosuggestAddress {
|
|
|
74
74
|
this.checkAPIStatus();
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
checkAPIStatus() {
|
|
77
|
+
async checkAPIStatus() {
|
|
78
78
|
this.fetch = abortableFetch(this.lookupURL + 'CF142&limit=10', {
|
|
79
79
|
method: 'GET',
|
|
80
80
|
headers: this.setAuthorization(this.authorizationToken),
|
|
81
81
|
});
|
|
82
|
-
|
|
83
|
-
.send()
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (status > 400) {
|
|
87
|
-
if (this.isEditable) {
|
|
88
|
-
this.handleAPIError();
|
|
89
|
-
} else {
|
|
90
|
-
this.autosuggest.handleNoResults(status);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
.catch(error => {
|
|
95
|
-
console.log(error);
|
|
82
|
+
try {
|
|
83
|
+
const response = await this.fetch.send();
|
|
84
|
+
const status = (await response.json()).status.code;
|
|
85
|
+
if (status > 400) {
|
|
96
86
|
if (this.isEditable) {
|
|
97
87
|
this.handleAPIError();
|
|
98
88
|
} else {
|
|
99
89
|
this.autosuggest.handleNoResults(status);
|
|
100
90
|
}
|
|
101
|
-
}
|
|
91
|
+
}
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.log(error);
|
|
94
|
+
if (this.isEditable) {
|
|
95
|
+
this.handleAPIError();
|
|
96
|
+
} else {
|
|
97
|
+
this.autosuggest.handleNoResults(status);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
suggestAddresses(query, [], grouped) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
102
|
+
async suggestAddresses(query, [], grouped) {
|
|
103
|
+
if (this.fetch && this.fetch.status !== 'DONE') {
|
|
104
|
+
this.fetch.abort();
|
|
105
|
+
}
|
|
109
106
|
|
|
110
|
-
|
|
111
|
-
this.findAddress(query, grouped)
|
|
112
|
-
.then(resolve)
|
|
113
|
-
.catch(reject);
|
|
114
|
-
});
|
|
107
|
+
return await this.findAddress(query, grouped);
|
|
115
108
|
}
|
|
116
109
|
|
|
117
|
-
findAddress(text, grouped) {
|
|
118
|
-
|
|
119
|
-
let queryURL, fullQueryURL;
|
|
110
|
+
async findAddress(text, grouped) {
|
|
111
|
+
let queryURL, fullQueryURL;
|
|
120
112
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
if (this.manualQueryParams) {
|
|
114
|
+
const manualQueryParams = this.container.getAttribute('data-query-params');
|
|
115
|
+
fullQueryURL = this.lookupURL + text + manualQueryParams;
|
|
116
|
+
} else {
|
|
117
|
+
const fullPostcodeQuery = this.testFullPostcodeQuery(text);
|
|
118
|
+
let limit = fullPostcodeQuery ? 100 : 10;
|
|
127
119
|
|
|
128
|
-
|
|
120
|
+
queryURL = grouped ? this.lookupGroupURL + this.groupQuery : this.lookupURL + text + '&limit=' + limit;
|
|
129
121
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
122
|
+
fullQueryURL = this.generateURLParams(queryURL);
|
|
123
|
+
if (fullPostcodeQuery && grouped !== false) {
|
|
124
|
+
fullQueryURL = fullQueryURL + '&groupfullpostcodes=combo';
|
|
134
125
|
}
|
|
126
|
+
}
|
|
135
127
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
140
|
-
this.fetch
|
|
141
|
-
.send()
|
|
142
|
-
.then(async data => {
|
|
143
|
-
const response = await data.json();
|
|
144
|
-
const status = response.status.code;
|
|
145
|
-
const addresses = response.response;
|
|
146
|
-
const limit = response.response.limit;
|
|
147
|
-
const results = await this.mapFindResults(addresses, limit, status);
|
|
148
|
-
resolve(results);
|
|
149
|
-
})
|
|
150
|
-
.catch(reject);
|
|
128
|
+
this.fetch = abortableFetch(fullQueryURL, {
|
|
129
|
+
method: 'GET',
|
|
130
|
+
headers: this.setAuthorization(this.authorizationToken),
|
|
151
131
|
});
|
|
132
|
+
const data = await this.fetch.send();
|
|
133
|
+
const response = await data.json();
|
|
134
|
+
const status = response.status.code;
|
|
135
|
+
const addresses = response.response;
|
|
136
|
+
const limit = response.response.limit;
|
|
137
|
+
const results = await this.mapFindResults(addresses, limit, status);
|
|
138
|
+
return results;
|
|
152
139
|
}
|
|
153
140
|
|
|
154
141
|
async mapFindResults(results, limit, status) {
|
|
@@ -262,75 +249,66 @@ export default class AutosuggestAddress {
|
|
|
262
249
|
}
|
|
263
250
|
}
|
|
264
251
|
|
|
265
|
-
retrieveAddress(id, type = null) {
|
|
266
|
-
|
|
267
|
-
let retrieveUrl = this.retrieveURL + id;
|
|
268
|
-
|
|
269
|
-
const fullUPRNURL = this.generateURLParams(retrieveUrl, id, type);
|
|
252
|
+
async retrieveAddress(id, type = null) {
|
|
253
|
+
let retrieveUrl = this.retrieveURL + id;
|
|
270
254
|
|
|
271
|
-
|
|
272
|
-
method: 'GET',
|
|
273
|
-
headers: this.setAuthorization(this.authorizationToken),
|
|
274
|
-
});
|
|
255
|
+
const fullUPRNURL = this.generateURLParams(retrieveUrl, id, type);
|
|
275
256
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const data = await response.json();
|
|
280
|
-
resolve(data);
|
|
281
|
-
})
|
|
282
|
-
.catch(reject);
|
|
257
|
+
this.fetch = abortableFetch(fullUPRNURL, {
|
|
258
|
+
method: 'GET',
|
|
259
|
+
headers: this.setAuthorization(this.authorizationToken),
|
|
283
260
|
});
|
|
261
|
+
|
|
262
|
+
const response = await this.fetch.send();
|
|
263
|
+
const data = await response.json();
|
|
264
|
+
return data;
|
|
284
265
|
}
|
|
285
266
|
|
|
286
|
-
onAddressSelect(selectedResult) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
this.retrieveAddress(selectedResult.uprn, selectedResult.type)
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
reject();
|
|
313
|
-
});
|
|
314
|
-
} else if (selectedResult.postcode) {
|
|
315
|
-
this.autosuggest.input.value =
|
|
316
|
-
selectedResult.streetName +
|
|
317
|
-
', ' +
|
|
318
|
-
(selectedResult.townName === selectedResult.postTown
|
|
319
|
-
? selectedResult.postTown
|
|
320
|
-
: selectedResult.townName + ', ' + selectedResult.postTown) +
|
|
321
|
-
', ' +
|
|
322
|
-
selectedResult.postcode;
|
|
323
|
-
this.autosuggest.input.focus();
|
|
324
|
-
this.groupQuery =
|
|
325
|
-
'postcode=' + selectedResult.postcode + '&streetname=' + selectedResult.streetName + '&townname=' + selectedResult.townName;
|
|
326
|
-
this.autosuggest.handleChange(true);
|
|
267
|
+
async onAddressSelect(selectedResult) {
|
|
268
|
+
if (selectedResult.uprn) {
|
|
269
|
+
try {
|
|
270
|
+
const data = await this.retrieveAddress(selectedResult.uprn, selectedResult.type);
|
|
271
|
+
if (this.isEditable) {
|
|
272
|
+
if (data.status.code >= 403) {
|
|
273
|
+
this.autosuggest.handleNoResults(403);
|
|
274
|
+
} else {
|
|
275
|
+
this.addressSetter.setAddress(this.createAddressLines(data));
|
|
276
|
+
this.addressSelected = true;
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
this.selectedAddressValue = selectedResult.displayText;
|
|
280
|
+
this.autosuggest.input.value = selectedResult.displayText;
|
|
281
|
+
this.uprn.value = selectedResult.uprn;
|
|
282
|
+
this.addressSelected = true;
|
|
283
|
+
}
|
|
284
|
+
} catch (error) {
|
|
285
|
+
console.log(error);
|
|
286
|
+
if (this.isEditable) {
|
|
287
|
+
this.handleAPIError();
|
|
288
|
+
} else {
|
|
289
|
+
this.autosuggest.handleNoResults(403);
|
|
290
|
+
}
|
|
291
|
+
throw error;
|
|
327
292
|
}
|
|
328
|
-
})
|
|
293
|
+
} else if (selectedResult.postcode) {
|
|
294
|
+
this.autosuggest.input.value =
|
|
295
|
+
selectedResult.streetName +
|
|
296
|
+
', ' +
|
|
297
|
+
(selectedResult.townName === selectedResult.postTown
|
|
298
|
+
? selectedResult.postTown
|
|
299
|
+
: selectedResult.townName + ', ' + selectedResult.postTown) +
|
|
300
|
+
', ' +
|
|
301
|
+
selectedResult.postcode;
|
|
302
|
+
this.autosuggest.input.focus();
|
|
303
|
+
this.groupQuery =
|
|
304
|
+
'postcode=' + selectedResult.postcode + '&streetname=' + selectedResult.streetName + '&townname=' + selectedResult.townName;
|
|
305
|
+
this.autosuggest.handleChange(true);
|
|
306
|
+
}
|
|
329
307
|
}
|
|
330
308
|
|
|
331
|
-
createAddressLines(data
|
|
309
|
+
createAddressLines(data) {
|
|
332
310
|
const values = data.response.address;
|
|
333
|
-
|
|
311
|
+
return {
|
|
334
312
|
addressLine1: values.addressLine1,
|
|
335
313
|
addressLine2: values.addressLine2,
|
|
336
314
|
addressLine3: values.addressLine3,
|
|
@@ -338,9 +316,6 @@ export default class AutosuggestAddress {
|
|
|
338
316
|
postcode: values.postcode,
|
|
339
317
|
uprn: values.uprn,
|
|
340
318
|
};
|
|
341
|
-
resolve();
|
|
342
|
-
|
|
343
|
-
return addressLines;
|
|
344
319
|
}
|
|
345
320
|
|
|
346
321
|
generateURLParams(baseURL, uprn, type) {
|
|
@@ -14,19 +14,11 @@ export default class Autosuggest {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
onSelect(result) {
|
|
18
|
-
|
|
19
|
-
this.autosuggest.input.value = result.displayText;
|
|
20
|
-
|
|
21
|
-
resolve();
|
|
22
|
-
});
|
|
17
|
+
async onSelect(result) {
|
|
18
|
+
this.autosuggest.input.value = result.displayText;
|
|
23
19
|
}
|
|
24
20
|
|
|
25
|
-
onUnsetResult() {
|
|
26
|
-
return new Promise(resolve => {
|
|
27
|
-
resolve();
|
|
28
|
-
});
|
|
29
|
-
}
|
|
21
|
+
async onUnsetResult() {}
|
|
30
22
|
|
|
31
23
|
onError(error) {
|
|
32
24
|
console.error(error);
|
|
@@ -120,17 +120,10 @@ export default class AutosuggestUI {
|
|
|
120
120
|
this.bindEventListeners();
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
fetchData() {
|
|
123
|
+
async fetchData() {
|
|
124
124
|
this.fetch = abortableFetch(this.autosuggestData);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
.send()
|
|
128
|
-
.then(async response => {
|
|
129
|
-
this.data = await response.json();
|
|
130
|
-
resolve(this.data);
|
|
131
|
-
})
|
|
132
|
-
.catch(reject);
|
|
133
|
-
});
|
|
125
|
+
const response = await this.fetch.send();
|
|
126
|
+
this.data = await response.json();
|
|
134
127
|
}
|
|
135
128
|
|
|
136
129
|
bindEventListeners() {
|
|
@@ -29,9 +29,12 @@
|
|
|
29
29
|
{% set iconType = "loader" %}
|
|
30
30
|
{% set iconPosition = "after" %}
|
|
31
31
|
{# CTA or mobile menu toggle #}
|
|
32
|
-
{% elif params.
|
|
32
|
+
{% elif params.buttonStyle is defined and params.buttonStyle == "mobile" %}
|
|
33
33
|
{% set iconType = "chevron" %}
|
|
34
34
|
{% set iconPosition = "after" %}
|
|
35
|
+
{% elif params.url is defined and params.url %}
|
|
36
|
+
{% set iconType = "arrow-next" %}
|
|
37
|
+
{% set iconPosition = "after" %}
|
|
35
38
|
{% endif %}
|
|
36
39
|
{% endif %}
|
|
37
40
|
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
{% from "components/error/_macro.njk" import onsError %}
|
|
2
2
|
|
|
3
3
|
{% macro onsFieldset(params) %}
|
|
4
|
-
{% set fieldset
|
|
5
|
-
{% if params.dontWrap is defined and params.dontWrap
|
|
4
|
+
{% set fieldset -%}
|
|
5
|
+
{% if params.dontWrap is defined and params.dontWrap -%}
|
|
6
6
|
<div class="ons-input-items">
|
|
7
|
-
{{ caller() }}
|
|
7
|
+
{{- caller() -}}
|
|
8
8
|
</div>
|
|
9
|
-
{
|
|
9
|
+
{%- elif (params.legend is defined and params.legend) or (params.legendIsQuestionTitle is defined and params.legendIsQuestionTitle) -%}
|
|
10
10
|
<fieldset
|
|
11
11
|
{% if params.id is defined and params.id %}id="{{ params.id }}"{% endif %}
|
|
12
12
|
class="ons-fieldset{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}"
|
|
13
13
|
{% 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 %}
|
|
14
14
|
>
|
|
15
15
|
<legend class="ons-fieldset__legend{% if params.legendIsQuestionTitle is defined and params.legendIsQuestionTitle %} ons-u-mb-no{% endif %}{% if params.legendClasses is defined and params.legendClasses %} {{ params.legendClasses }}{% endif %}">
|
|
16
|
-
{
|
|
16
|
+
{%- if params.legendIsQuestionTitle -%}
|
|
17
17
|
<h1 id="fieldset-legend-title" class="ons-fieldset__legend-title ons-u-mb-m{% if params.legendTitleClasses is defined and params.legendTitleClasses %} {{ params.legendTitleClasses }}{% endif %}">
|
|
18
18
|
{{- params.legend | safe -}}
|
|
19
19
|
</h1>
|
|
20
|
-
{
|
|
20
|
+
{%- else -%}
|
|
21
21
|
{{- params.legend | safe -}}
|
|
22
|
-
{
|
|
23
|
-
{
|
|
24
|
-
<div class="ons-fieldset__description{% if params.legendIsQuestionTitle %} ons-fieldset__description--title ons-u-mb-m{% endif %}">
|
|
25
|
-
|
|
22
|
+
{%- endif -%}
|
|
23
|
+
{%- if params.description is defined and params.description -%}
|
|
24
|
+
<div class="ons-fieldset__description{% if params.legendIsQuestionTitle %} ons-fieldset__description--title ons-u-mb-m{% endif %}">
|
|
25
|
+
{{- params.description | safe -}}
|
|
26
|
+
</div>
|
|
27
|
+
{%- endif -%}
|
|
26
28
|
</legend>
|
|
27
|
-
{{ caller() }}
|
|
29
|
+
{{- caller() -}}
|
|
28
30
|
</fieldset>
|
|
29
|
-
{
|
|
30
|
-
{
|
|
31
|
+
{%- endif %}
|
|
32
|
+
{%- endset %}
|
|
31
33
|
|
|
32
|
-
{% if params.error is defined and params.error
|
|
34
|
+
{% if params.error is defined and params.error -%}
|
|
33
35
|
{% call onsError(params.error) %}
|
|
34
|
-
{{ fieldset | safe }}
|
|
36
|
+
{{- fieldset | safe -}}
|
|
35
37
|
{% endcall %}
|
|
36
|
-
{
|
|
37
|
-
{{ fieldset | safe }}
|
|
38
|
-
{
|
|
38
|
+
{%- else -%}
|
|
39
|
+
{{- fieldset | safe -}}
|
|
40
|
+
{%- endif %}
|
|
39
41
|
{% endmacro %}
|
|
@@ -86,7 +86,9 @@
|
|
|
86
86
|
"value": params.button.value,
|
|
87
87
|
"attributes": params.button.attributes,
|
|
88
88
|
"url": params.button.url,
|
|
89
|
-
"buttonStyle": params.button.buttonStyle
|
|
89
|
+
"buttonStyle": params.button.buttonStyle,
|
|
90
|
+
"iconType": params.button.iconType,
|
|
91
|
+
"iconPosition": params.button.iconPosition
|
|
90
92
|
})
|
|
91
93
|
}}
|
|
92
94
|
</div>
|
|
@@ -161,6 +163,7 @@
|
|
|
161
163
|
<div class="ons-grid__col">
|
|
162
164
|
{{
|
|
163
165
|
onsList({
|
|
166
|
+
"classes": "ons-footer--rows",
|
|
164
167
|
"variants": ["bare", "inline"],
|
|
165
168
|
"itemsList": row.itemsList
|
|
166
169
|
})
|
|
@@ -225,7 +228,7 @@
|
|
|
225
228
|
<div class="ons-grid__col">
|
|
226
229
|
{{
|
|
227
230
|
onsList({
|
|
228
|
-
"classes": 'ons-u-mb-m',
|
|
231
|
+
"classes": 'ons-u-mb-m ons-footer--rows',
|
|
229
232
|
"variants": ['bare', 'inline'],
|
|
230
233
|
"itemsList": legal.itemsList
|
|
231
234
|
})
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"buttonStyle": "mobile",
|
|
132
132
|
"variants": ["mobile", "ghost"],
|
|
133
133
|
"attributes": {
|
|
134
|
-
"aria-label": params.toggleButton.ariaLabel | default("Toggle main
|
|
134
|
+
"aria-label": params.toggleButton.ariaLabel | default("Toggle main menu") ,
|
|
135
135
|
"aria-controls": params.navigation.id,
|
|
136
136
|
"aria-haspopup": "true",
|
|
137
137
|
"aria-expanded": "false"
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{% macro onsLabel(params) %}
|
|
2
|
-
{% set field
|
|
2
|
+
{% set field -%}
|
|
3
3
|
<span
|
|
4
4
|
{% if params.id is defined and params.id %} id="{{ params.id }}-description-hint"{% else %}id="description-hint"{% endif %}
|
|
5
5
|
class="ons-label__description {% if params.inputType is defined and params.inputType %}ons-{{ params.inputType }}__label--with-description{% else %} ons-input--with-description{% endif %}">
|
|
6
|
-
{{ params.description }}
|
|
6
|
+
{{- params.description -}}
|
|
7
7
|
</span>
|
|
8
|
-
{
|
|
8
|
+
{%- endset %}
|
|
9
9
|
|
|
10
10
|
<label
|
|
11
|
-
class="{% if params.inputType is not defined
|
|
11
|
+
class="{% if params.inputType is not defined -%}ons-label{%- endif %}{{- ' ' + params.classes if params.classes else "" -}}{%- if params.description is defined and params.description %} ons-label--with-description{%- endif %} {{- ' ons-label--placeholder' if params.accessiblePlaceholder else "" -}}"
|
|
12
12
|
{% if params.for is defined and params.for %} for="{{ params.for }}"{% endif %}
|
|
13
13
|
{% if params.id is defined and params.id %} id="{{ params.id }}"{% endif %}
|
|
14
14
|
{% 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 %}
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
|
|
17
17
|
{{- params.text | safe -}}
|
|
18
18
|
|
|
19
|
-
{
|
|
20
|
-
{% if params.inputType == "checkbox" or params.inputType == "radio"
|
|
21
|
-
{%- if params.description is defined and params.description
|
|
22
|
-
{{ field | safe }}
|
|
23
|
-
{
|
|
24
|
-
{
|
|
19
|
+
{%- if params.inputType is defined and params.inputType -%}
|
|
20
|
+
{% if params.inputType == "checkbox" or params.inputType == "radio" -%}
|
|
21
|
+
{%- if params.description is defined and params.description -%}
|
|
22
|
+
{{- field | safe -}}
|
|
23
|
+
{%- endif -%}
|
|
24
|
+
{%- endif -%}
|
|
25
25
|
</label>
|
|
26
|
-
{
|
|
26
|
+
{%- else -%}
|
|
27
27
|
</label>
|
|
28
|
-
{%- if params.description is defined and params.description
|
|
29
|
-
{{ field | safe }}
|
|
30
|
-
{
|
|
31
|
-
{
|
|
28
|
+
{%- if params.description is defined and params.description -%}
|
|
29
|
+
{{- field | safe -}}
|
|
30
|
+
{%- endif -%}
|
|
31
|
+
{%- endif %}
|
|
32
32
|
{% endmacro %}
|
|
@@ -13,23 +13,18 @@
|
|
|
13
13
|
{% set otherClasses = '' %}
|
|
14
14
|
{% endif %}
|
|
15
15
|
|
|
16
|
-
{% if params.element is defined and params.element %}
|
|
16
|
+
{% if params.element is defined and params.element and listLength > 1 %}
|
|
17
17
|
{% set listEl = params.element | lower %}
|
|
18
|
+
{% elif (params.element is defined and params.element == 'ol') and listLength < 2 %}
|
|
19
|
+
{% set listEl = 'p' %}
|
|
18
20
|
{% else %}
|
|
19
21
|
{% set listEl = 'ul' %}
|
|
20
22
|
{% endif %}
|
|
21
|
-
|
|
22
|
-
{% if (params.element is defined and params.element == 'ol') and listLength < 2 %}
|
|
23
|
-
<p {% if params.id is defined and params.id %}id="{{ params.id }}"{% endif %}{% if params.classes is defined and params.classes %} class="{{ params.classes -}}"{% endif %}>
|
|
24
|
-
{%- for item in params.itemsList -%}
|
|
25
|
-
{{ item.text }}
|
|
26
|
-
{%- endfor -%}
|
|
27
|
-
</p>
|
|
28
|
-
{% else %}
|
|
29
|
-
<{{listEl}} {% if params.id is defined and params.id %}id="{{ params.id }}"{% endif %}class="{% if listLength > 1 %}ons-list{% endif %}{% if params.classes is defined and params.classes %} {{ params.classes -}}{% endif %}{% if params.variants is defined and params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-list--{{ variant }}{% endfor %}{% else %} ons-list--{{ params.variants }}{% endif %}{% endif %}{% if otherClasses %} {{ otherClasses -}}{% endif %}">
|
|
23
|
+
<{{listEl}} {% if params.id is defined and params.id %}id="{{ params.id }}"{% endif %}class="{% if listLength > 1 or listEl == 'ul' %}ons-list{% else %}ons-list--p{% endif %}{% if params.classes is defined and params.classes %} {{ params.classes -}}{% endif %}{% if params.variants is defined and params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-list--{{ variant }}{% endfor %}{% else %} ons-list--{{ params.variants }}{% endif %}{% endif %}{% if otherClasses %} {{ otherClasses -}}{% endif %}">
|
|
30
24
|
{%- for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) -%}
|
|
25
|
+
{% if listLength > 1 or listEl == 'ul' %}
|
|
31
26
|
<li class="ons-list__item{% if item.listClasses is defined and item.listClasses %} {{ item.listClasses }}{% endif %}"{% if item.current is defined and item.current %} aria-current="true"{% endif %}>
|
|
32
|
-
|
|
27
|
+
{% endif %}
|
|
33
28
|
{% set itemText = item.text %}
|
|
34
29
|
|
|
35
30
|
{% if params.itemsList[0] is defined and item.iconType is defined and item.iconType %}
|
|
@@ -70,7 +65,7 @@
|
|
|
70
65
|
})
|
|
71
66
|
}}
|
|
72
67
|
{%- else -%}
|
|
73
|
-
<a href="{{ item.url }}" class="ons-list__link {% if item.
|
|
68
|
+
<a href="{{ item.url }}" class="ons-list__link {% if item.variants == 'inPageLink' %}ons-js-inpagelink {% endif %} {{ item.classes }}"{% if item.index is defined and item.index %} data-qa="list-item-{{ loop.index }}"{% endif %}{% if item.target is defined and item.target %} target="{{ item.target }}"{% endif %}{% if item.rel is defined and item.rel %} rel="{{ item.rel }}"{% endif %}>
|
|
74
69
|
{%- if item.prefix is defined and item.prefix -%}<span class="ons-u-vh">{{- item.prefix -}}</span>{%- endif -%} {{- itemText | safe -}}
|
|
75
70
|
{%- if item.target is defined and item.target == "_blank" -%}<span class="ons-u-vh">{{- item.screenreaderMessage | default("this link will open in a new tab") -}}</span>{%- endif -%}
|
|
76
71
|
</a>
|
|
@@ -94,8 +89,9 @@
|
|
|
94
89
|
}}
|
|
95
90
|
{%- endif -%} </span>
|
|
96
91
|
{%- endif -%}
|
|
92
|
+
{% if listLength > 1 or listEl == 'ul' %}
|
|
97
93
|
</li>
|
|
94
|
+
{% endif %}
|
|
98
95
|
{%- endfor -%}
|
|
99
96
|
</{{listEl}}>
|
|
100
|
-
{% endif %}
|
|
101
97
|
{% endmacro %}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
</li>
|
|
42
42
|
{% endif %}
|
|
43
43
|
{% if currentPageIndex > 4 %}
|
|
44
|
-
<li class="ons-pagination__item ons-
|
|
44
|
+
<li class="ons-pagination__item ons-pagination__item--gap">…</li>
|
|
45
45
|
{% endif %}
|
|
46
46
|
{% for page in params.pages %}
|
|
47
47
|
{% if loop.index >= middlePagesStart and loop.index <= middlePagesEnd %}
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
{% endif %}
|
|
64
64
|
{% endfor %}
|
|
65
65
|
{% if currentPageIndex < totalPages - 3 %}
|
|
66
|
-
<li class="ons-pagination__item ons-
|
|
66
|
+
<li class="ons-pagination__item ons-pagination__item--gap">…</li>
|
|
67
67
|
{% endif %}
|
|
68
68
|
{% if currentPageIndex < totalPages - 2 %}
|
|
69
69
|
{% set lastPage = params.pages | last %}
|