@semcore/mini-chart 16.0.9 → 16.1.0-prerelease.3

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 (34) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/lib/cjs/component/score/Donut.js +43 -33
  3. package/lib/cjs/component/score/Donut.js.map +1 -1
  4. package/lib/cjs/component/score/Line.js +20 -23
  5. package/lib/cjs/component/score/Line.js.map +1 -1
  6. package/lib/cjs/component/trend/Bar.js +9 -12
  7. package/lib/cjs/component/trend/Bar.js.map +1 -1
  8. package/lib/cjs/component/trend/Line.js +9 -12
  9. package/lib/cjs/component/trend/Line.js.map +1 -1
  10. package/lib/cjs/component/trend/Trend.js +2 -5
  11. package/lib/cjs/component/trend/Trend.js.map +1 -1
  12. package/lib/cjs/utils/ScoreDonutUtils.js +36 -28
  13. package/lib/cjs/utils/ScoreDonutUtils.js.map +1 -1
  14. package/lib/es6/component/score/Donut.js +42 -32
  15. package/lib/es6/component/score/Donut.js.map +1 -1
  16. package/lib/es6/component/score/Line.js +19 -22
  17. package/lib/es6/component/score/Line.js.map +1 -1
  18. package/lib/es6/component/trend/Bar.js +8 -11
  19. package/lib/es6/component/trend/Bar.js.map +1 -1
  20. package/lib/es6/component/trend/Line.js +8 -11
  21. package/lib/es6/component/trend/Line.js.map +1 -1
  22. package/lib/es6/component/trend/Trend.js +1 -4
  23. package/lib/es6/component/trend/Trend.js.map +1 -1
  24. package/lib/es6/utils/ScoreDonutUtils.js +36 -28
  25. package/lib/es6/utils/ScoreDonutUtils.js.map +1 -1
  26. package/lib/esm/component/score/Donut.mjs +41 -35
  27. package/lib/esm/component/score/Line.mjs +20 -25
  28. package/lib/esm/component/trend/Bar.mjs +9 -14
  29. package/lib/esm/component/trend/Line.mjs +9 -14
  30. package/lib/esm/component/trend/Trend.mjs +1 -6
  31. package/lib/esm/utils/ScoreDonutUtils.mjs +36 -28
  32. package/lib/types/component/score/Donut.d.ts +2 -0
  33. package/lib/types/utils/ScoreDonutUtils.d.ts +10 -7
  34. package/package.json +4 -4
@@ -9,14 +9,9 @@ var ScoreDonutUtils = /* @__PURE__ */ function() {
9
9
  _defineProperty(this, "radius", void 0);
10
10
  this.isSemiDonut = isSemiDonut;
11
11
  this.radius = isSemiDonut ? 9 : 10;
12
- this.value = value;
12
+ this.value = Math.max(Math.min(value, 100), 0);
13
13
  }
14
14
  return _createClass(ScoreDonutUtils2, [{
15
- key: "hasDivider",
16
- get: function get() {
17
- return ![0, 100].includes(this.value);
18
- }
19
- }, {
20
15
  key: "viewBox",
21
16
  get: function get() {
22
17
  return this.isSemiDonut ? "0 0 24 12" : "0 0 24 24";
@@ -27,45 +22,58 @@ var ScoreDonutUtils = /* @__PURE__ */ function() {
27
22
  return this.isSemiDonut ? 6 : 4;
28
23
  }
29
24
  }, {
30
- key: "baseStrokeDashArray",
25
+ key: "fullLength",
31
26
  get: function get() {
32
27
  return this.isSemiDonut ? Math.PI * this.radius : 2 * Math.PI * this.radius;
33
28
  }
34
29
  }, {
35
- key: "valueStrokeDashArray",
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",
36
53
  get: function get() {
37
- return this.baseStrokeDashArray * (this.value / 100);
54
+ var margin = 0;
55
+ if (!this.isSemiDonut && this.value > 0) margin = this.point;
56
+ return margin;
38
57
  }
39
58
  }, {
40
- key: "greyStrokeDashArray",
59
+ key: "baseOffset",
41
60
  get: function get() {
42
- return this.baseStrokeDashArray - this.valueStrokeDashArray;
61
+ return -1 * (this.valueLength + this.startMargin);
43
62
  }
44
63
  }, {
45
- key: "offsetPoint",
64
+ key: "baseLength",
46
65
  get: function get() {
47
- return this.isSemiDonut ? this.baseStrokeDashArray / (100 / 3) : this.baseStrokeDashArray / 100;
66
+ return Math.max(this.fullLength - this.valueLength - this.startMargin - this.endMargin, 0);
48
67
  }
49
68
  }, {
50
- key: "strokeDashArrayParts",
69
+ key: "animatedBaseLengthFrom",
51
70
  get: function get() {
52
- var greyStroke = this.greyStrokeDashArray;
53
- var offsetPoint = this.offsetPoint;
54
- var greyStrokeDash = greyStroke - 2 * offsetPoint;
55
- var strokeDashArrayBetweenSpaces = "".concat(greyStrokeDash, " ").concat(offsetPoint);
56
- if (this.isSemiDonut) {
57
- return "".concat(offsetPoint, " ").concat(this.value < 95 ? strokeDashArrayBetweenSpaces : "", " ").concat(this.baseStrokeDashArray);
58
- }
59
- return "".concat(offsetPoint, " ").concat(greyStrokeDash >= 0 ? strokeDashArrayBetweenSpaces : "", " ").concat(this.baseStrokeDashArray);
71
+ return this.fullLength - this.startMargin - this.endMargin;
60
72
  }
61
73
  }, {
62
- key: "strokeDashOffsetBase",
74
+ key: "animatedBaseLengthTo",
63
75
  get: function get() {
64
- var hasDivider = this.hasDivider;
65
- if (!hasDivider) return 0;
66
- var valueStroke = this.valueStrokeDashArray;
67
- var offsetPoint = this.offsetPoint;
68
- return -1 * (valueStroke + (this.isSemiDonut ? offsetPoint : 0));
76
+ return this.fullLength - this.valueLength - this.startMargin - this.endMargin;
69
77
  }
70
78
  }]);
71
79
  }();
@@ -1,10 +1,12 @@
1
1
  import { type ComponentType } from '@semcore/core';
2
2
  import resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';
3
+ import { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';
3
4
  import { type BoxProps } from '@semcore/flex-box';
4
5
  import type { CommonScoreProps } from './Score';
5
6
  export type ScoreDonutProps = BoxProps & CommonScoreProps;
6
7
  type Enhances = {
7
8
  resolveColor: ReturnType<typeof resolveColorEnhance>;
9
+ duration: ReturnType<typeof cssVariableEnhance>;
8
10
  isSemiDonut?: true;
9
11
  };
10
12
  export declare const ScoreDonut: ComponentType<ScoreDonutProps, {}, {}, Enhances>;
@@ -3,13 +3,16 @@ export declare class ScoreDonutUtils {
3
3
  private readonly value;
4
4
  readonly radius: number;
5
5
  constructor(value: number, isSemiDonut: boolean);
6
- get hasDivider(): boolean;
7
6
  get viewBox(): "0 0 24 12" | "0 0 24 24";
8
7
  get strokeWidth(): 6 | 4;
9
- get baseStrokeDashArray(): number;
10
- get valueStrokeDashArray(): number;
11
- get greyStrokeDashArray(): number;
12
- get offsetPoint(): number;
13
- get strokeDashArrayParts(): string;
14
- get strokeDashOffsetBase(): number;
8
+ get fullLength(): number;
9
+ get point(): number;
10
+ get valueLength(): number;
11
+ get animatedValueLength(): number;
12
+ get startMargin(): number;
13
+ get endMargin(): number;
14
+ get baseOffset(): number;
15
+ get baseLength(): number;
16
+ get animatedBaseLengthFrom(): number;
17
+ get animatedBaseLengthTo(): number;
15
18
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/mini-chart",
3
3
  "description": "Semrush MiniChart Component",
4
- "version": "16.0.9",
4
+ "version": "16.1.0-prerelease.3",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,8 +14,8 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "peerDependencies": {
17
- "@semcore/base-components": "^16.0.0",
18
- "@semcore/flex-box": "^16.0.0"
17
+ "@semcore/base-components": "^16.4.0-prerelease.3",
18
+ "@semcore/flex-box": "^16.0.10-prerelease.3"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "directory": "semcore/mini-chart"
24
24
  },
25
25
  "devDependencies": {
26
- "@semcore/core": "16.3.0",
26
+ "@semcore/core": "16.5.0-prerelease.3",
27
27
  "@semcore/testing-utils": "1.0.0"
28
28
  },
29
29
  "scripts": {