@ons/design-system 45.0.3 → 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.
@@ -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-s">{{ params.instruction | safe }}</div>
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
- {% call onsFieldset({
36
- "legendIsQuestionTitle": params.legendIsQuestionTitle,
37
- "legend": titleHtml,
38
- "description": descHtml if params.description is defined and params.description else '',
39
- "legendClasses": params.legendClasses,
40
- "legendTitleClasses": params.legendTitleClasses
41
- }) %}
42
-
43
- {% if params.instruction is defined and params.instruction %}
44
- {{- instHtml -}}
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
- {{ caller () }}
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
- margin: 0 0 1rem;
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;
@@ -8,7 +8,8 @@
8
8
  "legendClasses": params.legendClasses,
9
9
  "dontWrap": params.dontWrap,
10
10
  "legendIsQuestionTitle": params.legendIsQuestionTitle,
11
- "error": params.error
11
+ "error": params.error,
12
+ "inline": params.label.inline
12
13
  }) %}
13
14
  {{
14
15
  onsLabel({
@@ -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{{ '' + params.thClasses if params.thClasses is defined and params.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 %}>
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 {{ '' + 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 %}>
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
  {{
@@ -169,7 +169,8 @@ export default class Timeout {
169
169
  if (!canSetNewExpiry) {
170
170
  this.redirect();
171
171
  } else {
172
- this.closeModalAndRestartTimeout();
172
+ const newExpiryTimeInMilliseconds = this.convertTimeToMilliSeconds(canSetNewExpiry).toString();
173
+ this.closeModalAndRestartTimeout(newExpiryTimeInMilliseconds);
173
174
  }
174
175
  }
175
176
  }
@@ -207,7 +208,7 @@ export default class Timeout {
207
208
  method: fetchMethod,
208
209
  headers: { 'Cache-Control': 'no-cache', 'Content-type': 'application/json; charset=UTF-8' },
209
210
  });
210
- if (!response.ok) {
211
+ if (response.status === 401) {
211
212
  this.redirect();
212
213
  return false;
213
214
  }