@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/CHANGELOG.md CHANGED
@@ -3,6 +3,38 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.51.4](https://github.com/carbon-design-system/carbon-charts/compare/v0.51.3...v0.51.4) (2021-11-16)
7
+
8
+ **Note:** Version bump only for package @carbon/charts-vue
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.51.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.51.2...v0.51.3) (2021-11-03)
15
+
16
+ **Note:** Version bump only for package @carbon/charts-vue
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.51.2](https://github.com/carbon-design-system/carbon-charts/compare/v0.51.1...v0.51.2) (2021-11-02)
23
+
24
+ **Note:** Version bump only for package @carbon/charts-vue
25
+
26
+
27
+
28
+
29
+
30
+ ## [0.51.1](https://github.com/carbon-design-system/carbon-charts/compare/v0.51.0...v0.51.1) (2021-11-02)
31
+
32
+ **Note:** Version bump only for package @carbon/charts-vue
33
+
34
+
35
+
36
+
37
+
6
38
  # [0.51.0](https://github.com/carbon-design-system/carbon-charts/compare/v0.50.10...v0.51.0) (2021-11-01)
7
39
 
8
40
  **Note:** Version bump only for package @carbon/charts-vue
@@ -18240,11 +18240,25 @@ var legend_Legend = /** @class */ (function (_super) {
18240
18240
  hoveredElement: hoveredItem,
18241
18241
  });
18242
18242
  });
18243
- svg.selectAll('div.legend-item div.checkbox').on('keyup', function (event, d) {
18244
- if (event.key && (event.key === 'Enter' || event.key === ' ')) {
18243
+ svg.selectAll('div.legend-item div.checkbox').on('keyup', function (event) {
18244
+ if (event.key && event.key === 'Tab') {
18245
+ // Higlight group
18246
+ self.services.events.dispatchEvent(Events.Legend.ITEM_HOVER, {
18247
+ hoveredElement: src_select(this),
18248
+ });
18249
+ }
18250
+ });
18251
+ svg.selectAll('div.legend-item div.checkbox').on('keydown', function (event, d) {
18252
+ if (event.key && event.key === ' ') {
18245
18253
  event.preventDefault();
18246
18254
  self.model.toggleDataLabel(d.name);
18247
18255
  }
18256
+ else if (event.key && event.key === 'Tab') {
18257
+ // Unhiglight group
18258
+ self.services.events.dispatchEvent(Events.Legend.ITEM_MOUSEOUT, {
18259
+ hoveredElement: src_select(this),
18260
+ });
18261
+ }
18248
18262
  });
18249
18263
  svg.selectAll('g.additional-item').on('mouseover', function (event) {
18250
18264
  var hoveredItem = src_select(this);
@@ -31564,7 +31578,9 @@ function polarToCartesianCoords(a, r, t) {
31564
31578
  if (t === void 0) { t = { x: 0, y: 0 }; }
31565
31579
  var x = r * Math.cos(a) + t.x;
31566
31580
  var y = r * Math.sin(a) + t.y;
31567
- return { x: x, y: y };
31581
+ // NaN is rendered at coordinate 0 in browsers
31582
+ // By setting it to 0, further operations can be performed
31583
+ return { x: isNaN(x) ? 0 : x, y: isNaN(y) ? 0 : y };
31568
31584
  }
31569
31585
  // Return the distance between a point (described with polar coordinates)
31570
31586
  // on a circumference and the vertical diameter.
@@ -35378,8 +35394,9 @@ var axis_Axis = /** @class */ (function (_super) {
35378
35394
  var mockTextPiece = invisibleAxisRef
35379
35395
  .append('text')
35380
35396
  .text('A');
35381
- var averageLetterWidth_1 = mockTextPiece.node().getBBox()
35382
- .width;
35397
+ var averageLetterWidth_1 = dom_utils_DOMUtils.getSVGElementSize(mockTextPiece.node(), {
35398
+ useBBox: true,
35399
+ }).width;
35383
35400
  var lastStartPosition_1;
35384
35401
  // Find out whether any text nodes roughly collide
35385
35402
  invisibleAxisRef.selectAll('g.tick').each(function () {
@@ -38554,6 +38571,7 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38554
38571
  .append('div')
38555
38572
  .attr('class', 'toolbar-control bx--overflow-menu')
38556
38573
  .attr('role', 'button');
38574
+ var self_1 = this;
38557
38575
  var allToolbarControls = enteringToolbarControls
38558
38576
  .merge(toolbarControls)
38559
38577
  .classed('disabled', function (d) {
@@ -38564,16 +38582,23 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38564
38582
  })
38565
38583
  .attr('aria-label', function (d) { return d.title; })
38566
38584
  .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>"; })
38567
- .each(function (d) {
38585
+ .each(function (d, index) {
38568
38586
  src_select(this)
38569
38587
  .select('button')
38570
38588
  .on('click', !d.shouldBeDisabled() ? d.clickFunction : null)
38571
- .on('keyup', function (event) {
38589
+ .on('keydown', function (event) {
38572
38590
  if ((event.key && event.key === 'Enter') ||
38573
38591
  event.key === ' ') {
38574
38592
  event.preventDefault();
38575
38593
  d.clickFunction();
38576
38594
  }
38595
+ else if (event.key && event.key === 'ArrowLeft') {
38596
+ self_1.focusOnPreviousEnabledToolbarItem(index);
38597
+ }
38598
+ else if (event.key &&
38599
+ event.key === 'ArrowRight') {
38600
+ self_1.focusOnNextEnabledToolbarItem(index);
38601
+ }
38577
38602
  });
38578
38603
  });
38579
38604
  this.overflowButton = this.getComponentContainer().select("button.bx--overflow-menu__trigger#" + this.services.domUtils.generateElementIDString('control-toolbar-overflow-menu'));
@@ -38627,6 +38652,43 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38627
38652
  this.services.events.dispatchEvent(Events.Toolbar.HIDE_OVERFLOW_MENU);
38628
38653
  }
38629
38654
  };
38655
+ // Toolbar controllers
38656
+ Toolbar.prototype.focusOnPreviousEnabledToolbarItem = function (currentItemIndex) {
38657
+ var buttonList = this.getToolbarButtonItems();
38658
+ var previousItemIndex = buttonList.length;
38659
+ for (var i = currentItemIndex - 1; i >= 0; i--) {
38660
+ var previousButtonItem = buttonList[i];
38661
+ if (!previousButtonItem.shouldBeDisabled()) {
38662
+ previousItemIndex = i;
38663
+ break;
38664
+ }
38665
+ }
38666
+ // only if previous enabled menu item found
38667
+ if (previousItemIndex < buttonList.length) {
38668
+ var previousItemNode = src_select("button#" + this.services.domUtils.generateElementIDString("control-" + buttonList[previousItemIndex].id)).node();
38669
+ if ('focus' in previousItemNode) {
38670
+ previousItemNode.focus();
38671
+ }
38672
+ }
38673
+ };
38674
+ Toolbar.prototype.focusOnNextEnabledToolbarItem = function (currentItemIndex) {
38675
+ var buttonList = this.getToolbarButtonItems();
38676
+ var nextItemIndex = -1;
38677
+ for (var i = currentItemIndex + 1; i < buttonList.length; i++) {
38678
+ var nextOverflowMenuItem = buttonList[i];
38679
+ if (!nextOverflowMenuItem.shouldBeDisabled()) {
38680
+ nextItemIndex = i;
38681
+ break;
38682
+ }
38683
+ }
38684
+ // only if next enabled menu item found
38685
+ if (nextItemIndex > -1) {
38686
+ var nextItemNode = src_select("button#" + this.services.domUtils.generateElementIDString("control-" + buttonList[nextItemIndex].id)).node();
38687
+ if ('focus' in nextItemNode) {
38688
+ nextItemNode.focus();
38689
+ }
38690
+ }
38691
+ };
38630
38692
  Toolbar.prototype.focusOnPreviousEnabledMenuItem = function (currentItemIndex) {
38631
38693
  var overflowMenuItems = this.getOverflowMenuItems();
38632
38694
  var previousItemIndex = overflowMenuItems.length;
@@ -38673,7 +38735,7 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38673
38735
  // show overflow menu
38674
38736
  this.updateOverflowMenu(true);
38675
38737
  // setup overflow menu item event listener
38676
- var self_1 = this;
38738
+ var self_2 = this;
38677
38739
  var overflowMenuItems = this.getOverflowMenuItems();
38678
38740
  overflowMenuItems.forEach(function (menuItem, index) {
38679
38741
  var element = src_select("#" + _this.services.domUtils.generateElementIDString("control-" + menuItem.id));
@@ -38682,29 +38744,37 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38682
38744
  // call the specified function
38683
38745
  menuItem.clickFunction();
38684
38746
  // hide overflow menu
38685
- self_1.updateOverflowMenu(false);
38747
+ self_2.updateOverflowMenu(false);
38686
38748
  });
38687
- element.on('keyup', function () {
38688
- if (event.key === 'Enter') {
38749
+ element.on('keydown', function (keyEvent) {
38750
+ if (keyEvent && keyEvent.key === 'Enter') {
38689
38751
  // call the specified function
38690
38752
  menuItem.clickFunction();
38691
38753
  }
38692
- else if (event.key === 'ArrowUp') {
38754
+ else if (keyEvent && keyEvent.key === 'ArrowUp') {
38693
38755
  // focus on previous menu item
38694
- self_1.focusOnPreviousEnabledMenuItem(index);
38756
+ self_2.focusOnPreviousEnabledMenuItem(index);
38695
38757
  }
38696
- else if (event.key === 'ArrowDown') {
38758
+ else if (keyEvent && keyEvent.key === 'ArrowDown') {
38697
38759
  // focus on next menu item
38698
- self_1.focusOnNextEnabledMenuItem(index);
38760
+ self_2.focusOnNextEnabledMenuItem(index);
38761
+ }
38762
+ else if (keyEvent && keyEvent.key === 'Escape') {
38763
+ self_2.updateOverflowMenu(false);
38699
38764
  }
38700
38765
  // Not hide overflow menu by keyboard arrow up/down event
38766
+ // Prevent page from scrolling up/down
38767
+ keyEvent.preventDefault();
38701
38768
  });
38702
38769
  }
38703
38770
  });
38704
38771
  // default to focus on the first enabled menu item
38705
- self_1.focusOnNextEnabledMenuItem(-1);
38772
+ self_2.focusOnNextEnabledMenuItem(-1);
38773
+ }
38774
+ // propogation should not be stopped for keyboard events
38775
+ if (!!event) {
38776
+ event.stopImmediatePropagation();
38706
38777
  }
38707
- event.stopImmediatePropagation();
38708
38778
  };
38709
38779
  Toolbar.prototype.getControlConfigs = function () {
38710
38780
  var _this = this;
@@ -38737,6 +38807,16 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38737
38807
  overflowMenuItemList: controlList.concat(overflowSpecificControls),
38738
38808
  };
38739
38809
  };
38810
+ Toolbar.prototype.getToolbarButtonItems = function () {
38811
+ var _a = this.getControlConfigs(), buttonList = _a.buttonList, overflowMenuItemList = _a.overflowMenuItemList;
38812
+ if (!!overflowMenuItemList) {
38813
+ buttonList.push(this.getOverflowButtonConfig());
38814
+ }
38815
+ if (!!buttonList) {
38816
+ return buttonList;
38817
+ }
38818
+ return [];
38819
+ };
38740
38820
  Toolbar.prototype.getOverflowMenuItems = function () {
38741
38821
  var overflowMenuItemList = this.getControlConfigs().overflowMenuItemList;
38742
38822
  if (!!overflowMenuItemList) {