@widergy/energy-ui 1.114.0 → 1.115.0

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 CHANGED
@@ -1,3 +1,24 @@
1
+ # [1.115.0](https://github.com/widergy/energy-ui/compare/v1.114.2...v1.115.0) (2022-03-17)
2
+
3
+
4
+ ### Features
5
+
6
+ * bar chart updates ([#270](https://github.com/widergy/energy-ui/issues/270)) ([683f556](https://github.com/widergy/energy-ui/commit/683f556d4c9f3d1df72b837fd33b487ab45d3d10))
7
+
8
+ ## [1.114.2](https://github.com/widergy/energy-ui/compare/v1.114.1...v1.114.2) (2022-03-11)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * adding optional tooltip to UTImageRadio ([#269](https://github.com/widergy/energy-ui/issues/269)) ([4facad6](https://github.com/widergy/energy-ui/commit/4facad6b35e93f24f24a439fb53278aabf92a84f))
14
+
15
+ ## [1.114.1](https://github.com/widergy/energy-ui/compare/v1.114.0...v1.114.1) (2022-03-11)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * markdown fixes ([#266](https://github.com/widergy/energy-ui/issues/266)) ([a1749eb](https://github.com/widergy/energy-ui/commit/a1749eb2c4d6fa1fb38c8986750f723cba180fd4))
21
+
1
22
  # [1.114.0](https://github.com/widergy/energy-ui/compare/v1.113.0...v1.114.0) (2022-03-08)
2
23
 
3
24
 
@@ -52,3 +52,4 @@ Component that aims to provide an easy and dynamic solution for creating bar cha
52
52
  - `spacingOptions`: expects an `object` of the shape `{ onTopLabelPadding: number, lateralMargin: number, verticalMargin: number, axisPadding: number, marginTop: number, scrollPadding: number }`.
53
53
  - `valuesOnTop`: expects a `bool` that indicates that values must be rendered on top of each bar.
54
54
  - `NoDataComponent`: expects a `func` that renders a component to show when no bar data is available.
55
+ - `markers`: expects a shape for markers configuration and styling
@@ -25,6 +25,8 @@ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
25
25
 
26
26
  var _constants = require("./constants");
27
27
 
28
+ var _utils = require("./utils");
29
+
28
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
31
 
30
32
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -110,7 +112,8 @@ var Legend = function Legend(_ref) {
110
112
  return referencesToShow.includes(id);
111
113
  };
112
114
 
113
- return [levelsReferences.filter(filterFunction), linearReferences.filter(filterFunction), barReferences.filter(filterFunction)].filter(function (row) {
115
+ var getOrderedLegend = (0, _utils.orderLegend)(references === null || references === void 0 ? void 0 : references.orderFunction);
116
+ return getOrderedLegend(levelsReferences.filter(filterFunction), linearReferences.filter(filterFunction), barReferences.filter(filterFunction)).filter(function (row) {
114
117
  return !(0, _array.isEmpty)(row);
115
118
  });
116
119
  };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.orderLegend = void 0;
7
+
8
+ var orderLegend = function orderLegend(legendOrderFunction) {
9
+ return function (levels, linear, bar) {
10
+ return legendOrderFunction ? legendOrderFunction(levels, linear, bar) : [levels, linear, bar];
11
+ };
12
+ };
13
+
14
+ exports.orderLegend = orderLegend;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MARKER_TYPES = exports.DEFAULT_MARKER_SIZE = void 0;
7
+ var DEFAULT_MARKER_SIZE = 4;
8
+ exports.DEFAULT_MARKER_SIZE = DEFAULT_MARKER_SIZE;
9
+ var MARKER_TYPES = {
10
+ DOT: 'dot'
11
+ };
12
+ exports.MARKER_TYPES = MARKER_TYPES;
@@ -32,7 +32,8 @@ var LinearPlot = function LinearPlot(_ref) {
32
32
  xAxis = _ref.xAxis,
33
33
  type = _ref.type,
34
34
  color = _ref.color,
35
- customLineProps = _ref.customLineProps;
35
+ customLineProps = _ref.customLineProps,
36
+ markers = _ref.markers;
36
37
  var lineGenerator = d3.line().x(function (_ref2) {
37
38
  var xCoordinate = _ref2.xCoordinate;
38
39
  return xAxis(xCoordinate) + barWidth / 2;
@@ -42,13 +43,12 @@ var LinearPlot = function LinearPlot(_ref) {
42
43
  });
43
44
 
44
45
  var _getLineConfiguration = (0, _utils.getLineConfiguration)(type, lineGenerator),
45
- generator = _getLineConfiguration.generator,
46
46
  props = _getLineConfiguration.props;
47
47
 
48
48
  return /*#__PURE__*/_react.default.createElement("g", null, /*#__PURE__*/_react.default.createElement("path", _extends({
49
- d: generator(data),
49
+ d: lineGenerator(data),
50
50
  stroke: color
51
- }, props, customLineProps)));
51
+ }, props, customLineProps)), markers && (0, _utils.getMarkers)(data, xAxis, yAxis, barWidth, color, markers));
52
52
  };
53
53
 
54
54
  LinearPlot.propTypes = {
@@ -58,6 +58,7 @@ LinearPlot.propTypes = {
58
58
  xAxis: _propTypes.func,
59
59
  type: _propTypes.string,
60
60
  color: _propTypes.string,
61
+ markers: _types.linearMarkersType,
61
62
  customLineProps: (0, _propTypes.shape)({
62
63
  fill: _propTypes.string,
63
64
  strokeWidth: _propTypes.string,
@@ -3,29 +3,56 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getLineConfiguration = void 0;
6
+ exports.getMarkers = exports.getLineConfiguration = void 0;
7
7
 
8
- var getLineConfiguration = function getLineConfiguration(type, lineGenerator) {
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _constants = require("./constants");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ var DEFAULT_LINE_TYPE = 'solid';
15
+
16
+ var getLineConfiguration = function getLineConfiguration(type) {
9
17
  return {
10
18
  solid: {
11
- generator: lineGenerator,
12
19
  props: {
13
20
  fill: 'none',
14
21
  strokeWidth: '1'
15
22
  }
16
23
  },
17
24
  dashed: {
18
- generator: lineGenerator,
19
25
  props: {
20
26
  fill: 'none',
21
27
  strokeWidth: '1',
22
28
  strokeDasharray: '2,2'
23
29
  }
24
30
  },
25
- custom: {
26
- generator: lineGenerator
27
- }
28
- }[type];
31
+ custom: {}
32
+ }[type || DEFAULT_LINE_TYPE];
33
+ };
34
+
35
+ exports.getLineConfiguration = getLineConfiguration;
36
+
37
+ var getMarkers = function getMarkers(data, xAxis, yAxis, barWidth, color, markersConfig) {
38
+ return data.map(function (_ref) {
39
+ var xCoordinate = _ref.xCoordinate,
40
+ value = _ref.value;
41
+ var x = xAxis(xCoordinate) + barWidth / 2;
42
+ var y = yAxis(value);
43
+ var size = (markersConfig.size || _constants.DEFAULT_MARKER_SIZE) / 2;
44
+ return markersConfig.type === _constants.MARKER_TYPES.DOT && /*#__PURE__*/_react.default.createElement("svg", {
45
+ x: x - size,
46
+ y: y - size,
47
+ height: 2 * size,
48
+ width: 2 * size
49
+ }, /*#__PURE__*/_react.default.createElement("circle", {
50
+ cx: size,
51
+ cy: size,
52
+ r: size,
53
+ fill: color
54
+ }));
55
+ });
29
56
  };
30
57
 
31
- exports.getLineConfiguration = getLineConfiguration;
58
+ exports.getMarkers = getMarkers;
@@ -80,37 +80,38 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
80
80
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
81
81
 
82
82
  var UTBarChart = function UTBarChart(_ref) {
83
- var barData = _ref.barData,
84
- linearData = _ref.linearData,
85
- pagination = _ref.pagination,
86
- yAxisTicks = _ref.yAxisTicks,
87
- className = _ref.className,
88
- xAxisDefinition = _ref.xAxisDefinition,
83
+ var barBorderRadius = _ref.barBorderRadius,
84
+ barData = _ref.barData,
89
85
  barPadding = _ref.barPadding,
90
- barBorderRadius = _ref.barBorderRadius,
91
- onBarClick = _ref.onBarClick,
92
- minBarWidth = _ref.minBarWidth,
93
- gradientGenerator = _ref.gradientGenerator,
94
- decoratorRenderer = _ref.decoratorRenderer,
95
- levels = _ref.levels,
96
- title = _ref.title,
97
- labelFormatters = _ref.labelFormatters,
98
- units = _ref.units,
99
- showGrid = _ref.showGrid,
100
86
  center = _ref.center,
101
- hideYAxis = _ref.hideYAxis,
102
- singleYAxis = _ref.singleYAxis,
103
- references = _ref.references,
87
+ theme = _ref.classes,
88
+ className = _ref.className,
89
+ classNames = _ref.classNames,
90
+ decoratorRenderer = _ref.decoratorRenderer,
104
91
  displayLegendAs = _ref.displayLegendAs,
92
+ gradientGenerator = _ref.gradientGenerator,
93
+ hideYAxis = _ref.hideYAxis,
94
+ highlightWidth = _ref.highlightWidth,
95
+ labelFormatters = _ref.labelFormatters,
105
96
  labels = _ref.labels,
97
+ levels = _ref.levels,
98
+ linearData = _ref.linearData,
99
+ minBarWidth = _ref.minBarWidth,
100
+ NoDataComponent = _ref.NoDataComponent,
101
+ onBarClick = _ref.onBarClick,
102
+ pagination = _ref.pagination,
106
103
  selectable = _ref.selectable,
107
- highlightWidth = _ref.highlightWidth,
108
- classNames = _ref.classNames,
109
- theme = _ref.classes,
104
+ references = _ref.references,
105
+ showGrid = _ref.showGrid,
106
+ singleYAxis = _ref.singleYAxis,
110
107
  spacingOptions = _ref.spacingOptions,
108
+ fitLegend = _ref.fitLegend,
109
+ title = _ref.title,
110
+ transitionDuration = _ref.transitionDuration,
111
+ units = _ref.units,
111
112
  valuesOnTop = _ref.valuesOnTop,
112
- NoDataComponent = _ref.NoDataComponent,
113
- transitionDuration = _ref.transitionDuration;
113
+ xAxisDefinition = _ref.xAxisDefinition,
114
+ yAxisTicks = _ref.yAxisTicks;
114
115
  var classes = (0, _classesUtils.mergeClasses)(theme, classNames);
115
116
 
116
117
  var _useState = (0, _react.useState)(0),
@@ -250,12 +251,14 @@ var UTBarChart = function UTBarChart(_ref) {
250
251
  var data = _ref3.data,
251
252
  type = _ref3.type,
252
253
  color = _ref3.color,
253
- customLineProps = _ref3.customLineProps;
254
+ customLineProps = _ref3.customLineProps,
255
+ markers = _ref3.markers;
254
256
  return /*#__PURE__*/_react.default.createElement(_LinearPlot.default, {
255
257
  data: data,
256
258
  type: type,
257
259
  yAxis: linearYAxis,
258
260
  xAxis: xAxis,
261
+ markers: markers,
259
262
  barWidth: groupWidth,
260
263
  color: color,
261
264
  graphYStart: GRAPH_Y_START,
@@ -320,8 +323,8 @@ var UTBarChart = function UTBarChart(_ref) {
320
323
  classes: classes,
321
324
  displayAs: displayLegendAs,
322
325
  style: {
323
- width: containerWidth,
324
- margin: '0 auto'
326
+ width: containerWidth - 2 * GRAPH_X_START,
327
+ margin: fitLegend ? "0 ".concat(GRAPH_X_START, "px 0 ").concat(GRAPH_X_START, "px") : '0 auto'
325
328
  },
326
329
  flatData: {
327
330
  bar: flatBarData,
@@ -349,6 +352,7 @@ UTBarChart.propTypes = {
349
352
  decoratorRenderer: _propTypes.func,
350
353
  levels: _types.levelsType,
351
354
  title: _propTypes.string,
355
+ fitLegend: _propTypes.bool,
352
356
  labelFormatters: (0, _propTypes.objectOf)(_propTypes.func),
353
357
  units: (0, _propTypes.objectOf)(_propTypes.string),
354
358
  spacingOptions: (0, _propTypes.objectOf)(_propTypes.number),
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.xAxisDefinitionType = exports.referencesType = exports.linearType = exports.linearDataType = exports.levelsType = exports.barType = exports.barDataType = void 0;
6
+ exports.xAxisDefinitionType = exports.referencesType = exports.linearType = exports.linearMarkersType = exports.linearDataType = exports.levelsType = exports.barType = exports.barDataType = void 0;
7
7
 
8
8
  var _propTypes = require("prop-types");
9
9
 
@@ -24,6 +24,10 @@ var barType = (0, _propTypes.shape)({
24
24
  }))
25
25
  });
26
26
  exports.barType = barType;
27
+ var linearMarkersType = (0, _propTypes.shape)({
28
+ type: _propTypes.string
29
+ });
30
+ exports.linearMarkersType = linearMarkersType;
27
31
  var barDataType = (0, _propTypes.arrayOf)((0, _propTypes.arrayOf)(barType));
28
32
  exports.barDataType = barDataType;
29
33
  var linearType = (0, _propTypes.shape)({
@@ -32,7 +36,8 @@ var linearType = (0, _propTypes.shape)({
32
36
  value: _propTypes.number
33
37
  }),
34
38
  type: _propTypes.string,
35
- color: _propTypes.string
39
+ color: _propTypes.string,
40
+ marker: linearMarkersType
36
41
  });
37
42
  exports.linearType = linearType;
38
43
  var linearDataType = (0, _propTypes.arrayOf)(linearType);
@@ -47,7 +52,8 @@ var referencesType = (0, _propTypes.arrayOf)((0, _propTypes.shape)({
47
52
  id: _propTypes.string,
48
53
  className: _propTypes.string,
49
54
  check: _propTypes.func,
50
- label: _propTypes.string
55
+ label: _propTypes.string,
56
+ orderFunction: _propTypes.func
51
57
  }));
52
58
  exports.referencesType = referencesType;
53
59
  var xAxisDefinitionType = (0, _propTypes.arrayOf)((0, _propTypes.shape)({
@@ -13,6 +13,8 @@ var _propTypes = require("prop-types");
13
13
 
14
14
  var _UTLabel = _interopRequireDefault(require("../../../UTLabel"));
15
15
 
16
+ var _UTTooltip = _interopRequireDefault(require("../../../UTTooltip"));
17
+
16
18
  var _UTTouchableWithoutFeedback = _interopRequireDefault(require("../../../UTTouchableWithoutFeedback"));
17
19
 
18
20
  var _types = require("../../types");
@@ -46,6 +48,7 @@ var ImageRadioCard = function ImageRadioCard(_ref) {
46
48
  selectedImageUrl = configuration.selected_image_url,
47
49
  UnselectedImageComponent = configuration.UnselectedImageComponent,
48
50
  SelectedImageComponent = configuration.SelectedImageComponent,
51
+ tooltip = configuration.tooltip,
49
52
  description = configuration.description;
50
53
 
51
54
  var handleOnChange = function handleOnChange() {
@@ -64,19 +67,28 @@ var ImageRadioCard = function ImageRadioCard(_ref) {
64
67
  });
65
68
  };
66
69
  }, [imageUrl, selectedImageUrl]);
67
- return /*#__PURE__*/_react.default.createElement(_UTTouchableWithoutFeedback.default, {
68
- className: "".concat(_stylesModule.default.container, " ").concat(classes.containerCard, " ").concat(isSelected && "".concat(_stylesModule.default.isSelected, " ").concat(classes.isSelected), " ").concat(oneColumn && _stylesModule.default.oneColumn, " ").concat(compact && _stylesModule.default.compact, " ").concat(disabled && _stylesModule.default.disabled, " ").concat(transparent && _stylesModule.default.transparent, " ").concat(vertical && classes.vertical),
69
- onClick: handleOnChange
70
- }, (imageUrl || ImageComponent) && /*#__PURE__*/_react.default.createElement("div", {
71
- className: "".concat(classes.image, " ").concat(_stylesModule.default.image)
72
- }, imageUrl && renderImage(isSelected), ImageComponent && /*#__PURE__*/_react.default.createElement(ImageComponent, null)), /*#__PURE__*/_react.default.createElement("div", {
73
- className: "".concat(_stylesModule.default.containerText, " ").concat(classes.containerText)
74
- }, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
75
- className: "".concat(classes.name, " ").concat(_stylesModule.default.text, " ").concat(isSelected && !transparent && classes.selectedText)
76
- }, name), description && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
77
- light: true,
78
- className: "".concat(classes.description, " ").concat(_stylesModule.default.text, " ").concat(isSelected && classes.selectedText)
79
- }, description)));
70
+
71
+ var Content = function Content() {
72
+ return /*#__PURE__*/_react.default.createElement(_UTTouchableWithoutFeedback.default, {
73
+ className: "".concat(_stylesModule.default.container, " ").concat(classes.containerCard, " ").concat(isSelected && "".concat(_stylesModule.default.isSelected, " ").concat(classes.isSelected), " ").concat(oneColumn && _stylesModule.default.oneColumn, " ").concat(compact && _stylesModule.default.compact, " ").concat(disabled && _stylesModule.default.disabled, " ").concat(transparent && _stylesModule.default.transparent, " ").concat(vertical && classes.vertical, " ").concat(tooltip && _stylesModule.default.contentWithTooltip, " "),
74
+ onClick: handleOnChange
75
+ }, (imageUrl || ImageComponent) && /*#__PURE__*/_react.default.createElement("div", {
76
+ className: "".concat(classes.image, " ").concat(_stylesModule.default.image)
77
+ }, imageUrl && renderImage(isSelected), ImageComponent && /*#__PURE__*/_react.default.createElement(ImageComponent, null)), /*#__PURE__*/_react.default.createElement("div", {
78
+ className: "".concat(_stylesModule.default.containerText, " ").concat(classes.containerText)
79
+ }, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
80
+ className: "".concat(classes.name, " ").concat(_stylesModule.default.text, " ").concat(isSelected && !transparent && classes.selectedText)
81
+ }, name), description && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
82
+ light: true,
83
+ className: "".concat(classes.description, " ").concat(_stylesModule.default.text, " ").concat(isSelected && classes.selectedText)
84
+ }, description)));
85
+ };
86
+
87
+ return tooltip ? /*#__PURE__*/_react.default.createElement(_UTTooltip.default, {
88
+ content: tooltip
89
+ }, /*#__PURE__*/_react.default.createElement("span", {
90
+ className: "".concat(_stylesModule.default.contentContainer, " ").concat(oneColumn ? _stylesModule.default.oneColumn : _stylesModule.default.twoColumns, " ")
91
+ }, /*#__PURE__*/_react.default.createElement(Content, null))) : /*#__PURE__*/_react.default.createElement(Content, null);
80
92
  };
81
93
 
82
94
  ImageRadioCard.propTypes = {
@@ -2,6 +2,7 @@
2
2
  @import '../../../../scss/variables/mediaQueries';
3
3
 
4
4
  $default-text-grid-gap: 8px;
5
+ $content-grid-gap: 16px;
5
6
  $compact-padding: 16px;
6
7
  $default-border-radius: 5px;
7
8
 
@@ -63,3 +64,28 @@ $default-border-radius: 5px;
63
64
  background: none;
64
65
  filter: none !important;
65
66
  }
67
+
68
+ .contentContainer {
69
+ align-items: center;
70
+ background-color: $image-radio-background;
71
+ border-radius: $default-border-radius;
72
+ box-sizing: border-box;
73
+ cursor: pointer;
74
+ display: flex;
75
+ flex-direction: row;
76
+ gap: $content-grid-gap;
77
+ height: fit-content;
78
+ transition: background-color 0.2s ease-in-out;
79
+
80
+ @media #{$tablet-mobile} {
81
+ width: 100%;
82
+ }
83
+ }
84
+
85
+ .twoColumns {
86
+ width: calc(50% - 2 * #{$content-grid-gap});
87
+ }
88
+
89
+ .contentWithTooltip {
90
+ width: 100%;
91
+ }
@@ -124,7 +124,7 @@ var UTLabel = /*#__PURE__*/function (_PureComponent) {
124
124
  title: withHoverTitle && (prop.children || prop),
125
125
  style: propStyle,
126
126
  key: prop.children,
127
- className: withoutMarkdown && className
127
+ className: withoutMarkdown && "".concat(className, " ").concat(classes.base, " ").concat(style)
128
128
  }, prop.children || prop);
129
129
  };
130
130
 
@@ -145,7 +145,7 @@ var UTLabel = /*#__PURE__*/function (_PureComponent) {
145
145
  plugins: [_remarkBreaks.default],
146
146
  unwrapDisallowed: true,
147
147
  disallowedTypes: ['root', 'paragraph'],
148
- className: " ".concat(className, " ").concat(classes.base, " ").concat(style, " "),
148
+ className: "".concat(className, " ").concat(classes.base, " ").concat(style),
149
149
  renderers: {
150
150
  link: renderLinkComponent,
151
151
  text: handleCustomTag
@@ -38,7 +38,9 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
38
38
  var SkeletonWrapper = (0, _reactSkeletor.createSkeletonElement)('div', _stylesModule.default.skeleton);
39
39
 
40
40
  var hasMock = function hasMock(string) {
41
- if (string && string.props.source) return string.props.source.toString().includes('MOCK');
41
+ var _string$props, _string$props$source, _string$props2, _string$props2$childr;
42
+
43
+ return (string === null || string === void 0 ? void 0 : (_string$props = string.props) === null || _string$props === void 0 ? void 0 : (_string$props$source = _string$props.source) === null || _string$props$source === void 0 ? void 0 : _string$props$source.toString().includes('MOCK')) || (string === null || string === void 0 ? void 0 : (_string$props2 = string.props) === null || _string$props2 === void 0 ? void 0 : (_string$props2$childr = _string$props2.children) === null || _string$props2$childr === void 0 ? void 0 : _string$props2$childr.toString().includes('MOCK'));
42
44
  };
43
45
 
44
46
  var hiddenChildren = function hiddenChildren(child) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "1.114.0",
3
+ "version": "1.115.0",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",