@semcore/mini-chart 0.30.0-prerelease.4 → 0.30.0-prerelease.5

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 (55) hide show
  1. package/lib/cjs/component/score/Donut.js +60 -64
  2. package/lib/cjs/component/score/Donut.js.map +1 -1
  3. package/lib/cjs/component/score/Line.js +38 -41
  4. package/lib/cjs/component/score/Line.js.map +1 -1
  5. package/lib/cjs/component/score/Line.types.js.map +1 -1
  6. package/lib/cjs/component/score/Score.js.map +1 -1
  7. package/lib/cjs/component/score/index.js.map +1 -1
  8. package/lib/cjs/component/trend/Bar.js +22 -28
  9. package/lib/cjs/component/trend/Bar.js.map +1 -1
  10. package/lib/cjs/component/trend/Line.js +20 -26
  11. package/lib/cjs/component/trend/Line.js.map +1 -1
  12. package/lib/cjs/component/trend/Trend.js +9 -13
  13. package/lib/cjs/component/trend/Trend.js.map +1 -1
  14. package/lib/cjs/component/trend/index.js +1 -1
  15. package/lib/cjs/component/trend/index.js.map +1 -1
  16. package/lib/cjs/index.js +1 -2
  17. package/lib/cjs/index.js.map +1 -1
  18. package/lib/cjs/utils/ScoreDonutUtils.js +87 -0
  19. package/lib/cjs/utils/ScoreDonutUtils.js.map +1 -0
  20. package/lib/es6/component/score/Donut.js +57 -58
  21. package/lib/es6/component/score/Donut.js.map +1 -1
  22. package/lib/es6/component/score/Line.js +31 -31
  23. package/lib/es6/component/score/Line.js.map +1 -1
  24. package/lib/es6/component/score/Line.types.js.map +1 -1
  25. package/lib/es6/component/score/Score.js.map +1 -1
  26. package/lib/es6/component/score/index.js.map +1 -1
  27. package/lib/es6/component/trend/Bar.js +19 -21
  28. package/lib/es6/component/trend/Bar.js.map +1 -1
  29. package/lib/es6/component/trend/Line.js +17 -19
  30. package/lib/es6/component/trend/Line.js.map +1 -1
  31. package/lib/es6/component/trend/Trend.js +7 -10
  32. package/lib/es6/component/trend/Trend.js.map +1 -1
  33. package/lib/es6/component/trend/index.js +1 -1
  34. package/lib/es6/component/trend/index.js.map +1 -1
  35. package/lib/es6/index.js.map +1 -1
  36. package/lib/es6/utils/ScoreDonutUtils.js +80 -0
  37. package/lib/es6/utils/ScoreDonutUtils.js.map +1 -0
  38. package/lib/esm/component/score/Donut.mjs +58 -61
  39. package/lib/esm/component/score/Line.mjs +35 -37
  40. package/lib/esm/component/score/index.mjs +7 -0
  41. package/lib/esm/component/trend/Bar.mjs +20 -23
  42. package/lib/esm/component/trend/Line.mjs +20 -23
  43. package/lib/esm/component/trend/Trend.mjs +9 -12
  44. package/lib/esm/component/trend/index.mjs +8 -0
  45. package/lib/esm/index.mjs +5 -3
  46. package/lib/esm/utils/ScoreDonutUtils.mjs +82 -0
  47. package/lib/types/component/score/Donut.d.ts +8 -11
  48. package/lib/types/component/score/Line.d.ts +1 -1
  49. package/lib/types/component/score/Line.types.d.ts +11 -9
  50. package/lib/types/component/trend/Bar.d.ts +3 -9
  51. package/lib/types/component/trend/Line.d.ts +7 -11
  52. package/lib/types/component/trend/Trend.d.ts +4 -4
  53. package/lib/types/component/trend/index.d.ts +1 -1
  54. package/lib/types/utils/ScoreDonutUtils.d.ts +18 -0
  55. package/package.json +4 -4
@@ -1,29 +1,27 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
3
+ import _callSuper from "@babel/runtime/helpers/esm/callSuper";
4
4
  import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
5
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
- import React from "react";
8
6
  import { Component } from "@semcore/core";
9
- var Trend = /* @__PURE__ */ function(_Component) {
10
- _inherits(Trend2, _Component);
11
- var _super = _createSuper(Trend2);
7
+ import React from "react";
8
+ var Trend = /* @__PURE__ */ (function(_Component) {
12
9
  function Trend2() {
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, Trend2);
18
- _this = _super.call.apply(_super, [this].concat(args));
19
- _defineProperty(_assertThisInitialized(_this), "state", {
15
+ _this = _callSuper(this, Trend2, [].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(Trend2, [{
23
+ _inherits(Trend2, _Component);
24
+ return _createClass(Trend2, [{
27
25
  key: "componentDidMount",
28
26
  value: function componentDidMount() {
29
27
  this.setSizes();
@@ -71,8 +69,7 @@ var Trend = /* @__PURE__ */ function(_Component) {
71
69
  }
72
70
  }
73
71
  }]);
74
- return Trend2;
75
- }(Component);
72
+ })(Component);
76
73
  export {
77
74
  Trend
78
75
  };
@@ -0,0 +1,8 @@
1
+ import { TrendBar, TrendHistogram } from "./Bar.mjs";
2
+ import { TrendArea, TrendLine } from "./Line.mjs";
3
+ export {
4
+ TrendArea,
5
+ TrendBar,
6
+ TrendHistogram,
7
+ TrendLine
8
+ };
package/lib/esm/index.mjs CHANGED
@@ -1,7 +1,9 @@
1
- import { ScoreSemiDonut, ScoreDonut } from "./component/score/Donut.mjs";
1
+ import "./component/score/index.mjs";
2
+ import "./component/trend/index.mjs";
2
3
  import { ScoreLine } from "./component/score/Line.mjs";
3
- import { TrendLine, TrendArea } from "./component/trend/Line.mjs";
4
- import { TrendBar, TrendHistogram } from "./component/trend/Bar.mjs";
4
+ import { ScoreDonut, ScoreSemiDonut } from "./component/score/Donut.mjs";
5
+ import { TrendHistogram, TrendBar } from "./component/trend/Bar.mjs";
6
+ import { TrendArea, TrendLine } from "./component/trend/Line.mjs";
5
7
  var miniCharts = {
6
8
  TrendLine,
7
9
  TrendArea,
@@ -0,0 +1,82 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ var ScoreDonutUtils = /* @__PURE__ */ (function() {
5
+ function ScoreDonutUtils2(value, isSemiDonut) {
6
+ _classCallCheck(this, ScoreDonutUtils2);
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(ScoreDonutUtils2, [{
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
+ export {
81
+ ScoreDonutUtils
82
+ };
@@ -1,12 +1,9 @@
1
- import { ComponentType } from '@semcore/core';
2
- import { BoxProps } from '@semcore/flex-box';
3
- import resolveColorEnhance from '@semcore/utils/lib/enhances/resolveColorEnhance';
4
- import { CommonScoreProps } from './Score';
1
+ import { type BoxProps } from '@semcore/base-components';
2
+ import type { CommonScoreProps } from './Score';
5
3
  export type ScoreDonutProps = BoxProps & CommonScoreProps;
6
- type Enhances = {
7
- resolveColor: ReturnType<typeof resolveColorEnhance>;
8
- isSemiDonut?: true;
9
- };
10
- export declare const ScoreDonut: ComponentType<ScoreDonutProps, {}, {}, Enhances>;
11
- export declare const ScoreSemiDonut: ComponentType<ScoreDonutProps, {}, {}, Enhances>;
12
- export {};
4
+ export declare const ScoreDonut: import("@semcore/core").Intergalactic.Component<"svg", ScoreDonutProps, {}, readonly [<T extends {}>(props: T) => T & {
5
+ duration: string;
6
+ }, (props: any) => any]>;
7
+ export declare const ScoreSemiDonut: import("@semcore/core").Intergalactic.Component<"svg", ScoreDonutProps, {}, readonly [<T extends {}>(props: T) => T & {
8
+ duration: string;
9
+ }, (props: any) => any]>;
@@ -1,2 +1,2 @@
1
- import { ScoreLineComponent } from './Line.types';
1
+ import type { ScoreLineComponent } from './Line.types';
2
2
  export declare const ScoreLine: ScoreLineComponent;
@@ -1,8 +1,8 @@
1
- import { Intergalactic, ComponentType } from '@semcore/utils/lib/core';
2
- import { CommonScoreProps } from './Score';
3
- import React from 'react';
4
- import { BoxProps, Box } from '@semcore/flex-box';
5
- import resolveColorEnhance from '@semcore/utils/lib/enhances/resolveColorEnhance';
1
+ import type { BoxProps, Box } from '@semcore/base-components';
2
+ import type { Intergalactic } from '@semcore/core';
3
+ import type resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';
4
+ import type React from 'react';
5
+ import type { CommonScoreProps } from './Score';
6
6
  type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>;
7
7
  type Range<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
8
8
  export type SegmentColor = `chart-palette-order-${Range<1, 24>}`;
@@ -39,10 +39,12 @@ type CustomRenderScoreProps = {
39
39
  children: SegmentComponent[];
40
40
  };
41
41
  export type ScoreLineGaugeProps = BoxProps & Intergalactic.InternalTypings.EfficientOmit<CommonScoreProps, 'value' | 'color'> & (ValuedScoreProps | CustomRenderScoreProps);
42
- export type Enhances = {
43
- resolveColor: ReturnType<typeof resolveColorEnhance>;
44
- };
45
- export type ScoreLineComponent = ComponentType<ScoreLineGaugeProps, {}, {}, Enhances> & {
42
+ export type Enhances = [
43
+ () => {
44
+ resolveColor: ReturnType<typeof resolveColorEnhance>;
45
+ }
46
+ ];
47
+ export type ScoreLineComponent = Intergalactic.Component<'svg', ScoreLineGaugeProps, {}, Enhances> & {
46
48
  Segment: Intergalactic.Component<typeof Box, SegmentProps>;
47
49
  };
48
50
  export {};
@@ -1,6 +1,4 @@
1
- import { ComponentType } from '@semcore/core';
2
- import resolveColorEnhance from '@semcore/utils/lib/enhances/resolveColorEnhance';
3
- import { CommonTrendProps } from './Trend';
1
+ import { type CommonTrendProps } from './Trend';
4
2
  type BarItem = {
5
3
  /**
6
4
  * Value
@@ -17,10 +15,6 @@ export type TrendBarProps = CommonTrendProps & {
17
15
  */
18
16
  data: BarItem[];
19
17
  };
20
- type Enhances = {
21
- resolveColor: ReturnType<typeof resolveColorEnhance>;
22
- isHistogram?: true;
23
- };
24
- export declare const TrendBar: ComponentType<TrendBarProps, {}, {}, Enhances>;
25
- export declare const TrendHistogram: ComponentType<TrendBarProps, {}, {}, Enhances>;
18
+ export declare const TrendBar: import("@semcore/core").Intergalactic.Component<"svg", TrendBarProps, {}, readonly [(props: any) => any]>;
19
+ export declare const TrendHistogram: import("@semcore/core").Intergalactic.Component<"svg", TrendBarProps, {}, readonly [(props: any) => any]>;
26
20
  export {};
@@ -1,6 +1,4 @@
1
- import { ComponentType } from '@semcore/core';
2
- import resolveColorEnhance from '@semcore/utils/lib/enhances/resolveColorEnhance';
3
- import { CommonTrendProps } from './Trend';
1
+ import { type CommonTrendProps } from './Trend';
4
2
  export type TrendLineProps = CommonTrendProps & {
5
3
  /**
6
4
  * List of values
@@ -19,11 +17,9 @@ export type TrendLineProps = CommonTrendProps & {
19
17
  */
20
18
  lastPointRadius?: number;
21
19
  };
22
- type Enhances = {
23
- uid: string;
24
- resolveColor: ReturnType<typeof resolveColorEnhance>;
25
- withArea?: true;
26
- };
27
- export declare const TrendLine: ComponentType<TrendLineProps, {}, {}, Enhances>;
28
- export declare const TrendArea: ComponentType<TrendLineProps, {}, {}, Enhances>;
29
- export {};
20
+ export declare const TrendLine: import("@semcore/core").Intergalactic.Component<"svg", TrendLineProps, {}, readonly [(props: any) => any, (props: any) => {
21
+ uid: ReturnType<typeof import("@semcore/core/lib/utils/uniqueID").useUID>;
22
+ }]>;
23
+ export declare const TrendArea: import("@semcore/core").Intergalactic.Component<"svg", TrendLineProps, {}, readonly [(props: any) => any, (props: any) => {
24
+ uid: ReturnType<typeof import("@semcore/core/lib/utils/uniqueID").useUID>;
25
+ }]>;
@@ -1,6 +1,6 @@
1
- import React from 'react';
1
+ import type { BoxProps } from '@semcore/base-components';
2
2
  import { Component } from '@semcore/core';
3
- import { BoxProps } from '@semcore/flex-box';
3
+ import React from 'react';
4
4
  export type CommonTrendProps = BoxProps & {
5
5
  /**
6
6
  * Flag to enable animate of charts
@@ -17,10 +17,10 @@ export type CommonTrendProps = BoxProps & {
17
17
  */
18
18
  data: any[];
19
19
  };
20
- export declare abstract class Trend<P extends CommonTrendProps, E extends readonly ((...args: any[]) => any)[]> extends Component<P, {}, {
20
+ export declare abstract class Trend<P extends CommonTrendProps, E extends readonly ((...args: any[]) => any)[]> extends Component<P, E, Readonly<{}>, {
21
21
  width: number;
22
22
  height: number;
23
- }, E> {
23
+ }> {
24
24
  state: {
25
25
  width: number;
26
26
  height: number;
@@ -1,3 +1,3 @@
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 };
@@ -0,0 +1,18 @@
1
+ export declare class ScoreDonutUtils {
2
+ private readonly isSemiDonut;
3
+ private readonly value;
4
+ readonly radius: number;
5
+ constructor(value: number, isSemiDonut: boolean);
6
+ get viewBox(): "0 0 24 12" | "0 0 24 24";
7
+ get strokeWidth(): 6 | 4;
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;
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": "0.30.0-prerelease.4",
4
+ "version": "0.30.0-prerelease.5",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,11 +14,11 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/flex-box": "5.42.0-prerelease.4",
18
- "@semcore/utils": "4.49.0-prerelease.4"
17
+ "@semcore/flex-box": "5.42.0-prerelease.5",
18
+ "@semcore/utils": "4.49.0-prerelease.5"
19
19
  },
20
20
  "peerDependencies": {
21
- "@semcore/core": "^2.40.0-prerelease.4",
21
+ "@semcore/core": "^2.40.0-prerelease.5",
22
22
  "react": "16.8 - 18",
23
23
  "react-dom": "16.8 - 18"
24
24
  },