@ons/design-system 72.10.0 → 72.10.2

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 (32) hide show
  1. package/components/char-check-limit/_macro.njk +2 -2
  2. package/components/char-check-limit/character-check.js +30 -9
  3. package/components/char-check-limit/character-check.spec.js +1 -1
  4. package/components/chart/_chart.scss +2 -3
  5. package/components/chart/_macro.njk +27 -16
  6. package/components/chart/_macro.spec.js +19 -0
  7. package/components/chart/bar-chart.js +46 -20
  8. package/components/chart/chart-constants.js +1 -0
  9. package/components/chart/chart.js +17 -1
  10. package/components/chart/common-chart-options.js +57 -28
  11. package/components/chart/example-column-chart-with-custom-reference-line-value.njk +56 -0
  12. package/components/chart/example-line-chart-with-custom-reference-line-value.njk +224 -0
  13. package/components/chart/example-line-chart-with-markers.njk +20 -20
  14. package/components/chart/example-scatter-chart.njk +4 -4
  15. package/components/chart/line-chart.js +29 -11
  16. package/components/chart/range-annotations-options.js +6 -1
  17. package/components/chart/scatter-chart.js +0 -6
  18. package/components/chart/specific-chart-options.js +21 -0
  19. package/components/chart/utilities.js +8 -7
  20. package/components/checkboxes/_macro.spec.js +1 -1
  21. package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +1 -1
  22. package/components/textarea/_macro.njk +8 -6
  23. package/components/textarea/_macro.spec.js +12 -8
  24. package/components/textarea/{example-textarea-with-character-limit.njk → example-textarea-with-character-check.njk} +3 -1
  25. package/css/main.css +1 -1
  26. package/js/main.js +0 -1
  27. package/package.json +14 -14
  28. package/scripts/main.es5.js +1 -1
  29. package/scripts/main.js +1 -1
  30. package/components/char-check-limit/character-limit.js +0 -55
  31. package/components/textarea/textarea.dom.js +0 -12
  32. package/components/textarea/textarea.spec.js +0 -98
@@ -0,0 +1,224 @@
1
+ {% from "components/chart/_macro.njk" import onsChart %}
2
+
3
+ {{
4
+ onsChart({
5
+ "chartType": "line",
6
+ "description": "Line chart showing the annual rate of inflation for the Consumer Prices Index including owner occupiers’ housing costs (CPIH) and its components.",
7
+ "theme": "alternate",
8
+ "title": "Sales volumes and values saw moderate growth in July 2024",
9
+ "subtitle": "Figure 6: Upward contribution from housing and household services (including energy) saw the annual CPIH inflation rate rise",
10
+ "id": "id",
11
+ "headingLevel": 4,
12
+ "caption": "Source: Monthly Business Survey, Retails Sales Inquiry from the Office for National Statistics",
13
+ "download": {
14
+ 'title': 'Download Figure 1 data',
15
+ 'itemsList': [
16
+ {
17
+ "text": "Excel spreadsheet (XLSX format, 18KB)",
18
+ "url": "#"
19
+ },
20
+ {
21
+ "text": "Simple text file (CSV format, 25KB)",
22
+ "url": "#"
23
+ },
24
+ {
25
+
26
+ "text": "Image (PNG format, 25KB)",
27
+ "url": "#"
28
+ }
29
+ ]},
30
+ "legend": true,
31
+ "xAxis": {
32
+ "title": "Year",
33
+ "type": "linear",
34
+ "labelFormat": "{value:,.f}",
35
+ "categories": [
36
+ 'Oct 2014',
37
+ 'Nov 2014',
38
+ 'Dec 2014',
39
+ 'Jan 2015',
40
+ 'Feb 2015',
41
+ 'Mar 2015',
42
+ 'Apr 2015',
43
+ 'May 2015',
44
+ 'Jun 2015',
45
+ 'Jul 2015',
46
+ 'Aug 2015',
47
+ 'Sep 2015',
48
+ 'Oct 2015',
49
+ 'Nov 2015',
50
+ 'Dec 2015',
51
+ 'Jan 2016',
52
+ 'Feb 2016',
53
+ 'Mar 2016',
54
+ 'Apr 2016',
55
+ 'May 2016',
56
+ 'Jun 2016',
57
+ 'Jul 2016',
58
+ 'Aug 2016',
59
+ 'Sep 2016',
60
+ 'Oct 2016',
61
+ 'Nov 2016',
62
+ 'Dec 2016',
63
+ 'Jan 2017',
64
+ 'Feb 2017',
65
+ 'Mar 2017',
66
+ 'Apr 2017',
67
+ 'May 2017',
68
+ 'Jun 2017',
69
+ 'Jul 2017',
70
+ 'Aug 2017',
71
+ 'Sep 2017',
72
+ 'Oct 2017',
73
+ 'Nov 2017',
74
+ 'Dec 2017',
75
+ 'Jan 2018',
76
+ 'Feb 2018',
77
+ 'Mar 2018',
78
+ 'Apr 2018',
79
+ 'May 2018',
80
+ 'Jun 2018',
81
+ 'Jul 2018',
82
+ 'Aug 2018',
83
+ 'Sep 2018',
84
+ 'Oct 2018',
85
+ 'Nov 2018',
86
+ 'Dec 2018',
87
+ 'Jan 2019',
88
+ 'Feb 2019',
89
+ 'Mar 2019',
90
+ 'Apr 2019',
91
+ 'May 2019',
92
+ 'Jun 2019',
93
+ 'Jul 2019',
94
+ 'Aug 2019',
95
+ 'Sep 2019',
96
+ 'Oct 2019',
97
+ 'Nov 2019',
98
+ 'Dec 2019',
99
+ 'Jan 2020',
100
+ 'Feb 2020',
101
+ 'Mar 2020',
102
+ 'Apr 2020',
103
+ 'May 2020',
104
+ 'Jun 2020',
105
+ 'Jul 2020',
106
+ 'Aug 2020',
107
+ 'Sep 2020',
108
+ 'Oct 2020',
109
+ 'Nov 2020',
110
+ 'Dec 2020',
111
+ 'Jan 2021',
112
+ 'Feb 2021',
113
+ 'Mar 2021',
114
+ 'Apr 2021',
115
+ 'May 2021',
116
+ 'Jun 2021',
117
+ 'Jul 2021',
118
+ 'Aug 2021',
119
+ 'Sep 2021',
120
+ 'Oct 2021',
121
+ 'Nov 2021',
122
+ 'Dec 2021',
123
+ 'Jan 2022',
124
+ 'Feb 2022',
125
+ 'Mar 2022',
126
+ 'Apr 2022',
127
+ 'May 2022',
128
+ 'Jun 2022',
129
+ 'Jul 2022',
130
+ 'Aug 2022',
131
+ 'Sep 2022',
132
+ 'Oct 2022',
133
+ 'Nov 2022',
134
+ 'Dec 2022',
135
+ 'Jan 2023',
136
+ 'Feb 2023',
137
+ 'Mar 2023',
138
+ 'Apr 2023',
139
+ 'May 2023',
140
+ 'Jun 2023',
141
+ 'Jul 2023',
142
+ 'Aug 2023',
143
+ 'Sep 2023',
144
+ 'Oct 2023',
145
+ 'Nov 2023',
146
+ 'Dec 2023',
147
+ 'Jan 2024',
148
+ 'Feb 2024',
149
+ 'Mar 2024',
150
+ 'Apr 2024',
151
+ 'May 2024',
152
+ 'Jun 2024',
153
+ 'Jul 2024',
154
+ 'Aug 2024',
155
+ 'Sep 2024',
156
+ 'Oct 2024'
157
+ ],
158
+ "tickIntervalDesktop": 15,
159
+ "tickIntervalMobile": 30
160
+ },
161
+ "yAxis": {
162
+ "title": "Sales",
163
+ "labelFormat": "{value:,.f}",
164
+ "customReferenceLineValue": 5
165
+ },
166
+ "series": [
167
+ {
168
+ "name": 'CPIH',
169
+ "data": [
170
+ 1.3, 1.1, 0.7, 0.5, 0.4, 0.3, 0.3, 0.4, 0.3, 0.5, 0.4, 0.2, 0.2, 0.4, 0.5, 0.6,
171
+ 0.6, 0.8, 0.7, 0.7, 0.8, 0.9, 1.0, 1.3, 1.3, 1.5, 1.8, 1.9, 2.3, 2.3, 2.6, 2.7,
172
+ 2.6, 2.6, 2.7, 2.8, 2.8, 2.8, 2.7, 2.7, 2.5, 2.3, 2.2, 2.3, 2.3, 2.3, 2.4, 2.2,
173
+ 2.2, 2.2, 2.0, 1.8, 1.8, 1.8, 2.0, 1.9, 1.9, 2.0, 1.7, 1.7, 1.5, 1.5, 1.4, 1.8,
174
+ 1.7, 1.5, 0.9, 0.7, 0.8, 1.1, 0.5, 0.7, 0.9, 0.6, 0.8, 0.9, 0.7, 1.0, 1.6, 2.1,
175
+ 2.4, 2.1, 3.0, 2.9, 3.8, 4.6, 4.8, 4.9, 5.5, 6.2, 7.8, 7.9, 8.2, 8.8, 8.6, 8.8,
176
+ 9.6, 9.3, 9.2, 8.8, 9.2, 8.9, 7.8, 7.9, 7.3, 6.4, 6.3, 6.3, 4.7, 4.2, 4.2, 4.2,
177
+ 3.8, 3.8, 3.0, 2.8, 2.8, 3.1, 3.1, 2.6, 3.2
178
+ ]
179
+ },
180
+ {
181
+ "name": 'Goods',
182
+ "data": [
183
+ 0.3, -0.2, -1.0, -1.5, -2.0, -2.1, -1.9, -1.8, -2.0, -1.8, -2.0, -2.4, -2.1,
184
+ -1.9,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
  "data": [
56
56
  1.3, null, 0.7, 0.5, 0.4, 0.3, 0.3, 0.4, 0.3, 0.5
57
57
  ],
58
- "marker": 'true',
59
- "connectNulls": 'true'
58
+ "marker": true,
59
+ "connectNulls": true
60
60
  },
61
61
  {
62
62
  "name": 'Goods',
63
63
  "data": [
64
64
  0.3, -0.2, -1.0, null, -2.0, -2.1, -1.9, -1.8, -2.0, -1.8
65
65
  ],
66
- "marker": 'true',
67
- "connectNulls": 'true'
66
+ "marker": true,
67
+ "connectNulls": true
68
68
  },
69
69
  {
70
70
  "name": 'Services',
71
71
  "data": [
72
72
  2.2, 2.1, 2.1, 2.1, 2.2, 2.2, 2.0, 2.1, 2.1, 2.2
73
73
  ],
74
- "marker": 'true',
75
- "connectNulls": 'true'
74
+ "marker": true,
75
+ "connectNulls": true
76
76
  },
77
77
  {
78
78
  "name": 'CPIH excl energy, food, alcohol & tobacco',
79
79
  "data": [
80
80
  1.5, 1.3, 1.4, 1.5, 1.4, 1.2, 1.1, 1.2, 1.0, 1.3
81
81
  ],
82
- "marker": 'true',
83
- "connectNulls": 'true'
82
+ "marker": true,
83
+ "connectNulls": true
84
84
  }
85
85
  ,
86
86
  {
@@ -88,48 +88,48 @@
88
88
  "data": [
89
89
  3.2, 3.7, 3.8, 3.9, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7
90
90
  ],
91
- "marker": 'true',
92
- "connectNulls": 'true'
91
+ "marker": true,
92
+ "connectNulls": true
93
93
  },
94
94
  {
95
95
  "name": 'Extra test series 2',
96
96
  "data": [
97
97
  4.5, 4.3, 4.4, 4.5, 4.4, 4.2, 4.1, 4.2, 4.0, 4.3
98
98
  ],
99
- "marker": 'true',
100
- "connectNulls": 'true'
99
+ "marker": true,
100
+ "connectNulls": true
101
101
  },
102
102
  {
103
103
  "name": 'Extra test series 3',
104
104
  "data": [
105
105
  5.5, 5.3, 5.4, 5.5, 5.4, 5.2, 5.1, 5.2, 5.0, 5.3
106
106
  ],
107
- "marker": 'true',
108
- "connectNulls": 'true'
107
+ "marker": true,
108
+ "connectNulls": true
109
109
  },
110
110
  {
111
111
  "name": 'Extra test series 4',
112
112
  "data": [
113
113
  -3.5, -3.3, -3.4, -3.5, -3.4, -3.2, -3.1, -3.2, -3.0, -3.3
114
114
  ],
115
- "marker": 'true',
116
- "connectNulls": 'true'
115
+ "marker": true,
116
+ "connectNulls": true
117
117
  },
118
118
  {
119
119
  "name": 'Extra test series 5',
120
120
  "data": [
121
121
  -4.5, -4.3, -4.4, -4.5, -4.4, -4.2, -4.1, -4.2, -4.0, -4.3
122
122
  ],
123
- "marker": 'true',
124
- "connectNulls": 'true'
123
+ "marker": true,
124
+ "connectNulls": true
125
125
  },
126
126
  {
127
127
  "name": 'Extra test series 6',
128
128
  "data": [
129
129
  -5.5, -5.3, -5.4, -5.5, -5.4, -5.2, -5.1, -5.2, -5.0, -5.3
130
130
  ],
131
- "marker": 'true',
132
- "connectNulls": 'true'
131
+ "marker": true,
132
+ "connectNulls": true
133
133
  }
134
134
  ],
135
135
  "percentageHeightDesktop": 35,
@@ -47,7 +47,7 @@
47
47
  [162.7, 55.4], [166.4, 58.4], [159.4, 51.5], [164.8, 56.5],
48
48
  [158.6, 50.6], [163.4, 53.5]
49
49
  ],
50
- "marker": 'true'
50
+ "marker": true
51
51
  },
52
52
  {
53
53
  "name": "Male",
@@ -61,7 +61,7 @@
61
61
  [184.1, 73.4], [179.2, 70.8], [186.6, 79.8], [183.4, 75.4],
62
62
  [177.8, 69.6], [185.5, 76.7]
63
63
  ],
64
- "marker": 'true'
64
+ "marker": true
65
65
  },
66
66
  {
67
67
  "name": "Adolescent Male",
@@ -73,7 +73,7 @@
73
73
  [170.2, 61.6], [172.4, 64.2], [168.2, 58.1], [173.9, 64.8],
74
74
  [169.8, 60.7], [171.4, 63.6]
75
75
  ],
76
- "marker": 'true'
76
+ "marker": true
77
77
  },
78
78
  {
79
79
  "name": "Adolescent Female",
@@ -85,7 +85,7 @@
85
85
  [162.6, 52.5], [167.5, 58.4], [164.4, 55.6], [166.6, 57.6],
86
86
  [163.8, 53.7], [165.2, 56.9]
87
87
  ],
88
- "marker": 'true'
88
+ "marker": true
89
89
  }
90
90
  ],
91
91
  "percentageHeightDesktop": 35,
@@ -12,24 +12,42 @@ class LineChart {
12
12
  lineWidth: 3,
13
13
  linecap: 'round',
14
14
  },
15
+ marker: {
16
+ enabled: true,
17
+ },
18
+ },
19
+ };
20
+ };
21
+
22
+ getExtraLineChartOptions = () => {
23
+ return {
24
+ plotOptions: {
25
+ line: {
26
+ color: this.chartConstants.extraLineColor,
27
+ },
15
28
  },
16
29
  };
17
30
  };
18
31
 
32
+ // Customise line charts which are set to hide markers
33
+ // so that the last point marker displays (at the end of the line)
19
34
  updateLastPointMarker = (series) => {
20
35
  series.forEach((series, i) => {
21
- const points = series.points;
22
- if (points && points.length > 0) {
23
- // Show only the last point marker
24
- const lastPoint = points[points.length - 1];
25
- lastPoint.update({
26
- marker: {
27
- enabled: true,
28
- },
29
- });
30
- // Update the marker styles to use for each series
31
- series.update({ marker: this.markerStyles[i] != undefined ? this.markerStyles[i] : this.markerStyles[0] }, false);
36
+ if (series.userOptions.marker.enabled === false) {
37
+ const points = series.points;
38
+
39
+ if (points && points.length > 0) {
40
+ // Show only the last point marker
41
+ const lastPoint = points[points.length - 1];
42
+ lastPoint.update({
43
+ marker: {
44
+ enabled: true,
45
+ },
46
+ });
47
+ }
32
48
  }
49
+ // Update the marker styles to use for each series
50
+ series.update({ marker: this.markerStyles[i] != undefined ? this.markerStyles[i] : this.markerStyles[0] }, false);
33
51
  });
34
52
  };
35
53
  }
@@ -11,6 +11,10 @@ class RangeAnnotationsOptions {
11
11
  let yAxisPlotBands = [];
12
12
  this.rangeAnnotations.forEach((rangeAnnotation) => {
13
13
  let adjustedRangeValues = this.adjustRangeForCategoryAxis(rangeAnnotation, chartType);
14
+ let rangeAnnotationLabelWidth = undefined;
15
+ if (!rangeAnnotation.labelInside) {
16
+ rangeAnnotationLabelWidth = rangeAnnotation.labelWidth ? rangeAnnotation.labelWidth : 150;
17
+ }
14
18
  let rangeConfig = {
15
19
  from: adjustedRangeValues.axisValue1,
16
20
  to: adjustedRangeValues.axisValue2,
@@ -24,7 +28,8 @@ class RangeAnnotationsOptions {
24
28
  style: {
25
29
  color: this.constants.labelColor,
26
30
  fontSize: this.constants.defaultFontSize,
27
- width: rangeAnnotation.labelWidth ? rangeAnnotation.labelWidth : 150,
31
+ // This property is not set as an inline style if rangeAnnotation.labelInside is undefined
32
+ width: rangeAnnotationLabelWidth,
28
33
  },
29
34
  },
30
35
  color: this.constants.shadingColor,
@@ -9,12 +9,6 @@ class ScatterChart {
9
9
 
10
10
  getScatterChartOptions = () => {
11
11
  return {
12
- plotOptions: {
13
- scatter: {
14
- // enable tooltips for scatter charts
15
- enableMouseTracking: true,
16
- },
17
- },
18
12
  xAxis: {
19
13
  gridLineWidth: 1,
20
14
  },
@@ -17,6 +17,27 @@ class SpecificChartOptions {
17
17
  }
18
18
 
19
19
  getOptions = () => this.options;
20
+
21
+ // Add zero line or custom reference line (but only for column or line charts)
22
+ getReferenceLine = (customReferenceLineValue, chartType) => {
23
+ let lineValue = 0;
24
+ if (customReferenceLineValue && (chartType === 'line' || chartType === 'column')) {
25
+ lineValue = customReferenceLineValue;
26
+ }
27
+
28
+ return {
29
+ yAxis: {
30
+ plotLines: [
31
+ {
32
+ color: this.constants.zeroLineColor,
33
+ width: 1.5,
34
+ value: lineValue,
35
+ zIndex: 2,
36
+ },
37
+ ],
38
+ },
39
+ };
40
+ };
20
41
  }
21
42
 
22
43
  export default SpecificChartOptions;
@@ -39,8 +39,9 @@ export const preparePlotLinesAndBands = (
39
39
  rangeAnnotations = undefined,
40
40
  rangeAnnotationsOptions = undefined,
41
41
  referenceLineAnnotationsOptions = undefined,
42
- commonChartOptions,
42
+ specificChartOptions,
43
43
  chartType,
44
+ customReferenceLineValue,
44
45
  ) => {
45
46
  const totalPointAndRangeAnnotations = (annotations ? annotations.length : 0) + (rangeAnnotations ? rangeAnnotations.length : 0);
46
47
 
@@ -69,20 +70,20 @@ export const preparePlotLinesAndBands = (
69
70
  );
70
71
  }
71
72
 
72
- // We also need to combine the zero line (and any future plot lines) with the reference line annotations here, as otherwise
73
+ // We also need to combine the zero line / custom reference line with the reference line annotations here, as otherwise
73
74
  // it gets overridden by the reference line annotations config
74
- let plotLineOptions = commonChartOptions.getPlotLines();
75
+ let plotLineOptions = specificChartOptions.getReferenceLine(customReferenceLineValue, chartType);
76
+ desktopAllPlotLines = { ...desktopReferenceLineAnnotations };
77
+ mobileAllPlotLines = { ...mobileReferenceLineAnnotations };
75
78
 
76
79
  if (desktopReferenceLineAnnotations.yAxis !== undefined) {
77
80
  let desktopMergedPlotLines = desktopReferenceLineAnnotations.yAxis.plotLines.concat(plotLineOptions.yAxis.plotLines);
78
81
  let mobileMergedPlotLines = mobileReferenceLineAnnotations.yAxis.plotLines.concat(plotLineOptions.yAxis.plotLines);
79
- desktopAllPlotLines = { ...desktopReferenceLineAnnotations };
80
- mobileAllPlotLines = { ...mobileReferenceLineAnnotations };
81
82
  desktopAllPlotLines.yAxis.plotLines = desktopMergedPlotLines;
82
83
  mobileAllPlotLines.yAxis.plotLines = mobileMergedPlotLines;
83
84
  } else {
84
- desktopAllPlotLines = { ...plotLineOptions };
85
- mobileAllPlotLines = { ...plotLineOptions };
85
+ desktopAllPlotLines.yAxis = { ...plotLineOptions.yAxis };
86
+ mobileAllPlotLines.yAxis = { ...plotLineOptions.yAxis };
86
87
  }
87
88
 
88
89
  // combine the desktop and mobile range and reference line annotations, along with other plot lines, ready to pass to the config
@@ -164,7 +164,7 @@ describe('macro: checkboxes', () => {
164
164
  it('renders the text area with expected parameters', () => {
165
165
  const $ = cheerio.load(renderComponent('checkboxes', EXAMPLE_CHECKBOX_ITEM_CHECKBOXES_WITH_TEXTAREA));
166
166
  expect($('.ons-input--textarea').attr('name')).toBe('other answer');
167
- expect($('.ons-input--textarea').attr('maxlength')).toBe('300');
167
+ expect($('.ons-input--textarea').attr('data-char-check-num')).toBe('300');
168
168
  expect($('.ons-input__limit').attr('data-charcount-singular')).toBe('You have {x} character remaining');
169
169
  expect($('.ons-input__limit').attr('data-charcount-plural')).toBe('You have {x} characters remaining');
170
170
  });
@@ -65,7 +65,7 @@ describe('script: mutually-exclusive', () => {
65
65
  });
66
66
 
67
67
  it('then the characters remaining readout should be reset', async () => {
68
- const limitText = await page.$eval('#feedback-lim', (node) => node.textContent);
68
+ const limitText = await page.$eval('#feedback-check', (node) => node.textContent);
69
69
  expect(limitText).toBe('You have 200 characters remaining');
70
70
  });
71
71
 
@@ -19,14 +19,14 @@
19
19
 
20
20
  <textarea
21
21
  id="{{ params.id }}"
22
- class="ons-input ons-input--textarea{{ ' ons-input--error' if params.error }}{{ ' ons-js-char-limit-input' if params.charCheckLimit and params.charCheckLimit.limit }}{{ textareaExclusiveClass }}{{ ' ' + params.classes if params.classes else '' }}{% if params.width %}{{ ' ' }}ons-input--w-{{ params.width }}{% endif %}"
22
+ class="ons-input ons-input--textarea{{ ' ons-input--error' if params.error }}{{ ' ons-js-char-check-input' if params.charCheckLimit and params.charCheckLimit.limit }}{{ textareaExclusiveClass }}{{ ' ' + params.classes if params.classes else '' }}{% if params.width %}{{ ' ' }}ons-input--w-{{ params.width }}{% endif %}"
23
23
  {% if params.name %}
24
24
  name="{{ params.name }}"
25
25
  {% endif %}
26
26
  rows="{{ params.rows | default(8) }}"
27
- {% if params.charCheckLimit and params.charCheckLimit.limit %}
28
- maxlength="{{ params.charCheckLimit.limit }}" data-char-limit-ref="{{ params.id }}-lim"
29
- aria-describedby="{{ params.id }}-lim"
27
+ {% if params.charCheckLimit %}
28
+ data-char-check-ref="{{ params.id }}-check" data-char-check-num="{{ params.charCheckLimit.limit }}"
29
+ aria-describedby="{{ params.id }}-check" data-char-check-countdown=true
30
30
  {% endif %}
31
31
  {% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ ' ' }}{{ attribute }}{% if value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}
32
32
  >
@@ -36,10 +36,12 @@
36
36
  {% if params.charCheckLimit and params.charCheckLimit.limit %}
37
37
  {%
38
38
  call onsCharLimit({
39
- "id": params.id ~ "-lim",
39
+ "id": params.id ~ "-check",
40
40
  "limit": params.charCheckLimit.limit,
41
41
  "charCountSingular": params.charCheckLimit.charCountSingular,
42
- "charCountPlural": params.charCheckLimit.charCountPlural
42
+ "charCountPlural": params.charCheckLimit.charCountPlural,
43
+ "charCountOverLimitSingular": params.charCheckLimit.charCountOverLimitSingular,
44
+ "charCountOverLimitPlural": params.charCheckLimit.charCountOverLimitPlural
43
45
  })
44
46
  %}
45
47
  {% endcall %}
@@ -22,6 +22,8 @@ const EXAMPLE_TEXTAREA_WITH_CHARACTER_LIMIT = {
22
22
  limit: 200,
23
23
  charCountSingular: 'You have {x} character remaining',
24
24
  charCountPlural: 'You have {x} characters remaining',
25
+ charCountOverLimitSingular: '{x} character too many',
26
+ charCountOverLimitPlural: '{x} characters too many',
25
27
  },
26
28
  };
27
29
 
@@ -200,29 +202,29 @@ describe('macro: textarea', () => {
200
202
  });
201
203
  });
202
204
 
203
- describe('with character limit', () => {
204
- it('has the `ons-js-char-limit-input` class', () => {
205
+ describe('with character check', () => {
206
+ it('has the `ons-js-char-check-input` class', () => {
205
207
  const $ = cheerio.load(renderComponent('textarea', EXAMPLE_TEXTAREA_WITH_CHARACTER_LIMIT));
206
208
 
207
- expect($('.ons-input--textarea').hasClass('ons-js-char-limit-input')).toBe(true);
209
+ expect($('.ons-input--textarea').hasClass('ons-js-char-check-input')).toBe(true);
208
210
  });
209
211
 
210
212
  it('has the provided maximum length', () => {
211
213
  const $ = cheerio.load(renderComponent('textarea', EXAMPLE_TEXTAREA_WITH_CHARACTER_LIMIT));
212
214
 
213
- expect($('.ons-input--textarea').attr('maxlength')).toBe('200');
215
+ expect($('.ons-input--textarea').attr('data-char-check-num')).toBe('200');
214
216
  });
215
217
 
216
- it('has data attribute which references the character limit component', () => {
218
+ it('has data attribute which references the character check component', () => {
217
219
  const $ = cheerio.load(renderComponent('textarea', EXAMPLE_TEXTAREA_WITH_CHARACTER_LIMIT));
218
220
 
219
- expect($('.ons-input--textarea').attr('data-char-limit-ref')).toBe('example-id-lim');
221
+ expect($('.ons-input--textarea').attr('data-char-check-ref')).toBe('example-id-check');
220
222
  });
221
223
 
222
224
  it('has `aria-describedby` attribute which references the character limit component', () => {
223
225
  const $ = cheerio.load(renderComponent('textarea', EXAMPLE_TEXTAREA_WITH_CHARACTER_LIMIT));
224
226
 
225
- expect($('.ons-input--textarea').attr('aria-describedby')).toBe('example-id-lim');
227
+ expect($('.ons-input--textarea').attr('aria-describedby')).toBe('example-id-check');
226
228
  });
227
229
 
228
230
  it('renders character limit component', () => {
@@ -232,10 +234,12 @@ describe('macro: textarea', () => {
232
234
  faker.renderComponent('textarea', EXAMPLE_TEXTAREA_WITH_CHARACTER_LIMIT);
233
235
 
234
236
  expect(charCheckLimitSpy.occurrences).toContainEqual({
235
- id: 'example-id-lim',
237
+ id: 'example-id-check',
236
238
  limit: 200,
237
239
  charCountSingular: 'You have {x} character remaining',
238
240
  charCountPlural: 'You have {x} characters remaining',
241
+ charCountOverLimitSingular: '{x} character too many',
242
+ charCountOverLimitPlural: '{x} characters too many',
239
243
  });
240
244
  });
241
245
  });
@@ -12,7 +12,9 @@
12
12
  "charCheckLimit": {
13
13
  "limit": 200,
14
14
  "charCountSingular": "You have {x} character remaining",
15
- "charCountPlural": "You have {x} characters remaining"
15
+ "charCountPlural": "You have {x} characters remaining",
16
+ "charCountOverLimitSingular": "{x} character too many",
17
+ "charCountOverLimitPlural": "{x} characters too many"
16
18
  }
17
19
  })
18
20
  }}