@ons/design-system 72.10.6 → 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.
- package/components/char-check-limit/_macro.njk +5 -4
- package/components/char-check-limit/_macro.spec.js +167 -7
- package/components/char-check-limit/character-check.js +23 -17
- package/components/char-check-limit/character-check.spec.js +106 -1
- package/components/chart/_chart.scss +33 -5
- package/components/chart/_macro.njk +169 -149
- package/components/chart/_macro.spec.js +215 -21
- package/components/chart/annotations-options.js +1 -1
- package/components/chart/bar-chart.js +1 -0
- package/components/chart/chart-iframe-resize.dom.js +8 -0
- package/components/chart/chart-iframe-resize.js +16 -0
- package/components/chart/chart.js +5 -0
- package/components/chart/example-bar-chart.njk +4 -0
- package/components/chart/example-iframe-chart.njk +32 -0
- package/components/chart/example-line-chart-with-annotations.njk +3 -1
- package/components/chart/example-line-chart.njk +4 -0
- package/components/chart/example-scatter-chart.njk +4 -0
- package/components/chart/range-annotations-options.js +1 -1
- package/components/chart/reference-line-annotations-options.js +1 -1
- package/components/checkboxes/_macro.spec.js +3 -3
- package/components/input/_macro.njk +1 -2
- package/components/input/_macro.spec.js +2 -22
- package/components/input/example-input-search-with-character-check.njk +0 -1
- package/components/textarea/_macro.njk +19 -3
- package/components/textarea/_macro.spec.js +76 -3
- package/components/textarea/example-textarea-with-word-limit.njk +20 -0
- package/css/main.css +1 -1
- package/js/main.js +2 -0
- package/package.json +3 -2
- package/scripts/main.es5.js +3 -1
- package/scripts/main.js +3 -1
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
EXAMPLE_LINE_CHART_WITH_RANGE_ANNOTATION_WITH_LABEL_INSIDE_PARAMS,
|
|
26
26
|
EXAMPLE_LINE_CHART_WITH_REFERENCE_LINE_ANNOTATIONS_PARAMS,
|
|
27
27
|
EXAMPLE_LINE_CHART_WITH_MIXED_ANNOTATION_TYPES_PARAMS,
|
|
28
|
+
EXAMPLE_IFRAME_CHART_PARAMS,
|
|
28
29
|
} from './_test-examples';
|
|
29
30
|
|
|
30
31
|
describe('Macro: Chart', () => {
|
|
@@ -628,14 +629,14 @@ describe('Macro: Chart', () => {
|
|
|
628
629
|
});
|
|
629
630
|
|
|
630
631
|
test('THEN: it renders the footnotes', () => {
|
|
631
|
-
expect($('.ons-
|
|
632
|
-
expect($('.ons-
|
|
633
|
-
expect($('.ons-
|
|
634
|
-
expect($('.ons-
|
|
632
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('1');
|
|
633
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test annotation');
|
|
634
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('2');
|
|
635
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('Another test annotation');
|
|
635
636
|
});
|
|
636
637
|
|
|
637
638
|
test('THEN: the footnotes are hidden from screen readers', () => {
|
|
638
|
-
expect($('.ons-
|
|
639
|
+
expect($('.ons-chart__annotations-footnotes').attr('aria-hidden')).toBe('true');
|
|
639
640
|
});
|
|
640
641
|
|
|
641
642
|
test('THEN: it includes the Annotations JSON config', () => {
|
|
@@ -658,12 +659,12 @@ describe('Macro: Chart', () => {
|
|
|
658
659
|
});
|
|
659
660
|
|
|
660
661
|
test('THEN: it renders the footnotes', () => {
|
|
661
|
-
expect($('.ons-
|
|
662
|
-
expect($('.ons-
|
|
662
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('1');
|
|
663
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test annotation');
|
|
663
664
|
});
|
|
664
665
|
|
|
665
666
|
test('THEN: the footnotes are hidden from screen readers', () => {
|
|
666
|
-
expect($('.ons-
|
|
667
|
+
expect($('.ons-chart__annotations-footnotes').attr('aria-hidden')).toBe('true');
|
|
667
668
|
});
|
|
668
669
|
|
|
669
670
|
test('THEN: it includes the Annotations JSON config', () => {
|
|
@@ -687,12 +688,12 @@ describe('Macro: Chart', () => {
|
|
|
687
688
|
});
|
|
688
689
|
|
|
689
690
|
test('THEN: it renders the footnotes', () => {
|
|
690
|
-
expect($('.ons-
|
|
691
|
-
expect($('.ons-
|
|
691
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('1');
|
|
692
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test annotation');
|
|
692
693
|
});
|
|
693
694
|
|
|
694
695
|
test('THEN: the footnotes are hidden from screen readers', () => {
|
|
695
|
-
expect($('.ons-
|
|
696
|
+
expect($('.ons-chart__annotations-footnotes').attr('aria-hidden')).toBe('true');
|
|
696
697
|
});
|
|
697
698
|
|
|
698
699
|
test('THEN: it includes the Annotations JSON config', () => {
|
|
@@ -977,6 +978,26 @@ describe('Macro: Chart', () => {
|
|
|
977
978
|
});
|
|
978
979
|
});
|
|
979
980
|
});
|
|
981
|
+
|
|
982
|
+
describe('GIVEN: Params: Footnotes', () => {
|
|
983
|
+
describe('WHEN: footnotes are provided', () => {
|
|
984
|
+
const $ = cheerio.load(
|
|
985
|
+
renderComponent('chart', {
|
|
986
|
+
...EXAMPLE_AREA_CHART_PARAMS,
|
|
987
|
+
footnotes: {
|
|
988
|
+
title: 'Footnotes',
|
|
989
|
+
content:
|
|
990
|
+
'<ol><li>Non-store retailing refers to retailers that do not have a store presence. While the majority is made up of online retailers, it also includes other retailers, such as stalls and markets.</li><li>More data are available in our Retail Sales Index datasets.</li></ol>',
|
|
991
|
+
},
|
|
992
|
+
}),
|
|
993
|
+
);
|
|
994
|
+
test('THEN: it renders the footnotes', () => {
|
|
995
|
+
expect($('#footnotes--area-chart-123').length).toBe(1);
|
|
996
|
+
expect($('#footnotes--area-chart-123').find('ol').length).toBe(1);
|
|
997
|
+
expect($('#footnotes--area-chart-123').text()).toContain('Footnotes');
|
|
998
|
+
});
|
|
999
|
+
});
|
|
1000
|
+
});
|
|
980
1001
|
});
|
|
981
1002
|
|
|
982
1003
|
describe('FOR: Boxplot Chart', () => {
|
|
@@ -1304,16 +1325,16 @@ describe('Macro: Chart', () => {
|
|
|
1304
1325
|
});
|
|
1305
1326
|
|
|
1306
1327
|
test('THEN: it renders the footnotes sequentially', () => {
|
|
1307
|
-
expect($('.ons-
|
|
1308
|
-
expect($('.ons-
|
|
1309
|
-
expect($('.ons-
|
|
1310
|
-
expect($('.ons-
|
|
1311
|
-
expect($('.ons-
|
|
1312
|
-
expect($('.ons-
|
|
1313
|
-
expect($('.ons-
|
|
1314
|
-
expect($('.ons-
|
|
1315
|
-
expect($('.ons-
|
|
1316
|
-
expect($('.ons-
|
|
1328
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('1');
|
|
1329
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test point annotation');
|
|
1330
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('2');
|
|
1331
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test x axis range annotation');
|
|
1332
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('3');
|
|
1333
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test y axis range annotation with the label inside');
|
|
1334
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('4');
|
|
1335
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test x axis reference line annotation');
|
|
1336
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('5');
|
|
1337
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test y axis reference line annotation');
|
|
1317
1338
|
});
|
|
1318
1339
|
});
|
|
1319
1340
|
});
|
|
@@ -1456,4 +1477,177 @@ describe('Macro: Chart', () => {
|
|
|
1456
1477
|
});
|
|
1457
1478
|
});
|
|
1458
1479
|
});
|
|
1480
|
+
|
|
1481
|
+
describe('FOR: Iframe chart', () => {
|
|
1482
|
+
describe('GIVEN: Params: Iframe chart', () => {
|
|
1483
|
+
describe('WHEN: an iframe url param is provided', () => {
|
|
1484
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_IFRAME_CHART_PARAMS));
|
|
1485
|
+
|
|
1486
|
+
test('THEN: it passes jest-axe checks', async () => {
|
|
1487
|
+
const results = await axe($.html());
|
|
1488
|
+
expect(results).toHaveNoViolations();
|
|
1489
|
+
});
|
|
1490
|
+
|
|
1491
|
+
test('THEN: it renders the iframe', () => {
|
|
1492
|
+
expect($('[data-chart-iframe]').length).toBe(1);
|
|
1493
|
+
});
|
|
1494
|
+
|
|
1495
|
+
test('THEN: it includes the iframe title as a data attribute', () => {
|
|
1496
|
+
const iframe = $('[data-chart-iframe]');
|
|
1497
|
+
expect(iframe.attr('data-title')).toBe(EXAMPLE_IFRAME_CHART_PARAMS.title);
|
|
1498
|
+
});
|
|
1499
|
+
|
|
1500
|
+
test('THEN: the theme parameter is ignored', () => {
|
|
1501
|
+
const $ = cheerio.load(
|
|
1502
|
+
renderComponent('chart', {
|
|
1503
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1504
|
+
theme: 'secondary',
|
|
1505
|
+
}),
|
|
1506
|
+
);
|
|
1507
|
+
|
|
1508
|
+
expect($('[data-highcharts-theme]').length).toBe(0);
|
|
1509
|
+
});
|
|
1510
|
+
|
|
1511
|
+
test('THEN: the percentageHeightDesktop and percentageHeightMobile parameters are ignored', () => {
|
|
1512
|
+
const $ = cheerio.load(
|
|
1513
|
+
renderComponent('chart', {
|
|
1514
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1515
|
+
percentageHeightDesktop: 50,
|
|
1516
|
+
percentageHeightMobile: 10,
|
|
1517
|
+
}),
|
|
1518
|
+
);
|
|
1519
|
+
|
|
1520
|
+
expect($('[data-highcharts-percentage-height-desktop]').length).toBe(0);
|
|
1521
|
+
expect($('[data-highcharts-percentage-height-mobile]').length).toBe(0);
|
|
1522
|
+
});
|
|
1523
|
+
|
|
1524
|
+
test('THEN: the tickIntervalDesktop and tickIntervalMobile parameters are ignored', () => {
|
|
1525
|
+
const $ = cheerio.load(
|
|
1526
|
+
renderComponent('chart', {
|
|
1527
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1528
|
+
xAxis: {
|
|
1529
|
+
tickIntervalDesktop: 10,
|
|
1530
|
+
tickIntervalMobile: 5,
|
|
1531
|
+
},
|
|
1532
|
+
yAxis: {
|
|
1533
|
+
tickIntervalDesktop: 10,
|
|
1534
|
+
tickIntervalMobile: 5,
|
|
1535
|
+
},
|
|
1536
|
+
}),
|
|
1537
|
+
);
|
|
1538
|
+
|
|
1539
|
+
expect($('[data-highcharts-x-axis-tick-interval-desktop]').length).toBe(0);
|
|
1540
|
+
expect($('[data-highcharts-x-axis-tick-interval-mobile]').length).toBe(0);
|
|
1541
|
+
expect($('[data-highcharts-y-axis-tick-interval-desktop]').length).toBe(0);
|
|
1542
|
+
expect($('[data-highcharts-y-axis-tick-interval-mobile]').length).toBe(0);
|
|
1543
|
+
});
|
|
1544
|
+
|
|
1545
|
+
test('THEN: the tickIntervalDesktop and tickIntervalMobile parameters are ignored', () => {
|
|
1546
|
+
const $ = cheerio.load(
|
|
1547
|
+
renderComponent('chart', {
|
|
1548
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1549
|
+
estimateLineLabel: 'Estimated value',
|
|
1550
|
+
uncertaintyRangeLabel: '95% Confidence Interval',
|
|
1551
|
+
}),
|
|
1552
|
+
);
|
|
1553
|
+
|
|
1554
|
+
expect($('[data-highcharts-estimate-line-label]').length).toBe(0);
|
|
1555
|
+
expect($('[data-highcharts-uncertainty-range-label]').length).toBe(0);
|
|
1556
|
+
});
|
|
1557
|
+
|
|
1558
|
+
test('THEN: the customReferenceLineValue parameter is ignored', () => {
|
|
1559
|
+
const $ = cheerio.load(
|
|
1560
|
+
renderComponent('chart', {
|
|
1561
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1562
|
+
yAxis: {
|
|
1563
|
+
customReferenceLineValue: 10,
|
|
1564
|
+
},
|
|
1565
|
+
}),
|
|
1566
|
+
);
|
|
1567
|
+
|
|
1568
|
+
expect($('[data-highcharts-custom-reference-line-value]').length).toBe(0);
|
|
1569
|
+
});
|
|
1570
|
+
|
|
1571
|
+
test('THEN: the legend for boxplot charts is not rendered', () => {
|
|
1572
|
+
const $ = cheerio.load(
|
|
1573
|
+
renderComponent('chart', {
|
|
1574
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1575
|
+
chartType: 'boxplot',
|
|
1576
|
+
legend: true,
|
|
1577
|
+
estimateLineLabel: 'Estimated value',
|
|
1578
|
+
uncertaintyRangeLabel: '95% Confidence Interval',
|
|
1579
|
+
}),
|
|
1580
|
+
);
|
|
1581
|
+
|
|
1582
|
+
expect($('.ons-chart__boxplot-legend').length).toBe(0);
|
|
1583
|
+
});
|
|
1584
|
+
|
|
1585
|
+
test('THEN: the Highcharts config is not included', () => {
|
|
1586
|
+
const configScript = $(`script[data-highcharts-config--iframe-chart-123]`).html();
|
|
1587
|
+
expect(configScript).toBeNull();
|
|
1588
|
+
});
|
|
1589
|
+
|
|
1590
|
+
test('THEN: the annotations footnotes and scripts are not rendered', () => {
|
|
1591
|
+
const $ = cheerio.load(
|
|
1592
|
+
renderComponent('chart', {
|
|
1593
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1594
|
+
annotations: [
|
|
1595
|
+
{
|
|
1596
|
+
text: 'A test point annotation',
|
|
1597
|
+
point: { x: 2, y: 3 },
|
|
1598
|
+
labelOffsetX: 10,
|
|
1599
|
+
labelOffsetY: -50,
|
|
1600
|
+
},
|
|
1601
|
+
],
|
|
1602
|
+
rangeAnnotations: [
|
|
1603
|
+
{
|
|
1604
|
+
text: 'A test x axis range annotation',
|
|
1605
|
+
range: { axisValue1: 10, axisValue2: 15 },
|
|
1606
|
+
axis: 'x',
|
|
1607
|
+
labelOffsetX: 150,
|
|
1608
|
+
labelOffsetY: 0,
|
|
1609
|
+
},
|
|
1610
|
+
{
|
|
1611
|
+
text: 'A test y axis range annotation with the label inside',
|
|
1612
|
+
range: { axisValue1: 5, axisValue2: 10 },
|
|
1613
|
+
axis: 'y',
|
|
1614
|
+
labelInside: true,
|
|
1615
|
+
labelWidth: 250,
|
|
1616
|
+
},
|
|
1617
|
+
],
|
|
1618
|
+
referenceLineAnnotations: [
|
|
1619
|
+
{
|
|
1620
|
+
text: 'A test x axis reference line annotation',
|
|
1621
|
+
value: 34,
|
|
1622
|
+
axis: 'x',
|
|
1623
|
+
},
|
|
1624
|
+
{
|
|
1625
|
+
text: 'A test y axis reference line annotation',
|
|
1626
|
+
value: 12,
|
|
1627
|
+
axis: 'y',
|
|
1628
|
+
labelWidth: 100,
|
|
1629
|
+
},
|
|
1630
|
+
],
|
|
1631
|
+
}),
|
|
1632
|
+
);
|
|
1633
|
+
|
|
1634
|
+
expect($('[data-annotations-footnotes]').length).toBe(0);
|
|
1635
|
+
expect($('[data-highcharts-annotations--iframe-chart-123]').length).toBe(0);
|
|
1636
|
+
expect($('[data-highcharts-range-annotations--iframe-chart-123]').length).toBe(0);
|
|
1637
|
+
expect($('[data-highcharts-reference-line-annotations--iframe-chart-123]').length).toBe(0);
|
|
1638
|
+
});
|
|
1639
|
+
|
|
1640
|
+
test('THEN: invalid chart type is ignored', () => {
|
|
1641
|
+
const $ = cheerio.load(
|
|
1642
|
+
renderComponent('chart', {
|
|
1643
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1644
|
+
chartType: 'foobar',
|
|
1645
|
+
}),
|
|
1646
|
+
);
|
|
1647
|
+
|
|
1648
|
+
expect($('[data-invalid-chart-type]').length).toBe(0);
|
|
1649
|
+
});
|
|
1650
|
+
});
|
|
1651
|
+
});
|
|
1652
|
+
});
|
|
1459
1653
|
});
|
|
@@ -49,7 +49,7 @@ class AnnotationsOptions {
|
|
|
49
49
|
borderColor: 'transparent',
|
|
50
50
|
// We use css styling for the rounded number annotation at mobile
|
|
51
51
|
useHTML: true,
|
|
52
|
-
className: 'ons-
|
|
52
|
+
className: 'ons-chart__annotations-footnotes-number',
|
|
53
53
|
},
|
|
54
54
|
draggable: '',
|
|
55
55
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ChartIframeResize from './chart-iframe-resize';
|
|
2
|
+
import domready from '../../js/domready';
|
|
3
|
+
|
|
4
|
+
domready(async () => {
|
|
5
|
+
[ChartIframeResize].forEach((Component) => {
|
|
6
|
+
document.querySelectorAll(Component.selector()).forEach((el) => new Component(el));
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import pym from 'pym.js';
|
|
2
|
+
|
|
3
|
+
class ChartIframeResize {
|
|
4
|
+
static selector() {
|
|
5
|
+
return '[data-chart-iframe]';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
constructor(node) {
|
|
9
|
+
this.node = node;
|
|
10
|
+
new pym.Parent(this.node.getAttribute('id'), this.node.dataset.url, {
|
|
11
|
+
title: this.node.dataset.title,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default ChartIframeResize;
|
|
@@ -31,6 +31,11 @@ class HighchartsBaseChart {
|
|
|
31
31
|
console.error('No chart node found');
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
// Add a CSS class to the chart based on the chart type (e.g., 'bar-chart-container', 'line-chart-container')
|
|
36
|
+
// This allows type-specific styling in CSS.
|
|
37
|
+
chartNode.classList.add(`${this.chartType}-chart-container`);
|
|
38
|
+
|
|
34
39
|
this.id = this.node.dataset.highchartsId;
|
|
35
40
|
this.useStackedLayout = this.node.hasAttribute('data-highcharts-use-stacked-layout');
|
|
36
41
|
this.config = JSON.parse(this.node.querySelector(`[data-highcharts-config--${this.id}]`).textContent);
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
}
|
|
27
27
|
]
|
|
28
28
|
},
|
|
29
|
+
"footnotes": {
|
|
30
|
+
"title": "Footnotes",
|
|
31
|
+
"content": "<ol><li>Non-store retailing refers to retailers that do not have a store presence. While the majority is made up of online retailers, it also includes other retailers, such as stalls and markets.</li><li>More data are available in our Retail Sales Index datasets.</li></ol>"
|
|
32
|
+
},
|
|
29
33
|
"xAxis": {
|
|
30
34
|
"categories": [
|
|
31
35
|
"All retailing",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{% from "components/chart/_macro.njk" import onsChart %}
|
|
2
|
+
|
|
3
|
+
{# Important note: the example visualisation used here by the iframeUrl parameter
|
|
4
|
+
may not be available in the future once Florence is decommissioned. #}
|
|
5
|
+
|
|
6
|
+
{{
|
|
7
|
+
onsChart({
|
|
8
|
+
"description": "Volume sales, seasonally adjusted, Great Britain, January 2022 to January 2025",
|
|
9
|
+
"title": "Food stores showed a strong rise on the month, while non-food stores fell",
|
|
10
|
+
"subtitle": "Figure 6: Upward contribution from housing and household services (including energy) saw the annual CPIH inflation rate rise",
|
|
11
|
+
"id": "uuid",
|
|
12
|
+
"caption": "Source: Monthly Business Survey, Retail 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
|
+
"text": "Image (PNG format, 25KB)",
|
|
26
|
+
"url": "#"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"iframeUrl": "https://www.ons.gov.uk/visualisations/dvc3294/fig01/index.html"
|
|
31
|
+
})
|
|
32
|
+
}}
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
"url": "#"
|
|
28
28
|
}
|
|
29
29
|
]},
|
|
30
|
+
"footnotes": {
|
|
31
|
+
"title": "Footnotes",
|
|
32
|
+
"content": "<ol><li>Non-store retailing refers to retailers that do not have a store presence. While the majority is made up of online retailers, it also includes other retailers, such as stalls and markets.</li><li>More data are available in our Retail Sales Index datasets.</li></ol>"
|
|
33
|
+
},
|
|
30
34
|
"legend": true,
|
|
31
35
|
"xAxis": {
|
|
32
36
|
"title": "Year",
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
"url": "#"
|
|
28
28
|
}
|
|
29
29
|
]},
|
|
30
|
+
"footnotes": {
|
|
31
|
+
"title": "Footnotes",
|
|
32
|
+
"content": "<ol><li>Non-store retailing refers to retailers that do not have a store presence. While the majority is made up of online retailers, it also includes other retailers, such as stalls and markets.</li><li>More data are available in our Retail Sales Index datasets.</li></ol>"
|
|
33
|
+
},
|
|
30
34
|
"xAxis": {
|
|
31
35
|
"title": "Height"
|
|
32
36
|
},
|
|
@@ -65,7 +65,7 @@ class RangeAnnotationsOptions {
|
|
|
65
65
|
// So that if we have both types of annotations, the numbers will be sequential
|
|
66
66
|
text: `${annotationsLength + index + 1}`,
|
|
67
67
|
useHTML: true,
|
|
68
|
-
className: 'ons-
|
|
68
|
+
className: 'ons-chart__annotations-footnotes-number',
|
|
69
69
|
allowOverlap: true,
|
|
70
70
|
style: {
|
|
71
71
|
color: this.constants.labelColor,
|
|
@@ -58,7 +58,7 @@ class ReferenceLineAnnotationsOptions {
|
|
|
58
58
|
// So that if we have more than one type of annotations, the numbers will be sequential
|
|
59
59
|
text: `${annotationsLength + index + 1}`,
|
|
60
60
|
useHTML: true,
|
|
61
|
-
className: 'ons-
|
|
61
|
+
className: 'ons-chart__annotations-footnotes-number',
|
|
62
62
|
allowOverlap: true,
|
|
63
63
|
style: {
|
|
64
64
|
color: this.constants.labelColor,
|
|
@@ -164,9 +164,9 @@ 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('data-
|
|
168
|
-
expect($('.ons-input__limit').attr('data-
|
|
169
|
-
expect($('.ons-input__limit').attr('data-
|
|
167
|
+
expect($('.ons-input--textarea').attr('data-message-check-num')).toBe('300');
|
|
168
|
+
expect($('.ons-input__limit').attr('data-message-singular')).toBe('You have {x} character remaining');
|
|
169
|
+
expect($('.ons-input__limit').attr('data-message-plural')).toBe('You have {x} characters remaining');
|
|
170
170
|
});
|
|
171
171
|
});
|
|
172
172
|
|
|
@@ -44,10 +44,9 @@
|
|
|
44
44
|
{% if params.autocomplete %}autocomplete="{{ params.autocomplete }}"{% endif %}
|
|
45
45
|
{% if params.accessiblePlaceholder %}placeholder="{{ params.label.text }}"{% endif %}
|
|
46
46
|
{% if params.charCheckLimit %}
|
|
47
|
-
data-
|
|
47
|
+
data-message-check-ref="{{ params.id }}-check" data-message-check-num="{{ params.charCheckLimit.limit }}"
|
|
48
48
|
aria-describedby="{{ params.id }}-check"
|
|
49
49
|
{% endif %}
|
|
50
|
-
{% if params.charCheckLimit and params.charCheckLimit.charcheckCountdown %}data-char-check-countdown="true"{% endif %}
|
|
51
50
|
{% 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 %}
|
|
52
51
|
{% if params.label and params.label.description %}{% if params.label.id %}aria-describedby="{{ params.label.id }}-description-hint"{% else %}aria-describedby="description-hint"{% endif %}{% endif %}
|
|
53
52
|
/>
|
|
@@ -570,36 +570,16 @@ describe('macro: input', () => {
|
|
|
570
570
|
expect($('.ons-input').attr('maxlength')).toBe('200');
|
|
571
571
|
});
|
|
572
572
|
|
|
573
|
-
it('does not have `data-char-check-countdown` attribute when `charcheckCountdown` is not provided', () => {
|
|
574
|
-
const $ = cheerio.load(renderComponent('input', EXAMPLE_INPUT_WITH_CHARACTER_LIMIT));
|
|
575
|
-
|
|
576
|
-
expect($('.ons-input').attr('data-char-check-countdown')).toBe(undefined);
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
it('has `data-char-check-countdown` attribute when `charcheckCountdown` is true', () => {
|
|
580
|
-
const $ = cheerio.load(
|
|
581
|
-
renderComponent('input', {
|
|
582
|
-
...EXAMPLE_INPUT_WITH_CHARACTER_LIMIT,
|
|
583
|
-
charCheckLimit: {
|
|
584
|
-
...EXAMPLE_INPUT_WITH_CHARACTER_LIMIT.charCheckLimit,
|
|
585
|
-
charcheckCountdown: true,
|
|
586
|
-
},
|
|
587
|
-
}),
|
|
588
|
-
);
|
|
589
|
-
|
|
590
|
-
expect($('.ons-input').attr('data-char-check-countdown')).toBe('true');
|
|
591
|
-
});
|
|
592
|
-
|
|
593
573
|
it('has data attribute which references the character limit component', () => {
|
|
594
574
|
const $ = cheerio.load(renderComponent('input', EXAMPLE_INPUT_WITH_CHARACTER_LIMIT));
|
|
595
575
|
|
|
596
|
-
expect($('.ons-input').attr('data-
|
|
576
|
+
expect($('.ons-input').attr('data-message-check-ref')).toBe('example-id-check');
|
|
597
577
|
});
|
|
598
578
|
|
|
599
579
|
it('has data attribute which defines limit for character check', () => {
|
|
600
580
|
const $ = cheerio.load(renderComponent('input', EXAMPLE_INPUT_WITH_CHARACTER_LIMIT));
|
|
601
581
|
|
|
602
|
-
expect($('.ons-input').attr('data-
|
|
582
|
+
expect($('.ons-input').attr('data-message-check-num')).toBe('200');
|
|
603
583
|
});
|
|
604
584
|
|
|
605
585
|
it('has `aria-describedby` attribute which references the character limit component', () => {
|
|
@@ -19,14 +19,17 @@
|
|
|
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-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 %}"
|
|
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) or (params.wordCheckLimit and params.wordCheckLimit.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
27
|
{% if params.charCheckLimit %}
|
|
28
|
-
data-
|
|
29
|
-
aria-describedby="{{ params.id }}-check"
|
|
28
|
+
data-message-check-ref="{{ params.id }}-check" data-message-check-num="{{ params.charCheckLimit.limit }}"
|
|
29
|
+
aria-describedby="{{ params.id }}-check"
|
|
30
|
+
{% elif params.wordCheckLimit %}
|
|
31
|
+
data-message-check-ref="{{ params.id }}-check" data-message-check-num="{{ params.wordCheckLimit.limit }}"
|
|
32
|
+
aria-describedby="{{ params.id }}-check"
|
|
30
33
|
{% endif %}
|
|
31
34
|
{% 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
35
|
>
|
|
@@ -45,6 +48,19 @@
|
|
|
45
48
|
})
|
|
46
49
|
%}
|
|
47
50
|
{% endcall %}
|
|
51
|
+
{% elif params.wordCheckLimit and params.wordCheckLimit.limit %}
|
|
52
|
+
{%
|
|
53
|
+
call onsCharLimit({
|
|
54
|
+
"id": params.id ~ "-check",
|
|
55
|
+
"variant": "word",
|
|
56
|
+
"limit": params.wordCheckLimit.limit,
|
|
57
|
+
"wordCountSingular": params.wordCheckLimit.wordCountSingular,
|
|
58
|
+
"wordCountPlural": params.wordCheckLimit.wordCountPlural,
|
|
59
|
+
"wordCountOverLimitSingular": params.wordCheckLimit.wordCountOverLimitSingular,
|
|
60
|
+
"wordCountOverLimitPlural": params.wordCheckLimit.wordCountOverLimitPlural
|
|
61
|
+
})
|
|
62
|
+
%}
|
|
63
|
+
{% endcall %}
|
|
48
64
|
{% endif %}
|
|
49
65
|
{% endset %}
|
|
50
66
|
|