@ons/design-system 72.10.5 → 72.10.7

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.
Files changed (57) hide show
  1. package/components/button/_button.scss +8 -6
  2. package/components/char-check-limit/_macro.njk +5 -4
  3. package/components/char-check-limit/_macro.spec.js +167 -7
  4. package/components/char-check-limit/character-check.js +23 -17
  5. package/components/char-check-limit/character-check.spec.js +106 -1
  6. package/components/chart/_chart.scss +33 -5
  7. package/components/chart/_macro.njk +172 -140
  8. package/components/chart/_macro.spec.js +378 -22
  9. package/components/chart/annotations-options.js +1 -1
  10. package/components/chart/bar-chart.js +1 -0
  11. package/components/chart/chart-iframe-resize.dom.js +8 -0
  12. package/components/chart/chart-iframe-resize.js +16 -0
  13. package/components/chart/chart.js +5 -0
  14. package/components/chart/example-area-chart-with-axis-min-and-max-values.njk +72 -0
  15. package/components/chart/example-bar-chart-with-axis-min-and-max-values.njk +59 -0
  16. package/components/chart/example-bar-chart.njk +4 -0
  17. package/components/chart/example-column-chart-with-axis-min-and-max-values.njk +59 -0
  18. package/components/chart/example-iframe-chart.njk +32 -0
  19. package/components/chart/example-line-chart-with-annotations.njk +3 -1
  20. package/components/chart/example-line-chart-with-axis-min-and-max-values.njk +227 -0
  21. package/components/chart/example-line-chart.njk +4 -0
  22. package/components/chart/example-scatter-chart-with-axis-min-and-max-values.njk +98 -0
  23. package/components/chart/example-scatter-chart.njk +4 -0
  24. package/components/chart/range-annotations-options.js +1 -1
  25. package/components/chart/reference-line-annotations-options.js +1 -1
  26. package/components/chart/specific-chart-options.js +19 -0
  27. package/components/checkboxes/_macro.spec.js +3 -3
  28. package/components/details-panel/_details-panel.scss +4 -0
  29. package/components/details-panel/_macro.njk +17 -13
  30. package/components/details-panel/_macro.spec.js +17 -0
  31. package/components/details-panel/example-details-panel-open.njk +2 -1
  32. package/components/details-panel/example-details-panel.njk +2 -1
  33. package/components/header/_header.scss +40 -24
  34. package/components/header/_macro.njk +103 -89
  35. package/components/header/_macro.spec.js +130 -2
  36. package/components/header/example-header-basic-with-search-and-language.njk +207 -0
  37. package/components/header/{example-header-with-search-button.njk → example-header-basic-with-search-button.njk} +1 -0
  38. package/components/header/example-header-basic.njk +1 -0
  39. package/components/hero/_macro.njk +9 -2
  40. package/components/hero/_macro.spec.js +22 -0
  41. package/components/hero/example-hero-grey.njk +2 -1
  42. package/components/input/_macro.njk +1 -2
  43. package/components/input/_macro.spec.js +2 -22
  44. package/components/input/example-input-search-with-character-check.njk +0 -1
  45. package/components/language-selector/_macro.njk +1 -1
  46. package/components/language-selector/_macro.spec.js +45 -0
  47. package/components/navigation/navigation.js +24 -17
  48. package/components/pagination/_macro.njk +17 -7
  49. package/components/pagination/_macro.spec.js +191 -17
  50. package/components/textarea/_macro.njk +19 -3
  51. package/components/textarea/_macro.spec.js +76 -3
  52. package/components/textarea/example-textarea-with-word-limit.njk +20 -0
  53. package/css/main.css +1 -1
  54. package/js/main.js +2 -0
  55. package/package.json +3 -2
  56. package/scripts/main.es5.js +3 -1
  57. package/scripts/main.js +3 -1
@@ -1,9 +1,12 @@
1
1
  {% from "components/list/_macro.njk" import onsList %}
2
+ {% from "components/details/_macro.njk" import onsDetails %}
2
3
 
3
4
  {% macro onsChart(params) %}
4
5
  {% set supportedChartTypes = ['line', 'bar', 'column', 'scatter', 'area', 'columnrange', 'boxplot'] %}
5
6
  {% set supportedChartTypesWithLine = ['column'] %}
6
7
  {% set supportedChartTypesWithScatter = ['columnrange'] %}
8
+ {% set supportedChartTypesWithXAxisMinAndMax = ['scatter'] %}
9
+ {% set supportedChartTypesWithYAxisMinAndMax = ['line', 'bar', 'column', 'scatter', 'area', 'columnrange', 'boxplot'] %}
7
10
  {% set headingLevel = params.headingLevel | default(2) %}
8
11
  {% set openingTitleTag = "<h" ~ headingLevel %}
9
12
  {% set closingTitleTag = "</h" ~ headingLevel ~ ">" %}
@@ -12,38 +15,37 @@
12
15
  {% set openingDownloadTitleTag = "<h" ~ (headingLevel + 2) %}
13
16
  {% set closingDownloadTitleTag = "</h" ~ (headingLevel + 2) ~ ">" %}
14
17
  <div
15
- data-highcharts-base-chart
16
- data-highcharts-type="{{ params.chartType }}"
17
- data-highcharts-theme="{{ params.theme }}"
18
- data-highcharts-title="{{ params.title }}"
19
- data-highcharts-id="{{ params.id }}"
20
- {% if params.useStackedLayout %}data-highcharts-use-stacked-layout="{{ params.useStackedLayout }}"{% endif %}
21
- {% if params.percentageHeightDesktop and params.chartType != 'bar' %}
22
- data-highcharts-percentage-height-desktop="{{ params.percentageHeightDesktop }}"
23
- {% endif %}
24
- {% if params.percentageHeightMobile and params.chartType != 'bar' %}
25
- data-highcharts-percentage-height-mobile="{{ params.percentageHeightMobile }}"
26
- {% endif %}
27
- {% if params.xAxis.tickIntervalMobile %}
28
- data-highcharts-x-axis-tick-interval-mobile="{{ params.xAxis.tickIntervalMobile }}"
29
- {% endif %}
30
- {% if params.xAxis.tickIntervalDesktop %}
31
- data-highcharts-x-axis-tick-interval-desktop="{{ params.xAxis.tickIntervalDesktop }}"
32
- {% endif %}
33
- {% if params.yAxis.tickIntervalMobile %}
34
- data-highcharts-y-axis-tick-interval-mobile="{{ params.yAxis.tickIntervalMobile }}"
35
- {% endif %}
36
- {% if params.yAxis.tickIntervalDesktop %}
37
- data-highcharts-y-axis-tick-interval-desktop="{{ params.yAxis.tickIntervalDesktop }}"
38
- {% endif %}
39
- {% if params.estimateLineLabel %}
40
- data-highcharts-estimate-line-label="{{ params.estimateLineLabel }}"
41
- {% endif %}
42
- {% if params.uncertaintyRangeLabel %}
43
- data-highcharts-uncertainty-range-label="{{ params.uncertaintyRangeLabel }}"
44
- {% endif %}
45
- {% if params.yAxis.customReferenceLineValue %}
46
- data-highcharts-custom-reference-line-value="{{ params.yAxis.customReferenceLineValue }}"
18
+ {% if not params.iframeUrl %}
19
+ data-highcharts-base-chart data-highcharts-type="{{ params.chartType }}" data-highcharts-theme="{{ params.theme }}"
20
+ data-highcharts-title="{{ params.title }}" data-highcharts-id="{{ params.id }}"
21
+ {% if params.useStackedLayout %}data-highcharts-use-stacked-layout="{{ params.useStackedLayout }}"{% endif %}
22
+ {% if params.percentageHeightDesktop and params.chartType != 'bar' %}
23
+ data-highcharts-percentage-height-desktop="{{ params.percentageHeightDesktop }}"
24
+ {% endif %}
25
+ {% if params.percentageHeightMobile and params.chartType != 'bar' %}
26
+ data-highcharts-percentage-height-mobile="{{ params.percentageHeightMobile }}"
27
+ {% endif %}
28
+ {% if params.xAxis.tickIntervalMobile %}
29
+ data-highcharts-x-axis-tick-interval-mobile="{{ params.xAxis.tickIntervalMobile }}"
30
+ {% endif %}
31
+ {% if params.xAxis.tickIntervalDesktop %}
32
+ data-highcharts-x-axis-tick-interval-desktop="{{ params.xAxis.tickIntervalDesktop }}"
33
+ {% endif %}
34
+ {% if params.yAxis.tickIntervalMobile %}
35
+ data-highcharts-y-axis-tick-interval-mobile="{{ params.yAxis.tickIntervalMobile }}"
36
+ {% endif %}
37
+ {% if params.yAxis.tickIntervalDesktop %}
38
+ data-highcharts-y-axis-tick-interval-desktop="{{ params.yAxis.tickIntervalDesktop }}"
39
+ {% endif %}
40
+ {% if params.estimateLineLabel %}
41
+ data-highcharts-estimate-line-label="{{ params.estimateLineLabel }}"
42
+ {% endif %}
43
+ {% if params.uncertaintyRangeLabel %}
44
+ data-highcharts-uncertainty-range-label="{{ params.uncertaintyRangeLabel }}"
45
+ {% endif %}
46
+ {% if params.yAxis.customReferenceLineValue %}
47
+ data-highcharts-custom-reference-line-value="{{ params.yAxis.customReferenceLineValue }}"
48
+ {% endif %}
47
49
  {% endif %}
48
50
  >
49
51
  <figure class="ons-chart">
@@ -52,52 +54,59 @@
52
54
  {{ openingSubtitleTag | safe }}
53
55
  class="ons-chart__subtitle">{{ params.subtitle }}{{ closingSubtitleTag | safe }}
54
56
  {% endif %}
55
-
56
57
  {% if params.description %}
57
58
  <p class="ons-u-vh">{{ params.description }}</p>
58
59
  {% endif %}
59
- {% if params.chartType == 'boxplot' and (params.estimateLineLabel or params.uncertaintyRangeLabel) and params.legend == true %}
60
- <div class="ons-chart__boxplot-legend">
61
- {% if params.uncertaintyRangeLabel %}
62
- <div class="ons-chart__boxplot-legend-item">
63
- <span class="ons-chart__boxplot-legend-item ons-chart__boxplot-legend-item--uncertainty"></span>
64
- <span class="ons-chart__boxplot-legend-label">{{ params.uncertaintyRangeLabel }}</span>
65
- </div>
66
- {% endif %}
67
- {% if params.estimateLineLabel %}
68
- <div class="ons-chart__boxplot-legend-item">
69
- <span class="ons-chart__boxplot-legend-item ons-chart__boxplot-legend-item--estimate"></span>
70
- <span class="ons-chart__boxplot-legend-label">{{ params.estimateLineLabel }}</span>
71
- </div>
72
- {% endif %}
60
+ {% if params.iframeUrl %}
61
+ <div data-chart-iframe id="{{ params.id }}" data-url="{{ params.iframeUrl }}" data-title="{{ params.title }}">
62
+ <iframe src="{{ params.iframeUrl }}" title="{{ params.title }}" class="ons-chart__iframe"> </iframe>
73
63
  </div>
74
- {% endif %}
75
- {% if params.chartType in supportedChartTypes %}
76
- <div data-highcharts-chart></div>
77
64
  {% else %}
78
- <p data-invalid-chart-type><b>Chart type "{{ params.chartType }}" is not supported</b></p>
65
+ {% if params.chartType == 'boxplot' and (params.estimateLineLabel or params.uncertaintyRangeLabel) and params.legend == true %}
66
+ <div class="ons-chart__boxplot-legend">
67
+ {% if params.uncertaintyRangeLabel %}
68
+ <div class="ons-chart__boxplot-legend-item">
69
+ <span class="ons-chart__boxplot-legend-item ons-chart__boxplot-legend-item--uncertainty"></span>
70
+ <span class="ons-chart__boxplot-legend-label">{{ params.uncertaintyRangeLabel }}</span>
71
+ </div>
72
+ {% endif %}
73
+ {% if params.estimateLineLabel %}
74
+ <div class="ons-chart__boxplot-legend-item">
75
+ <span class="ons-chart__boxplot-legend-item ons-chart__boxplot-legend-item--estimate"></span>
76
+ <span class="ons-chart__boxplot-legend-label">{{ params.estimateLineLabel }}</span>
77
+ </div>
78
+ {% endif %}
79
+ </div>
80
+ {% endif %}
81
+ {% if params.chartType in supportedChartTypes %}
82
+ <div data-highcharts-chart class="ons-chart__chart"></div>
83
+ {% else %}
84
+ <p data-invalid-chart-type data-unsupported-chart-text>
85
+ <b>{{ '"' + params.chartType + '" - ' + (params.unsupportedChartText or 'chart type is not supported') }}</b>
86
+ </p>
87
+ {% endif %}
79
88
  {% endif %}
80
89
  {#
81
90
  Footnotes for the annotations at mobile
82
91
  Hidden from screen readers because the full text will be read out where they appear in the chart
83
92
  #}
84
- {% if params.annotations or params.rangeAnnotations or params.referenceLineAnnotations %}
85
- <ul class="ons-chart__footnotes" aria-hidden="true">
93
+ {% if (params.annotations or params.rangeAnnotations or params.referenceLineAnnotations) and not params.iframeUrl %}
94
+ <ul class="ons-chart__annotations-footnotes" aria-hidden="true" data-annotations-footnotes>
86
95
  {% for annotation in params.annotations %}
87
- <li class="ons-chart__footnote_item">
88
- <span class="ons-chart__footnote-number">{{ loop.index }}</span>
96
+ <li class="ons-chart__annotations-footnotes_item">
97
+ <span class="ons-chart__annotations-footnotes-number">{{ loop.index }}</span>
89
98
  {{ annotation.text }}
90
99
  </li>
91
100
  {% endfor %}
92
101
  {% for rangeAnnotation in params.rangeAnnotations %}
93
- <li class="ons-chart__footnote_item">
94
- <span class="ons-chart__footnote-number">{{ loop.index + params.annotations | length }}</span>
102
+ <li class="ons-chart__annotations-footnotes_item">
103
+ <span class="ons-chart__annotations-footnotes-number">{{ loop.index + params.annotations | length }}</span>
95
104
  {{ rangeAnnotation.text }}
96
105
  </li>
97
106
  {% endfor %}
98
107
  {% for referenceLineAnnotation in params.referenceLineAnnotations %}
99
- <li class="ons-chart__footnote_item">
100
- <span class="ons-chart__footnote-number"
108
+ <li class="ons-chart__annotations-footnotes_item">
109
+ <span class="ons-chart__annotations-footnotes-number"
101
110
  >{{ loop.index + params.annotations | length + params.rangeAnnotations | length }}</span
102
111
  >
103
112
  {{ referenceLineAnnotation.text }}
@@ -105,7 +114,6 @@
105
114
  {% endfor %}
106
115
  </ul>
107
116
  {% endif %}
108
-
109
117
  {% if params.caption %}
110
118
  <figcaption class="ons-chart__caption">{{ params.caption }}</figcaption>
111
119
  {% endif %}
@@ -121,94 +129,118 @@
121
129
  })
122
130
  }}
123
131
  {% endif %}
124
- {% if params.chartType in supportedChartTypes %}
125
- {% set series = [] %}
126
- {% set lineSeriesCount = 0 %}
127
- {% for item in params.series %}
128
- {% if item.type == 'line' and lineSeriesCount > 0 %}
129
- {# skip extra line series as the DS guidelines only allow for one extra line series #}
130
- {% else %}
131
- {%
132
- set seriesItem = {
133
- "name": item.name if item.name else '',
134
- "data": item.data if item.data else [],
135
- "marker": {
136
- "enabled": true if (item.type == 'scatter' or params.chartType == 'scatter' or item.marker == true) else false
132
+
133
+ {% if params.footnotes %}
134
+ {% set footnotesId = ["footnotes--", params.id] | join %}
135
+
136
+ {{
137
+ onsDetails({
138
+ "id": footnotesId,
139
+ "title": params.footnotes.title,
140
+ "content": params.footnotes.content,
141
+ "headingLevel": headingLevel + 2,
142
+ "classes": "ons-u-mt-xl"
143
+ })
144
+ }}
145
+ {% endif %}
146
+
147
+ {% if (params.chartType in supportedChartTypes) and not params.iframeUrl %}
148
+ {% set series = [] %}
149
+ {% set lineSeriesCount = 0 %}
150
+ {% for item in params.series %}
151
+ {% if item.type == 'line' and lineSeriesCount > 0 %}
152
+ {# skip extra line series as the DS guidelines only allow for one extra line series #}
153
+ {% else %}
154
+ {%
155
+ set seriesItem = {
156
+ "name": item.name if item.name else '',
157
+ "data": item.data if item.data else [],
158
+ "marker": {
159
+ "enabled": true if (item.type == 'scatter' or params.chartType == 'scatter' or item.marker == true) else false
160
+ },
161
+ "dataLabels": {
162
+ "enabled": item.dataLabels if item.dataLabels else false
163
+ },
164
+ "connectNulls": item.connectNulls if item.connectNulls else false,
165
+ "type": item.type if item.type and (item.type == 'line' and params.chartType in supportedChartTypesWithLine) or (item.type == 'scatter' and params.chartType in supportedChartTypesWithScatter) else params.chartType
166
+ }
167
+ %}
168
+ {# Use `set` tag to avoid printing the return value of extend #}
169
+ {% set _ = extend(series, seriesItem) %}
170
+ {% endif %}
171
+ {% if item.type == 'line' %}
172
+ {% set lineSeriesCount = lineSeriesCount + 1 %}
173
+ {% endif %}
174
+ {% endfor %}
175
+ {# Set the legend value to true by default #}
176
+ {% set legendValue = true %}
177
+ {% if params.legend is defined %}
178
+ {# if a legend parameter has been provided, check that it is a boolean #}
179
+ {% if params.legend == true or params.legend == false %}
180
+ {# legend value is a boolean - use the value passed in #}
181
+ {% set legendValue = params.legend %}
182
+ {% endif %}
183
+ {% endif %}
184
+ {%
185
+ set config = {
186
+ "chart": {
187
+ "type": params.chartType
188
+ },
189
+ "legend": {
190
+ "enabled" : legendValue
191
+ },
192
+ "yAxis": {
193
+ "title": {
194
+ "text": params.yAxis.title
137
195
  },
138
- "dataLabels": {
139
- "enabled": item.dataLabels if item.dataLabels else false
196
+ "labels": {
197
+ "format": params.yAxis.labelFormat
140
198
  },
141
- "connectNulls": item.connectNulls if item.connectNulls else false,
142
- "type": item.type if item.type and (item.type == 'line' and params.chartType in supportedChartTypesWithLine) or (item.type == 'scatter' and params.chartType in supportedChartTypesWithScatter) else params.chartType
143
- }
144
- %}
145
- {# Use `set` tag to avoid printing the return value of extend #}
146
- {% set _ = extend(series, seriesItem) %}
147
- {% endif %}
148
- {% if item.type == 'line' %}
149
- {% set lineSeriesCount = lineSeriesCount + 1 %}
150
- {% endif %}
151
- {% endfor %}
152
- {# Set the legend value to true by default #}
153
- {% set legendValue = true %}
154
- {% if params.legend is defined %}
155
- {# if a legend parameter has been provided, check that it is a boolean #}
156
- {% if params.legend == true or params.legend == false %}
157
- {# legend value is a boolean - use the value passed in #}
158
- {% set legendValue = params.legend %}
159
- {% endif %}
160
- {% endif %}
161
- {%
162
- set config = {
163
- "chart": {
164
- "type": params.chartType
165
- },
166
- "legend": {
167
- "enabled" : legendValue
168
- },
169
- "yAxis": {
170
- "title": {
171
- "text": params.yAxis.title
199
+ "min": params.yAxis.min if params.yAxis.min is defined and params.chartType in supportedChartTypesWithYAxisMinAndMax else undefined,
200
+ "max": params.yAxis.max if params.yAxis.max is defined and params.chartType in supportedChartTypesWithYAxisMinAndMax else undefined,
201
+ "startOnTick": params.yAxis.startOnTick if params.yAxis.startOnTick is defined and params.chartType in supportedChartTypesWithYAxisMinAndMax else undefined,
202
+ "endOnTick": params.yAxis.endOnTick if params.yAxis.endOnTick is defined and params.chartType in supportedChartTypesWithYAxisMinAndMax else undefined
172
203
  },
173
- "labels": {
174
- "format": params.yAxis.labelFormat
175
- }
176
- },
177
- "xAxis": {
178
- "title": {
179
- "text": params.xAxis.title
204
+ "xAxis": {
205
+ "title": {
206
+ "text": params.xAxis.title
207
+ },
208
+ "categories": params.xAxis.categories,
209
+ "type": params.xAxis.type,
210
+ "labels": {
211
+ "format": params.xAxis.labelFormat
212
+ },
213
+ "min": params.xAxis.min if params.xAxis.min is defined and params.chartType in supportedChartTypesWithXAxisMinAndMax else undefined,
214
+ "max": params.xAxis.max if params.xAxis.max is defined and params.chartType in supportedChartTypesWithXAxisMinAndMax else undefined,
215
+ "startOnTick": params.xAxis.startOnTick if params.xAxis.startOnTick is defined and params.chartType in supportedChartTypesWithXAxisMinAndMax else undefined,
216
+ "endOnTick": params.xAxis.endOnTick if params.xAxis.endOnTick is defined and params.chartType in supportedChartTypesWithXAxisMinAndMax else undefined
180
217
  },
181
- "categories": params.xAxis.categories,
182
- "type": params.xAxis.type,
183
- "labels": {
184
- "format": params.xAxis.labelFormat
185
- }
186
- },
187
- "series": series
188
- }
189
- %}
218
+ "series": series
219
+ }
220
+ %}
190
221
 
191
- <!-- Set scripts to pass the config values as json to the javascript -->
192
- <!-- prettier-ignore-start -->
222
+ <!-- Set scripts to pass the config values as json to the javascript -->
223
+ <!-- prettier-ignore-start -->
193
224
  <script type="application/json" data-highcharts-config--{{ params.id }}>
194
225
  {{ config | tojson }}
195
226
  </script>
227
+
228
+ {% if params.annotations %}
229
+ <script type="application/json" data-highcharts-annotations--{{ params.id }}>
230
+ {{ params.annotations | tojson }}
231
+ </script>
232
+ {% endif %}
233
+ {% if params.rangeAnnotations %}
234
+ <script type="application/json" data-highcharts-range-annotations--{{ params.id }}>
235
+ {{ params.rangeAnnotations | tojson }}
236
+ </script>
237
+ {% endif %}
238
+ {% if params.referenceLineAnnotations %}
239
+ <script type="application/json" data-highcharts-reference-line-annotations--{{ params.id }}>
240
+ {{ params.referenceLineAnnotations | tojson }}
241
+ </script>
242
+ {% endif %}
243
+ <!-- prettier-ignore-end -->
196
244
  {% endif %}
197
- {% if params.annotations %}
198
- <script type="application/json" data-highcharts-annotations--{{ params.id }}>
199
- {{ params.annotations | tojson }}
200
- </script>
201
- {% endif %}
202
- {% if params.rangeAnnotations %}
203
- <script type="application/json" data-highcharts-range-annotations--{{ params.id }}>
204
- {{ params.rangeAnnotations | tojson }}
205
- </script>
206
- {% endif %}
207
- {% if params.referenceLineAnnotations %}
208
- <script type="application/json" data-highcharts-reference-line-annotations--{{ params.id }}>
209
- {{ params.referenceLineAnnotations | tojson }}
210
- </script>
211
- {% endif %}
212
- <!-- prettier-ignore-end -->
213
245
  </div>
214
246
  {% endmacro %}