carbon-addons-iot-react 5.9.1 → 5.10.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 (32) 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/Table/TableBody/TableBodyRow/TableBodyRow.js +5 -5
  11. package/es/components/ValueCard/Attribute.js +38 -2
  12. package/es/components/ValueCard/ValueCard.js +15 -3
  13. package/es/components/ValueCard/ValueContent.js +19 -2
  14. package/es/constants/CardPropTypes.js +2 -0
  15. package/es/utils/cardUtilityFunctions.js +16 -1
  16. package/lib/components/Card/Card.js +17 -4
  17. package/lib/components/CardEditor/CardEditForm/CardEditForm.js +16 -0
  18. package/lib/components/CardEditor/CardEditForm/CardEditFormContent.js +17 -0
  19. package/lib/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItemModal.js +17 -2
  20. package/lib/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItems/DataSeriesFormContent.js +19 -2
  21. package/lib/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +17 -1
  22. package/lib/components/CardEditor/CardEditor.js +16 -0
  23. package/lib/components/DashboardEditor/DashboardEditor.js +19 -1
  24. package/lib/components/DashboardEditor/DashboardEditorCardRenderer.js +4 -2
  25. package/lib/components/Table/TableBody/TableBodyRow/TableBodyRow.js +5 -5
  26. package/lib/components/ValueCard/Attribute.js +38 -2
  27. package/lib/components/ValueCard/ValueCard.js +15 -3
  28. package/lib/components/ValueCard/ValueContent.js +19 -2
  29. package/lib/constants/CardPropTypes.js +2 -0
  30. package/lib/utils/cardUtilityFunctions.js +16 -0
  31. package/package.json +1 -1
  32. package/umd/carbon-addons-iot-react.js +231 -24
@@ -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'",
@@ -37,7 +37,7 @@ var React__default = /*#__PURE__*/_interopDefault(React);
37
37
  var update__default = /*#__PURE__*/_interopDefault(update);
38
38
 
39
39
  var _excluded = ["style", "children"],
40
- _excluded2 = ["isSelected", "availableDimensions", "i18n", "onRemove", "onDuplicate", "onCardChange", "setSelectedCardId", "renderIconByName", "onShowImageGallery", "onValidateUploadedImage", "baseClassName", "renderCardPreview", "style"];
40
+ _excluded2 = ["isSelected", "availableDimensions", "i18n", "onRemove", "onDuplicate", "onCardChange", "setSelectedCardId", "renderIconByName", "onShowImageGallery", "onValidateUploadedImage", "baseClassName", "renderCardPreview", "style", "shouldUseTranslatedLabels"];
41
41
  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; }
42
42
  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; }
43
43
 
@@ -109,6 +109,7 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default.default.memo(funct
109
109
  baseClassName = _ref2.baseClassName,
110
110
  renderCardPreview = _ref2.renderCardPreview,
111
111
  style = _ref2.style,
112
+ shouldUseTranslatedLabels = _ref2.shouldUseTranslatedLabels,
112
113
  cardConfig = _objectWithoutProperties__default.default(_ref2, _excluded2);
113
114
  // We have to keep track of our dynamic hotspots here
114
115
  var _useState5 = React.useState([]),
@@ -142,6 +143,7 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default.default.memo(funct
142
143
  key: cardConfig.id,
143
144
  tooltip: cardConfig.description,
144
145
  i18n: i18n,
146
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
145
147
  availableActions: availableActions,
146
148
  onCardAction: handleOnCardAction,
147
149
  renderIconByName: renderIconByName,
@@ -154,7 +156,7 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default.default.memo(funct
154
156
  onBrowseClick: cardConfig.type === LayoutConstants.CARD_TYPES.IMAGE && isNil((_cardConfig$content = cardConfig.content) === null || _cardConfig$content === void 0 ? void 0 : _cardConfig$content.src) ? onShowImageGallery : undefined,
155
157
  validateUploadedImage: cardConfig.type === LayoutConstants.CARD_TYPES.IMAGE ? onValidateUploadedImage : undefined
156
158
  });
157
- }, [baseClassName, cardConfig, handleOnCardAction, handleOnCardKeyDown, handleOnCardMouseDown, i18n, isSelected, onShowImageGallery, onValidateUploadedImage, renderIconByName, style]);
159
+ }, [baseClassName, cardConfig, handleOnCardAction, handleOnCardKeyDown, handleOnCardMouseDown, i18n, isSelected, onShowImageGallery, onValidateUploadedImage, renderIconByName, shouldUseTranslatedLabels, style]);
158
160
  React.useEffect(function () {
159
161
  var _cardProps$values;
160
162
  var originalDynamicHotspot = (_cardProps$values = cardProps.values) === null || _cardProps$values === void 0 || (_cardProps$values = _cardProps$values.hotspots) === null || _cardProps$values === void 0 ? void 0 : _cardProps$values.find(function (hotspot) {
@@ -398,7 +398,7 @@ var TableBodyRow = function TableBodyRow(_ref) {
398
398
  key: id
399
399
  }, /*#__PURE__*/React__default.default.createElement(TableExpandRow, _extends__default.default({
400
400
  expandHeaderId: "".concat(tableId, "-expand"),
401
- className: classnames__default.default("".concat(iotPrefix, "--expandable-tablerow--expanded"), _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, "".concat(iotPrefix, "--expandable-tablerow--indented"), parseInt(nestingOffset, 10) > 0), "".concat(iotPrefix, "--expandable-tablerow--childless"), hasRowNesting && nestingChildCount === 0), "".concat(iotPrefix, "--table__row--dragging"), isDragRow), "".concat(iotPrefix, "--table__row--softdeleted"), values === null || values === void 0 ? void 0 : values[deletedAttribute])),
401
+ className: classnames__default.default("".concat(iotPrefix, "--expandable-tablerow--expanded"), _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, "".concat(iotPrefix, "--expandable-tablerow--indented"), parseInt(nestingOffset, 10) > 0), "".concat(iotPrefix, "--expandable-tablerow--childless"), hasRowNesting && nestingChildCount === 0), "".concat(iotPrefix, "--table__row--dragging"), isDragRow), "".concat(iotPrefix, "--table__row--softdeleted"), values === null || values === void 0 ? void 0 : values[deletedAttribute]), "".concat(iotPrefix, "--table__row--updated"), values === null || values === void 0 ? void 0 : values._updated)),
402
402
  ariaLabel: clickToCollapseAria,
403
403
  expandIconDescription: clickToCollapseAria,
404
404
  isExpanded: true,
@@ -426,13 +426,13 @@ var TableBodyRow = function TableBodyRow(_ref) {
426
426
  rowId: id,
427
427
  langDir: langDir
428
428
  }, dragEnterLeaveHandlers), tableCells), !hasRowNesting && /*#__PURE__*/React__default.default.createElement(react.TableRow, _extends__default.default({
429
- className: classnames__default.default("".concat(iotPrefix, "--expanded-tablerow"), _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, "".concat(iotPrefix, "--expanded-tablerow--singly-selected"), hasRowSelection === 'single' && isSelected && !useRadioButtonSingleSelect), "".concat(iotPrefix, "--table__row--dragging"), isDragRow), "".concat(iotPrefix, "--table__row--softdeleted"), values === null || values === void 0 ? void 0 : values[deletedAttribute]))
429
+ className: classnames__default.default("".concat(iotPrefix, "--expanded-tablerow"), _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, "".concat(iotPrefix, "--expanded-tablerow--singly-selected"), hasRowSelection === 'single' && isSelected && !useRadioButtonSingleSelect), "".concat(iotPrefix, "--table__row--dragging"), isDragRow), "".concat(iotPrefix, "--table__row--softdeleted"), values === null || values === void 0 ? void 0 : values[deletedAttribute]), "".concat(iotPrefix, "--table__row--updated"), values === null || values === void 0 ? void 0 : values._updated))
430
430
  }, dragEnterLeaveHandlers), /*#__PURE__*/React__default.default.createElement(react.TableCell, {
431
431
  colSpan: totalColumns
432
432
  }, rowDetails))) : /*#__PURE__*/React__default.default.createElement(TableExpandRow, _extends__default.default({
433
433
  key: id,
434
434
  expandHeaderId: "".concat(tableId, "-expand"),
435
- className: classnames__default.default("".concat(iotPrefix, "--expandable-tablerow"), _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, "".concat(iotPrefix, "--expandable-tablerow--parent"), hasRowNesting && (hasRowNesting === null || hasRowNesting === void 0 ? void 0 : hasRowNesting.hasSingleNestedHierarchy) && nestingChildCount > 0), "".concat(iotPrefix, "--expandable-tablerow--childless"), hasRowNesting && nestingChildCount === 0), "".concat(iotPrefix, "--expandable-tablerow--indented"), parseInt(nestingOffset, 10) > 0), "".concat(iotPrefix, "--expandable-tablerow--singly-selected"), hasRowSelection === 'single' && isSelected && !useRadioButtonSingleSelect), "".concat(iotPrefix, "--expandable-tablerow--last-child"), isLastChild), "".concat(iotPrefix, "--table__row--dragging"), isDragRow), "".concat(iotPrefix, "--table__row--softdeleted"), values === null || values === void 0 ? void 0 : values[deletedAttribute])),
435
+ className: classnames__default.default("".concat(iotPrefix, "--expandable-tablerow"), _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, "".concat(iotPrefix, "--expandable-tablerow--parent"), hasRowNesting && (hasRowNesting === null || hasRowNesting === void 0 ? void 0 : hasRowNesting.hasSingleNestedHierarchy) && nestingChildCount > 0), "".concat(iotPrefix, "--expandable-tablerow--childless"), hasRowNesting && nestingChildCount === 0), "".concat(iotPrefix, "--expandable-tablerow--indented"), parseInt(nestingOffset, 10) > 0), "".concat(iotPrefix, "--expandable-tablerow--singly-selected"), hasRowSelection === 'single' && isSelected && !useRadioButtonSingleSelect), "".concat(iotPrefix, "--expandable-tablerow--last-child"), isLastChild), "".concat(iotPrefix, "--table__row--dragging"), isDragRow), "".concat(iotPrefix, "--table__row--softdeleted"), values === null || values === void 0 ? void 0 : values[deletedAttribute]), "".concat(iotPrefix, "--table__row--updated"), values === null || values === void 0 ? void 0 : values._updated)),
436
436
  "data-row-nesting": hasRowNesting,
437
437
  "data-child-count": nestingChildCount,
438
438
  "data-nesting-offset": nestingOffset,
@@ -461,7 +461,7 @@ var TableBodyRow = function TableBodyRow(_ref) {
461
461
  rowId: id,
462
462
  langDir: langDir
463
463
  }, dragEnterLeaveHandlers), tableCells) : hasRowSelection === 'single' && isSelected ? /*#__PURE__*/React__default.default.createElement(react.TableRow, _extends__default.default({
464
- className: classnames__default.default("".concat(iotPrefix, "--table__row"), _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, "".concat(iotPrefix, "--table__row--singly-selected"), isSelected && !useRadioButtonSingleSelect), "".concat(iotPrefix, "--table__row--background"), isSelected), "".concat(iotPrefix, "--table__row--softdeleted"), values === null || values === void 0 ? void 0 : values[deletedAttribute])),
464
+ className: classnames__default.default("".concat(iotPrefix, "--table__row"), _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, "".concat(iotPrefix, "--table__row--singly-selected"), isSelected && !useRadioButtonSingleSelect), "".concat(iotPrefix, "--table__row--background"), isSelected), "".concat(iotPrefix, "--table__row--softdeleted"), values === null || values === void 0 ? void 0 : values[deletedAttribute]), "".concat(iotPrefix, "--table__row--updated"), values === null || values === void 0 ? void 0 : values._updated)),
465
465
  key: id,
466
466
  onClick: function onClick() {
467
467
  if (isSelectable !== false) {
@@ -472,7 +472,7 @@ var TableBodyRow = function TableBodyRow(_ref) {
472
472
  }
473
473
  }
474
474
  }, dragEnterLeaveHandlers), tableCells) : /*#__PURE__*/React__default.default.createElement(react.TableRow, _extends__default.default({
475
- className: classnames__default.default("".concat(iotPrefix, "--table__row"), _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, "".concat(iotPrefix, "--table__row--unselectable"), isSelectable === false), "".concat(iotPrefix, "--table__row--selectable"), isSelectable !== false), "".concat(iotPrefix, "--table__row--editing"), isEditMode), "".concat(iotPrefix, "--table__row--selected"), isSelected), "".concat(iotPrefix, "--table__row--dragging"), isDragRow), "".concat(iotPrefix, "--table__row--softdeleted"), values === null || values === void 0 ? void 0 : values[deletedAttribute])),
475
+ className: classnames__default.default("".concat(iotPrefix, "--table__row"), _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, "".concat(iotPrefix, "--table__row--unselectable"), isSelectable === false), "".concat(iotPrefix, "--table__row--selectable"), isSelectable !== false), "".concat(iotPrefix, "--table__row--editing"), isEditMode), "".concat(iotPrefix, "--table__row--selected"), isSelected), "".concat(iotPrefix, "--table__row--dragging"), isDragRow), "".concat(iotPrefix, "--table__row--softdeleted"), values === null || values === void 0 ? void 0 : values[deletedAttribute]), "".concat(iotPrefix, "--table__row--updated"), values === null || values === void 0 ? void 0 : values._updated)),
476
476
  key: id,
477
477
  onClick: function onClick() {
478
478
  if (isSelectable !== false) {
@@ -13,6 +13,7 @@ var LayoutConstants = require('../../constants/LayoutConstants.js');
13
13
  var CardIcon = require('../ImageCard/CardIcon.js');
14
14
  var useMatchingThreshold = require('../../hooks/useMatchingThreshold.js');
15
15
  var index = require('../Tooltip/index.js');
16
+ var cardUtilityFunctions = require('../../utils/cardUtilityFunctions.js');
16
17
  var ValueRenderer = require('./ValueRenderer.js');
17
18
  var UnitRenderer = require('./UnitRenderer.js');
18
19
  var valueCardUtils = require('./valueCardUtils.js');
@@ -48,6 +49,9 @@ var propTypes = {
48
49
  isEditable: PropTypes__default.default.bool,
49
50
  layout: PropTypes__default.default.oneOf(Object.values(LayoutConstants.CARD_LAYOUTS)),
50
51
  locale: PropTypes__default.default.string,
52
+ /** whether to use translated labels in cards */
53
+ shouldUseTranslatedLabels: PropTypes__default.default.bool,
54
+ i18n: PropTypes__default.default.objectOf(PropTypes__default.default.any),
51
55
  renderIconByName: PropTypes__default.default.func,
52
56
  /** Optional trend information */
53
57
  secondaryValue: PropTypes__default.default.shape({
@@ -76,6 +80,8 @@ var defaultProps = {
76
80
  customFormatter: null,
77
81
  formatter: null,
78
82
  isEditable: false,
83
+ shouldUseTranslatedLabels: false,
84
+ i18n: {},
79
85
  testId: 'attribute',
80
86
  onValueClick: null
81
87
  };
@@ -102,6 +108,8 @@ var Attribute = function Attribute(_ref) {
102
108
  isEditable = _ref.isEditable,
103
109
  layout = _ref.layout,
104
110
  locale = _ref.locale,
111
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
112
+ i18n = _ref.i18n,
105
113
  renderIconByName = _ref.renderIconByName,
106
114
  secondaryValue = _ref.secondaryValue,
107
115
  value = _ref.value,
@@ -121,6 +129,9 @@ var Attribute = function Attribute(_ref) {
121
129
  // need to reduce the width size to fit multiple attributes when card layout is horizontal
122
130
  var attributeWidthPercentage = layout === LayoutConstants.CARD_LAYOUTS.HORIZONTAL ? 100 / attributeCount : 100;
123
131
 
132
+ // Get translated label if shouldUseTranslatedLabels is true
133
+ var displayLabel = cardUtilityFunctions.getTranslatedLabel(label, shouldUseTranslatedLabels, i18n);
134
+
124
135
  // Render threshold icon component
125
136
  var renderThresholdIcon = function renderThresholdIcon() {
126
137
  if (!(matchingThreshold !== null && matchingThreshold !== void 0 && matchingThreshold.icon)) return null;
@@ -146,10 +157,10 @@ var Attribute = function Attribute(_ref) {
146
157
  }, thresholdsIconPosition === 'label' && renderThresholdIcon(), tooltip ? /*#__PURE__*/React__default.default.createElement(index.Tooltip, {
147
158
  direction: "right",
148
159
  showIcon: false,
149
- triggerText: label
160
+ triggerText: displayLabel
150
161
  }, /*#__PURE__*/React__default.default.createElement("p", null, tooltip)) : /*#__PURE__*/React__default.default.createElement("span", {
151
162
  "data-testid": "".concat(testId, "-threshold-label")
152
- }, label)), /*#__PURE__*/React__default.default.createElement("div", {
163
+ }, displayLabel)), /*#__PURE__*/React__default.default.createElement("div", {
153
164
  className: "".concat(BEM_BASE)
154
165
  }, /*#__PURE__*/React__default.default.createElement(ValueRenderer, {
155
166
  value: value,
@@ -340,6 +351,31 @@ Attribute.__docgenInfo = {
340
351
  },
341
352
  "required": false
342
353
  },
354
+ "shouldUseTranslatedLabels": {
355
+ "defaultValue": {
356
+ "value": "false",
357
+ "computed": false
358
+ },
359
+ "description": "whether to use translated labels in cards",
360
+ "type": {
361
+ "name": "bool"
362
+ },
363
+ "required": false
364
+ },
365
+ "i18n": {
366
+ "defaultValue": {
367
+ "value": "{}",
368
+ "computed": false
369
+ },
370
+ "description": "",
371
+ "type": {
372
+ "name": "objectOf",
373
+ "value": {
374
+ "name": "any"
375
+ }
376
+ },
377
+ "required": false
378
+ },
343
379
  "testId": {
344
380
  "defaultValue": {
345
381
  "value": "'attribute'",
@@ -30,7 +30,7 @@ var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWith
30
30
  var React__default = /*#__PURE__*/_interopDefault(React);
31
31
  var classnames__default = /*#__PURE__*/_interopDefault(classnames);
32
32
 
33
- var _excluded = ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "customFormatter", "formatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "className"];
33
+ var _excluded = ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "customFormatter", "formatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "className", "shouldUseTranslatedLabels"];
34
34
  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; }
35
35
  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; }
36
36
 
@@ -60,6 +60,7 @@ var ValueCard = function ValueCard(_ref) {
60
60
  testId = _ref.testId,
61
61
  onAttributeClick = _ref.onAttributeClick,
62
62
  className = _ref.className,
63
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
63
64
  others = _objectWithoutProperties__default.default(_ref, _excluded);
64
65
  var availableActions = _objectSpread({
65
66
  expand: false
@@ -84,6 +85,7 @@ var ValueCard = function ValueCard(_ref) {
84
85
  isResizable: isResizable,
85
86
  resizeHandles: resizeHandles,
86
87
  i18n: i18n,
88
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
87
89
  locale: locale,
88
90
  id: id,
89
91
  className: classnames__default.default(className, _defineProperty__default.default(_defineProperty__default.default({}, "".concat(valueCardUtils.BASE_CLASS_NAME, "__horizontal"), layout === LayoutConstants.CARD_LAYOUTS.HORIZONTAL), "".concat(valueCardUtils.BASE_CLASS_NAME, "__vertical"), layout === LayoutConstants.CARD_LAYOUTS.VERTICAL))
@@ -107,7 +109,9 @@ var ValueCard = function ValueCard(_ref) {
107
109
  values: values,
108
110
  isEditable: isEditable,
109
111
  fontSize: fontSize,
110
- isNumberValueCompact: isNumberValueCompact
112
+ isNumberValueCompact: isNumberValueCompact,
113
+ i18n: i18n,
114
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels
111
115
  }, others)), resizeHandles);
112
116
  };
113
117
  ValueCard.propTypes = _objectSpread(_objectSpread({}, CardPropTypes.CardPropTypes), CardPropTypes.ValueContentPropTypes);
@@ -124,7 +128,8 @@ ValueCard.defaultProps = {
124
128
  isNumberValueCompact: false,
125
129
  // TODO: fix this default in V3, so that cards are unique not inherited from the base Card
126
130
  testId: 'Card',
127
- onAttributeClick: null
131
+ onAttributeClick: null,
132
+ shouldUseTranslatedLabels: false
128
133
  };
129
134
  ValueCard.__docgenInfo = {
130
135
  "description": "This components responsibilities include:\nRendering the attribute groups\nDetermining the layout\ndetermines the data to render",
@@ -207,6 +212,13 @@ ValueCard.__docgenInfo = {
207
212
  "computed": false
208
213
  },
209
214
  "required": false
215
+ },
216
+ "shouldUseTranslatedLabels": {
217
+ "defaultValue": {
218
+ "value": "false",
219
+ "computed": false
220
+ },
221
+ "required": false
210
222
  }
211
223
  },
212
224
  "composes": ["../../constants/CardPropTypes"]
@@ -30,7 +30,7 @@ var React__default = /*#__PURE__*/_interopDefault(React);
30
30
  var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
31
31
  var classnames__default = /*#__PURE__*/_interopDefault(classnames);
32
32
 
33
- var _excluded = ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "customFormatter", "formatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"];
33
+ var _excluded = ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "shouldUseTranslatedLabels", "customFormatter", "formatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"];
34
34
  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; }
35
35
  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; }
36
36
  var propTypes = _objectSpread({
@@ -38,7 +38,9 @@ var propTypes = _objectSpread({
38
38
  title: PropTypes__default.default.string,
39
39
  layout: PropTypes__default.default.oneOf(['HORIZONTAL', 'VERTICAL']),
40
40
  locale: PropTypes__default.default.string,
41
- isEditable: PropTypes__default.default.bool
41
+ isEditable: PropTypes__default.default.bool,
42
+ /** whether to use translated labels in cards */
43
+ shouldUseTranslatedLabels: PropTypes__default.default.bool
42
44
  }, CardPropTypes.ValueContentPropTypes);
43
45
  var defaultProps = {
44
46
  id: 'valueContent-id',
@@ -46,6 +48,7 @@ var defaultProps = {
46
48
  layout: 'VERTICAL',
47
49
  locale: 'en',
48
50
  isEditable: false,
51
+ shouldUseTranslatedLabels: false,
49
52
  dataState: null,
50
53
  values: null,
51
54
  fontSize: valueCardUtils.DEFAULT_FONT_SIZE,
@@ -65,6 +68,7 @@ var ValueContent = function ValueContent(_ref) {
65
68
  dataState = _ref.dataState,
66
69
  locale = _ref.locale,
67
70
  isEditable = _ref.isEditable,
71
+ shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
68
72
  customFormatter = _ref.customFormatter,
69
73
  formatter = _ref.formatter,
70
74
  fontSize = _ref.fontSize,
@@ -85,6 +89,8 @@ var ValueContent = function ValueContent(_ref) {
85
89
  locale: locale,
86
90
  isEditable: isEditable,
87
91
  title: title,
92
+ shouldUseTranslatedLabels: shouldUseTranslatedLabels,
93
+ i18n: others.i18n,
88
94
  renderIconByName: others.renderIconByName,
89
95
  value: valueCardUtils.determineValue(attribute.dataSourceId, values, attribute.dataFilter),
90
96
  secondaryValue: attribute.secondaryValue && _objectSpread(_objectSpread({}, attribute.secondaryValue), {}, {
@@ -175,6 +181,17 @@ ValueContent.__docgenInfo = {
175
181
  },
176
182
  "required": false
177
183
  },
184
+ "shouldUseTranslatedLabels": {
185
+ "defaultValue": {
186
+ "value": "false",
187
+ "computed": false
188
+ },
189
+ "description": "whether to use translated labels in cards",
190
+ "type": {
191
+ "name": "bool"
192
+ },
193
+ "required": false
194
+ },
178
195
  "dataState": {
179
196
  "defaultValue": {
180
197
  "value": "null",
@@ -179,6 +179,8 @@ var TableCardPropTypes = {
179
179
  defaultFilterStringPlaceholdText: PropTypes__default.default.string,
180
180
  downloadIconDescription: PropTypes__default.default.string
181
181
  }),
182
+ /** whether to use translated labels in cards */
183
+ shouldUseTranslatedLabels: PropTypes__default.default.bool,
182
184
  cardVariables: PropTypes__default.default.objectOf(PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.func, PropTypes__default.default.number, PropTypes__default.default.bool])),
183
185
  /** default date format pattern that follows the dayjs formatting patterns */
184
186
  defaultDateFormatPattern: PropTypes__default.default.string
@@ -6,6 +6,7 @@ var _typeof = require('@babel/runtime/helpers/typeof');
6
6
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
7
7
  var mapValues = require('../node_modules/lodash-es/mapValues.js');
8
8
  var isNil = require('../node_modules/lodash-es/isNil.js');
9
+ var isEmpty = require('../node_modules/lodash-es/isEmpty.js');
9
10
  require('core-js/modules/es.symbol.js');
10
11
  require('core-js/modules/es.array.concat.js');
11
12
  require('core-js/modules/es.array.filter.js');
@@ -584,6 +585,20 @@ var isTimeBasedCard = function isTimeBasedCard(card) {
584
585
  })) || ((_card$content2 = card.content) === null || _card$content2 === void 0 ? void 0 : _card$content2.type) === LayoutConstants.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) === LayoutConstants.BAR_CHART_TYPES.STACKED && ((_card$content5 = card.content) === null || _card$content5 === void 0 ? void 0 : _card$content5.timeDataSourceId);
585
586
  };
586
587
 
588
+ /**
589
+ * Get translated label or title from i18n object, fallback to original if not found
590
+ * @param {string} label - The label or title key to translate
591
+ * @param {boolean} shouldUseTranslatedLabels - Flag to determine if translation should be used
592
+ * @param {Object} i18n - The i18n object containing translations
593
+ * @returns {string} - The translated label or original label if translation not found
594
+ */
595
+ var getTranslatedLabel = function getTranslatedLabel(label, shouldUseTranslatedLabels, i18n) {
596
+ if (!isEmpty(label) && shouldUseTranslatedLabels && i18n && i18n[label]) {
597
+ return i18n[label];
598
+ }
599
+ return label;
600
+ };
601
+
587
602
  exports.chartValueFormatter = chartValueFormatter;
588
603
  exports.compareGrains = compareGrains;
589
604
  exports.determineCardRange = determineCardRange;
@@ -594,6 +609,7 @@ exports.findMatchingThresholds = findMatchingThresholds;
594
609
  exports.formatNumberWithPrecision = formatNumberWithPrecision;
595
610
  exports.getCardVariables = getCardVariables;
596
611
  exports.getResizeHandles = getResizeHandles;
612
+ exports.getTranslatedLabel = getTranslatedLabel;
597
613
  exports.getUpdatedCardSize = getUpdatedCardSize;
598
614
  exports.getVariables = getVariables;
599
615
  exports.handleCardVariables = handleCardVariables;
package/package.json CHANGED
@@ -353,7 +353,7 @@
353
353
  "whatwg-fetch": "^3.0.0"
354
354
  },
355
355
  "sideEffects": false,
356
- "version": "5.9.1",
356
+ "version": "5.10.0",
357
357
  "resolutions": {
358
358
  "chokidar": "3.3.1",
359
359
  "react-grid-layout": "1.2.2",