carbon-addons-iot-react 2.149.0-next.32 → 2.149.0-next.35

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.
@@ -6,7 +6,7 @@ import classnames from 'classnames';
6
6
  import { ErrorFilled24, WarningFilled24 } from '@carbon/icons-react';
7
7
  import { Tooltip } from '../Tooltip/index.js';
8
8
  import { settings } from '../../constants/Settings.js';
9
- import { ValueCardPropTypes, CardPropTypes } from '../../constants/CardPropTypes.js';
9
+ import { ValueContentPropTypes, CardPropTypes } from '../../constants/CardPropTypes.js';
10
10
  import { CARD_CONTENT_PADDING, CARD_SIZES, CARD_DATA_STATE } from '../../constants/LayoutConstants.js';
11
11
 
12
12
  var iotPrefix = settings.iotPrefix;
@@ -26,7 +26,7 @@ var TooltipContent = function TooltipContent(_ref) {
26
26
  }, label), /*#__PURE__*/React__default.createElement("p", null, description), extraTooltipText && /*#__PURE__*/React__default.createElement("p", null, extraTooltipText), learnMoreElement);
27
27
  };
28
28
  TooltipContent.propTypes = {
29
- tooltipContent: ValueCardPropTypes.dataState.isRequired
29
+ tooltipContent: ValueContentPropTypes.dataState.isRequired
30
30
  };
31
31
 
32
32
  var DataStateRenderer = function DataStateRenderer(_ref2) {
@@ -96,7 +96,7 @@ var DataStateRenderer = function DataStateRenderer(_ref2) {
96
96
  DataStateRenderer.propTypes = {
97
97
  size: CardPropTypes.size,
98
98
  id: CardPropTypes.id,
99
- dataState: ValueCardPropTypes.dataState.isRequired
99
+ dataState: ValueContentPropTypes.dataState.isRequired
100
100
  };
101
101
  DataStateRenderer.defaultProps = {
102
102
  size: CARD_SIZES.MEDIUM,
@@ -134,7 +134,7 @@ DataStateRenderer.__docgenInfo = {
134
134
  "dataState": {
135
135
  "type": {
136
136
  "name": "custom",
137
- "raw": "ValueCardPropTypes.dataState.isRequired"
137
+ "raw": "ValueContentPropTypes.dataState.isRequired"
138
138
  },
139
139
  "required": false,
140
140
  "description": ""
@@ -149,7 +149,7 @@ TooltipContent.__docgenInfo = {
149
149
  "tooltipContent": {
150
150
  "type": {
151
151
  "name": "custom",
152
- "raw": "ValueCardPropTypes.dataState.isRequired"
152
+ "raw": "ValueContentPropTypes.dataState.isRequired"
153
153
  },
154
154
  "required": false,
155
155
  "description": ""
@@ -0,0 +1,109 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import React__default from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import classnames from 'classnames';
5
+ import { settings } from '../../constants/Settings.js';
6
+
7
+ var iotPrefix = settings.iotPrefix;
8
+ var propTypes = {
9
+ type: PropTypes.oneOf(['stacked', 'inline', 'inline_small']),
10
+ label: PropTypes.string,
11
+ value: PropTypes.string,
12
+ testId: PropTypes.string
13
+ };
14
+ var defaultProps = {
15
+ type: 'stacked',
16
+ label: '',
17
+ value: '',
18
+ testId: 'read-only-value'
19
+ };
20
+
21
+ var ReadOnlyValue = function ReadOnlyValue(_ref) {
22
+ var _classnames;
23
+
24
+ var type = _ref.type,
25
+ label = _ref.label,
26
+ value = _ref.value,
27
+ className = _ref.className,
28
+ testId = _ref.testId;
29
+ return /*#__PURE__*/React__default.createElement("div", {
30
+ "data-testid": testId,
31
+ className: classnames(className, "".concat(iotPrefix, "--read-only-value"), (_classnames = {}, _defineProperty(_classnames, "".concat(iotPrefix, "--read-only-value__inline"), type === 'inline' || type === 'inline_small'), _defineProperty(_classnames, "".concat(iotPrefix, "--read-only-value__inline_small"), type === 'inline_small'), _classnames))
32
+ }, /*#__PURE__*/React__default.createElement("label", {
33
+ "data-testid": "".concat(testId, "--label"),
34
+ htmlFor: "readonly-".concat(label)
35
+ }, label, /*#__PURE__*/React__default.createElement("textarea", {
36
+ "data-testid": "".concat(testId, "--value"),
37
+ type: "text",
38
+ id: "readonly-".concat(label),
39
+ name: value,
40
+ value: value,
41
+ readOnly: true
42
+ })));
43
+ };
44
+
45
+ ReadOnlyValue.propTypes = propTypes;
46
+ ReadOnlyValue.defaultProps = defaultProps;
47
+ ReadOnlyValue.__docgenInfo = {
48
+ "description": "",
49
+ "methods": [],
50
+ "displayName": "ReadOnlyValue",
51
+ "props": {
52
+ "type": {
53
+ "defaultValue": {
54
+ "value": "'stacked'",
55
+ "computed": false
56
+ },
57
+ "type": {
58
+ "name": "enum",
59
+ "value": [{
60
+ "value": "'stacked'",
61
+ "computed": false
62
+ }, {
63
+ "value": "'inline'",
64
+ "computed": false
65
+ }, {
66
+ "value": "'inline_small'",
67
+ "computed": false
68
+ }]
69
+ },
70
+ "required": false,
71
+ "description": ""
72
+ },
73
+ "label": {
74
+ "defaultValue": {
75
+ "value": "''",
76
+ "computed": false
77
+ },
78
+ "type": {
79
+ "name": "string"
80
+ },
81
+ "required": false,
82
+ "description": ""
83
+ },
84
+ "value": {
85
+ "defaultValue": {
86
+ "value": "''",
87
+ "computed": false
88
+ },
89
+ "type": {
90
+ "name": "string"
91
+ },
92
+ "required": false,
93
+ "description": ""
94
+ },
95
+ "testId": {
96
+ "defaultValue": {
97
+ "value": "'read-only-value'",
98
+ "computed": false
99
+ },
100
+ "type": {
101
+ "name": "string"
102
+ },
103
+ "required": false,
104
+ "description": ""
105
+ }
106
+ }
107
+ };
108
+
109
+ export default ReadOnlyValue;
@@ -13,12 +13,14 @@ import useMatchingThreshold from '../../hooks/useMatchingThreshold.js';
13
13
  import ValueRenderer from './ValueRenderer.js';
14
14
  import UnitRenderer from './UnitRenderer.js';
15
15
  import { BASE_CLASS_NAME } from './valueCardUtils.js';
16
+ import { Link } from 'carbon-components-react';
16
17
 
17
18
  var propTypes = {
18
19
  attribute: PropTypes.shape({
19
20
  label: PropTypes.string,
20
21
  unit: PropTypes.string,
21
22
  dataSourceId: PropTypes.string,
23
+ measurementUnitLabel: PropTypes.string,
22
24
  // decimal precision
23
25
  precision: PropTypes.number,
24
26
  thresholds: PropTypes.arrayOf(PropTypes.shape({
@@ -38,7 +40,9 @@ var propTypes = {
38
40
  secondaryValue: PropTypes.shape({
39
41
  color: PropTypes.string,
40
42
  trend: PropTypes.oneOf(['up', 'down']),
41
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number])
43
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number]),
44
+ href: PropTypes.string,
45
+ onClick: PropTypes.func
42
46
  }),
43
47
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number]),
44
48
  fontSize: PropTypes.number.isRequired,
@@ -79,6 +83,7 @@ var Attribute = function Attribute(_ref) {
79
83
  thresholds = _ref$attribute.thresholds,
80
84
  precision = _ref$attribute.precision,
81
85
  dataSourceId = _ref$attribute.dataSourceId,
86
+ measurementUnitLabel = _ref$attribute.measurementUnitLabel,
82
87
  attributeCount = _ref.attributeCount,
83
88
  customFormatter = _ref.customFormatter,
84
89
  isEditable = _ref.isEditable,
@@ -131,6 +136,7 @@ var Attribute = function Attribute(_ref) {
131
136
  isNumberValueCompact: isNumberValueCompact,
132
137
  testId: "".concat(testId, "-value"),
133
138
  dataSourceId: dataSourceId,
139
+ measurementUnitLabel: measurementUnitLabel,
134
140
  onClick: onValueClick
135
141
  }), /*#__PURE__*/React__default.createElement(UnitRenderer, {
136
142
  unit: unit,
@@ -141,7 +147,7 @@ var Attribute = function Attribute(_ref) {
141
147
  style: {
142
148
  '--secondary-value-color': gray60
143
149
  }
144
- }, secondaryValue.trend && secondaryValue.trend === 'up' ? /*#__PURE__*/React__default.createElement(CaretUp16, {
150
+ }, secondaryValue.trend === 'up' ? /*#__PURE__*/React__default.createElement(CaretUp16, {
145
151
  className: "".concat(BEM_BASE, "_trend-icon"),
146
152
  "aria-label": "trending up",
147
153
  "data-testid": "".concat(testId, "-trending-up"),
@@ -151,7 +157,18 @@ var Attribute = function Attribute(_ref) {
151
157
  "aria-label": "trending down",
152
158
  "data-testid": "".concat(testId, "-trending-down"),
153
159
  fill: secondaryValue.color || gray60
154
- }) : null, secondaryValue.value) : null));
160
+ }) : null, secondaryValue.href || secondaryValue.onClick ? /*#__PURE__*/React__default.createElement(Link, {
161
+ "data-testid": "".concat(testId, "-secondary-value--link"),
162
+ className: "".concat(BEM_BASE, "-secondary-value--link"),
163
+ href: secondaryValue === null || secondaryValue === void 0 ? void 0 : secondaryValue.href,
164
+ rel: "noopener noreferrer",
165
+ onClick: function onClick() {
166
+ return secondaryValue === null || secondaryValue === void 0 ? void 0 : secondaryValue.onClick({
167
+ dataSourceId: dataSourceId,
168
+ secondaryValue: secondaryValue
169
+ });
170
+ }
171
+ }, secondaryValue.value) : secondaryValue.value) : null));
155
172
  };
156
173
 
157
174
  Attribute.propTypes = propTypes;
@@ -236,6 +253,14 @@ Attribute.__docgenInfo = {
236
253
  "name": "number"
237
254
  }],
238
255
  "required": false
256
+ },
257
+ "href": {
258
+ "name": "string",
259
+ "required": false
260
+ },
261
+ "onClick": {
262
+ "name": "func",
263
+ "required": false
239
264
  }
240
265
  }
241
266
  },
@@ -313,6 +338,10 @@ Attribute.__docgenInfo = {
313
338
  "name": "string",
314
339
  "required": false
315
340
  },
341
+ "measurementUnitLabel": {
342
+ "name": "string",
343
+ "required": false
344
+ },
316
345
  "precision": {
317
346
  "name": "number",
318
347
  "required": false
@@ -1,9 +1,3 @@
1
- import 'core-js/modules/es.object.keys.js';
2
- import 'core-js/modules/es.symbol.js';
3
- import 'core-js/modules/es.array.filter.js';
4
- import 'core-js/modules/es.object.get-own-property-descriptor.js';
5
- import 'core-js/modules/web.dom-collections.for-each.js';
6
- import 'core-js/modules/es.object.get-own-property-descriptors.js';
7
1
  import _extends from '@babel/runtime/helpers/extends';
8
2
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
9
3
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
@@ -11,17 +5,20 @@ import isEmpty from '../../node_modules/lodash-es/isEmpty.js';
11
5
  import 'core-js/modules/es.array.iterator.js';
12
6
  import 'core-js/modules/es.object.to-string.js';
13
7
  import 'core-js/modules/web.dom-collections.iterator.js';
14
- import 'core-js/modules/es.array.map.js';
15
- import 'core-js/modules/es.array.concat.js';
8
+ import 'core-js/modules/es.object.keys.js';
9
+ import 'core-js/modules/es.symbol.js';
10
+ import 'core-js/modules/es.array.filter.js';
11
+ import 'core-js/modules/es.object.get-own-property-descriptor.js';
12
+ import 'core-js/modules/web.dom-collections.for-each.js';
13
+ import 'core-js/modules/es.object.get-own-property-descriptors.js';
16
14
  import React__default from 'react';
17
15
  import classnames from 'classnames';
18
- import { CardPropTypes, ValueCardPropTypes } from '../../constants/CardPropTypes.js';
16
+ import { CardPropTypes, ValueContentPropTypes } from '../../constants/CardPropTypes.js';
19
17
  import { CARD_LAYOUTS, CARD_SIZES } from '../../constants/LayoutConstants.js';
20
18
  import Card from '../Card/Card.js';
21
19
  import { getUpdatedCardSize, getResizeHandles, handleCardVariables } from '../../utils/cardUtilityFunctions.js';
22
- import DataStateRenderer from '../Card/DataStateRenderer.js';
23
- import { BASE_CLASS_NAME, PREVIEW_DATA, determineValue, DEFAULT_FONT_SIZE, determineLayout } from './valueCardUtils.js';
24
- import Attribute from './Attribute.js';
20
+ import { BASE_CLASS_NAME, DEFAULT_FONT_SIZE, determineLayout } from './valueCardUtils.js';
21
+ import ValueContent from './ValueContent.js';
25
22
 
26
23
  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; }
27
24
 
@@ -70,7 +67,6 @@ var ValueCard = function ValueCard(_ref) {
70
67
  values = _handleCardVariables.values;
71
68
 
72
69
  var layout = determineLayout(newSize);
73
- var attributeCount = content.attributes.length;
74
70
  return /*#__PURE__*/React__default.createElement(Card, _extends({
75
71
  title: title,
76
72
  size: newSize,
@@ -85,41 +81,25 @@ var ValueCard = function ValueCard(_ref) {
85
81
  className: classnames((_classnames = {}, _defineProperty(_classnames, "".concat(BASE_CLASS_NAME, "__horizontal"), layout === CARD_LAYOUTS.HORIZONTAL), _defineProperty(_classnames, "".concat(BASE_CLASS_NAME, "__vertical"), layout === CARD_LAYOUTS.VERTICAL), _classnames)) // TODO: remove deprecated 'testID' in v3.
86
82
  ,
87
83
  testId: testID || testId
88
- }, others), /*#__PURE__*/React__default.createElement("div", {
89
- className: classnames("".concat(BASE_CLASS_NAME, "__content-wrapper"), _defineProperty({}, "".concat(BASE_CLASS_NAME, "__content-wrapper--vertical"), layout === CARD_LAYOUTS.VERTICAL))
90
- }, !dataState ? content.attributes.map(function (attribute, index) {
91
- return /*#__PURE__*/React__default.createElement(Attribute, {
92
- key: "fragment-".concat(attribute.dataSourceId, "-").concat(JSON.stringify(attribute.dataFilter || {})),
93
- attribute: attribute,
94
- attributeCount: attributeCount,
95
- layout: layout,
96
- locale: locale,
97
- isEditable: isEditable,
98
- title: title,
99
- renderIconByName: others.renderIconByName,
100
- value: // When the card is in the editable state, we will show a preview
101
- isEditable ? PREVIEW_DATA : determineValue(attribute.dataSourceId, values, attribute.dataFilter),
102
- secondaryValue: attribute.secondaryValue && _objectSpread(_objectSpread({}, attribute.secondaryValue), {}, {
103
- // When the card is in the editable state, we will show a preview
104
- value: isEditable ? PREVIEW_DATA : determineValue(attribute.secondaryValue.dataSourceId, values)
105
- }),
106
- customFormatter: customFormatter,
107
- fontSize: fontSize,
108
- isNumberValueCompact: isNumberValueCompact // TODO: remove deprecated 'testID' in v3.
109
- ,
110
- testId: "".concat(testID || testId, "-attribute-").concat(index),
111
- onValueClick: onAttributeClick
112
- });
113
- }) : /*#__PURE__*/React__default.createElement(DataStateRenderer, {
84
+ }, others), /*#__PURE__*/React__default.createElement(ValueContent, _extends({
85
+ id: id,
86
+ layout: layout,
114
87
  dataState: dataState,
88
+ content: content,
89
+ locale: locale,
90
+ title: title,
91
+ customFormatter: customFormatter,
92
+ testId: testID || testId,
93
+ onAttributeClick: onAttributeClick,
115
94
  size: newSize,
116
- id: id // TODO: remove deprecated 'testID' in v3.
117
- ,
118
- testId: "".concat(testID || testId, "-data-state")
119
- })), resizeHandles);
95
+ values: values,
96
+ isEditable: isEditable,
97
+ fontSize: fontSize,
98
+ isNumberValueCompact: isNumberValueCompact
99
+ }, others)), resizeHandles);
120
100
  };
121
101
 
122
- ValueCard.propTypes = _objectSpread(_objectSpread({}, CardPropTypes), ValueCardPropTypes);
102
+ ValueCard.propTypes = _objectSpread(_objectSpread({}, CardPropTypes), ValueContentPropTypes);
123
103
  ValueCard.defaultProps = {
124
104
  size: CARD_SIZES.MEDIUM,
125
105
  locale: 'en',
@@ -0,0 +1,230 @@
1
+ import 'core-js/modules/es.object.keys.js';
2
+ import 'core-js/modules/es.symbol.js';
3
+ import 'core-js/modules/es.array.filter.js';
4
+ import 'core-js/modules/es.object.get-own-property-descriptor.js';
5
+ import 'core-js/modules/web.dom-collections.for-each.js';
6
+ import 'core-js/modules/es.object.get-own-property-descriptors.js';
7
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
8
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
9
+ import 'core-js/modules/es.array.iterator.js';
10
+ import 'core-js/modules/es.object.to-string.js';
11
+ import 'core-js/modules/web.dom-collections.iterator.js';
12
+ import 'core-js/modules/es.array.map.js';
13
+ import 'core-js/modules/es.array.concat.js';
14
+ import React__default from 'react';
15
+ import PropTypes from 'prop-types';
16
+ import classnames from 'classnames';
17
+ import { CARD_LAYOUTS, CARD_SIZES } from '../../constants/LayoutConstants.js';
18
+ import { ValueContentPropTypes } from '../../constants/CardPropTypes.js';
19
+ import DataStateRenderer from '../Card/DataStateRenderer.js';
20
+ import { BASE_CLASS_NAME, PREVIEW_DATA, determineValue, DEFAULT_FONT_SIZE } from './valueCardUtils.js';
21
+ import Attribute from './Attribute.js';
22
+
23
+ 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; }
24
+
25
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
26
+
27
+ var propTypes = _objectSpread({
28
+ id: PropTypes.string,
29
+ title: PropTypes.string,
30
+ layout: PropTypes.oneOf(['HORIZONTAL', 'VERTICAL']),
31
+ locale: PropTypes.string,
32
+ isEditable: PropTypes.bool
33
+ }, ValueContentPropTypes);
34
+
35
+ var defaultProps = {
36
+ id: 'valueContent-id',
37
+ title: '',
38
+ layout: 'VERTICAL',
39
+ locale: 'en',
40
+ isEditable: false,
41
+ dataState: null,
42
+ values: null,
43
+ fontSize: DEFAULT_FONT_SIZE,
44
+ customFormatter: null,
45
+ isNumberValueCompact: false,
46
+ testId: 'ValueContent',
47
+ onAttributeClick: null,
48
+ size: CARD_SIZES.MEDIUM
49
+ };
50
+
51
+ var ValueContent = function ValueContent(_ref) {
52
+ var id = _ref.id,
53
+ title = _ref.title,
54
+ content = _ref.content,
55
+ values = _ref.values,
56
+ layout = _ref.layout,
57
+ dataState = _ref.dataState,
58
+ locale = _ref.locale,
59
+ isEditable = _ref.isEditable,
60
+ customFormatter = _ref.customFormatter,
61
+ fontSize = _ref.fontSize,
62
+ isNumberValueCompact = _ref.isNumberValueCompact,
63
+ testId = _ref.testId,
64
+ onAttributeClick = _ref.onAttributeClick,
65
+ size = _ref.size,
66
+ others = _objectWithoutProperties(_ref, ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "customFormatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"]);
67
+
68
+ var attributeCount = content.attributes.length;
69
+ return /*#__PURE__*/React__default.createElement("div", {
70
+ className: classnames("".concat(BASE_CLASS_NAME, "__content-wrapper"), _defineProperty({}, "".concat(BASE_CLASS_NAME, "__content-wrapper--vertical"), layout === CARD_LAYOUTS.VERTICAL))
71
+ }, !dataState ? content.attributes.map(function (attribute, index) {
72
+ return /*#__PURE__*/React__default.createElement(Attribute, {
73
+ key: "fragment-".concat(attribute.dataSourceId, "-").concat(JSON.stringify(attribute.dataFilter || {})),
74
+ attribute: attribute,
75
+ attributeCount: attributeCount,
76
+ layout: layout,
77
+ locale: locale,
78
+ isEditable: isEditable,
79
+ title: title,
80
+ renderIconByName: others.renderIconByName,
81
+ value: // When the card is in the editable state, we will show a preview
82
+ isEditable ? PREVIEW_DATA : determineValue(attribute.dataSourceId, values, attribute.dataFilter),
83
+ secondaryValue: attribute.secondaryValue && _objectSpread(_objectSpread({}, attribute.secondaryValue), {}, {
84
+ // When the card is in the editable state, we will show a preview
85
+ value: isEditable ? PREVIEW_DATA : determineValue(attribute.secondaryValue.dataSourceId, values)
86
+ }),
87
+ customFormatter: customFormatter,
88
+ fontSize: fontSize,
89
+ isNumberValueCompact: isNumberValueCompact,
90
+ testId: "".concat(testId, "-attribute-").concat(index),
91
+ onValueClick: onAttributeClick
92
+ });
93
+ }) : /*#__PURE__*/React__default.createElement(DataStateRenderer, {
94
+ dataState: dataState,
95
+ size: size,
96
+ id: id,
97
+ testId: "".concat(testId, "-data-state")
98
+ }));
99
+ };
100
+
101
+ ValueContent.propTypes = propTypes;
102
+ ValueContent.defaultProps = defaultProps;
103
+ ValueContent.__docgenInfo = {
104
+ "description": "",
105
+ "methods": [],
106
+ "displayName": "ValueContent",
107
+ "props": {
108
+ "id": {
109
+ "defaultValue": {
110
+ "value": "'valueContent-id'",
111
+ "computed": false
112
+ },
113
+ "type": {
114
+ "name": "string"
115
+ },
116
+ "required": false,
117
+ "description": ""
118
+ },
119
+ "title": {
120
+ "defaultValue": {
121
+ "value": "''",
122
+ "computed": false
123
+ },
124
+ "type": {
125
+ "name": "string"
126
+ },
127
+ "required": false,
128
+ "description": ""
129
+ },
130
+ "layout": {
131
+ "defaultValue": {
132
+ "value": "'VERTICAL'",
133
+ "computed": false
134
+ },
135
+ "type": {
136
+ "name": "enum",
137
+ "value": [{
138
+ "value": "'HORIZONTAL'",
139
+ "computed": false
140
+ }, {
141
+ "value": "'VERTICAL'",
142
+ "computed": false
143
+ }]
144
+ },
145
+ "required": false,
146
+ "description": ""
147
+ },
148
+ "locale": {
149
+ "defaultValue": {
150
+ "value": "'en'",
151
+ "computed": false
152
+ },
153
+ "type": {
154
+ "name": "string"
155
+ },
156
+ "required": false,
157
+ "description": ""
158
+ },
159
+ "isEditable": {
160
+ "defaultValue": {
161
+ "value": "false",
162
+ "computed": false
163
+ },
164
+ "type": {
165
+ "name": "bool"
166
+ },
167
+ "required": false,
168
+ "description": ""
169
+ },
170
+ "dataState": {
171
+ "defaultValue": {
172
+ "value": "null",
173
+ "computed": false
174
+ },
175
+ "required": false
176
+ },
177
+ "values": {
178
+ "defaultValue": {
179
+ "value": "null",
180
+ "computed": false
181
+ },
182
+ "required": false
183
+ },
184
+ "fontSize": {
185
+ "defaultValue": {
186
+ "value": "DEFAULT_FONT_SIZE",
187
+ "computed": true
188
+ },
189
+ "required": false
190
+ },
191
+ "customFormatter": {
192
+ "defaultValue": {
193
+ "value": "null",
194
+ "computed": false
195
+ },
196
+ "required": false
197
+ },
198
+ "isNumberValueCompact": {
199
+ "defaultValue": {
200
+ "value": "false",
201
+ "computed": false
202
+ },
203
+ "required": false
204
+ },
205
+ "testId": {
206
+ "defaultValue": {
207
+ "value": "'ValueContent'",
208
+ "computed": false
209
+ },
210
+ "required": false
211
+ },
212
+ "onAttributeClick": {
213
+ "defaultValue": {
214
+ "value": "null",
215
+ "computed": false
216
+ },
217
+ "required": false
218
+ },
219
+ "size": {
220
+ "defaultValue": {
221
+ "value": "CARD_SIZES.MEDIUM",
222
+ "computed": true
223
+ },
224
+ "required": false
225
+ }
226
+ },
227
+ "composes": ["../../constants/CardPropTypes"]
228
+ };
229
+
230
+ export default ValueContent;
@@ -29,7 +29,8 @@ var propTypes = {
29
29
 
30
30
  /** callback to trigger further action when clicking the value */
31
31
  onClick: PropTypes.func,
32
- dataSourceId: PropTypes.string.isRequired
32
+ dataSourceId: PropTypes.string.isRequired,
33
+ measurementUnitLabel: PropTypes.string
33
34
  };
34
35
  var defaultProps = {
35
36
  layout: CARD_LAYOUTS.HORIZONTAL,
@@ -38,7 +39,8 @@ var defaultProps = {
38
39
  locale: 'en',
39
40
  customFormatter: null,
40
41
  testId: 'value',
41
- onClick: null
42
+ onClick: null,
43
+ measurementUnitLabel: null
42
44
  };
43
45
  /**
44
46
  * This components job is determining how to render different kinds of card values.
@@ -57,7 +59,8 @@ var ValueRenderer = function ValueRenderer(_ref) {
57
59
  isNumberValueCompact = _ref.isNumberValueCompact,
58
60
  testId = _ref.testId,
59
61
  _onClick = _ref.onClick,
60
- dataSourceId = _ref.dataSourceId;
62
+ dataSourceId = _ref.dataSourceId,
63
+ measurementUnitLabel = _ref.measurementUnitLabel;
61
64
  var renderValue = value;
62
65
 
63
66
  if (typeof value === 'boolean') {
@@ -82,7 +85,7 @@ var ValueRenderer = function ValueRenderer(_ref) {
82
85
  // otherwise, trucate the first line
83
86
  '--value-renderer-max-lines': fontSize < 20 ? 2 : 1
84
87
  },
85
- title: renderValue
88
+ title: measurementUnitLabel ? /*#__PURE__*/React__default.createElement("div", null, renderValue, " ", measurementUnitLabel) : renderValue
86
89
  };
87
90
  return /*#__PURE__*/React__default.createElement("div", {
88
91
  className: "".concat(BASE_CLASS_NAME, "__value-renderer--wrapper")
@@ -94,7 +97,11 @@ var ValueRenderer = function ValueRenderer(_ref) {
94
97
  });
95
98
  },
96
99
  kind: "ghost"
97
- }), renderValue) : /*#__PURE__*/React__default.createElement("span", commonProps, renderValue));
100
+ }), measurementUnitLabel ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderValue, /*#__PURE__*/React__default.createElement("span", {
101
+ className: "".concat(BASE_CLASS_NAME, "__value-renderer--value--measurement-unit")
102
+ }, measurementUnitLabel)) : renderValue) : /*#__PURE__*/React__default.createElement("span", commonProps, measurementUnitLabel ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderValue, /*#__PURE__*/React__default.createElement("span", {
103
+ className: "".concat(BASE_CLASS_NAME, "__value-renderer--value--measurement-unit")
104
+ }, measurementUnitLabel)) : renderValue));
98
105
  };
99
106
 
100
107
  ValueRenderer.propTypes = propTypes;
@@ -183,6 +190,17 @@ ValueRenderer.__docgenInfo = {
183
190
  "required": false,
184
191
  "description": "callback to trigger further action when clicking the value"
185
192
  },
193
+ "measurementUnitLabel": {
194
+ "defaultValue": {
195
+ "value": "null",
196
+ "computed": false
197
+ },
198
+ "type": {
199
+ "name": "string"
200
+ },
201
+ "required": false,
202
+ "description": ""
203
+ },
186
204
  "value": {
187
205
  "type": {
188
206
  "name": "any"
@@ -57,7 +57,7 @@ var DashboardColumnsPropTypes = PropTypes.shape({
57
57
  sm: PropTypes.number,
58
58
  xs: PropTypes.number
59
59
  });
60
- var ValueCardPropTypes = {
60
+ var ValueContentPropTypes = {
61
61
  content: PropTypes.shape({
62
62
  attributes: PropTypes.arrayOf(AttributePropTypes).isRequired
63
63
  }),
@@ -826,4 +826,4 @@ var CardPropTypes = {
826
826
  })
827
827
  };
828
828
 
829
- export { AttributePropTypes, BarChartCardPropTypes, CHART_COLORS, CardDimensionPropTypes, CardDimensionsPropTypes, CardPropTypes, CardSizesToDimensionsPropTypes, ComboChartPropTypes, DATE_PICKER_OPTIONS, DashboardBreakpointsPropTypes, DashboardColumnsPropTypes, DashboardLayoutPropTypes, GaugeCardPropTypes, ImageCardPropTypes, ImageCardValuesPropType, MapCardPropTypes, MapControlPropType, PieCardPropTypes, RowHeightPropTypes, TableCardPropTypes, TimeRangeOptionsPropTypes, TruncationPropTypes, ValueCardPropTypes, ZoomBarPropTypes };
829
+ export { AttributePropTypes, BarChartCardPropTypes, CHART_COLORS, CardDimensionPropTypes, CardDimensionsPropTypes, CardPropTypes, CardSizesToDimensionsPropTypes, ComboChartPropTypes, DATE_PICKER_OPTIONS, DashboardBreakpointsPropTypes, DashboardColumnsPropTypes, DashboardLayoutPropTypes, GaugeCardPropTypes, ImageCardPropTypes, ImageCardValuesPropType, MapCardPropTypes, MapControlPropType, PieCardPropTypes, RowHeightPropTypes, TableCardPropTypes, TimeRangeOptionsPropTypes, TruncationPropTypes, ValueContentPropTypes, ZoomBarPropTypes };