@carbon/charts-vue 0.53.3 → 0.53.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,14 @@
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.53.4](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.3...v0.53.4) (2021-12-13)
7
+
8
+ **Note:** Version bump only for package @carbon/charts-vue
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.53.3](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.2...v0.53.3) (2021-12-07)
7
15
 
8
16
  **Note:** Version bump only for package @carbon/charts-vue
@@ -441,6 +441,7 @@ var events_Toolbar;
441
441
  (function (Toolbar) {
442
442
  Toolbar["SHOW_OVERFLOW_MENU"] = "show-toolbar-overflow-menu";
443
443
  Toolbar["HIDE_OVERFLOW_MENU"] = "hide-toolbar-overflow-menu";
444
+ Toolbar["BUTTON_CLICK"] = "toolbar-button-click";
444
445
  })(events_Toolbar || (events_Toolbar = {}));
445
446
  /**
446
447
  * enum of all events related to the zoom-bar
@@ -884,6 +885,7 @@ var ToolbarControlTypes;
884
885
  ToolbarControlTypes["RESET_ZOOM"] = "Reset zoom";
885
886
  ToolbarControlTypes["MAKE_FULLSCREEN"] = "Make fullscreen";
886
887
  ToolbarControlTypes["SHOW_AS_DATATABLE"] = "Show as data-table";
888
+ ToolbarControlTypes["CUSTOM"] = "Custom";
887
889
  })(ToolbarControlTypes || (ToolbarControlTypes = {}));
888
890
  /**
889
891
  * enum of title orientations for _vertical axes_
@@ -38635,23 +38637,26 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38635
38637
  var self_1 = this;
38636
38638
  var allToolbarControls = enteringToolbarControls
38637
38639
  .merge(toolbarControls)
38638
- .classed('disabled', function (d) {
38639
- return d.shouldBeDisabled ? d.shouldBeDisabled() : false;
38640
- })
38641
- .attr('aria-disabled', function (d) {
38642
- return d.shouldBeDisabled ? d.shouldBeDisabled() : false;
38643
- })
38640
+ .classed('disabled', function (d) { return d.shouldBeDisabled(); })
38641
+ .attr('aria-disabled', function (d) { return d.shouldBeDisabled(); })
38644
38642
  .attr('aria-label', function (d) { return d.title; })
38645
- .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>"; })
38643
+ .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.iconSVG.width !== undefined ? d.iconSVG.width : '20px') + "; height: " + (d.iconSVG.height !== undefined
38644
+ ? d.iconSVG.height
38645
+ : '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.iconSVG.content + "\n\t\t\t\t</svg>\n\t\t\t</button>"; })
38646
38646
  .each(function (d, index) {
38647
+ var _this = this;
38647
38648
  src_select(this)
38648
38649
  .select('button')
38649
- .on('click', !d.shouldBeDisabled() ? d.clickFunction : null)
38650
+ .on('click', function (event) {
38651
+ if (!d.shouldBeDisabled()) {
38652
+ self_1.triggerFunctionAndEvent(d, event, _this);
38653
+ }
38654
+ })
38650
38655
  .on('keydown', function (event) {
38651
38656
  if ((event.key && event.key === 'Enter') ||
38652
38657
  event.key === ' ') {
38653
38658
  event.preventDefault();
38654
- d.clickFunction();
38659
+ self_1.triggerFunctionAndEvent(d, event, _this);
38655
38660
  }
38656
38661
  else if (event.key && event.key === 'ArrowLeft') {
38657
38662
  self_1.focusOnPreviousEnabledToolbarItem(index);
@@ -38805,15 +38810,13 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38805
38810
  var element = src_select("#" + _this.services.domUtils.generateElementIDString("control-" + menuItem.id));
38806
38811
  if (element !== null) {
38807
38812
  element.on('click', function () {
38808
- // call the specified function
38809
- menuItem.clickFunction();
38813
+ self_2.triggerFunctionAndEvent(menuItem, event, element.node());
38810
38814
  // hide overflow menu
38811
38815
  self_2.updateOverflowMenu(false);
38812
38816
  });
38813
38817
  element.on('keydown', function (keyEvent) {
38814
38818
  if (keyEvent && keyEvent.key === 'Enter') {
38815
- // call the specified function
38816
- menuItem.clickFunction();
38819
+ self_2.triggerFunctionAndEvent(menuItem, event, element.node());
38817
38820
  }
38818
38821
  else if (keyEvent && keyEvent.key === 'ArrowUp') {
38819
38822
  // focus on previous menu item
@@ -38840,35 +38843,75 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38840
38843
  event.stopImmediatePropagation();
38841
38844
  }
38842
38845
  };
38846
+ // Calls passed function && dispatches event
38847
+ Toolbar.prototype.triggerFunctionAndEvent = function (control, event, element) {
38848
+ // Call custom function only if it exists
38849
+ if (typeof control.clickFunction === 'function') {
38850
+ control.clickFunction(event);
38851
+ }
38852
+ // Dispatch selection event
38853
+ this.services.events.dispatchEvent(Events.Toolbar.BUTTON_CLICK, {
38854
+ control: control,
38855
+ event: event,
38856
+ element: element,
38857
+ });
38858
+ };
38843
38859
  Toolbar.prototype.getControlConfigs = function () {
38844
38860
  var _this = this;
38845
- var numberOfIcons = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'numberOfIcons');
38861
+ var numberOfIcons = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'numberOfIcons') -
38862
+ 1;
38846
38863
  var controls = tools_Tools.getProperty(this.getOptions(), 'toolbar', 'controls');
38847
- var controlList = [];
38848
38864
  var overflowSpecificControls = [];
38865
+ var buttonList = [];
38866
+ var overflowList = [];
38849
38867
  controls.forEach(function (control) {
38850
- var controlConfig = _this.getControlConfigByType(control.type);
38868
+ var controlConfig = null;
38869
+ // check if button is custom or default control
38870
+ if (control.type === ToolbarControlTypes.CUSTOM) {
38871
+ // add generic id if missing
38872
+ if (tools_Tools.getProperty(control, 'id') === null) {
38873
+ // add id directly to the data passed so that id isn't reassigned on rerender
38874
+ control.id = "toolbar-button-" + Toolbar.buttonID++;
38875
+ }
38876
+ // define function if missing
38877
+ if (tools_Tools.getProperty(control, 'shouldBeDisabled') === null) {
38878
+ control.shouldBeDisabled = function () { return false; };
38879
+ }
38880
+ controlConfig = control;
38881
+ }
38882
+ else {
38883
+ controlConfig = _this.getControlConfigByType(control.type);
38884
+ }
38851
38885
  // add to list if config is valid
38852
38886
  if (controlConfig) {
38853
38887
  controlConfig.text = control.text ? control.text : control.type;
38854
38888
  if (controlConfig.id.indexOf('toolbar-export') !== -1) {
38855
38889
  overflowSpecificControls.push(controlConfig);
38856
38890
  }
38891
+ else if (buttonList.length < numberOfIcons) {
38892
+ // check if icon exists else assign to the overflow list
38893
+ if (tools_Tools.getProperty(controlConfig, 'iconSVG', 'content') === null) {
38894
+ overflowList.push(controlConfig);
38895
+ }
38896
+ else {
38897
+ buttonList.push(controlConfig);
38898
+ }
38899
+ }
38857
38900
  else {
38858
- controlList.push(controlConfig);
38901
+ overflowList.push(controlConfig);
38859
38902
  }
38860
38903
  }
38861
38904
  });
38862
- if (controlList.length <= numberOfIcons &&
38863
- overflowSpecificControls.length === 0) {
38905
+ // Ensures the `export` controls are always at the bottom
38906
+ overflowList.push.apply(overflowList, overflowSpecificControls);
38907
+ if (!overflowList.length) {
38864
38908
  return {
38865
- buttonList: controlList,
38909
+ buttonList: buttonList,
38866
38910
  };
38867
38911
  }
38868
38912
  return {
38869
- // leave one button for overflow button
38870
- buttonList: controlList.splice(0, numberOfIcons - 1),
38871
- overflowMenuItemList: controlList.concat(overflowSpecificControls),
38913
+ buttonList: buttonList,
38914
+ overflowMenuItemList: overflowList,
38872
38915
  };
38873
38916
  };
38874
38917
  Toolbar.prototype.getToolbarButtonItems = function () {
@@ -38897,7 +38940,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38897
38940
  id: 'toolbar-overflow-menu',
38898
38941
  title: 'More options',
38899
38942
  shouldBeDisabled: function () { return false; },
38900
- iconSVGContent: "<circle cx=\"16\" cy=\"8\" r=\"2\"></circle>\n\t\t\t\t\t\t\t <circle cx=\"16\" cy=\"16\" r=\"2\"></circle>\n\t\t\t\t\t\t\t <circle cx=\"16\" cy=\"24\" r=\"2\"></circle>",
38943
+ iconSVG: {
38944
+ content: "<circle cx=\"16\" cy=\"8\" r=\"2\"></circle>\n\t\t\t\t<circle cx=\"16\" cy=\"16\" r=\"2\"></circle>\n\t\t\t\t<circle cx=\"16\" cy=\"24\" r=\"2\"></circle>",
38945
+ },
38901
38946
  clickFunction: function (event) { return _this.toggleOverflowMenu(event); },
38902
38947
  };
38903
38948
  };
@@ -38917,7 +38962,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38917
38962
  shouldBeDisabled: function () {
38918
38963
  return _this.services.zoom.isMinZoomDomain();
38919
38964
  },
38920
- iconSVGContent: this.getControlIconByType(controlType),
38965
+ iconSVG: {
38966
+ content: this.getControlIconByType(controlType),
38967
+ },
38921
38968
  clickFunction: function () { return _this.services.zoom.zoomIn(); },
38922
38969
  };
38923
38970
  }
@@ -38930,7 +38977,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38930
38977
  shouldBeDisabled: function () {
38931
38978
  return _this.services.zoom.isMaxZoomDomain();
38932
38979
  },
38933
- iconSVGContent: this.getControlIconByType(controlType),
38980
+ iconSVG: {
38981
+ content: this.getControlIconByType(controlType),
38982
+ },
38934
38983
  clickFunction: function () { return _this.services.zoom.zoomOut(); },
38935
38984
  };
38936
38985
  }
@@ -38943,7 +38992,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38943
38992
  shouldBeDisabled: function () {
38944
38993
  return _this.services.zoom.isMaxZoomDomain();
38945
38994
  },
38946
- iconSVGContent: this.getControlIconByType(controlType),
38995
+ iconSVG: {
38996
+ content: this.getControlIconByType(controlType),
38997
+ },
38947
38998
  clickFunction: function () {
38948
38999
  return _this.services.zoom.resetZoomDomain();
38949
39000
  },
@@ -38953,10 +39004,12 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38953
39004
  case ToolbarControlTypes.MAKE_FULLSCREEN:
38954
39005
  controlConfig = {
38955
39006
  id: 'toolbar-makefullscreen',
39007
+ iconSVG: {
39008
+ content: this.getControlIconByType(controlType),
39009
+ width: '15px',
39010
+ height: '15px',
39011
+ },
38956
39012
  title: 'Make fullscreen',
38957
- iconSVGContent: this.getControlIconByType(controlType),
38958
- iconWidth: '15px',
38959
- iconHight: '15px',
38960
39013
  shouldBeDisabled: function () { return false; },
38961
39014
  clickFunction: function () {
38962
39015
  _this.services.domUtils.toggleFullscreen();
@@ -38966,8 +39019,10 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38966
39019
  case ToolbarControlTypes.SHOW_AS_DATATABLE:
38967
39020
  controlConfig = {
38968
39021
  id: 'toolbar-showasdatatable',
39022
+ iconSVG: {
39023
+ content: this.getControlIconByType(controlType),
39024
+ },
38969
39025
  title: 'Show as table',
38970
- iconSVGContent: this.getControlIconByType(controlType),
38971
39026
  shouldBeDisabled: function () { return displayData.length === 0; },
38972
39027
  clickFunction: function () {
38973
39028
  return _this.services.events.dispatchEvent(Events.Modal.SHOW);
@@ -38979,7 +39034,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38979
39034
  id: 'toolbar-export-CSV',
38980
39035
  title: 'Export as CSV',
38981
39036
  shouldBeDisabled: function () { return false; },
38982
- iconSVGContent: this.getControlIconByType(controlType),
39037
+ iconSVG: {
39038
+ content: this.getControlIconByType(controlType),
39039
+ },
38983
39040
  clickFunction: function () { return _this.model.exportToCSV(); },
38984
39041
  };
38985
39042
  break;
@@ -38988,7 +39045,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38988
39045
  id: 'toolbar-export-PNG',
38989
39046
  title: 'Export as PNG',
38990
39047
  shouldBeDisabled: function () { return false; },
38991
- iconSVGContent: this.getControlIconByType(controlType),
39048
+ iconSVG: {
39049
+ content: this.getControlIconByType(controlType),
39050
+ },
38992
39051
  clickFunction: function () { return _this.services.domUtils.exportToPNG(); },
38993
39052
  };
38994
39053
  break;
@@ -38997,7 +39056,9 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
38997
39056
  id: 'toolbar-export-JPG',
38998
39057
  title: 'Export as JPG',
38999
39058
  shouldBeDisabled: function () { return false; },
39000
- iconSVGContent: this.getControlIconByType(controlType),
39059
+ iconSVG: {
39060
+ content: this.getControlIconByType(controlType),
39061
+ },
39001
39062
  clickFunction: function () { return _this.services.domUtils.exportToJPG(); },
39002
39063
  };
39003
39064
  break;
@@ -39030,6 +39091,7 @@ var toolbar_Toolbar = /** @class */ (function (_super) {
39030
39091
  throw Error('Not supported toolbar control type: ' + controlType);
39031
39092
  }
39032
39093
  };
39094
+ Toolbar.buttonID = 0;
39033
39095
  return Toolbar;
39034
39096
  }(component_Component));
39035
39097