carbon-addons-iot-react 2.155.13 → 2.156.1

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.
Files changed (30) hide show
  1. package/es/components/Card/Card.js +17 -5
  2. package/es/components/CardEditor/CardEditForm/CardEditForm.js +17 -0
  3. package/es/components/CardEditor/CardEditForm/CardEditFormContent.js +18 -0
  4. package/es/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItemModal.js +20 -3
  5. package/es/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItems/DataSeriesFormContent.js +20 -2
  6. package/es/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +19 -2
  7. package/es/components/CardEditor/CardEditor.js +17 -0
  8. package/es/components/DashboardEditor/DashboardEditor.js +20 -1
  9. package/es/components/DashboardEditor/DashboardEditorCardRenderer.js +4 -2
  10. package/es/components/ValueCard/Attribute.js +41 -4
  11. package/es/components/ValueCard/ValueCard.js +15 -3
  12. package/es/components/ValueCard/ValueContent.js +20 -2
  13. package/es/constants/CardPropTypes.js +3 -0
  14. package/es/utils/cardUtilityFunctions.js +17 -1
  15. package/lib/components/Card/Card.js +16 -4
  16. package/lib/components/CardEditor/CardEditForm/CardEditForm.js +17 -0
  17. package/lib/components/CardEditor/CardEditForm/CardEditFormContent.js +18 -0
  18. package/lib/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItemModal.js +20 -3
  19. package/lib/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItems/DataSeriesFormContent.js +20 -2
  20. package/lib/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +19 -2
  21. package/lib/components/CardEditor/CardEditor.js +17 -0
  22. package/lib/components/DashboardEditor/DashboardEditor.js +20 -1
  23. package/lib/components/DashboardEditor/DashboardEditorCardRenderer.js +4 -2
  24. package/lib/components/ValueCard/Attribute.js +41 -4
  25. package/lib/components/ValueCard/ValueCard.js +15 -3
  26. package/lib/components/ValueCard/ValueContent.js +20 -2
  27. package/lib/constants/CardPropTypes.js +3 -0
  28. package/lib/utils/cardUtilityFunctions.js +17 -0
  29. package/package.json +2 -2
  30. package/umd/carbon-addons-iot-react.js +240 -23
@@ -50,7 +50,8 @@ var ValueCard = function ValueCard(_ref) {
50
50
  testID = _ref.testID,
51
51
  testId = _ref.testId,
52
52
  onAttributeClick = _ref.onAttributeClick,
53
- others = _objectWithoutProperties(_ref, ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "customFormatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick"]);
53
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
54
+ others = _objectWithoutProperties(_ref, ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "customFormatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "shouldUseTranslatedLabels"]);
54
55
 
55
56
  var availableActions = _objectSpread({
56
57
  expand: false
@@ -76,6 +77,7 @@ var ValueCard = function ValueCard(_ref) {
76
77
  isResizable: isResizable,
77
78
  resizeHandles: resizeHandles,
78
79
  i18n: i18n,
80
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
79
81
  locale: locale,
80
82
  id: id,
81
83
  className: classnames((_classnames = {}, _defineProperty(_classnames, "".concat(BASE_CLASS_NAME, "__horizontal"), layout === CARD_LAYOUTS.HORIZONTAL), _defineProperty(_classnames, "".concat(BASE_CLASS_NAME, "__vertical"), layout === CARD_LAYOUTS.VERTICAL), _classnames)) // TODO: remove deprecated 'testID' in v3.
@@ -95,7 +97,9 @@ var ValueCard = function ValueCard(_ref) {
95
97
  values: values,
96
98
  isEditable: isEditable,
97
99
  fontSize: fontSize,
98
- isNumberValueCompact: isNumberValueCompact
100
+ isNumberValueCompact: isNumberValueCompact,
101
+ i18n: i18n,
102
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels
99
103
  }, others)), resizeHandles);
100
104
  };
101
105
 
@@ -112,7 +116,8 @@ ValueCard.defaultProps = {
112
116
  isNumberValueCompact: false,
113
117
  // TODO: fix this default in V3, so that cards are unique not inherited from the base Card
114
118
  testId: 'Card',
115
- onAttributeClick: null
119
+ onAttributeClick: null,
120
+ shouldUseTranslatedLabels: false
116
121
  };
117
122
  ValueCard.__docgenInfo = {
118
123
  "description": "This components responsibilities include:\nRendering the attribute groups\nDetermining the layout\ndetermines the data to render",
@@ -188,6 +193,13 @@ ValueCard.__docgenInfo = {
188
193
  "computed": false
189
194
  },
190
195
  "required": false
196
+ },
197
+ "shouldUseTranslatedLabels": {
198
+ "defaultValue": {
199
+ "value": "false",
200
+ "computed": false
201
+ },
202
+ "required": false
191
203
  }
192
204
  },
193
205
  "composes": ["../../constants/CardPropTypes"]
@@ -29,7 +29,10 @@ var propTypes = _objectSpread({
29
29
  title: PropTypes.string,
30
30
  layout: PropTypes.oneOf(['HORIZONTAL', 'VERTICAL']),
31
31
  locale: PropTypes.string,
32
- isEditable: PropTypes.bool
32
+ isEditable: PropTypes.bool,
33
+
34
+ /** whether to use translated labels in cards */
35
+ shouldUseTranslatedLabels: PropTypes.bool
33
36
  }, ValueContentPropTypes);
34
37
 
35
38
  var defaultProps = {
@@ -38,6 +41,7 @@ var defaultProps = {
38
41
  layout: 'VERTICAL',
39
42
  locale: 'en',
40
43
  isEditable: false,
44
+ shouldUseTranslatedLabels: false,
41
45
  dataState: null,
42
46
  values: null,
43
47
  fontSize: DEFAULT_FONT_SIZE,
@@ -57,13 +61,14 @@ var ValueContent = function ValueContent(_ref) {
57
61
  dataState = _ref.dataState,
58
62
  locale = _ref.locale,
59
63
  isEditable = _ref.isEditable,
64
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
60
65
  customFormatter = _ref.customFormatter,
61
66
  fontSize = _ref.fontSize,
62
67
  isNumberValueCompact = _ref.isNumberValueCompact,
63
68
  testId = _ref.testId,
64
69
  onAttributeClick = _ref.onAttributeClick,
65
70
  size = _ref.size,
66
- others = _objectWithoutProperties(_ref, ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "customFormatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"]);
71
+ others = _objectWithoutProperties(_ref, ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "shouldUseTranslatedLabels", "customFormatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"]);
67
72
 
68
73
  var attributeCount = content.attributes.length;
69
74
  return /*#__PURE__*/React__default.createElement("div", {
@@ -77,6 +82,8 @@ var ValueContent = function ValueContent(_ref) {
77
82
  locale: locale,
78
83
  isEditable: isEditable,
79
84
  title: title,
85
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
86
+ i18n: others.i18n,
80
87
  renderIconByName: others.renderIconByName,
81
88
  value: determineValue(attribute.dataSourceId, values, attribute.dataFilter),
82
89
  secondaryValue: attribute.secondaryValue && _objectSpread(_objectSpread({}, attribute.secondaryValue), {}, {
@@ -165,6 +172,17 @@ ValueContent.__docgenInfo = {
165
172
  "required": false,
166
173
  "description": ""
167
174
  },
175
+ "shouldUseTranslatedLabels": {
176
+ "defaultValue": {
177
+ "value": "false",
178
+ "computed": false
179
+ },
180
+ "type": {
181
+ "name": "bool"
182
+ },
183
+ "required": false,
184
+ "description": "whether to use translated labels in cards"
185
+ },
168
186
  "dataState": {
169
187
  "defaultValue": {
170
188
  "value": "null",
@@ -184,6 +184,9 @@ var TableCardPropTypes = {
184
184
  defaultFilterStringPlaceholdText: PropTypes.string,
185
185
  downloadIconDescription: PropTypes.string
186
186
  }),
187
+
188
+ /** whether to use translated labels in cards */
189
+ shouldUseTranslatedLabels: PropTypes.bool,
187
190
  cardVariables: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.number, PropTypes.bool])),
188
191
 
189
192
  /** default date format pattern that follows the dayjs formatting patterns */
@@ -7,6 +7,7 @@ import _typeof from '@babel/runtime/helpers/typeof';
7
7
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
8
8
  import mapValues from '../node_modules/lodash-es/mapValues.js';
9
9
  import isNil from '../node_modules/lodash-es/isNil.js';
10
+ import isEmpty from '../node_modules/lodash-es/isEmpty.js';
10
11
  import 'core-js/modules/es.array.includes.js';
11
12
  import 'core-js/modules/es.string.includes.js';
12
13
  import 'core-js/modules/es.array.concat.js';
@@ -611,5 +612,20 @@ var handleTooltip = function handleTooltip(dataOrHoveredElement, defaultTooltip,
611
612
  });
612
613
  return defaultTooltipDOM.innerHTML;
613
614
  };
615
+ /**
616
+ * Get translated label or title from i18n object, fallback to original if not found
617
+ * @param {string} label - The label or title key to translate
618
+ * @param {boolean} shouldUseTranslatedLabels - Flag to determine if translation should be used
619
+ * @param {Object} i18n - The i18n object containing translations
620
+ * @returns {string} - The translated label or original label if translation not found
621
+ */
622
+
623
+ var getTranslatedLabel = function getTranslatedLabel(label, shouldUseTranslatedLabels, i18n) {
624
+ if (!isEmpty(label) && shouldUseTranslatedLabels && i18n && i18n[label]) {
625
+ return i18n[label];
626
+ }
627
+
628
+ return label;
629
+ };
614
630
 
615
- export { chartValueFormatter, compareGrains, determineCardRange, determinePrecision, fetchDataURL, findMatchingAlertRange, findMatchingThresholds, formatNumberWithPrecision, getCardVariables, getResizeHandles, getUpdatedCardSize, getVariables, handleCardVariables, handleTooltip, increaseSmallCardSize, replaceVariables, useCardResizing };
631
+ export { chartValueFormatter, compareGrains, determineCardRange, determinePrecision, fetchDataURL, findMatchingAlertRange, findMatchingThresholds, formatNumberWithPrecision, getCardVariables, getResizeHandles, getTranslatedLabel, getUpdatedCardSize, getVariables, handleCardVariables, handleTooltip, increaseSmallCardSize, replaceVariables, useCardResizing };
@@ -278,7 +278,8 @@ var defaultProps = {
278
278
  overrides: undefined,
279
279
  type: null,
280
280
  data: null,
281
- content: null
281
+ content: null,
282
+ shouldUseTranslatedLabels: false
282
283
  };
283
284
  /** Dumb component that renders the card basics */
284
285
 
@@ -287,7 +288,7 @@ var Card = function Card(props) {
287
288
 
288
289
  var size = props.size,
289
290
  children = props.children,
290
- title = props.title,
291
+ titleProp = props.title,
291
292
  subtitleProp = props.subtitle,
292
293
  hasTitleWrap = props.hasTitleWrap;
293
294
  props.layout;
@@ -301,7 +302,7 @@ var Card = function Card(props) {
301
302
  error = props.error,
302
303
  hideHeader = props.hideHeader,
303
304
  id = props.id,
304
- tooltip = props.tooltip,
305
+ tooltipProp = props.tooltip,
305
306
  titleTextTooltip = props.titleTextTooltip,
306
307
  timeRange = props.timeRange,
307
308
  timeRangeOptions = props.timeRangeOptions,
@@ -325,9 +326,13 @@ var Card = function Card(props) {
325
326
  type = props.type,
326
327
  data = props.data,
327
328
  content = props.content,
328
- others = _objectWithoutProperties__default["default"](props, ["size", "children", "title", "subtitle", "hasTitleWrap", "layout", "isLoading", "isEmpty", "isEditable", "isExpanded", "isLazyLoading", "isResizable", "resizeHandles", "error", "hideHeader", "id", "tooltip", "titleTextTooltip", "timeRange", "timeRangeOptions", "onCardAction", "availableActions", "renderExpandIcon", "renderDateDropdownInPortal", "breakpoint", "i18n", "style", "className", "values", "testID", "testId", "contentClassName", "footerContent", "dateTimeMask", "extraActions", "padding", "overrides", "type", "data", "content"]); // TODO: remove once final version of range prop is supported
329
+ shouldUseTranslatedLabels = props.shouldUseTranslatedLabels,
330
+ others = _objectWithoutProperties__default["default"](props, ["size", "children", "title", "subtitle", "hasTitleWrap", "layout", "isLoading", "isEmpty", "isEditable", "isExpanded", "isLazyLoading", "isResizable", "resizeHandles", "error", "hideHeader", "id", "tooltip", "titleTextTooltip", "timeRange", "timeRangeOptions", "onCardAction", "availableActions", "renderExpandIcon", "renderDateDropdownInPortal", "breakpoint", "i18n", "style", "className", "values", "testID", "testId", "contentClassName", "footerContent", "dateTimeMask", "extraActions", "padding", "overrides", "type", "data", "content", "shouldUseTranslatedLabels"]); // Get translated title if shouldUseTranslatedLabels is true
329
331
 
330
332
 
333
+ var title = cardUtilityFunctions.getTranslatedLabel(titleProp, shouldUseTranslatedLabels, i18n);
334
+ var tooltip = cardUtilityFunctions.getTranslatedLabel(tooltipProp, shouldUseTranslatedLabels, i18n); // TODO: remove once final version of range prop is supported
335
+
331
336
  React.useEffect(function () {
332
337
  if (typeof (availableActions === null || availableActions === void 0 ? void 0 : availableActions.range) === 'string') {
333
338
  warning__default["default"](false, 'The Card components availableActions.range is an experimental property and may be subject to change.') ;
@@ -823,6 +828,13 @@ Card.__docgenInfo = {
823
828
  "computed": false
824
829
  },
825
830
  "required": false
831
+ },
832
+ "shouldUseTranslatedLabels": {
833
+ "defaultValue": {
834
+ "value": "false",
835
+ "computed": false
836
+ },
837
+ "required": false
826
838
  }
827
839
  },
828
840
  "composes": ["../../constants/CardPropTypes"]
@@ -65,6 +65,9 @@ var propTypes = {
65
65
  modalIconDescription: PropTypes__default["default"].string
66
66
  }),
67
67
 
68
+ /** whether to use translated labels in cards */
69
+ shouldUseTranslatedLabels: PropTypes__default["default"].bool,
70
+
68
71
  /** if provided, returns an array of strings which are the dataItems to be allowed
69
72
  * on each card
70
73
  * getValidDataItems(card, selectedTimeRange)
@@ -130,6 +133,7 @@ var defaultProps = {
130
133
  modalHelpText: 'The JSON definition for this card is provided below. You can modify this data directly to update the card configuration.',
131
134
  modalIconDescription: 'Close'
132
135
  },
136
+ shouldUseTranslatedLabels: false,
133
137
  getValidDataItems: null,
134
138
  getValidTimeRanges: null,
135
139
  dataItems: [],
@@ -159,6 +163,7 @@ var CardEditForm = function CardEditForm(_ref) {
159
163
  availableDimensions = _ref.availableDimensions,
160
164
  dataSeriesItemLinks = _ref.dataSeriesItemLinks,
161
165
  onFetchDynamicDemoHotspots = _ref.onFetchDynamicDemoHotspots,
166
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
162
167
  actions = _ref.actions;
163
168
  var mergedI18n = React.useMemo(function () {
164
169
  return _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
@@ -176,6 +181,7 @@ var CardEditForm = function CardEditForm(_ref) {
176
181
  onChange: onChange,
177
182
  isSummaryDashboard: isSummaryDashboard,
178
183
  i18n: mergedI18n,
184
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
179
185
  dataItems: dataItems,
180
186
  availableDimensions: availableDimensions,
181
187
  getValidDataItems: getValidDataItems,
@@ -326,6 +332,17 @@ CardEditForm.__docgenInfo = {
326
332
  "required": false,
327
333
  "description": ""
328
334
  },
335
+ "shouldUseTranslatedLabels": {
336
+ "defaultValue": {
337
+ "value": "false",
338
+ "computed": false
339
+ },
340
+ "type": {
341
+ "name": "bool"
342
+ },
343
+ "required": false,
344
+ "description": "whether to use translated labels in cards"
345
+ },
329
346
  "getValidDataItems": {
330
347
  "defaultValue": {
331
348
  "value": "null",
@@ -94,6 +94,9 @@ var propTypes = {
94
94
  thisYearLabel: PropTypes__default["default"].string
95
95
  }),
96
96
 
97
+ /** whether to use translated labels in cards */
98
+ shouldUseTranslatedLabels: PropTypes__default["default"].bool,
99
+
97
100
  /** if provided, returns an array of strings which are the timeRanges to be allowed
98
101
  * on each card
99
102
  * getValidTimeRanges(card, selectedDataItems)
@@ -134,6 +137,7 @@ var propTypes = {
134
137
  var defaultProps = {
135
138
  cardConfig: {},
136
139
  i18n: {},
140
+ shouldUseTranslatedLabels: false,
137
141
  getValidDataItems: null,
138
142
  getValidTimeRanges: null,
139
143
  dataItems: [],
@@ -175,6 +179,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
175
179
  isSummaryDashboard = _ref.isSummaryDashboard,
176
180
  onChange = _ref.onChange,
177
181
  i18n = _ref.i18n,
182
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
178
183
  dataItems = _ref.dataItems,
179
184
  getValidDataItems = _ref.getValidDataItems,
180
185
  getValidTimeRanges = _ref.getValidTimeRanges,
@@ -212,6 +217,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
212
217
  ,
213
218
  onChange: onChange,
214
219
  i18n: mergedI18n,
220
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
215
221
  getValidTimeRanges: getValidTimeRanges,
216
222
  currentBreakpoint: currentBreakpoint,
217
223
  selectedDataItems: selectedDataItems,
@@ -258,6 +264,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
258
264
  getValidDataItems: getValidDataItems,
259
265
  availableDimensions: availableDimensions,
260
266
  i18n: mergedI18n,
267
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
261
268
  dataSeriesItemLinks: dataSeriesItemLinks,
262
269
  translateWithId: handleTranslation,
263
270
  actions: actions
@@ -499,6 +506,17 @@ CardEditFormContent.__docgenInfo = {
499
506
  "required": false,
500
507
  "description": ""
501
508
  },
509
+ "shouldUseTranslatedLabels": {
510
+ "defaultValue": {
511
+ "value": "false",
512
+ "computed": false
513
+ },
514
+ "type": {
515
+ "name": "bool"
516
+ },
517
+ "required": false,
518
+ "description": "whether to use translated labels in cards"
519
+ },
502
520
  "getValidDataItems": {
503
521
  "defaultValue": {
504
522
  "value": "null",
@@ -29,6 +29,7 @@ var editorUtils = require('../../../DashboardEditor/editorUtils.js');
29
29
  var ColorDropdown = require('../../../ColorDropdown/ColorDropdown.js');
30
30
  var LayoutConstants = require('../../../../constants/LayoutConstants.js');
31
31
  var Button = require('../../../Button/Button.js');
32
+ var cardUtilityFunctions = require('../../../../utils/cardUtilityFunctions.js');
32
33
  var ThresholdsFormItem = require('./ThresholdsFormItem.js');
33
34
 
34
35
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -146,6 +147,9 @@ var propTypes = {
146
147
  primaryButtonLabelText: PropTypes__default["default"].string,
147
148
  secondaryButtonLabelText: PropTypes__default["default"].string
148
149
  }),
150
+
151
+ /** whether to use translated labels in cards */
152
+ shouldUseTranslatedLabels: PropTypes__default["default"].bool,
149
153
  actions: editorUtils.DashboardEditorActionsPropTypes,
150
154
 
151
155
  /**
@@ -200,6 +204,7 @@ var defaultProps = {
200
204
  secondaryButtonLabelText: 'Cancel',
201
205
  decimalPlacesLabel: 'Decimal places'
202
206
  },
207
+ shouldUseTranslatedLabels: false,
203
208
  editDataSeries: [],
204
209
  showEditor: false,
205
210
  setShowEditor: null,
@@ -282,6 +287,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
282
287
  availableDimensions = _ref.availableDimensions,
283
288
  onChange = _ref.onChange,
284
289
  i18n = _ref.i18n,
290
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
285
291
  isLarge = _ref.isLarge,
286
292
  testId = _ref.testId,
287
293
  _ref$actions$dataSeri = _ref.actions.dataSeriesFormActions,
@@ -452,7 +458,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
452
458
  label: evt.target.value
453
459
  }));
454
460
  },
455
- value: editDataItem.label,
461
+ value: cardUtilityFunctions.getTranslatedLabel(editDataItem.label, shouldUseTranslatedLabels, i18n),
456
462
  helperText: mergedI18n.dataItemEditorDataItemHelperText(mergedI18n.dataItemSource, editDataItem.dataItemId)
457
463
  })), hasColorDropdown &&
458
464
  /*#__PURE__*/
@@ -499,7 +505,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
499
505
  unit: evt.target.value
500
506
  }));
501
507
  },
502
- value: editDataItem.unit
508
+ value: cardUtilityFunctions.getTranslatedLabel(editDataItem.unit, shouldUseTranslatedLabels, i18n)
503
509
  })), hasDecimalPlacesDropdown && /*#__PURE__*/React__default["default"].createElement("div", {
504
510
  className: "".concat(baseClassName, "--input-group--item-end")
505
511
  }, /*#__PURE__*/React__default["default"].createElement(carbonComponentsReact.Dropdown, {
@@ -586,7 +592,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
586
592
  },
587
593
  columnType: editDataItem.columnType || editDataItem.type
588
594
  }));
589
- }, [availableDimensions, availableGrains, baseClassName, cardConfig, editDataItem, handleTranslation, hasAggregationsDropDown, hasColorDropdown, hasDataFilterDropdown, hasDecimalPlacesDropdown, hasThresholds, hasTooltip, hasUnit, id, initialAggregation, initialGrain, isSummaryDashboard, isTimeBasedCard, mergedI18n, onAddAggregations, selectedDimensionFilter, setEditDataItem, testId, type]);
595
+ }, [availableDimensions, availableGrains, baseClassName, cardConfig, editDataItem, handleTranslation, hasAggregationsDropDown, hasColorDropdown, hasDataFilterDropdown, hasDecimalPlacesDropdown, hasThresholds, hasTooltip, hasUnit, i18n, id, initialAggregation, initialGrain, isSummaryDashboard, isTimeBasedCard, mergedI18n, onAddAggregations, selectedDimensionFilter, setEditDataItem, shouldUseTranslatedLabels, testId, type]);
590
596
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, showEditor && /*#__PURE__*/React__default["default"].createElement("div", {
591
597
  className: "".concat(baseClassName, "--modal-wrapper")
592
598
  }, /*#__PURE__*/React__default["default"].createElement(ComposedModal["default"], {
@@ -816,6 +822,17 @@ DataSeriesFormItemModal.__docgenInfo = {
816
822
  "required": false,
817
823
  "description": ""
818
824
  },
825
+ "shouldUseTranslatedLabels": {
826
+ "defaultValue": {
827
+ "value": "false",
828
+ "computed": false
829
+ },
830
+ "type": {
831
+ "name": "bool"
832
+ },
833
+ "required": false,
834
+ "description": "whether to use translated labels in cards"
835
+ },
819
836
  "editDataSeries": {
820
837
  "defaultValue": {
821
838
  "value": "[]",
@@ -33,6 +33,7 @@ var ComboBox = require('../../../../ComboBox/ComboBox.js');
33
33
  var DataSeriesFormItemModal = require('../DataSeriesFormItemModal.js');
34
34
  var LayoutConstants = require('../../../../../constants/LayoutConstants.js');
35
35
  var ContentFormItemTitle = require('../ContentFormItemTitle.js');
36
+ var cardUtilityFunctions = require('../../../../../utils/cardUtilityFunctions.js');
36
37
  var BarChartDataSeriesContent = require('./BarChartDataSeriesContent.js');
37
38
  var carbonComponentsReact = require('carbon-components-react');
38
39
 
@@ -141,6 +142,9 @@ var propTypes = {
141
142
  incrementNumberText: PropTypes__default["default"].string,
142
143
  decrementNumberText: PropTypes__default["default"].string
143
144
  }),
145
+
146
+ /** whether to use translated labels in cards */
147
+ shouldUseTranslatedLabels: PropTypes__default["default"].bool,
144
148
  translateWithId: PropTypes__default["default"].func.isRequired,
145
149
  actions: editorUtils.DashboardEditorActionsPropTypes
146
150
  };
@@ -174,6 +178,7 @@ var defaultProps = {
174
178
  incrementNumberText: 'Increment number',
175
179
  decrementNumberText: 'Decrement number'
176
180
  },
181
+ shouldUseTranslatedLabels: false,
177
182
  getValidDataItems: null,
178
183
  dataItems: [],
179
184
  selectedDataItems: [],
@@ -275,6 +280,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
275
280
  selectedTimeRange = _ref2.selectedTimeRange,
276
281
  availableDimensions = _ref2.availableDimensions,
277
282
  i18n = _ref2.i18n,
283
+ shouldUseTranslatedLabels = _ref2.shouldUseTranslatedLabels,
278
284
  dataSeriesItemLinks = _ref2.dataSeriesItemLinks,
279
285
  translateWithId = _ref2.translateWithId,
280
286
  actions = _ref2.actions;
@@ -416,7 +422,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
416
422
  return {
417
423
  id: dataItem.dataSourceId,
418
424
  content: {
419
- value: dataItem.label || dataItem.dataItemId,
425
+ value: cardUtilityFunctions.getTranslatedLabel(dataItem.label || dataItem.dataItemId, shouldUseTranslatedLabels, i18n),
420
426
  icon: cardConfig.type === LayoutConstants.CARD_TYPES.TIMESERIES || cardConfig.type === LayoutConstants.CARD_TYPES.BAR ? /*#__PURE__*/React__default["default"].createElement("div", {
421
427
  className: "".concat(baseClassName, "--data-item-list--item-color-icon"),
422
428
  style: {
@@ -453,7 +459,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
453
459
  }
454
460
  };
455
461
  });
456
- }, [cardConfig.type, dataSection, handleEditButton, handleRemoveButton, mergedI18n.edit, mergedI18n.remove]);
462
+ }, [cardConfig.type, dataSection, handleEditButton, handleRemoveButton, i18n, mergedI18n.edit, mergedI18n.remove, shouldUseTranslatedLabels]);
457
463
  return !isEmpty(validDataItems) ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(DataSeriesFormItemModal, {
458
464
  cardConfig: cardConfig,
459
465
  isSummaryDashboard: isSummaryDashboard,
@@ -468,6 +474,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
468
474
  dataSection: dataSection,
469
475
  onChange: _onChange,
470
476
  i18n: mergedI18n,
477
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
471
478
  actions: actions,
472
479
  options: {
473
480
  hasColorDropdown: type === LayoutConstants.CARD_TYPES.TIMESERIES || type === LayoutConstants.CARD_TYPES.BAR,
@@ -780,6 +787,17 @@ DataSeriesFormItem.__docgenInfo = {
780
787
  "required": false,
781
788
  "description": ""
782
789
  },
790
+ "shouldUseTranslatedLabels": {
791
+ "defaultValue": {
792
+ "value": "false",
793
+ "computed": false
794
+ },
795
+ "type": {
796
+ "name": "bool"
797
+ },
798
+ "required": false,
799
+ "description": "whether to use translated labels in cards"
800
+ },
783
801
  "getValidDataItems": {
784
802
  "defaultValue": {
785
803
  "value": "null",
@@ -19,6 +19,7 @@ var PropTypes = require('prop-types');
19
19
  var LayoutConstants = require('../../../constants/LayoutConstants.js');
20
20
  var Settings = require('../../../constants/Settings.js');
21
21
  var editorUtils = require('../../DashboardEditor/editorUtils.js');
22
+ var cardUtilityFunctions = require('../../../utils/cardUtilityFunctions.js');
22
23
  var carbonComponentsReact = require('carbon-components-react');
23
24
 
24
25
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -87,6 +88,9 @@ var propTypes = {
87
88
  thisYearLabel: PropTypes__default["default"].string
88
89
  }),
89
90
 
91
+ /** whether to use translated labels in cards */
92
+ shouldUseTranslatedLabels: PropTypes__default["default"].bool,
93
+
90
94
  /** if provided, returns an array of strings which are the timeRanges to be allowed
91
95
  * on each card
92
96
  * getValidTimeRanges(card, selectedDataItems)
@@ -121,6 +125,7 @@ var defaultProps = {
121
125
  thisQuarterLabel: 'This quarter',
122
126
  thisYearLabel: 'This year'
123
127
  },
128
+ shouldUseTranslatedLabels: false,
124
129
  selectedDataItems: [],
125
130
  getValidTimeRanges: null,
126
131
  currentBreakpoint: 'xl',
@@ -146,6 +151,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
146
151
  var cardConfig = _ref.cardConfig,
147
152
  _onChange = _ref.onChange,
148
153
  i18n = _ref.i18n,
154
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
149
155
  getValidTimeRanges = _ref.getValidTimeRanges,
150
156
  currentBreakpoint = _ref.currentBreakpoint,
151
157
  selectedDataItems = _ref.selectedDataItems,
@@ -178,7 +184,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
178
184
  title: evt.target.value
179
185
  }));
180
186
  },
181
- value: title
187
+ value: cardUtilityFunctions.getTranslatedLabel(title, shouldUseTranslatedLabels, mergedI18n)
182
188
  })), /*#__PURE__*/React__default["default"].createElement("div", {
183
189
  className: "".concat(baseClassName, "--input")
184
190
  }, /*#__PURE__*/React__default["default"].createElement(carbonComponentsReact.TextArea, {
@@ -190,7 +196,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
190
196
  description: evt.target.value
191
197
  }));
192
198
  },
193
- value: description
199
+ value: cardUtilityFunctions.getTranslatedLabel(description, shouldUseTranslatedLabels, mergedI18n)
194
200
  })), /*#__PURE__*/React__default["default"].createElement("div", {
195
201
  className: "".concat(baseClassName, "--input")
196
202
  }, /*#__PURE__*/React__default["default"].createElement(carbonComponentsReact.Dropdown, {
@@ -473,6 +479,17 @@ CommonCardEditFormFields.__docgenInfo = {
473
479
  "required": false,
474
480
  "description": ""
475
481
  },
482
+ "shouldUseTranslatedLabels": {
483
+ "defaultValue": {
484
+ "value": "false",
485
+ "computed": false
486
+ },
487
+ "type": {
488
+ "name": "bool"
489
+ },
490
+ "required": false,
491
+ "description": "whether to use translated labels in cards"
492
+ },
476
493
  "selectedDataItems": {
477
494
  "defaultValue": {
478
495
  "value": "[]",
@@ -167,6 +167,9 @@ var propTypes = {
167
167
  searchPlaceHolderText: PropTypes__default["default"].string,
168
168
  editDataItems: PropTypes__default["default"].string
169
169
  }),
170
+
171
+ /** whether to use translated labels in cards */
172
+ shouldUseTranslatedLabels: PropTypes__default["default"].bool,
170
173
  currentBreakpoint: PropTypes__default["default"].string,
171
174
  isSummaryDashboard: PropTypes__default["default"].bool,
172
175
 
@@ -202,6 +205,7 @@ var defaultProps = {
202
205
  modalHelpText: 'The JSON definition for this card is provided below. You can modify this data directly to update the card configuration.',
203
206
  modalIconDescription: 'Close'
204
207
  },
208
+ shouldUseTranslatedLabels: false,
205
209
  getValidDimensions: null,
206
210
  getValidDataItems: null,
207
211
  getValidTimeRanges: null,
@@ -367,6 +371,7 @@ var CardEditor = function CardEditor(_ref) {
367
371
  onRenderCardEditForm = _ref.onRenderCardEditForm,
368
372
  icons = _ref.icons,
369
373
  i18n = _ref.i18n,
374
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
370
375
  currentBreakpoint = _ref.currentBreakpoint,
371
376
  testId = _ref.testId,
372
377
  dataSeriesItemLinks = _ref.dataSeriesItemLinks,
@@ -435,6 +440,7 @@ var CardEditor = function CardEditor(_ref) {
435
440
  getValidTimeRanges: getValidTimeRanges,
436
441
  availableDimensions: availableDimensions,
437
442
  i18n: mergedI18n,
443
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
438
444
  currentBreakpoint: currentBreakpoint,
439
445
  dataSeriesItemLinks: dataSeriesItemLinks,
440
446
  onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
@@ -601,6 +607,17 @@ CardEditor.__docgenInfo = {
601
607
  "required": false,
602
608
  "description": "i18n must include the label for each `supportedCardTypes`\nex:\n[\n TIMESERIES: 'ITEM 1',\n ALERT: 'ITEM 8',\n CUSTOM: 'ITEM 10',\n COOL_NEW_CARD: 'Missing Icon',\n]"
603
609
  },
610
+ "shouldUseTranslatedLabels": {
611
+ "defaultValue": {
612
+ "value": "false",
613
+ "computed": false
614
+ },
615
+ "type": {
616
+ "name": "bool"
617
+ },
618
+ "required": false,
619
+ "description": "whether to use translated labels in cards"
620
+ },
604
621
  "getValidDimensions": {
605
622
  "defaultValue": {
606
623
  "value": "null",