@progress/kendo-charts 2.3.0-dev.202404221217 → 2.3.0-dev.202404250846

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.
@@ -19,7 +19,8 @@ import isDateAxis from './utils/is-date-axis';
19
19
  import { ChartPane, ChartPlotArea, findAxisByName } from './api-elements';
20
20
 
21
21
  import { X, Y, VALUE, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_SERIES_OPACITY,
22
- ARROW_DOWN, ARROW_UP, ARROW_LEFT, ARROW_RIGHT, ARIA_ACTIVE_DESCENDANT, TAB, TOP, LEFT, BLACK } from '../common/constants';
22
+ ARROW_DOWN, ARROW_UP, ARROW_LEFT, ARROW_RIGHT, ARIA_ACTIVE_DESCENDANT, TAB, TOP, LEFT, BLACK,
23
+ ENTER, ESCAPE } from '../common/constants';
23
24
  import { addClass, Class, setDefaultOptions, deepExtend, defined, find, isObject, isFunction, elementSize, elementOffset,
24
25
  elementScale, elementStyles, eventCoordinates, bindEvents, unbindEvents, mousewheelDelta, FontLoader, inArray, round,
25
26
  valueOrDefault, isString, cycleUp, cycleDown, hasOwnProperty } from '../common';
@@ -342,6 +343,20 @@ var Chart = (function (Class) {
342
343
  if (!this._navState) {
343
344
  this._cancelDomEvents();
344
345
  }
346
+
347
+ this._redrawFocusHighlight();
348
+ };
349
+
350
+ Chart.prototype._redrawFocusHighlight = function _redrawFocusHighlight () {
351
+ var ref = this;
352
+ var ref_focusState = ref._focusState;
353
+ var legendInFocus = ref_focusState.legendInFocus;
354
+ var preserveHighlight = ref_focusState.preserveHighlight;
355
+
356
+ if (legendInFocus && preserveHighlight) {
357
+ this._focusElement(this._getFocusedLegendItem(), false);
358
+ this._focusState.preserveHighlight = false;
359
+ }
345
360
  };
346
361
 
347
362
  Chart.prototype._setElementAccessibilityAttributes = function _setElementAccessibilityAttributes () {
@@ -1122,7 +1137,9 @@ var Chart = (function (Class) {
1122
1137
 
1123
1138
  Chart.prototype._keydown = function _keydown (e) {
1124
1139
  var ref = this;
1125
- var legendInFocus = ref._focusState.legendInFocus;
1140
+ var ref_focusState = ref._focusState;
1141
+ var legendInFocus = ref_focusState.legendInFocus;
1142
+ var focusedElement = ref_focusState.focusedElement;
1126
1143
  var legend = ref._legend;
1127
1144
 
1128
1145
  if (e.key === TAB) {
@@ -1134,6 +1151,22 @@ var Chart = (function (Class) {
1134
1151
  } else if (!legendInFocus && isLegendBeforeChart === e.shiftKey && legend.hasItems()) {
1135
1152
  this._navigateLegend(e);
1136
1153
  }
1154
+ } else if (e.key === ESCAPE) {
1155
+ if (focusedElement) {
1156
+ e.stopPropagation();
1157
+ }
1158
+
1159
+ if (this._tooltip && this._tooltip.visible) {
1160
+ this._hideTooltip();
1161
+ } else {
1162
+ this._blur();
1163
+ }
1164
+ } else if (e.key === ENTER) {
1165
+ if (focusedElement) {
1166
+ this._focusState.preserveHighlight = true;
1167
+ this._propagateClick(focusedElement, e);
1168
+ this._focusElement(focusedElement);
1169
+ }
1137
1170
  } else if (!legendInFocus) {
1138
1171
  this._navigatePoints(e);
1139
1172
  } else {
@@ -1160,6 +1193,7 @@ var Chart = (function (Class) {
1160
1193
  focusState.focusedPoint = point;
1161
1194
 
1162
1195
  this$1._focusElement(focusState.focusedPoint);
1196
+ this$1._displayTooltip(point);
1163
1197
  e.preventDefault();
1164
1198
  };
1165
1199
 
@@ -1226,6 +1260,7 @@ var Chart = (function (Class) {
1226
1260
 
1227
1261
  if (point) {
1228
1262
  this._focusElement(point);
1263
+ this._displayTooltip(point);
1229
1264
  }
1230
1265
  };
1231
1266
 
@@ -1261,6 +1296,8 @@ var Chart = (function (Class) {
1261
1296
  focusState.focusedLegendItemIndex = 0;
1262
1297
  this._focusElement(this._getFocusedLegendItem());
1263
1298
  focusState.legendInFocus = true;
1299
+
1300
+ this._hideTooltip();
1264
1301
  };
1265
1302
 
1266
1303
  Chart.prototype._focusLegendItem = function _focusLegendItem (args) {
@@ -1404,6 +1441,12 @@ var Chart = (function (Class) {
1404
1441
  }
1405
1442
  };
1406
1443
 
1444
+ Chart.prototype._hideTooltip = function _hideTooltip () {
1445
+ if (this._tooltip) {
1446
+ this._tooltip.hide();
1447
+ }
1448
+ };
1449
+
1407
1450
  Chart.prototype._displayInactiveOpacity = function _displayInactiveOpacity (activePoint, multipleSeries, highlightPoints) {
1408
1451
  var chartInstance = this._activeChartInstance = this._chartInstanceFromPoint(activePoint);
1409
1452
  if (!chartInstance) {
@@ -1746,14 +1789,13 @@ var Chart = (function (Class) {
1746
1789
 
1747
1790
  Chart.prototype._unsetActivePoint = function _unsetActivePoint (options) {
1748
1791
  var ref = this;
1749
- var tooltip = ref._tooltip;
1750
1792
  var highlight = ref._highlight;
1751
1793
 
1752
1794
  this._activePoint = null;
1753
1795
  this._hoveredPoint = null;
1754
1796
 
1755
- if (tooltip && !(options && options.keepTooltipOpen)) {
1756
- tooltip.hide();
1797
+ if (!options || !options.keepTooltipOpen) {
1798
+ this._hideTooltip();
1757
1799
  }
1758
1800
 
1759
1801
  this._tooltipCategoryIx = null;
@@ -18,6 +18,8 @@ export var DEFAULT_HEIGHT = 400;
18
18
  export var DEFAULT_PRECISION = 10;
19
19
  export var DEFAULT_WIDTH = 600;
20
20
  export var END = "end";
21
+ export var ENTER = "Enter";
22
+ export var ESCAPE = "Escape";
21
23
  export var FORMAT_REGEX = /\{\d+:?/;
22
24
  export var HEIGHT = "height";
23
25
  export var HIGHLIGHT_ZINDEX = 100;
@@ -19,7 +19,8 @@ import isDateAxis from './utils/is-date-axis';
19
19
  import { ChartPane, ChartPlotArea, findAxisByName } from './api-elements';
20
20
 
21
21
  import { X, Y, VALUE, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_SERIES_OPACITY,
22
- ARROW_DOWN, ARROW_UP, ARROW_LEFT, ARROW_RIGHT, ARIA_ACTIVE_DESCENDANT, TAB, TOP, LEFT, BLACK } from '../common/constants';
22
+ ARROW_DOWN, ARROW_UP, ARROW_LEFT, ARROW_RIGHT, ARIA_ACTIVE_DESCENDANT, TAB, TOP, LEFT, BLACK,
23
+ ENTER, ESCAPE } from '../common/constants';
23
24
  import { addClass, Class, setDefaultOptions, deepExtend, defined, find, isObject, isFunction, elementSize, elementOffset,
24
25
  elementScale, elementStyles, eventCoordinates, bindEvents, unbindEvents, mousewheelDelta, FontLoader, inArray, round,
25
26
  valueOrDefault, isString, cycleUp, cycleDown, hasOwnProperty } from '../common';
@@ -333,6 +334,17 @@ class Chart extends Class {
333
334
  if (!this._navState) {
334
335
  this._cancelDomEvents();
335
336
  }
337
+
338
+ this._redrawFocusHighlight();
339
+ }
340
+
341
+ _redrawFocusHighlight() {
342
+ const { _focusState: { legendInFocus, preserveHighlight } } = this;
343
+
344
+ if (legendInFocus && preserveHighlight) {
345
+ this._focusElement(this._getFocusedLegendItem(), false);
346
+ this._focusState.preserveHighlight = false;
347
+ }
336
348
  }
337
349
 
338
350
  _setElementAccessibilityAttributes() {
@@ -1100,7 +1112,7 @@ class Chart extends Class {
1100
1112
  }
1101
1113
 
1102
1114
  _keydown(e) {
1103
- const { _focusState: { legendInFocus }, _legend: legend } = this;
1115
+ const { _focusState: { legendInFocus, focusedElement }, _legend: legend } = this;
1104
1116
 
1105
1117
  if (e.key === TAB) {
1106
1118
  this._clearFocusedElement();
@@ -1111,6 +1123,22 @@ class Chart extends Class {
1111
1123
  } else if (!legendInFocus && isLegendBeforeChart === e.shiftKey && legend.hasItems()) {
1112
1124
  this._navigateLegend(e);
1113
1125
  }
1126
+ } else if (e.key === ESCAPE) {
1127
+ if (focusedElement) {
1128
+ e.stopPropagation();
1129
+ }
1130
+
1131
+ if (this._tooltip && this._tooltip.visible) {
1132
+ this._hideTooltip();
1133
+ } else {
1134
+ this._blur();
1135
+ }
1136
+ } else if (e.key === ENTER) {
1137
+ if (focusedElement) {
1138
+ this._focusState.preserveHighlight = true;
1139
+ this._propagateClick(focusedElement, e);
1140
+ this._focusElement(focusedElement);
1141
+ }
1114
1142
  } else if (!legendInFocus) {
1115
1143
  this._navigatePoints(e);
1116
1144
  } else {
@@ -1133,6 +1161,7 @@ class Chart extends Class {
1133
1161
  focusState.focusedPoint = point;
1134
1162
 
1135
1163
  this._focusElement(focusState.focusedPoint);
1164
+ this._displayTooltip(point);
1136
1165
  e.preventDefault();
1137
1166
  };
1138
1167
 
@@ -1194,6 +1223,7 @@ class Chart extends Class {
1194
1223
 
1195
1224
  if (point) {
1196
1225
  this._focusElement(point);
1226
+ this._displayTooltip(point);
1197
1227
  }
1198
1228
  }
1199
1229
 
@@ -1228,6 +1258,8 @@ class Chart extends Class {
1228
1258
  focusState.focusedLegendItemIndex = 0;
1229
1259
  this._focusElement(this._getFocusedLegendItem());
1230
1260
  focusState.legendInFocus = true;
1261
+
1262
+ this._hideTooltip();
1231
1263
  }
1232
1264
 
1233
1265
  _focusLegendItem(args) {
@@ -1366,6 +1398,12 @@ class Chart extends Class {
1366
1398
  }
1367
1399
  }
1368
1400
 
1401
+ _hideTooltip() {
1402
+ if (this._tooltip) {
1403
+ this._tooltip.hide();
1404
+ }
1405
+ }
1406
+
1369
1407
  _displayInactiveOpacity(activePoint, multipleSeries, highlightPoints) {
1370
1408
  const chartInstance = this._activeChartInstance = this._chartInstanceFromPoint(activePoint);
1371
1409
  if (!chartInstance) {
@@ -1690,13 +1728,13 @@ class Chart extends Class {
1690
1728
  }
1691
1729
 
1692
1730
  _unsetActivePoint(options) {
1693
- const { _tooltip: tooltip, _highlight: highlight } = this;
1731
+ const { _highlight: highlight } = this;
1694
1732
 
1695
1733
  this._activePoint = null;
1696
1734
  this._hoveredPoint = null;
1697
1735
 
1698
- if (tooltip && !(options && options.keepTooltipOpen)) {
1699
- tooltip.hide();
1736
+ if (!options || !options.keepTooltipOpen) {
1737
+ this._hideTooltip();
1700
1738
  }
1701
1739
 
1702
1740
  this._tooltipCategoryIx = null;
@@ -18,6 +18,8 @@ export const DEFAULT_HEIGHT = 400;
18
18
  export const DEFAULT_PRECISION = 10;
19
19
  export const DEFAULT_WIDTH = 600;
20
20
  export const END = "end";
21
+ export const ENTER = "Enter";
22
+ export const ESCAPE = "Escape";
21
23
  export const FORMAT_REGEX = /\{\d+:?/;
22
24
  export const HEIGHT = "height";
23
25
  export const HIGHLIGHT_ZINDEX = 100;