@semcore/mini-chart 0.29.4-prerelease.0 → 0.30.0-prerelease.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/cjs/component/score/Donut.js +60 -64
  3. package/lib/cjs/component/score/Donut.js.map +1 -1
  4. package/lib/cjs/component/score/Line.js +38 -41
  5. package/lib/cjs/component/score/Line.js.map +1 -1
  6. package/lib/cjs/component/score/Line.types.js.map +1 -1
  7. package/lib/cjs/component/score/Score.js.map +1 -1
  8. package/lib/cjs/component/score/index.js.map +1 -1
  9. package/lib/cjs/component/score/line.shadow.css +4 -4
  10. package/lib/cjs/component/trend/Bar.js +22 -28
  11. package/lib/cjs/component/trend/Bar.js.map +1 -1
  12. package/lib/cjs/component/trend/Line.js +20 -26
  13. package/lib/cjs/component/trend/Line.js.map +1 -1
  14. package/lib/cjs/component/trend/Trend.js +9 -13
  15. package/lib/cjs/component/trend/Trend.js.map +1 -1
  16. package/lib/cjs/component/trend/index.js +1 -1
  17. package/lib/cjs/component/trend/index.js.map +1 -1
  18. package/lib/cjs/index.js +1 -2
  19. package/lib/cjs/index.js.map +1 -1
  20. package/lib/cjs/utils/ScoreDonutUtils.js +87 -0
  21. package/lib/cjs/utils/ScoreDonutUtils.js.map +1 -0
  22. package/lib/es6/component/score/Donut.js +57 -58
  23. package/lib/es6/component/score/Donut.js.map +1 -1
  24. package/lib/es6/component/score/Line.js +31 -31
  25. package/lib/es6/component/score/Line.js.map +1 -1
  26. package/lib/es6/component/score/Line.types.js.map +1 -1
  27. package/lib/es6/component/score/Score.js.map +1 -1
  28. package/lib/es6/component/score/index.js.map +1 -1
  29. package/lib/es6/component/score/line.shadow.css +4 -4
  30. package/lib/es6/component/trend/Bar.js +19 -21
  31. package/lib/es6/component/trend/Bar.js.map +1 -1
  32. package/lib/es6/component/trend/Line.js +17 -19
  33. package/lib/es6/component/trend/Line.js.map +1 -1
  34. package/lib/es6/component/trend/Trend.js +7 -10
  35. package/lib/es6/component/trend/Trend.js.map +1 -1
  36. package/lib/es6/component/trend/index.js +1 -1
  37. package/lib/es6/component/trend/index.js.map +1 -1
  38. package/lib/es6/index.js.map +1 -1
  39. package/lib/es6/utils/ScoreDonutUtils.js +80 -0
  40. package/lib/es6/utils/ScoreDonutUtils.js.map +1 -0
  41. package/lib/esm/component/score/Donut.mjs +58 -61
  42. package/lib/esm/component/score/Line.mjs +35 -37
  43. package/lib/esm/component/score/index.mjs +7 -0
  44. package/lib/esm/component/score/line.shadow.css +4 -4
  45. package/lib/esm/component/trend/Bar.mjs +20 -23
  46. package/lib/esm/component/trend/Line.mjs +20 -23
  47. package/lib/esm/component/trend/Trend.mjs +9 -12
  48. package/lib/esm/component/trend/index.mjs +8 -0
  49. package/lib/esm/index.mjs +5 -3
  50. package/lib/esm/utils/ScoreDonutUtils.mjs +82 -0
  51. package/lib/types/component/score/Donut.d.ts +8 -11
  52. package/lib/types/component/score/Line.d.ts +1 -1
  53. package/lib/types/component/score/Line.types.d.ts +11 -9
  54. package/lib/types/component/trend/Bar.d.ts +3 -9
  55. package/lib/types/component/trend/Line.d.ts +7 -11
  56. package/lib/types/component/trend/Trend.d.ts +4 -4
  57. package/lib/types/component/trend/index.d.ts +1 -1
  58. package/lib/types/utils/ScoreDonutUtils.d.ts +18 -0
  59. package/package.json +4 -4
@@ -2,37 +2,36 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _objectSpread from "@babel/runtime/helpers/objectSpread2";
3
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/createClass";
5
+ import _callSuper from "@babel/runtime/helpers/callSuper";
5
6
  import _inherits from "@babel/runtime/helpers/inherits";
6
- import _createSuper from "@babel/runtime/helpers/createSuper";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- import { sstyled as _sstyled } from "@semcore/utils/lib/core/index";
8
+ import { sstyled as _sstyled } from "@semcore/core";
9
9
  import { assignProps as _assignProps } from "@semcore/core";
10
+ import { Box } from '@semcore/base-components';
11
+ import { createComponent, assignProps, Root, sstyled } from '@semcore/core';
12
+ import { extractAriaProps } from '@semcore/core/lib/utils/ariaProps';
13
+ import resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';
14
+ import uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';
10
15
  import React from 'react';
11
- import createComponent, { assignProps, Root, sstyled } from '@semcore/core';
12
- import resolveColorEnhance from '@semcore/utils/lib/enhances/resolveColorEnhance';
13
- import uniqueIDEnhancement from '@semcore/utils/lib/uniqueID';
14
16
  import { Trend } from './Trend';
15
- import { Box } from '@semcore/flex-box';
16
17
  /*!__reshadow-styles__:"../skeleton/skeleton.shadow.css"*/
17
- var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/"@keyframes pulse_1k9zd{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_1k9zd_gg_.__loading_1k9zd_gg_,.___SLineGauge_1k9zd_gg_.__loading_1k9zd_gg_,.___STrendBar_1k9zd_gg_.__loading_1k9zd_gg_,.___STrendLine_1k9zd_gg_.__loading_1k9zd_gg_{animation-name:pulse_1k9zd;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}", /*__inner_css_end__*/"1k9zd_gg_"),
18
+ var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/"@keyframes pulse_1yrsa{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_1yrsa_gg_.__loading_1yrsa_gg_,.___SLineGauge_1yrsa_gg_.__loading_1yrsa_gg_,.___STrendBar_1yrsa_gg_.__loading_1yrsa_gg_,.___STrendLine_1yrsa_gg_.__loading_1yrsa_gg_{animation-name:pulse_1yrsa;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}", /*__inner_css_end__*/"1yrsa_gg_"),
18
19
  /*__reshadow_css_end__*/
19
20
  {
20
- "__SLineGauge": "___SLineGauge_1k9zd_gg_",
21
- "_loading": "__loading_1k9zd_gg_",
22
- "__SDonutContainer": "___SDonutContainer_1k9zd_gg_",
23
- "__STrendLine": "___STrendLine_1k9zd_gg_",
24
- "__STrendBar": "___STrendBar_1k9zd_gg_",
25
- "@pulse": "pulse_1k9zd"
21
+ "__SLineGauge": "___SLineGauge_1yrsa_gg_",
22
+ "_loading": "__loading_1yrsa_gg_",
23
+ "__SDonutContainer": "___SDonutContainer_1yrsa_gg_",
24
+ "__STrendLine": "___STrendLine_1yrsa_gg_",
25
+ "__STrendBar": "___STrendBar_1yrsa_gg_",
26
+ "@pulse": "pulse_1yrsa"
26
27
  });
27
- import { extractAriaProps } from '@semcore/utils/lib/ariaProps';
28
28
  var TrendLineRoot = /*#__PURE__*/function (_Trend) {
29
- _inherits(TrendLineRoot, _Trend);
30
- var _super = _createSuper(TrendLineRoot);
31
29
  function TrendLineRoot() {
32
30
  _classCallCheck(this, TrendLineRoot);
33
- return _super.apply(this, arguments);
31
+ return _callSuper(this, TrendLineRoot, arguments);
34
32
  }
35
- _createClass(TrendLineRoot, [{
33
+ _inherits(TrendLineRoot, _Trend);
34
+ return _createClass(TrendLineRoot, [{
36
35
  key: "defaultData",
37
36
  get: function get() {
38
37
  return [15, 70, 20, 85, 20];
@@ -142,7 +141,6 @@ var TrendLineRoot = /*#__PURE__*/function (_Trend) {
142
141
  }))))));
143
142
  }
144
143
  }]);
145
- return TrendLineRoot;
146
144
  }(Trend);
147
145
  _defineProperty(TrendLineRoot, "enhance", [resolveColorEnhance(), uniqueIDEnhancement()]);
148
146
  _defineProperty(TrendLineRoot, "style", style);
@@ -1 +1 @@
1
- {"version":3,"file":"Line.js","names":["React","createComponent","assignProps","Root","sstyled","resolveColorEnhance","uniqueIDEnhancement","Trend","Box","style","_sstyled","insert","extractAriaProps","TrendLineRoot","_Trend","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_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 React from 'react';\nimport createComponent, { ComponentType, assignProps, Root, sstyled } from '@semcore/core';\nimport resolveColorEnhance from '@semcore/utils/lib/enhances/resolveColorEnhance';\nimport uniqueIDEnhancement from '@semcore/utils/lib/uniqueID';\nimport { Trend, CommonTrendProps } from './Trend';\nimport { Box } from '@semcore/flex-box';\n\nimport style from '../skeleton/skeleton.shadow.css';\nimport { extractAriaProps } from '@semcore/utils/lib/ariaProps';\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,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,IAAmBC,WAAW,EAAEC,IAAI,EAAEC,OAAO,QAAQ,eAAe;AAC1F,OAAOC,mBAAmB,MAAM,iDAAiD;AACjF,OAAOC,mBAAmB,MAAM,6BAA6B;AAC7D,SAASC,KAAK,QAA0B,SAAS;AACjD,SAASC,GAAG,QAAQ,mBAAmB;AAAC;AAAA,IAAAC,KAAA,+BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAGxC,SAASC,gBAAgB,QAAQ,8BAA8B;AAAC,IA8B1DC,aAAa,0BAAAC,MAAA;EAAAC,SAAA,CAAAF,aAAA,EAAAC,MAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,aAAA;EAAA,SAAAA,cAAA;IAAAK,eAAA,OAAAL,aAAA;IAAA,OAAAG,MAAA,CAAAG,KAAA,OAAAC,SAAA;EAAA;EAAAC,YAAA,CAAAR,aAAA;IAAAS,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,QAAAA,qBAAA,GAAO,IAAI,CAACC,OAAO,CAACC,eAAe,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,CAAC;IAC1C;EAAC;IAAAF,GAAA;IAAAC,GAAA,EAED,SAAAA,IAAA,EAA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Q,MAAM;QAAA,QAAO;MAAO,iBACxD1D,KAAA,CAAAyD,aAAA,YAAAhB,KAAA,CAAAiB,EAAA;QAAA,OAAa,OAAO;QAAA,iBAAe,OAAO;QAAA,UAAQ;MAAQ,GAAG,CACxD,CAEV,CACG,CACK;IAEjB;EAAC;EAAA,OAAA7C,aAAA;AAAA,EA9GyBN,KAAK;AAAA2D,eAAA,CAA3BrD,aAAa,aACA,CAACR,mBAAmB,EAAE,EAAEC,mBAAmB,EAAE,CAAC;AAAA4D,eAAA,CAD3DrD,aAAa,WAGFJ,KAAK;AAAAyD,eAAA,CAHhBrD,aAAa,kBAKK;EACpBiC,OAAO,EAAE;AACX,CAAC;AA0GH,OAAO,IAAMqB,SAA0D,GACrElE,eAAe,CAACY,aAAa,CAAC;AAEhCsD,SAAS,CAACC,WAAW,GAAG,qBAAqB;AAE7C,OAAO,IAAMC,SAA0D,GAAGpE,eAAe,CACvFY,aAAa,EACb,CAAC,CAAC,EACF;EACEyD,YAAY,EAAE,CACZ,YAAM;IACJ,OAAO;MACLC,YAAY,EAAE,SAAAA,aAACC,KAAqB,EAAK;QACvC,OAAOtE,WAAW,CAACsE,KAAK,EAAE;UAAE3B,QAAQ,EAAE;QAAK,CAAC,CAAC;MAC/C;IACF,CAAC;EACH,CAAC;AAEL,CAAC,CACF;AAEDwB,SAAS,CAACD,WAAW,GAAG,qBAAqB"}
1
+ {"version":3,"file":"Line.js","names":["Box","createComponent","assignProps","Root","sstyled","extractAriaProps","resolveColorEnhance","uniqueIDEnhancement","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 { 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,GAAG,QAAQ,0BAA0B;AAC9C,SAASC,eAAe,EAAEC,WAAW,E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CAAC;AAAAyD,eAAA,CAD3DnD,aAAa,WAGFH,KAAK;AAAAsD,eAAA,CAHhBnD,aAAa,kBAKK;EACpB+B,OAAO,EAAE;AACX,CAAC;AA0GH,OAAO,IAAMqB,SAAS,GAAGhE,eAAe,CAA0DY,aAAa,CAAC;AAEhHoD,SAAS,CAACC,WAAW,GAAG,qBAAqB;AAE7C,OAAO,IAAMC,SAAS,GAAGlE,eAAe,CACtCY,aAAa,EACb,CAAC,CAAC,EACF;EACEuD,YAAY,EAAE,CACZ,YAAM;IACJ,OAAO;MACLC,YAAY,EAAE,SAAdA,YAAYA,CAAGC,KAAqB,EAAK;QACvC,OAAOpE,WAAW,CAACoE,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,29 +1,27 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
3
+ import _callSuper from "@babel/runtime/helpers/callSuper";
4
4
  import _inherits from "@babel/runtime/helpers/inherits";
5
- import _createSuper from "@babel/runtime/helpers/createSuper";
6
5
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- import React from 'react';
8
6
  import { Component } from '@semcore/core';
7
+ import React from 'react';
9
8
  export var Trend = /*#__PURE__*/function (_Component) {
10
- _inherits(Trend, _Component);
11
- var _super = _createSuper(Trend);
12
9
  function Trend() {
13
10
  var _this;
14
11
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
15
12
  args[_key] = arguments[_key];
16
13
  }
17
14
  _classCallCheck(this, Trend);
18
- _this = _super.call.apply(_super, [this].concat(args));
19
- _defineProperty(_assertThisInitialized(_this), "state", {
15
+ _this = _callSuper(this, Trend, [].concat(args));
16
+ _defineProperty(_this, "state", {
20
17
  width: 200,
21
18
  height: 100
22
19
  });
23
- _defineProperty(_assertThisInitialized(_this), "containerRef", /*#__PURE__*/React.createRef());
20
+ _defineProperty(_this, "containerRef", /*#__PURE__*/React.createRef());
24
21
  return _this;
25
22
  }
26
- _createClass(Trend, [{
23
+ _inherits(Trend, _Component);
24
+ return _createClass(Trend, [{
27
25
  key: "componentDidMount",
28
26
  value: function componentDidMount() {
29
27
  this.setSizes();
@@ -74,6 +72,5 @@ export var Trend = /*#__PURE__*/function (_Component) {
74
72
  }
75
73
  }
76
74
  }]);
77
- return Trend;
78
75
  }(Component);
79
76
  //# sourceMappingURL=Trend.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Trend.js","names":["React","Component","Trend","_Component","_inherits","_super","_createSuper","_this","_len","arguments","length","args","Array","_key","_classCallCheck","call","apply","concat","_defineProperty","_assertThisInitialized","width","height","createRef","_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 React from 'react';\nimport { Component } from '@semcore/core';\nimport { BoxProps } from '@semcore/flex-box';\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 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,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,QAAQ,eAAe;AAsBzC,WAAsBC,KAAK,0BAAAC,UAAA;EAAAC,SAAA,CAAAF,KAAA,EAAAC,UAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,KAAA;EAAA,SAAAA,MAAA;IAAA,IAAAK,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,OAAAZ,KAAA;IAAAK,KAAA,GAAAF,MAAA,CAAAU,IAAA,CAAAC,KAAA,CAAAX,MAAA,SAAAY,MAAA,CAAAN,IAAA;IAAAO,eAAA,CAAAC,sBAAA,CAAAZ,KAAA,YAIjB;MACNa,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE;IACV,CAAC;IAAAH,eAAA,CAAAC,sBAAA,CAAAZ,KAAA,gCAEcP,KAAK,CAACsB,SAAS,EAAkB;IAAA,OAAAf,KAAA;EAAA;EAAAgB,YAAA,CAAArB,KAAA;IAAAsB,GAAA;IAAAC,KAAA,EAEhD,SAAAC,kBAAA,EAAoB;MAClB,IAAI,CAACC,QAAQ,EAAE;IACjB;EAAC;IAAAH,GAAA;IAAAC,KAAA,EACD,SAAAG,mBAAmBC,SAAY,EAAE;MAC/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AAA;AAAA,EAjDOD,SAAS"}
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 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,WAAsBC,KAAK,0BAAAC,UAAA;EAAA,SAAAD,MAAA;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a;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,4 +1,4 @@
1
- import { TrendLine, TrendArea } from './Line';
2
1
  import { TrendBar, TrendHistogram } from './Bar';
2
+ import { TrendLine, TrendArea } from './Line';
3
3
  export { TrendLine, TrendArea, TrendBar, TrendHistogram };
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["TrendLine","TrendArea","TrendBar","TrendHistogram"],"sources":["../../../../src/component/trend/index.ts"],"sourcesContent":["import { TrendLine, TrendArea } from './Line';\nimport { TrendBar, TrendHistogram } from './Bar';\n\nexport { TrendLine, TrendArea, TrendBar, TrendHistogram };\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,SAAS,QAAQ,QAAQ;AAC7C,SAASC,QAAQ,EAAEC,cAAc,QAAQ,OAAO;AAEhD,SAASH,SAAS,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,cAAc"}
1
+ {"version":3,"file":"index.js","names":["TrendBar","TrendHistogram","TrendLine","TrendArea"],"sources":["../../../../src/component/trend/index.ts"],"sourcesContent":["import { TrendBar, TrendHistogram } from './Bar';\nimport { TrendLine, TrendArea } from './Line';\n\nexport { TrendLine, TrendArea, TrendBar, TrendHistogram };\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,cAAc,QAAQ,OAAO;AAChD,SAASC,SAAS,EAAEC,SAAS,QAAQ,QAAQ;AAE7C,SAASD,SAAS,EAAEC,SAAS,EAAEH,QAAQ,EAAEC,cAAc","ignoreList":[]}
@@ -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"}
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":[]}
@@ -0,0 +1,80 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ export var ScoreDonutUtils = /*#__PURE__*/function () {
5
+ function ScoreDonutUtils(value, isSemiDonut) {
6
+ _classCallCheck(this, ScoreDonutUtils);
7
+ _defineProperty(this, "isSemiDonut", void 0);
8
+ _defineProperty(this, "value", void 0);
9
+ _defineProperty(this, "radius", void 0);
10
+ this.isSemiDonut = isSemiDonut;
11
+ this.radius = isSemiDonut ? 9 : 10;
12
+ this.value = Math.max(Math.min(value, 100), 0);
13
+ }
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
+ }();
80
+ //# sourceMappingURL=ScoreDonutUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScoreDonutUtils.js","names":["ScoreDonutUtils","value","isSemiDonut","_classCallCheck","_defineProperty","radius","Math","max","min","_createClass","key","get","PI","fullLength","valueLength","startMargin","endMargin","margin","point"],"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,WAAaA,eAAe;E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1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _callSuper from "@babel/runtime/helpers/esm/callSuper";
4
5
  import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
6
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
- import { sstyled } from "@semcore/utils/lib/core/index";
8
- import createComponent, { assignProps, sstyled as sstyled$1, Component } from "@semcore/core";
7
+ import { sstyled, assignProps, Component, createComponent } from "@semcore/core";
8
+ import { Box } from "@semcore/base-components";
9
+ import { extractAriaProps } from "@semcore/core/lib/utils/ariaProps";
10
+ import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
11
+ import { cssVariableEnhance } from "@semcore/core/lib/utils/useCssVariable";
9
12
  import React from "react";
10
- import { Box } from "@semcore/flex-box";
11
- import resolveColorEnhance from "@semcore/utils/lib/enhances/resolveColorEnhance";
12
- import { extractAriaProps } from "@semcore/utils/lib/ariaProps";
13
+ import { ScoreDonutUtils } from "../../utils/ScoreDonutUtils.mjs";
13
14
  /*!__reshadow-styles__:"./donut.shadow.css"*/
14
15
  var style = (
15
16
  /*__reshadow_css_start__*/
16
17
  (sstyled.insert(
17
18
  /*__inner_css_start__*/
18
- "@keyframes pulse_1uvfz{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_1uvfz_gg_.__loading_1uvfz_gg_,.___SLineGauge_1uvfz_gg_.__loading_1uvfz_gg_,.___STrendBar_1uvfz_gg_.__loading_1uvfz_gg_,.___STrendLine_1uvfz_gg_.__loading_1uvfz_gg_{animation-name:pulse_1uvfz;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}.___SDonutContainer_1uvfz_gg_.__semi_1uvfz_gg_ g{transform:rotate(180deg) translate(-24px,-24px)}.___SDonutContainer_1uvfz_gg_ g{transform:rotate(-90deg) translate(-24px)}.___SDonutContainer_1uvfz_gg_.__animate_1uvfz_gg_ circle{transition:all var(--intergalactic-duration-extra-slow, 500) ease-in-out}",
19
+ "@keyframes pulse_w54vj{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_w54vj_gg_.__loading_w54vj_gg_,.___SLineGauge_w54vj_gg_.__loading_w54vj_gg_,.___STrendBar_w54vj_gg_.__loading_w54vj_gg_,.___STrendLine_w54vj_gg_.__loading_w54vj_gg_{animation-name:pulse_w54vj;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}.___SDonutContainer_w54vj_gg_.__semi_w54vj_gg_ g{transform:rotate(180deg) translate(-24px,-24px)}.___SDonutContainer_w54vj_gg_ g{transform:rotate(-90deg) translate(-24px)}.___SDonutContainer_w54vj_gg_.__animate_w54vj_gg_ circle{transition:all var(--intergalactic-duration-extra-slow, 500) ease-in-out}",
19
20
  /*__inner_css_end__*/
20
- "1uvfz_gg_"
21
+ "w54vj_gg_"
21
22
  ), /*__reshadow_css_end__*/
22
23
  {
23
- "__SLineGauge": "___SLineGauge_1uvfz_gg_",
24
- "_loading": "__loading_1uvfz_gg_",
25
- "__SDonutContainer": "___SDonutContainer_1uvfz_gg_",
26
- "__STrendLine": "___STrendLine_1uvfz_gg_",
27
- "__STrendBar": "___STrendBar_1uvfz_gg_",
28
- "@pulse": "pulse_1uvfz",
29
- "_animate": "__animate_1uvfz_gg_",
30
- "_semi": "__semi_1uvfz_gg_"
24
+ "__SLineGauge": "___SLineGauge_w54vj_gg_",
25
+ "_loading": "__loading_w54vj_gg_",
26
+ "__SDonutContainer": "___SDonutContainer_w54vj_gg_",
27
+ "__STrendLine": "___STrendLine_w54vj_gg_",
28
+ "__STrendBar": "___STrendBar_w54vj_gg_",
29
+ "@pulse": "pulse_w54vj",
30
+ "_animate": "__animate_w54vj_gg_",
31
+ "_semi": "__semi_w54vj_gg_"
31
32
  })
32
33
  );
33
- var DonutRoot = /* @__PURE__ */ function(_Component) {
34
- _inherits(DonutRoot2, _Component);
35
- var _super = _createSuper(DonutRoot2);
34
+ var DonutRoot = /* @__PURE__ */ (function(_Component) {
36
35
  function DonutRoot2() {
37
36
  _classCallCheck(this, DonutRoot2);
38
- return _super.apply(this, arguments);
37
+ return _callSuper(this, DonutRoot2, arguments);
39
38
  }
40
- _createClass(DonutRoot2, [{
39
+ _inherits(DonutRoot2, _Component);
40
+ return _createClass(DonutRoot2, [{
41
41
  key: "render",
42
42
  value: function render() {
43
43
  var _ref = this.asProps, _ref2;
44
44
  var SDonutContainer = Box;
45
- var _this$asProps = this.asProps, value = _this$asProps.value, styles = _this$asProps.styles, _this$asProps$baseBgC = _this$asProps.baseBgColor, baseBgColor = _this$asProps$baseBgC === void 0 ? "chart-grid-bar-chart-base-bg" : _this$asProps$baseBgC, _this$asProps$color = _this$asProps.color, color = _this$asProps$color === void 0 ? "chart-palette-order-1" : _this$asProps$color, resolveColor = _this$asProps.resolveColor, isSemiDonut = _this$asProps.isSemiDonut, loading = _this$asProps.loading;
46
- var strokeWidth = isSemiDonut ? 6 : 4;
47
- var radius = isSemiDonut ? 9 : 10;
48
- var baseStrokeDasharray = isSemiDonut ? Math.PI * radius : Math.PI * 2 * radius;
49
- var valueStrokeDasharray = baseStrokeDasharray * (value / 100);
50
- var greyStrokeDasharray = baseStrokeDasharray * ((100 - value) / 100);
51
- var offsetPoint = isSemiDonut ? baseStrokeDasharray / (100 / 3) : baseStrokeDasharray / 100;
52
- var strokeDasharrayBetweenSpaces = "".concat(greyStrokeDasharray - 2 * offsetPoint, " ").concat(offsetPoint);
53
- var spaceStrokeDasharray = "".concat(offsetPoint, " ").concat(value < 99 ? "".concat(strokeDasharrayBetweenSpaces) : "", " ").concat(baseStrokeDasharray);
54
- if (isSemiDonut) {
55
- spaceStrokeDasharray = "".concat(offsetPoint, " ").concat(value < 95 ? "".concat(strokeDasharrayBetweenSpaces) : "", " ").concat(baseStrokeDasharray);
56
- }
57
- var viewBox = isSemiDonut ? "0 0 24 12" : "0 0 24 24";
58
- var strokeDashoffsetBase = -1 * (valueStrokeDasharray + (isSemiDonut ? offsetPoint : 0));
45
+ var _this$asProps = this.asProps, value = _this$asProps.value, styles = _this$asProps.styles, _this$asProps$baseBgC = _this$asProps.baseBgColor, baseBgColor = _this$asProps$baseBgC === void 0 ? "chart-grid-bar-chart-base-bg" : _this$asProps$baseBgC, _this$asProps$color = _this$asProps.color, color = _this$asProps$color === void 0 ? "chart-palette-order-1" : _this$asProps$color, resolveColor = _this$asProps.resolveColor, isSemiDonut = _this$asProps.isSemiDonut, loading = _this$asProps.loading, animate = _this$asProps.animate, duration = _this$asProps.duration;
46
+ var scoreDonut = new ScoreDonutUtils(value, isSemiDonut);
59
47
  var _extractAriaProps = extractAriaProps(this.asProps), __excludeProps = _extractAriaProps.__excludeProps, extractedAriaProps = _extractAriaProps.extractedAriaProps;
60
- return _ref2 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SDonutContainer, _ref2.cn("SDonutContainer", _objectSpread({}, assignProps({
48
+ return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(SDonutContainer, _ref2.cn("SDonutContainer", _objectSpread({}, assignProps({
61
49
  "semi": isSemiDonut,
62
50
  "__excludeProps": __excludeProps
63
51
  }, _ref))), /* @__PURE__ */ React.createElement("svg", _ref2.cn("svg", _objectSpread({
64
52
  "width": "100%",
65
53
  "height": "100%",
66
- "viewBox": viewBox,
54
+ "viewBox": scoreDonut.viewBox,
67
55
  "fill": "none",
68
56
  "role": "img"
69
57
  }, extractedAriaProps)), /* @__PURE__ */ React.createElement("g", _ref2.cn("g", {}), /* @__PURE__ */ React.createElement("circle", _ref2.cn("circle", {
70
58
  "cx": "12",
71
59
  "cy": "12",
72
- "r": radius,
73
- "strokeWidth": strokeWidth,
60
+ "r": scoreDonut.radius,
61
+ "strokeWidth": scoreDonut.strokeWidth,
74
62
  "stroke": resolveColor(baseBgColor),
75
- "strokeDasharray": loading ? void 0 : "".concat(greyStrokeDasharray, " ").concat(baseStrokeDasharray),
76
- "strokeDashoffset": strokeDashoffsetBase
77
- })), !loading && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("circle", _ref2.cn("circle", {
78
- "cx": "12",
79
- "cy": "12",
80
- "r": radius,
81
- "strokeWidth": strokeWidth,
82
- "stroke": resolveColor(color),
83
- "strokeDasharray": "".concat(valueStrokeDasharray, " ").concat(baseStrokeDasharray),
84
- "strokeDashoffset": valueStrokeDasharray
85
- }), /* @__PURE__ */ React.createElement("animate", _ref2.cn("animate", {
63
+ "strokeDasharray": loading ? void 0 : "".concat(scoreDonut.baseLength, " ").concat(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": "".concat(scoreDonut.animatedBaseLengthFrom, " ").concat(scoreDonut.fullLength),
68
+ "to": "".concat(scoreDonut.animatedBaseLengthTo, " ").concat(scoreDonut.fullLength),
69
+ "dur": duration + "ms"
70
+ })), /* @__PURE__ */ React.createElement("animate", _ref2.cn("animate", {
86
71
  "attributeName": "stroke-dashoffset",
87
- "values": "0;".concat(valueStrokeDasharray)
88
- }))), value !== 100 && !isSemiDonut && /* @__PURE__ */ React.createElement("circle", _ref2.cn("circle", {
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", {
89
76
  "cx": "12",
90
77
  "cy": "12",
91
- "r": radius,
92
- "strokeWidth": strokeWidth,
93
- "stroke": resolveColor("chart-grid-border"),
94
- "strokeDasharray": spaceStrokeDasharray,
95
- "strokeDashoffset": -1 * valueStrokeDasharray
96
- }))))));
78
+ "r": scoreDonut.radius,
79
+ "strokeWidth": scoreDonut.strokeWidth,
80
+ "stroke": resolveColor(color),
81
+ "strokeDasharray": "".concat(scoreDonut.valueLength, " ").concat(scoreDonut.fullLength)
82
+ }), animate && /* @__PURE__ */ React.createElement("animate", _ref2.cn("animate", {
83
+ "attributeName": "stroke-dasharray",
84
+ "from": "0 ".concat(scoreDonut.fullLength),
85
+ "to": "".concat(scoreDonut.valueLength, " ").concat(scoreDonut.fullLength),
86
+ "dur": duration + "ms"
87
+ })))))));
97
88
  }
98
89
  }]);
99
- return DonutRoot2;
100
- }(Component);
101
- _defineProperty(DonutRoot, "enhance", [resolveColorEnhance()]);
90
+ })(Component);
91
+ _defineProperty(DonutRoot, "enhance", [cssVariableEnhance({
92
+ variable: "--intergalactic-duration-extra-slow",
93
+ fallback: "500",
94
+ map: function map(v) {
95
+ return Number.parseInt(v, 10).toString();
96
+ },
97
+ prop: "duration"
98
+ }), resolveColorEnhance()]);
102
99
  _defineProperty(DonutRoot, "style", style);
103
100
  _defineProperty(DonutRoot, "defaultProps", {
104
101
  animate: true