@ons/design-system 67.0.6 → 67.2.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.
@@ -0,0 +1,86 @@
1
+ {% from "components/mutually-exclusive/_macro.njk" import onsMutuallyExclusive %}
2
+ {% from "components/fieldset/_macro.njk" import onsFieldset %}
3
+ {% from "components/input/_macro.njk" import onsInput %}
4
+ {% from "components/error/_macro.njk" import onsError %}
5
+
6
+ {% macro onsDateFieldInput(params) %}
7
+ {% set fields %}
8
+ {% for field in params.fields %}
9
+ {{
10
+ onsInput({
11
+ "id": field.id,
12
+ "classes": field.classes,
13
+ "width": field.width,
14
+ "type": "number",
15
+ "name": field.name,
16
+ "value": field.value,
17
+ "min": field.min,
18
+ "max": field.max,
19
+ "maxLength": field.maxLength,
20
+ "suffix": field.suffix,
21
+ "label": field.label,
22
+ "attributes": field.attributes,
23
+ "error": field.error,
24
+ "fieldId": field.fieldId
25
+ })
26
+ }}
27
+ {% endfor %}
28
+ {% endset %}
29
+
30
+ {% if numberOfFields > 1 %}
31
+ {% set fields %}
32
+ <div class="ons-field-group">
33
+ {{ fields | safe }}
34
+ </div>
35
+ {% endset %}
36
+ {% endif %}
37
+
38
+ {% if params.mutuallyExclusive %}
39
+ {% set mutuallyExclusive = params.mutuallyExclusive | setAttributes({
40
+ "id": params.id,
41
+ "legend": params.legendOrLabel,
42
+ "legendClasses": params.legendClasses,
43
+ "description": params.description,
44
+ "error": params.error,
45
+ "classes": params.classes,
46
+ "legendIsQuestionTitle": params.legendIsQuestionTitle,
47
+ "dontWrap": params.dontWrap,
48
+ "exclusiveOptions": params.mutuallyExclusive.exclusiveOptions,
49
+ "or": params.mutuallyExclusive.or,
50
+ "deselectMessage": params.mutuallyExclusive.deselectMessage,
51
+ "deselectGroupAdjective": params.mutuallyExclusive.deselectGroupAdjective,
52
+ "deselectExclusiveOptionAdjective": params.mutuallyExclusive.deselectExclusiveOptionAdjective
53
+ }) %}
54
+
55
+ {% call onsMutuallyExclusive(mutuallyExclusive) %}
56
+ <div class="ons-field-group">
57
+ {{ fields | safe }}
58
+ </div>
59
+ {% endcall %}
60
+ {% elif params.numberOfFields > 1 %}
61
+ {% call onsFieldset({
62
+ "id": params.id,
63
+ "legend": params.legendOrLabel,
64
+ "classes": params.classes,
65
+ "description": params.description,
66
+ "legendClasses": params.legendClasses,
67
+ "error": params.error,
68
+ "legendIsQuestionTitle": params.legendIsQuestionTitle,
69
+ "dontWrap": params.dontWrap
70
+ }) %}
71
+ <div class="ons-field-group">
72
+ {{ fields | safe }}
73
+ </div>
74
+ {% endcall %}
75
+ {% elif params.numberOfFields == 1 %}
76
+ {% if params.error %}
77
+ {% call onsError(params.error) %}
78
+ {{ fields | safe }}
79
+ {% endcall %}
80
+ {% else %}
81
+ {{ fields | safe }}
82
+ {% endif %}
83
+ {% else %}
84
+ {{ fields | safe }}
85
+ {% endif %}
86
+ {% endmacro %}
@@ -1,12 +1,8 @@
1
- {% macro onsDateInput(params) %}
2
- {% from "components/fieldset/_macro.njk" import onsFieldset %}
3
- {% from "components/mutually-exclusive/_macro.njk" import onsMutuallyExclusive %}
4
- {% from "components/input/_macro.njk" import onsInput %}
5
- {% from "components/error/_macro.njk" import onsError %}
1
+ {% from "components/date-field-input/_macro.njk" import onsDateFieldInput %}
6
2
 
3
+ {% macro onsDateInput(params) %}
7
4
  {% set exclusiveClass = " ons-js-exclusive-group-item" if params.mutuallyExclusive else "" %}
8
-
9
- {%- set numberOfFields = 0 -%}
5
+ {%- set numberOfFields = 0 -%}
10
6
 
11
7
  {%- if params.day -%}
12
8
  {%- set numberOfFields = numberOfFields + 1 -%}
@@ -20,114 +16,82 @@
20
16
  {%- set numberOfFields = numberOfFields + 1 -%}
21
17
  {%- endif -%}
22
18
 
23
- {% set fields %}
24
- {% if params.day %}
25
- {{ onsInput({
26
- "id": params.id + "-day",
27
- "type": "number",
28
- "name": params.day.name,
29
- "classes": (" ons-input--error" if (params.error and params.day.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default(""),
30
- "width": "2",
31
- "min": 1,
32
- "max": 31,
33
- "maxLength": 2,
34
- "attributes": params.day.attributes,
35
- "label": {
36
- "text": params.day.label.text if numberOfFields > 1 else params.legendOrLabel,
37
- "description": params.day.label.description if numberOfFields > 1 else params.description,
38
- "id": params.id + "-day-label"
39
- },
40
- "value": params.day.value
41
- }) }}
42
- {% endif %}
43
-
44
- {% if params.month %}
45
- {{ onsInput({
46
- "id": params.id + "-month",
47
- "type": "number",
48
- "name": params.month.name,
49
- "classes": (" ons-input--error" if (params.error and params.month.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default(""),
50
- "width": "2",
51
- "min": 1,
52
- "max": 12,
53
- "maxLength": 2,
54
- "attributes": params.month.attributes,
55
- "label": {
56
- "text": params.month.label.text if numberOfFields > 1 else params.legendOrLabel,
57
- "description": params.month.label.description if numberOfFields > 1 else params.description,
58
- "id": params.id + "-month-label"
59
- },
60
- "value": params.month.value
61
- }) }}
62
- {% endif %}
63
-
64
- {% if params.year %}
65
- {{ onsInput({
66
- "id": params.id + "-year",
67
- "type": "number",
68
- "name": params.year.name,
69
- "classes": (" ons-input--error" if (params.error and params.year.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default(""),
70
- "width": "4",
71
- "min": 1000,
72
- "max": 3000,
73
- "maxLength": 4,
74
- "attributes": params.year.attributes,
75
- "label": {
76
- "text": params.year.label.text if numberOfFields > 1 else params.legendOrLabel,
77
- "description": params.year.label.description if numberOfFields > 1 else params.description,
78
- "id": params.id + "-year-label"
79
- },
80
- "value": params.year.value
81
- }) }}
82
- {% endif %}
83
- {% endset %}
84
-
85
- {% if numberOfFields > 1 %}
86
- {% set fields %}
87
- <div class="ons-field-group">
88
- {{ fields | safe }}
89
- </div>
90
- {% endset %}
19
+ {% set fields = [] %}
20
+ {% if params.day %}
21
+ {% set dayField = {
22
+ "id": params.id + "-day",
23
+ "label": {
24
+ "text": params.day.label.text if numberOfFields > 1 else params.legendOrLabel,
25
+ "description": params.day.label.description if numberOfFields > 1 else params.description,
26
+ "id": params.id + "-day-label"
27
+ },
28
+ "name": params.day.name,
29
+ "width": "2",
30
+ "min": 1,
31
+ "max": 31,
32
+ "maxLength": 2,
33
+ "attributes": params.day.attributes,
34
+ "value": params.day.value,
35
+ "classes": (" ons-input--error" if (params.error and params.day.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default("")
36
+ } %}
37
+ {% set fields = (fields.push(dayField), fields) %}
91
38
  {% endif %}
92
-
93
- {% if params.mutuallyExclusive %}
94
- {% call onsMutuallyExclusive({
95
- "id": params.id,
96
- "legend": params.legendOrLabel,
97
- "legendClasses": params.legendClasses,
98
- "description": params.description,
99
- "classes": params.classes,
100
- "dontWrap": params.dontWrap if numberOfFields > 1 else true,
101
- "legendIsQuestionTitle": params.legendIsQuestionTitle,
102
- "exclusiveOptions": params.mutuallyExclusive.exclusiveOptions,
103
- "or": params.mutuallyExclusive.or,
104
- "deselectMessage": params.mutuallyExclusive.deselectMessage,
105
- "deselectGroupAdjective": params.mutuallyExclusive.deselectGroupAdjective,
106
- "deselectExclusiveOptionAdjective": params.mutuallyExclusive.deselectExclusiveOptionAdjective,
107
- "error": params.error
108
- }) %}
109
- {{ fields | safe }}
110
- {% endcall %}
111
- {% elif numberOfFields == 1 %}
112
- {% if params.error %}
113
- {% call onsError(params.error) %}
114
- {{ fields | safe }}
115
- {% endcall %}
116
- {% else %}
117
- {{ fields | safe }}
118
- {% endif %}
119
- {% else %}
120
- {% call onsFieldset({
121
- "id": params.id,
122
- "legend": params.legendOrLabel,
123
- "legendClasses": params.legendClasses,
124
- "description": params.description,
125
- "classes": params.classes,
126
- "dontWrap": params.dontWrap,
127
- "legendIsQuestionTitle": params.legendIsQuestionTitle,
128
- "error": params.error
129
- }) %}
130
- {{ fields | safe }}
131
- {% endcall %}
39
+ {% if params.month %}
40
+ {% set monthField = {
41
+ "id": params.id + "-month",
42
+ "label": {
43
+ "text": params.month.label.text if numberOfFields > 1 else params.legendOrLabel,
44
+ "description": params.month.label.description if numberOfFields > 1 else params.description,
45
+ "id": params.id + "-month-label"
46
+ },
47
+ "name": params.month.name,
48
+ "width": "2",
49
+ "min": 1,
50
+ "max": 12,
51
+ "maxLength": 2,
52
+ "attributes": params.month.attributes,
53
+ "value": params.month.value,
54
+ "classes": (" ons-input--error" if (params.error and params.month.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default("")
55
+ } %}
56
+ {% set fields = (fields.push(monthField), fields) %}
132
57
  {% endif %}
58
+ {% if params.year %}
59
+ {% set yearField = {
60
+ "id": params.id + "-year",
61
+ "label": {
62
+ "text": params.year.label.text if numberOfFields > 1 else params.legendOrLabel,
63
+ "description": params.year.label.description if numberOfFields > 1 else params.description,
64
+ "id": params.id + "-year-label"
65
+ },
66
+ "name": params.year.name,
67
+ "width": "4",
68
+ "min": 1000,
69
+ "max": 3000,
70
+ "maxLength": 4,
71
+ "attributes": params.year.attributes,
72
+ "value": params.year.value,
73
+ "classes": (" ons-input--error" if (params.error and params.year.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default("")
74
+ } %}
75
+ {% set fields = (fields.push(yearField), fields) %}
76
+ {% endif %}
77
+
78
+ {{ onsDateFieldInput({
79
+ "id": params.id,
80
+ "legendOrLabel": params.legendOrLabel,
81
+ "description": params.description,
82
+ "mutuallyExclusive": params.mutuallyExclusive,
83
+ "fields": fields,
84
+ "numberOfFields": numberOfFields,
85
+ "error": params.error,
86
+ "legend": params.legendOrLabel,
87
+ "dontWrap": params.dontWrap,
88
+ "legendClasses": params.legendClasses,
89
+ "legendIsQuestionTitle": params.legendIsQuestionTitle,
90
+ "classes": params.classes,
91
+ "exclusiveOptions": params.mutuallyExclusive.exclusiveOptions,
92
+ "or": params.mutuallyExclusive.or,
93
+ "deselectMessage": params.mutuallyExclusive.deselectMessage,
94
+ "deselectGroupAdjective": params.mutuallyExclusive.deselectGroupAdjective,
95
+ "deselectExclusiveOptionAdjective": params.mutuallyExclusive.deselectExclusiveOptionAdjective
96
+ }) }}
133
97
  {% endmacro %}
@@ -1,5 +1,5 @@
1
- .ons-metadata {
2
- &__list {
1
+ .ons-description-list {
2
+ &__items {
3
3
  margin: 0 0 2rem;
4
4
  }
5
5
 
@@ -0,0 +1,14 @@
1
+ {% macro onsDescriptionList(params) %}
2
+ <dl class="ons-description-list ons-description-list__items ons-grid ons-grid--gutterless ons-u-cf{{ (' ' + params.classes) if params.classes }}"{% if params.id %} id="{{ params.id }}" {% endif %}{% if params.descriptionListLabel %} title="{{ params.descriptionListLabel }}" aria-label="{{ params.descriptionListLabel }}"{% endif %}>
3
+ {% for item in params.itemsList %}
4
+ {% if item.term | length %}
5
+ <dt class="ons-description-list__term ons-grid__col ons-col-{{ params.termCol }}@m">{{ item.term }}</dt>
6
+ {% endif %}
7
+ {% for descriptionItem in item.descriptions %}
8
+ {% if descriptionItem.description | length %}
9
+ <dd {% if descriptionItem.id %}id="{{ descriptionItem.id }}" {% endif %}class="ons-description-list__value ons-grid__col ons-col-{{ params.descriptionCol }}@m">{{ descriptionItem.description }}</dd>
10
+ {% endif %}
11
+ {% endfor %}
12
+ {% endfor %}
13
+ </dl>
14
+ {% endmacro %}
@@ -5,10 +5,10 @@ import * as cheerio from 'cheerio';
5
5
  import axe from '../../tests/helpers/axe';
6
6
  import { renderComponent } from '../../tests/helpers/rendering';
7
7
 
8
- const EXAMPLE_METADATA_FULL = {
8
+ const EXAMPLE_DESCRIPTION_LIST_FULL = {
9
9
  id: 'example-id',
10
10
  classes: 'ons-u-mb-no',
11
- metadataLabel: 'This is an example of the metadata component',
11
+ descriptionListLabel: 'This is an example of the description list component',
12
12
  termCol: 2,
13
13
  descriptionCol: 10,
14
14
  itemsList: [
@@ -37,7 +37,7 @@ const EXAMPLE_METADATA_FULL = {
37
37
  ],
38
38
  };
39
39
 
40
- const EXAMPLE_METADATA_MINIMAL = {
40
+ const EXAMPLE_DESCRIPTION_LIST_MINIMAL = {
41
41
  itemsList: [
42
42
  {
43
43
  term: 'Survey:',
@@ -61,16 +61,16 @@ const EXAMPLE_METADATA_MINIMAL = {
61
61
  ],
62
62
  };
63
63
 
64
- describe('macro: metadata', () => {
64
+ describe('macro: description-list', () => {
65
65
  it('passes jest-axe checks when all parameters are provided', async () => {
66
- const $ = cheerio.load(renderComponent('metadata', EXAMPLE_METADATA_FULL));
66
+ const $ = cheerio.load(renderComponent('description-list', EXAMPLE_DESCRIPTION_LIST_FULL));
67
67
 
68
68
  const results = await axe($.html());
69
69
  expect(results).toHaveNoViolations();
70
70
  });
71
71
 
72
72
  it('passes jest-axe checks when minimal parameters are provided', async () => {
73
- const $ = cheerio.load(renderComponent('metadata', EXAMPLE_METADATA_MINIMAL));
73
+ const $ = cheerio.load(renderComponent('description-list', EXAMPLE_DESCRIPTION_LIST_MINIMAL));
74
74
 
75
75
  const results = await axe($.html());
76
76
  expect(results).toHaveNoViolations();
@@ -78,8 +78,8 @@ describe('macro: metadata', () => {
78
78
 
79
79
  it('has the provided `id` attribute', () => {
80
80
  const $ = cheerio.load(
81
- renderComponent('metadata', {
82
- ...EXAMPLE_METADATA_MINIMAL,
81
+ renderComponent('description-list', {
82
+ ...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
83
83
  id: 'example-id',
84
84
  }),
85
85
  );
@@ -89,32 +89,32 @@ describe('macro: metadata', () => {
89
89
 
90
90
  it('has additionally provided style classes', () => {
91
91
  const $ = cheerio.load(
92
- renderComponent('metadata', {
93
- ...EXAMPLE_METADATA_MINIMAL,
92
+ renderComponent('description-list', {
93
+ ...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
94
94
  classes: 'extra-class another-extra-class',
95
95
  }),
96
96
  );
97
97
 
98
- expect($('.ons-metadata').hasClass('extra-class')).toBe(true);
99
- expect($('.ons-metadata').hasClass('another-extra-class')).toBe(true);
98
+ expect($('.ons-description-list').hasClass('extra-class')).toBe(true);
99
+ expect($('.ons-description-list').hasClass('another-extra-class')).toBe(true);
100
100
  });
101
101
 
102
- it('outputs `title` and `aria-label` attributes when `metadataLabel` is provided', () => {
102
+ it('outputs `title` and `aria-label` attributes when `descriptionListLabel` is provided', () => {
103
103
  const $ = cheerio.load(
104
- renderComponent('metadata', {
105
- ...EXAMPLE_METADATA_MINIMAL,
106
- metadataLabel: 'This is an example of the metadata component',
104
+ renderComponent('description-list', {
105
+ ...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
106
+ descriptionListLabel: 'This is an example of the description list component',
107
107
  }),
108
108
  );
109
109
 
110
- expect($('.ons-metadata').attr('title')).toBe('This is an example of the metadata component');
111
- expect($('.ons-metadata').attr('aria-label')).toBe('This is an example of the metadata component');
110
+ expect($('.ons-description-list').attr('title')).toBe('This is an example of the description list component');
111
+ expect($('.ons-description-list').attr('aria-label')).toBe('This is an example of the description list component');
112
112
  });
113
113
 
114
114
  it('outputs list items as expected', () => {
115
- const $ = cheerio.load(renderComponent('metadata', EXAMPLE_METADATA_FULL));
115
+ const $ = cheerio.load(renderComponent('description-list', EXAMPLE_DESCRIPTION_LIST_FULL));
116
116
 
117
- const $listElements = $('.ons-metadata__term, .ons-metadata__value');
117
+ const $listElements = $('.ons-description-list__term, .ons-description-list__value');
118
118
 
119
119
  expect($listElements[0].tagName).toBe('dt');
120
120
  expect($($listElements[0]).text()).toBe('Survey:');
@@ -140,13 +140,13 @@ describe('macro: metadata', () => {
140
140
  [4, 'ons-col-4\\@m'],
141
141
  ])('applies class for the provided `termCol` (%i -> %s)', (termCol, expectedClass) => {
142
142
  const $ = cheerio.load(
143
- renderComponent('metadata', {
144
- ...EXAMPLE_METADATA_MINIMAL,
143
+ renderComponent('description-list', {
144
+ ...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
145
145
  termCol,
146
146
  }),
147
147
  );
148
148
 
149
- const $termElements = $(`.ons-metadata__term.${expectedClass}`);
149
+ const $termElements = $(`.ons-description-list__term.${expectedClass}`);
150
150
  expect($termElements.length).toBe(2);
151
151
  });
152
152
 
@@ -155,13 +155,13 @@ describe('macro: metadata', () => {
155
155
  [4, 'ons-col-4\\@m'],
156
156
  ])('applies class for the provided `descriptionCol` (%i -> %s)', (descriptionCol, expectedClass) => {
157
157
  const $ = cheerio.load(
158
- renderComponent('metadata', {
159
- ...EXAMPLE_METADATA_MINIMAL,
158
+ renderComponent('description-list', {
159
+ ...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
160
160
  descriptionCol,
161
161
  }),
162
162
  );
163
163
 
164
- const $valueElements = $(`.ons-metadata__value.${expectedClass}`);
164
+ const $valueElements = $(`.ons-description-list__value.${expectedClass}`);
165
165
  expect($valueElements.length).toBe(3);
166
166
  });
167
167
  });
@@ -1,8 +1,8 @@
1
- {% from "components/metadata/_macro.njk" import onsMetadata %}
1
+ {% from "components/description-list/_macro.njk" import onsDescriptionList %}
2
2
  {{
3
- onsMetadata({
3
+ onsDescriptionList({
4
4
  "classes": "ons-u-mb-no",
5
- "metadataLabel": "Information about this business and its survey requirements",
5
+ "descriptionListLabel": "Information about this business and its survey requirements",
6
6
  "termCol": "2",
7
7
  "descriptionCol": "10",
8
8
  "itemsList": [
@@ -4,7 +4,7 @@
4
4
  margin-bottom: 0;
5
5
 
6
6
  &__item {
7
- border-bottom: 1px solid var(--ons-color-borders-list);
7
+ border-bottom: 1px solid var(--ons-color-borders-light);
8
8
  margin: 0 0 1.5rem;
9
9
  padding: 0 0 1.5rem;
10
10
 
@@ -1,6 +1,6 @@
1
1
  .ons-adv-filter {
2
2
  &__gallery {
3
- border-top: 1px solid var(--ons-color-borders-list);
3
+ border-top: 1px solid var(--ons-color-borders-light);
4
4
  margin-left: 0;
5
5
  padding-left: 0;
6
6
  padding-top: 1.5rem;
@@ -1,12 +1,7 @@
1
-
2
- {% from "components/mutually-exclusive/_macro.njk" import onsMutuallyExclusive %}
3
- {% from "components/fieldset/_macro.njk" import onsFieldset %}
4
- {% from "components/field/_macro.njk" import onsField %}
5
- {% from "components/input/_macro.njk" import onsInput %}
1
+ {% from "components/date-field-input/_macro.njk" import onsDateFieldInput %}
6
2
 
7
3
  {% macro onsDuration(params) %}
8
4
  {% set numberOfFields = 0 %}
9
-
10
5
  {% if params.field1 %}
11
6
  {% set numberOfFields = numberOfFields + 1 %}
12
7
  {% endif %}
@@ -15,85 +10,65 @@
15
10
  {% set numberOfFields = numberOfFields + 1 %}
16
11
  {% endif %}
17
12
 
18
- {% set fields %}
19
- {% if params.field1 %}
20
- {{ onsInput({
21
- "id": params.field1.id,
22
- "classes": (" ons-input--error" if (params.error and params.field1.error) or (numberOfFields > 1 and params.error and not params.field1.error and not params.field2.error) else "") + (" ons-js-exclusive-group-item" if params.mutuallyExclusive else ""),
23
- "width": "2",
24
- "type": "number",
25
- "name": params.field1.name,
26
- "value": params.field1.value,
27
- "suffix": {
28
- "text": params.field1.suffix.text,
29
- "title": params.field1.suffix.title,
30
- "id": params.field1.suffix.id
31
- },
32
- "label": {
33
- "text": params.legendOrLabel if numberOfFields < 2,
34
- "description": params.description if numberOfFields < 2
35
- },
36
- "attributes": params.field1.attributes,
37
- "fieldId": params.id if numberOfFields < 2,
38
- "error": params.error if numberOfFields < 2
39
- }) }}
40
- {% endif %}
41
-
42
- {% if params.field2 %}
43
- {{ onsInput({
44
- "id": params.field2.id,
45
- "classes": (" ons-input--error" if (params.error and params.field2.error) or (numberOfFields > 1 and params.error and not params.field1.error and not params.field2.error) else "") + (" ons-js-exclusive-group-item" if params.mutuallyExclusive else ""),
46
- "width": "2",
47
- "type": "number",
48
- "name": params.field2.name,
49
- "value": params.field2.value,
50
- "suffix": {
51
- "text": params.field2.suffix.text,
52
- "title": params.field2.suffix.title,
53
- "id": params.field2.suffix.id
54
- },
55
- "label": {
56
- "text": params.legendOrLabel if numberOfFields < 2,
57
- "description": params.description if numberOfFields < 2
58
- },
59
- "attributes": params.field2.attributes,
60
- "fieldId": params.id if numberOfFields < 2,
61
- "error": params.error if numberOfFields < 2
62
- }) }}
63
- {% endif %}
64
- {% endset %}
65
-
66
- {% if params.mutuallyExclusive %}
67
- {% set mutuallyExclusive = params.mutuallyExclusive | setAttributes({
68
- "id": params.id,
69
- "legend": params.legendOrLabel,
70
- "legendClasses": params.legendClasses,
71
- "description": params.description,
72
- "error": params.error,
73
- "legendIsQuestionTitle": params.legendIsQuestionTitle,
74
- "dontWrap": params.dontWrap
75
- }) %}
13
+ {% set fields = [] %}
14
+ {% if params.field1 %}
15
+ {% set field1 = {
16
+ "id": params.field1.id,
17
+ "name": params.field1.name,
18
+ "attributes": params.field1.attributes,
19
+ "label": {
20
+ "text": params.legendOrLabel if numberOfFields < 2,
21
+ "description": params.description if numberOfFields < 2
22
+ },
23
+ "suffix": {
24
+ "text": params.field1.suffix.text,
25
+ "title": params.field1.suffix.title,
26
+ "id": params.field1.suffix.id
27
+ },
28
+ "width": "2",
29
+ "fieldId": params.id if numberOfFields < 2,
30
+ "value": params.field1.value,
31
+ "error": params.error if numberOfFields < 2,
32
+ "classes": (" ons-input--error" if (params.error and params.field1.error) or (params.error and not params.field1.error and not params.field2.error) else "") + (" ons-js-exclusive-group-item" if params.mutuallyExclusive else "")
33
+ } %}
34
+ {% set fields = (fields.push(field1), fields) %}
35
+ {% endif %}
76
36
 
77
- {% call onsMutuallyExclusive(mutuallyExclusive) %}
78
- <div class="ons-field-group">
79
- {{ fields | safe }}
80
- </div>
81
- {% endcall %}
82
- {% elif numberOfFields > 1 %}
83
- {% call onsFieldset({
84
- "id": params.id,
85
- "legend": params.legendOrLabel,
86
- "description": params.description,
87
- "legendClasses": params.legendClasses,
88
- "error": params.error,
89
- "legendIsQuestionTitle": params.legendIsQuestionTitle,
90
- "dontWrap": params.dontWrap
91
- }) %}
92
- <div class="ons-field-group">
93
- {{ fields | safe }}
94
- </div>
95
- {% endcall %}
96
- {% else %}
97
- {{ fields | safe }}
37
+ {% if params.field2 %}
38
+ {% set field2 = {
39
+ "id": params.field2.id,
40
+ "name": params.field2.name,
41
+ "attributes": params.field2.attributes,
42
+ "width": "2",
43
+ "label": {
44
+ "text": params.legendOrLabel if numberOfFields < 2,
45
+ "description": params.description if numberOfFields < 2
46
+ },
47
+ "suffix": {
48
+ "text": params.field2.suffix.text,
49
+ "title": params.field2.suffix.title,
50
+ "id": params.field2.suffix.id
51
+ },
52
+ "value": params.field2.value,
53
+ "error": params.error if numberOfFields < 2,
54
+ "fieldId": params.id if numberOfFields < 2,
55
+ "classes": (" ons-input--error" if (params.error and params.field2.error) or (params.error and not params.field1.error and not params.field2.error) else "") + (" ons-js-exclusive-group-item" if params.mutuallyExclusive else "")
56
+ } %}
57
+ {% set fields = (fields.push(field2), fields) %}
98
58
  {% endif %}
59
+
60
+ {{ onsDateFieldInput({
61
+ "id": params.id,
62
+ "legendOrLabel": params.legendOrLabel,
63
+ "description": params.description,
64
+ "mutuallyExclusive": params.mutuallyExclusive,
65
+ "numberOfFields": numberOfFields,
66
+ "fields": fields,
67
+ "error": params.error,
68
+ "legend": params.legendOrLabel,
69
+ "dontWrap": params.dontWrap,
70
+ "classes": params.classes,
71
+ "legendClasses": params.legendClasses,
72
+ "legendIsQuestionTitle": params.legendIsQuestionTitle
73
+ }) }}
99
74
  {% endmacro %}