@semcore/mini-chart 16.0.0-prerelease.2 → 16.0.0-prerelease.21

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.
@@ -1,39 +1,44 @@
1
- import w from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import f from "@babel/runtime/helpers/esm/objectSpread2";
3
- import L from "@babel/runtime/helpers/esm/classCallCheck";
4
- import A from "@babel/runtime/helpers/esm/createClass";
5
- import D from "@babel/runtime/helpers/esm/inherits";
6
- import E from "@babel/runtime/helpers/esm/createSuper";
7
- import l from "@babel/runtime/helpers/esm/defineProperty";
8
- import { sstyled as v, createComponent as y, assignProps as j } from "@semcore/core";
9
- import _ from "react";
10
- import R from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
11
- import { Trend as G } from "./Trend.mjs";
12
- import { Box as N } from "@semcore/flex-box";
13
- import { extractAriaProps as M } from "@semcore/core/lib/utils/ariaProps";
14
- var W = (
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
6
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
7
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
+ import { sstyled, createComponent, assignProps } from "@semcore/core";
9
+ import React from "react";
10
+ import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
11
+ import { Trend } from "./Trend.mjs";
12
+ import { Box } from "@semcore/flex-box";
13
+ import { extractAriaProps } from "@semcore/core/lib/utils/ariaProps";
14
+ /*!__reshadow-styles__:"../skeleton/skeleton.shadow.css"*/
15
+ var style = (
15
16
  /*__reshadow_css_start__*/
16
- (v.insert(
17
+ (sstyled.insert(
17
18
  /*__inner_css_start__*/
18
19
  "@keyframes pulse_7jer1{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_7jer1_gg_.__loading_7jer1_gg_,.___SLineGauge_7jer1_gg_.__loading_7jer1_gg_,.___STrendBar_7jer1_gg_.__loading_7jer1_gg_,.___STrendLine_7jer1_gg_.__loading_7jer1_gg_{animation-name:pulse_7jer1;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}",
20
+ /*__inner_css_end__*/
19
21
  "7jer1_gg_"
20
- ), {
21
- __SLineGauge: "___SLineGauge_7jer1_gg_",
22
- _loading: "__loading_7jer1_gg_",
23
- __SDonutContainer: "___SDonutContainer_7jer1_gg_",
24
- __STrendLine: "___STrendLine_7jer1_gg_",
25
- __STrendBar: "___STrendBar_7jer1_gg_",
22
+ ), /*__reshadow_css_end__*/
23
+ {
24
+ "__SLineGauge": "___SLineGauge_7jer1_gg_",
25
+ "_loading": "__loading_7jer1_gg_",
26
+ "__SDonutContainer": "___SDonutContainer_7jer1_gg_",
27
+ "__STrendLine": "___STrendLine_7jer1_gg_",
28
+ "__STrendBar": "___STrendBar_7jer1_gg_",
26
29
  "@pulse": "pulse_7jer1"
27
30
  })
28
- ), o = /* @__PURE__ */ function(u) {
29
- D(e, u);
30
- var s = E(e);
31
- function e() {
32
- return L(this, e), s.apply(this, arguments);
31
+ );
32
+ var TrendBarRoot = /* @__PURE__ */ function(_Trend) {
33
+ _inherits(TrendBarRoot2, _Trend);
34
+ var _super = _createSuper(TrendBarRoot2);
35
+ function TrendBarRoot2() {
36
+ _classCallCheck(this, TrendBarRoot2);
37
+ return _super.apply(this, arguments);
33
38
  }
34
- return A(e, [{
39
+ _createClass(TrendBarRoot2, [{
35
40
  key: "defaultData",
36
- get: function() {
41
+ get: function get() {
37
42
  return [{
38
43
  value: 20
39
44
  }, {
@@ -46,60 +51,71 @@ var W = (
46
51
  }
47
52
  }, {
48
53
  key: "data",
49
- get: function() {
50
- var n = this.asProps, r = n.data, t = n.loading;
51
- return t ? this.defaultData : r;
54
+ get: function get() {
55
+ var _this$asProps = this.asProps, data = _this$asProps.data, loading = _this$asProps.loading;
56
+ if (loading) {
57
+ return this.defaultData;
58
+ }
59
+ return data;
52
60
  }
53
61
  }, {
54
62
  key: "render",
55
- value: function() {
56
- var n = this.asProps, r, t = this, S = N, a = this.asProps, T = a.styles, p = a.resolveColor, C = a.isHistogram, B = a.animate, x = a.loading, g = this.defaultWidth / this.data.length, c = M(this.asProps), H = c.__excludeProps, k = c.extractedAriaProps;
57
- return r = v(T), /* @__PURE__ */ _.createElement(S, r.cn("STrendBar", f({}, j({
58
- ref: this.containerRef,
59
- __excludeProps: ["data"].concat(w(H))
60
- }, n))), /* @__PURE__ */ _.createElement("svg", r.cn("svg", f({
61
- width: "100%",
62
- height: "100%",
63
- viewBox: "0 0 ".concat(this.svgWidth, " ").concat(this.svgHeight),
64
- role: "img"
65
- }, k)), this.data.map(function(i, m) {
66
- var h = p("chart-palette-order-other-data");
67
- return i.color && (h = p(i.color)), /* @__PURE__ */ _.createElement("rect", {
68
- key: m,
69
- x: g * m,
70
- y: t.defaultHeight - i.value,
71
- width: C ? g : g * 0.8,
72
- height: i.value,
73
- fill: h
74
- }, B && !x && /* @__PURE__ */ _.createElement("animate", {
63
+ value: function render() {
64
+ var _ref = this.asProps, _ref2, _this = this;
65
+ var STrendBar = Box;
66
+ var _this$asProps2 = this.asProps, styles = _this$asProps2.styles, resolveColor = _this$asProps2.resolveColor, isHistogram = _this$asProps2.isHistogram, animate = _this$asProps2.animate, loading = _this$asProps2.loading;
67
+ var step = this.defaultWidth / this.data.length;
68
+ var _extractAriaProps = extractAriaProps(this.asProps), __excludeProps = _extractAriaProps.__excludeProps, extractedAriaProps = _extractAriaProps.extractedAriaProps;
69
+ return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(STrendBar, _ref2.cn("STrendBar", _objectSpread({}, assignProps({
70
+ "ref": this.containerRef,
71
+ "__excludeProps": ["data"].concat(_toConsumableArray(__excludeProps))
72
+ }, _ref))), /* @__PURE__ */ React.createElement("svg", _ref2.cn("svg", _objectSpread({
73
+ "width": "100%",
74
+ "height": "100%",
75
+ "viewBox": "0 0 ".concat(this.svgWidth, " ").concat(this.svgHeight),
76
+ "role": "img"
77
+ }, extractedAriaProps)), this.data.map(function(barItem, index) {
78
+ var color = resolveColor("chart-palette-order-other-data");
79
+ if (barItem.color) {
80
+ color = resolveColor(barItem.color);
81
+ }
82
+ return /* @__PURE__ */ React.createElement("rect", {
83
+ key: index,
84
+ x: step * index,
85
+ y: _this.defaultHeight - barItem.value,
86
+ width: isHistogram ? step : step * 0.8,
87
+ height: barItem.value,
88
+ fill: color
89
+ }, animate && !loading && /* @__PURE__ */ React.createElement("animate", {
75
90
  attributeName: "y",
76
- values: "".concat(t.defaultHeight, ";").concat(t.defaultHeight - i.value),
91
+ values: "".concat(_this.defaultHeight, ";").concat(_this.defaultHeight - barItem.value),
77
92
  dur: "500ms"
78
93
  }));
79
94
  })));
80
95
  }
81
- }]), e;
82
- }(G);
83
- l(o, "enhance", [R()]);
84
- l(o, "style", W);
85
- l(o, "defaultProps", {
86
- animate: !0
96
+ }]);
97
+ return TrendBarRoot2;
98
+ }(Trend);
99
+ _defineProperty(TrendBarRoot, "enhance", [resolveColorEnhance()]);
100
+ _defineProperty(TrendBarRoot, "style", style);
101
+ _defineProperty(TrendBarRoot, "defaultProps", {
102
+ animate: true
87
103
  });
88
- var P = y(o);
89
- P.displayName = "MiniChart.TrendBar";
90
- var b = y(o, {}, {
104
+ var TrendBar = createComponent(TrendBarRoot);
105
+ TrendBar.displayName = "MiniChart.TrendBar";
106
+ var TrendHistogram = createComponent(TrendBarRoot, {}, {
91
107
  enhancements: [function() {
92
108
  return {
93
- wrapperProps: function(s) {
94
- return j(s, {
95
- isHistogram: !0
109
+ wrapperProps: function wrapperProps(props) {
110
+ return assignProps(props, {
111
+ isHistogram: true
96
112
  });
97
113
  }
98
114
  };
99
115
  }]
100
116
  });
101
- P.displayName = "MiniChart.TrendHistogram";
117
+ TrendBar.displayName = "MiniChart.TrendHistogram";
102
118
  export {
103
- P as TrendBar,
104
- b as TrendHistogram
119
+ TrendBar,
120
+ TrendHistogram
105
121
  };
@@ -1,139 +1,158 @@
1
- import A from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import y from "@babel/runtime/helpers/esm/objectSpread2";
3
- import E from "@babel/runtime/helpers/esm/classCallCheck";
4
- import R from "@babel/runtime/helpers/esm/createClass";
5
- import H from "@babel/runtime/helpers/esm/inherits";
6
- import W from "@babel/runtime/helpers/esm/createSuper";
7
- import g from "@babel/runtime/helpers/esm/defineProperty";
8
- import { sstyled as j, createComponent as C, assignProps as S } from "@semcore/core";
9
- import i from "react";
10
- import $ from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
11
- import b from "@semcore/core/lib/utils/uniqueID";
12
- import { Trend as D } from "./Trend.mjs";
13
- import { Box as B } from "@semcore/flex-box";
14
- import { extractAriaProps as G } from "@semcore/core/lib/utils/ariaProps";
15
- var N = (
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
6
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
7
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
+ import { sstyled, createComponent, assignProps } from "@semcore/core";
9
+ import React from "react";
10
+ import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
11
+ import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
12
+ import { Trend } from "./Trend.mjs";
13
+ import { Box } from "@semcore/flex-box";
14
+ import { extractAriaProps } from "@semcore/core/lib/utils/ariaProps";
15
+ /*!__reshadow-styles__:"../skeleton/skeleton.shadow.css"*/
16
+ var style = (
16
17
  /*__reshadow_css_start__*/
17
- (j.insert(
18
+ (sstyled.insert(
18
19
  /*__inner_css_start__*/
19
20
  "@keyframes pulse_7jer1{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_7jer1_gg_.__loading_7jer1_gg_,.___SLineGauge_7jer1_gg_.__loading_7jer1_gg_,.___STrendBar_7jer1_gg_.__loading_7jer1_gg_,.___STrendLine_7jer1_gg_.__loading_7jer1_gg_{animation-name:pulse_7jer1;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}",
21
+ /*__inner_css_end__*/
20
22
  "7jer1_gg_"
21
- ), {
22
- __SLineGauge: "___SLineGauge_7jer1_gg_",
23
- _loading: "__loading_7jer1_gg_",
24
- __SDonutContainer: "___SDonutContainer_7jer1_gg_",
25
- __STrendLine: "___STrendLine_7jer1_gg_",
26
- __STrendBar: "___STrendBar_7jer1_gg_",
23
+ ), /*__reshadow_css_end__*/
24
+ {
25
+ "__SLineGauge": "___SLineGauge_7jer1_gg_",
26
+ "_loading": "__loading_7jer1_gg_",
27
+ "__SDonutContainer": "___SDonutContainer_7jer1_gg_",
28
+ "__STrendLine": "___STrendLine_7jer1_gg_",
29
+ "__STrendBar": "___STrendBar_7jer1_gg_",
27
30
  "@pulse": "pulse_7jer1"
28
31
  })
29
- ), l = /* @__PURE__ */ function(u) {
30
- H(s, u);
31
- var d = W(s);
32
- function s() {
33
- return E(this, s), d.apply(this, arguments);
32
+ );
33
+ var TrendLineRoot = /* @__PURE__ */ function(_Trend) {
34
+ _inherits(TrendLineRoot2, _Trend);
35
+ var _super = _createSuper(TrendLineRoot2);
36
+ function TrendLineRoot2() {
37
+ _classCallCheck(this, TrendLineRoot2);
38
+ return _super.apply(this, arguments);
34
39
  }
35
- return R(s, [{
40
+ _createClass(TrendLineRoot2, [{
36
41
  key: "defaultData",
37
- get: function() {
42
+ get: function get() {
38
43
  return [15, 70, 20, 85, 20];
39
44
  }
40
45
  }, {
41
46
  key: "lastPointRadius",
42
- get: function() {
43
- var e;
44
- return (e = this.asProps.lastPointRadius) !== null && e !== void 0 ? e : 6;
47
+ get: function get() {
48
+ var _this$asProps$lastPoi;
49
+ return (_this$asProps$lastPoi = this.asProps.lastPointRadius) !== null && _this$asProps$lastPoi !== void 0 ? _this$asProps$lastPoi : 6;
45
50
  }
46
51
  }, {
47
52
  key: "data",
48
- get: function() {
49
- var e = this.asProps, t = e.data, o = e.loading;
50
- return o ? this.defaultData : t;
53
+ get: function get() {
54
+ var _this$asProps = this.asProps, data = _this$asProps.data, loading = _this$asProps.loading;
55
+ if (loading) {
56
+ return this.defaultData;
57
+ }
58
+ return data;
51
59
  }
52
60
  }, {
53
61
  key: "svgWidth",
54
- get: function() {
62
+ get: function get() {
55
63
  return this.asProps.lastPointColor ? this.defaultWidth + this.lastPointRadius : this.defaultWidth;
56
64
  }
57
65
  }, {
58
66
  key: "svgHeight",
59
- get: function() {
67
+ get: function get() {
60
68
  return this.asProps.lastPointColor ? this.defaultHeight + this.lastPointRadius : this.defaultHeight;
61
69
  }
62
70
  }, {
63
71
  key: "color",
64
- get: function() {
65
- var e = this.asProps, t = e.resolveColor, o = e.color, r = o === void 0 ? "chart-palette-order-1" : o, n = e.loading;
66
- return t(n ? "skeleton-bg" : r);
72
+ get: function get() {
73
+ var _this$asProps2 = this.asProps, resolveColor = _this$asProps2.resolveColor, _this$asProps2$color = _this$asProps2.color, color = _this$asProps2$color === void 0 ? "chart-palette-order-1" : _this$asProps2$color, loading = _this$asProps2.loading;
74
+ if (loading) {
75
+ return resolveColor("skeleton-bg");
76
+ }
77
+ return resolveColor(color);
67
78
  }
68
79
  }, {
69
80
  key: "render",
70
- value: function() {
71
- for (var e = this.asProps, t, o = B, r = this.asProps, n = r.uid, k = r.withArea, T = r.animate, p = r.lastPointColor, m = r.resolveColor, f = r.loading, x = r.styles, h = [], _ = this.data.length, P = this.defaultWidth / (_ - 1), c = 0; c < _; c++)
72
- h.push("".concat(P * c, ",").concat(this.defaultHeight - this.data[c]));
73
- var v = G(this.asProps), L = v.__excludeProps, w = v.extractedAriaProps;
74
- return t = j(x), /* @__PURE__ */ i.createElement(o, t.cn("STrendLine", y({}, S({
75
- ref: this.containerRef,
76
- __excludeProps: ["data"].concat(A(L))
77
- }, e))), /* @__PURE__ */ i.createElement("svg", t.cn("svg", y({
78
- width: "100%",
79
- height: "100%",
80
- viewBox: "0 0 ".concat(this.svgWidth, " ").concat(this.svgHeight),
81
- role: "img"
82
- }, w)), /* @__PURE__ */ i.createElement("polyline", t.cn("polyline", {
83
- points: h.join(" "),
84
- stroke: this.color,
85
- strokeWidth: "4",
86
- fill: "none",
87
- clipPath: "url(#".concat(n, ")")
88
- })), k && /* @__PURE__ */ i.createElement("polyline", t.cn("polyline", {
89
- points: "0,".concat(this.defaultHeight, " ").concat(h.join(" "), " ").concat(this.defaultWidth, ",").concat(this.defaultHeight),
90
- fill: this.color,
91
- fillOpacity: 0.2,
92
- clipPath: "url(#".concat(n, ")")
93
- })), p && !f && /* @__PURE__ */ i.createElement("circle", t.cn("circle", {
94
- cx: P * (_ - 1),
95
- cy: this.defaultHeight - this.data[_ - 1],
96
- r: this.lastPointRadius,
97
- fill: m(p),
98
- stroke: m("chart-grid-border"),
99
- strokeWidth: 4,
100
- clipPath: "url(#".concat(n, ")")
101
- })), T && !f && /* @__PURE__ */ i.createElement("clipPath", t.cn("clipPath", {
102
- id: n
103
- }), /* @__PURE__ */ i.createElement("rect", t.cn("rect", {
104
- x: "0",
105
- y: "0",
106
- width: "100%",
107
- height: "100%",
108
- fill: "black"
109
- }), /* @__PURE__ */ i.createElement("animate", t.cn("animate", {
110
- dur: "500ms",
111
- attributeName: "width",
112
- values: "0;100%"
81
+ value: function render() {
82
+ var _ref = this.asProps, _ref2;
83
+ var STrendLine = Box;
84
+ var _this$asProps3 = this.asProps, uid = _this$asProps3.uid, withArea = _this$asProps3.withArea, animate = _this$asProps3.animate, lastPointColor = _this$asProps3.lastPointColor, resolveColor = _this$asProps3.resolveColor, loading = _this$asProps3.loading, styles = _this$asProps3.styles;
85
+ var points = [];
86
+ var length = this.data.length;
87
+ var step = this.defaultWidth / (length - 1);
88
+ for (var i = 0; i < length; i++) {
89
+ points.push("".concat(step * i, ",").concat(this.defaultHeight - this.data[i]));
90
+ }
91
+ var _extractAriaProps = extractAriaProps(this.asProps), __excludeProps = _extractAriaProps.__excludeProps, extractedAriaProps = _extractAriaProps.extractedAriaProps;
92
+ return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(STrendLine, _ref2.cn("STrendLine", _objectSpread({}, assignProps({
93
+ "ref": this.containerRef,
94
+ "__excludeProps": ["data"].concat(_toConsumableArray(__excludeProps))
95
+ }, _ref))), /* @__PURE__ */ React.createElement("svg", _ref2.cn("svg", _objectSpread({
96
+ "width": "100%",
97
+ "height": "100%",
98
+ "viewBox": "0 0 ".concat(this.svgWidth, " ").concat(this.svgHeight),
99
+ "role": "img"
100
+ }, extractedAriaProps)), /* @__PURE__ */ React.createElement("polyline", _ref2.cn("polyline", {
101
+ "points": points.join(" "),
102
+ "stroke": this.color,
103
+ "strokeWidth": "4",
104
+ "fill": "none",
105
+ "clipPath": "url(#".concat(uid, ")")
106
+ })), withArea && /* @__PURE__ */ React.createElement("polyline", _ref2.cn("polyline", {
107
+ "points": "0,".concat(this.defaultHeight, " ").concat(points.join(" "), " ").concat(this.defaultWidth, ",").concat(this.defaultHeight),
108
+ "fill": this.color,
109
+ "fillOpacity": 0.2,
110
+ "clipPath": "url(#".concat(uid, ")")
111
+ })), lastPointColor && !loading && /* @__PURE__ */ React.createElement("circle", _ref2.cn("circle", {
112
+ "cx": step * (length - 1),
113
+ "cy": this.defaultHeight - this.data[length - 1],
114
+ "r": this.lastPointRadius,
115
+ "fill": resolveColor(lastPointColor),
116
+ "stroke": resolveColor("chart-grid-border"),
117
+ "strokeWidth": 4,
118
+ "clipPath": "url(#".concat(uid, ")")
119
+ })), animate && !loading && /* @__PURE__ */ React.createElement("clipPath", _ref2.cn("clipPath", {
120
+ "id": uid
121
+ }), /* @__PURE__ */ React.createElement("rect", _ref2.cn("rect", {
122
+ "x": "0",
123
+ "y": "0",
124
+ "width": "100%",
125
+ "height": "100%",
126
+ "fill": "black"
127
+ }), /* @__PURE__ */ React.createElement("animate", _ref2.cn("animate", {
128
+ "dur": "500ms",
129
+ "attributeName": "width",
130
+ "values": "0;100%"
113
131
  }))))));
114
132
  }
115
- }]), s;
116
- }(D);
117
- g(l, "enhance", [$(), b()]);
118
- g(l, "style", N);
119
- g(l, "defaultProps", {
120
- animate: !0
133
+ }]);
134
+ return TrendLineRoot2;
135
+ }(Trend);
136
+ _defineProperty(TrendLineRoot, "enhance", [resolveColorEnhance(), uniqueIDEnhancement()]);
137
+ _defineProperty(TrendLineRoot, "style", style);
138
+ _defineProperty(TrendLineRoot, "defaultProps", {
139
+ animate: true
121
140
  });
122
- var M = C(l);
123
- M.displayName = "MiniChart.TrendLine";
124
- var q = C(l, {}, {
141
+ var TrendLine = createComponent(TrendLineRoot);
142
+ TrendLine.displayName = "MiniChart.TrendLine";
143
+ var TrendArea = createComponent(TrendLineRoot, {}, {
125
144
  enhancements: [function() {
126
145
  return {
127
- wrapperProps: function(d) {
128
- return S(d, {
129
- withArea: !0
146
+ wrapperProps: function wrapperProps(props) {
147
+ return assignProps(props, {
148
+ withArea: true
130
149
  });
131
150
  }
132
151
  };
133
152
  }]
134
153
  });
135
- q.displayName = "MiniChart.TrendArea";
154
+ TrendArea.displayName = "MiniChart.TrendArea";
136
155
  export {
137
- q as TrendArea,
138
- M as TrendLine
156
+ TrendArea,
157
+ TrendLine
139
158
  };
@@ -1,66 +1,78 @@
1
- import f from "@babel/runtime/helpers/esm/classCallCheck";
2
- import u from "@babel/runtime/helpers/esm/createClass";
3
- import a from "@babel/runtime/helpers/esm/assertThisInitialized";
4
- import c from "@babel/runtime/helpers/esm/inherits";
5
- import d from "@babel/runtime/helpers/esm/createSuper";
6
- import s from "@babel/runtime/helpers/esm/defineProperty";
7
- import m from "react";
8
- import { Component as p } from "@semcore/core";
9
- var R = /* @__PURE__ */ function(h) {
10
- c(n, h);
11
- var o = d(n);
12
- function n() {
13
- for (var e, t = arguments.length, r = new Array(t), i = 0; i < t; i++)
14
- r[i] = arguments[i];
15
- return f(this, n), e = o.call.apply(o, [this].concat(r)), s(a(e), "state", {
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
+ import React from "react";
8
+ import { Component } from "@semcore/core";
9
+ var Trend = /* @__PURE__ */ function(_Component) {
10
+ _inherits(Trend2, _Component);
11
+ var _super = _createSuper(Trend2);
12
+ function Trend2() {
13
+ var _this;
14
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
15
+ args[_key] = arguments[_key];
16
+ }
17
+ _classCallCheck(this, Trend2);
18
+ _this = _super.call.apply(_super, [this].concat(args));
19
+ _defineProperty(_assertThisInitialized(_this), "state", {
16
20
  width: 200,
17
21
  height: 100
18
- }), s(a(e), "containerRef", /* @__PURE__ */ m.createRef()), e;
22
+ });
23
+ _defineProperty(_assertThisInitialized(_this), "containerRef", /* @__PURE__ */ React.createRef());
24
+ return _this;
19
25
  }
20
- return u(n, [{
26
+ _createClass(Trend2, [{
21
27
  key: "componentDidMount",
22
- value: function() {
28
+ value: function componentDidMount() {
23
29
  this.setSizes();
24
30
  }
25
31
  }, {
26
32
  key: "componentDidUpdate",
27
- value: function(t) {
28
- (t.w !== this.props.w || t.h !== this.props.h || t.data !== this.props.data) && this.setSizes();
33
+ value: function componentDidUpdate(prevProps) {
34
+ if (prevProps.w !== this.props.w || prevProps.h !== this.props.h || prevProps.data !== this.props.data) {
35
+ this.setSizes();
36
+ }
29
37
  }
30
38
  }, {
31
39
  key: "defaultWidth",
32
- get: function() {
33
- var t = this.state, r = t.width, i = t.height;
34
- return r / i * this.defaultHeight;
40
+ get: function get() {
41
+ var _this$state = this.state, width = _this$state.width, height = _this$state.height;
42
+ return width / height * this.defaultHeight;
35
43
  }
36
44
  }, {
37
45
  key: "defaultHeight",
38
- get: function() {
46
+ get: function get() {
39
47
  return 100;
40
48
  }
41
49
  }, {
42
50
  key: "svgWidth",
43
- get: function() {
51
+ get: function get() {
44
52
  return this.defaultWidth;
45
53
  }
46
54
  }, {
47
55
  key: "svgHeight",
48
- get: function() {
56
+ get: function get() {
49
57
  return this.defaultHeight;
50
58
  }
51
59
  }, {
52
60
  key: "setSizes",
53
- value: function() {
61
+ value: function setSizes() {
54
62
  if (this.containerRef.current) {
55
- var t = this.containerRef.current.getBoundingClientRect(), r = t.width, i = t.height;
56
- r > 0 && i > 0 && this.setState({
57
- width: r,
58
- height: i
59
- });
63
+ var boundingClientRect = this.containerRef.current.getBoundingClientRect();
64
+ var width = boundingClientRect.width, height = boundingClientRect.height;
65
+ if (width > 0 && height > 0) {
66
+ this.setState({
67
+ width,
68
+ height
69
+ });
70
+ }
60
71
  }
61
72
  }
62
- }]), n;
63
- }(p);
73
+ }]);
74
+ return Trend2;
75
+ }(Component);
64
76
  export {
65
- R as Trend
77
+ Trend
66
78
  };
package/lib/esm/index.mjs CHANGED
@@ -1,16 +1,16 @@
1
- import { ScoreSemiDonut as r, ScoreDonut as o } from "./component/score/Donut.mjs";
2
- import { ScoreLine as e } from "./component/score/Line.mjs";
3
- import { TrendLine as m, TrendArea as i } from "./component/trend/Line.mjs";
4
- import { TrendBar as t, TrendHistogram as n } from "./component/trend/Bar.mjs";
5
- var S = {
6
- TrendLine: m,
7
- TrendArea: i,
8
- TrendBar: t,
9
- TrendHistogram: n,
10
- ScoreSemiDonut: r,
11
- ScoreDonut: o,
12
- ScoreLine: e
1
+ import { ScoreSemiDonut, ScoreDonut } from "./component/score/Donut.mjs";
2
+ import { ScoreLine } from "./component/score/Line.mjs";
3
+ import { TrendLine, TrendArea } from "./component/trend/Line.mjs";
4
+ import { TrendBar, TrendHistogram } from "./component/trend/Bar.mjs";
5
+ var miniCharts = {
6
+ TrendLine,
7
+ TrendArea,
8
+ TrendBar,
9
+ TrendHistogram,
10
+ ScoreSemiDonut,
11
+ ScoreDonut,
12
+ ScoreLine
13
13
  };
14
14
  export {
15
- S as default
15
+ miniCharts as default
16
16
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/mini-chart",
3
3
  "description": "Semrush MiniChart Component",
4
- "version": "16.0.0-prerelease.2",
4
+ "version": "16.0.0-prerelease.21",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,8 +14,8 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "peerDependencies": {
17
- "@semcore/base-components": "^16.0.0-prerelease.2",
18
- "@semcore/flex-box": "^16.0.0-prerelease.2"
17
+ "@semcore/base-components": "^16.0.0-prerelease.21",
18
+ "@semcore/flex-box": "^16.0.0-prerelease.21"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",