carbon-addons-iot-react 4.3.6 → 4.4.0

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 +18 -5
  2. package/es/components/CardEditor/CardEditForm/CardEditForm.js +16 -0
  3. package/es/components/CardEditor/CardEditForm/CardEditFormContent.js +17 -0
  4. package/es/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItemModal.js +18 -3
  5. package/es/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItems/DataSeriesFormContent.js +19 -2
  6. package/es/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +17 -1
  7. package/es/components/CardEditor/CardEditor.js +16 -0
  8. package/es/components/DashboardEditor/DashboardEditor.js +19 -1
  9. package/es/components/DashboardEditor/DashboardEditorCardRenderer.js +4 -2
  10. package/es/components/ValueCard/Attribute.js +38 -2
  11. package/es/components/ValueCard/ValueCard.js +15 -3
  12. package/es/components/ValueCard/ValueContent.js +19 -2
  13. package/es/constants/CardPropTypes.js +2 -0
  14. package/es/utils/cardUtilityFunctions.js +16 -1
  15. package/lib/components/Card/Card.js +17 -4
  16. package/lib/components/CardEditor/CardEditForm/CardEditForm.js +16 -0
  17. package/lib/components/CardEditor/CardEditForm/CardEditFormContent.js +17 -0
  18. package/lib/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItemModal.js +17 -2
  19. package/lib/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItems/DataSeriesFormContent.js +19 -2
  20. package/lib/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +17 -1
  21. package/lib/components/CardEditor/CardEditor.js +16 -0
  22. package/lib/components/DashboardEditor/DashboardEditor.js +19 -1
  23. package/lib/components/DashboardEditor/DashboardEditorCardRenderer.js +4 -2
  24. package/lib/components/ValueCard/Attribute.js +38 -2
  25. package/lib/components/ValueCard/ValueCard.js +15 -3
  26. package/lib/components/ValueCard/ValueContent.js +19 -2
  27. package/lib/constants/CardPropTypes.js +2 -0
  28. package/lib/utils/cardUtilityFunctions.js +16 -0
  29. package/package.json +1 -1
  30. package/umd/carbon-addons-iot-react.js +226 -19
@@ -20,7 +20,7 @@ import { getUpdatedCardSize, getResizeHandles, handleCardVariables } from '../..
20
20
  import { determineLayout, BASE_CLASS_NAME, DEFAULT_FONT_SIZE } from './valueCardUtils.js';
21
21
  import ValueContent from './ValueContent.js';
22
22
 
23
- var _excluded = ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "customFormatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "className"];
23
+ var _excluded = ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "customFormatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "className", "shouldUseTranslatedLabels"];
24
24
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
25
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
26
26
 
@@ -49,6 +49,7 @@ var ValueCard = function ValueCard(_ref) {
49
49
  testId = _ref.testId,
50
50
  onAttributeClick = _ref.onAttributeClick,
51
51
  className = _ref.className,
52
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
52
53
  others = _objectWithoutProperties(_ref, _excluded);
53
54
  var availableActions = _objectSpread({
54
55
  expand: false
@@ -73,6 +74,7 @@ var ValueCard = function ValueCard(_ref) {
73
74
  isResizable: isResizable,
74
75
  resizeHandles: resizeHandles,
75
76
  i18n: i18n,
77
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
76
78
  locale: locale,
77
79
  id: id,
78
80
  className: classnames(className, _defineProperty(_defineProperty({}, "".concat(BASE_CLASS_NAME, "__horizontal"), layout === CARD_LAYOUTS.HORIZONTAL), "".concat(BASE_CLASS_NAME, "__vertical"), layout === CARD_LAYOUTS.VERTICAL))
@@ -93,7 +95,9 @@ var ValueCard = function ValueCard(_ref) {
93
95
  values: values,
94
96
  isEditable: isEditable,
95
97
  fontSize: fontSize,
96
- isNumberValueCompact: isNumberValueCompact
98
+ isNumberValueCompact: isNumberValueCompact,
99
+ i18n: i18n,
100
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels
97
101
  }, others)), resizeHandles);
98
102
  };
99
103
  ValueCard.propTypes = _objectSpread(_objectSpread({}, CardPropTypes), ValueContentPropTypes);
@@ -109,7 +113,8 @@ ValueCard.defaultProps = {
109
113
  isNumberValueCompact: false,
110
114
  // TODO: fix this default in V3, so that cards are unique not inherited from the base Card
111
115
  testId: 'Card',
112
- onAttributeClick: null
116
+ onAttributeClick: null,
117
+ shouldUseTranslatedLabels: false
113
118
  };
114
119
  ValueCard.__docgenInfo = {
115
120
  "description": "This components responsibilities include:\nRendering the attribute groups\nDetermining the layout\ndetermines the data to render",
@@ -185,6 +190,13 @@ ValueCard.__docgenInfo = {
185
190
  "computed": false
186
191
  },
187
192
  "required": false
193
+ },
194
+ "shouldUseTranslatedLabels": {
195
+ "defaultValue": {
196
+ "value": "false",
197
+ "computed": false
198
+ },
199
+ "required": false
188
200
  }
189
201
  },
190
202
  "composes": ["../../constants/CardPropTypes"]
@@ -20,7 +20,7 @@ import DataStateRenderer from '../Card/DataStateRenderer.js';
20
20
  import { DEFAULT_FONT_SIZE, BASE_CLASS_NAME, determineValue } from './valueCardUtils.js';
21
21
  import Attribute from './Attribute.js';
22
22
 
23
- var _excluded = ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "customFormatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"];
23
+ var _excluded = ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "shouldUseTranslatedLabels", "customFormatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"];
24
24
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
25
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
26
26
  var propTypes = _objectSpread({
@@ -28,7 +28,9 @@ var propTypes = _objectSpread({
28
28
  title: PropTypes.string,
29
29
  layout: PropTypes.oneOf(['HORIZONTAL', 'VERTICAL']),
30
30
  locale: PropTypes.string,
31
- isEditable: PropTypes.bool
31
+ isEditable: PropTypes.bool,
32
+ /** whether to use translated labels in cards */
33
+ shouldUseTranslatedLabels: PropTypes.bool
32
34
  }, ValueContentPropTypes);
33
35
  var defaultProps = {
34
36
  id: 'valueContent-id',
@@ -36,6 +38,7 @@ var defaultProps = {
36
38
  layout: 'VERTICAL',
37
39
  locale: 'en',
38
40
  isEditable: false,
41
+ shouldUseTranslatedLabels: false,
39
42
  dataState: null,
40
43
  values: null,
41
44
  fontSize: DEFAULT_FONT_SIZE,
@@ -54,6 +57,7 @@ var ValueContent = function ValueContent(_ref) {
54
57
  dataState = _ref.dataState,
55
58
  locale = _ref.locale,
56
59
  isEditable = _ref.isEditable,
60
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
57
61
  customFormatter = _ref.customFormatter,
58
62
  fontSize = _ref.fontSize,
59
63
  isNumberValueCompact = _ref.isNumberValueCompact,
@@ -73,6 +77,8 @@ var ValueContent = function ValueContent(_ref) {
73
77
  locale: locale,
74
78
  isEditable: isEditable,
75
79
  title: title,
80
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
81
+ i18n: others.i18n,
76
82
  renderIconByName: others.renderIconByName,
77
83
  value: determineValue(attribute.dataSourceId, values, attribute.dataFilter),
78
84
  secondaryValue: attribute.secondaryValue && _objectSpread(_objectSpread({}, attribute.secondaryValue), {}, {
@@ -160,6 +166,17 @@ ValueContent.__docgenInfo = {
160
166
  },
161
167
  "required": false
162
168
  },
169
+ "shouldUseTranslatedLabels": {
170
+ "defaultValue": {
171
+ "value": "false",
172
+ "computed": false
173
+ },
174
+ "description": "whether to use translated labels in cards",
175
+ "type": {
176
+ "name": "bool"
177
+ },
178
+ "required": false
179
+ },
163
180
  "dataState": {
164
181
  "defaultValue": {
165
182
  "value": "null",
@@ -165,6 +165,8 @@ var TableCardPropTypes = {
165
165
  defaultFilterStringPlaceholdText: PropTypes.string,
166
166
  downloadIconDescription: PropTypes.string
167
167
  }),
168
+ /** whether to use translated labels in cards */
169
+ shouldUseTranslatedLabels: PropTypes.bool,
168
170
  cardVariables: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.number, PropTypes.bool])),
169
171
  /** default date format pattern that follows the dayjs formatting patterns */
170
172
  defaultDateFormatPattern: PropTypes.string
@@ -4,6 +4,7 @@ import _typeof from '@babel/runtime/helpers/typeof';
4
4
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
5
5
  import mapValues from '../packages/react/node_modules/lodash-es/mapValues.js';
6
6
  import isNil from '../packages/react/node_modules/lodash-es/isNil.js';
7
+ import isEmpty from '../packages/react/node_modules/lodash-es/isEmpty.js';
7
8
  import 'core-js/modules/es.symbol.js';
8
9
  import 'core-js/modules/es.array.concat.js';
9
10
  import 'core-js/modules/es.array.filter.js';
@@ -573,4 +574,18 @@ var isTimeBasedCard = function isTimeBasedCard(card) {
573
574
  })) || ((_card$content2 = card.content) === null || _card$content2 === void 0 ? void 0 : _card$content2.type) === BAR_CHART_TYPES.SIMPLE && ((_card$content3 = card.content) === null || _card$content3 === void 0 ? void 0 : _card$content3.timeDataSourceId) || ((_card$content4 = card.content) === null || _card$content4 === void 0 ? void 0 : _card$content4.type) === BAR_CHART_TYPES.STACKED && ((_card$content5 = card.content) === null || _card$content5 === void 0 ? void 0 : _card$content5.timeDataSourceId);
574
575
  };
575
576
 
576
- export { chartValueFormatter, compareGrains, determineCardRange, determinePrecision, fetchDataURL, findMatchingAlertRange, findMatchingThresholds, formatNumberWithPrecision, getCardVariables, getResizeHandles, getUpdatedCardSize, getVariables, handleCardVariables, handleTooltip, increaseSmallCardSize, isTimeBasedCard, replaceVariables, useCardResizing };
577
+ /**
578
+ * Get translated label or title from i18n object, fallback to original if not found
579
+ * @param {string} label - The label or title key to translate
580
+ * @param {boolean} shouldUseTranslatedLabels - Flag to determine if translation should be used
581
+ * @param {Object} i18n - The i18n object containing translations
582
+ * @returns {string} - The translated label or original label if translation not found
583
+ */
584
+ var getTranslatedLabel = function getTranslatedLabel(label, shouldUseTranslatedLabels, i18n) {
585
+ if (!isEmpty(label) && shouldUseTranslatedLabels && i18n && i18n[label]) {
586
+ return i18n[label];
587
+ }
588
+ return label;
589
+ };
590
+
591
+ export { chartValueFormatter, compareGrains, determineCardRange, determinePrecision, fetchDataURL, findMatchingAlertRange, findMatchingThresholds, formatNumberWithPrecision, getCardVariables, getResizeHandles, getTranslatedLabel, getUpdatedCardSize, getVariables, handleCardVariables, handleTooltip, increaseSmallCardSize, isTimeBasedCard, replaceVariables, useCardResizing };
@@ -51,7 +51,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
51
51
  var warning__default = /*#__PURE__*/_interopDefault(warning);
52
52
 
53
53
  var _excluded = ["isSelected", "children", "dimensions", "id", "style", "className", "onScroll", "onMouseDown", "onMouseUp", "onTouchEnd", "onTouchStart", "onFocus", "onBlur", "tabIndex", "testID", "testId"],
54
- _excluded2 = ["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"];
54
+ _excluded2 = ["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"];
55
55
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
56
56
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
57
57
  var prefix = Settings.settings.prefix,
@@ -267,7 +267,8 @@ var defaultProps = {
267
267
  overrides: undefined,
268
268
  type: null,
269
269
  data: null,
270
- content: null
270
+ content: null,
271
+ shouldUseTranslatedLabels: false
271
272
  };
272
273
 
273
274
  /** Dumb component that renders the card basics */
@@ -275,7 +276,7 @@ var Card = function Card(props) {
275
276
  var _overrides$errorMessa, _overrides$errorMessa2, _overrides$errorMessa3;
276
277
  var size = props.size,
277
278
  children = props.children,
278
- title = props.title,
279
+ titleProp = props.title,
279
280
  subtitleProp = props.subtitle,
280
281
  hasTitleWrap = props.hasTitleWrap;
281
282
  props.layout;
@@ -289,7 +290,7 @@ var Card = function Card(props) {
289
290
  error = props.error,
290
291
  hideHeader = props.hideHeader,
291
292
  id = props.id,
292
- tooltip = props.tooltip,
293
+ tooltipProp = props.tooltip,
293
294
  titleTextTooltip = props.titleTextTooltip,
294
295
  timeRange = props.timeRange,
295
296
  timeRangeOptions = props.timeRangeOptions,
@@ -313,8 +314,13 @@ var Card = function Card(props) {
313
314
  type = props.type,
314
315
  data = props.data,
315
316
  content = props.content,
317
+ shouldUseTranslatedLabels = props.shouldUseTranslatedLabels,
316
318
  others = _objectWithoutProperties__default.default(props, _excluded2);
317
319
 
320
+ // Get translated title if shouldUseTranslatedLabels is true
321
+ var title = cardUtilityFunctions.getTranslatedLabel(titleProp, shouldUseTranslatedLabels, i18n);
322
+ var tooltip = cardUtilityFunctions.getTranslatedLabel(tooltipProp, shouldUseTranslatedLabels, i18n);
323
+
318
324
  // TODO: remove once final version of range prop is supported
319
325
  React.useEffect(function () {
320
326
  if (typeof (availableActions === null || availableActions === void 0 ? void 0 : availableActions.range) === 'string') {
@@ -802,6 +808,13 @@ Card.__docgenInfo = {
802
808
  "computed": false
803
809
  },
804
810
  "required": false
811
+ },
812
+ "shouldUseTranslatedLabels": {
813
+ "defaultValue": {
814
+ "value": "false",
815
+ "computed": false
816
+ },
817
+ "required": false
805
818
  }
806
819
  },
807
820
  "composes": ["../../constants/CardPropTypes"]
@@ -59,6 +59,8 @@ var propTypes = {
59
59
  modalHelpText: PropTypes__default.default.string,
60
60
  modalIconDescription: PropTypes__default.default.string
61
61
  }),
62
+ /** whether to use translated labels in cards */
63
+ shouldUseTranslatedLabels: PropTypes__default.default.bool,
62
64
  /** if provided, returns an array of strings which are the dataItems to be allowed
63
65
  * on each card
64
66
  * getValidDataItems(card, selectedTimeRange)
@@ -120,6 +122,7 @@ var defaultProps = {
120
122
  modalHelpText: 'The JSON definition for this card is provided below. You can modify this data directly to update the card configuration.',
121
123
  modalIconDescription: 'Close'
122
124
  },
125
+ shouldUseTranslatedLabels: false,
123
126
  getValidDataItems: null,
124
127
  getValidTimeRanges: null,
125
128
  dataItems: [],
@@ -141,6 +144,7 @@ var CardEditForm = function CardEditForm(_ref) {
141
144
  availableDimensions = _ref.availableDimensions,
142
145
  dataSeriesItemLinks = _ref.dataSeriesItemLinks,
143
146
  onFetchDynamicDemoHotspots = _ref.onFetchDynamicDemoHotspots,
147
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
144
148
  actions = _ref.actions;
145
149
  var mergedI18n = React.useMemo(function () {
146
150
  return _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
@@ -157,6 +161,7 @@ var CardEditForm = function CardEditForm(_ref) {
157
161
  onChange: onChange,
158
162
  isSummaryDashboard: isSummaryDashboard,
159
163
  i18n: mergedI18n,
164
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
160
165
  dataItems: dataItems,
161
166
  availableDimensions: availableDimensions,
162
167
  getValidDataItems: getValidDataItems,
@@ -304,6 +309,17 @@ CardEditForm.__docgenInfo = {
304
309
  },
305
310
  "required": false
306
311
  },
312
+ "shouldUseTranslatedLabels": {
313
+ "defaultValue": {
314
+ "value": "false",
315
+ "computed": false
316
+ },
317
+ "description": "whether to use translated labels in cards",
318
+ "type": {
319
+ "name": "bool"
320
+ },
321
+ "required": false
322
+ },
307
323
  "getValidDataItems": {
308
324
  "defaultValue": {
309
325
  "value": "null",
@@ -89,6 +89,8 @@ var propTypes = {
89
89
  thisQuarterLabel: PropTypes__default.default.string,
90
90
  thisYearLabel: PropTypes__default.default.string
91
91
  }),
92
+ /** whether to use translated labels in cards */
93
+ shouldUseTranslatedLabels: PropTypes__default.default.bool,
92
94
  /** if provided, returns an array of strings which are the timeRanges to be allowed
93
95
  * on each card
94
96
  * getValidTimeRanges(card, selectedDataItems)
@@ -125,6 +127,7 @@ var propTypes = {
125
127
  var defaultProps = {
126
128
  cardConfig: {},
127
129
  i18n: {},
130
+ shouldUseTranslatedLabels: false,
128
131
  getValidDataItems: null,
129
132
  getValidTimeRanges: null,
130
133
  dataItems: [],
@@ -154,6 +157,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
154
157
  isSummaryDashboard = _ref.isSummaryDashboard,
155
158
  onChange = _ref.onChange,
156
159
  i18n = _ref.i18n,
160
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
157
161
  dataItems = _ref.dataItems,
158
162
  getValidDataItems = _ref.getValidDataItems,
159
163
  getValidTimeRanges = _ref.getValidTimeRanges,
@@ -188,6 +192,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
188
192
  ,
189
193
  onChange: onChange,
190
194
  i18n: mergedI18n,
195
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
191
196
  getValidTimeRanges: getValidTimeRanges,
192
197
  currentBreakpoint: currentBreakpoint,
193
198
  selectedDataItems: selectedDataItems,
@@ -234,6 +239,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
234
239
  getValidDataItems: getValidDataItems,
235
240
  availableDimensions: availableDimensions,
236
241
  i18n: mergedI18n,
242
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
237
243
  dataSeriesItemLinks: dataSeriesItemLinks,
238
244
  translateWithId: handleTranslation,
239
245
  actions: actions
@@ -472,6 +478,17 @@ CardEditFormContent.__docgenInfo = {
472
478
  },
473
479
  "required": false
474
480
  },
481
+ "shouldUseTranslatedLabels": {
482
+ "defaultValue": {
483
+ "value": "false",
484
+ "computed": false
485
+ },
486
+ "description": "whether to use translated labels in cards",
487
+ "type": {
488
+ "name": "bool"
489
+ },
490
+ "required": false
491
+ },
475
492
  "getValidDataItems": {
476
493
  "defaultValue": {
477
494
  "value": "null",
@@ -136,6 +136,8 @@ var propTypes = {
136
136
  primaryButtonLabelText: PropTypes__default.default.string,
137
137
  secondaryButtonLabelText: PropTypes__default.default.string
138
138
  }),
139
+ /** whether to use translated labels in cards */
140
+ shouldUseTranslatedLabels: PropTypes__default.default.bool,
139
141
  actions: editorUtils.DashboardEditorActionsPropTypes,
140
142
  /**
141
143
  * Used to override the default behaviour of handleDataItemEdit. if we dont pass any function then it uses handleDefaultDataItemEdit function by default
@@ -189,6 +191,7 @@ var defaultProps = {
189
191
  secondaryButtonLabelText: 'Cancel',
190
192
  decimalPlacesLabel: 'Decimal places'
191
193
  },
194
+ shouldUseTranslatedLabels: false,
192
195
  editDataSeries: [],
193
196
  showEditor: false,
194
197
  setShowEditor: null,
@@ -259,6 +262,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
259
262
  availableDimensions = _ref.availableDimensions,
260
263
  onChange = _ref.onChange,
261
264
  i18n = _ref.i18n,
265
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
262
266
  isLarge = _ref.isLarge,
263
267
  _ref$actions$dataSeri = _ref.actions.dataSeriesFormActions,
264
268
  hasAggregationsDropDown = _ref$actions$dataSeri.hasAggregationsDropDown,
@@ -415,7 +419,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
415
419
  label: evt.target.value
416
420
  }));
417
421
  },
418
- value: editDataItem.label,
422
+ value: cardUtilityFunctions.getTranslatedLabel(editDataItem.label, shouldUseTranslatedLabels, i18n),
419
423
  helperText: mergedI18n.dataItemEditorDataItemHelperText(mergedI18n.dataItemSource, editDataItem.dataItemId)
420
424
  })), hasColorDropdown &&
421
425
  /*#__PURE__*/
@@ -560,7 +564,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
560
564
  },
561
565
  columnType: editDataItem.columnType || editDataItem.type
562
566
  }));
563
- }, [availableDimensions, availableDimensionsItems, availableGrains, baseClassName, cardConfig, editDataItem, handleTranslation, hasAggregationsDropDown, hasColorDropdown, hasDataFilterDropdown, hasDecimalPlacesDropdown, hasGrainsDropDown, hasThresholds, hasTooltip, hasUnit, id, initialAggregation, initialGrain, isSummaryDashboard, isTimeBasedCard, mergedI18n, selectedDimensionFilter, setEditDataItem, type]);
567
+ }, [availableDimensions, availableDimensionsItems, availableGrains, baseClassName, cardConfig, editDataItem, handleTranslation, hasAggregationsDropDown, hasColorDropdown, hasDataFilterDropdown, hasDecimalPlacesDropdown, hasGrainsDropDown, hasThresholds, hasTooltip, hasUnit, i18n, id, initialAggregation, initialGrain, isSummaryDashboard, isTimeBasedCard, mergedI18n, selectedDimensionFilter, setEditDataItem, shouldUseTranslatedLabels, type]);
564
568
  return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, showEditor && /*#__PURE__*/React__default.default.createElement("div", {
565
569
  className: "".concat(baseClassName, "--modal-wrapper")
566
570
  }, /*#__PURE__*/React__default.default.createElement(ComposedModal.default, {
@@ -790,6 +794,17 @@ DataSeriesFormItemModal.__docgenInfo = {
790
794
  },
791
795
  "required": false
792
796
  },
797
+ "shouldUseTranslatedLabels": {
798
+ "defaultValue": {
799
+ "value": "false",
800
+ "computed": false
801
+ },
802
+ "description": "whether to use translated labels in cards",
803
+ "type": {
804
+ "name": "bool"
805
+ },
806
+ "required": false
807
+ },
793
808
  "editDataSeries": {
794
809
  "defaultValue": {
795
810
  "value": "[]",
@@ -34,6 +34,7 @@ var DataSeriesFormItemModal = require('../DataSeriesFormItemModal.js');
34
34
  var LayoutConstants = require('../../../../../constants/LayoutConstants.js');
35
35
  var ContentFormItemTitle = require('../ContentFormItemTitle.js');
36
36
  var HierarchyDataFormItems = require('../HierarchyDataFormItems/HierarchyDataFormItems.js');
37
+ var cardUtilityFunctions = require('../../../../../utils/cardUtilityFunctions.js');
37
38
  var BarChartDataSeriesContent = require('./BarChartDataSeriesContent.js');
38
39
  var iconsReact = require('@carbon/icons-react');
39
40
 
@@ -132,6 +133,8 @@ var propTypes = {
132
133
  incrementNumberText: PropTypes__default.default.string,
133
134
  decrementNumberText: PropTypes__default.default.string
134
135
  }),
136
+ /** whether to use translated labels in cards */
137
+ shouldUseTranslatedLabels: PropTypes__default.default.bool,
135
138
  translateWithId: PropTypes__default.default.func.isRequired,
136
139
  actions: editorUtils.DashboardEditorActionsPropTypes
137
140
  };
@@ -165,6 +168,7 @@ var defaultProps = {
165
168
  incrementNumberText: 'Increment number',
166
169
  decrementNumberText: 'Decrement number'
167
170
  },
171
+ shouldUseTranslatedLabels: false,
168
172
  getValidDataItems: null,
169
173
  dataItems: [],
170
174
  selectedDataItems: [],
@@ -252,6 +256,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
252
256
  selectedTimeRange = _ref2.selectedTimeRange,
253
257
  availableDimensions = _ref2.availableDimensions,
254
258
  i18n = _ref2.i18n,
259
+ shouldUseTranslatedLabels = _ref2.shouldUseTranslatedLabels,
255
260
  dataSeriesItemLinks = _ref2.dataSeriesItemLinks,
256
261
  translateWithId = _ref2.translateWithId,
257
262
  actions = _ref2.actions;
@@ -397,7 +402,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
397
402
  return {
398
403
  id: dataItem.dataSourceId,
399
404
  content: {
400
- value: dataItem.label || dataItem.dataItemId,
405
+ value: cardUtilityFunctions.getTranslatedLabel(dataItem.label || dataItem.dataItemId, shouldUseTranslatedLabels, i18n),
401
406
  icon: cardConfig.type === LayoutConstants.CARD_TYPES.TIMESERIES || cardConfig.type === LayoutConstants.CARD_TYPES.BAR ? /*#__PURE__*/React__default.default.createElement("div", {
402
407
  className: "".concat(baseClassName, "--data-item-list--item-color-icon"),
403
408
  style: {
@@ -434,7 +439,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
434
439
  }
435
440
  };
436
441
  })) || [];
437
- }, [cardConfig.type, handleEditButton, handleRemoveButton, mergedI18n.edit, mergedI18n.remove]);
442
+ }, [cardConfig.type, handleEditButton, handleRemoveButton, i18n, mergedI18n.edit, mergedI18n.remove, shouldUseTranslatedLabels]);
438
443
  var dataItemListItems = React.useMemo(function () {
439
444
  return generateListItems(dataSection);
440
445
  }, [dataSection, generateListItems]);
@@ -455,6 +460,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
455
460
  dataSection: dataSection,
456
461
  onChange: _onChange,
457
462
  i18n: mergedI18n,
463
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
458
464
  actions: actions,
459
465
  options: {
460
466
  hasColorDropdown: type === LayoutConstants.CARD_TYPES.TIMESERIES || type === LayoutConstants.CARD_TYPES.BAR,
@@ -776,6 +782,17 @@ DataSeriesFormItem.__docgenInfo = {
776
782
  },
777
783
  "required": false
778
784
  },
785
+ "shouldUseTranslatedLabels": {
786
+ "defaultValue": {
787
+ "value": "false",
788
+ "computed": false
789
+ },
790
+ "description": "whether to use translated labels in cards",
791
+ "type": {
792
+ "name": "bool"
793
+ },
794
+ "required": false
795
+ },
779
796
  "getValidDataItems": {
780
797
  "defaultValue": {
781
798
  "value": "null",
@@ -21,6 +21,7 @@ var react = require('@carbon/react');
21
21
  var LayoutConstants = require('../../../constants/LayoutConstants.js');
22
22
  var Settings = require('../../../constants/Settings.js');
23
23
  var editorUtils = require('../../DashboardEditor/editorUtils.js');
24
+ var cardUtilityFunctions = require('../../../utils/cardUtilityFunctions.js');
24
25
 
25
26
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
26
27
 
@@ -85,6 +86,8 @@ var propTypes = {
85
86
  thisQuarterLabel: PropTypes__default.default.string,
86
87
  thisYearLabel: PropTypes__default.default.string
87
88
  }),
89
+ /** whether to use translated labels in cards */
90
+ shouldUseTranslatedLabels: PropTypes__default.default.bool,
88
91
  /** if provided, returns an array of strings which are the timeRanges to be allowed
89
92
  * on each card
90
93
  * getValidTimeRanges(card, selectedDataItems)
@@ -118,6 +121,7 @@ var defaultProps = {
118
121
  thisQuarterLabel: 'This quarter',
119
122
  thisYearLabel: 'This year'
120
123
  },
124
+ shouldUseTranslatedLabels: false,
121
125
  selectedDataItems: [],
122
126
  getValidTimeRanges: null,
123
127
  currentBreakpoint: 'xl',
@@ -141,6 +145,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
141
145
  var cardConfig = _ref.cardConfig,
142
146
  _onChange = _ref.onChange,
143
147
  i18n = _ref.i18n,
148
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
144
149
  getValidTimeRanges = _ref.getValidTimeRanges,
145
150
  currentBreakpoint = _ref.currentBreakpoint,
146
151
  selectedDataItems = _ref.selectedDataItems,
@@ -171,7 +176,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
171
176
  title: evt.target.value
172
177
  }));
173
178
  },
174
- value: title
179
+ value: cardUtilityFunctions.getTranslatedLabel(title, shouldUseTranslatedLabels, mergedI18n)
175
180
  })), /*#__PURE__*/React__default.default.createElement("div", {
176
181
  className: "".concat(baseClassName, "--input")
177
182
  }, /*#__PURE__*/React__default.default.createElement(react.TextArea, {
@@ -464,6 +469,17 @@ CommonCardEditFormFields.__docgenInfo = {
464
469
  },
465
470
  "required": false
466
471
  },
472
+ "shouldUseTranslatedLabels": {
473
+ "defaultValue": {
474
+ "value": "false",
475
+ "computed": false
476
+ },
477
+ "description": "whether to use translated labels in cards",
478
+ "type": {
479
+ "name": "bool"
480
+ },
481
+ "required": false
482
+ },
467
483
  "selectedDataItems": {
468
484
  "defaultValue": {
469
485
  "value": "[]",
@@ -149,6 +149,8 @@ var propTypes = {
149
149
  searchPlaceHolderText: PropTypes__default.default.string,
150
150
  editDataItems: PropTypes__default.default.string
151
151
  }),
152
+ /** whether to use translated labels in cards */
153
+ shouldUseTranslatedLabels: PropTypes__default.default.bool,
152
154
  currentBreakpoint: PropTypes__default.default.string,
153
155
  isSummaryDashboard: PropTypes__default.default.bool,
154
156
  /** Id that can be used for testing */
@@ -182,6 +184,7 @@ var defaultProps = {
182
184
  modalHelpText: 'The JSON definition for this card is provided below. You can modify this data directly to update the card configuration.',
183
185
  modalIconDescription: 'Close'
184
186
  },
187
+ shouldUseTranslatedLabels: false,
185
188
  getValidDimensions: null,
186
189
  getValidDataItems: null,
187
190
  getValidTimeRanges: null,
@@ -327,6 +330,7 @@ var CardEditor = function CardEditor(_ref) {
327
330
  onRenderCardEditForm = _ref.onRenderCardEditForm,
328
331
  icons = _ref.icons,
329
332
  i18n = _ref.i18n,
333
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
330
334
  currentBreakpoint = _ref.currentBreakpoint,
331
335
  testId = _ref.testId,
332
336
  dataSeriesItemLinks = _ref.dataSeriesItemLinks,
@@ -392,6 +396,7 @@ var CardEditor = function CardEditor(_ref) {
392
396
  getValidTimeRanges: getValidTimeRanges,
393
397
  availableDimensions: availableDimensions,
394
398
  i18n: mergedI18n,
399
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
395
400
  currentBreakpoint: currentBreakpoint,
396
401
  dataSeriesItemLinks: dataSeriesItemLinks,
397
402
  onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
@@ -557,6 +562,17 @@ CardEditor.__docgenInfo = {
557
562
  },
558
563
  "required": false
559
564
  },
565
+ "shouldUseTranslatedLabels": {
566
+ "defaultValue": {
567
+ "value": "false",
568
+ "computed": false
569
+ },
570
+ "description": "whether to use translated labels in cards",
571
+ "type": {
572
+ "name": "bool"
573
+ },
574
+ "required": false
575
+ },
560
576
  "getValidDimensions": {
561
577
  "defaultValue": {
562
578
  "value": "null",
@@ -29,6 +29,7 @@ var LayoutConstants = require('../../constants/LayoutConstants.js');
29
29
  var DashboardGrid = require('../Dashboard/DashboardGrid.js');
30
30
  var CardEditor = require('../CardEditor/CardEditor.js');
31
31
  var ImageGalleryModal = require('../ImageGalleryModal/ImageGalleryModal.js');
32
+ var cardUtilityFunctions = require('../../utils/cardUtilityFunctions.js');
32
33
  var DashboardEditorHeader = require('./DashboardEditorHeader/DashboardEditorHeader.js');
33
34
  var DashboardEditorCardRenderer = require('./DashboardEditorCardRenderer.js');
34
35
  var editorUtils = require('./editorUtils.js');
@@ -306,6 +307,8 @@ var propTypes = {
306
307
  abbreviateNumbersTooltip: PropTypes__default.default.string,
307
308
  editDataItems: PropTypes__default.default.string
308
309
  }),
310
+ /** whether to use translated labels in cards */
311
+ shouldUseTranslatedLabels: PropTypes__default.default.bool,
309
312
  /** locale data */
310
313
  locale: PropTypes__default.default.string,
311
314
  /** optional link href's for each card type that will appear in a tooltip */
@@ -396,6 +399,7 @@ var defaultProps = {
396
399
  saveTitleButton: 'Save title',
397
400
  editDataItems: 'Edit data items'
398
401
  },
402
+ shouldUseTranslatedLabels: false,
399
403
  locale: 'en',
400
404
  dataSeriesItemLinks: null,
401
405
  onFetchDynamicDemoHotspots: function onFetchDynamicDemoHotspots() {
@@ -465,6 +469,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
465
469
  isSummaryDashboard = _ref.isSummaryDashboard,
466
470
  isLoading = _ref.isLoading,
467
471
  i18n = _ref.i18n,
472
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
468
473
  locale = _ref.locale,
469
474
  dataSeriesItemLinks = _ref.dataSeriesItemLinks,
470
475
  isTitleEditable = _ref.isTitleEditable,
@@ -721,7 +726,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
721
726
  className: classnames__default.default("".concat(baseClassName, "--content"), _defineProperty__default.default({}, "".concat(baseClassName, "__overflow"), selectedBreakpointIndex !== LAYOUTS.FIT_TO_SCREEN.index)),
722
727
  ref: scrollContainerRef
723
728
  }, renderHeader ? renderHeader() : /*#__PURE__*/React__default.default.createElement(DashboardEditorHeader, {
724
- title: (dashboardJson === null || dashboardJson === void 0 ? void 0 : dashboardJson.title) || title,
729
+ title: cardUtilityFunctions.getTranslatedLabel(dashboardJson === null || dashboardJson === void 0 ? void 0 : dashboardJson.title, shouldUseTranslatedLabels, i18n) || title,
725
730
  breadcrumbs: headerBreadcrumbs,
726
731
  onImport: onImport,
727
732
  onExport: function onExport() {
@@ -805,6 +810,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
805
810
  key: cardConfig.id,
806
811
  isResizable: isCardResizable,
807
812
  i18n: mergedI18n,
813
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
808
814
  isSelected: isSelected,
809
815
  availableDimensions: availableDimensions,
810
816
  onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
@@ -849,6 +855,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
849
855
  getValidDimensions: getValidDimensions,
850
856
  availableDimensions: availableDimensions,
851
857
  i18n: mergedI18n,
858
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
852
859
  currentBreakpoint: currentBreakpoint,
853
860
  dataSeriesItemLinks: dataSeriesItemLinks,
854
861
  onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
@@ -1771,6 +1778,17 @@ DashboardEditor.__docgenInfo = {
1771
1778
  },
1772
1779
  "required": false
1773
1780
  },
1781
+ "shouldUseTranslatedLabels": {
1782
+ "defaultValue": {
1783
+ "value": "false",
1784
+ "computed": false
1785
+ },
1786
+ "description": "whether to use translated labels in cards",
1787
+ "type": {
1788
+ "name": "bool"
1789
+ },
1790
+ "required": false
1791
+ },
1774
1792
  "locale": {
1775
1793
  "defaultValue": {
1776
1794
  "value": "'en'",