carbon-addons-iot-react 2.155.13 → 2.156.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 +15 -4
  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 +19 -2
  5. package/es/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItems/DataSeriesFormContent.js +20 -2
  6. package/es/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +18 -1
  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 +39 -3
  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 +14 -3
  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 +19 -2
  19. package/lib/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItems/DataSeriesFormContent.js +20 -2
  20. package/lib/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +18 -1
  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 +39 -3
  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 +234 -19
@@ -26,7 +26,7 @@ import { settings } from '../../constants/Settings.js';
26
26
  import { CARD_SIZES, CARD_LAYOUTS, ROW_HEIGHT, DASHBOARD_SIZES, CARD_DIMENSIONS, DASHBOARD_BREAKPOINTS, DASHBOARD_COLUMNS, CARD_TYPES, CARD_CONTENT_PADDING, CARD_TITLE_HEIGHT } from '../../constants/LayoutConstants.js';
27
27
  import { CardPropTypes } from '../../constants/CardPropTypes.js';
28
28
  import { getCardMinSize, filterValidAttributes } from '../../utils/componentUtilityFunctions.js';
29
- import { getUpdatedCardSize, useCardResizing } from '../../utils/cardUtilityFunctions.js';
29
+ import { getTranslatedLabel, getUpdatedCardSize, useCardResizing } from '../../utils/cardUtilityFunctions.js';
30
30
  import { parseValue } from '../DateTimePicker/dateTimePickerUtils.js';
31
31
  import useSizeObserver from '../../hooks/useSizeObserver.js';
32
32
  import EmptyState from '../EmptyState/EmptyState.js';
@@ -263,7 +263,8 @@ var defaultProps = {
263
263
  overrides: undefined,
264
264
  type: null,
265
265
  data: null,
266
- content: null
266
+ content: null,
267
+ shouldUseTranslatedLabels: false
267
268
  };
268
269
  /** Dumb component that renders the card basics */
269
270
 
@@ -272,7 +273,7 @@ var Card = function Card(props) {
272
273
 
273
274
  var size = props.size,
274
275
  children = props.children,
275
- title = props.title,
276
+ titleProp = props.title,
276
277
  subtitleProp = props.subtitle,
277
278
  hasTitleWrap = props.hasTitleWrap;
278
279
  props.layout;
@@ -310,9 +311,12 @@ var Card = function Card(props) {
310
311
  type = props.type,
311
312
  data = props.data,
312
313
  content = props.content,
313
- others = _objectWithoutProperties(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
314
+ shouldUseTranslatedLabels = props.shouldUseTranslatedLabels,
315
+ others = _objectWithoutProperties(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
314
316
 
315
317
 
318
+ var title = getTranslatedLabel(titleProp, shouldUseTranslatedLabels, i18n); // TODO: remove once final version of range prop is supported
319
+
316
320
  useEffect(function () {
317
321
  if (typeof (availableActions === null || availableActions === void 0 ? void 0 : availableActions.range) === 'string') {
318
322
  warning(false, 'The Card components availableActions.range is an experimental property and may be subject to change.') ;
@@ -808,6 +812,13 @@ Card.__docgenInfo = {
808
812
  "computed": false
809
813
  },
810
814
  "required": false
815
+ },
816
+ "shouldUseTranslatedLabels": {
817
+ "defaultValue": {
818
+ "value": "false",
819
+ "computed": false
820
+ },
821
+ "required": false
811
822
  }
812
823
  },
813
824
  "composes": ["../../constants/CardPropTypes"]
@@ -57,6 +57,9 @@ var propTypes = {
57
57
  modalIconDescription: PropTypes.string
58
58
  }),
59
59
 
60
+ /** whether to use translated labels in cards */
61
+ shouldUseTranslatedLabels: PropTypes.bool,
62
+
60
63
  /** if provided, returns an array of strings which are the dataItems to be allowed
61
64
  * on each card
62
65
  * getValidDataItems(card, selectedTimeRange)
@@ -122,6 +125,7 @@ var defaultProps = {
122
125
  modalHelpText: 'The JSON definition for this card is provided below. You can modify this data directly to update the card configuration.',
123
126
  modalIconDescription: 'Close'
124
127
  },
128
+ shouldUseTranslatedLabels: false,
125
129
  getValidDataItems: null,
126
130
  getValidTimeRanges: null,
127
131
  dataItems: [],
@@ -151,6 +155,7 @@ var CardEditForm = function CardEditForm(_ref) {
151
155
  availableDimensions = _ref.availableDimensions,
152
156
  dataSeriesItemLinks = _ref.dataSeriesItemLinks,
153
157
  onFetchDynamicDemoHotspots = _ref.onFetchDynamicDemoHotspots,
158
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
154
159
  actions = _ref.actions;
155
160
  var mergedI18n = useMemo(function () {
156
161
  return _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
@@ -168,6 +173,7 @@ var CardEditForm = function CardEditForm(_ref) {
168
173
  onChange: onChange,
169
174
  isSummaryDashboard: isSummaryDashboard,
170
175
  i18n: mergedI18n,
176
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
171
177
  dataItems: dataItems,
172
178
  availableDimensions: availableDimensions,
173
179
  getValidDataItems: getValidDataItems,
@@ -318,6 +324,17 @@ CardEditForm.__docgenInfo = {
318
324
  "required": false,
319
325
  "description": ""
320
326
  },
327
+ "shouldUseTranslatedLabels": {
328
+ "defaultValue": {
329
+ "value": "false",
330
+ "computed": false
331
+ },
332
+ "type": {
333
+ "name": "bool"
334
+ },
335
+ "required": false,
336
+ "description": "whether to use translated labels in cards"
337
+ },
321
338
  "getValidDataItems": {
322
339
  "defaultValue": {
323
340
  "value": "null",
@@ -83,6 +83,9 @@ var propTypes = {
83
83
  thisYearLabel: PropTypes.string
84
84
  }),
85
85
 
86
+ /** whether to use translated labels in cards */
87
+ shouldUseTranslatedLabels: PropTypes.bool,
88
+
86
89
  /** if provided, returns an array of strings which are the timeRanges to be allowed
87
90
  * on each card
88
91
  * getValidTimeRanges(card, selectedDataItems)
@@ -123,6 +126,7 @@ var propTypes = {
123
126
  var defaultProps = {
124
127
  cardConfig: {},
125
128
  i18n: {},
129
+ shouldUseTranslatedLabels: false,
126
130
  getValidDataItems: null,
127
131
  getValidTimeRanges: null,
128
132
  dataItems: [],
@@ -164,6 +168,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
164
168
  isSummaryDashboard = _ref.isSummaryDashboard,
165
169
  onChange = _ref.onChange,
166
170
  i18n = _ref.i18n,
171
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
167
172
  dataItems = _ref.dataItems,
168
173
  getValidDataItems = _ref.getValidDataItems,
169
174
  getValidTimeRanges = _ref.getValidTimeRanges,
@@ -201,6 +206,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
201
206
  ,
202
207
  onChange: onChange,
203
208
  i18n: mergedI18n,
209
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
204
210
  getValidTimeRanges: getValidTimeRanges,
205
211
  currentBreakpoint: currentBreakpoint,
206
212
  selectedDataItems: selectedDataItems,
@@ -247,6 +253,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
247
253
  getValidDataItems: getValidDataItems,
248
254
  availableDimensions: availableDimensions,
249
255
  i18n: mergedI18n,
256
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
250
257
  dataSeriesItemLinks: dataSeriesItemLinks,
251
258
  translateWithId: handleTranslation,
252
259
  actions: actions
@@ -488,6 +495,17 @@ CardEditFormContent.__docgenInfo = {
488
495
  "required": false,
489
496
  "description": ""
490
497
  },
498
+ "shouldUseTranslatedLabels": {
499
+ "defaultValue": {
500
+ "value": "false",
501
+ "computed": false
502
+ },
503
+ "type": {
504
+ "name": "bool"
505
+ },
506
+ "required": false,
507
+ "description": "whether to use translated labels in cards"
508
+ },
491
509
  "getValidDataItems": {
492
510
  "defaultValue": {
493
511
  "value": "null",
@@ -27,6 +27,7 @@ import { DataItemsPropTypes, DashboardEditorActionsPropTypes, handleDefaultDataI
27
27
  import ColorDropdown from '../../../ColorDropdown/ColorDropdown.js';
28
28
  import { CARD_TYPES, BAR_CHART_TYPES } from '../../../../constants/LayoutConstants.js';
29
29
  import Button from '../../../Button/Button.js';
30
+ import { getTranslatedLabel } from '../../../../utils/cardUtilityFunctions.js';
30
31
  import ThresholdsFormItem from './ThresholdsFormItem.js';
31
32
 
32
33
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
@@ -136,6 +137,9 @@ var propTypes = {
136
137
  primaryButtonLabelText: PropTypes.string,
137
138
  secondaryButtonLabelText: PropTypes.string
138
139
  }),
140
+
141
+ /** whether to use translated labels in cards */
142
+ shouldUseTranslatedLabels: PropTypes.bool,
139
143
  actions: DashboardEditorActionsPropTypes,
140
144
 
141
145
  /**
@@ -190,6 +194,7 @@ var defaultProps = {
190
194
  secondaryButtonLabelText: 'Cancel',
191
195
  decimalPlacesLabel: 'Decimal places'
192
196
  },
197
+ shouldUseTranslatedLabels: false,
193
198
  editDataSeries: [],
194
199
  showEditor: false,
195
200
  setShowEditor: null,
@@ -272,6 +277,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
272
277
  availableDimensions = _ref.availableDimensions,
273
278
  onChange = _ref.onChange,
274
279
  i18n = _ref.i18n,
280
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
275
281
  isLarge = _ref.isLarge,
276
282
  testId = _ref.testId,
277
283
  _ref$actions$dataSeri = _ref.actions.dataSeriesFormActions,
@@ -442,7 +448,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
442
448
  label: evt.target.value
443
449
  }));
444
450
  },
445
- value: editDataItem.label,
451
+ value: getTranslatedLabel(editDataItem.label, shouldUseTranslatedLabels, i18n),
446
452
  helperText: mergedI18n.dataItemEditorDataItemHelperText(mergedI18n.dataItemSource, editDataItem.dataItemId)
447
453
  })), hasColorDropdown &&
448
454
  /*#__PURE__*/
@@ -576,7 +582,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
576
582
  },
577
583
  columnType: editDataItem.columnType || editDataItem.type
578
584
  }));
579
- }, [availableDimensions, availableGrains, baseClassName, cardConfig, editDataItem, handleTranslation, hasAggregationsDropDown, hasColorDropdown, hasDataFilterDropdown, hasDecimalPlacesDropdown, hasThresholds, hasTooltip, hasUnit, id, initialAggregation, initialGrain, isSummaryDashboard, isTimeBasedCard, mergedI18n, onAddAggregations, selectedDimensionFilter, setEditDataItem, testId, type]);
585
+ }, [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]);
580
586
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, showEditor && /*#__PURE__*/React__default.createElement("div", {
581
587
  className: "".concat(baseClassName, "--modal-wrapper")
582
588
  }, /*#__PURE__*/React__default.createElement(ComposedModal, {
@@ -806,6 +812,17 @@ DataSeriesFormItemModal.__docgenInfo = {
806
812
  "required": false,
807
813
  "description": ""
808
814
  },
815
+ "shouldUseTranslatedLabels": {
816
+ "defaultValue": {
817
+ "value": "false",
818
+ "computed": false
819
+ },
820
+ "type": {
821
+ "name": "bool"
822
+ },
823
+ "required": false,
824
+ "description": "whether to use translated labels in cards"
825
+ },
809
826
  "editDataSeries": {
810
827
  "defaultValue": {
811
828
  "value": "[]",
@@ -29,6 +29,7 @@ import ComboBox from '../../../../ComboBox/ComboBox.js';
29
29
  import DataSeriesFormItemModal from '../DataSeriesFormItemModal.js';
30
30
  import { BAR_CHART_TYPES, CARD_TYPES } from '../../../../../constants/LayoutConstants.js';
31
31
  import ContentFormItemTitle from '../ContentFormItemTitle.js';
32
+ import { getTranslatedLabel } from '../../../../../utils/cardUtilityFunctions.js';
32
33
  import BarChartDataSeriesContent from './BarChartDataSeriesContent.js';
33
34
  import { Dropdown } from 'carbon-components-react';
34
35
 
@@ -126,6 +127,9 @@ var propTypes = {
126
127
  incrementNumberText: PropTypes.string,
127
128
  decrementNumberText: PropTypes.string
128
129
  }),
130
+
131
+ /** whether to use translated labels in cards */
132
+ shouldUseTranslatedLabels: PropTypes.bool,
129
133
  translateWithId: PropTypes.func.isRequired,
130
134
  actions: DashboardEditorActionsPropTypes
131
135
  };
@@ -159,6 +163,7 @@ var defaultProps = {
159
163
  incrementNumberText: 'Increment number',
160
164
  decrementNumberText: 'Decrement number'
161
165
  },
166
+ shouldUseTranslatedLabels: false,
162
167
  getValidDataItems: null,
163
168
  dataItems: [],
164
169
  selectedDataItems: [],
@@ -260,6 +265,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
260
265
  selectedTimeRange = _ref2.selectedTimeRange,
261
266
  availableDimensions = _ref2.availableDimensions,
262
267
  i18n = _ref2.i18n,
268
+ shouldUseTranslatedLabels = _ref2.shouldUseTranslatedLabels,
263
269
  dataSeriesItemLinks = _ref2.dataSeriesItemLinks,
264
270
  translateWithId = _ref2.translateWithId,
265
271
  actions = _ref2.actions;
@@ -401,7 +407,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
401
407
  return {
402
408
  id: dataItem.dataSourceId,
403
409
  content: {
404
- value: dataItem.label || dataItem.dataItemId,
410
+ value: getTranslatedLabel(dataItem.label || dataItem.dataItemId, shouldUseTranslatedLabels, i18n),
405
411
  icon: cardConfig.type === CARD_TYPES.TIMESERIES || cardConfig.type === CARD_TYPES.BAR ? /*#__PURE__*/React__default.createElement("div", {
406
412
  className: "".concat(baseClassName, "--data-item-list--item-color-icon"),
407
413
  style: {
@@ -438,7 +444,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
438
444
  }
439
445
  };
440
446
  });
441
- }, [cardConfig.type, dataSection, handleEditButton, handleRemoveButton, mergedI18n.edit, mergedI18n.remove]);
447
+ }, [cardConfig.type, dataSection, handleEditButton, handleRemoveButton, i18n, mergedI18n.edit, mergedI18n.remove, shouldUseTranslatedLabels]);
442
448
  return !isEmpty(validDataItems) ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(DataSeriesFormItemModal, {
443
449
  cardConfig: cardConfig,
444
450
  isSummaryDashboard: isSummaryDashboard,
@@ -453,6 +459,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
453
459
  dataSection: dataSection,
454
460
  onChange: _onChange,
455
461
  i18n: mergedI18n,
462
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
456
463
  actions: actions,
457
464
  options: {
458
465
  hasColorDropdown: type === CARD_TYPES.TIMESERIES || type === CARD_TYPES.BAR,
@@ -765,6 +772,17 @@ DataSeriesFormItem.__docgenInfo = {
765
772
  "required": false,
766
773
  "description": ""
767
774
  },
775
+ "shouldUseTranslatedLabels": {
776
+ "defaultValue": {
777
+ "value": "false",
778
+ "computed": false
779
+ },
780
+ "type": {
781
+ "name": "bool"
782
+ },
783
+ "required": false,
784
+ "description": "whether to use translated labels in cards"
785
+ },
768
786
  "getValidDataItems": {
769
787
  "defaultValue": {
770
788
  "value": "null",
@@ -15,6 +15,7 @@ import PropTypes from 'prop-types';
15
15
  import { ALLOWED_CARD_SIZES_PER_TYPE, CARD_SIZES, CARD_DIMENSIONS } from '../../../constants/LayoutConstants.js';
16
16
  import { settings } from '../../../constants/Settings.js';
17
17
  import { timeRangeToJSON } from '../../DashboardEditor/editorUtils.js';
18
+ import { getTranslatedLabel } from '../../../utils/cardUtilityFunctions.js';
18
19
  import { TextInput, TextArea, Dropdown } from 'carbon-components-react';
19
20
 
20
21
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
@@ -77,6 +78,9 @@ var propTypes = {
77
78
  thisYearLabel: PropTypes.string
78
79
  }),
79
80
 
81
+ /** whether to use translated labels in cards */
82
+ shouldUseTranslatedLabels: PropTypes.bool,
83
+
80
84
  /** if provided, returns an array of strings which are the timeRanges to be allowed
81
85
  * on each card
82
86
  * getValidTimeRanges(card, selectedDataItems)
@@ -111,6 +115,7 @@ var defaultProps = {
111
115
  thisQuarterLabel: 'This quarter',
112
116
  thisYearLabel: 'This year'
113
117
  },
118
+ shouldUseTranslatedLabels: false,
114
119
  selectedDataItems: [],
115
120
  getValidTimeRanges: null,
116
121
  currentBreakpoint: 'xl',
@@ -136,6 +141,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
136
141
  var cardConfig = _ref.cardConfig,
137
142
  _onChange = _ref.onChange,
138
143
  i18n = _ref.i18n,
144
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
139
145
  getValidTimeRanges = _ref.getValidTimeRanges,
140
146
  currentBreakpoint = _ref.currentBreakpoint,
141
147
  selectedDataItems = _ref.selectedDataItems,
@@ -168,7 +174,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
168
174
  title: evt.target.value
169
175
  }));
170
176
  },
171
- value: title
177
+ value: getTranslatedLabel(title, shouldUseTranslatedLabels, mergedI18n)
172
178
  })), /*#__PURE__*/React__default.createElement("div", {
173
179
  className: "".concat(baseClassName, "--input")
174
180
  }, /*#__PURE__*/React__default.createElement(TextArea, {
@@ -463,6 +469,17 @@ CommonCardEditFormFields.__docgenInfo = {
463
469
  "required": false,
464
470
  "description": ""
465
471
  },
472
+ "shouldUseTranslatedLabels": {
473
+ "defaultValue": {
474
+ "value": "false",
475
+ "computed": false
476
+ },
477
+ "type": {
478
+ "name": "bool"
479
+ },
480
+ "required": false,
481
+ "description": "whether to use translated labels in cards"
482
+ },
466
483
  "selectedDataItems": {
467
484
  "defaultValue": {
468
485
  "value": "[]",
@@ -154,6 +154,9 @@ var propTypes = {
154
154
  searchPlaceHolderText: PropTypes.string,
155
155
  editDataItems: PropTypes.string
156
156
  }),
157
+
158
+ /** whether to use translated labels in cards */
159
+ shouldUseTranslatedLabels: PropTypes.bool,
157
160
  currentBreakpoint: PropTypes.string,
158
161
  isSummaryDashboard: PropTypes.bool,
159
162
 
@@ -189,6 +192,7 @@ var defaultProps = {
189
192
  modalHelpText: 'The JSON definition for this card is provided below. You can modify this data directly to update the card configuration.',
190
193
  modalIconDescription: 'Close'
191
194
  },
195
+ shouldUseTranslatedLabels: false,
192
196
  getValidDimensions: null,
193
197
  getValidDataItems: null,
194
198
  getValidTimeRanges: null,
@@ -354,6 +358,7 @@ var CardEditor = function CardEditor(_ref) {
354
358
  onRenderCardEditForm = _ref.onRenderCardEditForm,
355
359
  icons = _ref.icons,
356
360
  i18n = _ref.i18n,
361
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
357
362
  currentBreakpoint = _ref.currentBreakpoint,
358
363
  testId = _ref.testId,
359
364
  dataSeriesItemLinks = _ref.dataSeriesItemLinks,
@@ -422,6 +427,7 @@ var CardEditor = function CardEditor(_ref) {
422
427
  getValidTimeRanges: getValidTimeRanges,
423
428
  availableDimensions: availableDimensions,
424
429
  i18n: mergedI18n,
430
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
425
431
  currentBreakpoint: currentBreakpoint,
426
432
  dataSeriesItemLinks: dataSeriesItemLinks,
427
433
  onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
@@ -588,6 +594,17 @@ CardEditor.__docgenInfo = {
588
594
  "required": false,
589
595
  "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]"
590
596
  },
597
+ "shouldUseTranslatedLabels": {
598
+ "defaultValue": {
599
+ "value": "false",
600
+ "computed": false
601
+ },
602
+ "type": {
603
+ "name": "bool"
604
+ },
605
+ "required": false,
606
+ "description": "whether to use translated labels in cards"
607
+ },
591
608
  "getValidDimensions": {
592
609
  "defaultValue": {
593
610
  "value": "null",
@@ -25,6 +25,7 @@ import { CARD_TYPES, DASHBOARD_EDITOR_CARD_TYPES } from '../../constants/LayoutC
25
25
  import DashboardGrid from '../Dashboard/DashboardGrid.js';
26
26
  import CardEditor from '../CardEditor/CardEditor.js';
27
27
  import ImageGalleryModal, { ImagePropTypes } from '../ImageGalleryModal/ImageGalleryModal.js';
28
+ import { getTranslatedLabel } from '../../utils/cardUtilityFunctions.js';
28
29
  import DashboardEditorHeader from './DashboardEditorHeader/DashboardEditorHeader.js';
29
30
  import DashboardEditorCardRenderer from './DashboardEditorCardRenderer.js';
30
31
  import { DataItemsPropTypes, DashboardEditorActionsPropTypes, getDefaultCard, getDuplicateCard, renderBreakpointInfo, renderDefaultIconByName } from './editorUtils.js';
@@ -331,6 +332,9 @@ var propTypes = {
331
332
  editDataItems: PropTypes.string
332
333
  }),
333
334
 
335
+ /** whether to use translated labels in cards */
336
+ shouldUseTranslatedLabels: PropTypes.bool,
337
+
334
338
  /** locale data */
335
339
  locale: PropTypes.string,
336
340
 
@@ -424,6 +428,7 @@ var defaultProps = {
424
428
  saveTitleButton: 'Save title',
425
429
  editDataItems: 'Edit data items'
426
430
  },
431
+ shouldUseTranslatedLabels: false,
427
432
  locale: 'en',
428
433
  dataSeriesItemLinks: null,
429
434
  onFetchDynamicDemoHotspots: function onFetchDynamicDemoHotspots() {
@@ -502,6 +507,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
502
507
  isSummaryDashboard = _ref.isSummaryDashboard,
503
508
  isLoading = _ref.isLoading,
504
509
  i18n = _ref.i18n,
510
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
505
511
  locale = _ref.locale,
506
512
  dataSeriesItemLinks = _ref.dataSeriesItemLinks,
507
513
  isTitleEditable = _ref.isTitleEditable,
@@ -768,7 +774,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
768
774
  className: classnames("".concat(baseClassName, "--content"), _defineProperty({}, "".concat(baseClassName, "__overflow"), selectedBreakpointIndex !== LAYOUTS.FIT_TO_SCREEN.index)),
769
775
  ref: scrollContainerRef
770
776
  }, renderHeader ? renderHeader() : /*#__PURE__*/React__default.createElement(DashboardEditorHeader, {
771
- title: (dashboardJson === null || dashboardJson === void 0 ? void 0 : dashboardJson.title) || title,
777
+ title: getTranslatedLabel(dashboardJson === null || dashboardJson === void 0 ? void 0 : dashboardJson.title, shouldUseTranslatedLabels, i18n) || title,
772
778
  breadcrumbs: headerBreadcrumbs,
773
779
  onImport: onImport,
774
780
  onExport: function onExport() {
@@ -852,6 +858,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
852
858
  key: cardConfig.id,
853
859
  isResizable: isCardResizable,
854
860
  i18n: mergedI18n,
861
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
855
862
  isSelected: isSelected,
856
863
  availableDimensions: availableDimensions,
857
864
  onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
@@ -896,6 +903,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
896
903
  getValidDimensions: getValidDimensions,
897
904
  availableDimensions: availableDimensions,
898
905
  i18n: mergedI18n,
906
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
899
907
  currentBreakpoint: currentBreakpoint,
900
908
  dataSeriesItemLinks: dataSeriesItemLinks,
901
909
  onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
@@ -1819,6 +1827,17 @@ DashboardEditor.__docgenInfo = {
1819
1827
  "required": false,
1820
1828
  "description": "internationalization strings"
1821
1829
  },
1830
+ "shouldUseTranslatedLabels": {
1831
+ "defaultValue": {
1832
+ "value": "false",
1833
+ "computed": false
1834
+ },
1835
+ "type": {
1836
+ "name": "bool"
1837
+ },
1838
+ "required": false,
1839
+ "description": "whether to use translated labels in cards"
1840
+ },
1822
1841
  "locale": {
1823
1842
  "defaultValue": {
1824
1843
  "value": "'en'",
@@ -102,7 +102,8 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default.memo(function (_re
102
102
  baseClassName = _ref2.baseClassName,
103
103
  renderCardPreview = _ref2.renderCardPreview,
104
104
  style = _ref2.style,
105
- cardConfig = _objectWithoutProperties(_ref2, ["isSelected", "availableDimensions", "i18n", "onRemove", "onDuplicate", "onCardChange", "setSelectedCardId", "renderIconByName", "onShowImageGallery", "onValidateUploadedImage", "baseClassName", "renderCardPreview", "style"]);
105
+ shouldUseTranslatedLabels = _ref2.shouldUseTranslatedLabels,
106
+ cardConfig = _objectWithoutProperties(_ref2, ["isSelected", "availableDimensions", "i18n", "onRemove", "onDuplicate", "onCardChange", "setSelectedCardId", "renderIconByName", "onShowImageGallery", "onValidateUploadedImage", "baseClassName", "renderCardPreview", "style", "shouldUseTranslatedLabels"]);
106
107
 
107
108
  // We have to keep track of our dynamic hotspots here
108
109
  var _useState5 = useState([]),
@@ -137,6 +138,7 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default.memo(function (_re
137
138
  key: cardConfig.id,
138
139
  tooltip: cardConfig.description,
139
140
  i18n: i18n,
141
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
140
142
  availableActions: availableActions,
141
143
  onCardAction: handleOnCardAction,
142
144
  renderIconByName: renderIconByName,
@@ -149,7 +151,7 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default.memo(function (_re
149
151
  onBrowseClick: cardConfig.type === CARD_TYPES.IMAGE && isNil((_cardConfig$content = cardConfig.content) === null || _cardConfig$content === void 0 ? void 0 : _cardConfig$content.src) ? onShowImageGallery : undefined,
150
152
  validateUploadedImage: cardConfig.type === CARD_TYPES.IMAGE ? onValidateUploadedImage : undefined
151
153
  });
152
- }, [baseClassName, cardConfig, handleOnCardAction, handleOnCardKeyDown, handleOnCardMouseDown, i18n, isSelected, onShowImageGallery, onValidateUploadedImage, renderIconByName, style]);
154
+ }, [baseClassName, cardConfig, handleOnCardAction, handleOnCardKeyDown, handleOnCardMouseDown, i18n, isSelected, onShowImageGallery, onValidateUploadedImage, renderIconByName, shouldUseTranslatedLabels, style]);
153
155
  useEffect(function () {
154
156
  var _cardProps$values, _cardProps$values$hot;
155
157
 
@@ -11,6 +11,7 @@ import { TooltipDefinition, Link } from 'carbon-components-react';
11
11
  import { CARD_LAYOUTS } from '../../constants/LayoutConstants.js';
12
12
  import CardIcon from '../ImageCard/CardIcon.js';
13
13
  import useMatchingThreshold from '../../hooks/useMatchingThreshold.js';
14
+ import { getTranslatedLabel } from '../../utils/cardUtilityFunctions.js';
14
15
  import ValueRenderer from './ValueRenderer.js';
15
16
  import UnitRenderer from './UnitRenderer.js';
16
17
  import { BASE_CLASS_NAME } from './valueCardUtils.js';
@@ -35,6 +36,10 @@ var propTypes = {
35
36
  isEditable: PropTypes.bool,
36
37
  layout: PropTypes.oneOf(Object.values(CARD_LAYOUTS)),
37
38
  locale: PropTypes.string,
39
+
40
+ /** whether to use translated labels in cards */
41
+ shouldUseTranslatedLabels: PropTypes.bool,
42
+ i18n: PropTypes.objectOf(PropTypes.any),
38
43
  renderIconByName: PropTypes.func,
39
44
 
40
45
  /** Optional trend information */
@@ -66,6 +71,8 @@ var defaultProps = {
66
71
  locale: 'en',
67
72
  customFormatter: null,
68
73
  isEditable: false,
74
+ shouldUseTranslatedLabels: false,
75
+ i18n: {},
69
76
  testId: 'attribute',
70
77
  onValueClick: null
71
78
  };
@@ -91,6 +98,8 @@ var Attribute = function Attribute(_ref) {
91
98
  isEditable = _ref.isEditable,
92
99
  layout = _ref.layout,
93
100
  locale = _ref.locale,
101
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
102
+ i18n = _ref.i18n,
94
103
  renderIconByName = _ref.renderIconByName,
95
104
  secondaryValue = _ref.secondaryValue,
96
105
  value = _ref.value,
@@ -106,7 +115,9 @@ var Attribute = function Attribute(_ref) {
106
115
  var matchingThreshold = thresholds ? isEditable ? thresholds[0] : matchedThreshold : null;
107
116
  var valueColor = matchingThreshold && matchingThreshold.icon === undefined ? matchingThreshold.color : null; // need to reduce the width size to fit multiple attributes when card layout is horizontal
108
117
 
109
- var attributeWidthPercentage = layout === CARD_LAYOUTS.HORIZONTAL ? 100 / attributeCount : 100;
118
+ var attributeWidthPercentage = layout === CARD_LAYOUTS.HORIZONTAL ? 100 / attributeCount : 100; // Get translated label if shouldUseTranslatedLabels is true
119
+
120
+ var displayLabel = getTranslatedLabel(label, shouldUseTranslatedLabels, i18n);
110
121
  return /*#__PURE__*/React__default.createElement("div", {
111
122
  className: classnames("".concat(BEM_BASE, "-wrapper"), (_classnames = {}, _defineProperty(_classnames, "".concat(BEM_BASE, "-wrapper--vertical"), layout === CARD_LAYOUTS.VERTICAL), _defineProperty(_classnames, "".concat(BEM_BASE, "-wrapper--horizontal"), layout === CARD_LAYOUTS.HORIZONTAL), _classnames)),
112
123
  style: {
@@ -126,9 +137,9 @@ var Attribute = function Attribute(_ref) {
126
137
  }) : null, tooltip ? /*#__PURE__*/React__default.createElement(TooltipDefinition, {
127
138
  direction: "right",
128
139
  tooltipText: tooltip
129
- }, label) : /*#__PURE__*/React__default.createElement("span", {
140
+ }, displayLabel) : /*#__PURE__*/React__default.createElement("span", {
130
141
  "data-testid": "".concat(testId, "-threshold-label")
131
- }, label)), /*#__PURE__*/React__default.createElement("div", {
142
+ }, displayLabel)), /*#__PURE__*/React__default.createElement("div", {
132
143
  className: "".concat(BEM_BASE)
133
144
  }, /*#__PURE__*/React__default.createElement(ValueRenderer, {
134
145
  value: value,
@@ -305,6 +316,31 @@ Attribute.__docgenInfo = {
305
316
  "required": false,
306
317
  "description": ""
307
318
  },
319
+ "shouldUseTranslatedLabels": {
320
+ "defaultValue": {
321
+ "value": "false",
322
+ "computed": false
323
+ },
324
+ "type": {
325
+ "name": "bool"
326
+ },
327
+ "required": false,
328
+ "description": "whether to use translated labels in cards"
329
+ },
330
+ "i18n": {
331
+ "defaultValue": {
332
+ "value": "{}",
333
+ "computed": false
334
+ },
335
+ "type": {
336
+ "name": "objectOf",
337
+ "value": {
338
+ "name": "any"
339
+ }
340
+ },
341
+ "required": false,
342
+ "description": ""
343
+ },
308
344
  "testId": {
309
345
  "defaultValue": {
310
346
  "value": "'attribute'",