@carbon/charts-vue 0.51.0 → 0.51.4

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/charts-vue.umd.js CHANGED
@@ -18249,11 +18249,25 @@ var legend_Legend = /** @class */ (function (_super) {
18249
18249
  hoveredElement: hoveredItem,
18250
18250
  });
18251
18251
  });
18252
- svg.selectAll('div.legend-item div.checkbox').on('keyup', function (event, d) {
18253
- if (event.key && (event.key === 'Enter' || event.key === ' ')) {
18252
+ svg.selectAll('div.legend-item div.checkbox').on('keyup', function (event) {
18253
+ if (event.key && event.key === 'Tab') {
18254
+ // Higlight group
18255
+ self.services.events.dispatchEvent(Events.Legend.ITEM_HOVER, {
18256
+ hoveredElement: src_select(this),
18257
+ });
18258
+ }
18259
+ });
18260
+ svg.selectAll('div.legend-item div.checkbox').on('keydown', function (event, d) {
18261
+ if (event.key && event.key === ' ') {
18254
18262
  event.preventDefault();
18255
18263
  self.model.toggleDataLabel(d.name);
18256
18264
  }
18265
+ else if (event.key && event.key === 'Tab') {
18266
+ // Unhiglight group
18267
+ self.services.events.dispatchEvent(Events.Legend.ITEM_MOUSEOUT, {
18268
+ hoveredElement: src_select(this),
18269
+ });
18270
+ }
18257
18271
  });
18258
18272
  svg.selectAll('g.additional-item').on('mouseover', function (event) {
18259
18273
  var hoveredItem = src_select(this);
@@ -31573,7 +31587,9 @@ function polarToCartesianCoords(a, r, t) {
31573
31587
  if (t === void 0) { t = { x: 0, y: 0 }; }
31574
31588
  var x = r * Math.cos(a) + t.x;
31575
31589
  var y = r * Math.sin(a) + t.y;
31576
- return { x: x, y: y };
31590
+ // NaN is rendered at coordinate 0 in browsers
31591
+ // By setting it to 0, further operations can be performed
31592
+ return { x: isNaN(x) ? 0 : x, y: isNaN(y) ? 0 : y };
31577
31593
  }
31578
31594
  // Return the distance between a point (described with polar coordinates)
31579
31595
  // on a circumference and the vertical diameter.
@@ -35387,8 +35403,9 @@ var axis_Axis = /** @class */ (function (_super) {
35387
35403
  var mockTextPiece = invisibleAxisRef
35388
35404
  .append('text')
35389
35405
  .text('A');
35390
- var averageLetterWidth_1 = mockTextPiece.node().getBBox()
35391
- .width;
35406
+ var averageLetterWidth_1 = dom_utils_DOMUtils.getSVGElementSize(mockTextPiece.node(), {
35407
+ useBBox: true,
35408
+ }).width;
35392
35409
  var lastStartPosition_1;
35393
35410
  // Find out whether any text nodes roughly collide
35394
35411
  invisibleAxisRef.selectAll('g.tick').each(function () {
@@ -38563,6 +38580,7 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38563
38580
  .append('div')
38564
38581
  .attr('class', 'toolbar-control bx--overflow-menu')
38565
38582
  .attr('role', 'button');
38583
+ var self_1 = this;
38566
38584
  var allToolbarControls = enteringToolbarControls
38567
38585
  .merge(toolbarControls)
38568
38586
  .classed('disabled', function (d) {
@@ -38573,16 +38591,23 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38573
38591
  })
38574
38592
  .attr('aria-label', function (d) { return d.title; })
38575
38593
  .html(function (d) { return "\n\t\t\t<button\n\t\t\t\tclass=\"bx--overflow-menu__trigger\"\n\t\t\t\taria-haspopup=\"true\" aria-expanded=\"false\" id=\"" + _this.services.domUtils.generateElementIDString("control-" + d.id) + "\" aria-label=\"" + d.title + "\">\n\t\t\t\t<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" style=\"will-change: transform; width: " + (d.iconWidth !== undefined ? d.iconWidth : '20px') + "; height: " + (d.iconWidth !== undefined ? d.iconHeight : '20px') + "\" xmlns=\"http://www.w3.org/2000/svg\" class=\"bx--overflow-menu__icon\" viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n\t\t\t\t\t" + d.iconSVGContent + "\n\t\t\t\t</svg>\n\t\t\t</button>"; })
38576
- .each(function (d) {
38594
+ .each(function (d, index) {
38577
38595
  src_select(this)
38578
38596
  .select('button')
38579
38597
  .on('click', !d.shouldBeDisabled() ? d.clickFunction : null)
38580
- .on('keyup', function (event) {
38598
+ .on('keydown', function (event) {
38581
38599
  if ((event.key && event.key === 'Enter') ||
38582
38600
  event.key === ' ') {
38583
38601
  event.preventDefault();
38584
38602
  d.clickFunction();
38585
38603
  }
38604
+ else if (event.key && event.key === 'ArrowLeft') {
38605
+ self_1.focusOnPreviousEnabledToolbarItem(index);
38606
+ }
38607
+ else if (event.key &&
38608
+ event.key === 'ArrowRight') {
38609
+ self_1.focusOnNextEnabledToolbarItem(index);
38610
+ }
38586
38611
  });
38587
38612
  });
38588
38613
  this.overflowButton = this.getComponentContainer().select("button.bx--overflow-menu__trigger#" + this.services.domUtils.generateElementIDString('control-toolbar-overflow-menu'));
@@ -38636,6 +38661,43 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38636
38661
  this.services.events.dispatchEvent(Events.Toolbar.HIDE_OVERFLOW_MENU);
38637
38662
  }
38638
38663
  };
38664
+ // Toolbar controllers
38665
+ Toolbar.prototype.focusOnPreviousEnabledToolbarItem = function (currentItemIndex) {
38666
+ var buttonList = this.getToolbarButtonItems();
38667
+ var previousItemIndex = buttonList.length;
38668
+ for (var i = currentItemIndex - 1; i >= 0; i--) {
38669
+ var previousButtonItem = buttonList[i];
38670
+ if (!previousButtonItem.shouldBeDisabled()) {
38671
+ previousItemIndex = i;
38672
+ break;
38673
+ }
38674
+ }
38675
+ // only if previous enabled menu item found
38676
+ if (previousItemIndex < buttonList.length) {
38677
+ var previousItemNode = src_select("button#" + this.services.domUtils.generateElementIDString("control-" + buttonList[previousItemIndex].id)).node();
38678
+ if ('focus' in previousItemNode) {
38679
+ previousItemNode.focus();
38680
+ }
38681
+ }
38682
+ };
38683
+ Toolbar.prototype.focusOnNextEnabledToolbarItem = function (currentItemIndex) {
38684
+ var buttonList = this.getToolbarButtonItems();
38685
+ var nextItemIndex = -1;
38686
+ for (var i = currentItemIndex + 1; i < buttonList.length; i++) {
38687
+ var nextOverflowMenuItem = buttonList[i];
38688
+ if (!nextOverflowMenuItem.shouldBeDisabled()) {
38689
+ nextItemIndex = i;
38690
+ break;
38691
+ }
38692
+ }
38693
+ // only if next enabled menu item found
38694
+ if (nextItemIndex > -1) {
38695
+ var nextItemNode = src_select("button#" + this.services.domUtils.generateElementIDString("control-" + buttonList[nextItemIndex].id)).node();
38696
+ if ('focus' in nextItemNode) {
38697
+ nextItemNode.focus();
38698
+ }
38699
+ }
38700
+ };
38639
38701
  Toolbar.prototype.focusOnPreviousEnabledMenuItem = function (currentItemIndex) {
38640
38702
  var overflowMenuItems = this.getOverflowMenuItems();
38641
38703
  var previousItemIndex = overflowMenuItems.length;
@@ -38682,7 +38744,7 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38682
38744
  // show overflow menu
38683
38745
  this.updateOverflowMenu(true);
38684
38746
  // setup overflow menu item event listener
38685
- var self_1 = this;
38747
+ var self_2 = this;
38686
38748
  var overflowMenuItems = this.getOverflowMenuItems();
38687
38749
  overflowMenuItems.forEach(function (menuItem, index) {
38688
38750
  var element = src_select("#" + _this.services.domUtils.generateElementIDString("control-" + menuItem.id));
@@ -38691,29 +38753,37 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38691
38753
  // call the specified function
38692
38754
  menuItem.clickFunction();
38693
38755
  // hide overflow menu
38694
- self_1.updateOverflowMenu(false);
38756
+ self_2.updateOverflowMenu(false);
38695
38757
  });
38696
- element.on('keyup', function () {
38697
- if (event.key === 'Enter') {
38758
+ element.on('keydown', function (keyEvent) {
38759
+ if (keyEvent && keyEvent.key === 'Enter') {
38698
38760
  // call the specified function
38699
38761
  menuItem.clickFunction();
38700
38762
  }
38701
- else if (event.key === 'ArrowUp') {
38763
+ else if (keyEvent && keyEvent.key === 'ArrowUp') {
38702
38764
  // focus on previous menu item
38703
- self_1.focusOnPreviousEnabledMenuItem(index);
38765
+ self_2.focusOnPreviousEnabledMenuItem(index);
38704
38766
  }
38705
- else if (event.key === 'ArrowDown') {
38767
+ else if (keyEvent && keyEvent.key === 'ArrowDown') {
38706
38768
  // focus on next menu item
38707
- self_1.focusOnNextEnabledMenuItem(index);
38769
+ self_2.focusOnNextEnabledMenuItem(index);
38770
+ }
38771
+ else if (keyEvent && keyEvent.key === 'Escape') {
38772
+ self_2.updateOverflowMenu(false);
38708
38773
  }
38709
38774
  // Not hide overflow menu by keyboard arrow up/down event
38775
+ // Prevent page from scrolling up/down
38776
+ keyEvent.preventDefault();
38710
38777
  });
38711
38778
  }
38712
38779
  });
38713
38780
  // default to focus on the first enabled menu item
38714
- self_1.focusOnNextEnabledMenuItem(-1);
38781
+ self_2.focusOnNextEnabledMenuItem(-1);
38782
+ }
38783
+ // propogation should not be stopped for keyboard events
38784
+ if (!!event) {
38785
+ event.stopImmediatePropagation();
38715
38786
  }
38716
- event.stopImmediatePropagation();
38717
38787
  };
38718
38788
  Toolbar.prototype.getControlConfigs = function () {
38719
38789
  var _this = this;
@@ -38746,6 +38816,16 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38746
38816
  overflowMenuItemList: controlList.concat(overflowSpecificControls),
38747
38817
  };
38748
38818
  };
38819
+ Toolbar.prototype.getToolbarButtonItems = function () {
38820
+ var _a = this.getControlConfigs(), buttonList = _a.buttonList, overflowMenuItemList = _a.overflowMenuItemList;
38821
+ if (!!overflowMenuItemList) {
38822
+ buttonList.push(this.getOverflowButtonConfig());
38823
+ }
38824
+ if (!!buttonList) {
38825
+ return buttonList;
38826
+ }
38827
+ return [];
38828
+ };
38749
38829
  Toolbar.prototype.getOverflowMenuItems = function () {
38750
38830
  var overflowMenuItemList = this.getControlConfigs().overflowMenuItemList;
38751
38831
  if (!!overflowMenuItemList) {