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.
- package/CHANGELOG.md +32 -0
- package/css/carbon-addons-iot-react.css +11 -1
- package/css/carbon-addons-iot-react.css.map +1 -1
- package/es/components/Card/DataStateRenderer.js +5 -5
- package/es/components/ReadOnlyValue/ReadOnlyValue.js +109 -0
- package/es/components/ValueCard/Attribute.js +32 -3
- package/es/components/ValueCard/ValueCard.js +24 -44
- package/es/components/ValueCard/ValueContent.js +230 -0
- package/es/components/ValueCard/ValueRenderer.js +23 -5
- package/es/constants/CardPropTypes.js +2 -2
- package/es/index.js +2 -0
- package/lib/components/Card/DataStateRenderer.js +4 -4
- package/lib/components/ReadOnlyValue/ReadOnlyValue.js +118 -0
- package/lib/components/ValueCard/Attribute.js +32 -3
- package/lib/components/ValueCard/ValueCard.js +22 -42
- package/lib/components/ValueCard/ValueContent.js +240 -0
- package/lib/components/ValueCard/ValueRenderer.js +23 -5
- package/lib/constants/CardPropTypes.js +2 -2
- package/lib/css/carbon-addons-iot-react.css +11 -1
- package/lib/css/carbon-addons-iot-react.css.map +1 -1
- package/lib/index.js +4 -0
- package/lib/scss/components/Card/_card.scss +1 -1
- package/lib/scss/components/ValueCard/_attribute.scss +3 -0
- package/lib/scss/components/ValueCard/_value-renderer.scss +4 -0
- package/package.json +2 -2
- package/scss/components/Card/_card.scss +1 -1
- package/scss/components/ValueCard/_attribute.scss +3 -0
- package/scss/components/ValueCard/_value-renderer.scss +4 -0
- package/umd/carbon-addons-iot-react.js +1632 -1292
package/es/index.js
CHANGED
|
@@ -53,6 +53,7 @@ export { default as suiteHeaderData } from './components/SuiteHeader/util/suiteH
|
|
|
53
53
|
export { default as useUiResources } from './components/SuiteHeader/hooks/useUiResources.js';
|
|
54
54
|
export { default as uiresources } from './components/SuiteHeader/util/uiresources.js';
|
|
55
55
|
export { default as Walkme } from './components/Walkme/Walkme.js';
|
|
56
|
+
export { default as ReadOnlyValue } from './components/ReadOnlyValue/ReadOnlyValue.js';
|
|
56
57
|
export { default as Dashboard } from './components/Dashboard/Dashboard.js';
|
|
57
58
|
export { default as DashboardHeader } from './components/Dashboard/DashboardHeader.js';
|
|
58
59
|
export { default as DashboardGrid } from './components/Dashboard/DashboardGrid.js';
|
|
@@ -68,6 +69,7 @@ export { default as ImageCard } from './components/ImageCard/ImageCard.js';
|
|
|
68
69
|
export { default as TableCard } from './components/TableCard/TableCard.js';
|
|
69
70
|
export { default as GaugeCard } from './components/GaugeCard/GaugeCard.js';
|
|
70
71
|
export { DragAndDrop } from './utils/DragAndDropUtils.js';
|
|
72
|
+
export { default as ValueContent } from './components/ValueCard/ValueContent.js';
|
|
71
73
|
export { default as ListCard } from './components/ListCard/ListCard.js';
|
|
72
74
|
export { default as PageWizard } from './components/PageWizard/PageWizard.js';
|
|
73
75
|
export { default as PageWizardStep } from './components/PageWizard/PageWizardStep/PageWizardStep.js';
|
|
@@ -35,7 +35,7 @@ var TooltipContent = function TooltipContent(_ref) {
|
|
|
35
35
|
}, label), /*#__PURE__*/React__default['default'].createElement("p", null, description), extraTooltipText && /*#__PURE__*/React__default['default'].createElement("p", null, extraTooltipText), learnMoreElement);
|
|
36
36
|
};
|
|
37
37
|
TooltipContent.propTypes = {
|
|
38
|
-
tooltipContent: CardPropTypes.
|
|
38
|
+
tooltipContent: CardPropTypes.ValueContentPropTypes.dataState.isRequired
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
var DataStateRenderer = function DataStateRenderer(_ref2) {
|
|
@@ -105,7 +105,7 @@ var DataStateRenderer = function DataStateRenderer(_ref2) {
|
|
|
105
105
|
DataStateRenderer.propTypes = {
|
|
106
106
|
size: CardPropTypes.CardPropTypes.size,
|
|
107
107
|
id: CardPropTypes.CardPropTypes.id,
|
|
108
|
-
dataState: CardPropTypes.
|
|
108
|
+
dataState: CardPropTypes.ValueContentPropTypes.dataState.isRequired
|
|
109
109
|
};
|
|
110
110
|
DataStateRenderer.defaultProps = {
|
|
111
111
|
size: LayoutConstants.CARD_SIZES.MEDIUM,
|
|
@@ -143,7 +143,7 @@ DataStateRenderer.__docgenInfo = {
|
|
|
143
143
|
"dataState": {
|
|
144
144
|
"type": {
|
|
145
145
|
"name": "custom",
|
|
146
|
-
"raw": "
|
|
146
|
+
"raw": "ValueContentPropTypes.dataState.isRequired"
|
|
147
147
|
},
|
|
148
148
|
"required": false,
|
|
149
149
|
"description": ""
|
|
@@ -158,7 +158,7 @@ TooltipContent.__docgenInfo = {
|
|
|
158
158
|
"tooltipContent": {
|
|
159
159
|
"type": {
|
|
160
160
|
"name": "custom",
|
|
161
|
-
"raw": "
|
|
161
|
+
"raw": "ValueContentPropTypes.dataState.isRequired"
|
|
162
162
|
},
|
|
163
163
|
"required": false,
|
|
164
164
|
"description": ""
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var PropTypes = require('prop-types');
|
|
6
|
+
var classnames = require('classnames');
|
|
7
|
+
var Settings = require('../../constants/Settings.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
14
|
+
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
15
|
+
|
|
16
|
+
var iotPrefix = Settings.settings.iotPrefix;
|
|
17
|
+
var propTypes = {
|
|
18
|
+
type: PropTypes__default['default'].oneOf(['stacked', 'inline', 'inline_small']),
|
|
19
|
+
label: PropTypes__default['default'].string,
|
|
20
|
+
value: PropTypes__default['default'].string,
|
|
21
|
+
testId: PropTypes__default['default'].string
|
|
22
|
+
};
|
|
23
|
+
var defaultProps = {
|
|
24
|
+
type: 'stacked',
|
|
25
|
+
label: '',
|
|
26
|
+
value: '',
|
|
27
|
+
testId: 'read-only-value'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var ReadOnlyValue = function ReadOnlyValue(_ref) {
|
|
31
|
+
var _classnames;
|
|
32
|
+
|
|
33
|
+
var type = _ref.type,
|
|
34
|
+
label = _ref.label,
|
|
35
|
+
value = _ref.value,
|
|
36
|
+
className = _ref.className,
|
|
37
|
+
testId = _ref.testId;
|
|
38
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
39
|
+
"data-testid": testId,
|
|
40
|
+
className: classnames__default['default'](className, "".concat(iotPrefix, "--read-only-value"), (_classnames = {}, _defineProperty__default['default'](_classnames, "".concat(iotPrefix, "--read-only-value__inline"), type === 'inline' || type === 'inline_small'), _defineProperty__default['default'](_classnames, "".concat(iotPrefix, "--read-only-value__inline_small"), type === 'inline_small'), _classnames))
|
|
41
|
+
}, /*#__PURE__*/React__default['default'].createElement("label", {
|
|
42
|
+
"data-testid": "".concat(testId, "--label"),
|
|
43
|
+
htmlFor: "readonly-".concat(label)
|
|
44
|
+
}, label, /*#__PURE__*/React__default['default'].createElement("textarea", {
|
|
45
|
+
"data-testid": "".concat(testId, "--value"),
|
|
46
|
+
type: "text",
|
|
47
|
+
id: "readonly-".concat(label),
|
|
48
|
+
name: value,
|
|
49
|
+
value: value,
|
|
50
|
+
readOnly: true
|
|
51
|
+
})));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
ReadOnlyValue.propTypes = propTypes;
|
|
55
|
+
ReadOnlyValue.defaultProps = defaultProps;
|
|
56
|
+
ReadOnlyValue.__docgenInfo = {
|
|
57
|
+
"description": "",
|
|
58
|
+
"methods": [],
|
|
59
|
+
"displayName": "ReadOnlyValue",
|
|
60
|
+
"props": {
|
|
61
|
+
"type": {
|
|
62
|
+
"defaultValue": {
|
|
63
|
+
"value": "'stacked'",
|
|
64
|
+
"computed": false
|
|
65
|
+
},
|
|
66
|
+
"type": {
|
|
67
|
+
"name": "enum",
|
|
68
|
+
"value": [{
|
|
69
|
+
"value": "'stacked'",
|
|
70
|
+
"computed": false
|
|
71
|
+
}, {
|
|
72
|
+
"value": "'inline'",
|
|
73
|
+
"computed": false
|
|
74
|
+
}, {
|
|
75
|
+
"value": "'inline_small'",
|
|
76
|
+
"computed": false
|
|
77
|
+
}]
|
|
78
|
+
},
|
|
79
|
+
"required": false,
|
|
80
|
+
"description": ""
|
|
81
|
+
},
|
|
82
|
+
"label": {
|
|
83
|
+
"defaultValue": {
|
|
84
|
+
"value": "''",
|
|
85
|
+
"computed": false
|
|
86
|
+
},
|
|
87
|
+
"type": {
|
|
88
|
+
"name": "string"
|
|
89
|
+
},
|
|
90
|
+
"required": false,
|
|
91
|
+
"description": ""
|
|
92
|
+
},
|
|
93
|
+
"value": {
|
|
94
|
+
"defaultValue": {
|
|
95
|
+
"value": "''",
|
|
96
|
+
"computed": false
|
|
97
|
+
},
|
|
98
|
+
"type": {
|
|
99
|
+
"name": "string"
|
|
100
|
+
},
|
|
101
|
+
"required": false,
|
|
102
|
+
"description": ""
|
|
103
|
+
},
|
|
104
|
+
"testId": {
|
|
105
|
+
"defaultValue": {
|
|
106
|
+
"value": "'read-only-value'",
|
|
107
|
+
"computed": false
|
|
108
|
+
},
|
|
109
|
+
"type": {
|
|
110
|
+
"name": "string"
|
|
111
|
+
},
|
|
112
|
+
"required": false,
|
|
113
|
+
"description": ""
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
module.exports = ReadOnlyValue;
|
|
@@ -15,6 +15,7 @@ var useMatchingThreshold = require('../../hooks/useMatchingThreshold.js');
|
|
|
15
15
|
var ValueRenderer = require('./ValueRenderer.js');
|
|
16
16
|
var UnitRenderer = require('./UnitRenderer.js');
|
|
17
17
|
var valueCardUtils = require('./valueCardUtils.js');
|
|
18
|
+
var carbonComponentsReact = require('carbon-components-react');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
21
|
|
|
@@ -28,6 +29,7 @@ var propTypes = {
|
|
|
28
29
|
label: PropTypes__default['default'].string,
|
|
29
30
|
unit: PropTypes__default['default'].string,
|
|
30
31
|
dataSourceId: PropTypes__default['default'].string,
|
|
32
|
+
measurementUnitLabel: PropTypes__default['default'].string,
|
|
31
33
|
// decimal precision
|
|
32
34
|
precision: PropTypes__default['default'].number,
|
|
33
35
|
thresholds: PropTypes__default['default'].arrayOf(PropTypes__default['default'].shape({
|
|
@@ -47,7 +49,9 @@ var propTypes = {
|
|
|
47
49
|
secondaryValue: PropTypes__default['default'].shape({
|
|
48
50
|
color: PropTypes__default['default'].string,
|
|
49
51
|
trend: PropTypes__default['default'].oneOf(['up', 'down']),
|
|
50
|
-
value: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].bool, PropTypes__default['default'].number])
|
|
52
|
+
value: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].bool, PropTypes__default['default'].number]),
|
|
53
|
+
href: PropTypes__default['default'].string,
|
|
54
|
+
onClick: PropTypes__default['default'].func
|
|
51
55
|
}),
|
|
52
56
|
value: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].bool, PropTypes__default['default'].number]),
|
|
53
57
|
fontSize: PropTypes__default['default'].number.isRequired,
|
|
@@ -88,6 +92,7 @@ var Attribute = function Attribute(_ref) {
|
|
|
88
92
|
thresholds = _ref$attribute.thresholds,
|
|
89
93
|
precision = _ref$attribute.precision,
|
|
90
94
|
dataSourceId = _ref$attribute.dataSourceId,
|
|
95
|
+
measurementUnitLabel = _ref$attribute.measurementUnitLabel,
|
|
91
96
|
attributeCount = _ref.attributeCount,
|
|
92
97
|
customFormatter = _ref.customFormatter,
|
|
93
98
|
isEditable = _ref.isEditable,
|
|
@@ -140,6 +145,7 @@ var Attribute = function Attribute(_ref) {
|
|
|
140
145
|
isNumberValueCompact: isNumberValueCompact,
|
|
141
146
|
testId: "".concat(testId, "-value"),
|
|
142
147
|
dataSourceId: dataSourceId,
|
|
148
|
+
measurementUnitLabel: measurementUnitLabel,
|
|
143
149
|
onClick: onValueClick
|
|
144
150
|
}), /*#__PURE__*/React__default['default'].createElement(UnitRenderer, {
|
|
145
151
|
unit: unit,
|
|
@@ -150,7 +156,7 @@ var Attribute = function Attribute(_ref) {
|
|
|
150
156
|
style: {
|
|
151
157
|
'--secondary-value-color': colors.gray60
|
|
152
158
|
}
|
|
153
|
-
}, secondaryValue.trend
|
|
159
|
+
}, secondaryValue.trend === 'up' ? /*#__PURE__*/React__default['default'].createElement(iconsReact.CaretUp16, {
|
|
154
160
|
className: "".concat(BEM_BASE, "_trend-icon"),
|
|
155
161
|
"aria-label": "trending up",
|
|
156
162
|
"data-testid": "".concat(testId, "-trending-up"),
|
|
@@ -160,7 +166,18 @@ var Attribute = function Attribute(_ref) {
|
|
|
160
166
|
"aria-label": "trending down",
|
|
161
167
|
"data-testid": "".concat(testId, "-trending-down"),
|
|
162
168
|
fill: secondaryValue.color || colors.gray60
|
|
163
|
-
}) : null, secondaryValue.
|
|
169
|
+
}) : null, secondaryValue.href || secondaryValue.onClick ? /*#__PURE__*/React__default['default'].createElement(carbonComponentsReact.Link, {
|
|
170
|
+
"data-testid": "".concat(testId, "-secondary-value--link"),
|
|
171
|
+
className: "".concat(BEM_BASE, "-secondary-value--link"),
|
|
172
|
+
href: secondaryValue === null || secondaryValue === void 0 ? void 0 : secondaryValue.href,
|
|
173
|
+
rel: "noopener noreferrer",
|
|
174
|
+
onClick: function onClick() {
|
|
175
|
+
return secondaryValue === null || secondaryValue === void 0 ? void 0 : secondaryValue.onClick({
|
|
176
|
+
dataSourceId: dataSourceId,
|
|
177
|
+
secondaryValue: secondaryValue
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}, secondaryValue.value) : secondaryValue.value) : null));
|
|
164
181
|
};
|
|
165
182
|
|
|
166
183
|
Attribute.propTypes = propTypes;
|
|
@@ -245,6 +262,14 @@ Attribute.__docgenInfo = {
|
|
|
245
262
|
"name": "number"
|
|
246
263
|
}],
|
|
247
264
|
"required": false
|
|
265
|
+
},
|
|
266
|
+
"href": {
|
|
267
|
+
"name": "string",
|
|
268
|
+
"required": false
|
|
269
|
+
},
|
|
270
|
+
"onClick": {
|
|
271
|
+
"name": "func",
|
|
272
|
+
"required": false
|
|
248
273
|
}
|
|
249
274
|
}
|
|
250
275
|
},
|
|
@@ -322,6 +347,10 @@ Attribute.__docgenInfo = {
|
|
|
322
347
|
"name": "string",
|
|
323
348
|
"required": false
|
|
324
349
|
},
|
|
350
|
+
"measurementUnitLabel": {
|
|
351
|
+
"name": "string",
|
|
352
|
+
"required": false
|
|
353
|
+
},
|
|
325
354
|
"precision": {
|
|
326
355
|
"name": "number",
|
|
327
356
|
"required": false
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('core-js/modules/es.object.keys.js');
|
|
4
|
-
require('core-js/modules/es.symbol.js');
|
|
5
|
-
require('core-js/modules/es.array.filter.js');
|
|
6
|
-
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
7
|
-
require('core-js/modules/web.dom-collections.for-each.js');
|
|
8
|
-
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
9
3
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
10
4
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
5
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
@@ -13,17 +7,20 @@ var isEmpty = require('../../node_modules/lodash-es/isEmpty.js');
|
|
|
13
7
|
require('core-js/modules/es.array.iterator.js');
|
|
14
8
|
require('core-js/modules/es.object.to-string.js');
|
|
15
9
|
require('core-js/modules/web.dom-collections.iterator.js');
|
|
16
|
-
require('core-js/modules/es.
|
|
17
|
-
require('core-js/modules/es.
|
|
10
|
+
require('core-js/modules/es.object.keys.js');
|
|
11
|
+
require('core-js/modules/es.symbol.js');
|
|
12
|
+
require('core-js/modules/es.array.filter.js');
|
|
13
|
+
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
14
|
+
require('core-js/modules/web.dom-collections.for-each.js');
|
|
15
|
+
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
18
16
|
var React = require('react');
|
|
19
17
|
var classnames = require('classnames');
|
|
20
18
|
var CardPropTypes = require('../../constants/CardPropTypes.js');
|
|
21
19
|
var LayoutConstants = require('../../constants/LayoutConstants.js');
|
|
22
20
|
var Card = require('../Card/Card.js');
|
|
23
21
|
var cardUtilityFunctions = require('../../utils/cardUtilityFunctions.js');
|
|
24
|
-
var DataStateRenderer = require('../Card/DataStateRenderer.js');
|
|
25
22
|
var valueCardUtils = require('./valueCardUtils.js');
|
|
26
|
-
var
|
|
23
|
+
var ValueContent = require('./ValueContent.js');
|
|
27
24
|
|
|
28
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
29
26
|
|
|
@@ -80,7 +77,6 @@ var ValueCard = function ValueCard(_ref) {
|
|
|
80
77
|
values = _handleCardVariables.values;
|
|
81
78
|
|
|
82
79
|
var layout = valueCardUtils.determineLayout(newSize);
|
|
83
|
-
var attributeCount = content.attributes.length;
|
|
84
80
|
return /*#__PURE__*/React__default['default'].createElement(Card['default'], _extends__default['default']({
|
|
85
81
|
title: title,
|
|
86
82
|
size: newSize,
|
|
@@ -95,41 +91,25 @@ var ValueCard = function ValueCard(_ref) {
|
|
|
95
91
|
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.
|
|
96
92
|
,
|
|
97
93
|
testId: testID || testId
|
|
98
|
-
}, others), /*#__PURE__*/React__default['default'].createElement(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return /*#__PURE__*/React__default['default'].createElement(Attribute, {
|
|
102
|
-
key: "fragment-".concat(attribute.dataSourceId, "-").concat(JSON.stringify(attribute.dataFilter || {})),
|
|
103
|
-
attribute: attribute,
|
|
104
|
-
attributeCount: attributeCount,
|
|
105
|
-
layout: layout,
|
|
106
|
-
locale: locale,
|
|
107
|
-
isEditable: isEditable,
|
|
108
|
-
title: title,
|
|
109
|
-
renderIconByName: others.renderIconByName,
|
|
110
|
-
value: // When the card is in the editable state, we will show a preview
|
|
111
|
-
isEditable ? valueCardUtils.PREVIEW_DATA : valueCardUtils.determineValue(attribute.dataSourceId, values, attribute.dataFilter),
|
|
112
|
-
secondaryValue: attribute.secondaryValue && _objectSpread(_objectSpread({}, attribute.secondaryValue), {}, {
|
|
113
|
-
// When the card is in the editable state, we will show a preview
|
|
114
|
-
value: isEditable ? valueCardUtils.PREVIEW_DATA : valueCardUtils.determineValue(attribute.secondaryValue.dataSourceId, values)
|
|
115
|
-
}),
|
|
116
|
-
customFormatter: customFormatter,
|
|
117
|
-
fontSize: fontSize,
|
|
118
|
-
isNumberValueCompact: isNumberValueCompact // TODO: remove deprecated 'testID' in v3.
|
|
119
|
-
,
|
|
120
|
-
testId: "".concat(testID || testId, "-attribute-").concat(index),
|
|
121
|
-
onValueClick: onAttributeClick
|
|
122
|
-
});
|
|
123
|
-
}) : /*#__PURE__*/React__default['default'].createElement(DataStateRenderer['default'], {
|
|
94
|
+
}, others), /*#__PURE__*/React__default['default'].createElement(ValueContent, _extends__default['default']({
|
|
95
|
+
id: id,
|
|
96
|
+
layout: layout,
|
|
124
97
|
dataState: dataState,
|
|
98
|
+
content: content,
|
|
99
|
+
locale: locale,
|
|
100
|
+
title: title,
|
|
101
|
+
customFormatter: customFormatter,
|
|
102
|
+
testId: testID || testId,
|
|
103
|
+
onAttributeClick: onAttributeClick,
|
|
125
104
|
size: newSize,
|
|
126
|
-
|
|
127
|
-
,
|
|
128
|
-
|
|
129
|
-
|
|
105
|
+
values: values,
|
|
106
|
+
isEditable: isEditable,
|
|
107
|
+
fontSize: fontSize,
|
|
108
|
+
isNumberValueCompact: isNumberValueCompact
|
|
109
|
+
}, others)), resizeHandles);
|
|
130
110
|
};
|
|
131
111
|
|
|
132
|
-
ValueCard.propTypes = _objectSpread(_objectSpread({}, CardPropTypes.CardPropTypes), CardPropTypes.
|
|
112
|
+
ValueCard.propTypes = _objectSpread(_objectSpread({}, CardPropTypes.CardPropTypes), CardPropTypes.ValueContentPropTypes);
|
|
133
113
|
ValueCard.defaultProps = {
|
|
134
114
|
size: LayoutConstants.CARD_SIZES.MEDIUM,
|
|
135
115
|
locale: 'en',
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/es.object.keys.js');
|
|
4
|
+
require('core-js/modules/es.symbol.js');
|
|
5
|
+
require('core-js/modules/es.array.filter.js');
|
|
6
|
+
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
7
|
+
require('core-js/modules/web.dom-collections.for-each.js');
|
|
8
|
+
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
9
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
+
require('core-js/modules/es.array.iterator.js');
|
|
12
|
+
require('core-js/modules/es.object.to-string.js');
|
|
13
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
14
|
+
require('core-js/modules/es.array.map.js');
|
|
15
|
+
require('core-js/modules/es.array.concat.js');
|
|
16
|
+
var React = require('react');
|
|
17
|
+
var PropTypes = require('prop-types');
|
|
18
|
+
var classnames = require('classnames');
|
|
19
|
+
var LayoutConstants = require('../../constants/LayoutConstants.js');
|
|
20
|
+
var CardPropTypes = require('../../constants/CardPropTypes.js');
|
|
21
|
+
var DataStateRenderer = require('../Card/DataStateRenderer.js');
|
|
22
|
+
var valueCardUtils = require('./valueCardUtils.js');
|
|
23
|
+
var Attribute = require('./Attribute.js');
|
|
24
|
+
|
|
25
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
26
|
+
|
|
27
|
+
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
28
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
29
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
30
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
31
|
+
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
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; }
|
|
34
|
+
|
|
35
|
+
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__default['default'](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; }
|
|
36
|
+
|
|
37
|
+
var propTypes = _objectSpread({
|
|
38
|
+
id: PropTypes__default['default'].string,
|
|
39
|
+
title: PropTypes__default['default'].string,
|
|
40
|
+
layout: PropTypes__default['default'].oneOf(['HORIZONTAL', 'VERTICAL']),
|
|
41
|
+
locale: PropTypes__default['default'].string,
|
|
42
|
+
isEditable: PropTypes__default['default'].bool
|
|
43
|
+
}, CardPropTypes.ValueContentPropTypes);
|
|
44
|
+
|
|
45
|
+
var defaultProps = {
|
|
46
|
+
id: 'valueContent-id',
|
|
47
|
+
title: '',
|
|
48
|
+
layout: 'VERTICAL',
|
|
49
|
+
locale: 'en',
|
|
50
|
+
isEditable: false,
|
|
51
|
+
dataState: null,
|
|
52
|
+
values: null,
|
|
53
|
+
fontSize: valueCardUtils.DEFAULT_FONT_SIZE,
|
|
54
|
+
customFormatter: null,
|
|
55
|
+
isNumberValueCompact: false,
|
|
56
|
+
testId: 'ValueContent',
|
|
57
|
+
onAttributeClick: null,
|
|
58
|
+
size: LayoutConstants.CARD_SIZES.MEDIUM
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
var ValueContent = function ValueContent(_ref) {
|
|
62
|
+
var id = _ref.id,
|
|
63
|
+
title = _ref.title,
|
|
64
|
+
content = _ref.content,
|
|
65
|
+
values = _ref.values,
|
|
66
|
+
layout = _ref.layout,
|
|
67
|
+
dataState = _ref.dataState,
|
|
68
|
+
locale = _ref.locale,
|
|
69
|
+
isEditable = _ref.isEditable,
|
|
70
|
+
customFormatter = _ref.customFormatter,
|
|
71
|
+
fontSize = _ref.fontSize,
|
|
72
|
+
isNumberValueCompact = _ref.isNumberValueCompact,
|
|
73
|
+
testId = _ref.testId,
|
|
74
|
+
onAttributeClick = _ref.onAttributeClick,
|
|
75
|
+
size = _ref.size,
|
|
76
|
+
others = _objectWithoutProperties__default['default'](_ref, ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "customFormatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"]);
|
|
77
|
+
|
|
78
|
+
var attributeCount = content.attributes.length;
|
|
79
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
80
|
+
className: classnames__default['default']("".concat(valueCardUtils.BASE_CLASS_NAME, "__content-wrapper"), _defineProperty__default['default']({}, "".concat(valueCardUtils.BASE_CLASS_NAME, "__content-wrapper--vertical"), layout === LayoutConstants.CARD_LAYOUTS.VERTICAL))
|
|
81
|
+
}, !dataState ? content.attributes.map(function (attribute, index) {
|
|
82
|
+
return /*#__PURE__*/React__default['default'].createElement(Attribute, {
|
|
83
|
+
key: "fragment-".concat(attribute.dataSourceId, "-").concat(JSON.stringify(attribute.dataFilter || {})),
|
|
84
|
+
attribute: attribute,
|
|
85
|
+
attributeCount: attributeCount,
|
|
86
|
+
layout: layout,
|
|
87
|
+
locale: locale,
|
|
88
|
+
isEditable: isEditable,
|
|
89
|
+
title: title,
|
|
90
|
+
renderIconByName: others.renderIconByName,
|
|
91
|
+
value: // When the card is in the editable state, we will show a preview
|
|
92
|
+
isEditable ? valueCardUtils.PREVIEW_DATA : valueCardUtils.determineValue(attribute.dataSourceId, values, attribute.dataFilter),
|
|
93
|
+
secondaryValue: attribute.secondaryValue && _objectSpread(_objectSpread({}, attribute.secondaryValue), {}, {
|
|
94
|
+
// When the card is in the editable state, we will show a preview
|
|
95
|
+
value: isEditable ? valueCardUtils.PREVIEW_DATA : valueCardUtils.determineValue(attribute.secondaryValue.dataSourceId, values)
|
|
96
|
+
}),
|
|
97
|
+
customFormatter: customFormatter,
|
|
98
|
+
fontSize: fontSize,
|
|
99
|
+
isNumberValueCompact: isNumberValueCompact,
|
|
100
|
+
testId: "".concat(testId, "-attribute-").concat(index),
|
|
101
|
+
onValueClick: onAttributeClick
|
|
102
|
+
});
|
|
103
|
+
}) : /*#__PURE__*/React__default['default'].createElement(DataStateRenderer['default'], {
|
|
104
|
+
dataState: dataState,
|
|
105
|
+
size: size,
|
|
106
|
+
id: id,
|
|
107
|
+
testId: "".concat(testId, "-data-state")
|
|
108
|
+
}));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
ValueContent.propTypes = propTypes;
|
|
112
|
+
ValueContent.defaultProps = defaultProps;
|
|
113
|
+
ValueContent.__docgenInfo = {
|
|
114
|
+
"description": "",
|
|
115
|
+
"methods": [],
|
|
116
|
+
"displayName": "ValueContent",
|
|
117
|
+
"props": {
|
|
118
|
+
"id": {
|
|
119
|
+
"defaultValue": {
|
|
120
|
+
"value": "'valueContent-id'",
|
|
121
|
+
"computed": false
|
|
122
|
+
},
|
|
123
|
+
"type": {
|
|
124
|
+
"name": "string"
|
|
125
|
+
},
|
|
126
|
+
"required": false,
|
|
127
|
+
"description": ""
|
|
128
|
+
},
|
|
129
|
+
"title": {
|
|
130
|
+
"defaultValue": {
|
|
131
|
+
"value": "''",
|
|
132
|
+
"computed": false
|
|
133
|
+
},
|
|
134
|
+
"type": {
|
|
135
|
+
"name": "string"
|
|
136
|
+
},
|
|
137
|
+
"required": false,
|
|
138
|
+
"description": ""
|
|
139
|
+
},
|
|
140
|
+
"layout": {
|
|
141
|
+
"defaultValue": {
|
|
142
|
+
"value": "'VERTICAL'",
|
|
143
|
+
"computed": false
|
|
144
|
+
},
|
|
145
|
+
"type": {
|
|
146
|
+
"name": "enum",
|
|
147
|
+
"value": [{
|
|
148
|
+
"value": "'HORIZONTAL'",
|
|
149
|
+
"computed": false
|
|
150
|
+
}, {
|
|
151
|
+
"value": "'VERTICAL'",
|
|
152
|
+
"computed": false
|
|
153
|
+
}]
|
|
154
|
+
},
|
|
155
|
+
"required": false,
|
|
156
|
+
"description": ""
|
|
157
|
+
},
|
|
158
|
+
"locale": {
|
|
159
|
+
"defaultValue": {
|
|
160
|
+
"value": "'en'",
|
|
161
|
+
"computed": false
|
|
162
|
+
},
|
|
163
|
+
"type": {
|
|
164
|
+
"name": "string"
|
|
165
|
+
},
|
|
166
|
+
"required": false,
|
|
167
|
+
"description": ""
|
|
168
|
+
},
|
|
169
|
+
"isEditable": {
|
|
170
|
+
"defaultValue": {
|
|
171
|
+
"value": "false",
|
|
172
|
+
"computed": false
|
|
173
|
+
},
|
|
174
|
+
"type": {
|
|
175
|
+
"name": "bool"
|
|
176
|
+
},
|
|
177
|
+
"required": false,
|
|
178
|
+
"description": ""
|
|
179
|
+
},
|
|
180
|
+
"dataState": {
|
|
181
|
+
"defaultValue": {
|
|
182
|
+
"value": "null",
|
|
183
|
+
"computed": false
|
|
184
|
+
},
|
|
185
|
+
"required": false
|
|
186
|
+
},
|
|
187
|
+
"values": {
|
|
188
|
+
"defaultValue": {
|
|
189
|
+
"value": "null",
|
|
190
|
+
"computed": false
|
|
191
|
+
},
|
|
192
|
+
"required": false
|
|
193
|
+
},
|
|
194
|
+
"fontSize": {
|
|
195
|
+
"defaultValue": {
|
|
196
|
+
"value": "DEFAULT_FONT_SIZE",
|
|
197
|
+
"computed": true
|
|
198
|
+
},
|
|
199
|
+
"required": false
|
|
200
|
+
},
|
|
201
|
+
"customFormatter": {
|
|
202
|
+
"defaultValue": {
|
|
203
|
+
"value": "null",
|
|
204
|
+
"computed": false
|
|
205
|
+
},
|
|
206
|
+
"required": false
|
|
207
|
+
},
|
|
208
|
+
"isNumberValueCompact": {
|
|
209
|
+
"defaultValue": {
|
|
210
|
+
"value": "false",
|
|
211
|
+
"computed": false
|
|
212
|
+
},
|
|
213
|
+
"required": false
|
|
214
|
+
},
|
|
215
|
+
"testId": {
|
|
216
|
+
"defaultValue": {
|
|
217
|
+
"value": "'ValueContent'",
|
|
218
|
+
"computed": false
|
|
219
|
+
},
|
|
220
|
+
"required": false
|
|
221
|
+
},
|
|
222
|
+
"onAttributeClick": {
|
|
223
|
+
"defaultValue": {
|
|
224
|
+
"value": "null",
|
|
225
|
+
"computed": false
|
|
226
|
+
},
|
|
227
|
+
"required": false
|
|
228
|
+
},
|
|
229
|
+
"size": {
|
|
230
|
+
"defaultValue": {
|
|
231
|
+
"value": "CARD_SIZES.MEDIUM",
|
|
232
|
+
"computed": true
|
|
233
|
+
},
|
|
234
|
+
"required": false
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
"composes": ["../../constants/CardPropTypes"]
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
module.exports = ValueContent;
|