@semcore/mini-chart 16.1.1 → 17.0.0-prerelease.18
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 +6 -0
- 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 +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScoreDonutUtils.js","names":["ScoreDonutUtils","
|
|
1
|
+
{"version":3,"file":"ScoreDonutUtils.js","names":["ScoreDonutUtils","constructor","value","isSemiDonut","_defineProperty","radius","Math","max","min","viewBox","strokeWidth","fullLength","PI","point","valueLength","animatedValueLength","startMargin","endMargin","margin","baseOffset","baseLength","animatedBaseLengthFrom","animatedBaseLengthTo"],"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":";AAAA,OAAO,MAAMA,eAAe,CAAC;EAM3BC,WAAWA,CAACC,KAAa,EAAEC,WAAoB,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAC/C,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACE,MAAM,GAAGF,WAAW,GAAG,CAAC,GAAG,EAAE;IAClC,IAAI,CAACD,KAAK,GAAGI,IAAI,CAACC,GAAG,CAACD,IAAI,CAACE,GAAG,CAACN,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;EAChD;EAEA,IAAWO,OAAOA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACN,WAAW,GAAG,WAAW,GAAG,WAAW;EACrD;EAEA,IAAWO,WAAWA,CAAA,EAAG;IACvB,OAAO,IAAI,CAACP,WAAW,GAAG,CAAC,GAAG,CAAC;EACjC;EAEA,IAAWQ,UAAUA,CAAA,EAAG;IACtB,OAAO,IAAI,CAACR,WAAW,GAAGG,IAAI,CAACM,EAAE,GAAG,IAAI,CAACP,MAAM,GAAG,CAAC,GAAGC,IAAI,CAACM,EAAE,GAAG,IAAI,CAACP,MAAM;EAC7E;EAEA,IAAWQ,KAAKA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACV,WAAW,GACnB,IAAI,CAACQ,UAAU,IAAI,GAAG,GAAG,CAAC,CAAC,GAC3B,IAAI,CAACA,UAAU,GAAG,GAAG;EAC3B;EAEA,IAAWG,WAAWA,CAAA,EAAG;IACvB,OAAO,IAAI,CAACH,UAAU,IAAI,IAAI,CAACT,KAAK,GAAG,GAAG,CAAC;EAC7C;EAEA,IAAWa,mBAAmBA,CAAA,EAAG;IAC/B,OAAOT,IAAI,CAACE,GAAG,CAAC,IAAI,CAACM,WAAW,EAAE,IAAI,CAACH,UAAU,GAAG,IAAI,CAACK,WAAW,GAAG,IAAI,CAACC,SAAS,CAAC;EACxF;EAEA,IAAWD,WAAWA,CAAA,EAAG;IACvB,IAAIE,MAAM,GAAG,CAAC;IACd,IAAI,IAAI,CAAChB,KAAK,GAAG,CAAC,EAAEgB,MAAM,GAAG,IAAI,CAACL,KAAK;IACvC,OAAOK,MAAM;EACf;EAEA,IAAWD,SAASA,CAAA,EAAG;IACrB,IAAIC,MAAM,GAAG,CAAC;IACd,IAAI,CAAC,IAAI,CAACf,WAAW,IAAI,IAAI,CAACD,KAAK,GAAG,CAAC,EAAEgB,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","ignoreList":[]}
|
|
@@ -1,111 +1,112 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
2
|
import { createComponent, sstyled, assignProps, Component } from "@semcore/core";
|
|
3
|
+
import { Box } from "@semcore/base-components";
|
|
8
4
|
import { extractAriaProps } from "@semcore/core/lib/utils/ariaProps";
|
|
9
5
|
import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
|
|
10
6
|
import { cssVariableEnhance } from "@semcore/core/lib/utils/useCssVariable";
|
|
11
|
-
import { Box } from "@semcore/flex-box";
|
|
12
7
|
import React from "react";
|
|
13
8
|
import { ScoreDonutUtils } from "../../utils/ScoreDonutUtils.mjs";
|
|
14
9
|
/*!__reshadow-styles__:"./donut.shadow.css"*/
|
|
15
|
-
|
|
10
|
+
const style = (
|
|
16
11
|
/*__reshadow_css_start__*/
|
|
17
12
|
(sstyled.insert(
|
|
18
13
|
/*__inner_css_start__*/
|
|
19
|
-
"@keyframes
|
|
14
|
+
"@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}",
|
|
20
15
|
/*__inner_css_end__*/
|
|
21
|
-
"
|
|
16
|
+
"1yj1g_gg_"
|
|
22
17
|
), /*__reshadow_css_end__*/
|
|
23
18
|
{
|
|
24
|
-
"__SLineGauge": "
|
|
25
|
-
"_loading": "
|
|
26
|
-
"__SDonutContainer": "
|
|
27
|
-
"__STrendLine": "
|
|
28
|
-
"__STrendBar": "
|
|
29
|
-
"@pulse": "
|
|
30
|
-
"_animate": "
|
|
31
|
-
"_semi": "
|
|
19
|
+
"__SLineGauge": "___SLineGauge_1yj1g_gg_",
|
|
20
|
+
"_loading": "__loading_1yj1g_gg_",
|
|
21
|
+
"__SDonutContainer": "___SDonutContainer_1yj1g_gg_",
|
|
22
|
+
"__STrendLine": "___STrendLine_1yj1g_gg_",
|
|
23
|
+
"__STrendBar": "___STrendBar_1yj1g_gg_",
|
|
24
|
+
"@pulse": "pulse_1yj1g",
|
|
25
|
+
"_animate": "__animate_1yj1g_gg_",
|
|
26
|
+
"_semi": "__semi_1yj1g_gg_"
|
|
32
27
|
})
|
|
33
28
|
);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
class DonutRoot extends Component {
|
|
30
|
+
render() {
|
|
31
|
+
var _ref = this.asProps, _ref2;
|
|
32
|
+
const SDonutContainer = Box;
|
|
33
|
+
const {
|
|
34
|
+
value,
|
|
35
|
+
styles,
|
|
36
|
+
baseBgColor = "chart-grid-bar-chart-base-bg",
|
|
37
|
+
color = "chart-palette-order-1",
|
|
38
|
+
resolveColor,
|
|
39
|
+
isSemiDonut,
|
|
40
|
+
loading,
|
|
41
|
+
animate,
|
|
42
|
+
duration
|
|
43
|
+
} = this.asProps;
|
|
44
|
+
const scoreDonut = new ScoreDonutUtils(value, isSemiDonut);
|
|
45
|
+
const {
|
|
46
|
+
__excludeProps,
|
|
47
|
+
extractedAriaProps
|
|
48
|
+
} = extractAriaProps(this.asProps);
|
|
49
|
+
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(SDonutContainer, _ref2.cn("SDonutContainer", {
|
|
50
|
+
...assignProps({
|
|
49
51
|
"semi": isSemiDonut,
|
|
50
52
|
"__excludeProps": __excludeProps
|
|
51
|
-
}, _ref)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
}
|
|
53
|
+
}, _ref)
|
|
54
|
+
}), /* @__PURE__ */ React.createElement("svg", _ref2.cn("svg", {
|
|
55
|
+
"width": "100%",
|
|
56
|
+
"height": "100%",
|
|
57
|
+
"viewBox": scoreDonut.viewBox,
|
|
58
|
+
"fill": "none",
|
|
59
|
+
"role": "img",
|
|
60
|
+
...extractedAriaProps
|
|
61
|
+
}), /* @__PURE__ */ React.createElement("g", _ref2.cn("g", {}), /* @__PURE__ */ React.createElement("circle", _ref2.cn("circle", {
|
|
62
|
+
"cx": "12",
|
|
63
|
+
"cy": "12",
|
|
64
|
+
"r": scoreDonut.radius,
|
|
65
|
+
"strokeWidth": scoreDonut.strokeWidth,
|
|
66
|
+
"stroke": resolveColor(baseBgColor),
|
|
67
|
+
"strokeDasharray": loading ? void 0 : `${scoreDonut.baseLength} ${scoreDonut.fullLength}`,
|
|
68
|
+
"strokeDashoffset": scoreDonut.baseOffset
|
|
69
|
+
}), animate && value > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("animate", _ref2.cn("animate", {
|
|
70
|
+
"attributeName": "stroke-dasharray",
|
|
71
|
+
"from": `${scoreDonut.animatedBaseLengthFrom} ${scoreDonut.fullLength}`,
|
|
72
|
+
"to": `${scoreDonut.animatedBaseLengthTo} ${scoreDonut.fullLength}`,
|
|
73
|
+
"dur": duration + "ms"
|
|
74
|
+
})), /* @__PURE__ */ React.createElement("animate", _ref2.cn("animate", {
|
|
75
|
+
"attributeName": "stroke-dashoffset",
|
|
76
|
+
"from": -1 * scoreDonut.startMargin,
|
|
77
|
+
"to": scoreDonut.baseOffset,
|
|
78
|
+
"dur": duration + "ms"
|
|
79
|
+
})))), !loading && value > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("circle", _ref2.cn("circle", {
|
|
80
|
+
"cx": "12",
|
|
81
|
+
"cy": "12",
|
|
82
|
+
"r": scoreDonut.radius,
|
|
83
|
+
"strokeWidth": scoreDonut.strokeWidth,
|
|
84
|
+
"stroke": resolveColor(color),
|
|
85
|
+
"strokeDasharray": `${scoreDonut.valueLength} ${scoreDonut.fullLength}`
|
|
86
|
+
}), animate && /* @__PURE__ */ React.createElement("animate", _ref2.cn("animate", {
|
|
87
|
+
"attributeName": "stroke-dasharray",
|
|
88
|
+
"from": `0 ${scoreDonut.fullLength}`,
|
|
89
|
+
"to": `${scoreDonut.valueLength} ${scoreDonut.fullLength}`,
|
|
90
|
+
"dur": duration + "ms"
|
|
91
|
+
})))))));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
91
94
|
_defineProperty(DonutRoot, "enhance", [cssVariableEnhance({
|
|
92
95
|
variable: "--intergalactic-duration-extra-slow",
|
|
93
96
|
fallback: "500",
|
|
94
|
-
map:
|
|
95
|
-
return Number.parseInt(v, 10).toString();
|
|
96
|
-
},
|
|
97
|
+
map: (v) => Number.parseInt(v, 10).toString(),
|
|
97
98
|
prop: "duration"
|
|
98
99
|
}), resolveColorEnhance()]);
|
|
99
100
|
_defineProperty(DonutRoot, "style", style);
|
|
100
101
|
_defineProperty(DonutRoot, "defaultProps", {
|
|
101
102
|
animate: true
|
|
102
103
|
});
|
|
103
|
-
|
|
104
|
+
const ScoreDonut = createComponent(DonutRoot);
|
|
104
105
|
ScoreDonut.displayName = "MiniChart.ScoreDonut";
|
|
105
|
-
|
|
106
|
-
enhancements: [
|
|
106
|
+
const ScoreSemiDonut = createComponent(DonutRoot, {}, {
|
|
107
|
+
enhancements: [() => {
|
|
107
108
|
return {
|
|
108
|
-
wrapperProps:
|
|
109
|
+
wrapperProps: (props) => {
|
|
109
110
|
return assignProps(props, {
|
|
110
111
|
isSemiDonut: true
|
|
111
112
|
});
|
|
@@ -1,107 +1,111 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
-
import { createComponent, sstyled, assignProps
|
|
2
|
+
import { createComponent, Component, sstyled, assignProps } from "@semcore/core";
|
|
3
|
+
import { Box, Flex } from "@semcore/base-components";
|
|
8
4
|
import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
|
|
9
|
-
import { Box, Flex } from "@semcore/flex-box";
|
|
10
5
|
import React from "react";
|
|
11
6
|
/*!__reshadow-styles__:"./line.shadow.css"*/
|
|
12
|
-
|
|
7
|
+
const style = (
|
|
13
8
|
/*__reshadow_css_start__*/
|
|
14
9
|
(sstyled.insert(
|
|
15
10
|
/*__inner_css_start__*/
|
|
16
|
-
"@keyframes
|
|
11
|
+
"@keyframes pulse_1q9hd{0%,to{opacity:1}50%{opacity:.4}}@keyframes move-line_1q9hd{0%{transform:translateX(0)}to{transform:translateX(100%)}}.___SDonutContainer_1q9hd_gg_.__loading_1q9hd_gg_,.___SLineGauge_1q9hd_gg_.__loading_1q9hd_gg_,.___STrendBar_1q9hd_gg_.__loading_1q9hd_gg_,.___STrendLine_1q9hd_gg_.__loading_1q9hd_gg_{animation-name:pulse_1q9hd;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}.___SLineGauge_1q9hd_gg_{height:8px;background-color:var(--base-bg-color_1q9hd, var(--intergalactic-chart-grid-bar-chart-base-bg, #e0e1e9));border-radius:var(--intergalactic-chart-rounded, 2px);overflow:hidden;position:relative}.___SLineValue_1q9hd_gg_{height:8px;border-radius:var(--intergalactic-chart-rounded, 2px)0 0 var(--intergalactic-chart-rounded, 2px)}.___SLineValue_1q9hd_gg_.__percent_1q9hd_gg_{width:var(--percent_1q9hd)}.___SLineSegmentItem_1q9hd_gg_.__color_1q9hd_gg_,.___SLineValue_1q9hd_gg_.__color_1q9hd_gg_{background-color:var(--color_1q9hd, var(--intergalactic-chart-palette-order-1, #2bb3ff))}.___SLineGauge_1q9hd_gg_.__segments_1q9hd_gg_{border-radius:var(--intergalactic-progress-bar-rounded, 6px)}.___SAnimationLine_1q9hd_gg_,.___SLineGaugeSegment_1q9hd_gg_{position:absolute;top:0;left:0;right:0;bottom:0}.___SLineSegmentItem_1q9hd_gg_:last-child{margin-right:0;border-right:none}.___SLineSegmentItem_1q9hd_gg_{height:8px;background:0 0;border-right-color:var(--intergalactic-chart-grid-border, #ffffff);border-right-style:solid;border-right-width:1px;box-sizing:content-box}.___SAnimationLine_1q9hd_gg_{background-color:var(--intergalactic-chart-grid-bar-chart-base-bg, #e0e1e9);transition:all var(--intergalactic-duration-extra-slow, 500) ease-in-out;animation-name:move-line_1q9hd;animation-duration:.5s;animation-timing-function:ease-in-out;animation-fill-mode:forwards}",
|
|
17
12
|
/*__inner_css_end__*/
|
|
18
|
-
"
|
|
13
|
+
"1q9hd_gg_"
|
|
19
14
|
), /*__reshadow_css_end__*/
|
|
20
15
|
{
|
|
21
|
-
"__SLineGauge": "
|
|
22
|
-
"_loading": "
|
|
23
|
-
"__SDonutContainer": "
|
|
24
|
-
"__STrendLine": "
|
|
25
|
-
"__STrendBar": "
|
|
26
|
-
"@pulse": "
|
|
27
|
-
"--base-bg-color": "--base-bg-
|
|
28
|
-
"__SLineValue": "
|
|
29
|
-
"_percent": "
|
|
30
|
-
"--percent": "--
|
|
31
|
-
"_color": "
|
|
32
|
-
"__SLineSegmentItem": "
|
|
33
|
-
"--color": "--
|
|
34
|
-
"_segments": "
|
|
35
|
-
"__SLineGaugeSegment": "
|
|
36
|
-
"__SAnimationLine": "
|
|
37
|
-
"@move-line": "move-
|
|
16
|
+
"__SLineGauge": "___SLineGauge_1q9hd_gg_",
|
|
17
|
+
"_loading": "__loading_1q9hd_gg_",
|
|
18
|
+
"__SDonutContainer": "___SDonutContainer_1q9hd_gg_",
|
|
19
|
+
"__STrendLine": "___STrendLine_1q9hd_gg_",
|
|
20
|
+
"__STrendBar": "___STrendBar_1q9hd_gg_",
|
|
21
|
+
"@pulse": "pulse_1q9hd",
|
|
22
|
+
"--base-bg-color": "--base-bg-color_1q9hd",
|
|
23
|
+
"__SLineValue": "___SLineValue_1q9hd_gg_",
|
|
24
|
+
"_percent": "__percent_1q9hd_gg_",
|
|
25
|
+
"--percent": "--percent_1q9hd",
|
|
26
|
+
"_color": "__color_1q9hd_gg_",
|
|
27
|
+
"__SLineSegmentItem": "___SLineSegmentItem_1q9hd_gg_",
|
|
28
|
+
"--color": "--color_1q9hd",
|
|
29
|
+
"_segments": "__segments_1q9hd_gg_",
|
|
30
|
+
"__SLineGaugeSegment": "___SLineGaugeSegment_1q9hd_gg_",
|
|
31
|
+
"__SAnimationLine": "___SAnimationLine_1q9hd_gg_",
|
|
32
|
+
"@move-line": "move-line_1q9hd"
|
|
38
33
|
})
|
|
39
34
|
);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
class LineRoot extends Component {
|
|
36
|
+
getSegmentProps(segmentProps) {
|
|
37
|
+
const {
|
|
38
|
+
children,
|
|
39
|
+
resolveColor
|
|
40
|
+
} = this.asProps;
|
|
41
|
+
let sum = 0;
|
|
42
|
+
React.Children.forEach(children, (child) => {
|
|
43
|
+
if (/* @__PURE__ */ React.isValidElement(child)) {
|
|
44
|
+
sum = sum + child.props.value;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const width = sum > 0 ? 100 * segmentProps.value / sum : 0;
|
|
48
|
+
return {
|
|
49
|
+
"w": `${width}%`,
|
|
50
|
+
"use:color": resolveColor(segmentProps.color)
|
|
51
|
+
};
|
|
44
52
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var SLineValue = Box;
|
|
68
|
-
var SAnimationLine = Box;
|
|
69
|
-
var SLineGaugeSegment = Flex;
|
|
70
|
-
var SLineSegmentItem = Box;
|
|
71
|
-
var _this$asProps2 = this.asProps, value = _this$asProps2.value, styles = _this$asProps2.styles, _this$asProps2$color = _this$asProps2.color, color = _this$asProps2$color === void 0 ? "chart-palette-order-1" : _this$asProps2$color, baseBgColor = _this$asProps2.baseBgColor, resolveColor = _this$asProps2.resolveColor, loading = _this$asProps2.loading, children = _this$asProps2.children, Children = _this$asProps2.Children, animate = _this$asProps2.animate;
|
|
72
|
-
if (children !== void 0) {
|
|
73
|
-
var _ref3;
|
|
74
|
-
return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineGauge, _ref3.cn("SLineGauge", _objectSpread({}, assignProps({
|
|
53
|
+
render() {
|
|
54
|
+
var _ref = this.asProps, _ref5;
|
|
55
|
+
const SLineGauge = Box;
|
|
56
|
+
const SLineValue = Box;
|
|
57
|
+
const SAnimationLine = Box;
|
|
58
|
+
const SLineGaugeSegment = Flex;
|
|
59
|
+
const SLineSegmentItem = Box;
|
|
60
|
+
const {
|
|
61
|
+
value,
|
|
62
|
+
styles,
|
|
63
|
+
color = "chart-palette-order-1",
|
|
64
|
+
baseBgColor,
|
|
65
|
+
resolveColor,
|
|
66
|
+
loading,
|
|
67
|
+
children,
|
|
68
|
+
Children,
|
|
69
|
+
animate
|
|
70
|
+
} = this.asProps;
|
|
71
|
+
if (children !== void 0) {
|
|
72
|
+
var _ref3;
|
|
73
|
+
return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineGauge, _ref3.cn("SLineGauge", {
|
|
74
|
+
...assignProps({
|
|
75
75
|
"segments": true,
|
|
76
76
|
"base-bg-color": resolveColor(baseBgColor)
|
|
77
|
-
}, _ref)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (segments) {
|
|
94
|
-
percent = "".concat(value / segments * 100, "%");
|
|
77
|
+
}, _ref)
|
|
78
|
+
}), /* @__PURE__ */ React.createElement(SLineGaugeSegment, _ref3.cn("SLineGaugeSegment", {}), /* @__PURE__ */ React.createElement(Children, _ref3.cn("Children", {}))), animate && /* @__PURE__ */ React.createElement(SAnimationLine, _ref3.cn("SAnimationLine", {})));
|
|
79
|
+
}
|
|
80
|
+
const {
|
|
81
|
+
segments
|
|
82
|
+
} = this.asProps;
|
|
83
|
+
const SegmentItems = [];
|
|
84
|
+
if (segments) {
|
|
85
|
+
for (let i = 0; i < segments; i++) {
|
|
86
|
+
var _ref4;
|
|
87
|
+
const width = `calc((100% - ${segments - 1}px) / ${segments})`;
|
|
88
|
+
SegmentItems.push((_ref4 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineSegmentItem, _ref4.cn("SLineSegmentItem", {
|
|
89
|
+
"key": i,
|
|
90
|
+
"color": i < value ? resolveColor(color) : void 0,
|
|
91
|
+
"w": width
|
|
92
|
+
}))));
|
|
95
93
|
}
|
|
96
|
-
return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineGauge, _ref5.cn("SLineGauge", _objectSpread({}, assignProps({
|
|
97
|
-
"base-bg-color": resolveColor(baseBgColor)
|
|
98
|
-
}, _ref))), !loading && /* @__PURE__ */ React.createElement(SLineValue, _ref5.cn("SLineValue", {
|
|
99
|
-
"w": percent,
|
|
100
|
-
"color": resolveColor(color)
|
|
101
|
-
})), Boolean(SegmentItems.length) && /* @__PURE__ */ React.createElement(SLineGaugeSegment, _ref5.cn("SLineGaugeSegment", {}), SegmentItems), animate && /* @__PURE__ */ React.createElement(SAnimationLine, _ref5.cn("SAnimationLine", {})));
|
|
102
94
|
}
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
let percent = `${value}%`;
|
|
96
|
+
if (segments) {
|
|
97
|
+
percent = `${value / segments * 100}%`;
|
|
98
|
+
}
|
|
99
|
+
return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineGauge, _ref5.cn("SLineGauge", {
|
|
100
|
+
...assignProps({
|
|
101
|
+
"base-bg-color": resolveColor(baseBgColor)
|
|
102
|
+
}, _ref)
|
|
103
|
+
}), !loading && /* @__PURE__ */ React.createElement(SLineValue, _ref5.cn("SLineValue", {
|
|
104
|
+
"w": percent,
|
|
105
|
+
"color": resolveColor(color)
|
|
106
|
+
})), Boolean(SegmentItems.length) && /* @__PURE__ */ React.createElement(SLineGaugeSegment, _ref5.cn("SLineGaugeSegment", {}), SegmentItems), animate && /* @__PURE__ */ React.createElement(SAnimationLine, _ref5.cn("SAnimationLine", {})));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
105
109
|
_defineProperty(LineRoot, "enhance", [resolveColorEnhance()]);
|
|
106
110
|
_defineProperty(LineRoot, "displayName", "ScoreLine");
|
|
107
111
|
_defineProperty(LineRoot, "style", style);
|
|
@@ -110,13 +114,18 @@ _defineProperty(LineRoot, "defaultProps", {
|
|
|
110
114
|
});
|
|
111
115
|
function Segment(props) {
|
|
112
116
|
var _ref2 = arguments[0], _ref6;
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
const {
|
|
118
|
+
styles,
|
|
119
|
+
value
|
|
120
|
+
} = props;
|
|
121
|
+
const SLineSegmentItem = Box;
|
|
115
122
|
if (!value) return null;
|
|
116
|
-
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineSegmentItem, _ref6.cn("SLineSegmentItem",
|
|
123
|
+
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineSegmentItem, _ref6.cn("SLineSegmentItem", {
|
|
124
|
+
...assignProps({}, _ref2)
|
|
125
|
+
}));
|
|
117
126
|
}
|
|
118
127
|
Segment.displayName = "Segment";
|
|
119
|
-
|
|
128
|
+
const ScoreLine = createComponent(LineRoot, {
|
|
120
129
|
Segment
|
|
121
130
|
});
|
|
122
131
|
ScoreLine.displayName = "MiniChart.ScoreLine";
|