@semcore/mini-chart 16.1.1-prerelease.5 → 17.0.0-prerelease.17

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +4 -4
  3. package/lib/cjs/component/score/Donut.js +84 -96
  4. package/lib/cjs/component/score/Donut.js.map +1 -1
  5. package/lib/cjs/component/score/Line.js +104 -108
  6. package/lib/cjs/component/score/Line.js.map +1 -1
  7. package/lib/cjs/component/score/Line.types.js.map +1 -1
  8. package/lib/cjs/component/score/index.js +3 -3
  9. package/lib/cjs/component/trend/Bar.js +83 -96
  10. package/lib/cjs/component/trend/Bar.js.map +1 -1
  11. package/lib/cjs/component/trend/Line.js +114 -135
  12. package/lib/cjs/component/trend/Line.js.map +1 -1
  13. package/lib/cjs/component/trend/Trend.js +43 -65
  14. package/lib/cjs/component/trend/Trend.js.map +1 -1
  15. package/lib/cjs/component/trend/index.js +4 -4
  16. package/lib/cjs/index.js +3 -3
  17. package/lib/cjs/index.js.map +1 -1
  18. package/lib/cjs/utils/ScoreDonutUtils.js +48 -75
  19. package/lib/cjs/utils/ScoreDonutUtils.js.map +1 -1
  20. package/lib/es6/component/score/Donut.js +80 -93
  21. package/lib/es6/component/score/Donut.js.map +1 -1
  22. package/lib/es6/component/score/Line.js +99 -103
  23. package/lib/es6/component/score/Line.js.map +1 -1
  24. package/lib/es6/component/score/Line.types.js.map +1 -1
  25. package/lib/es6/component/trend/Bar.js +78 -91
  26. package/lib/es6/component/trend/Bar.js.map +1 -1
  27. package/lib/es6/component/trend/Line.js +109 -130
  28. package/lib/es6/component/trend/Line.js.map +1 -1
  29. package/lib/es6/component/trend/Trend.js +41 -64
  30. package/lib/es6/component/trend/Trend.js.map +1 -1
  31. package/lib/es6/index.js +8 -8
  32. package/lib/es6/index.js.map +1 -1
  33. package/lib/es6/utils/ScoreDonutUtils.js +43 -71
  34. package/lib/es6/utils/ScoreDonutUtils.js.map +1 -1
  35. package/lib/esm/component/score/Donut.mjs +80 -79
  36. package/lib/esm/component/score/Line.mjs +100 -91
  37. package/lib/esm/component/trend/Bar.mjs +79 -82
  38. package/lib/esm/component/trend/Line.mjs +110 -116
  39. package/lib/esm/component/trend/Trend.mjs +41 -61
  40. package/lib/esm/index.mjs +1 -1
  41. package/lib/esm/utils/ScoreDonutUtils.mjs +43 -71
  42. package/lib/types/component/score/Donut.d.ts +7 -12
  43. package/lib/types/component/score/Line.types.d.ts +8 -6
  44. package/lib/types/component/trend/Bar.d.ts +2 -8
  45. package/lib/types/component/trend/Line.d.ts +6 -10
  46. package/lib/types/component/trend/Trend.d.ts +3 -3
  47. package/package.json +5 -5
@@ -1,158 +1,137 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
3
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/createClass";
5
- import _callSuper from "@babel/runtime/helpers/callSuper";
6
- import _inherits from "@babel/runtime/helpers/inherits";
7
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
2
  import { sstyled as _sstyled } from "@semcore/core";
9
3
  import { assignProps as _assignProps } from "@semcore/core";
4
+ import { Box } from '@semcore/base-components';
10
5
  import { createComponent, assignProps, Root, sstyled } from '@semcore/core';
11
6
  import { extractAriaProps } from '@semcore/core/lib/utils/ariaProps';
12
7
  import resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';
13
8
  import uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';
14
- import { Box } from '@semcore/flex-box';
15
9
  import React from 'react';
16
10
  import { Trend } from './Trend';
17
11
  /*!__reshadow-styles__:"../skeleton/skeleton.shadow.css"*/
18
- var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/"@keyframes pulse_1wd8q{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_1wd8q_gg_.__loading_1wd8q_gg_,.___SLineGauge_1wd8q_gg_.__loading_1wd8q_gg_,.___STrendBar_1wd8q_gg_.__loading_1wd8q_gg_,.___STrendLine_1wd8q_gg_.__loading_1wd8q_gg_{animation-name:pulse_1wd8q;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}", /*__inner_css_end__*/"1wd8q_gg_"),
12
+ const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/"@keyframes pulse_1ydx6{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_1ydx6_gg_.__loading_1ydx6_gg_,.___SLineGauge_1ydx6_gg_.__loading_1ydx6_gg_,.___STrendBar_1ydx6_gg_.__loading_1ydx6_gg_,.___STrendLine_1ydx6_gg_.__loading_1ydx6_gg_{animation-name:pulse_1ydx6;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}", /*__inner_css_end__*/"1ydx6_gg_"),
19
13
  /*__reshadow_css_end__*/
20
14
  {
21
- "__SLineGauge": "___SLineGauge_1wd8q_gg_",
22
- "_loading": "__loading_1wd8q_gg_",
23
- "__SDonutContainer": "___SDonutContainer_1wd8q_gg_",
24
- "__STrendLine": "___STrendLine_1wd8q_gg_",
25
- "__STrendBar": "___STrendBar_1wd8q_gg_",
26
- "@pulse": "pulse_1wd8q"
15
+ "__SLineGauge": "___SLineGauge_1ydx6_gg_",
16
+ "_loading": "__loading_1ydx6_gg_",
17
+ "__SDonutContainer": "___SDonutContainer_1ydx6_gg_",
18
+ "__STrendLine": "___STrendLine_1ydx6_gg_",
19
+ "__STrendBar": "___STrendBar_1ydx6_gg_",
20
+ "@pulse": "pulse_1ydx6"
27
21
  });
28
- var TrendLineRoot = /*#__PURE__*/function (_Trend) {
29
- function TrendLineRoot() {
30
- _classCallCheck(this, TrendLineRoot);
31
- return _callSuper(this, TrendLineRoot, arguments);
22
+ class TrendLineRoot extends Trend {
23
+ get defaultData() {
24
+ return [15, 70, 20, 85, 20];
32
25
  }
33
- _inherits(TrendLineRoot, _Trend);
34
- return _createClass(TrendLineRoot, [{
35
- key: "defaultData",
36
- get: function get() {
37
- return [15, 70, 20, 85, 20];
38
- }
39
- }, {
40
- key: "lastPointRadius",
41
- get: function get() {
42
- var _this$asProps$lastPoi;
43
- return (_this$asProps$lastPoi = this.asProps.lastPointRadius) !== null && _this$asProps$lastPoi !== void 0 ? _this$asProps$lastPoi : 6;
44
- }
45
- }, {
46
- key: "data",
47
- get: function get() {
48
- var _this$asProps = this.asProps,
49
- data = _this$asProps.data,
50
- loading = _this$asProps.loading;
51
- if (loading) {
52
- return this.defaultData;
53
- }
54
- return data;
55
- }
56
- }, {
57
- key: "svgWidth",
58
- get: function get() {
59
- return this.asProps.lastPointColor ? this.defaultWidth + this.lastPointRadius : this.defaultWidth;
26
+ get lastPointRadius() {
27
+ return this.asProps.lastPointRadius ?? 6;
28
+ }
29
+ get data() {
30
+ const {
31
+ data,
32
+ loading
33
+ } = this.asProps;
34
+ if (loading) {
35
+ return this.defaultData;
60
36
  }
61
- }, {
62
- key: "svgHeight",
63
- get: function get() {
64
- return this.asProps.lastPointColor ? this.defaultHeight + this.lastPointRadius : this.defaultHeight;
37
+ return data;
38
+ }
39
+ get svgWidth() {
40
+ return this.asProps.lastPointColor ? this.defaultWidth + this.lastPointRadius : this.defaultWidth;
41
+ }
42
+ get svgHeight() {
43
+ return this.asProps.lastPointColor ? this.defaultHeight + this.lastPointRadius : this.defaultHeight;
44
+ }
45
+ get color() {
46
+ const {
47
+ resolveColor,
48
+ color = 'chart-palette-order-1',
49
+ loading
50
+ } = this.asProps;
51
+ if (loading) {
52
+ return resolveColor('skeleton-bg');
65
53
  }
66
- }, {
67
- key: "color",
68
- get: function get() {
69
- var _this$asProps2 = this.asProps,
70
- resolveColor = _this$asProps2.resolveColor,
71
- _this$asProps2$color = _this$asProps2.color,
72
- color = _this$asProps2$color === void 0 ? 'chart-palette-order-1' : _this$asProps2$color,
73
- loading = _this$asProps2.loading;
74
- if (loading) {
75
- return resolveColor('skeleton-bg');
76
- }
77
- return resolveColor(color);
54
+ return resolveColor(color);
55
+ }
56
+ render() {
57
+ var _ref = this.asProps,
58
+ _ref2;
59
+ const STrendLine = Box;
60
+ const {
61
+ uid,
62
+ withArea,
63
+ animate,
64
+ lastPointColor,
65
+ resolveColor,
66
+ loading,
67
+ styles
68
+ } = this.asProps;
69
+ const points = [];
70
+ const length = this.data.length;
71
+ const step = this.defaultWidth / (length - 1);
72
+ for (let i = 0; i < length; i++) {
73
+ points.push(`${step * i},${this.defaultHeight - this.data[i]}`);
78
74
  }
79
- }, {
80
- key: "render",
81
- value: function render() {
82
- var _ref = this.asProps,
83
- _ref2;
84
- var STrendLine = Box;
85
- var _this$asProps3 = this.asProps,
86
- uid = _this$asProps3.uid,
87
- withArea = _this$asProps3.withArea,
88
- animate = _this$asProps3.animate,
89
- lastPointColor = _this$asProps3.lastPointColor,
90
- resolveColor = _this$asProps3.resolveColor,
91
- loading = _this$asProps3.loading,
92
- styles = _this$asProps3.styles;
93
- var points = [];
94
- var length = this.data.length;
95
- var step = this.defaultWidth / (length - 1);
96
- for (var i = 0; i < length; i++) {
97
- points.push("".concat(step * i, ",").concat(this.defaultHeight - this.data[i]));
98
- }
99
- var _extractAriaProps = extractAriaProps(this.asProps),
100
- __excludeProps = _extractAriaProps.__excludeProps,
101
- extractedAriaProps = _extractAriaProps.extractedAriaProps;
102
- return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(STrendLine, _ref2.cn("STrendLine", _objectSpread({}, _assignProps({
75
+ const {
76
+ __excludeProps,
77
+ extractedAriaProps
78
+ } = extractAriaProps(this.asProps);
79
+ return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(STrendLine, _ref2.cn("STrendLine", {
80
+ ..._assignProps({
103
81
  "ref": this.containerRef,
104
- "__excludeProps": ['data'].concat(_toConsumableArray(__excludeProps))
105
- }, _ref))), /*#__PURE__*/React.createElement("svg", _ref2.cn("svg", _objectSpread({
106
- "width": '100%',
107
- "height": '100%',
108
- "viewBox": "0 0 ".concat(this.svgWidth, " ").concat(this.svgHeight),
109
- "role": 'img'
110
- }, extractedAriaProps)), /*#__PURE__*/React.createElement("polyline", _ref2.cn("polyline", {
111
- "points": points.join(' '),
112
- "stroke": this.color,
113
- "strokeWidth": '4',
114
- "fill": 'none',
115
- "clipPath": "url(#".concat(uid, ")")
116
- })), withArea && /*#__PURE__*/React.createElement("polyline", _ref2.cn("polyline", {
117
- "points": "0,".concat(this.defaultHeight, " ").concat(points.join(' '), " ").concat(this.defaultWidth, ",").concat(this.defaultHeight),
118
- "fill": this.color,
119
- "fillOpacity": 0.2,
120
- "clipPath": "url(#".concat(uid, ")")
121
- })), lastPointColor && !loading && /*#__PURE__*/React.createElement("circle", _ref2.cn("circle", {
122
- "cx": step * (length - 1),
123
- "cy": this.defaultHeight - this.data[length - 1],
124
- "r": this.lastPointRadius,
125
- "fill": resolveColor(lastPointColor),
126
- "stroke": resolveColor('chart-grid-border'),
127
- "strokeWidth": 4,
128
- "clipPath": "url(#".concat(uid, ")")
129
- })), animate && !loading && /*#__PURE__*/React.createElement("clipPath", _ref2.cn("clipPath", {
130
- "id": uid
131
- }), /*#__PURE__*/React.createElement("rect", _ref2.cn("rect", {
132
- "x": '0',
133
- "y": '0',
134
- "width": '100%',
135
- "height": '100%',
136
- "fill": 'black'
137
- }), /*#__PURE__*/React.createElement("animate", _ref2.cn("animate", {
138
- "dur": '500ms',
139
- "attributeName": 'width',
140
- "values": '0;100%'
141
- }))))));
142
- }
143
- }]);
144
- }(Trend);
82
+ "__excludeProps": ['data', ...__excludeProps]
83
+ }, _ref)
84
+ }), /*#__PURE__*/React.createElement("svg", _ref2.cn("svg", {
85
+ "width": '100%',
86
+ "height": '100%',
87
+ "viewBox": `0 0 ${this.svgWidth} ${this.svgHeight}`,
88
+ "role": 'img',
89
+ ...extractedAriaProps
90
+ }), /*#__PURE__*/React.createElement("polyline", _ref2.cn("polyline", {
91
+ "points": points.join(' '),
92
+ "stroke": this.color,
93
+ "strokeWidth": '4',
94
+ "fill": 'none',
95
+ "clipPath": `url(#${uid})`
96
+ })), withArea && /*#__PURE__*/React.createElement("polyline", _ref2.cn("polyline", {
97
+ "points": `0,${this.defaultHeight} ${points.join(' ')} ${this.defaultWidth},${this.defaultHeight}`,
98
+ "fill": this.color,
99
+ "fillOpacity": 0.2,
100
+ "clipPath": `url(#${uid})`
101
+ })), lastPointColor && !loading && /*#__PURE__*/React.createElement("circle", _ref2.cn("circle", {
102
+ "cx": step * (length - 1),
103
+ "cy": this.defaultHeight - this.data[length - 1],
104
+ "r": this.lastPointRadius,
105
+ "fill": resolveColor(lastPointColor),
106
+ "stroke": resolveColor('chart-grid-border'),
107
+ "strokeWidth": 4,
108
+ "clipPath": `url(#${uid})`
109
+ })), animate && !loading && /*#__PURE__*/React.createElement("clipPath", _ref2.cn("clipPath", {
110
+ "id": uid
111
+ }), /*#__PURE__*/React.createElement("rect", _ref2.cn("rect", {
112
+ "x": '0',
113
+ "y": '0',
114
+ "width": '100%',
115
+ "height": '100%',
116
+ "fill": 'black'
117
+ }), /*#__PURE__*/React.createElement("animate", _ref2.cn("animate", {
118
+ "dur": '500ms',
119
+ "attributeName": 'width',
120
+ "values": '0;100%'
121
+ }))))));
122
+ }
123
+ }
145
124
  _defineProperty(TrendLineRoot, "enhance", [resolveColorEnhance(), uniqueIDEnhancement()]);
146
125
  _defineProperty(TrendLineRoot, "style", style);
147
126
  _defineProperty(TrendLineRoot, "defaultProps", {
148
127
  animate: true
149
128
  });
150
- export var TrendLine = createComponent(TrendLineRoot);
129
+ export const TrendLine = createComponent(TrendLineRoot);
151
130
  TrendLine.displayName = 'MiniChart.TrendLine';
152
- export var TrendArea = createComponent(TrendLineRoot, {}, {
153
- enhancements: [function () {
131
+ export const TrendArea = createComponent(TrendLineRoot, {}, {
132
+ enhancements: [() => {
154
133
  return {
155
- wrapperProps: function wrapperProps(props) {
134
+ wrapperProps: props => {
156
135
  return assignProps(props, {
157
136
  withArea: true
158
137
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Line.js","names":["createComponent","assignProps","Root","sstyled","extractAriaProps","resolveColorEnhance","uniqueIDEnhancement","Box","React","Trend","style","_sstyled","insert","TrendLineRoot","_Trend","_classCallCheck","_callSuper","arguments","_inherits","_createClass","key","get","_this$asProps$lastPoi","asProps","lastPointRadius","_this$asProps","data","loading","defaultData","lastPointColor","defaultWidth","defaultHeight","_this$asProps2","resolveColor","_this$asProps2$color","color","value","render","_ref","_ref2","STrendLine","_this$asProps3","uid","withArea","animate","styles","points","length","step","i","push","concat","_extractAriaProps","__excludeProps","extractedAriaProps","createElement","cn","_objectSpread","_assignProps","containerRef","_toConsumableArray","svgWidth","svgHeight","join","_defineProperty","TrendLine","displayName","TrendArea","enhancements","wrapperProps","props"],"sources":["../../../../src/component/trend/Line.tsx"],"sourcesContent":["import { createComponent, type ComponentType, assignProps, Root, sstyled } from '@semcore/core';\nimport { extractAriaProps } from '@semcore/core/lib/utils/ariaProps';\nimport resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';\nimport uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';\nimport { Box } from '@semcore/flex-box';\nimport React from 'react';\n\nimport { Trend, type CommonTrendProps } from './Trend';\nimport style from '../skeleton/skeleton.shadow.css';\n\nexport type TrendLineProps = CommonTrendProps & {\n /**\n * List of values\n */\n data: number[];\n\n /**\n * Color of line\n */\n color?: string;\n\n /**\n * Color of last point in chart\n */\n lastPointColor?: string;\n\n /**\n * Radius for last point item\n */\n lastPointRadius?: number;\n};\n\ntype Enhances = {\n uid: string;\n resolveColor: ReturnType<typeof resolveColorEnhance>;\n withArea?: true;\n};\n\nclass TrendLineRoot extends Trend<TrendLineProps, typeof TrendLineRoot.enhance> {\n static enhance = [resolveColorEnhance(), uniqueIDEnhancement()] as const;\n\n static style = style;\n\n static defaultProps = {\n animate: true,\n };\n\n get defaultData(): number[] {\n return [15, 70, 20, 85, 20];\n }\n\n get lastPointRadius(): number {\n return this.asProps.lastPointRadius ?? 6;\n }\n\n get data(): number[] {\n const { data, loading } = this.asProps;\n\n if (loading) {\n return this.defaultData;\n }\n\n return data;\n }\n\n override get svgWidth(): number {\n return this.asProps.lastPointColor\n ? this.defaultWidth + this.lastPointRadius\n : this.defaultWidth;\n }\n\n override get svgHeight(): number {\n return this.asProps.lastPointColor\n ? this.defaultHeight + this.lastPointRadius\n : this.defaultHeight;\n }\n\n get color() {\n const { resolveColor, color = 'chart-palette-order-1', loading } = this.asProps;\n\n if (loading) {\n return resolveColor('skeleton-bg');\n }\n\n return resolveColor(color);\n }\n\n render() {\n const STrendLine = Root;\n const { uid, withArea, animate, lastPointColor, resolveColor, loading, styles } = this.asProps;\n\n const points: string[] = [];\n const length = this.data.length;\n const step = this.defaultWidth / (length - 1);\n\n for (let i = 0; i < length; i++) {\n points.push(`${step * i},${this.defaultHeight - this.data[i]}`);\n }\n const { __excludeProps, extractedAriaProps } = extractAriaProps(this.asProps);\n\n return sstyled(styles)(\n <STrendLine render={Box} ref={this.containerRef} __excludeProps={['data', ...__excludeProps]}>\n <svg\n width='100%'\n height='100%'\n viewBox={`0 0 ${this.svgWidth} ${this.svgHeight}`}\n role='img'\n {...extractedAriaProps}\n >\n <polyline\n points={points.join(' ')}\n stroke={this.color}\n strokeWidth='4'\n fill='none'\n clipPath={`url(#${uid})`}\n />\n {withArea && (\n <polyline\n points={`0,${this.defaultHeight} ${points.join(' ')} ${this.defaultWidth},${\n this.defaultHeight\n }`}\n fill={this.color}\n fillOpacity={0.2}\n clipPath={`url(#${uid})`}\n />\n )}\n {lastPointColor && !loading && (\n <circle\n cx={step * (length - 1)}\n cy={this.defaultHeight - this.data[length - 1]}\n r={this.lastPointRadius}\n fill={resolveColor(lastPointColor)}\n stroke={resolveColor('chart-grid-border')}\n strokeWidth={4}\n clipPath={`url(#${uid})`}\n />\n )}\n\n {animate && !loading && (\n <clipPath id={uid}>\n <rect x='0' y='0' width='100%' height='100%' fill='black'>\n <animate dur='500ms' attributeName='width' values='0;100%' />\n </rect>\n </clipPath>\n )}\n </svg>\n </STrendLine>,\n );\n }\n}\n\nexport const TrendLine: ComponentType<TrendLineProps, {}, {}, Enhances> =\n createComponent(TrendLineRoot);\n\nTrendLine.displayName = 'MiniChart.TrendLine';\n\nexport const TrendArea: ComponentType<TrendLineProps, {}, {}, Enhances> = createComponent(\n TrendLineRoot,\n {},\n {\n enhancements: [\n () => {\n return {\n wrapperProps: (props: TrendLineProps) => {\n return assignProps(props, { withArea: true });\n },\n };\n },\n ],\n },\n);\n\nTrendArea.displayName = 'MiniChart.TrendArea';\n"],"mappings":";;;;;;;;;AAAA,SAASA,eAAe,EAAsBC,WAAW,EAAEC,IAAI,EAAEC,OAAO,QAAQ,eAAe;AAC/F,SAASC,gBAAgB,QAAQ,mCAAmC;AACpE,OAAOC,mBAAmB,MAAM,sDAAsD;AACtF,OAAOC,mBAAmB,MAAM,kCAAkC;AAClE,SAASC,GAAG,QAAQ,mBAAmB;AACvC,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,KAAK,QAA+B,SAAS;AAAC;AAAA,IAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,IA+BjDC,aAAa,0BAAAC,MAAA;EAAA,SAAAD,cAAA;IAAAE,eAAA,OAAAF,aAAA;IAAA,OAAAG,UAAA,OAAAH,aAAA,EAAAI,SAAA;EAAA;EAAAC,SAAA,CAAAL,aAAA,EAAAC,MAAA;EAAA,OAAAK,YAAA,CAAAN,aAAA;IAAAO,GAAA;IAAAC,GAAA,EASjB,SAAAA,IAAA,EAA4B;MAC1B,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAC7B;EAAC;IAAAD,GAAA;IAAAC,GAAA,EAED,SAAAA,IAAA,EAA8B;MAAA,IAAAC,qBAAA;MAC5B,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AA+C,aAAA,aAAAhB,KAAA,CAAAiB,EAAA;QAAA,MAAcd;MAAG,iBACflC,KAAA,CAAA+C,aAAA,SAAAhB,KAAA,CAAAiB,EAAA;QAAA,KAAQ,GAAG;QAAA,KAAG,GAAG;QAAA,SAAO,MAAM;QAAA,UAAQ,MAAM;QAAA,QAAM;MAAO,iBACvDhD,KAAA,CAAA+C,aAAA,YAAAhB,KAAA,CAAAiB,EAAA;QAAA,OAAa,OAAO;QAAA,iBAAe,OAAO;QAAA,UAAQ;MAAQ,EAAE,CACxD,CACE,CAET,CACK,CAAC;IAEjB;EAAC;AAAA,EA9GyB/C,KAAK;AAAAuD,eAAA,CAA3BnD,aAAa,aACA,CAACR,mBAAmB,CAAC,CAAC,EAAEC,mBAAmB,CAAC,CAAC,CAAC;AAAA0D,eAAA,CAD3DnD,aAAa,WAGFH,KAAK;AAAAsD,eAAA,CAHhBnD,aAAa,kBAKK;EACpB+B,OAAO,EAAE;AACX,CAAC;AA0GH,OAAO,IAAMqB,SAA0D,GACrEjE,eAAe,CAACa,aAAa,CAAC;AAEhCoD,SAAS,CAACC,WAAW,GAAG,qBAAqB;AAE7C,OAAO,IAAMC,SAA0D,GAAGnE,eAAe,CACvFa,aAAa,EACb,CAAC,CAAC,EACF;EACEuD,YAAY,EAAE,CACZ,YAAM;IACJ,OAAO;MACLC,YAAY,EAAE,SAAdA,YAAYA,CAAGC,KAAqB,EAAK;QACvC,OAAOrE,WAAW,CAACqE,KAAK,EAAE;UAAE3B,QAAQ,EAAE;QAAK,CAAC,CAAC;MAC/C;IACF,CAAC;EACH,CAAC;AAEL,CACF,CAAC;AAEDwB,SAAS,CAACD,WAAW,GAAG,qBAAqB","ignoreList":[]}
1
+ {"version":3,"file":"Line.js","names":["Box","createComponent","assignProps","Root","sstyled","extractAriaProps","resolveColorEnhance","uniqueIDEnhancement","React","Trend","style","_sstyled","insert","TrendLineRoot","defaultData","lastPointRadius","asProps","data","loading","svgWidth","lastPointColor","defaultWidth","svgHeight","defaultHeight","color","resolveColor","render","_ref","_ref2","STrendLine","uid","withArea","animate","styles","points","length","step","i","push","__excludeProps","extractedAriaProps","createElement","cn","_assignProps","containerRef","join","_defineProperty","TrendLine","displayName","TrendArea","enhancements","wrapperProps","props"],"sources":["../../../../src/component/trend/Line.tsx"],"sourcesContent":["import { Box } from '@semcore/base-components';\nimport { createComponent, assignProps, Root, sstyled } from '@semcore/core';\nimport { extractAriaProps } from '@semcore/core/lib/utils/ariaProps';\nimport resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';\nimport uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';\nimport React from 'react';\n\nimport { Trend, type CommonTrendProps } from './Trend';\nimport style from '../skeleton/skeleton.shadow.css';\n\nexport type TrendLineProps = CommonTrendProps & {\n /**\n * List of values\n */\n data: number[];\n\n /**\n * Color of line\n */\n color?: string;\n\n /**\n * Color of last point in chart\n */\n lastPointColor?: string;\n\n /**\n * Radius for last point item\n */\n lastPointRadius?: number;\n};\n\nclass TrendLineRoot extends Trend<TrendLineProps, typeof TrendLineRoot.enhance> {\n static enhance = [resolveColorEnhance(), uniqueIDEnhancement()] as const;\n\n static style = style;\n\n static defaultProps = {\n animate: true,\n };\n\n get defaultData(): number[] {\n return [15, 70, 20, 85, 20];\n }\n\n get lastPointRadius(): number {\n return this.asProps.lastPointRadius ?? 6;\n }\n\n get data(): number[] {\n const { data, loading } = this.asProps;\n\n if (loading) {\n return this.defaultData;\n }\n\n return data;\n }\n\n override get svgWidth(): number {\n return this.asProps.lastPointColor\n ? this.defaultWidth + this.lastPointRadius\n : this.defaultWidth;\n }\n\n override get svgHeight(): number {\n return this.asProps.lastPointColor\n ? this.defaultHeight + this.lastPointRadius\n : this.defaultHeight;\n }\n\n get color() {\n const { resolveColor, color = 'chart-palette-order-1', loading } = this.asProps;\n\n if (loading) {\n return resolveColor('skeleton-bg');\n }\n\n return resolveColor(color);\n }\n\n render() {\n const STrendLine = Root;\n const { uid, withArea, animate, lastPointColor, resolveColor, loading, styles } = this.asProps;\n\n const points: string[] = [];\n const length = this.data.length;\n const step = this.defaultWidth / (length - 1);\n\n for (let i = 0; i < length; i++) {\n points.push(`${step * i},${this.defaultHeight - this.data[i]}`);\n }\n const { __excludeProps, extractedAriaProps } = extractAriaProps(this.asProps);\n\n return sstyled(styles)(\n <STrendLine render={Box} ref={this.containerRef} __excludeProps={['data', ...__excludeProps]}>\n <svg\n width='100%'\n height='100%'\n viewBox={`0 0 ${this.svgWidth} ${this.svgHeight}`}\n role='img'\n {...extractedAriaProps}\n >\n <polyline\n points={points.join(' ')}\n stroke={this.color}\n strokeWidth='4'\n fill='none'\n clipPath={`url(#${uid})`}\n />\n {withArea && (\n <polyline\n points={`0,${this.defaultHeight} ${points.join(' ')} ${this.defaultWidth},${\n this.defaultHeight\n }`}\n fill={this.color}\n fillOpacity={0.2}\n clipPath={`url(#${uid})`}\n />\n )}\n {lastPointColor && !loading && (\n <circle\n cx={step * (length - 1)}\n cy={this.defaultHeight - this.data[length - 1]}\n r={this.lastPointRadius}\n fill={resolveColor(lastPointColor)}\n stroke={resolveColor('chart-grid-border')}\n strokeWidth={4}\n clipPath={`url(#${uid})`}\n />\n )}\n\n {animate && !loading && (\n <clipPath id={uid}>\n <rect x='0' y='0' width='100%' height='100%' fill='black'>\n <animate dur='500ms' attributeName='width' values='0;100%' />\n </rect>\n </clipPath>\n )}\n </svg>\n </STrendLine>,\n );\n }\n}\n\nexport const TrendLine = createComponent<'svg', TrendLineProps, {}, typeof TrendLineRoot.enhance>(TrendLineRoot);\n\nTrendLine.displayName = 'MiniChart.TrendLine';\n\nexport const TrendArea = createComponent<'svg', TrendLineProps, {}, typeof TrendLineRoot.enhance>(\n TrendLineRoot,\n {},\n {\n enhancements: [\n () => {\n return {\n wrapperProps: (props: TrendLineProps) => {\n return assignProps(props, { withArea: true });\n },\n };\n },\n ],\n },\n);\n\nTrendArea.displayName = 'MiniChart.TrendArea';\n"],"mappings":";;;AAAA,SAASA,G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QAAM;IAAO,iBACvDlC,KAAA,CAAAiC,aAAA,YAAAb,KAAA,CAAAc,EAAA;MAAA,OAAa,OAAO;MAAA,iBAAe,OAAO;MAAA,UAAQ;IAAQ,EAAE,CACxD,CACE,CAET,CACK,CAAC;EAEjB;AACF;AAACI,eAAA,CA/GKjC,aAAa,aACA,CAACP,mBAAmB,CAAC,CAAC,EAAEC,mBAAmB,CAAC,CAAC,CAAC;AAAAuC,eAAA,CAD3DjC,aAAa,WAGFH,KAAK;AAAAoC,eAAA,CAHhBjC,aAAa,kBAKK;EACpBmB,OAAO,EAAE;AACX,CAAC;AA0GH,OAAO,MAAMe,SAAS,GAAG9C,eAAe,CAA0DY,aAAa,CAAC;AAEhHkC,SAAS,CAACC,WAAW,GAAG,qBAAqB;AAE7C,OAAO,MAAMC,SAAS,GAAGhD,eAAe,CACtCY,aAAa,EACb,CAAC,CAAC,EACF;EACEqC,YAAY,EAAE,CACZ,MAAM;IACJ,OAAO;MACLC,YAAY,EAAGC,KAAqB,IAAK;QACvC,OAAOlD,WAAW,CAACkD,KAAK,EAAE;UAAErB,QAAQ,EAAE;QAAK,CAAC,CAAC;MAC/C;IACF,CAAC;EACH,CAAC;AAEL,CACF,CAAC;AAEDkB,SAAS,CAACD,WAAW,GAAG,qBAAqB","ignoreList":[]}
@@ -1,76 +1,53 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _callSuper from "@babel/runtime/helpers/callSuper";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
2
  import { Component } from '@semcore/core';
7
3
  import React from 'react';
8
- export var Trend = /*#__PURE__*/function (_Component) {
9
- function Trend() {
10
- var _this;
11
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
12
- args[_key] = arguments[_key];
13
- }
14
- _classCallCheck(this, Trend);
15
- _this = _callSuper(this, Trend, [].concat(args));
16
- _defineProperty(_this, "state", {
4
+ export class Trend extends Component {
5
+ constructor(...args) {
6
+ super(...args);
7
+ _defineProperty(this, "state", {
17
8
  width: 200,
18
9
  height: 100
19
10
  });
20
- _defineProperty(_this, "containerRef", /*#__PURE__*/React.createRef());
21
- return _this;
11
+ _defineProperty(this, "containerRef", /*#__PURE__*/React.createRef());
12
+ }
13
+ componentDidMount() {
14
+ this.setSizes();
22
15
  }
23
- _inherits(Trend, _Component);
24
- return _createClass(Trend, [{
25
- key: "componentDidMount",
26
- value: function componentDidMount() {
16
+ componentDidUpdate(prevProps) {
17
+ if (prevProps.w !== this.props.w || prevProps.h !== this.props.h || prevProps.data !== this.props.data) {
27
18
  this.setSizes();
28
19
  }
29
- }, {
30
- key: "componentDidUpdate",
31
- value: function componentDidUpdate(prevProps) {
32
- if (prevProps.w !== this.props.w || prevProps.h !== this.props.h || prevProps.data !== this.props.data) {
33
- this.setSizes();
34
- }
35
- }
36
- }, {
37
- key: "defaultWidth",
38
- get: function get() {
39
- var _this$state = this.state,
40
- width = _this$state.width,
41
- height = _this$state.height;
42
- return width / height * this.defaultHeight;
43
- }
44
- }, {
45
- key: "defaultHeight",
46
- get: function get() {
47
- return 100;
48
- }
49
- }, {
50
- key: "svgWidth",
51
- get: function get() {
52
- return this.defaultWidth;
53
- }
54
- }, {
55
- key: "svgHeight",
56
- get: function get() {
57
- return this.defaultHeight;
58
- }
59
- }, {
60
- key: "setSizes",
61
- value: function setSizes() {
62
- if (this.containerRef.current) {
63
- var boundingClientRect = this.containerRef.current.getBoundingClientRect();
64
- var width = boundingClientRect.width,
65
- height = boundingClientRect.height;
66
- if (width > 0 && height > 0) {
67
- this.setState({
68
- width: width,
69
- height: height
70
- });
71
- }
20
+ }
21
+ get defaultWidth() {
22
+ const {
23
+ width,
24
+ height
25
+ } = this.state;
26
+ return width / height * this.defaultHeight;
27
+ }
28
+ get defaultHeight() {
29
+ return 100;
30
+ }
31
+ get svgWidth() {
32
+ return this.defaultWidth;
33
+ }
34
+ get svgHeight() {
35
+ return this.defaultHeight;
36
+ }
37
+ setSizes() {
38
+ if (this.containerRef.current) {
39
+ const boundingClientRect = this.containerRef.current.getBoundingClientRect();
40
+ const {
41
+ width,
42
+ height
43
+ } = boundingClientRect;
44
+ if (width > 0 && height > 0) {
45
+ this.setState({
46
+ width,
47
+ height
48
+ });
72
49
  }
73
50
  }
74
- }]);
75
- }(Component);
51
+ }
52
+ }
76
53
  //# sourceMappingURL=Trend.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Trend.js","names":["Component","React","Trend","_Component","_this","_len","arguments","length","args","Array","_key","_classCallCheck","_callSuper","concat","_defineProperty","width","height","createRef","_inherits","_createClass","key","value","componentDidMount","setSizes","componentDidUpdate","prevProps","w","props","h","data","get","_this$state","state","defaultHeight","defaultWidth","containerRef","current","boundingClientRect","getBoundingClientRect","setState"],"sources":["../../../../src/component/trend/Trend.tsx"],"sourcesContent":["import { Component } from '@semcore/core';\nimport type { BoxProps } from '@semcore/flex-box';\nimport React from 'react';\n\nexport type CommonTrendProps = BoxProps & {\n /**\n * Flag to enable animate of charts\n * @default true\n */\n animate?: boolean;\n\n /**\n * Flag to enable skeleton\n * @default false\n */\n loading?: boolean;\n\n /**\n * Data for chart\n */\n data: any[];\n};\n\nexport abstract class Trend<\n P extends CommonTrendProps,\n E extends readonly ((...args: any[]) => any)[],\n> extends Component<P, {}, { width: number; height: number }, E> {\n state = {\n width: 200,\n height: 100,\n };\n\n containerRef = React.createRef<HTMLDivElement>();\n\n componentDidMount() {\n this.setSizes();\n }\n\n componentDidUpdate(prevProps: P) {\n if (\n prevProps.w !== this.props.w ||\n prevProps.h !== this.props.h ||\n prevProps.data !== this.props.data\n ) {\n this.setSizes();\n }\n }\n\n get defaultWidth(): number {\n const { width, height } = this.state;\n\n return (width / height) * this.defaultHeight;\n }\n\n get defaultHeight(): number {\n return 100;\n }\n\n get svgWidth(): number {\n return this.defaultWidth;\n }\n\n get svgHeight(): number {\n return this.defaultHeight;\n }\n\n setSizes() {\n if (this.containerRef.current) {\n const boundingClientRect = this.containerRef.current.getBoundingClientRect();\n\n const { width, height } = boundingClientRect;\n\n if (width > 0 && height > 0) {\n this.setState({ width, height });\n }\n }\n }\n}\n"],"mappings":";;;;;AAAA,SAASA,SAAS,QAAQ,eAAe;AAEzC,OAAOC,KAAK,MAAM,OAAO;AAqBzB,WAAsBC,KAAK,0BAAAC,UAAA;EAAA,SAAAD,MAAA;IAAA,IAAAE,KAAA;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC,IAAA,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAAF,IAAA,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAAAC,eAAA,OAAAT,KAAA;IAAAE,KAAA,GAAAQ,UAAA,OAAAV,KAAA,KAAAW,MAAA,CAAAL,IAAA;IAAAM,eAAA,CAAAV,KAAA,WAIjB;MACNW,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE;IACV,CAAC;IAAAF,eAAA,CAAAV,KAAA,+BAEcH,KAAK,CAACgB,SAAS,CAAiB,CAAC;IAAA,OAAAb,KAAA;EAAA;EAAAc,SAAA,CAAAhB,KAAA,EAAAC,UAAA;EAAA,OAAAgB,YAAA,CAAAjB,KAAA;IAAAkB,GAAA;IAAAC,KAAA,EAEhD,SAAAC,iBAAiBA,CAAA,EAAG;MAClB,IAAI,CAACC,QAAQ,CAAC,CAAC;IACjB;EAAC;IAAAH,GAAA;IAAAC,KAAA,EAED,SAAAG,kBAAkBA,CAACC,SAAY,EAAE;MAC/B,IACEA,SAAS,CAACC,CAAC,KAAK,IAAI,CAACC,KAAK,CAACD,CAAC,IAC5BD,SAAS,CAACG,CAAC,KAAK,IAAI,CAACD,KAAK,CAACC,CAAC,IAC5BH,SAAS,CAACI,IAAI,KAAK,IAAI,CAACF,KAAK,CAACE,IAAI,EAClC;QACA,IAAI,CAACN,QAAQ,CAAC,CAAC;MACjB;IACF;EAAC;IAAAH,GAAA;IAAAU,GAAA,EAED,SAAAA,IAAA,EAA2B;MACzB,IAAAC,WAAA,GAA0B,IAAI,CAACC,KAAK;QAA5BjB,KAAK,GAAAgB,WAAA,CAALhB,KAAK;QAAEC,MAAM,GAAAe,WAAA,CAANf,MAAM;MAErB,OAAQD,KAAK,GAAGC,MAAM,GAAI,IAAI,CAACiB,aAAa;IAC9C;EAAC;IAAAb,GAAA;IAAAU,GAAA,EAED,SAAAA,IAAA,EAA4B;MAC1B,OAAO,GAAG;IACZ;EAAC;IAAAV,GAAA;IAAAU,GAAA,EAED,SAAAA,IAAA,EAAuB;MACrB,OAAO,IAAI,CAACI,YAAY;IAC1B;EAAC;IAAAd,GAAA;IAAAU,GAAA,EAED,SAAAA,IAAA,EAAwB;MACtB,OAAO,IAAI,CAACG,aAAa;IAC3B;EAAC;IAAAb,GAAA;IAAAC,KAAA,EAED,SAAAE,QAAQA,CAAA,EAAG;MACT,IAAI,IAAI,CAACY,YAAY,CAACC,OAAO,EAAE;QAC7B,IAAMC,kBAAkB,GAAG,IAAI,CAACF,YAAY,CAACC,OAAO,CAACE,qBAAqB,CAAC,CAAC;QAE5E,IAAQvB,KAAK,GAAasB,kBAAkB,CAApCtB,KAAK;UAAEC,MAAM,GAAKqB,kBAAkB,CAA7BrB,MAAM;QAErB,IAAID,KAAK,GAAG,CAAC,IAAIC,MAAM,GAAG,CAAC,EAAE;UAC3B,IAAI,CAACuB,QAAQ,CAAC;YAAExB,KAAK,EAALA,KAAK;YAAEC,MAAM,EAANA;UAAO,CAAC,CAAC;QAClC;MACF;IACF;EAAC;AAAA,EAlDOhB,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"Trend.js","names":["Component","React","Trend","constructor","args","_defineProperty","width","height","createRef","componentDidMount","setSizes","componentDidUpdate","prevProps","w","props","h","data","defaultWidth","state","defaultHeight","svgWidth","svgHeight","containerRef","current","boundingClientRect","getBoundingClientRect","setState"],"sources":["../../../../src/component/trend/Trend.tsx"],"sourcesContent":["import type { BoxProps } from '@semcore/base-components';\nimport { Component } from '@semcore/core';\nimport React from 'react';\n\nexport type CommonTrendProps = BoxProps & {\n /**\n * Flag to enable animate of charts\n * @default true\n */\n animate?: boolean;\n\n /**\n * Flag to enable skeleton\n * @default false\n */\n loading?: boolean;\n\n /**\n * Data for chart\n */\n data: any[];\n};\n\nexport abstract class Trend<\n P extends CommonTrendProps,\n E extends readonly ((...args: any[]) => any)[],\n> extends Component<P, E, Readonly<{}>, { width: number; height: number }> {\n state = {\n width: 200,\n height: 100,\n };\n\n containerRef = React.createRef<HTMLDivElement>();\n\n componentDidMount() {\n this.setSizes();\n }\n\n componentDidUpdate(prevProps: P) {\n if (\n prevProps.w !== this.props.w ||\n prevProps.h !== this.props.h ||\n prevProps.data !== this.props.data\n ) {\n this.setSizes();\n }\n }\n\n get defaultWidth(): number {\n const { width, height } = this.state;\n\n return (width / height) * this.defaultHeight;\n }\n\n get defaultHeight(): number {\n return 100;\n }\n\n get svgWidth(): number {\n return this.defaultWidth;\n }\n\n get svgHeight(): number {\n return this.defaultHeight;\n }\n\n setSizes() {\n if (this.containerRef.current) {\n const boundingClientRect = this.containerRef.current.getBoundingClientRect();\n\n const { width, height } = boundingClientRect;\n\n if (width > 0 && height > 0) {\n this.setState({ width, height });\n }\n }\n }\n}\n"],"mappings":";AACA,SAASA,SAAS,QAAQ,eAAe;AACzC,OAAOC,KAAK,MAAM,OAAO;AAqBzB,OAAO,MAAeC,KAAK,SAGjBF,SAAS,CAAwD;EAAAG,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,gBACjE;MACNC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE;IACV,CAAC;IAAAF,eAAA,oCAEcJ,KAAK,CAACO,SAAS,CAAiB,CAAC;EAAA;EAEhDC,iBAAiBA,CAAA,EAAG;IAClB,IAAI,CAACC,QAAQ,CAAC,CAAC;EACjB;EAEAC,kBAAkBA,CAACC,SAAY,EAAE;IAC/B,IACEA,SAAS,CAACC,CAAC,KAAK,IAAI,CAACC,KAAK,CAACD,CAAC,IAC5BD,SAAS,CAACG,CAAC,KAAK,IAAI,CAACD,KAAK,CAACC,CAAC,IAC5BH,SAAS,CAACI,IAAI,KAAK,IAAI,CAACF,KAAK,CAACE,IAAI,EAClC;MACA,IAAI,CAACN,QAAQ,CAAC,CAAC;IACjB;EACF;EAEA,IAAIO,YAAYA,CAAA,EAAW;IACzB,MAAM;MAAEX,KAAK;MAAEC;IAAO,CAAC,GAAG,IAAI,CAACW,KAAK;IAEpC,OAAQZ,KAAK,GAAGC,MAAM,GAAI,IAAI,CAACY,aAAa;EAC9C;EAEA,IAAIA,aAAaA,CAAA,EAAW;IAC1B,OAAO,GAAG;EACZ;EAEA,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACH,YAAY;EAC1B;EAEA,IAAII,SAASA,CAAA,EAAW;IACtB,OAAO,IAAI,CAACF,aAAa;EAC3B;EAEAT,QAAQA,CAAA,EAAG;IACT,IAAI,IAAI,CAACY,YAAY,CAACC,OAAO,EAAE;MAC7B,MAAMC,kBAAkB,GAAG,IAAI,CAACF,YAAY,CAACC,OAAO,CAACE,qBAAqB,CAAC,CAAC;MAE5E,MAAM;QAAEnB,KAAK;QAAEC;MAAO,CAAC,GAAGiB,kBAAkB;MAE5C,IAAIlB,KAAK,GAAG,CAAC,IAAIC,MAAM,GAAG,CAAC,EAAE;QAC3B,IAAI,CAACmB,QAAQ,CAAC;UAAEpB,KAAK;UAAEC;QAAO,CAAC,CAAC;MAClC;IACF;EACF;AACF","ignoreList":[]}
package/lib/es6/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { ScoreLine, ScoreDonut, ScoreSemiDonut } from './component/score';
2
2
  import { TrendLine, TrendArea, TrendBar, TrendHistogram } from './component/trend';
3
- var miniCharts = {
4
- TrendLine: TrendLine,
5
- TrendArea: TrendArea,
6
- TrendBar: TrendBar,
7
- TrendHistogram: TrendHistogram,
8
- ScoreSemiDonut: ScoreSemiDonut,
9
- ScoreDonut: ScoreDonut,
10
- ScoreLine: ScoreLine
3
+ const miniCharts = {
4
+ TrendLine,
5
+ TrendArea,
6
+ TrendBar,
7
+ TrendHistogram,
8
+ ScoreSemiDonut,
9
+ ScoreDonut,
10
+ ScoreLine
11
11
  };
12
12
  export default miniCharts;
13
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ScoreLine","ScoreDonut","ScoreSemiDonut","TrendLine","TrendArea","TrendBar","TrendHistogram","miniCharts"],"sources":["../../src/index.ts"],"sourcesContent":["import { ScoreLine, ScoreDonut, ScoreSemiDonut } from './component/score';\nimport { TrendLine, TrendArea, TrendBar, TrendHistogram } from './component/trend';\n\nconst miniCharts: {\n TrendLine: typeof TrendLine;\n TrendArea: typeof TrendArea;\n TrendBar: typeof TrendBar;\n TrendHistogram: typeof TrendHistogram;\n ScoreSemiDonut: typeof ScoreSemiDonut;\n ScoreDonut: typeof ScoreDonut;\n ScoreLine: typeof ScoreLine;\n} = {\n TrendLine,\n TrendArea,\n TrendBar,\n TrendHistogram,\n ScoreSemiDonut,\n ScoreDonut,\n ScoreLine,\n};\n\nexport default miniCharts;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,UAAU,EAAEC,cAAc,QAAQ,mBAAmB;AACzE,SAASC,SAAS,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,mBAAmB;AAElF,IAAMC,UAQL,GAAG;EACFJ,SAAS,EAATA,SAAS;EACTC,SAAS,EAATA,SAAS;EACTC,QAAQ,EAARA,QAAQ;EACRC,cAAc,EAAdA,cAAc;EACdJ,cAAc,EAAdA,cAAc;EACdD,UAAU,EAAVA,UAAU;EACVD,SAAS,EAATA;AACF,CAAC;AAED,eAAeO,UAAU","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["ScoreLine","ScoreDonut","ScoreSemiDonut","TrendLine","TrendArea","TrendBar","TrendHistogram","miniCharts"],"sources":["../../src/index.ts"],"sourcesContent":["import { ScoreLine, ScoreDonut, ScoreSemiDonut } from './component/score';\nimport { TrendLine, TrendArea, TrendBar, TrendHistogram } from './component/trend';\n\nconst miniCharts: {\n TrendLine: typeof TrendLine;\n TrendArea: typeof TrendArea;\n TrendBar: typeof TrendBar;\n TrendHistogram: typeof TrendHistogram;\n ScoreSemiDonut: typeof ScoreSemiDonut;\n ScoreDonut: typeof ScoreDonut;\n ScoreLine: typeof ScoreLine;\n} = {\n TrendLine,\n TrendArea,\n TrendBar,\n TrendHistogram,\n ScoreSemiDonut,\n ScoreDonut,\n ScoreLine,\n};\n\nexport default miniCharts;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,UAAU,EAAEC,cAAc,QAAQ,mBAAmB;AACzE,SAASC,SAAS,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,mBAAmB;AAElF,MAAMC,UAQL,GAAG;EACFJ,SAAS;EACTC,SAAS;EACTC,QAAQ;EACRC,cAAc;EACdJ,cAAc;EACdD,UAAU;EACVD;AACF,CAAC;AAED,eAAeO,UAAU","ignoreList":[]}
@@ -1,9 +1,6 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- export var ScoreDonutUtils = /*#__PURE__*/function () {
5
- function ScoreDonutUtils(value, isSemiDonut) {
6
- _classCallCheck(this, ScoreDonutUtils);
2
+ export class ScoreDonutUtils {
3
+ constructor(value, isSemiDonut) {
7
4
  _defineProperty(this, "isSemiDonut", void 0);
8
5
  _defineProperty(this, "value", void 0);
9
6
  _defineProperty(this, "radius", void 0);
@@ -11,70 +8,45 @@ export var ScoreDonutUtils = /*#__PURE__*/function () {
11
8
  this.radius = isSemiDonut ? 9 : 10;
12
9
  this.value = Math.max(Math.min(value, 100), 0);
13
10
  }
14
- return _createClass(ScoreDonutUtils, [{
15
- key: "viewBox",
16
- get: function get() {
17
- return this.isSemiDonut ? '0 0 24 12' : '0 0 24 24';
18
- }
19
- }, {
20
- key: "strokeWidth",
21
- get: function get() {
22
- return this.isSemiDonut ? 6 : 4;
23
- }
24
- }, {
25
- key: "fullLength",
26
- get: function get() {
27
- return this.isSemiDonut ? Math.PI * this.radius : 2 * Math.PI * this.radius;
28
- }
29
- }, {
30
- key: "point",
31
- get: function get() {
32
- return this.isSemiDonut ? this.fullLength / (100 / 3) : this.fullLength / 100;
33
- }
34
- }, {
35
- key: "valueLength",
36
- get: function get() {
37
- return this.fullLength * (this.value / 100);
38
- }
39
- }, {
40
- key: "animatedValueLength",
41
- get: function get() {
42
- return Math.min(this.valueLength, this.fullLength - this.startMargin - this.endMargin);
43
- }
44
- }, {
45
- key: "startMargin",
46
- get: function get() {
47
- var margin = 0;
48
- if (this.value > 0) margin = this.point;
49
- return margin;
50
- }
51
- }, {
52
- key: "endMargin",
53
- get: function get() {
54
- var margin = 0;
55
- if (!this.isSemiDonut && this.value > 0) margin = this.point;
56
- return margin;
57
- }
58
- }, {
59
- key: "baseOffset",
60
- get: function get() {
61
- return -1 * (this.valueLength + this.startMargin);
62
- }
63
- }, {
64
- key: "baseLength",
65
- get: function get() {
66
- return Math.max(this.fullLength - this.valueLength - this.startMargin - this.endMargin, 0);
67
- }
68
- }, {
69
- key: "animatedBaseLengthFrom",
70
- get: function get() {
71
- return this.fullLength - this.startMargin - this.endMargin;
72
- }
73
- }, {
74
- key: "animatedBaseLengthTo",
75
- get: function get() {
76
- return this.fullLength - this.valueLength - this.startMargin - this.endMargin;
77
- }
78
- }]);
79
- }();
11
+ get viewBox() {
12
+ return this.isSemiDonut ? '0 0 24 12' : '0 0 24 24';
13
+ }
14
+ get strokeWidth() {
15
+ return this.isSemiDonut ? 6 : 4;
16
+ }
17
+ get fullLength() {
18
+ return this.isSemiDonut ? Math.PI * this.radius : 2 * Math.PI * this.radius;
19
+ }
20
+ get point() {
21
+ return this.isSemiDonut ? this.fullLength / (100 / 3) : this.fullLength / 100;
22
+ }
23
+ get valueLength() {
24
+ return this.fullLength * (this.value / 100);
25
+ }
26
+ get animatedValueLength() {
27
+ return Math.min(this.valueLength, this.fullLength - this.startMargin - this.endMargin);
28
+ }
29
+ get startMargin() {
30
+ let margin = 0;
31
+ if (this.value > 0) margin = this.point;
32
+ return margin;
33
+ }
34
+ get endMargin() {
35
+ let margin = 0;
36
+ if (!this.isSemiDonut && this.value > 0) margin = this.point;
37
+ return margin;
38
+ }
39
+ get baseOffset() {
40
+ return -1 * (this.valueLength + this.startMargin);
41
+ }
42
+ get baseLength() {
43
+ return Math.max(this.fullLength - this.valueLength - this.startMargin - this.endMargin, 0);
44
+ }
45
+ get animatedBaseLengthFrom() {
46
+ return this.fullLength - this.startMargin - this.endMargin;
47
+ }
48
+ get animatedBaseLengthTo() {
49
+ return this.fullLength - this.valueLength - this.startMargin - this.endMargin;
50
+ }
51
+ }
80
52
  //# sourceMappingURL=ScoreDonutUtils.js.map