@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.
- package/CHANGELOG.md +7 -1
- package/README.md +4 -4
- package/lib/cjs/component/score/Donut.js +84 -96
- package/lib/cjs/component/score/Donut.js.map +1 -1
- package/lib/cjs/component/score/Line.js +104 -108
- package/lib/cjs/component/score/Line.js.map +1 -1
- package/lib/cjs/component/score/Line.types.js.map +1 -1
- package/lib/cjs/component/score/index.js +3 -3
- package/lib/cjs/component/trend/Bar.js +83 -96
- package/lib/cjs/component/trend/Bar.js.map +1 -1
- package/lib/cjs/component/trend/Line.js +114 -135
- package/lib/cjs/component/trend/Line.js.map +1 -1
- package/lib/cjs/component/trend/Trend.js +43 -65
- package/lib/cjs/component/trend/Trend.js.map +1 -1
- package/lib/cjs/component/trend/index.js +4 -4
- package/lib/cjs/index.js +3 -3
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils/ScoreDonutUtils.js +48 -75
- package/lib/cjs/utils/ScoreDonutUtils.js.map +1 -1
- package/lib/es6/component/score/Donut.js +80 -93
- package/lib/es6/component/score/Donut.js.map +1 -1
- package/lib/es6/component/score/Line.js +99 -103
- package/lib/es6/component/score/Line.js.map +1 -1
- package/lib/es6/component/score/Line.types.js.map +1 -1
- package/lib/es6/component/trend/Bar.js +78 -91
- package/lib/es6/component/trend/Bar.js.map +1 -1
- package/lib/es6/component/trend/Line.js +109 -130
- package/lib/es6/component/trend/Line.js.map +1 -1
- package/lib/es6/component/trend/Trend.js +41 -64
- package/lib/es6/component/trend/Trend.js.map +1 -1
- package/lib/es6/index.js +8 -8
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/utils/ScoreDonutUtils.js +43 -71
- package/lib/es6/utils/ScoreDonutUtils.js.map +1 -1
- package/lib/esm/component/score/Donut.mjs +80 -79
- package/lib/esm/component/score/Line.mjs +100 -91
- package/lib/esm/component/trend/Bar.mjs +79 -82
- package/lib/esm/component/trend/Line.mjs +110 -116
- package/lib/esm/component/trend/Trend.mjs +41 -61
- package/lib/esm/index.mjs +1 -1
- package/lib/esm/utils/ScoreDonutUtils.mjs +43 -71
- package/lib/types/component/score/Donut.d.ts +7 -12
- package/lib/types/component/score/Line.types.d.ts +8 -6
- package/lib/types/component/trend/Bar.d.ts +2 -8
- package/lib/types/component/trend/Line.d.ts +6 -10
- package/lib/types/component/trend/Trend.d.ts +3 -3
- package/package.json +5 -5
|
@@ -1,87 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.ScoreDonutUtils = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
(0,
|
|
14
|
-
(0, _defineProperty2
|
|
15
|
-
(0, _defineProperty2
|
|
16
|
-
(0, _defineProperty2["default"])(this, "radius", void 0);
|
|
9
|
+
class ScoreDonutUtils {
|
|
10
|
+
constructor(value, isSemiDonut) {
|
|
11
|
+
(0, _defineProperty2.default)(this, "isSemiDonut", void 0);
|
|
12
|
+
(0, _defineProperty2.default)(this, "value", void 0);
|
|
13
|
+
(0, _defineProperty2.default)(this, "radius", void 0);
|
|
17
14
|
this.isSemiDonut = isSemiDonut;
|
|
18
15
|
this.radius = isSemiDonut ? 9 : 10;
|
|
19
16
|
this.value = Math.max(Math.min(value, 100), 0);
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return margin;
|
|
64
|
-
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "baseOffset",
|
|
67
|
-
get: function get() {
|
|
68
|
-
return -1 * (this.valueLength + this.startMargin);
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "baseLength",
|
|
72
|
-
get: function get() {
|
|
73
|
-
return Math.max(this.fullLength - this.valueLength - this.startMargin - this.endMargin, 0);
|
|
74
|
-
}
|
|
75
|
-
}, {
|
|
76
|
-
key: "animatedBaseLengthFrom",
|
|
77
|
-
get: function get() {
|
|
78
|
-
return this.fullLength - this.startMargin - this.endMargin;
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
key: "animatedBaseLengthTo",
|
|
82
|
-
get: function get() {
|
|
83
|
-
return this.fullLength - this.valueLength - this.startMargin - this.endMargin;
|
|
84
|
-
}
|
|
85
|
-
}]);
|
|
86
|
-
}();
|
|
18
|
+
get viewBox() {
|
|
19
|
+
return this.isSemiDonut ? '0 0 24 12' : '0 0 24 24';
|
|
20
|
+
}
|
|
21
|
+
get strokeWidth() {
|
|
22
|
+
return this.isSemiDonut ? 6 : 4;
|
|
23
|
+
}
|
|
24
|
+
get fullLength() {
|
|
25
|
+
return this.isSemiDonut ? Math.PI * this.radius : 2 * Math.PI * this.radius;
|
|
26
|
+
}
|
|
27
|
+
get point() {
|
|
28
|
+
return this.isSemiDonut ? this.fullLength / (100 / 3) : this.fullLength / 100;
|
|
29
|
+
}
|
|
30
|
+
get valueLength() {
|
|
31
|
+
return this.fullLength * (this.value / 100);
|
|
32
|
+
}
|
|
33
|
+
get animatedValueLength() {
|
|
34
|
+
return Math.min(this.valueLength, this.fullLength - this.startMargin - this.endMargin);
|
|
35
|
+
}
|
|
36
|
+
get startMargin() {
|
|
37
|
+
let margin = 0;
|
|
38
|
+
if (this.value > 0) margin = this.point;
|
|
39
|
+
return margin;
|
|
40
|
+
}
|
|
41
|
+
get endMargin() {
|
|
42
|
+
let margin = 0;
|
|
43
|
+
if (!this.isSemiDonut && this.value > 0) margin = this.point;
|
|
44
|
+
return margin;
|
|
45
|
+
}
|
|
46
|
+
get baseOffset() {
|
|
47
|
+
return -1 * (this.valueLength + this.startMargin);
|
|
48
|
+
}
|
|
49
|
+
get baseLength() {
|
|
50
|
+
return Math.max(this.fullLength - this.valueLength - this.startMargin - this.endMargin, 0);
|
|
51
|
+
}
|
|
52
|
+
get animatedBaseLengthFrom() {
|
|
53
|
+
return this.fullLength - this.startMargin - this.endMargin;
|
|
54
|
+
}
|
|
55
|
+
get animatedBaseLengthTo() {
|
|
56
|
+
return this.fullLength - this.valueLength - this.startMargin - this.endMargin;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.ScoreDonutUtils = ScoreDonutUtils;
|
|
87
60
|
//# sourceMappingURL=ScoreDonutUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScoreDonutUtils.js","names":["ScoreDonutUtils","
|
|
1
|
+
{"version":3,"file":"ScoreDonutUtils.js","names":["ScoreDonutUtils","constructor","value","isSemiDonut","_defineProperty2","default","radius","Math","max","min","viewBox","strokeWidth","fullLength","PI","point","valueLength","animatedValueLength","startMargin","endMargin","margin","baseOffset","baseLength","animatedBaseLengthFrom","animatedBaseLengthTo","exports"],"sources":["../../../src/utils/ScoreDonutUtils.ts"],"sourcesContent":["export class ScoreDonutUtils {\n private readonly isSemiDonut: boolean;\n private readonly value: number;\n\n public readonly radius: number;\n\n constructor(value: number, isSemiDonut: boolean) {\n this.isSemiDonut = isSemiDonut;\n this.radius = isSemiDonut ? 9 : 10;\n this.value = Math.max(Math.min(value, 100), 0);\n }\n\n public get viewBox() {\n return this.isSemiDonut ? '0 0 24 12' : '0 0 24 24';\n }\n\n public get strokeWidth() {\n return this.isSemiDonut ? 6 : 4;\n }\n\n public get fullLength() {\n return this.isSemiDonut ? Math.PI * this.radius : 2 * Math.PI * this.radius;\n }\n\n public get point() {\n return this.isSemiDonut\n ? this.fullLength / (100 / 3)\n : this.fullLength / 100;\n }\n\n public get valueLength() {\n return this.fullLength * (this.value / 100);\n }\n\n public get animatedValueLength() {\n return Math.min(this.valueLength, this.fullLength - this.startMargin - this.endMargin);\n }\n\n public get startMargin() {\n let margin = 0;\n if (this.value > 0) margin = this.point;\n return margin;\n }\n\n public get endMargin() {\n let margin = 0;\n if (!this.isSemiDonut && this.value > 0) margin = this.point;\n return margin;\n }\n\n public get baseOffset() {\n return -1 * (this.valueLength + this.startMargin);\n };\n\n public get baseLength() {\n return Math.max(this.fullLength - this.valueLength - this.startMargin - this.endMargin, 0);\n }\n\n public get animatedBaseLengthFrom() {\n return this.fullLength - this.startMargin - this.endMargin;\n }\n\n public get animatedBaseLengthTo() {\n return this.fullLength - this.valueLength - this.startMargin - this.endMargin;\n }\n}\n"],"mappings":";;;;;;;;AAAO,MAAMA,eAAe,CAAC;EAM3BC,WAAWA,CAACC,KAAa,EAAEC,WAAoB,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAC/C,IAAI,CAACF,WAAW,GAAGA,WAAW;I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CAAC;IACd,IAAI,CAAC,IAAI,CAAChB,WAAW,IAAI,IAAI,CAACD,KAAK,GAAG,CAAC,EAAEiB,MAAM,GAAG,IAAI,CAACL,KAAK;IAC5D,OAAOK,MAAM;EACf;EAEA,IAAWC,UAAUA,CAAA,EAAG;IACtB,OAAO,CAAC,CAAC,IAAI,IAAI,CAACL,WAAW,GAAG,IAAI,CAACE,WAAW,CAAC;EACnD;EAEA,IAAWI,UAAUA,CAAA,EAAG;IACtB,OAAOd,IAAI,CAACC,GAAG,CAAC,IAAI,CAACI,UAAU,GAAG,IAAI,CAACG,WAAW,GAAG,IAAI,CAACE,WAAW,GAAG,IAAI,CAACC,SAAS,EAAE,CAAC,CAAC;EAC5F;EAEA,IAAWI,sBAAsBA,CAAA,EAAG;IAClC,OAAO,IAAI,CAACV,UAAU,GAAG,IAAI,CAACK,WAAW,GAAG,IAAI,CAACC,SAAS;EAC5D;EAEA,IAAWK,oBAAoBA,CAAA,EAAG;IAChC,OAAO,IAAI,CAACX,UAAU,GAAG,IAAI,CAACG,WAAW,GAAG,IAAI,CAACE,WAAW,GAAG,IAAI,CAACC,SAAS;EAC/E;AACF;AAACM,OAAA,CAAAxB,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -1,121 +1,108 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _callSuper from "@babel/runtime/helpers/callSuper";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
2
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
8
3
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
9
|
-
import {
|
|
10
|
-
import { assignProps } from '@semcore/core';
|
|
4
|
+
import { Box } from '@semcore/base-components';
|
|
5
|
+
import { createComponent, Component, Root, sstyled, assignProps } 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 { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';
|
|
14
|
-
import { Box } from '@semcore/flex-box';
|
|
15
9
|
import React from 'react';
|
|
16
10
|
/*!__reshadow-styles__:"./donut.shadow.css"*/
|
|
17
|
-
|
|
11
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/"@keyframes pulse_1yj1g{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_1yj1g_gg_.__loading_1yj1g_gg_,.___SLineGauge_1yj1g_gg_.__loading_1yj1g_gg_,.___STrendBar_1yj1g_gg_.__loading_1yj1g_gg_,.___STrendLine_1yj1g_gg_.__loading_1yj1g_gg_{animation-name:pulse_1yj1g;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}.___SDonutContainer_1yj1g_gg_.__semi_1yj1g_gg_ g{transform:rotate(180deg) translate(-24px,-24px)}.___SDonutContainer_1yj1g_gg_ g{transform:rotate(-90deg) translate(-24px)}.___SDonutContainer_1yj1g_gg_.__animate_1yj1g_gg_ circle{transition:all var(--intergalactic-duration-extra-slow, 500) ease-in-out}", /*__inner_css_end__*/"1yj1g_gg_"),
|
|
18
12
|
/*__reshadow_css_end__*/
|
|
19
13
|
{
|
|
20
|
-
"__SLineGauge": "
|
|
21
|
-
"_loading": "
|
|
22
|
-
"__SDonutContainer": "
|
|
23
|
-
"__STrendLine": "
|
|
24
|
-
"__STrendBar": "
|
|
25
|
-
"@pulse": "
|
|
26
|
-
"_animate": "
|
|
27
|
-
"_semi": "
|
|
14
|
+
"__SLineGauge": "___SLineGauge_1yj1g_gg_",
|
|
15
|
+
"_loading": "__loading_1yj1g_gg_",
|
|
16
|
+
"__SDonutContainer": "___SDonutContainer_1yj1g_gg_",
|
|
17
|
+
"__STrendLine": "___STrendLine_1yj1g_gg_",
|
|
18
|
+
"__STrendBar": "___STrendBar_1yj1g_gg_",
|
|
19
|
+
"@pulse": "pulse_1yj1g",
|
|
20
|
+
"_animate": "__animate_1yj1g_gg_",
|
|
21
|
+
"_semi": "__semi_1yj1g_gg_"
|
|
28
22
|
});
|
|
29
23
|
import { ScoreDonutUtils } from '../../utils/ScoreDonutUtils';
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
duration = _this$asProps.duration;
|
|
54
|
-
var scoreDonut = new ScoreDonutUtils(value, isSemiDonut);
|
|
55
|
-
var _extractAriaProps = extractAriaProps(this.asProps),
|
|
56
|
-
__excludeProps = _extractAriaProps.__excludeProps,
|
|
57
|
-
extractedAriaProps = _extractAriaProps.extractedAriaProps;
|
|
58
|
-
return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(SDonutContainer, _ref2.cn("SDonutContainer", _objectSpread({}, _assignProps({
|
|
24
|
+
class DonutRoot extends Component {
|
|
25
|
+
render() {
|
|
26
|
+
var _ref = this.asProps,
|
|
27
|
+
_ref2;
|
|
28
|
+
const SDonutContainer = Box;
|
|
29
|
+
const {
|
|
30
|
+
value,
|
|
31
|
+
styles,
|
|
32
|
+
baseBgColor = 'chart-grid-bar-chart-base-bg',
|
|
33
|
+
color = 'chart-palette-order-1',
|
|
34
|
+
resolveColor,
|
|
35
|
+
isSemiDonut,
|
|
36
|
+
loading,
|
|
37
|
+
animate,
|
|
38
|
+
duration
|
|
39
|
+
} = this.asProps;
|
|
40
|
+
const scoreDonut = new ScoreDonutUtils(value, isSemiDonut);
|
|
41
|
+
const {
|
|
42
|
+
__excludeProps,
|
|
43
|
+
extractedAriaProps
|
|
44
|
+
} = extractAriaProps(this.asProps);
|
|
45
|
+
return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(SDonutContainer, _ref2.cn("SDonutContainer", {
|
|
46
|
+
..._assignProps({
|
|
59
47
|
"semi": isSemiDonut,
|
|
60
48
|
"__excludeProps": __excludeProps
|
|
61
|
-
}, _ref)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
49
|
+
}, _ref)
|
|
50
|
+
}), /*#__PURE__*/React.createElement("svg", _ref2.cn("svg", {
|
|
51
|
+
"width": '100%',
|
|
52
|
+
"height": '100%',
|
|
53
|
+
"viewBox": scoreDonut.viewBox,
|
|
54
|
+
"fill": 'none',
|
|
55
|
+
"role": 'img',
|
|
56
|
+
...extractedAriaProps
|
|
57
|
+
}), /*#__PURE__*/React.createElement("g", _ref2.cn("g", {}), /*#__PURE__*/React.createElement("circle", _ref2.cn("circle", {
|
|
58
|
+
"cx": '12',
|
|
59
|
+
"cy": '12',
|
|
60
|
+
"r": scoreDonut.radius,
|
|
61
|
+
"strokeWidth": scoreDonut.strokeWidth,
|
|
62
|
+
"stroke": resolveColor(baseBgColor),
|
|
63
|
+
"strokeDasharray": loading ? undefined : `${scoreDonut.baseLength} ${scoreDonut.fullLength}`,
|
|
64
|
+
"strokeDashoffset": scoreDonut.baseOffset
|
|
65
|
+
}), animate && value > 0 && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("animate", _ref2.cn("animate", {
|
|
66
|
+
"attributeName": 'stroke-dasharray',
|
|
67
|
+
"from": `${scoreDonut.animatedBaseLengthFrom} ${scoreDonut.fullLength}`,
|
|
68
|
+
"to": `${scoreDonut.animatedBaseLengthTo} ${scoreDonut.fullLength}`,
|
|
69
|
+
"dur": duration + 'ms'
|
|
70
|
+
})), /*#__PURE__*/React.createElement("animate", _ref2.cn("animate", {
|
|
71
|
+
"attributeName": 'stroke-dashoffset',
|
|
72
|
+
"from": -1 * scoreDonut.startMargin,
|
|
73
|
+
"to": scoreDonut.baseOffset,
|
|
74
|
+
"dur": duration + 'ms'
|
|
75
|
+
})))), !loading && value > 0 && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("circle", _ref2.cn("circle", {
|
|
76
|
+
"cx": '12',
|
|
77
|
+
"cy": '12',
|
|
78
|
+
"r": scoreDonut.radius,
|
|
79
|
+
"strokeWidth": scoreDonut.strokeWidth,
|
|
80
|
+
"stroke": resolveColor(color),
|
|
81
|
+
"strokeDasharray": `${scoreDonut.valueLength} ${scoreDonut.fullLength}`
|
|
82
|
+
}), animate && /*#__PURE__*/React.createElement("animate", _ref2.cn("animate", {
|
|
83
|
+
"attributeName": 'stroke-dasharray',
|
|
84
|
+
"from": `0 ${scoreDonut.fullLength}`,
|
|
85
|
+
"to": `${scoreDonut.valueLength} ${scoreDonut.fullLength}`,
|
|
86
|
+
"dur": duration + 'ms'
|
|
87
|
+
})))))));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
101
90
|
_defineProperty(DonutRoot, "enhance", [cssVariableEnhance({
|
|
102
91
|
variable: '--intergalactic-duration-extra-slow',
|
|
103
92
|
fallback: '500',
|
|
104
|
-
map:
|
|
105
|
-
return Number.parseInt(v, 10).toString();
|
|
106
|
-
},
|
|
93
|
+
map: v => Number.parseInt(v, 10).toString(),
|
|
107
94
|
prop: 'duration'
|
|
108
95
|
}), resolveColorEnhance()]);
|
|
109
96
|
_defineProperty(DonutRoot, "style", style);
|
|
110
97
|
_defineProperty(DonutRoot, "defaultProps", {
|
|
111
98
|
animate: true
|
|
112
99
|
});
|
|
113
|
-
export
|
|
100
|
+
export const ScoreDonut = createComponent(DonutRoot);
|
|
114
101
|
ScoreDonut.displayName = 'MiniChart.ScoreDonut';
|
|
115
|
-
export
|
|
116
|
-
enhancements: [
|
|
102
|
+
export const ScoreSemiDonut = createComponent(DonutRoot, {}, {
|
|
103
|
+
enhancements: [() => {
|
|
117
104
|
return {
|
|
118
|
-
wrapperProps:
|
|
105
|
+
wrapperProps: props => {
|
|
119
106
|
return assignProps(props, {
|
|
120
107
|
isSemiDonut: true
|
|
121
108
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Donut.js","names":["createComponent","Component","Root","sstyled","assignProps","extractAriaProps","resolveColorEnhance","cssVariableEnhance","
|
|
1
|
+
{"version":3,"file":"Donut.js","names":["Box","createComponent","Component","Root","sstyled","assignProps","extractAriaProps","resolveColorEnhance","cssVariableEnhance","React","style","_sstyled","insert","ScoreDonutUtils","DonutRoot","render","_ref","asProps","_ref2","SDonutContainer","value","styles","baseBgColor","color","resolveColor","isSemiDonut","loading","animate","duration","scoreDonut","__excludeProps","extractedAriaProps","createElement","cn","_assignProps","viewBox","radius","strokeWidth","undefined","baseLength","fullLength","baseOffset","Fragment","animatedBaseLengthFrom","animatedBaseLengthTo","startMargin","valueLength","_defineProperty","variable","fallback","map","v","Number","parseInt","toString","prop","ScoreDonut","displayName","ScoreSemiDonut","enhancements","wrapperProps","props"],"sources":["../../../../src/component/score/Donut.tsx"],"sourcesContent":["import { Box, type BoxProps } from '@semcore/base-components';\nimport { createComponent, Component, Root, sstyled, assignProps } from '@semcore/core';\nimport { extractAriaProps } from '@semcore/core/lib/utils/ariaProps';\nimport resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport React from 'react';\n\nimport style from './donut.shadow.css';\nimport type { CommonScoreProps } from './Score';\nimport { ScoreDonutUtils } from '../../utils/ScoreDonutUtils';\n\nexport type ScoreDonutProps = BoxProps & CommonScoreProps;\n\nclass DonutRoot extends Component<ScoreDonutProps, typeof DonutRoot.enhance> {\n static enhance = [\n cssVariableEnhance({\n variable: '--intergalactic-duration-extra-slow',\n fallback: '500',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'duration',\n }),\n resolveColorEnhance(),\n ] as const;\n\n static style = style;\n\n static defaultProps = {\n animate: true,\n };\n\n render() {\n const SDonutContainer = Root;\n const {\n value,\n styles,\n baseBgColor = 'chart-grid-bar-chart-base-bg',\n color = 'chart-palette-order-1',\n resolveColor,\n isSemiDonut,\n loading,\n animate,\n duration,\n } = this.asProps;\n\n const scoreDonut = new ScoreDonutUtils(value, isSemiDonut);\n const { __excludeProps, extractedAriaProps } = extractAriaProps(this.asProps);\n\n return sstyled(styles)(\n <SDonutContainer render={Box} semi={isSemiDonut} __excludeProps={__excludeProps}>\n <svg\n width='100%'\n height='100%'\n viewBox={scoreDonut.viewBox}\n fill='none'\n role='img'\n {...extractedAriaProps}\n >\n <g>\n <circle\n cx='12'\n cy='12'\n r={scoreDonut.radius}\n strokeWidth={scoreDonut.strokeWidth}\n stroke={resolveColor(baseBgColor)}\n strokeDasharray={\n loading\n ? undefined\n : `${scoreDonut.baseLength} ${scoreDonut.fullLength}`\n }\n strokeDashoffset={scoreDonut.baseOffset}\n >\n {animate && value > 0 && (\n <>\n <animate\n attributeName='stroke-dasharray'\n from={`${scoreDonut.animatedBaseLengthFrom} ${scoreDonut.fullLength}`}\n to={`${scoreDonut.animatedBaseLengthTo} ${scoreDonut.fullLength}`}\n dur={duration + 'ms'}\n />\n <animate\n attributeName='stroke-dashoffset'\n from={-1 * scoreDonut.startMargin}\n to={scoreDonut.baseOffset}\n dur={duration + 'ms'}\n />\n </>\n )}\n </circle>\n {!loading && value > 0 && (\n <>\n <circle\n cx='12'\n cy='12'\n r={scoreDonut.radius}\n strokeWidth={scoreDonut.strokeWidth}\n stroke={resolveColor(color)}\n strokeDasharray={`${scoreDonut.valueLength} ${scoreDonut.fullLength}`}\n >\n {animate && (\n <animate\n attributeName='stroke-dasharray'\n from={`0 ${scoreDonut.fullLength}`}\n to={`${scoreDonut.valueLength} ${scoreDonut.fullLength}`}\n dur={duration + 'ms'}\n />\n )}\n </circle>\n </>\n )}\n </g>\n </svg>\n </SDonutContainer>,\n );\n }\n}\n\nexport const ScoreDonut = createComponent<'svg', ScoreDonutProps, {}, typeof DonutRoot.enhance>(DonutRoot);\n\nScoreDonut.displayName = 'MiniChart.ScoreDonut';\n\nexport const ScoreSemiDonut = createComponent<'svg', ScoreDonutProps, {}, typeof DonutRoot.enhance>(\n DonutRoot,\n {},\n {\n enhancements: [\n () => {\n return {\n wrapperProps: (props: ScoreDonutProps) => {\n return assignProps(props, { isSemiDonut: true });\n },\n };\n },\n ],\n },\n);\n\nScoreSemiDonut.displayName = 'MiniChart.ScoreSemiDonut';\n"],"mappings":";;;AAAA,SAASA,GAAG,QAAuB,0BAA0B;AAC7D,SAASC,eAAe,EAAEC,SAAS,EAAEC,IAAI,EAAEC,OAAO,EAAEC,WAAW,QAAQ,eAAe;AACtF,SAASC,gBAAgB,QAAQ,mCAAmC;AACpE,OAAOC,mBAAmB,MAAM,sDAAsD;AACtF,SAASC,kBAAkB,QAAQ,wCAAwC;AAC3E,OAAOC,KAAK,MAAM,OAAO;AAAC;AAAA,MAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI1B,SAASC,eAAe,QAAQ,6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