carbon-addons-iot-react 2.149.0-next.45 → 2.149.0-next.48
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 +44 -0
- package/css/carbon-addons-iot-react.css +44 -0
- package/css/carbon-addons-iot-react.css.map +1 -1
- package/es/components/Card/Card.js +58 -11
- package/es/components/Card/CardTypeContent.js +162 -0
- package/es/components/MeterChartCard/MeterChartCard.js +126 -0
- package/es/components/SparklineChartCard/SparklineChartCard.js +120 -0
- package/es/components/StackedAreaChartCard/StackedAreaChartCard.js +125 -0
- package/es/constants/CardPropTypes.js +56 -1
- package/es/constants/ChartPropTypes.js +79 -0
- package/es/constants/LayoutConstants.js +4 -1
- package/es/index.js +4 -0
- package/es/utils/cardTypeUtilityFunctions.js +103 -0
- package/lib/components/Card/Card.js +57 -10
- package/lib/components/Card/CardTypeContent.js +172 -0
- package/lib/components/MeterChartCard/MeterChartCard.js +135 -0
- package/lib/components/SparklineChartCard/SparklineChartCard.js +129 -0
- package/lib/components/StackedAreaChartCard/StackedAreaChartCard.js +134 -0
- package/lib/constants/CardPropTypes.js +58 -0
- package/lib/constants/ChartPropTypes.js +91 -0
- package/lib/constants/LayoutConstants.js +4 -1
- package/lib/css/carbon-addons-iot-react.css +44 -0
- package/lib/css/carbon-addons-iot-react.css.map +1 -1
- package/lib/index.js +25 -0
- package/lib/scss/components/EmptyState/_emptystate.scss +1 -0
- package/lib/scss/components/MeterChartCard/_meter-chart-card.scss +14 -0
- package/lib/scss/components/SparklineChartCard/_sparkline-chart-card.scss +30 -0
- package/lib/scss/components/StackedAreaChartCard/_stacked-area-chart-card.scss +6 -0
- package/lib/scss/styles.scss +3 -0
- package/lib/utils/cardTypeUtilityFunctions.js +112 -0
- package/package.json +2 -2
- package/scss/components/EmptyState/_emptystate.scss +1 -0
- package/scss/components/MeterChartCard/_meter-chart-card.scss +14 -0
- package/scss/components/SparklineChartCard/_sparkline-chart-card.scss +30 -0
- package/scss/components/StackedAreaChartCard/_stacked-area-chart-card.scss +6 -0
- package/scss/styles.scss +3 -0
- package/umd/carbon-addons-iot-react.js +2296 -1566
|
@@ -8,6 +8,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
8
8
|
import _extends from '@babel/runtime/helpers/extends';
|
|
9
9
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
10
10
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
11
|
+
import isEmpty from '../../node_modules/lodash-es/isEmpty.js';
|
|
11
12
|
import 'core-js/modules/es.array.iterator.js';
|
|
12
13
|
import 'core-js/modules/es.object.to-string.js';
|
|
13
14
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
@@ -22,13 +23,14 @@ import PropTypes from 'prop-types';
|
|
|
22
23
|
import warning from 'warning';
|
|
23
24
|
import useVisibilityObserver from '../../hooks/useVisibilityObserver.js';
|
|
24
25
|
import { settings } from '../../constants/Settings.js';
|
|
25
|
-
import { CARD_SIZES, CARD_LAYOUTS, ROW_HEIGHT, DASHBOARD_SIZES, CARD_DIMENSIONS, DASHBOARD_BREAKPOINTS, DASHBOARD_COLUMNS, CARD_CONTENT_PADDING, CARD_TITLE_HEIGHT } from '../../constants/LayoutConstants.js';
|
|
26
|
+
import { CARD_SIZES, CARD_LAYOUTS, ROW_HEIGHT, DASHBOARD_SIZES, CARD_DIMENSIONS, DASHBOARD_BREAKPOINTS, DASHBOARD_COLUMNS, CARD_CONTENT_PADDING, CARD_TITLE_HEIGHT, CARD_TYPES } from '../../constants/LayoutConstants.js';
|
|
26
27
|
import { CardPropTypes } from '../../constants/CardPropTypes.js';
|
|
27
28
|
import { getCardMinSize, filterValidAttributes } from '../../utils/componentUtilityFunctions.js';
|
|
28
29
|
import { getUpdatedCardSize, useCardResizing } from '../../utils/cardUtilityFunctions.js';
|
|
29
30
|
import { parseValue } from '../DateTimePicker/dateTimePickerUtils.js';
|
|
30
31
|
import useSizeObserver from '../../hooks/useSizeObserver.js';
|
|
31
32
|
import EmptyState from '../EmptyState/EmptyState.js';
|
|
33
|
+
import CardTypeContent from './CardTypeContent.js';
|
|
32
34
|
import CardToolbar from './CardToolbar.js';
|
|
33
35
|
import { CardTitle } from './CardTitle.js';
|
|
34
36
|
|
|
@@ -103,8 +105,9 @@ var CardContent = function CardContent(props) {
|
|
|
103
105
|
isExpanded = props.isExpanded,
|
|
104
106
|
className = props.className,
|
|
105
107
|
testId = props.testId,
|
|
106
|
-
noPadding = props.noPadding
|
|
107
|
-
|
|
108
|
+
noPadding = props.noPadding,
|
|
109
|
+
hasFooter = props.hasFooter;
|
|
110
|
+
var height = "".concat(dimensions.y - CARD_TITLE_HEIGHT - (hasFooter ? '40' : '0'), "px");
|
|
108
111
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
109
112
|
"data-testid": testId,
|
|
110
113
|
style: _defineProperty({}, "--card-content-height", height),
|
|
@@ -159,13 +162,16 @@ CardContent.propTypes = {
|
|
|
159
162
|
y: PropTypes.number
|
|
160
163
|
}).isRequired,
|
|
161
164
|
isExpanded: CardPropTypes.isExpanded.isRequired,
|
|
162
|
-
noPadding: PropTypes.bool
|
|
165
|
+
noPadding: PropTypes.bool,
|
|
166
|
+
// define the actual card content depending if it has a footer or not
|
|
167
|
+
hasFooter: PropTypes.bool
|
|
163
168
|
};
|
|
164
169
|
CardContent.defaultProps = {
|
|
165
170
|
children: undefined,
|
|
166
171
|
className: '',
|
|
167
172
|
testId: 'card-content',
|
|
168
|
-
noPadding: false
|
|
173
|
+
noPadding: false,
|
|
174
|
+
hasFooter: false
|
|
169
175
|
};
|
|
170
176
|
({
|
|
171
177
|
children: PropTypes.node.isRequired
|
|
@@ -252,7 +258,10 @@ var defaultProps = {
|
|
|
252
258
|
footerContent: undefined,
|
|
253
259
|
dateTimeMask: 'YYYY-MM-DD HH:mm',
|
|
254
260
|
padding: 'default',
|
|
255
|
-
overrides: undefined
|
|
261
|
+
overrides: undefined,
|
|
262
|
+
type: null,
|
|
263
|
+
data: null,
|
|
264
|
+
content: null
|
|
256
265
|
};
|
|
257
266
|
/** Dumb component that renders the card basics */
|
|
258
267
|
|
|
@@ -266,7 +275,7 @@ var Card = function Card(props) {
|
|
|
266
275
|
hasTitleWrap = props.hasTitleWrap;
|
|
267
276
|
props.layout;
|
|
268
277
|
var isLoading = props.isLoading,
|
|
269
|
-
|
|
278
|
+
isEmptyProp = props.isEmpty,
|
|
270
279
|
isEditable = props.isEditable,
|
|
271
280
|
isExpanded = props.isExpanded,
|
|
272
281
|
isLazyLoading = props.isLazyLoading,
|
|
@@ -295,7 +304,10 @@ var Card = function Card(props) {
|
|
|
295
304
|
extraActions = props.extraActions,
|
|
296
305
|
padding = props.padding,
|
|
297
306
|
overrides = props.overrides,
|
|
298
|
-
|
|
307
|
+
type = props.type,
|
|
308
|
+
data = props.data,
|
|
309
|
+
content = props.content,
|
|
310
|
+
others = _objectWithoutProperties(props, ["size", "children", "title", "subtitle", "hasTitleWrap", "layout", "isLoading", "isEmpty", "isEditable", "isExpanded", "isLazyLoading", "isResizable", "resizeHandles", "error", "hideHeader", "id", "tooltip", "titleTextTooltip", "timeRange", "timeRangeOptions", "onCardAction", "availableActions", "renderExpandIcon", "breakpoint", "i18n", "style", "className", "values", "testID", "testId", "contentClassName", "footerContent", "dateTimeMask", "extraActions", "padding", "overrides", "type", "data", "content"]); // TODO: remove once final version of range prop is supported
|
|
299
311
|
|
|
300
312
|
|
|
301
313
|
useEffect(function () {
|
|
@@ -416,6 +428,9 @@ var Card = function Card(props) {
|
|
|
416
428
|
dateTimeMask: dateTimeMask,
|
|
417
429
|
extraActions: extraActions
|
|
418
430
|
}) : null;
|
|
431
|
+
var isSupportedType = type === CARD_TYPES.METER_CHART || type === CARD_TYPES.SPARKLINE_CHART || type === CARD_TYPES.STACKED_AREA_CHART; // validate if the data is empty or prop says it's empty
|
|
432
|
+
|
|
433
|
+
var isCardEmpty = isSupportedType && isEmpty(data) || isEmptyProp;
|
|
419
434
|
var card = /*#__PURE__*/React__default.createElement(CardWrapper, _extends({}, others, {
|
|
420
435
|
// you need all of these to support dynamic positioning during edit
|
|
421
436
|
ref: function ref(node) {
|
|
@@ -455,7 +470,8 @@ var Card = function Card(props) {
|
|
|
455
470
|
dimensions: dimensions,
|
|
456
471
|
isExpanded: isExpanded,
|
|
457
472
|
className: contentClassName,
|
|
458
|
-
noPadding: padding === 'none'
|
|
473
|
+
noPadding: padding === 'none',
|
|
474
|
+
hasFooter: !!CardFooter
|
|
459
475
|
}, !isVisible && isLazyLoading ? // if not visible don't show anything
|
|
460
476
|
'' : isLoading ? /*#__PURE__*/React__default.createElement("div", {
|
|
461
477
|
style: {
|
|
@@ -470,10 +486,20 @@ var Card = function Card(props) {
|
|
|
470
486
|
icon: isSmall ? '' : 'error',
|
|
471
487
|
title: strings.errorLoadingDataShortLabel,
|
|
472
488
|
body: error
|
|
473
|
-
}, overrides === null || overrides === void 0 ? void 0 : (_overrides$errorMessa2 = overrides.errorMessage) === null || _overrides$errorMessa2 === void 0 ? void 0 : _overrides$errorMessa2.props)) :
|
|
489
|
+
}, overrides === null || overrides === void 0 ? void 0 : (_overrides$errorMessa2 = overrides.errorMessage) === null || _overrides$errorMessa2 === void 0 ? void 0 : _overrides$errorMessa2.props)) : isCardEmpty && !isEditable ? /*#__PURE__*/React__default.createElement(ErrorMessage, _extends({
|
|
474
490
|
title: isSmallOrThin ? strings.noDataShortLabel : strings.noDataLabel,
|
|
475
491
|
icon: isSmall ? '' : 'empty'
|
|
476
|
-
}, overrides === null || overrides === void 0 ? void 0 : (_overrides$errorMessa3 = overrides.errorMessage) === null || _overrides$errorMessa3 === void 0 ? void 0 : _overrides$errorMessa3.props)) :
|
|
492
|
+
}, overrides === null || overrides === void 0 ? void 0 : (_overrides$errorMessa3 = overrides.errorMessage) === null || _overrides$errorMessa3 === void 0 ? void 0 : _overrides$errorMessa3.props)) : isSupportedType ?
|
|
493
|
+
/*#__PURE__*/
|
|
494
|
+
// render card content based on supported type
|
|
495
|
+
// TODO: remove deprecated testID prop in v3
|
|
496
|
+
React__default.createElement(CardTypeContent, {
|
|
497
|
+
testId: testID || testId,
|
|
498
|
+
isExpanded: isExpanded,
|
|
499
|
+
type: type,
|
|
500
|
+
data: data,
|
|
501
|
+
content: content
|
|
502
|
+
}) : Array.isArray(children) && typeof (children === null || children === void 0 ? void 0 : children[0]) === 'function' ? // pass the measured size down to the children if it's an render function
|
|
477
503
|
[// first option is a function
|
|
478
504
|
children === null || children === void 0 ? void 0 : children[0](getChildSize(cardSize, title), _objectSpread({
|
|
479
505
|
cardToolbar: cardToolbar
|
|
@@ -749,6 +775,27 @@ Card.__docgenInfo = {
|
|
|
749
775
|
"computed": true
|
|
750
776
|
},
|
|
751
777
|
"required": false
|
|
778
|
+
},
|
|
779
|
+
"type": {
|
|
780
|
+
"defaultValue": {
|
|
781
|
+
"value": "null",
|
|
782
|
+
"computed": false
|
|
783
|
+
},
|
|
784
|
+
"required": false
|
|
785
|
+
},
|
|
786
|
+
"data": {
|
|
787
|
+
"defaultValue": {
|
|
788
|
+
"value": "null",
|
|
789
|
+
"computed": false
|
|
790
|
+
},
|
|
791
|
+
"required": false
|
|
792
|
+
},
|
|
793
|
+
"content": {
|
|
794
|
+
"defaultValue": {
|
|
795
|
+
"value": "null",
|
|
796
|
+
"computed": false
|
|
797
|
+
},
|
|
798
|
+
"required": false
|
|
752
799
|
}
|
|
753
800
|
},
|
|
754
801
|
"composes": ["../../constants/CardPropTypes"]
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
+
import defaultsDeep from '../../node_modules/lodash-es/defaultsDeep.js';
|
|
4
|
+
import 'core-js/modules/es.array.concat.js';
|
|
5
|
+
import 'core-js/modules/es.array.map.js';
|
|
6
|
+
import 'core-js/modules/es.regexp.exec.js';
|
|
7
|
+
import 'core-js/modules/es.string.replace.js';
|
|
8
|
+
import React__default, { useRef, useState, useMemo, useEffect } from 'react';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import classnames from 'classnames';
|
|
11
|
+
import { CARD_TYPES } from '../../constants/LayoutConstants.js';
|
|
12
|
+
import { MeterChartPropTypes, SparklineChartPropTypes } from '../../constants/ChartPropTypes.js';
|
|
13
|
+
import { settings } from '../../constants/Settings.js';
|
|
14
|
+
import { getChartOptions } from '../../utils/cardTypeUtilityFunctions.js';
|
|
15
|
+
import { MeterChart, AreaChart, StackedAreaChart } from '@carbon/charts-react';
|
|
16
|
+
|
|
17
|
+
var iotPrefix = settings.iotPrefix;
|
|
18
|
+
var propTypes = {
|
|
19
|
+
testId: PropTypes.string,
|
|
20
|
+
isExpanded: PropTypes.bool,
|
|
21
|
+
type: PropTypes.oneOf([CARD_TYPES.METER_CHART, CARD_TYPES.SPARKLINE_CHART, CARD_TYPES.STACKED_AREA_CHART]).isRequired,
|
|
22
|
+
data: PropTypes.oneOf([MeterChartPropTypes.data, SparklineChartPropTypes.data]),
|
|
23
|
+
content: PropTypes.oneOf([MeterChartPropTypes.content, SparklineChartPropTypes.content])
|
|
24
|
+
};
|
|
25
|
+
var defaultProps = {
|
|
26
|
+
testId: 'cart-type-content',
|
|
27
|
+
isExpanded: false,
|
|
28
|
+
data: [],
|
|
29
|
+
content: null
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var CardTypeContent = function CardTypeContent(_ref) {
|
|
33
|
+
var _listRef$current2, _content$listContent, _contentWithDefaults$;
|
|
34
|
+
|
|
35
|
+
var testId = _ref.testId,
|
|
36
|
+
isExpanded = _ref.isExpanded,
|
|
37
|
+
type = _ref.type,
|
|
38
|
+
data = _ref.data,
|
|
39
|
+
content = _ref.content;
|
|
40
|
+
var listRef = useRef(null);
|
|
41
|
+
|
|
42
|
+
var _useState = useState(),
|
|
43
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
44
|
+
listHeight = _useState2[0],
|
|
45
|
+
setListHeight = _useState2[1];
|
|
46
|
+
|
|
47
|
+
var contentWithDefaults = useMemo(function () {
|
|
48
|
+
return defaultsDeep({}, content, defaultProps.content);
|
|
49
|
+
}, [content]);
|
|
50
|
+
var options = getChartOptions(type, data.length > 1, contentWithDefaults);
|
|
51
|
+
useEffect(function () {
|
|
52
|
+
var _listRef$current;
|
|
53
|
+
|
|
54
|
+
setListHeight((_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.clientHeight);
|
|
55
|
+
}, [(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.clientHeight]);
|
|
56
|
+
var Chart = type === CARD_TYPES.METER_CHART ? MeterChart : type === CARD_TYPES.SPARKLINE_CHART ? AreaChart : type === CARD_TYPES.STACKED_AREA_CHART ? StackedAreaChart : null;
|
|
57
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
58
|
+
className: classnames("".concat(iotPrefix, "--").concat(type.replaceAll('_', '-').toLowerCase(), "--wrapper"), _defineProperty({}, "".concat(iotPrefix, "--").concat(type.replaceAll('_', '-').toLowerCase(), "--wrapper__expanded"), isExpanded)),
|
|
59
|
+
style: {
|
|
60
|
+
'--card-list-height': ((_content$listContent = content.listContent) === null || _content$listContent === void 0 ? void 0 : _content$listContent.length) > 0 ? "".concat(listHeight, "px") : '0px'
|
|
61
|
+
}
|
|
62
|
+
}, /*#__PURE__*/React__default.createElement(Chart, {
|
|
63
|
+
data: data,
|
|
64
|
+
options: options
|
|
65
|
+
}), ((_contentWithDefaults$ = contentWithDefaults.listContent) === null || _contentWithDefaults$ === void 0 ? void 0 : _contentWithDefaults$.length) > 0 ? /*#__PURE__*/React__default.createElement("div", {
|
|
66
|
+
ref: listRef,
|
|
67
|
+
"data-testid": "".concat(testId, "-list")
|
|
68
|
+
}, contentWithDefaults.listContent.map(function (_ref2) {
|
|
69
|
+
var label = _ref2.label,
|
|
70
|
+
value = _ref2.value;
|
|
71
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
72
|
+
className: "".concat(iotPrefix, "--").concat(type.replace('_', '-').toLowerCase(), "--wrapper--list")
|
|
73
|
+
}, /*#__PURE__*/React__default.createElement("p", null, label), /*#__PURE__*/React__default.createElement("span", null, value));
|
|
74
|
+
})) : null);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
CardTypeContent.propTypes = propTypes;
|
|
78
|
+
CardTypeContent.defaultProps = defaultProps;
|
|
79
|
+
CardTypeContent.__docgenInfo = {
|
|
80
|
+
"description": "",
|
|
81
|
+
"methods": [],
|
|
82
|
+
"displayName": "CardTypeContent",
|
|
83
|
+
"props": {
|
|
84
|
+
"testId": {
|
|
85
|
+
"defaultValue": {
|
|
86
|
+
"value": "'cart-type-content'",
|
|
87
|
+
"computed": false
|
|
88
|
+
},
|
|
89
|
+
"type": {
|
|
90
|
+
"name": "string"
|
|
91
|
+
},
|
|
92
|
+
"required": false,
|
|
93
|
+
"description": ""
|
|
94
|
+
},
|
|
95
|
+
"isExpanded": {
|
|
96
|
+
"defaultValue": {
|
|
97
|
+
"value": "false",
|
|
98
|
+
"computed": false
|
|
99
|
+
},
|
|
100
|
+
"type": {
|
|
101
|
+
"name": "bool"
|
|
102
|
+
},
|
|
103
|
+
"required": false,
|
|
104
|
+
"description": ""
|
|
105
|
+
},
|
|
106
|
+
"data": {
|
|
107
|
+
"defaultValue": {
|
|
108
|
+
"value": "[]",
|
|
109
|
+
"computed": false
|
|
110
|
+
},
|
|
111
|
+
"type": {
|
|
112
|
+
"name": "enum",
|
|
113
|
+
"value": [{
|
|
114
|
+
"value": "MeterChartPropTypes.data",
|
|
115
|
+
"computed": true
|
|
116
|
+
}, {
|
|
117
|
+
"value": "SparklineChartPropTypes.data",
|
|
118
|
+
"computed": true
|
|
119
|
+
}]
|
|
120
|
+
},
|
|
121
|
+
"required": false,
|
|
122
|
+
"description": ""
|
|
123
|
+
},
|
|
124
|
+
"content": {
|
|
125
|
+
"defaultValue": {
|
|
126
|
+
"value": "null",
|
|
127
|
+
"computed": false
|
|
128
|
+
},
|
|
129
|
+
"type": {
|
|
130
|
+
"name": "enum",
|
|
131
|
+
"value": [{
|
|
132
|
+
"value": "MeterChartPropTypes.content",
|
|
133
|
+
"computed": true
|
|
134
|
+
}, {
|
|
135
|
+
"value": "SparklineChartPropTypes.content",
|
|
136
|
+
"computed": true
|
|
137
|
+
}]
|
|
138
|
+
},
|
|
139
|
+
"required": false,
|
|
140
|
+
"description": ""
|
|
141
|
+
},
|
|
142
|
+
"type": {
|
|
143
|
+
"type": {
|
|
144
|
+
"name": "enum",
|
|
145
|
+
"value": [{
|
|
146
|
+
"value": "CARD_TYPES.METER_CHART",
|
|
147
|
+
"computed": true
|
|
148
|
+
}, {
|
|
149
|
+
"value": "CARD_TYPES.SPARKLINE_CHART",
|
|
150
|
+
"computed": true
|
|
151
|
+
}, {
|
|
152
|
+
"value": "CARD_TYPES.STACKED_AREA_CHART",
|
|
153
|
+
"computed": true
|
|
154
|
+
}]
|
|
155
|
+
},
|
|
156
|
+
"required": true,
|
|
157
|
+
"description": ""
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export default CardTypeContent;
|
|
@@ -0,0 +1,126 @@
|
|
|
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 _extends from '@babel/runtime/helpers/extends';
|
|
8
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
9
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
10
|
+
import 'core-js/modules/es.array.iterator.js';
|
|
11
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
12
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
13
|
+
import React__default from 'react';
|
|
14
|
+
import { CARD_TYPES, CARD_SIZES } from '../../constants/LayoutConstants.js';
|
|
15
|
+
import { CardPropTypes, MeterChartCardPropTypes } from '../../constants/CardPropTypes.js';
|
|
16
|
+
import Card from '../Card/Card.js';
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
var propTypes = _objectSpread(_objectSpread({}, CardPropTypes), MeterChartCardPropTypes);
|
|
23
|
+
|
|
24
|
+
var defaultProps = {
|
|
25
|
+
size: CARD_SIZES.MEDIUMWIDE,
|
|
26
|
+
title: '',
|
|
27
|
+
content: {
|
|
28
|
+
peak: null,
|
|
29
|
+
meterTotal: 100,
|
|
30
|
+
meterUnit: 'Unit',
|
|
31
|
+
legendPosition: 'bottom',
|
|
32
|
+
color: {
|
|
33
|
+
pairing: {
|
|
34
|
+
option: 2
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
footerContent: null,
|
|
39
|
+
locale: 'en',
|
|
40
|
+
values: []
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var MeterChartCard = function MeterChartCard(_ref) {
|
|
44
|
+
var title = _ref.title,
|
|
45
|
+
content = _ref.content,
|
|
46
|
+
values = _ref.values,
|
|
47
|
+
size = _ref.size,
|
|
48
|
+
breakpoint = _ref.breakpoint,
|
|
49
|
+
footerContent = _ref.footerContent,
|
|
50
|
+
locale = _ref.locale,
|
|
51
|
+
isExpanded = _ref.isExpanded,
|
|
52
|
+
isLoading = _ref.isLoading,
|
|
53
|
+
testId = _ref.testId,
|
|
54
|
+
i18n = _ref.i18n,
|
|
55
|
+
others = _objectWithoutProperties(_ref, ["title", "content", "values", "size", "breakpoint", "footerContent", "locale", "isExpanded", "isLoading", "testId", "i18n"]);
|
|
56
|
+
|
|
57
|
+
return /*#__PURE__*/React__default.createElement(Card, _extends({
|
|
58
|
+
title: title,
|
|
59
|
+
size: size,
|
|
60
|
+
breakpoint: breakpoint,
|
|
61
|
+
locale: locale,
|
|
62
|
+
isExpanded: isExpanded,
|
|
63
|
+
isLoading: isLoading,
|
|
64
|
+
testId: testId,
|
|
65
|
+
footerContent: !isExpanded ? footerContent : null,
|
|
66
|
+
i18n: i18n,
|
|
67
|
+
data: values,
|
|
68
|
+
type: CARD_TYPES.METER_CHART,
|
|
69
|
+
content: content
|
|
70
|
+
}, others));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
MeterChartCard.propTypes = propTypes;
|
|
74
|
+
MeterChartCard.defaultProps = defaultProps;
|
|
75
|
+
MeterChartCard.__docgenInfo = {
|
|
76
|
+
"description": "",
|
|
77
|
+
"methods": [],
|
|
78
|
+
"displayName": "MeterChartCard",
|
|
79
|
+
"props": {
|
|
80
|
+
"size": {
|
|
81
|
+
"defaultValue": {
|
|
82
|
+
"value": "CARD_SIZES.MEDIUMWIDE",
|
|
83
|
+
"computed": true
|
|
84
|
+
},
|
|
85
|
+
"required": false
|
|
86
|
+
},
|
|
87
|
+
"title": {
|
|
88
|
+
"defaultValue": {
|
|
89
|
+
"value": "''",
|
|
90
|
+
"computed": false
|
|
91
|
+
},
|
|
92
|
+
"required": false
|
|
93
|
+
},
|
|
94
|
+
"content": {
|
|
95
|
+
"defaultValue": {
|
|
96
|
+
"value": "{\n peak: null,\n meterTotal: 100,\n meterUnit: 'Unit',\n legendPosition: 'bottom',\n color: {\n pairing: {\n option: 2,\n },\n },\n}",
|
|
97
|
+
"computed": false
|
|
98
|
+
},
|
|
99
|
+
"required": false
|
|
100
|
+
},
|
|
101
|
+
"footerContent": {
|
|
102
|
+
"defaultValue": {
|
|
103
|
+
"value": "null",
|
|
104
|
+
"computed": false
|
|
105
|
+
},
|
|
106
|
+
"required": false
|
|
107
|
+
},
|
|
108
|
+
"locale": {
|
|
109
|
+
"defaultValue": {
|
|
110
|
+
"value": "'en'",
|
|
111
|
+
"computed": false
|
|
112
|
+
},
|
|
113
|
+
"required": false
|
|
114
|
+
},
|
|
115
|
+
"values": {
|
|
116
|
+
"defaultValue": {
|
|
117
|
+
"value": "[]",
|
|
118
|
+
"computed": false
|
|
119
|
+
},
|
|
120
|
+
"required": false
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"composes": ["../../constants/CardPropTypes"]
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export default MeterChartCard;
|
|
@@ -0,0 +1,120 @@
|
|
|
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 _extends from '@babel/runtime/helpers/extends';
|
|
8
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
9
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
10
|
+
import 'core-js/modules/es.array.iterator.js';
|
|
11
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
12
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
13
|
+
import React__default from 'react';
|
|
14
|
+
import Card from '../Card/Card.js';
|
|
15
|
+
import { CARD_TYPES, CARD_SIZES } from '../../constants/LayoutConstants.js';
|
|
16
|
+
import { CardPropTypes, SparklineChartCardPropTypes } from '../../constants/CardPropTypes.js';
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
var propTypes = _objectSpread(_objectSpread({}, CardPropTypes), SparklineChartCardPropTypes);
|
|
23
|
+
|
|
24
|
+
var defaultProps = {
|
|
25
|
+
size: CARD_SIZES.MEDIUMWIDE,
|
|
26
|
+
title: null,
|
|
27
|
+
content: {
|
|
28
|
+
xLabel: 'x label',
|
|
29
|
+
yLabel: 'y label'
|
|
30
|
+
},
|
|
31
|
+
footerContent: null,
|
|
32
|
+
locale: 'en',
|
|
33
|
+
values: []
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var SparklineChartCard = function SparklineChartCard(_ref) {
|
|
37
|
+
var title = _ref.title,
|
|
38
|
+
values = _ref.values,
|
|
39
|
+
content = _ref.content,
|
|
40
|
+
size = _ref.size,
|
|
41
|
+
breakpoint = _ref.breakpoint,
|
|
42
|
+
locale = _ref.locale,
|
|
43
|
+
isLoading = _ref.isLoading,
|
|
44
|
+
testId = _ref.testId,
|
|
45
|
+
footerContent = _ref.footerContent,
|
|
46
|
+
isExpanded = _ref.isExpanded,
|
|
47
|
+
i18n = _ref.i18n;
|
|
48
|
+
_ref.style;
|
|
49
|
+
var others = _objectWithoutProperties(_ref, ["title", "values", "content", "size", "breakpoint", "locale", "isLoading", "testId", "footerContent", "isExpanded", "i18n", "style"]);
|
|
50
|
+
|
|
51
|
+
return /*#__PURE__*/React__default.createElement(Card, _extends({
|
|
52
|
+
title: title,
|
|
53
|
+
size: size,
|
|
54
|
+
breakpoint: breakpoint,
|
|
55
|
+
locale: locale,
|
|
56
|
+
isExpanded: isExpanded,
|
|
57
|
+
isLoading: isLoading,
|
|
58
|
+
testId: testId,
|
|
59
|
+
footerContent: !isExpanded ? footerContent : null,
|
|
60
|
+
i18n: i18n,
|
|
61
|
+
data: values,
|
|
62
|
+
type: CARD_TYPES.SPARKLINE_CHART,
|
|
63
|
+
content: content
|
|
64
|
+
}, others));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
SparklineChartCard.propTypes = propTypes;
|
|
68
|
+
SparklineChartCard.defaultProps = defaultProps;
|
|
69
|
+
SparklineChartCard.__docgenInfo = {
|
|
70
|
+
"description": "",
|
|
71
|
+
"methods": [],
|
|
72
|
+
"displayName": "SparklineChartCard",
|
|
73
|
+
"props": {
|
|
74
|
+
"size": {
|
|
75
|
+
"defaultValue": {
|
|
76
|
+
"value": "CARD_SIZES.MEDIUMWIDE",
|
|
77
|
+
"computed": true
|
|
78
|
+
},
|
|
79
|
+
"required": false
|
|
80
|
+
},
|
|
81
|
+
"title": {
|
|
82
|
+
"defaultValue": {
|
|
83
|
+
"value": "null",
|
|
84
|
+
"computed": false
|
|
85
|
+
},
|
|
86
|
+
"required": false
|
|
87
|
+
},
|
|
88
|
+
"content": {
|
|
89
|
+
"defaultValue": {
|
|
90
|
+
"value": "{\n xLabel: 'x label',\n yLabel: 'y label',\n}",
|
|
91
|
+
"computed": false
|
|
92
|
+
},
|
|
93
|
+
"required": false
|
|
94
|
+
},
|
|
95
|
+
"footerContent": {
|
|
96
|
+
"defaultValue": {
|
|
97
|
+
"value": "null",
|
|
98
|
+
"computed": false
|
|
99
|
+
},
|
|
100
|
+
"required": false
|
|
101
|
+
},
|
|
102
|
+
"locale": {
|
|
103
|
+
"defaultValue": {
|
|
104
|
+
"value": "'en'",
|
|
105
|
+
"computed": false
|
|
106
|
+
},
|
|
107
|
+
"required": false
|
|
108
|
+
},
|
|
109
|
+
"values": {
|
|
110
|
+
"defaultValue": {
|
|
111
|
+
"value": "[]",
|
|
112
|
+
"computed": false
|
|
113
|
+
},
|
|
114
|
+
"required": false
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"composes": ["../../constants/CardPropTypes"]
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export default SparklineChartCard;
|