@ons/design-system 72.9.2 → 72.10.1
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/char-check-limit/_macro.njk +2 -2
- package/components/char-check-limit/character-check.js +30 -9
- package/components/char-check-limit/character-check.spec.js +1 -1
- package/components/chart/_chart.scss +73 -1
- package/components/chart/_macro.njk +90 -20
- package/components/chart/_macro.spec.js +424 -0
- package/components/chart/bar-chart.js +46 -20
- package/components/chart/boxplot.js +37 -0
- package/components/chart/chart-constants.js +14 -0
- package/components/chart/chart.js +102 -46
- package/components/chart/columnrange-chart.js +94 -0
- package/components/chart/common-chart-options.js +65 -23
- package/components/chart/example-bar-chart-with-annotations.njk +1 -1
- package/components/chart/example-bar-chart-with-point-range-and-reference-line-annotations.njk +95 -0
- package/components/chart/example-bar-with-confidence-levels.njk +71 -0
- package/components/chart/example-clustered-column-chart.njk +1 -3
- package/components/chart/example-column-chart-with-annotations.njk +1 -1
- package/components/chart/example-column-chart-with-custom-reference-line-value.njk +56 -0
- package/components/chart/example-column-chart-with-range-annotations.njk +64 -0
- package/components/chart/example-column-chart-with-reference-line-annotations.njk +64 -0
- package/components/chart/example-column-with-confidence-levels.njk +61 -0
- package/components/chart/example-line-chart-with-annotations.njk +3 -3
- package/components/chart/example-line-chart-with-custom-reference-line-value.njk +224 -0
- package/components/chart/example-line-chart-with-markers.njk +21 -21
- package/components/chart/example-line-chart-with-range-annotations-inside.njk +238 -0
- package/components/chart/example-line-chart-with-range-annotations-outside-left-right.njk +240 -0
- package/components/chart/example-line-chart-with-range-annotations-outside-top-bottom.njk +239 -0
- package/components/chart/example-line-chart-with-reference-line-annotations.njk +236 -0
- package/components/chart/example-scatter-chart.njk +5 -5
- package/components/chart/line-chart.js +29 -11
- package/components/chart/range-annotations-options.js +221 -0
- package/components/chart/reference-line-annotations-options.js +93 -0
- package/components/chart/scatter-chart.js +15 -6
- package/components/chart/specific-chart-options.js +22 -1
- package/components/chart/utilities.js +97 -0
- package/components/checkboxes/_macro.spec.js +1 -1
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +1 -1
- package/components/textarea/_macro.njk +8 -6
- package/components/textarea/_macro.spec.js +12 -8
- package/components/textarea/{example-textarea-with-character-limit.njk → example-textarea-with-character-check.njk} +3 -1
- package/css/main.css +1 -1
- package/js/main.js +0 -1
- package/package.json +14 -14
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/components/char-check-limit/character-limit.js +0 -55
- package/components/textarea/textarea.dom.js +0 -12
- package/components/textarea/textarea.spec.js +0 -98
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
class="ons-input__limit ons-u-fs-s--b ons-u-d-no ons-u-mt-2xs"
|
|
9
9
|
data-charcount-singular="{{ params.charCountSingular }}"
|
|
10
10
|
data-charcount-plural="{{ params.charCountPlural }}"
|
|
11
|
-
data-charcount-limit-singular="{{ params.charCountOverLimitSingular }}"
|
|
12
|
-
data-charcount-limit-plural="{{ params.charCountOverLimitPlural }}"
|
|
11
|
+
data-charcount-limit-singular="{{ params.charCountOverLimitSingular | default("You have exceeded the character limit by {x} character") }}"
|
|
12
|
+
data-charcount-limit-plural="{{ params.charCountOverLimitPlural | default("You have exceeded the character limit by {x} characters") }}"
|
|
13
13
|
>
|
|
14
14
|
</span>
|
|
15
15
|
{% endmacro %}
|
|
@@ -6,9 +6,18 @@ const attrCharCheckVal = 'data-char-check-num';
|
|
|
6
6
|
|
|
7
7
|
export default class CharCheck {
|
|
8
8
|
constructor(context) {
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
this.tagName = context.tagName;
|
|
10
|
+
|
|
11
|
+
// Handle either an input directly or a container with an input inside
|
|
12
|
+
if (this.tagName.toLowerCase() === 'input' || this.tagName.toLowerCase() === 'textarea') {
|
|
13
|
+
this.input = context;
|
|
14
|
+
} else {
|
|
15
|
+
this.input = context.querySelector('input');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Find the button: if input is passed directly, look at its parent
|
|
19
|
+
let parent = this.input.parentNode;
|
|
20
|
+
this.button = parent ? parent.querySelector('button') : null;
|
|
12
21
|
this.checkElement = document.getElementById(this.input.getAttribute(attrCharCheckRef));
|
|
13
22
|
this.checkVal = this.input.getAttribute(attrCharCheckVal);
|
|
14
23
|
this.countdown = this.input.getAttribute(attrCharCheckCountdown) || false;
|
|
@@ -22,15 +31,17 @@ export default class CharCheck {
|
|
|
22
31
|
if (this.button) {
|
|
23
32
|
this.setButtonState(this.checkVal);
|
|
24
33
|
}
|
|
34
|
+
|
|
25
35
|
this.input.addEventListener('input', this.updateCheckReadout.bind(this));
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
updateCheckReadout(event, firstRun) {
|
|
29
39
|
const value = this.input.value;
|
|
30
|
-
const remaining = this.checkVal - value
|
|
40
|
+
const remaining = this.checkVal - this.getCharLength(value);
|
|
41
|
+
|
|
31
42
|
// Prevent aria live announcement when component initialises
|
|
32
43
|
if (!firstRun && event.inputType) {
|
|
33
|
-
this.checkElement.setAttribute('aria-live', 'polite');
|
|
44
|
+
this.checkElement.setAttribute('aria-live', [remaining > 0 ? 'polite' : 'assertive']);
|
|
34
45
|
} else {
|
|
35
46
|
this.checkElement.removeAttribute('aria-live');
|
|
36
47
|
}
|
|
@@ -67,13 +78,23 @@ export default class CharCheck {
|
|
|
67
78
|
}
|
|
68
79
|
|
|
69
80
|
setShowMessage(remaining) {
|
|
70
|
-
this.
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
if (this.tagName.toLowerCase() === 'textarea') {
|
|
82
|
+
// Always display the remaining character message for textarea
|
|
83
|
+
this.checkElement.classList['remove']('ons-u-d-no');
|
|
84
|
+
} else {
|
|
85
|
+
this.checkElement.classList[(remaining < this.checkVal && remaining > 0 && this.countdown) || remaining < 0 ? 'remove' : 'add'](
|
|
86
|
+
'ons-u-d-no',
|
|
87
|
+
);
|
|
88
|
+
}
|
|
73
89
|
}
|
|
74
90
|
|
|
75
91
|
setCheckClass(remaining, element, setClass) {
|
|
76
92
|
element.classList[remaining < 0 ? 'add' : 'remove'](setClass);
|
|
77
|
-
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getCharLength(text) {
|
|
96
|
+
// line breaks count as two characters as forms convert to \n\r when submitted
|
|
97
|
+
const lineBreaks = (text.match(/\n/g) || []).length;
|
|
98
|
+
return text.length + lineBreaks;
|
|
78
99
|
}
|
|
79
100
|
}
|
|
@@ -192,7 +192,7 @@ describe('script: character-check', () => {
|
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
it('then aria-live attribute should removed', async () => {
|
|
195
|
-
const hasAriaLiveAttribute = await page.$eval('#feedback-
|
|
195
|
+
const hasAriaLiveAttribute = await page.$eval('#feedback-check', (element) => element.hasAttribute('aria-live'));
|
|
196
196
|
expect(hasAriaLiveAttribute).toBe(false);
|
|
197
197
|
});
|
|
198
198
|
});
|
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
&__footnote-number {
|
|
28
|
-
|
|
28
|
+
// !important is necessary for some range annotation labels at mobile, otherwise
|
|
29
|
+
// the inline-styled block display takes precedence. This inline style is only
|
|
30
|
+
// applied in some cases - it seems to happen when the shaded area is narrower than the label width.
|
|
31
|
+
display: flex !important;
|
|
29
32
|
flex-shrink: 0;
|
|
30
33
|
flex-grow: 0;
|
|
31
34
|
align-items: center;
|
|
@@ -72,6 +75,38 @@
|
|
|
72
75
|
font-size: 0.875rem; // 14px
|
|
73
76
|
color: var(--ons-color-grey-100);
|
|
74
77
|
}
|
|
78
|
+
|
|
79
|
+
&__boxplot-legend {
|
|
80
|
+
display: flex;
|
|
81
|
+
gap: 2rem;
|
|
82
|
+
font-size: 0.875rem; // 14px
|
|
83
|
+
padding-left: 1rem;
|
|
84
|
+
align-items: center;
|
|
85
|
+
|
|
86
|
+
&-item {
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
gap: 0.5rem;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&-item {
|
|
93
|
+
&--uncertainty {
|
|
94
|
+
width: 14px;
|
|
95
|
+
height: 14px;
|
|
96
|
+
background-color: rgb(32 96 149 / 65%);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&--estimate {
|
|
100
|
+
width: 20px;
|
|
101
|
+
height: 3px;
|
|
102
|
+
background-color: #003c57;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&-label {
|
|
107
|
+
font-size: inherit;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
75
110
|
}
|
|
76
111
|
|
|
77
112
|
// This is a workaround to position the axis title to the left
|
|
@@ -88,3 +123,40 @@
|
|
|
88
123
|
.highcharts-a11y-proxy-group-legend button {
|
|
89
124
|
cursor: auto !important;
|
|
90
125
|
}
|
|
126
|
+
|
|
127
|
+
.ons-chart__range-annotation-label {
|
|
128
|
+
&--x {
|
|
129
|
+
padding: 0 1.25rem;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&--outside {
|
|
133
|
+
padding: 0;
|
|
134
|
+
overflow: visible !important;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
&--right {
|
|
138
|
+
text-align: left !important;
|
|
139
|
+
padding-left: 0.3125rem;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&--left {
|
|
143
|
+
text-align: right !important;
|
|
144
|
+
padding-right: 0.3125rem;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&--top {
|
|
148
|
+
text-align: center !important;
|
|
149
|
+
padding-bottom: 0.3125rem;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
&--bottom {
|
|
153
|
+
text-align: center !important;
|
|
154
|
+
padding-top: 0.3125rem;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.ons-chart__connector-line {
|
|
159
|
+
position: absolute;
|
|
160
|
+
border-top: 1px solid var(--ons-color-grey-100);
|
|
161
|
+
border-left: 1px solid var(--ons-color-grey-100);
|
|
162
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{% from "components/list/_macro.njk" import onsList %}
|
|
2
2
|
|
|
3
3
|
{% macro onsChart(params) %}
|
|
4
|
-
{% set supportedChartTypes = ['line', 'bar', 'column', 'scatter', 'area'] %}
|
|
5
|
-
{% set supportedChartTypesWithLine = ['column'] %}
|
|
4
|
+
{% set supportedChartTypes = ['line', 'bar', 'column', 'scatter', 'area', 'columnrange', 'boxplot'] %}
|
|
5
|
+
{% set supportedChartTypesWithLine = ['column', 'columnrange'] %}
|
|
6
|
+
{% set supportedChartTypesWithScatter = ['columnrange'] %}
|
|
6
7
|
|
|
7
8
|
{% if params.headingLevel and params.headingLevel >= 1 and params.headingLevel <= 4 %}
|
|
8
9
|
{% set headingLevel = params.headingLevel %}
|
|
@@ -15,7 +16,6 @@
|
|
|
15
16
|
{% set closingSubtitleTag = "</h" ~ (headingLevel + 1) ~ ">" %}
|
|
16
17
|
{% set openingDownloadTitleTag = "<h" ~ (headingLevel + 2) %}
|
|
17
18
|
{% set closingDownloadTitleTag = "</h" ~ (headingLevel + 2) ~ ">" %}
|
|
18
|
-
|
|
19
19
|
<div
|
|
20
20
|
data-highcharts-base-chart
|
|
21
21
|
data-highcharts-type="{{ params.chartType }}"
|
|
@@ -41,6 +41,15 @@
|
|
|
41
41
|
{% if params.yAxis.tickIntervalDesktop %}
|
|
42
42
|
data-highcharts-y-axis-tick-interval-desktop="{{ params.yAxis.tickIntervalDesktop }}"
|
|
43
43
|
{% endif %}
|
|
44
|
+
{% if params.estimateLineLabel %}
|
|
45
|
+
data-highcharts-estimate-line-label="{{ params.estimateLineLabel }}"
|
|
46
|
+
{% endif %}
|
|
47
|
+
{% if params.uncertaintyRangeLabel %}
|
|
48
|
+
data-highcharts-uncertainty-range-label="{{ params.uncertaintyRangeLabel }}"
|
|
49
|
+
{% endif %}
|
|
50
|
+
{% if params.yAxis.customReferenceLineValue %}
|
|
51
|
+
data-highcharts-custom-reference-line-value="{{ params.yAxis.customReferenceLineValue }}"
|
|
52
|
+
{% endif %}
|
|
44
53
|
>
|
|
45
54
|
<figure class="ons-chart">
|
|
46
55
|
{{ openingTitleTag | safe }} class="ons-chart__title">{{ params.title }}{{ closingTitleTag | safe }}
|
|
@@ -49,6 +58,22 @@
|
|
|
49
58
|
{% if params.description %}
|
|
50
59
|
<p class="ons-u-vh">{{ params.description }}</p>
|
|
51
60
|
{% endif %}
|
|
61
|
+
{% if params.chartType == 'boxplot' and (params.estimateLineLabel or params.uncertaintyRangeLabel) and params.legend == true %}
|
|
62
|
+
<div class="ons-chart__boxplot-legend">
|
|
63
|
+
{% if params.uncertaintyRangeLabel %}
|
|
64
|
+
<div class="ons-chart__boxplot-legend-item">
|
|
65
|
+
<span class="ons-chart__boxplot-legend-item ons-chart__boxplot-legend-item--uncertainty"></span>
|
|
66
|
+
<span class="ons-chart__boxplot-legend-label">{{ params.uncertaintyRangeLabel }}</span>
|
|
67
|
+
</div>
|
|
68
|
+
{% endif %}
|
|
69
|
+
{% if params.estimateLineLabel %}
|
|
70
|
+
<div class="ons-chart__boxplot-legend-item">
|
|
71
|
+
<span class="ons-chart__boxplot-legend-item ons-chart__boxplot-legend-item--estimate"></span>
|
|
72
|
+
<span class="ons-chart__boxplot-legend-label">{{ params.estimateLineLabel }}</span>
|
|
73
|
+
</div>
|
|
74
|
+
{% endif %}
|
|
75
|
+
</div>
|
|
76
|
+
{% endif %}
|
|
52
77
|
{% if params.chartType in supportedChartTypes %}
|
|
53
78
|
<div data-highcharts-chart></div>
|
|
54
79
|
{% else %}
|
|
@@ -65,6 +90,20 @@
|
|
|
65
90
|
{{ annotation.text }}
|
|
66
91
|
</li>
|
|
67
92
|
{% endfor %}
|
|
93
|
+
{% for rangeAnnotation in params.rangeAnnotations %}
|
|
94
|
+
<li class="ons-chart__footnote_item">
|
|
95
|
+
<span class="ons-chart__footnote-number">{{ loop.index + params.annotations | length }}</span>
|
|
96
|
+
{{ rangeAnnotation.text }}
|
|
97
|
+
</li>
|
|
98
|
+
{% endfor %}
|
|
99
|
+
{% for referenceLineAnnotation in params.referenceLineAnnotations %}
|
|
100
|
+
<li class="ons-chart__footnote_item">
|
|
101
|
+
<span class="ons-chart__footnote-number"
|
|
102
|
+
>{{ loop.index + params.annotations | length + params.rangeAnnotations | length }}</span
|
|
103
|
+
>
|
|
104
|
+
{{ referenceLineAnnotation.text }}
|
|
105
|
+
</li>
|
|
106
|
+
{% endfor %}
|
|
68
107
|
</ul>
|
|
69
108
|
{% if params.caption %}
|
|
70
109
|
<figcaption class="ons-chart__caption">{{ params.caption }}</figcaption>
|
|
@@ -83,28 +122,49 @@
|
|
|
83
122
|
{% endif %}
|
|
84
123
|
{% if params.chartType in supportedChartTypes %}
|
|
85
124
|
{% set series = [] %}
|
|
125
|
+
{% set lineSeriesCount = 0 %}
|
|
86
126
|
{% for item in params.series %}
|
|
87
|
-
{%
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
127
|
+
{% if item.type == 'line' and lineSeriesCount > 0 %}
|
|
128
|
+
{# skip extra line series as the DS guidelines only allow for one extra line series #}
|
|
129
|
+
{% else %}
|
|
130
|
+
{%
|
|
131
|
+
set seriesItem = {
|
|
132
|
+
"name": item.name if item.name else '',
|
|
133
|
+
"data": item.data if item.data else [],
|
|
134
|
+
"marker": {
|
|
135
|
+
"enabled": item.marker if item.marker else false
|
|
136
|
+
},
|
|
137
|
+
"dataLabels": {
|
|
138
|
+
"enabled": item.dataLabels if item.dataLabels else false
|
|
139
|
+
},
|
|
140
|
+
"connectNulls": item.connectNulls if item.connectNulls else false,
|
|
141
|
+
"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
|
|
142
|
+
}
|
|
143
|
+
%}
|
|
144
|
+
{# Use `set` tag to avoid printing the return value of extend #}
|
|
145
|
+
{% set _ = extend(series, seriesItem) %}
|
|
146
|
+
{% endif %}
|
|
147
|
+
{% if item.type == 'line' %}
|
|
148
|
+
{% set lineSeriesCount = lineSeriesCount + 1 %}
|
|
149
|
+
{% endif %}
|
|
103
150
|
{% endfor %}
|
|
151
|
+
{# Set the legend value to true by default #}
|
|
152
|
+
{% set legendValue = true %}
|
|
153
|
+
{% if params.legend is defined %}
|
|
154
|
+
{# if a legend parameter has been provided, check that it is a boolean #}
|
|
155
|
+
{% if params.legend == true or params.legend == false %}
|
|
156
|
+
{# legend value is a boolean - use the value passed in #}
|
|
157
|
+
{% set legendValue = params.legend %}
|
|
158
|
+
{% endif %}
|
|
159
|
+
{% endif %}
|
|
104
160
|
{%
|
|
105
161
|
set config = {
|
|
162
|
+
"chart": {
|
|
163
|
+
"type": params.chartType,
|
|
164
|
+
"inverted": params.isChartInverted if params.isChartInverted == true else false
|
|
165
|
+
},
|
|
106
166
|
"legend": {
|
|
107
|
-
"enabled" :
|
|
167
|
+
"enabled" : legendValue
|
|
108
168
|
},
|
|
109
169
|
"yAxis": {
|
|
110
170
|
"title": {
|
|
@@ -139,6 +199,16 @@
|
|
|
139
199
|
{{ params.annotations | tojson }}
|
|
140
200
|
</script>
|
|
141
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 %}
|
|
142
212
|
<!-- prettier-ignore-end -->
|
|
143
213
|
</div>
|
|
144
214
|
{% endmacro %}
|