carbon-addons-iot-react 2.155.13 → 2.156.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/Card/Card.js +17 -5
- package/es/components/CardEditor/CardEditForm/CardEditForm.js +17 -0
- package/es/components/CardEditor/CardEditForm/CardEditFormContent.js +18 -0
- package/es/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItemModal.js +20 -3
- package/es/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItems/DataSeriesFormContent.js +20 -2
- package/es/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +19 -2
- package/es/components/CardEditor/CardEditor.js +17 -0
- package/es/components/DashboardEditor/DashboardEditor.js +20 -1
- package/es/components/DashboardEditor/DashboardEditorCardRenderer.js +4 -2
- package/es/components/ValueCard/Attribute.js +41 -4
- package/es/components/ValueCard/ValueCard.js +15 -3
- package/es/components/ValueCard/ValueContent.js +20 -2
- package/es/constants/CardPropTypes.js +3 -0
- package/es/utils/cardUtilityFunctions.js +17 -1
- package/lib/components/Card/Card.js +16 -4
- package/lib/components/CardEditor/CardEditForm/CardEditForm.js +17 -0
- package/lib/components/CardEditor/CardEditForm/CardEditFormContent.js +18 -0
- package/lib/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItemModal.js +20 -3
- package/lib/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItems/DataSeriesFormContent.js +20 -2
- package/lib/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +19 -2
- package/lib/components/CardEditor/CardEditor.js +17 -0
- package/lib/components/DashboardEditor/DashboardEditor.js +20 -1
- package/lib/components/DashboardEditor/DashboardEditorCardRenderer.js +4 -2
- package/lib/components/ValueCard/Attribute.js +41 -4
- package/lib/components/ValueCard/ValueCard.js +15 -3
- package/lib/components/ValueCard/ValueContent.js +20 -2
- package/lib/constants/CardPropTypes.js +3 -0
- package/lib/utils/cardUtilityFunctions.js +17 -0
- package/package.json +2 -2
- package/umd/carbon-addons-iot-react.js +240 -23
|
@@ -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');
|
|
@@ -346,6 +347,9 @@ var propTypes = {
|
|
|
346
347
|
editDataItems: PropTypes__default["default"].string
|
|
347
348
|
}),
|
|
348
349
|
|
|
350
|
+
/** whether to use translated labels in cards */
|
|
351
|
+
shouldUseTranslatedLabels: PropTypes__default["default"].bool,
|
|
352
|
+
|
|
349
353
|
/** locale data */
|
|
350
354
|
locale: PropTypes__default["default"].string,
|
|
351
355
|
|
|
@@ -439,6 +443,7 @@ var defaultProps = {
|
|
|
439
443
|
saveTitleButton: 'Save title',
|
|
440
444
|
editDataItems: 'Edit data items'
|
|
441
445
|
},
|
|
446
|
+
shouldUseTranslatedLabels: false,
|
|
442
447
|
locale: 'en',
|
|
443
448
|
dataSeriesItemLinks: null,
|
|
444
449
|
onFetchDynamicDemoHotspots: function onFetchDynamicDemoHotspots() {
|
|
@@ -517,6 +522,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
|
|
|
517
522
|
isSummaryDashboard = _ref.isSummaryDashboard,
|
|
518
523
|
isLoading = _ref.isLoading,
|
|
519
524
|
i18n = _ref.i18n,
|
|
525
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
520
526
|
locale = _ref.locale,
|
|
521
527
|
dataSeriesItemLinks = _ref.dataSeriesItemLinks,
|
|
522
528
|
isTitleEditable = _ref.isTitleEditable,
|
|
@@ -783,7 +789,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
|
|
|
783
789
|
className: classnames__default["default"]("".concat(baseClassName, "--content"), _defineProperty__default["default"]({}, "".concat(baseClassName, "__overflow"), selectedBreakpointIndex !== LAYOUTS.FIT_TO_SCREEN.index)),
|
|
784
790
|
ref: scrollContainerRef
|
|
785
791
|
}, renderHeader ? renderHeader() : /*#__PURE__*/React__default["default"].createElement(DashboardEditorHeader, {
|
|
786
|
-
title: (dashboardJson === null || dashboardJson === void 0 ? void 0 : dashboardJson.title) || title,
|
|
792
|
+
title: cardUtilityFunctions.getTranslatedLabel(dashboardJson === null || dashboardJson === void 0 ? void 0 : dashboardJson.title, shouldUseTranslatedLabels, i18n) || title,
|
|
787
793
|
breadcrumbs: headerBreadcrumbs,
|
|
788
794
|
onImport: onImport,
|
|
789
795
|
onExport: function onExport() {
|
|
@@ -867,6 +873,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
|
|
|
867
873
|
key: cardConfig.id,
|
|
868
874
|
isResizable: isCardResizable,
|
|
869
875
|
i18n: mergedI18n,
|
|
876
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
870
877
|
isSelected: isSelected,
|
|
871
878
|
availableDimensions: availableDimensions,
|
|
872
879
|
onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
|
|
@@ -911,6 +918,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
|
|
|
911
918
|
getValidDimensions: getValidDimensions,
|
|
912
919
|
availableDimensions: availableDimensions,
|
|
913
920
|
i18n: mergedI18n,
|
|
921
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
914
922
|
currentBreakpoint: currentBreakpoint,
|
|
915
923
|
dataSeriesItemLinks: dataSeriesItemLinks,
|
|
916
924
|
onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
|
|
@@ -1834,6 +1842,17 @@ DashboardEditor.__docgenInfo = {
|
|
|
1834
1842
|
"required": false,
|
|
1835
1843
|
"description": "internationalization strings"
|
|
1836
1844
|
},
|
|
1845
|
+
"shouldUseTranslatedLabels": {
|
|
1846
|
+
"defaultValue": {
|
|
1847
|
+
"value": "false",
|
|
1848
|
+
"computed": false
|
|
1849
|
+
},
|
|
1850
|
+
"type": {
|
|
1851
|
+
"name": "bool"
|
|
1852
|
+
},
|
|
1853
|
+
"required": false,
|
|
1854
|
+
"description": "whether to use translated labels in cards"
|
|
1855
|
+
},
|
|
1837
1856
|
"locale": {
|
|
1838
1857
|
"defaultValue": {
|
|
1839
1858
|
"value": "'en'",
|
|
@@ -113,7 +113,8 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default["default"].memo(fu
|
|
|
113
113
|
baseClassName = _ref2.baseClassName,
|
|
114
114
|
renderCardPreview = _ref2.renderCardPreview,
|
|
115
115
|
style = _ref2.style,
|
|
116
|
-
|
|
116
|
+
shouldUseTranslatedLabels = _ref2.shouldUseTranslatedLabels,
|
|
117
|
+
cardConfig = _objectWithoutProperties__default["default"](_ref2, ["isSelected", "availableDimensions", "i18n", "onRemove", "onDuplicate", "onCardChange", "setSelectedCardId", "renderIconByName", "onShowImageGallery", "onValidateUploadedImage", "baseClassName", "renderCardPreview", "style", "shouldUseTranslatedLabels"]);
|
|
117
118
|
|
|
118
119
|
// We have to keep track of our dynamic hotspots here
|
|
119
120
|
var _useState5 = React.useState([]),
|
|
@@ -148,6 +149,7 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default["default"].memo(fu
|
|
|
148
149
|
key: cardConfig.id,
|
|
149
150
|
tooltip: cardConfig.description,
|
|
150
151
|
i18n: i18n,
|
|
152
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
151
153
|
availableActions: availableActions,
|
|
152
154
|
onCardAction: handleOnCardAction,
|
|
153
155
|
renderIconByName: renderIconByName,
|
|
@@ -160,7 +162,7 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default["default"].memo(fu
|
|
|
160
162
|
onBrowseClick: cardConfig.type === LayoutConstants.CARD_TYPES.IMAGE && isNil((_cardConfig$content = cardConfig.content) === null || _cardConfig$content === void 0 ? void 0 : _cardConfig$content.src) ? onShowImageGallery : undefined,
|
|
161
163
|
validateUploadedImage: cardConfig.type === LayoutConstants.CARD_TYPES.IMAGE ? onValidateUploadedImage : undefined
|
|
162
164
|
});
|
|
163
|
-
}, [baseClassName, cardConfig, handleOnCardAction, handleOnCardKeyDown, handleOnCardMouseDown, i18n, isSelected, onShowImageGallery, onValidateUploadedImage, renderIconByName, style]);
|
|
165
|
+
}, [baseClassName, cardConfig, handleOnCardAction, handleOnCardKeyDown, handleOnCardMouseDown, i18n, isSelected, onShowImageGallery, onValidateUploadedImage, renderIconByName, shouldUseTranslatedLabels, style]);
|
|
164
166
|
React.useEffect(function () {
|
|
165
167
|
var _cardProps$values, _cardProps$values$hot;
|
|
166
168
|
|
|
@@ -13,6 +13,7 @@ var carbonComponentsReact = require('carbon-components-react');
|
|
|
13
13
|
var LayoutConstants = require('../../constants/LayoutConstants.js');
|
|
14
14
|
var CardIcon = require('../ImageCard/CardIcon.js');
|
|
15
15
|
var useMatchingThreshold = require('../../hooks/useMatchingThreshold.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');
|
|
@@ -44,6 +45,10 @@ var propTypes = {
|
|
|
44
45
|
isEditable: PropTypes__default["default"].bool,
|
|
45
46
|
layout: PropTypes__default["default"].oneOf(Object.values(LayoutConstants.CARD_LAYOUTS)),
|
|
46
47
|
locale: PropTypes__default["default"].string,
|
|
48
|
+
|
|
49
|
+
/** whether to use translated labels in cards */
|
|
50
|
+
shouldUseTranslatedLabels: PropTypes__default["default"].bool,
|
|
51
|
+
i18n: PropTypes__default["default"].objectOf(PropTypes__default["default"].any),
|
|
47
52
|
renderIconByName: PropTypes__default["default"].func,
|
|
48
53
|
|
|
49
54
|
/** Optional trend information */
|
|
@@ -75,6 +80,8 @@ var defaultProps = {
|
|
|
75
80
|
locale: 'en',
|
|
76
81
|
customFormatter: null,
|
|
77
82
|
isEditable: false,
|
|
83
|
+
shouldUseTranslatedLabels: false,
|
|
84
|
+
i18n: {},
|
|
78
85
|
testId: 'attribute',
|
|
79
86
|
onValueClick: null
|
|
80
87
|
};
|
|
@@ -100,6 +107,8 @@ var Attribute = function Attribute(_ref) {
|
|
|
100
107
|
isEditable = _ref.isEditable,
|
|
101
108
|
layout = _ref.layout,
|
|
102
109
|
locale = _ref.locale,
|
|
110
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
111
|
+
i18n = _ref.i18n,
|
|
103
112
|
renderIconByName = _ref.renderIconByName,
|
|
104
113
|
secondaryValue = _ref.secondaryValue,
|
|
105
114
|
value = _ref.value,
|
|
@@ -115,7 +124,10 @@ var Attribute = function Attribute(_ref) {
|
|
|
115
124
|
var matchingThreshold = thresholds ? isEditable ? thresholds[0] : matchedThreshold : null;
|
|
116
125
|
var valueColor = matchingThreshold && matchingThreshold.icon === undefined ? matchingThreshold.color : null; // need to reduce the width size to fit multiple attributes when card layout is horizontal
|
|
117
126
|
|
|
118
|
-
var attributeWidthPercentage = layout === LayoutConstants.CARD_LAYOUTS.HORIZONTAL ? 100 / attributeCount : 100;
|
|
127
|
+
var attributeWidthPercentage = layout === LayoutConstants.CARD_LAYOUTS.HORIZONTAL ? 100 / attributeCount : 100; // Get translated label if shouldUseTranslatedLabels is true
|
|
128
|
+
|
|
129
|
+
var displayLabel = cardUtilityFunctions.getTranslatedLabel(label, shouldUseTranslatedLabels, i18n);
|
|
130
|
+
var displayUnitLabel = cardUtilityFunctions.getTranslatedLabel(unit, shouldUseTranslatedLabels, i18n);
|
|
119
131
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
120
132
|
className: classnames__default["default"]("".concat(BEM_BASE, "-wrapper"), (_classnames = {}, _defineProperty__default["default"](_classnames, "".concat(BEM_BASE, "-wrapper--vertical"), layout === LayoutConstants.CARD_LAYOUTS.VERTICAL), _defineProperty__default["default"](_classnames, "".concat(BEM_BASE, "-wrapper--horizontal"), layout === LayoutConstants.CARD_LAYOUTS.HORIZONTAL), _classnames)),
|
|
121
133
|
style: {
|
|
@@ -135,9 +147,9 @@ var Attribute = function Attribute(_ref) {
|
|
|
135
147
|
}) : null, tooltip ? /*#__PURE__*/React__default["default"].createElement(carbonComponentsReact.TooltipDefinition, {
|
|
136
148
|
direction: "right",
|
|
137
149
|
tooltipText: tooltip
|
|
138
|
-
},
|
|
150
|
+
}, displayLabel) : /*#__PURE__*/React__default["default"].createElement("span", {
|
|
139
151
|
"data-testid": "".concat(testId, "-threshold-label")
|
|
140
|
-
},
|
|
152
|
+
}, displayLabel)), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
141
153
|
className: "".concat(BEM_BASE)
|
|
142
154
|
}, /*#__PURE__*/React__default["default"].createElement(ValueRenderer, {
|
|
143
155
|
value: value,
|
|
@@ -153,7 +165,7 @@ var Attribute = function Attribute(_ref) {
|
|
|
153
165
|
measurementUnitLabel: measurementUnitLabel,
|
|
154
166
|
onClick: onValueClick
|
|
155
167
|
}), /*#__PURE__*/React__default["default"].createElement(UnitRenderer, {
|
|
156
|
-
unit:
|
|
168
|
+
unit: displayUnitLabel,
|
|
157
169
|
testId: "".concat(testId, "-unit")
|
|
158
170
|
})), !isNil(secondaryValue) ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
159
171
|
"data-testid": "".concat(testId, "-secondary-value"),
|
|
@@ -314,6 +326,31 @@ Attribute.__docgenInfo = {
|
|
|
314
326
|
"required": false,
|
|
315
327
|
"description": ""
|
|
316
328
|
},
|
|
329
|
+
"shouldUseTranslatedLabels": {
|
|
330
|
+
"defaultValue": {
|
|
331
|
+
"value": "false",
|
|
332
|
+
"computed": false
|
|
333
|
+
},
|
|
334
|
+
"type": {
|
|
335
|
+
"name": "bool"
|
|
336
|
+
},
|
|
337
|
+
"required": false,
|
|
338
|
+
"description": "whether to use translated labels in cards"
|
|
339
|
+
},
|
|
340
|
+
"i18n": {
|
|
341
|
+
"defaultValue": {
|
|
342
|
+
"value": "{}",
|
|
343
|
+
"computed": false
|
|
344
|
+
},
|
|
345
|
+
"type": {
|
|
346
|
+
"name": "objectOf",
|
|
347
|
+
"value": {
|
|
348
|
+
"name": "any"
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
"required": false,
|
|
352
|
+
"description": ""
|
|
353
|
+
},
|
|
317
354
|
"testId": {
|
|
318
355
|
"defaultValue": {
|
|
319
356
|
"value": "'attribute'",
|
|
@@ -60,7 +60,8 @@ var ValueCard = function ValueCard(_ref) {
|
|
|
60
60
|
testID = _ref.testID,
|
|
61
61
|
testId = _ref.testId,
|
|
62
62
|
onAttributeClick = _ref.onAttributeClick,
|
|
63
|
-
|
|
63
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
64
|
+
others = _objectWithoutProperties__default["default"](_ref, ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "customFormatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "shouldUseTranslatedLabels"]);
|
|
64
65
|
|
|
65
66
|
var availableActions = _objectSpread({
|
|
66
67
|
expand: false
|
|
@@ -86,6 +87,7 @@ var ValueCard = function ValueCard(_ref) {
|
|
|
86
87
|
isResizable: isResizable,
|
|
87
88
|
resizeHandles: resizeHandles,
|
|
88
89
|
i18n: i18n,
|
|
90
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
89
91
|
locale: locale,
|
|
90
92
|
id: id,
|
|
91
93
|
className: classnames__default["default"]((_classnames = {}, _defineProperty__default["default"](_classnames, "".concat(valueCardUtils.BASE_CLASS_NAME, "__horizontal"), layout === LayoutConstants.CARD_LAYOUTS.HORIZONTAL), _defineProperty__default["default"](_classnames, "".concat(valueCardUtils.BASE_CLASS_NAME, "__vertical"), layout === LayoutConstants.CARD_LAYOUTS.VERTICAL), _classnames)) // TODO: remove deprecated 'testID' in v3.
|
|
@@ -105,7 +107,9 @@ var ValueCard = function ValueCard(_ref) {
|
|
|
105
107
|
values: values,
|
|
106
108
|
isEditable: isEditable,
|
|
107
109
|
fontSize: fontSize,
|
|
108
|
-
isNumberValueCompact: isNumberValueCompact
|
|
110
|
+
isNumberValueCompact: isNumberValueCompact,
|
|
111
|
+
i18n: i18n,
|
|
112
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels
|
|
109
113
|
}, others)), resizeHandles);
|
|
110
114
|
};
|
|
111
115
|
|
|
@@ -122,7 +126,8 @@ ValueCard.defaultProps = {
|
|
|
122
126
|
isNumberValueCompact: false,
|
|
123
127
|
// TODO: fix this default in V3, so that cards are unique not inherited from the base Card
|
|
124
128
|
testId: 'Card',
|
|
125
|
-
onAttributeClick: null
|
|
129
|
+
onAttributeClick: null,
|
|
130
|
+
shouldUseTranslatedLabels: false
|
|
126
131
|
};
|
|
127
132
|
ValueCard.__docgenInfo = {
|
|
128
133
|
"description": "This components responsibilities include:\nRendering the attribute groups\nDetermining the layout\ndetermines the data to render",
|
|
@@ -198,6 +203,13 @@ ValueCard.__docgenInfo = {
|
|
|
198
203
|
"computed": false
|
|
199
204
|
},
|
|
200
205
|
"required": false
|
|
206
|
+
},
|
|
207
|
+
"shouldUseTranslatedLabels": {
|
|
208
|
+
"defaultValue": {
|
|
209
|
+
"value": "false",
|
|
210
|
+
"computed": false
|
|
211
|
+
},
|
|
212
|
+
"required": false
|
|
201
213
|
}
|
|
202
214
|
},
|
|
203
215
|
"composes": ["../../constants/CardPropTypes"]
|
|
@@ -39,7 +39,10 @@ var propTypes = _objectSpread({
|
|
|
39
39
|
title: PropTypes__default["default"].string,
|
|
40
40
|
layout: PropTypes__default["default"].oneOf(['HORIZONTAL', 'VERTICAL']),
|
|
41
41
|
locale: PropTypes__default["default"].string,
|
|
42
|
-
isEditable: PropTypes__default["default"].bool
|
|
42
|
+
isEditable: PropTypes__default["default"].bool,
|
|
43
|
+
|
|
44
|
+
/** whether to use translated labels in cards */
|
|
45
|
+
shouldUseTranslatedLabels: PropTypes__default["default"].bool
|
|
43
46
|
}, CardPropTypes.ValueContentPropTypes);
|
|
44
47
|
|
|
45
48
|
var defaultProps = {
|
|
@@ -48,6 +51,7 @@ var defaultProps = {
|
|
|
48
51
|
layout: 'VERTICAL',
|
|
49
52
|
locale: 'en',
|
|
50
53
|
isEditable: false,
|
|
54
|
+
shouldUseTranslatedLabels: false,
|
|
51
55
|
dataState: null,
|
|
52
56
|
values: null,
|
|
53
57
|
fontSize: valueCardUtils.DEFAULT_FONT_SIZE,
|
|
@@ -67,13 +71,14 @@ var ValueContent = function ValueContent(_ref) {
|
|
|
67
71
|
dataState = _ref.dataState,
|
|
68
72
|
locale = _ref.locale,
|
|
69
73
|
isEditable = _ref.isEditable,
|
|
74
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
70
75
|
customFormatter = _ref.customFormatter,
|
|
71
76
|
fontSize = _ref.fontSize,
|
|
72
77
|
isNumberValueCompact = _ref.isNumberValueCompact,
|
|
73
78
|
testId = _ref.testId,
|
|
74
79
|
onAttributeClick = _ref.onAttributeClick,
|
|
75
80
|
size = _ref.size,
|
|
76
|
-
others = _objectWithoutProperties__default["default"](_ref, ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "customFormatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"]);
|
|
81
|
+
others = _objectWithoutProperties__default["default"](_ref, ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "shouldUseTranslatedLabels", "customFormatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"]);
|
|
77
82
|
|
|
78
83
|
var attributeCount = content.attributes.length;
|
|
79
84
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -87,6 +92,8 @@ var ValueContent = function ValueContent(_ref) {
|
|
|
87
92
|
locale: locale,
|
|
88
93
|
isEditable: isEditable,
|
|
89
94
|
title: title,
|
|
95
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
96
|
+
i18n: others.i18n,
|
|
90
97
|
renderIconByName: others.renderIconByName,
|
|
91
98
|
value: valueCardUtils.determineValue(attribute.dataSourceId, values, attribute.dataFilter),
|
|
92
99
|
secondaryValue: attribute.secondaryValue && _objectSpread(_objectSpread({}, attribute.secondaryValue), {}, {
|
|
@@ -175,6 +182,17 @@ ValueContent.__docgenInfo = {
|
|
|
175
182
|
"required": false,
|
|
176
183
|
"description": ""
|
|
177
184
|
},
|
|
185
|
+
"shouldUseTranslatedLabels": {
|
|
186
|
+
"defaultValue": {
|
|
187
|
+
"value": "false",
|
|
188
|
+
"computed": false
|
|
189
|
+
},
|
|
190
|
+
"type": {
|
|
191
|
+
"name": "bool"
|
|
192
|
+
},
|
|
193
|
+
"required": false,
|
|
194
|
+
"description": "whether to use translated labels in cards"
|
|
195
|
+
},
|
|
178
196
|
"dataState": {
|
|
179
197
|
"defaultValue": {
|
|
180
198
|
"value": "null",
|
|
@@ -193,6 +193,9 @@ var TableCardPropTypes = {
|
|
|
193
193
|
defaultFilterStringPlaceholdText: PropTypes__default["default"].string,
|
|
194
194
|
downloadIconDescription: PropTypes__default["default"].string
|
|
195
195
|
}),
|
|
196
|
+
|
|
197
|
+
/** whether to use translated labels in cards */
|
|
198
|
+
shouldUseTranslatedLabels: PropTypes__default["default"].bool,
|
|
196
199
|
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])),
|
|
197
200
|
|
|
198
201
|
/** default date format pattern that follows the dayjs formatting patterns */
|
|
@@ -11,6 +11,7 @@ var _typeof = require('@babel/runtime/helpers/typeof');
|
|
|
11
11
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
12
12
|
var mapValues = require('../node_modules/lodash-es/mapValues.js');
|
|
13
13
|
var isNil = require('../node_modules/lodash-es/isNil.js');
|
|
14
|
+
var isEmpty = require('../node_modules/lodash-es/isEmpty.js');
|
|
14
15
|
require('core-js/modules/es.array.includes.js');
|
|
15
16
|
require('core-js/modules/es.string.includes.js');
|
|
16
17
|
require('core-js/modules/es.array.concat.js');
|
|
@@ -624,6 +625,21 @@ var handleTooltip = function handleTooltip(dataOrHoveredElement, defaultTooltip,
|
|
|
624
625
|
});
|
|
625
626
|
return defaultTooltipDOM.innerHTML;
|
|
626
627
|
};
|
|
628
|
+
/**
|
|
629
|
+
* Get translated label or title from i18n object, fallback to original if not found
|
|
630
|
+
* @param {string} label - The label or title key to translate
|
|
631
|
+
* @param {boolean} shouldUseTranslatedLabels - Flag to determine if translation should be used
|
|
632
|
+
* @param {Object} i18n - The i18n object containing translations
|
|
633
|
+
* @returns {string} - The translated label or original label if translation not found
|
|
634
|
+
*/
|
|
635
|
+
|
|
636
|
+
var getTranslatedLabel = function getTranslatedLabel(label, shouldUseTranslatedLabels, i18n) {
|
|
637
|
+
if (!isEmpty(label) && shouldUseTranslatedLabels && i18n && i18n[label]) {
|
|
638
|
+
return i18n[label];
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
return label;
|
|
642
|
+
};
|
|
627
643
|
|
|
628
644
|
exports.chartValueFormatter = chartValueFormatter;
|
|
629
645
|
exports.compareGrains = compareGrains;
|
|
@@ -635,6 +651,7 @@ exports.findMatchingThresholds = findMatchingThresholds;
|
|
|
635
651
|
exports.formatNumberWithPrecision = formatNumberWithPrecision;
|
|
636
652
|
exports.getCardVariables = getCardVariables;
|
|
637
653
|
exports.getResizeHandles = getResizeHandles;
|
|
654
|
+
exports.getTranslatedLabel = getTranslatedLabel;
|
|
638
655
|
exports.getUpdatedCardSize = getUpdatedCardSize;
|
|
639
656
|
exports.getVariables = getVariables;
|
|
640
657
|
exports.handleCardVariables = handleCardVariables;
|
package/package.json
CHANGED
|
@@ -341,11 +341,11 @@
|
|
|
341
341
|
"whatwg-fetch": "^3.0.0"
|
|
342
342
|
},
|
|
343
343
|
"sideEffects": false,
|
|
344
|
-
"version": "2.
|
|
344
|
+
"version": "2.156.1",
|
|
345
345
|
"resolutions": {
|
|
346
346
|
"chokidar": "3.3.1",
|
|
347
347
|
"react-grid-layout": "1.2.2",
|
|
348
348
|
"got": "11.8.5"
|
|
349
349
|
},
|
|
350
|
-
"gitHead": "
|
|
350
|
+
"gitHead": "7a3b178053896da403e40467ef6f9af352f27202"
|
|
351
351
|
}
|