@ons/design-system 65.2.5 → 66.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.
@@ -110,17 +110,19 @@
110
110
  onsAutosuggest({
111
111
  "id": params.id + "-autosuggest",
112
112
  "classes": "ons-address-input__autosuggest ons-u-mb-no",
113
- "width": "50",
114
- "label": {
115
- "text": params.label.text,
116
- "id": params.label.id,
117
- "classes": "ons-js-autosuggest-label"
113
+ "input": {
114
+ "width": "50",
115
+ "label": {
116
+ "text": params.label.text,
117
+ "id": params.label.id,
118
+ "classes": "ons-js-autosuggest-label"
119
+ },
120
+ "value": params.value,
121
+ "attributes": params.attributes,
122
+ "error": params.error,
123
+ "name": params.name,
124
+ "mutuallyExclusive": params.mutuallyExclusive
118
125
  },
119
- "value": params.value,
120
- "attributes": params.attributes,
121
- "error": params.error,
122
- "name": params.name,
123
- "mutuallyExclusive": params.mutuallyExclusive,
124
126
  "externalInitialiser": true,
125
127
  "APIDomain": params.APIDomain,
126
128
  "APIDomainBearerToken": params.APIDomainBearerToken,
@@ -352,17 +352,19 @@ describe('macro: address-input', () => {
352
352
  expect(autosuggestSpy.occurrences[0]).toEqual({
353
353
  id: 'address-input-example-id-autosuggest',
354
354
  classes: 'ons-address-input__autosuggest ons-u-mb-no',
355
- width: '50',
356
- label: {
357
- text: '[params.label.text]',
358
- id: '[params.label.id]',
359
- classes: 'ons-js-autosuggest-label',
355
+ input: {
356
+ width: '50',
357
+ label: {
358
+ text: '[params.label.text]',
359
+ id: '[params.label.id]',
360
+ classes: 'ons-js-autosuggest-label',
361
+ },
362
+ value: '[params.value]',
363
+ attributes: '[params.attributes]',
364
+ error: '[params.error]',
365
+ name: '[params.name]',
366
+ mutuallyExclusive: '[params.mutuallyExclusive]',
360
367
  },
361
- value: '[params.value]',
362
- attributes: '[params.attributes]',
363
- error: '[params.error]',
364
- name: '[params.name]',
365
- mutuallyExclusive: '[params.mutuallyExclusive]',
366
368
  externalInitialiser: true,
367
369
  APIDomain: '[params.APIDomain]',
368
370
  APIDomainBearerToken: '[params.APIDomainBearerToken]',
@@ -37,37 +37,50 @@
37
37
  >
38
38
 
39
39
  {% set autosuggestResults %}
40
- <div class="ons-autosuggest__results ons-js-autosuggest-results{% if params.width %} ons-input--w-{{ params.width }}{% else %} ons-input--w-20{% endif %}">
40
+ <div class="ons-autosuggest__results ons-js-autosuggest-results{% if params.input.width %} ons-input--w-{{ params.input.width }}{% else %} ons-input--w-20{% endif %}">
41
41
  <div id="{{ params.resultsTitleId }}" class="ons-autosuggest__results-title ons-u-fs-s">{{ params.resultsTitle }}</div>
42
42
  <ul class="ons-autosuggest__listbox ons-js-autosuggest-listbox" title="{{ params.resultsTitle }}" role="listbox" id="{{ params.id }}-listbox" tabindex="-1"></ul>
43
43
  </div>
44
44
  <div class="ons-autosuggest__instructions ons-u-vh ons-js-autosuggest-instructions" id="{{ params.id }}-instructions" tabindex="-1">{{ params.instructions }}</div>
45
45
  <div class="ons-autosuggest__status ons-u-vh ons-js-autosuggest-aria-status" aria-live="assertive" aria-atomic="true" role="status" tabindex="-1"></div>
46
46
  {% endset %}
47
- {{ onsInput({
48
- "id": params.id,
49
- "classes": "ons-js-autosuggest-input " + (params.classes if params.classes else ''),
50
- "width": params.width,
51
- "label": {
52
- "text": params.label.text,
53
- "description": params.label.description,
54
- "id": params.label.id,
55
- "classes": params.label.classes
56
- },
57
- "autocomplete": params.autocomplete,
58
- "legend": params.legend,
59
- "legendClasses": params.legendClasses,
60
- "value": params.value,
61
- "attributes": params.attributes,
62
- "error": params.error,
63
- "mutuallyExclusive": params.mutuallyExclusive,
64
- "accessiblePlaceholder": params.accessiblePlaceholder,
65
- "name": params.name,
66
- "autosuggestResults": autosuggestResults
67
- }) }}
68
47
 
69
- {% if not params.mutuallyExclusive %}
70
- {{ autosuggestResults | safe }}
71
- {% endif %}
48
+ {{ onsInput({
49
+ "id": params.id,
50
+ "type": params.input.type,
51
+ "classes": "ons-js-autosuggest-input " + (params.input.classes if params.input.classes else ''),
52
+ "width": params.input.width,
53
+ "label": params.input.label,
54
+ "autocomplete": params.input.autocomplete,
55
+ "legend": params.input.legend,
56
+ "legendClasses": params.input.legendClasses,
57
+ "legendIsQuestionTitle": params.input.legendIsQuestionTitle,
58
+ "value": params.input.value,
59
+ "attributes": params.input.attributes,
60
+ "error": params.input.error,
61
+ "mutuallyExclusive": params.input.mutuallyExclusive,
62
+ "accessiblePlaceholder": params.input.accessiblePlaceholder,
63
+ "name": params.input.name,
64
+ "autosuggestResults": autosuggestResults,
65
+ "min": params.input.min,
66
+ "max": params.input.max,
67
+ "minLength": params.input.minLength,
68
+ "maxLength": params.input.maxLength,
69
+ "prefix": params.input.prefix,
70
+ "suffix": params.input.suffix,
71
+ "fieldId": params.input.fieldId,
72
+ "fieldClasses": params.input.fieldClasses,
73
+ "dontWrap": params.input.dontWrap,
74
+ "charCheckLimit": params.input.charCheckLimit,
75
+ "searchButton": params.input.searchButton,
76
+ "postTextboxLinkText": params.input.postTextboxLinkText,
77
+ "postTextboxLinkUrl": params.input.postTextboxLinkUrl,
78
+ "listeners": params.input.listeners
79
+ }) }}
80
+
81
+ {% if not params.mutuallyExclusive %}
82
+ {{ autosuggestResults | safe }}
83
+ {% endif %}
84
+
72
85
  </div>
73
86
  {% endmacro %}
@@ -7,13 +7,15 @@ import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
7
7
 
8
8
  const EXAMPLE_AUTOSUGGEST = {
9
9
  id: 'country-of-birth',
10
- label: {
11
- text: 'Current name of country',
12
- description: 'Enter your own answer or select from suggestions',
13
- id: 'country-of-birth-label',
14
- classes: 'extra-label-class',
10
+ input: {
11
+ label: {
12
+ text: 'Current name of country',
13
+ description: 'Enter your own answer or select from suggestions',
14
+ id: 'country-of-birth-label',
15
+ classes: 'extra-label-class',
16
+ },
17
+ autocomplete: 'off',
15
18
  },
16
- autocomplete: 'off',
17
19
  instructions: 'Use up and down keys to navigate.',
18
20
  ariaYouHaveSelected: 'You have selected',
19
21
  ariaMinChars: 'Enter 3 or more characters for suggestions.',
@@ -132,21 +134,67 @@ describe('macro: autosuggest', () => {
132
134
 
133
135
  faker.renderComponent('autosuggest', {
134
136
  ...EXAMPLE_AUTOSUGGEST,
135
- classes: 'extra-class another-extra-class',
136
- width: '7',
137
- value: 'abc',
138
- attributes: {
139
- a: 42,
137
+ input: {
138
+ type: 'text',
139
+ classes: 'extra-class another-extra-class',
140
+ width: '7',
141
+ label: {
142
+ text: 'Current name of country',
143
+ description: 'Enter your own answer or select from suggestions',
144
+ id: 'country-of-birth-label',
145
+ classes: 'extra-label-class',
146
+ },
147
+ autocomplete: 'off',
148
+ legend: 'this is a legend',
149
+ legendClasses: 'legend-extra-class',
150
+ value: 'abc',
151
+ attributes: {
152
+ a: 42,
153
+ },
154
+ error: {
155
+ id: 'error-id',
156
+ text: 'An error occurred.',
157
+ },
158
+ mutuallyExclusive: null,
159
+ accessiblePlaceholder: true,
160
+ name: 'country-of-birth-test',
161
+ min: 1,
162
+ max: 10,
163
+ minLength: 1,
164
+ maxLength: 10,
165
+ prefix: {
166
+ title: 'Great British Pounds',
167
+ text: '£',
168
+ id: 'gbp-prefix',
169
+ },
170
+ suffix: {
171
+ title: 'Percentage of total',
172
+ text: '%',
173
+ id: 'percentage-suffix',
174
+ },
175
+ fieldId: 'field-id-test',
176
+ fieldClasses: 'field-class-test',
177
+ dontWrap: true,
178
+ charCheckLimit: {
179
+ limit: 200,
180
+ charCountSingular: 'You have {x} character remaining',
181
+ charCountPlural: 'You have {x} characters remaining',
182
+ charCountOverLimitSingular: '{x} character too many',
183
+ charCountOverLimitPlural: '{x} characters too many',
184
+ },
185
+ searchButton: {
186
+ text: 'Search',
187
+ },
188
+ postTextboxLinkText: 'Post textbox link text',
189
+ postTextboxLinkUrl: 'https://www.ons.gov.uk',
190
+ listeners: {
191
+ click: "function() { console.log('click'); }",
192
+ },
140
193
  },
141
- error: {
142
- id: 'error-id',
143
- text: 'An error occurred.',
144
- },
145
- mutuallyExclusive: null,
146
- accessiblePlaceholder: true,
147
194
  });
148
195
 
149
196
  expect(inputSpy.occurrences[0]).toHaveProperty('id', 'country-of-birth');
197
+ expect(inputSpy.occurrences[0]).toHaveProperty('type', 'text');
150
198
  expect(inputSpy.occurrences[0]).toHaveProperty('classes', 'ons-js-autosuggest-input extra-class another-extra-class');
151
199
  expect(inputSpy.occurrences[0]).toHaveProperty('width', '7');
152
200
  expect(inputSpy.occurrences[0]).toHaveProperty('label.text', 'Current name of country');
@@ -154,13 +202,38 @@ describe('macro: autosuggest', () => {
154
202
  expect(inputSpy.occurrences[0]).toHaveProperty('label.id', 'country-of-birth-label');
155
203
  expect(inputSpy.occurrences[0]).toHaveProperty('label.classes', 'extra-label-class');
156
204
  expect(inputSpy.occurrences[0]).toHaveProperty('autocomplete', 'off');
205
+ expect(inputSpy.occurrences[0]).toHaveProperty('legend', 'this is a legend');
206
+ expect(inputSpy.occurrences[0]).toHaveProperty('legendClasses', 'legend-extra-class');
157
207
  expect(inputSpy.occurrences[0]).toHaveProperty('value', 'abc');
158
208
  expect(inputSpy.occurrences[0]).toHaveProperty('attributes.a', 42);
159
209
  expect(inputSpy.occurrences[0]).toHaveProperty('error.id', 'error-id');
160
210
  expect(inputSpy.occurrences[0]).toHaveProperty('error.text', 'An error occurred.');
161
211
  expect(inputSpy.occurrences[0]).toHaveProperty('mutuallyExclusive', null);
162
212
  expect(inputSpy.occurrences[0]).toHaveProperty('accessiblePlaceholder', true);
213
+ expect(inputSpy.occurrences[0]).toHaveProperty('name', 'country-of-birth-test');
163
214
  expect(typeof inputSpy.occurrences[0].autosuggestResults).toBe('string');
215
+ expect(inputSpy.occurrences[0]).toHaveProperty('min', 1);
216
+ expect(inputSpy.occurrences[0]).toHaveProperty('max', 10);
217
+ expect(inputSpy.occurrences[0]).toHaveProperty('minLength', 1);
218
+ expect(inputSpy.occurrences[0]).toHaveProperty('maxLength', 10);
219
+ expect(inputSpy.occurrences[0]).toHaveProperty('prefix.title', 'Great British Pounds');
220
+ expect(inputSpy.occurrences[0]).toHaveProperty('prefix.text', '£');
221
+ expect(inputSpy.occurrences[0]).toHaveProperty('prefix.id', 'gbp-prefix');
222
+ expect(inputSpy.occurrences[0]).toHaveProperty('suffix.title', 'Percentage of total');
223
+ expect(inputSpy.occurrences[0]).toHaveProperty('suffix.text', '%');
224
+ expect(inputSpy.occurrences[0]).toHaveProperty('suffix.id', 'percentage-suffix');
225
+ expect(inputSpy.occurrences[0]).toHaveProperty('fieldId', 'field-id-test');
226
+ expect(inputSpy.occurrences[0]).toHaveProperty('fieldClasses', 'field-class-test');
227
+ expect(inputSpy.occurrences[0]).toHaveProperty('dontWrap', true);
228
+ expect(inputSpy.occurrences[0]).toHaveProperty('charCheckLimit.limit', 200);
229
+ expect(inputSpy.occurrences[0]).toHaveProperty('charCheckLimit.charCountSingular', 'You have {x} character remaining');
230
+ expect(inputSpy.occurrences[0]).toHaveProperty('charCheckLimit.charCountPlural', 'You have {x} characters remaining');
231
+ expect(inputSpy.occurrences[0]).toHaveProperty('charCheckLimit.charCountOverLimitSingular', '{x} character too many');
232
+ expect(inputSpy.occurrences[0]).toHaveProperty('charCheckLimit.charCountOverLimitPlural', '{x} characters too many');
233
+ expect(inputSpy.occurrences[0]).toHaveProperty('searchButton.text', 'Search');
234
+ expect(inputSpy.occurrences[0]).toHaveProperty('postTextboxLinkText', 'Post textbox link text');
235
+ expect(inputSpy.occurrences[0]).toHaveProperty('postTextboxLinkUrl', 'https://www.ons.gov.uk');
236
+ expect(inputSpy.occurrences[0]).toHaveProperty('listeners.click', "function() { console.log('click'); }");
164
237
  });
165
238
  });
166
239
 
@@ -3,13 +3,15 @@ import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
3
3
 
4
4
  const EXAMPLE_AUTOSUGGEST = {
5
5
  id: 'country-of-birth',
6
- label: {
7
- text: 'Current name of country',
8
- description: 'Enter your own answer or select from suggestions',
9
- id: 'country-of-birth-label',
10
- classes: 'extra-label-class',
6
+ input: {
7
+ label: {
8
+ text: 'Current name of country',
9
+ description: 'Enter your own answer or select from suggestions',
10
+ id: 'country-of-birth-label',
11
+ classes: 'extra-label-class',
12
+ },
13
+ autocomplete: 'off',
11
14
  },
12
- autocomplete: 'off',
13
15
  instructions: 'Use up and down keys to navigate.',
14
16
  ariaYouHaveSelected: 'You have selected',
15
17
  ariaMinChars: 'Enter 3 or more characters for suggestions.',
@@ -5,12 +5,14 @@
5
5
 
6
6
  {{ onsAutosuggest({
7
7
  "id": "country-of-birth-autosuggest-multiple",
8
- "label": {
9
- "text": "Passport",
10
- "id": "country-of-birth-label-multiple",
11
- "description": "Enter your own answer or select from suggestions. You can enter multiple countries if you have a passport for more than one."
8
+ "input": {
9
+ "label": {
10
+ "text": "Passport",
11
+ "id": "country-of-birth-label-multiple",
12
+ "description": "Enter your own answer or select from suggestions. You can enter multiple countries if you have a passport for more than one."
13
+ },
14
+ "autocomplete": "off"
12
15
  },
13
- "autocomplete": "off",
14
16
  "instructions": "Use up and down keys to navigate suggestions once you\'ve typed more than two characters. Use the enter key to select a suggestion. Touch device users, explore by touch or with swipe gestures.",
15
17
  "ariaYouHaveSelected": "You have selected",
16
18
  "ariaMinChars": "Enter 3 or more characters for suggestions.",
@@ -5,12 +5,14 @@
5
5
 
6
6
  {{ onsAutosuggest({
7
7
  "id": "country-of-birth-autosuggest",
8
- "label": {
9
- "text": "Current name of country",
10
- "description": "Enter your own answer or select from suggestions",
11
- "id": "country-of-birth-label"
8
+ "input": {
9
+ "label": {
10
+ "text": "Current name of country",
11
+ "description": "Enter your own answer or select from suggestions",
12
+ "id": "country-of-birth-label"
13
+ },
14
+ "autocomplete": "off"
12
15
  },
13
- "autocomplete": "off",
14
16
  "instructions": "Use up and down keys to navigate suggestions once you\'ve typed more than two characters. Use the enter key to select a suggestion. Touch device users, explore by touch or with swipe gestures.",
15
17
  "ariaYouHaveSelected": "You have selected",
16
18
  "ariaMinChars": "Enter 3 or more characters for suggestions.",
@@ -6,7 +6,7 @@ async function submitButton() {
6
6
 
7
7
  if (buttons.length) {
8
8
  const SubmitButton = (await import('./button')).default;
9
- buttons.forEach(button => {
9
+ buttons.forEach((button) => {
10
10
  if (button.classList.contains('ons-js-timer')) {
11
11
  submitType = 'timer';
12
12
  } else if (button.classList.contains('ons-js-loader')) {
@@ -5,15 +5,13 @@
5
5
  &__link {
6
6
  display: flex;
7
7
  flex-direction: column;
8
- }
9
-
10
- &__image--reorder {
11
- order: 1;
12
- }
8
+ margin-bottom: 1rem;
9
+ width: fit-content;
13
10
 
14
- &__title--reorder {
15
- order: 2;
16
- }
11
+ & > .ons-card__title {
12
+ margin-bottom: 0;
13
+ }
14
+ }
17
15
 
18
16
  &__link:hover {
19
17
  text-decoration-thickness: 3px;
@@ -5,36 +5,18 @@
5
5
  {% set titleSize = params.titleSize | default('2') %}
6
6
 
7
7
  <div class="ons-card">
8
-
9
- {%- if params.image -%}
10
- {%- if params.url -%}
11
- <a href="{{ params.url }}" class="ons-card__link">
12
- {%- endif -%}
13
- <h{{ titleSize }} class="ons-card__title ons-card__title--reorder {{ params.titleClasses | default('ons-u-fs-m')}}" id="{{ params.id }}">
14
- {{ params.title }}
15
- </h{{ titleSize }}>
16
- {% if params.image.smallSrc %}
17
- <img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="200" width="303"{% if params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
18
- {% elif params.image == true or params.image.placeholderURL %}
19
- <img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
20
- {% endif %}
21
- {%- if params.url -%}
22
- </a>
8
+ <a href="{{ params.url }}" class="ons-card__link">
9
+ {%- if params.image -%}
10
+ {% if params.image.smallSrc %}
11
+ <img class="ons-card__image ons-u-mb-s" height="200" width="303"{% if params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
12
+ {% elif params.image == true or params.image.placeholderURL %}
13
+ <img class="ons-card__image ons-u-mb-s " height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
14
+ {% endif %}
23
15
  {%- endif -%}
24
-
25
- {%- else -%}
26
-
27
- <h{{ titleSize }} class="ons-card__title {{ params.titleClasses | default('ons-u-fs-m') }}" id="{{ params.id }}">
28
- {%- if params.url -%}
29
- <a class="ons-card__link" href="{{ params.url }}">
30
- {%- endif -%}
16
+ <h{{ titleSize }} class="ons-card__title {{ params.titleClasses | default('ons-u-fs-m')}}" id="{{ params.id }}">
31
17
  {{ params.title }}
32
- {%- if params.url -%}
33
- </a>
34
- {%- endif -%}
35
18
  </h{{ titleSize }}>
36
-
37
- {%- endif -%}
19
+ </a>
38
20
 
39
21
  <p id="{{ params.textId }}">{{ params.text }}</p>
40
22
 
@@ -26,7 +26,7 @@
26
26
  overflow: visible;
27
27
  padding: 1rem;
28
28
  position: static;
29
- text-decoration: underline solid var(--ons-color-text-link-focus) 2px;
29
+ text-decoration: underline solid var(--ons-color-text-link-focus) 4px;
30
30
  white-space: inherit;
31
31
  width: auto;
32
32
  }