@progress/kendo-charts 1.33.0-dev.202312010652 → 1.33.0-dev.202312060707

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.
@@ -351,7 +351,9 @@ var Chart = (function (Class) {
351
351
  var titleOptions = this.options.title;
352
352
  var title = isString(titleOptions) ? titleOptions : (titleOptions.description || titleOptions.text);
353
353
 
354
- this.element.setAttribute("aria-roledescription", title);
354
+ if (title) {
355
+ this.element.setAttribute("aria-roledescription", title);
356
+ }
355
357
  };
356
358
 
357
359
  Chart.prototype.exportVisual = function exportVisual (exportOptions) {
@@ -1295,11 +1297,11 @@ var Chart = (function (Class) {
1295
1297
 
1296
1298
  focusState.focusedElement = element;
1297
1299
 
1300
+ this._setElementActiveDescendant(element);
1301
+
1298
1302
  if (!omitHighlight) {
1299
1303
  element.focusVisual();
1300
1304
 
1301
- this._setElementActiveDescendant(element._id);
1302
-
1303
1305
  if (focusState.legendInFocus) {
1304
1306
  this._showSeriesInactiveOpacity(focusState.focusedLegendItemIndex);
1305
1307
  } else {
@@ -1318,18 +1320,39 @@ var Chart = (function (Class) {
1318
1320
 
1319
1321
  if (focusState.focusedElement) {
1320
1322
  focusState.focusedElement.clearFocusFromVisual();
1321
- this._setElementActiveDescendant(null);
1323
+ this._clearElementActiveDescendant();
1322
1324
  }
1323
1325
 
1324
1326
  focusState.focusedElement = null;
1325
1327
  };
1326
1328
 
1327
- Chart.prototype._setElementActiveDescendant = function _setElementActiveDescendant (id) {
1328
- if (id) {
1329
- this.element.setAttribute(ARIA_ACTIVE_DESCENDANT, id);
1330
- } else {
1331
- this.element.removeAttribute(ARIA_ACTIVE_DESCENDANT);
1329
+ Chart.prototype._setElementActiveDescendant = function _setElementActiveDescendant (element) {
1330
+ if (this.options.renderAs === "canvas") {
1331
+ this._pseudoFocusedElement = this._createPseudoFocusedElement(element);
1332
+ this.element.append(this._pseudoFocusedElement);
1332
1333
  }
1334
+
1335
+ this.element.setAttribute(ARIA_ACTIVE_DESCENDANT, element._id);
1336
+ };
1337
+
1338
+ Chart.prototype._clearElementActiveDescendant = function _clearElementActiveDescendant () {
1339
+ if (this._pseudoFocusedElement) {
1340
+ this._pseudoFocusedElement.remove();
1341
+ this._pseudoFocusedElement = null;
1342
+ }
1343
+
1344
+ this.element.removeAttribute(ARIA_ACTIVE_DESCENDANT);
1345
+ };
1346
+
1347
+ Chart.prototype._createPseudoFocusedElement = function _createPseudoFocusedElement (element) {
1348
+ var pseudoElement = document.createElement("div");
1349
+
1350
+ pseudoElement.id = element._id;
1351
+ pseudoElement.setAttribute("aria-label", element.getAriaLabelText());
1352
+ pseudoElement.setAttribute("role", element.options.accessibility.role);
1353
+ pseudoElement.setAttribute("aria-roledescription", element.options.accessibility.ariaRoleDescription);
1354
+
1355
+ return pseudoElement;
1333
1356
  };
1334
1357
 
1335
1358
  Chart.prototype._blur = function _blur () {
@@ -4,8 +4,8 @@ import { BoxElement, FloatElement, ShapeElement, TextBox } from '../../core';
4
4
  import { LEGEND_ITEM_ARIA_ROLE_DESCRIPTION, LEGEND_ITEM_CLASSNAME, LEGEND_ITEM_CLICK, LEGEND_ITEM_HOVER, LEGEND_ITEM_LEAVE, LEGEND_ITEM_ROLE } from '../constants';
5
5
  import { CENTER, WHITE } from '../../common/constants';
6
6
  import { deepExtend, eventElement, setDefaultOptions } from '../../common';
7
- import AccessibilityAttributesMixin from '../mixins/accessibility-attributes-mixin';
8
7
  import addAccessibilityAttributesToVisual from '../../core/utils/add-accessibility-attributes-to-visual';
8
+ import guid from '../../core/utils/guid';
9
9
 
10
10
  var LegendItem = (function (BoxElement) {
11
11
  function LegendItem(options) {
@@ -19,6 +19,8 @@ var LegendItem = (function (BoxElement) {
19
19
  this.createLabel();
20
20
  this.createMarker();
21
21
  }
22
+
23
+ this._id = guid();
22
24
  }
23
25
 
24
26
  if ( BoxElement ) LegendItem.__proto__ = BoxElement;
@@ -52,6 +54,18 @@ var LegendItem = (function (BoxElement) {
52
54
  this.container.append(new TextBox(options.text, labelOptions));
53
55
  };
54
56
 
57
+ LegendItem.prototype.getAriaLabelText = function getAriaLabelText () {
58
+ return this.options.text;
59
+ };
60
+
61
+ LegendItem.prototype.focusVisual = function focusVisual () {
62
+ this.toggleFocusHighlight(true);
63
+ };
64
+
65
+ LegendItem.prototype.clearFocusFromVisual = function clearFocusFromVisual () {
66
+ this.toggleFocusHighlight(false);
67
+ };
68
+
55
69
  LegendItem.prototype.renderComplete = function renderComplete () {
56
70
  BoxElement.prototype.renderComplete.call(this);
57
71
 
@@ -110,7 +124,10 @@ var LegendItem = (function (BoxElement) {
110
124
  var options = this.options;
111
125
 
112
126
  if (this.options.visible) {
113
- var accessibilityOptions = deepExtend({ ariaLabel: options.text }, options.accessibility);
127
+ var accessibilityOptions = deepExtend({
128
+ id: this._id,
129
+ ariaLabel: options.text
130
+ }, options.accessibility);
114
131
 
115
132
  addAccessibilityAttributesToVisual(this.visual, accessibilityOptions);
116
133
 
@@ -160,8 +177,6 @@ var LegendItem = (function (BoxElement) {
160
177
  return LegendItem;
161
178
  }(BoxElement));
162
179
 
163
- deepExtend(LegendItem.prototype, AccessibilityAttributesMixin);
164
-
165
180
  setDefaultOptions(LegendItem, {
166
181
  accessibility: {
167
182
  role: LEGEND_ITEM_ROLE,
@@ -18,6 +18,7 @@ var LinePoint = (function (ChartElement) {
18
18
  this.options = options;
19
19
  this.aboveAxis = valueOrDefault(this.options.aboveAxis, true);
20
20
  this.tooltipTracking = true;
21
+ this._id = guid();
21
22
  }
22
23
 
23
24
  if ( ChartElement ) LinePoint.__proto__ = ChartElement;
@@ -343,8 +344,6 @@ var LinePoint = (function (ChartElement) {
343
344
 
344
345
  LinePoint.prototype.focusVisual = function focusVisual () {
345
346
  if (this.marker) {
346
- this._id = guid();
347
-
348
347
  if (this.marker.visual) {
349
348
  this.marker.visual.options.set("id", this._id);
350
349
  }
@@ -359,7 +358,6 @@ var LinePoint = (function (ChartElement) {
359
358
  this.marker.visual.options.set("id", "");
360
359
  }
361
360
 
362
- this._id = null;
363
361
  this.toggleFocusHighlight(false);
364
362
  }
365
363
  };
@@ -4,7 +4,12 @@ import guid from '../../core/utils/guid';
4
4
 
5
5
  var AccessibilityAttributesMixin = {
6
6
  addAccessibilityAttributesToVisual: function() {
7
- var accessibilityOptions = deepExtend({ ariaLabel: this.getAriaLabelText() }, this.options.accessibility);
7
+ this._id = this._id || guid();
8
+
9
+ var accessibilityOptions = deepExtend({
10
+ id: this._id,
11
+ ariaLabel: this.getAriaLabelText()
12
+ }, this.options.accessibility);
8
13
 
9
14
  addAccessibilityAttributesToVisual(this.visual, accessibilityOptions);
10
15
  },
@@ -21,14 +26,10 @@ var AccessibilityAttributesMixin = {
21
26
  },
22
27
 
23
28
  focusVisual: function focusVisual() {
24
- this._id = guid();
25
- this.visual.options.set("id", this._id);
26
29
  this.toggleFocusHighlight(true);
27
30
  },
28
31
 
29
32
  clearFocusFromVisual: function clearFocusFromVisual() {
30
- this.visual.options.set("id", "");
31
- this._id = null;
32
33
  this.toggleFocusHighlight(false);
33
34
  }
34
35
  };
@@ -342,7 +342,9 @@ class Chart extends Class {
342
342
  let titleOptions = this.options.title;
343
343
  let title = isString(titleOptions) ? titleOptions : (titleOptions.description || titleOptions.text);
344
344
 
345
- this.element.setAttribute("aria-roledescription", title);
345
+ if (title) {
346
+ this.element.setAttribute("aria-roledescription", title);
347
+ }
346
348
  }
347
349
 
348
350
  exportVisual(exportOptions) {
@@ -1259,11 +1261,11 @@ class Chart extends Class {
1259
1261
 
1260
1262
  focusState.focusedElement = element;
1261
1263
 
1264
+ this._setElementActiveDescendant(element);
1265
+
1262
1266
  if (!omitHighlight) {
1263
1267
  element.focusVisual();
1264
1268
 
1265
- this._setElementActiveDescendant(element._id);
1266
-
1267
1269
  if (focusState.legendInFocus) {
1268
1270
  this._showSeriesInactiveOpacity(focusState.focusedLegendItemIndex);
1269
1271
  } else {
@@ -1281,18 +1283,39 @@ class Chart extends Class {
1281
1283
 
1282
1284
  if (focusState.focusedElement) {
1283
1285
  focusState.focusedElement.clearFocusFromVisual();
1284
- this._setElementActiveDescendant(null);
1286
+ this._clearElementActiveDescendant();
1285
1287
  }
1286
1288
 
1287
1289
  focusState.focusedElement = null;
1288
1290
  }
1289
1291
 
1290
- _setElementActiveDescendant(id) {
1291
- if (id) {
1292
- this.element.setAttribute(ARIA_ACTIVE_DESCENDANT, id);
1293
- } else {
1294
- this.element.removeAttribute(ARIA_ACTIVE_DESCENDANT);
1292
+ _setElementActiveDescendant(element) {
1293
+ if (this.options.renderAs === "canvas") {
1294
+ this._pseudoFocusedElement = this._createPseudoFocusedElement(element);
1295
+ this.element.append(this._pseudoFocusedElement);
1295
1296
  }
1297
+
1298
+ this.element.setAttribute(ARIA_ACTIVE_DESCENDANT, element._id);
1299
+ }
1300
+
1301
+ _clearElementActiveDescendant() {
1302
+ if (this._pseudoFocusedElement) {
1303
+ this._pseudoFocusedElement.remove();
1304
+ this._pseudoFocusedElement = null;
1305
+ }
1306
+
1307
+ this.element.removeAttribute(ARIA_ACTIVE_DESCENDANT);
1308
+ }
1309
+
1310
+ _createPseudoFocusedElement(element) {
1311
+ const pseudoElement = document.createElement("div");
1312
+
1313
+ pseudoElement.id = element._id;
1314
+ pseudoElement.setAttribute("aria-label", element.getAriaLabelText());
1315
+ pseudoElement.setAttribute("role", element.options.accessibility.role);
1316
+ pseudoElement.setAttribute("aria-roledescription", element.options.accessibility.ariaRoleDescription);
1317
+
1318
+ return pseudoElement;
1296
1319
  }
1297
1320
 
1298
1321
  _blur() {
@@ -4,8 +4,8 @@ import { BoxElement, FloatElement, ShapeElement, TextBox } from '../../core';
4
4
  import { LEGEND_ITEM_ARIA_ROLE_DESCRIPTION, LEGEND_ITEM_CLASSNAME, LEGEND_ITEM_CLICK, LEGEND_ITEM_HOVER, LEGEND_ITEM_LEAVE, LEGEND_ITEM_ROLE } from '../constants';
5
5
  import { CENTER, WHITE } from '../../common/constants';
6
6
  import { deepExtend, eventElement, setDefaultOptions } from '../../common';
7
- import AccessibilityAttributesMixin from '../mixins/accessibility-attributes-mixin';
8
7
  import addAccessibilityAttributesToVisual from '../../core/utils/add-accessibility-attributes-to-visual';
8
+ import guid from '../../core/utils/guid';
9
9
 
10
10
  class LegendItem extends BoxElement {
11
11
  constructor(options) {
@@ -19,6 +19,8 @@ class LegendItem extends BoxElement {
19
19
  this.createLabel();
20
20
  this.createMarker();
21
21
  }
22
+
23
+ this._id = guid();
22
24
  }
23
25
 
24
26
  createContainer() {
@@ -48,6 +50,18 @@ class LegendItem extends BoxElement {
48
50
  this.container.append(new TextBox(options.text, labelOptions));
49
51
  }
50
52
 
53
+ getAriaLabelText() {
54
+ return this.options.text;
55
+ }
56
+
57
+ focusVisual() {
58
+ this.toggleFocusHighlight(true);
59
+ }
60
+
61
+ clearFocusFromVisual() {
62
+ this.toggleFocusHighlight(false);
63
+ }
64
+
51
65
  renderComplete() {
52
66
  super.renderComplete();
53
67
 
@@ -106,7 +120,10 @@ class LegendItem extends BoxElement {
106
120
  const options = this.options;
107
121
 
108
122
  if (this.options.visible) {
109
- const accessibilityOptions = deepExtend({ ariaLabel: options.text }, options.accessibility);
123
+ const accessibilityOptions = deepExtend({
124
+ id: this._id,
125
+ ariaLabel: options.text
126
+ }, options.accessibility);
110
127
 
111
128
  addAccessibilityAttributesToVisual(this.visual, accessibilityOptions);
112
129
 
@@ -152,8 +169,6 @@ class LegendItem extends BoxElement {
152
169
  }
153
170
  }
154
171
 
155
- deepExtend(LegendItem.prototype, AccessibilityAttributesMixin);
156
-
157
172
  setDefaultOptions(LegendItem, {
158
173
  accessibility: {
159
174
  role: LEGEND_ITEM_ROLE,
@@ -18,6 +18,7 @@ class LinePoint extends ChartElement {
18
18
  this.options = options;
19
19
  this.aboveAxis = valueOrDefault(this.options.aboveAxis, true);
20
20
  this.tooltipTracking = true;
21
+ this._id = guid();
21
22
  }
22
23
 
23
24
  render() {
@@ -332,8 +333,6 @@ class LinePoint extends ChartElement {
332
333
 
333
334
  focusVisual() {
334
335
  if (this.marker) {
335
- this._id = guid();
336
-
337
336
  if (this.marker.visual) {
338
337
  this.marker.visual.options.set("id", this._id);
339
338
  }
@@ -348,7 +347,6 @@ class LinePoint extends ChartElement {
348
347
  this.marker.visual.options.set("id", "");
349
348
  }
350
349
 
351
- this._id = null;
352
350
  this.toggleFocusHighlight(false);
353
351
  }
354
352
  }
@@ -4,7 +4,12 @@ import guid from '../../core/utils/guid';
4
4
 
5
5
  const AccessibilityAttributesMixin = {
6
6
  addAccessibilityAttributesToVisual: function() {
7
- const accessibilityOptions = deepExtend({ ariaLabel: this.getAriaLabelText() }, this.options.accessibility);
7
+ this._id = this._id || guid();
8
+
9
+ const accessibilityOptions = deepExtend({
10
+ id: this._id,
11
+ ariaLabel: this.getAriaLabelText()
12
+ }, this.options.accessibility);
8
13
 
9
14
  addAccessibilityAttributesToVisual(this.visual, accessibilityOptions);
10
15
  },
@@ -21,14 +26,10 @@ const AccessibilityAttributesMixin = {
21
26
  },
22
27
 
23
28
  focusVisual() {
24
- this._id = guid();
25
- this.visual.options.set("id", this._id);
26
29
  this.toggleFocusHighlight(true);
27
30
  },
28
31
 
29
32
  clearFocusFromVisual() {
30
- this.visual.options.set("id", "");
31
- this._id = null;
32
33
  this.toggleFocusHighlight(false);
33
34
  }
34
35
  };