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
|
@@ -0,0 +1,125 @@
|
|
|
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, StackedAreaChartCardPropTypes } 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), StackedAreaChartCardPropTypes);
|
|
23
|
+
|
|
24
|
+
var defaultProps = {
|
|
25
|
+
size: CARD_SIZES.MEDIUM,
|
|
26
|
+
title: null,
|
|
27
|
+
testId: 'stacked-area-chart-testId',
|
|
28
|
+
content: {
|
|
29
|
+
xLabel: 'x label',
|
|
30
|
+
yLabel: 'y label',
|
|
31
|
+
pairing: {
|
|
32
|
+
option: 1
|
|
33
|
+
},
|
|
34
|
+
legendPosition: 'bottom',
|
|
35
|
+
curve: 'curveMonotoneX'
|
|
36
|
+
},
|
|
37
|
+
locale: 'en',
|
|
38
|
+
values: []
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var StackedAreaChartCard = function StackedAreaChartCard(_ref) {
|
|
42
|
+
var title = _ref.title,
|
|
43
|
+
values = _ref.values,
|
|
44
|
+
content = _ref.content,
|
|
45
|
+
size = _ref.size,
|
|
46
|
+
breakpoint = _ref.breakpoint,
|
|
47
|
+
locale = _ref.locale,
|
|
48
|
+
isLoading = _ref.isLoading,
|
|
49
|
+
testId = _ref.testId,
|
|
50
|
+
footerContent = _ref.footerContent,
|
|
51
|
+
isExpanded = _ref.isExpanded,
|
|
52
|
+
i18n = _ref.i18n;
|
|
53
|
+
_ref.style;
|
|
54
|
+
var others = _objectWithoutProperties(_ref, ["title", "values", "content", "size", "breakpoint", "locale", "isLoading", "testId", "footerContent", "isExpanded", "i18n", "style"]);
|
|
55
|
+
|
|
56
|
+
return /*#__PURE__*/React__default.createElement(Card, _extends({
|
|
57
|
+
title: title,
|
|
58
|
+
size: size,
|
|
59
|
+
breakpoint: breakpoint,
|
|
60
|
+
locale: locale,
|
|
61
|
+
isExpanded: isExpanded,
|
|
62
|
+
isLoading: isLoading,
|
|
63
|
+
testId: testId,
|
|
64
|
+
footerContent: !isExpanded ? footerContent : null,
|
|
65
|
+
i18n: i18n,
|
|
66
|
+
data: values,
|
|
67
|
+
type: CARD_TYPES.STACKED_AREA_CHART,
|
|
68
|
+
content: content
|
|
69
|
+
}, others));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
StackedAreaChartCard.propTypes = propTypes;
|
|
73
|
+
StackedAreaChartCard.defaultProps = defaultProps;
|
|
74
|
+
StackedAreaChartCard.__docgenInfo = {
|
|
75
|
+
"description": "",
|
|
76
|
+
"methods": [],
|
|
77
|
+
"displayName": "StackedAreaChartCard",
|
|
78
|
+
"props": {
|
|
79
|
+
"size": {
|
|
80
|
+
"defaultValue": {
|
|
81
|
+
"value": "CARD_SIZES.MEDIUM",
|
|
82
|
+
"computed": true
|
|
83
|
+
},
|
|
84
|
+
"required": false
|
|
85
|
+
},
|
|
86
|
+
"title": {
|
|
87
|
+
"defaultValue": {
|
|
88
|
+
"value": "null",
|
|
89
|
+
"computed": false
|
|
90
|
+
},
|
|
91
|
+
"required": false
|
|
92
|
+
},
|
|
93
|
+
"testId": {
|
|
94
|
+
"defaultValue": {
|
|
95
|
+
"value": "'stacked-area-chart-testId'",
|
|
96
|
+
"computed": false
|
|
97
|
+
},
|
|
98
|
+
"required": false
|
|
99
|
+
},
|
|
100
|
+
"content": {
|
|
101
|
+
"defaultValue": {
|
|
102
|
+
"value": "{\n xLabel: 'x label',\n yLabel: 'y label',\n pairing: {\n option: 1,\n },\n legendPosition: 'bottom',\n curve: 'curveMonotoneX',\n}",
|
|
103
|
+
"computed": false
|
|
104
|
+
},
|
|
105
|
+
"required": false
|
|
106
|
+
},
|
|
107
|
+
"locale": {
|
|
108
|
+
"defaultValue": {
|
|
109
|
+
"value": "'en'",
|
|
110
|
+
"computed": false
|
|
111
|
+
},
|
|
112
|
+
"required": false
|
|
113
|
+
},
|
|
114
|
+
"values": {
|
|
115
|
+
"defaultValue": {
|
|
116
|
+
"value": "[]",
|
|
117
|
+
"computed": false
|
|
118
|
+
},
|
|
119
|
+
"required": false
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"composes": ["../../constants/CardPropTypes"]
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default StackedAreaChartCard;
|
|
@@ -13,6 +13,7 @@ import deprecate from '../internal/deprecate.js';
|
|
|
13
13
|
import { DateTimePickerDefaultValuePropTypes } from '../components/DateTimePicker/DateTimePickerV2.js';
|
|
14
14
|
import { CARD_DATA_STATE, CARD_SIZES, BAR_CHART_LAYOUTS, BAR_CHART_TYPES, LEGACY_CARD_SIZES, CARD_LAYOUTS, DASHBOARD_SIZES } from './LayoutConstants.js';
|
|
15
15
|
import { SvgPropType, OverridePropTypes, ButtonIconPropType } from './SharedPropTypes.js';
|
|
16
|
+
import { MeterChartPropTypes, SparklineChartPropTypes, StackedAreaChartPropTypes } from './ChartPropTypes.js';
|
|
16
17
|
|
|
17
18
|
var CHART_COLORS = [purple70, cyan50, teal70, magenta70, red50, red90, green60, blue80, magenta50, teal50, cyan90, purple50];
|
|
18
19
|
var AttributePropTypes = PropTypes.shape({
|
|
@@ -661,6 +662,60 @@ var MapCardPropTypes = {
|
|
|
661
662
|
/** the ref used needed by a drag and drop library like react-dnd. Is added to the map container element. */
|
|
662
663
|
dropRef: PropTypes.oneOfType([PropTypes.shape({}), PropTypes.func])
|
|
663
664
|
};
|
|
665
|
+
var MeterChartCardPropTypes = {
|
|
666
|
+
content: MeterChartPropTypes.content,
|
|
667
|
+
values: MeterChartPropTypes.data,
|
|
668
|
+
size: function size(props, propName, componentName) {
|
|
669
|
+
var error;
|
|
670
|
+
|
|
671
|
+
if (!Object.keys(CARD_SIZES).includes(props[propName])) {
|
|
672
|
+
error = new Error("`".concat(componentName, "` prop `").concat(propName, "` must be one of ").concat(Object.keys(CARD_SIZES).join(','), "."));
|
|
673
|
+
} // If the size
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
if (props[propName] === CARD_SIZES.SMALL || props[propName] === CARD_SIZES.SMALLWIDE || props[propName] === CARD_SIZES.SMALLFULL || props[propName] === CARD_SIZES.MEDIUMTHIN) {
|
|
677
|
+
error = new Error("Deprecation notice: `".concat(componentName, "` prop `").concat(propName, "` cannot be `").concat(props[propName], "` as the charts will not render correctly. Minimum size is `MEDIUM`"));
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
return error;
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
var SparklineChartCardPropTypes = {
|
|
684
|
+
content: SparklineChartPropTypes.content,
|
|
685
|
+
values: SparklineChartPropTypes.data,
|
|
686
|
+
size: function size(props, propName, componentName) {
|
|
687
|
+
var error;
|
|
688
|
+
|
|
689
|
+
if (!Object.keys(CARD_SIZES).includes(props[propName])) {
|
|
690
|
+
error = new Error("`".concat(componentName, "` prop `").concat(propName, "` must be one of ").concat(Object.keys(CARD_SIZES).join(','), "."));
|
|
691
|
+
} // If the size
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
if (props[propName] === CARD_SIZES.SMALL || props[propName] === CARD_SIZES.SMALLWIDE || props[propName] === CARD_SIZES.SMALLFULL || props[propName] === CARD_SIZES.MEDIUMTHIN) {
|
|
695
|
+
error = new Error("Deprecation notice: `".concat(componentName, "` prop `").concat(propName, "` cannot be `").concat(props[propName], "` as the charts will not render correctly. Minimum size is `MEDIUM`"));
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
return error;
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
var StackedAreaChartCardPropTypes = {
|
|
702
|
+
content: StackedAreaChartPropTypes.content,
|
|
703
|
+
values: StackedAreaChartPropTypes.data,
|
|
704
|
+
size: function size(props, propName, componentName) {
|
|
705
|
+
var error;
|
|
706
|
+
|
|
707
|
+
if (!Object.keys(CARD_SIZES).includes(props[propName])) {
|
|
708
|
+
error = new Error("`".concat(componentName, "` prop `").concat(propName, "` must be one of ").concat(Object.keys(CARD_SIZES).join(','), "."));
|
|
709
|
+
} // If the size
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
if (props[propName] === CARD_SIZES.SMALL || props[propName] === CARD_SIZES.SMALLWIDE || props[propName] === CARD_SIZES.SMALLFULL || props[propName] === CARD_SIZES.MEDIUMTHIN) {
|
|
713
|
+
error = new Error("Deprecation notice: `".concat(componentName, "` prop `").concat(propName, "` cannot be `").concat(props[propName], "` as the charts will not render correctly. Minimum size is `MEDIUM`"));
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
return error;
|
|
717
|
+
}
|
|
718
|
+
};
|
|
664
719
|
var DATE_PICKER_OPTIONS = {
|
|
665
720
|
ICON_ONLY: 'iconOnly',
|
|
666
721
|
FULL: 'full'
|
|
@@ -836,4 +891,4 @@ var CardPropTypes = {
|
|
|
836
891
|
})
|
|
837
892
|
};
|
|
838
893
|
|
|
839
|
-
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 };
|
|
894
|
+
export { AttributePropTypes, BarChartCardPropTypes, CHART_COLORS, CardDimensionPropTypes, CardDimensionsPropTypes, CardPropTypes, CardSizesToDimensionsPropTypes, ComboChartPropTypes, DATE_PICKER_OPTIONS, DashboardBreakpointsPropTypes, DashboardColumnsPropTypes, DashboardLayoutPropTypes, GaugeCardPropTypes, ImageCardPropTypes, ImageCardValuesPropType, MapCardPropTypes, MapControlPropType, MeterChartCardPropTypes, PieCardPropTypes, RowHeightPropTypes, SparklineChartCardPropTypes, StackedAreaChartCardPropTypes, TableCardPropTypes, TimeRangeOptionsPropTypes, TruncationPropTypes, ValueContentPropTypes, ZoomBarPropTypes };
|
|
@@ -0,0 +1,79 @@
|
|
|
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 _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
var ChartColorPropType = {
|
|
14
|
+
color: PropTypes.shape({
|
|
15
|
+
gradient: PropTypes.shape({
|
|
16
|
+
colors: PropTypes.arrayOf(PropTypes.string),
|
|
17
|
+
enabled: PropTypes.boolean
|
|
18
|
+
}),
|
|
19
|
+
pairing: PropTypes.shape({
|
|
20
|
+
numberOfVariants: PropTypes.number,
|
|
21
|
+
option: PropTypes.number
|
|
22
|
+
}),
|
|
23
|
+
scale: PropTypes.shape(PropTypes.any)
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
var MeterChartPropTypes = {
|
|
27
|
+
content: PropTypes.shape(_objectSpread({
|
|
28
|
+
peak: PropTypes.number,
|
|
29
|
+
meterTotal: PropTypes.number,
|
|
30
|
+
meterUnit: PropTypes.string,
|
|
31
|
+
legendPosition: PropTypes.string
|
|
32
|
+
}, ChartColorPropType)),
|
|
33
|
+
data: PropTypes.arrayOf(PropTypes.shape({
|
|
34
|
+
group: PropTypes.string,
|
|
35
|
+
value: PropTypes.number
|
|
36
|
+
}))
|
|
37
|
+
};
|
|
38
|
+
var SparklineChartPropTypes = {
|
|
39
|
+
content: PropTypes.shape(_objectSpread({
|
|
40
|
+
xLabel: PropTypes.string,
|
|
41
|
+
yLabel: PropTypes.string,
|
|
42
|
+
xProperty: PropTypes.string.isRequired,
|
|
43
|
+
yProperty: PropTypes.string.isRequired,
|
|
44
|
+
listContent: PropTypes.arrayOf(PropTypes.shape({
|
|
45
|
+
label: PropTypes.string,
|
|
46
|
+
value: PropTypes.string
|
|
47
|
+
}))
|
|
48
|
+
}, ChartColorPropType)),
|
|
49
|
+
data: PropTypes.arrayOf(PropTypes.shape({
|
|
50
|
+
group: PropTypes.string.isRequired
|
|
51
|
+
}))
|
|
52
|
+
};
|
|
53
|
+
var StackedAreaChartPropTypes = {
|
|
54
|
+
content: PropTypes.shape(_objectSpread({
|
|
55
|
+
xLabel: PropTypes.string,
|
|
56
|
+
yLabel: PropTypes.string,
|
|
57
|
+
xProperty: PropTypes.string.isRequired,
|
|
58
|
+
xThresholds: PropTypes.arrayOf(PropTypes.shape({
|
|
59
|
+
value: PropTypes.number.isRequired,
|
|
60
|
+
valueFormatter: PropTypes.func,
|
|
61
|
+
label: PropTypes.string,
|
|
62
|
+
fillColor: PropTypes.string
|
|
63
|
+
})),
|
|
64
|
+
yProperty: PropTypes.string.isRequired,
|
|
65
|
+
yThresholds: PropTypes.arrayOf(PropTypes.shape({
|
|
66
|
+
value: PropTypes.number.isRequired,
|
|
67
|
+
valueFormatter: PropTypes.func,
|
|
68
|
+
label: PropTypes.string,
|
|
69
|
+
fillColor: PropTypes.string
|
|
70
|
+
})),
|
|
71
|
+
curve: PropTypes.string,
|
|
72
|
+
legendPosition: PropTypes.oneOf(['bottom', 'left', 'right', 'top'])
|
|
73
|
+
}, ChartColorPropType)),
|
|
74
|
+
data: PropTypes.arrayOf(PropTypes.shape({
|
|
75
|
+
group: PropTypes.string.isRequired
|
|
76
|
+
}))
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export { ChartColorPropType, MeterChartPropTypes, SparklineChartPropTypes, StackedAreaChartPropTypes };
|
|
@@ -37,7 +37,10 @@ var CARD_TYPES = {
|
|
|
37
37
|
PIE: 'PIE',
|
|
38
38
|
TABLE: 'TABLE',
|
|
39
39
|
TIMESERIES: 'TIMESERIES',
|
|
40
|
-
VALUE: 'VALUE'
|
|
40
|
+
VALUE: 'VALUE',
|
|
41
|
+
METER_CHART: 'METER_CHART',
|
|
42
|
+
SPARKLINE_CHART: 'SPARKLINE_CHART',
|
|
43
|
+
STACKED_AREA_CHART: 'STACKED_AREA_CHART'
|
|
41
44
|
};
|
|
42
45
|
var CARD_ACTIONS = {
|
|
43
46
|
OPEN_EXPANDED_CARD: 'OPEN_EXPANDED_CARD',
|
package/es/index.js
CHANGED
|
@@ -70,6 +70,9 @@ export { default as TableCard } from './components/TableCard/TableCard.js';
|
|
|
70
70
|
export { default as GaugeCard } from './components/GaugeCard/GaugeCard.js';
|
|
71
71
|
export { DragAndDrop } from './utils/DragAndDropUtils.js';
|
|
72
72
|
export { default as ValueContent } from './components/ValueCard/ValueContent.js';
|
|
73
|
+
export { default as MeterChartCard } from './components/MeterChartCard/MeterChartCard.js';
|
|
74
|
+
export { default as SparklineChartCard } from './components/SparklineChartCard/SparklineChartCard.js';
|
|
75
|
+
export { default as StackedAreaChartCard } from './components/StackedAreaChartCard/StackedAreaChartCard.js';
|
|
73
76
|
export { default as ListCard } from './components/ListCard/ListCard.js';
|
|
74
77
|
export { default as PageWizard } from './components/PageWizard/PageWizard.js';
|
|
75
78
|
export { default as PageWizardStep } from './components/PageWizard/PageWizardStep/PageWizardStep.js';
|
|
@@ -138,3 +141,4 @@ export { default as EmptystateErrorIcon } from './icons/static/EmptyStateErrorIc
|
|
|
138
141
|
export { default as EmptystateNoresultsIcon } from './icons/static/EmptyStateNoResultsIcon.js';
|
|
139
142
|
export { default as EmptystateNotauthorizedIcon } from './icons/static/EmptyStateNotAuthorizedIcon.js';
|
|
140
143
|
export { default as EmptystateSuccessIcon } from './icons/static/EmptyStateSuccessIcon.js';
|
|
144
|
+
export { AreaChart, MeterChart, StackedAreaChart } from '@carbon/charts-react';
|
|
@@ -0,0 +1,103 @@
|
|
|
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 _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
8
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
9
|
+
import 'core-js/modules/es.array.concat.js';
|
|
10
|
+
import { CARD_TYPES } from '../constants/LayoutConstants.js';
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
var getChartOptions = function getChartOptions(type, hasData, content) {
|
|
16
|
+
var _content$status, _content$status2, _content$status3;
|
|
17
|
+
|
|
18
|
+
var basicOptionsObject = {
|
|
19
|
+
color: content.color,
|
|
20
|
+
animations: false,
|
|
21
|
+
accessibility: true,
|
|
22
|
+
toolbar: {
|
|
23
|
+
enabled: false
|
|
24
|
+
},
|
|
25
|
+
legend: {
|
|
26
|
+
position: content.legendPosition,
|
|
27
|
+
enabled: hasData,
|
|
28
|
+
truncation: content.truncation
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return type === CARD_TYPES.METER_CHART ? _objectSpread(_objectSpread({}, basicOptionsObject), {}, {
|
|
32
|
+
containerResizable: true,
|
|
33
|
+
meter: {
|
|
34
|
+
peak: content.peak,
|
|
35
|
+
proportional: {
|
|
36
|
+
total: content.meterTotal,
|
|
37
|
+
unit: content.meterUnit
|
|
38
|
+
},
|
|
39
|
+
status: {
|
|
40
|
+
ranges: [].concat(_toConsumableArray(content !== null && content !== void 0 && (_content$status = content.status) !== null && _content$status !== void 0 && _content$status.success ? [{
|
|
41
|
+
range: content.status.success,
|
|
42
|
+
status: 'success'
|
|
43
|
+
}] : []), _toConsumableArray(content !== null && content !== void 0 && (_content$status2 = content.status) !== null && _content$status2 !== void 0 && _content$status2.warning ? [{
|
|
44
|
+
range: content.status.warning,
|
|
45
|
+
status: 'warning'
|
|
46
|
+
}] : []), _toConsumableArray(content !== null && content !== void 0 && (_content$status3 = content.status) !== null && _content$status3 !== void 0 && _content$status3.danger ? [{
|
|
47
|
+
range: content.status.danger,
|
|
48
|
+
status: 'danger'
|
|
49
|
+
}] : []))
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}) : type === CARD_TYPES.SPARKLINE_CHART ? _objectSpread(_objectSpread({}, basicOptionsObject), {}, {
|
|
53
|
+
grid: {
|
|
54
|
+
x: {
|
|
55
|
+
enabled: false
|
|
56
|
+
},
|
|
57
|
+
y: {
|
|
58
|
+
enabled: false
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
axes: {
|
|
62
|
+
bottom: {
|
|
63
|
+
visible: false,
|
|
64
|
+
title: content.xLabel,
|
|
65
|
+
mapsTo: content.xProperty,
|
|
66
|
+
thresholds: content.xThresholds,
|
|
67
|
+
scaleType: 'time'
|
|
68
|
+
},
|
|
69
|
+
left: {
|
|
70
|
+
visible: false,
|
|
71
|
+
title: content.yLabel,
|
|
72
|
+
mapsTo: content.yProperty,
|
|
73
|
+
thresholds: content.yThresholds,
|
|
74
|
+
scaleType: 'linear'
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
points: {
|
|
78
|
+
enabled: false
|
|
79
|
+
},
|
|
80
|
+
legend: {
|
|
81
|
+
enabled: false
|
|
82
|
+
}
|
|
83
|
+
}) : type === CARD_TYPES.STACKED_AREA_CHART ? _objectSpread(_objectSpread({}, basicOptionsObject), {}, {
|
|
84
|
+
axes: {
|
|
85
|
+
left: {
|
|
86
|
+
stacked: true,
|
|
87
|
+
title: content.yLabel,
|
|
88
|
+
mapsTo: content.yProperty,
|
|
89
|
+
thresholds: content.yThresholds,
|
|
90
|
+
scaleType: 'linear'
|
|
91
|
+
},
|
|
92
|
+
bottom: {
|
|
93
|
+
title: content.xLabel,
|
|
94
|
+
mapsTo: content.xProperty,
|
|
95
|
+
thresholds: content.xThresholds,
|
|
96
|
+
scaleType: 'time'
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
curve: content.curve
|
|
100
|
+
}) : content;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export { getChartOptions };
|
|
@@ -12,6 +12,7 @@ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
|
12
12
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
13
13
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
14
14
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
15
|
+
var isEmpty = require('../../node_modules/lodash-es/isEmpty.js');
|
|
15
16
|
require('core-js/modules/es.array.iterator.js');
|
|
16
17
|
require('core-js/modules/es.object.to-string.js');
|
|
17
18
|
require('core-js/modules/web.dom-collections.iterator.js');
|
|
@@ -33,6 +34,7 @@ var cardUtilityFunctions = require('../../utils/cardUtilityFunctions.js');
|
|
|
33
34
|
var dateTimePickerUtils = require('../DateTimePicker/dateTimePickerUtils.js');
|
|
34
35
|
var useSizeObserver = require('../../hooks/useSizeObserver.js');
|
|
35
36
|
var EmptyState = require('../EmptyState/EmptyState.js');
|
|
37
|
+
var CardTypeContent = require('./CardTypeContent.js');
|
|
36
38
|
var CardToolbar = require('./CardToolbar.js');
|
|
37
39
|
var CardTitle = require('./CardTitle.js');
|
|
38
40
|
|
|
@@ -118,8 +120,9 @@ var CardContent = function CardContent(props) {
|
|
|
118
120
|
isExpanded = props.isExpanded,
|
|
119
121
|
className = props.className,
|
|
120
122
|
testId = props.testId,
|
|
121
|
-
noPadding = props.noPadding
|
|
122
|
-
|
|
123
|
+
noPadding = props.noPadding,
|
|
124
|
+
hasFooter = props.hasFooter;
|
|
125
|
+
var height = "".concat(dimensions.y - LayoutConstants.CARD_TITLE_HEIGHT - (hasFooter ? '40' : '0'), "px");
|
|
123
126
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
124
127
|
"data-testid": testId,
|
|
125
128
|
style: _defineProperty__default['default']({}, "--card-content-height", height),
|
|
@@ -174,13 +177,16 @@ CardContent.propTypes = {
|
|
|
174
177
|
y: PropTypes__default['default'].number
|
|
175
178
|
}).isRequired,
|
|
176
179
|
isExpanded: CardPropTypes.CardPropTypes.isExpanded.isRequired,
|
|
177
|
-
noPadding: PropTypes__default['default'].bool
|
|
180
|
+
noPadding: PropTypes__default['default'].bool,
|
|
181
|
+
// define the actual card content depending if it has a footer or not
|
|
182
|
+
hasFooter: PropTypes__default['default'].bool
|
|
178
183
|
};
|
|
179
184
|
CardContent.defaultProps = {
|
|
180
185
|
children: undefined,
|
|
181
186
|
className: '',
|
|
182
187
|
testId: 'card-content',
|
|
183
|
-
noPadding: false
|
|
188
|
+
noPadding: false,
|
|
189
|
+
hasFooter: false
|
|
184
190
|
};
|
|
185
191
|
({
|
|
186
192
|
children: PropTypes__default['default'].node.isRequired
|
|
@@ -267,7 +273,10 @@ var defaultProps = {
|
|
|
267
273
|
footerContent: undefined,
|
|
268
274
|
dateTimeMask: 'YYYY-MM-DD HH:mm',
|
|
269
275
|
padding: 'default',
|
|
270
|
-
overrides: undefined
|
|
276
|
+
overrides: undefined,
|
|
277
|
+
type: null,
|
|
278
|
+
data: null,
|
|
279
|
+
content: null
|
|
271
280
|
};
|
|
272
281
|
/** Dumb component that renders the card basics */
|
|
273
282
|
|
|
@@ -281,7 +290,7 @@ var Card = function Card(props) {
|
|
|
281
290
|
hasTitleWrap = props.hasTitleWrap;
|
|
282
291
|
props.layout;
|
|
283
292
|
var isLoading = props.isLoading,
|
|
284
|
-
|
|
293
|
+
isEmptyProp = props.isEmpty,
|
|
285
294
|
isEditable = props.isEditable,
|
|
286
295
|
isExpanded = props.isExpanded,
|
|
287
296
|
isLazyLoading = props.isLazyLoading,
|
|
@@ -310,7 +319,10 @@ var Card = function Card(props) {
|
|
|
310
319
|
extraActions = props.extraActions,
|
|
311
320
|
padding = props.padding,
|
|
312
321
|
overrides = props.overrides,
|
|
313
|
-
|
|
322
|
+
type = props.type,
|
|
323
|
+
data = props.data,
|
|
324
|
+
content = props.content,
|
|
325
|
+
others = _objectWithoutProperties__default['default'](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
|
|
314
326
|
|
|
315
327
|
|
|
316
328
|
React.useEffect(function () {
|
|
@@ -431,6 +443,9 @@ var Card = function Card(props) {
|
|
|
431
443
|
dateTimeMask: dateTimeMask,
|
|
432
444
|
extraActions: extraActions
|
|
433
445
|
}) : null;
|
|
446
|
+
var isSupportedType = type === LayoutConstants.CARD_TYPES.METER_CHART || type === LayoutConstants.CARD_TYPES.SPARKLINE_CHART || type === LayoutConstants.CARD_TYPES.STACKED_AREA_CHART; // validate if the data is empty or prop says it's empty
|
|
447
|
+
|
|
448
|
+
var isCardEmpty = isSupportedType && isEmpty(data) || isEmptyProp;
|
|
434
449
|
var card = /*#__PURE__*/React__default['default'].createElement(CardWrapper, _extends__default['default']({}, others, {
|
|
435
450
|
// you need all of these to support dynamic positioning during edit
|
|
436
451
|
ref: function ref(node) {
|
|
@@ -470,7 +485,8 @@ var Card = function Card(props) {
|
|
|
470
485
|
dimensions: dimensions,
|
|
471
486
|
isExpanded: isExpanded,
|
|
472
487
|
className: contentClassName,
|
|
473
|
-
noPadding: padding === 'none'
|
|
488
|
+
noPadding: padding === 'none',
|
|
489
|
+
hasFooter: !!CardFooter
|
|
474
490
|
}, !isVisible && isLazyLoading ? // if not visible don't show anything
|
|
475
491
|
'' : isLoading ? /*#__PURE__*/React__default['default'].createElement("div", {
|
|
476
492
|
style: {
|
|
@@ -485,10 +501,20 @@ var Card = function Card(props) {
|
|
|
485
501
|
icon: isSmall ? '' : 'error',
|
|
486
502
|
title: strings.errorLoadingDataShortLabel,
|
|
487
503
|
body: error
|
|
488
|
-
}, overrides === null || overrides === void 0 ? void 0 : (_overrides$errorMessa2 = overrides.errorMessage) === null || _overrides$errorMessa2 === void 0 ? void 0 : _overrides$errorMessa2.props)) :
|
|
504
|
+
}, 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['default'].createElement(ErrorMessage, _extends__default['default']({
|
|
489
505
|
title: isSmallOrThin ? strings.noDataShortLabel : strings.noDataLabel,
|
|
490
506
|
icon: isSmall ? '' : 'empty'
|
|
491
|
-
}, overrides === null || overrides === void 0 ? void 0 : (_overrides$errorMessa3 = overrides.errorMessage) === null || _overrides$errorMessa3 === void 0 ? void 0 : _overrides$errorMessa3.props)) :
|
|
507
|
+
}, overrides === null || overrides === void 0 ? void 0 : (_overrides$errorMessa3 = overrides.errorMessage) === null || _overrides$errorMessa3 === void 0 ? void 0 : _overrides$errorMessa3.props)) : isSupportedType ?
|
|
508
|
+
/*#__PURE__*/
|
|
509
|
+
// render card content based on supported type
|
|
510
|
+
// TODO: remove deprecated testID prop in v3
|
|
511
|
+
React__default['default'].createElement(CardTypeContent, {
|
|
512
|
+
testId: testID || testId,
|
|
513
|
+
isExpanded: isExpanded,
|
|
514
|
+
type: type,
|
|
515
|
+
data: data,
|
|
516
|
+
content: content
|
|
517
|
+
}) : 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
|
|
492
518
|
[// first option is a function
|
|
493
519
|
children === null || children === void 0 ? void 0 : children[0](getChildSize(cardSize, title), _objectSpread({
|
|
494
520
|
cardToolbar: cardToolbar
|
|
@@ -764,6 +790,27 @@ Card.__docgenInfo = {
|
|
|
764
790
|
"computed": true
|
|
765
791
|
},
|
|
766
792
|
"required": false
|
|
793
|
+
},
|
|
794
|
+
"type": {
|
|
795
|
+
"defaultValue": {
|
|
796
|
+
"value": "null",
|
|
797
|
+
"computed": false
|
|
798
|
+
},
|
|
799
|
+
"required": false
|
|
800
|
+
},
|
|
801
|
+
"data": {
|
|
802
|
+
"defaultValue": {
|
|
803
|
+
"value": "null",
|
|
804
|
+
"computed": false
|
|
805
|
+
},
|
|
806
|
+
"required": false
|
|
807
|
+
},
|
|
808
|
+
"content": {
|
|
809
|
+
"defaultValue": {
|
|
810
|
+
"value": "null",
|
|
811
|
+
"computed": false
|
|
812
|
+
},
|
|
813
|
+
"required": false
|
|
767
814
|
}
|
|
768
815
|
},
|
|
769
816
|
"composes": ["../../constants/CardPropTypes"]
|