@semcore/mini-chart 16.1.1-prerelease.5 → 17.0.0-prerelease.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +4 -4
  3. package/lib/cjs/component/score/Donut.js +84 -96
  4. package/lib/cjs/component/score/Donut.js.map +1 -1
  5. package/lib/cjs/component/score/Line.js +104 -108
  6. package/lib/cjs/component/score/Line.js.map +1 -1
  7. package/lib/cjs/component/score/Line.types.js.map +1 -1
  8. package/lib/cjs/component/score/index.js +3 -3
  9. package/lib/cjs/component/trend/Bar.js +83 -96
  10. package/lib/cjs/component/trend/Bar.js.map +1 -1
  11. package/lib/cjs/component/trend/Line.js +114 -135
  12. package/lib/cjs/component/trend/Line.js.map +1 -1
  13. package/lib/cjs/component/trend/Trend.js +43 -65
  14. package/lib/cjs/component/trend/Trend.js.map +1 -1
  15. package/lib/cjs/component/trend/index.js +4 -4
  16. package/lib/cjs/index.js +3 -3
  17. package/lib/cjs/index.js.map +1 -1
  18. package/lib/cjs/utils/ScoreDonutUtils.js +48 -75
  19. package/lib/cjs/utils/ScoreDonutUtils.js.map +1 -1
  20. package/lib/es6/component/score/Donut.js +80 -93
  21. package/lib/es6/component/score/Donut.js.map +1 -1
  22. package/lib/es6/component/score/Line.js +99 -103
  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/trend/Bar.js +78 -91
  26. package/lib/es6/component/trend/Bar.js.map +1 -1
  27. package/lib/es6/component/trend/Line.js +109 -130
  28. package/lib/es6/component/trend/Line.js.map +1 -1
  29. package/lib/es6/component/trend/Trend.js +41 -64
  30. package/lib/es6/component/trend/Trend.js.map +1 -1
  31. package/lib/es6/index.js +8 -8
  32. package/lib/es6/index.js.map +1 -1
  33. package/lib/es6/utils/ScoreDonutUtils.js +43 -71
  34. package/lib/es6/utils/ScoreDonutUtils.js.map +1 -1
  35. package/lib/esm/component/score/Donut.mjs +80 -79
  36. package/lib/esm/component/score/Line.mjs +100 -91
  37. package/lib/esm/component/trend/Bar.mjs +79 -82
  38. package/lib/esm/component/trend/Line.mjs +110 -116
  39. package/lib/esm/component/trend/Trend.mjs +41 -61
  40. package/lib/esm/index.mjs +1 -1
  41. package/lib/esm/utils/ScoreDonutUtils.mjs +43 -71
  42. package/lib/types/component/score/Donut.d.ts +7 -12
  43. package/lib/types/component/score/Line.types.d.ts +8 -6
  44. package/lib/types/component/trend/Bar.d.ts +2 -8
  45. package/lib/types/component/trend/Line.d.ts +6 -10
  46. package/lib/types/component/trend/Trend.d.ts +3 -3
  47. package/package.json +5 -5
@@ -1,163 +1,142 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.TrendLine = exports.TrendArea = void 0;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
13
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
9
  var _core = require("@semcore/core");
10
+ var _baseComponents = require("@semcore/base-components");
16
11
  var _ariaProps = require("@semcore/core/lib/utils/ariaProps");
17
12
  var _resolveColorEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/resolveColorEnhance"));
18
13
  var _uniqueID = _interopRequireDefault(require("@semcore/core/lib/utils/uniqueID"));
19
- var _flexBox = require("@semcore/flex-box");
20
14
  var _react = _interopRequireDefault(require("react"));
21
- var _Trend2 = require("./Trend");
15
+ var _Trend = require("./Trend");
22
16
  /*!__reshadow-styles__:"../skeleton/skeleton.shadow.css"*/
23
- var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/"@keyframes pulse_1wd8q{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_1wd8q_gg_.__loading_1wd8q_gg_,.___SLineGauge_1wd8q_gg_.__loading_1wd8q_gg_,.___STrendBar_1wd8q_gg_.__loading_1wd8q_gg_,.___STrendLine_1wd8q_gg_.__loading_1wd8q_gg_{animation-name:pulse_1wd8q;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}", /*__inner_css_end__*/"1wd8q_gg_"),
17
+ const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/"@keyframes pulse_1ydx6{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_1ydx6_gg_.__loading_1ydx6_gg_,.___SLineGauge_1ydx6_gg_.__loading_1ydx6_gg_,.___STrendBar_1ydx6_gg_.__loading_1ydx6_gg_,.___STrendLine_1ydx6_gg_.__loading_1ydx6_gg_{animation-name:pulse_1ydx6;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}", /*__inner_css_end__*/"1ydx6_gg_"),
24
18
  /*__reshadow_css_end__*/
25
19
  {
26
- "__SLineGauge": "___SLineGauge_1wd8q_gg_",
27
- "_loading": "__loading_1wd8q_gg_",
28
- "__SDonutContainer": "___SDonutContainer_1wd8q_gg_",
29
- "__STrendLine": "___STrendLine_1wd8q_gg_",
30
- "__STrendBar": "___STrendBar_1wd8q_gg_",
31
- "@pulse": "pulse_1wd8q"
20
+ "__SLineGauge": "___SLineGauge_1ydx6_gg_",
21
+ "_loading": "__loading_1ydx6_gg_",
22
+ "__SDonutContainer": "___SDonutContainer_1ydx6_gg_",
23
+ "__STrendLine": "___STrendLine_1ydx6_gg_",
24
+ "__STrendBar": "___STrendBar_1ydx6_gg_",
25
+ "@pulse": "pulse_1ydx6"
32
26
  });
33
- var TrendLineRoot = /*#__PURE__*/function (_Trend) {
34
- function TrendLineRoot() {
35
- (0, _classCallCheck2["default"])(this, TrendLineRoot);
36
- return (0, _callSuper2["default"])(this, TrendLineRoot, arguments);
27
+ class TrendLineRoot extends _Trend.Trend {
28
+ get defaultData() {
29
+ return [15, 70, 20, 85, 20];
37
30
  }
38
- (0, _inherits2["default"])(TrendLineRoot, _Trend);
39
- return (0, _createClass2["default"])(TrendLineRoot, [{
40
- key: "defaultData",
41
- get: function get() {
42
- return [15, 70, 20, 85, 20];
43
- }
44
- }, {
45
- key: "lastPointRadius",
46
- get: function get() {
47
- var _this$asProps$lastPoi;
48
- return (_this$asProps$lastPoi = this.asProps.lastPointRadius) !== null && _this$asProps$lastPoi !== void 0 ? _this$asProps$lastPoi : 6;
49
- }
50
- }, {
51
- key: "data",
52
- get: function get() {
53
- var _this$asProps = this.asProps,
54
- data = _this$asProps.data,
55
- loading = _this$asProps.loading;
56
- if (loading) {
57
- return this.defaultData;
58
- }
59
- return data;
60
- }
61
- }, {
62
- key: "svgWidth",
63
- get: function get() {
64
- return this.asProps.lastPointColor ? this.defaultWidth + this.lastPointRadius : this.defaultWidth;
31
+ get lastPointRadius() {
32
+ return this.asProps.lastPointRadius ?? 6;
33
+ }
34
+ get data() {
35
+ const {
36
+ data,
37
+ loading
38
+ } = this.asProps;
39
+ if (loading) {
40
+ return this.defaultData;
65
41
  }
66
- }, {
67
- key: "svgHeight",
68
- get: function get() {
69
- return this.asProps.lastPointColor ? this.defaultHeight + this.lastPointRadius : this.defaultHeight;
42
+ return data;
43
+ }
44
+ get svgWidth() {
45
+ return this.asProps.lastPointColor ? this.defaultWidth + this.lastPointRadius : this.defaultWidth;
46
+ }
47
+ get svgHeight() {
48
+ return this.asProps.lastPointColor ? this.defaultHeight + this.lastPointRadius : this.defaultHeight;
49
+ }
50
+ get color() {
51
+ const {
52
+ resolveColor,
53
+ color = 'chart-palette-order-1',
54
+ loading
55
+ } = this.asProps;
56
+ if (loading) {
57
+ return resolveColor('skeleton-bg');
70
58
  }
71
- }, {
72
- key: "color",
73
- get: function get() {
74
- var _this$asProps2 = this.asProps,
75
- resolveColor = _this$asProps2.resolveColor,
76
- _this$asProps2$color = _this$asProps2.color,
77
- color = _this$asProps2$color === void 0 ? 'chart-palette-order-1' : _this$asProps2$color,
78
- loading = _this$asProps2.loading;
79
- if (loading) {
80
- return resolveColor('skeleton-bg');
81
- }
82
- return resolveColor(color);
59
+ return resolveColor(color);
60
+ }
61
+ render() {
62
+ var _ref = this.asProps,
63
+ _ref2;
64
+ const STrendLine = _baseComponents.Box;
65
+ const {
66
+ uid,
67
+ withArea,
68
+ animate,
69
+ lastPointColor,
70
+ resolveColor,
71
+ loading,
72
+ styles
73
+ } = this.asProps;
74
+ const points = [];
75
+ const length = this.data.length;
76
+ const step = this.defaultWidth / (length - 1);
77
+ for (let i = 0; i < length; i++) {
78
+ points.push(`${step * i},${this.defaultHeight - this.data[i]}`);
83
79
  }
84
- }, {
85
- key: "render",
86
- value: function render() {
87
- var _ref = this.asProps,
88
- _ref2;
89
- var STrendLine = _flexBox.Box;
90
- var _this$asProps3 = this.asProps,
91
- uid = _this$asProps3.uid,
92
- withArea = _this$asProps3.withArea,
93
- animate = _this$asProps3.animate,
94
- lastPointColor = _this$asProps3.lastPointColor,
95
- resolveColor = _this$asProps3.resolveColor,
96
- loading = _this$asProps3.loading,
97
- styles = _this$asProps3.styles;
98
- var points = [];
99
- var length = this.data.length;
100
- var step = this.defaultWidth / (length - 1);
101
- for (var i = 0; i < length; i++) {
102
- points.push("".concat(step * i, ",").concat(this.defaultHeight - this.data[i]));
103
- }
104
- var _extractAriaProps = (0, _ariaProps.extractAriaProps)(this.asProps),
105
- __excludeProps = _extractAriaProps.__excludeProps,
106
- extractedAriaProps = _extractAriaProps.extractedAriaProps;
107
- return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(STrendLine, _ref2.cn("STrendLine", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
80
+ const {
81
+ __excludeProps,
82
+ extractedAriaProps
83
+ } = (0, _ariaProps.extractAriaProps)(this.asProps);
84
+ return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(STrendLine, _ref2.cn("STrendLine", {
85
+ ...(0, _core.assignProps)({
108
86
  "ref": this.containerRef,
109
- "__excludeProps": ['data'].concat((0, _toConsumableArray2["default"])(__excludeProps))
110
- }, _ref))), /*#__PURE__*/_react["default"].createElement("svg", _ref2.cn("svg", (0, _objectSpread2["default"])({
111
- "width": '100%',
112
- "height": '100%',
113
- "viewBox": "0 0 ".concat(this.svgWidth, " ").concat(this.svgHeight),
114
- "role": 'img'
115
- }, extractedAriaProps)), /*#__PURE__*/_react["default"].createElement("polyline", _ref2.cn("polyline", {
116
- "points": points.join(' '),
117
- "stroke": this.color,
118
- "strokeWidth": '4',
119
- "fill": 'none',
120
- "clipPath": "url(#".concat(uid, ")")
121
- })), withArea && /*#__PURE__*/_react["default"].createElement("polyline", _ref2.cn("polyline", {
122
- "points": "0,".concat(this.defaultHeight, " ").concat(points.join(' '), " ").concat(this.defaultWidth, ",").concat(this.defaultHeight),
123
- "fill": this.color,
124
- "fillOpacity": 0.2,
125
- "clipPath": "url(#".concat(uid, ")")
126
- })), lastPointColor && !loading && /*#__PURE__*/_react["default"].createElement("circle", _ref2.cn("circle", {
127
- "cx": step * (length - 1),
128
- "cy": this.defaultHeight - this.data[length - 1],
129
- "r": this.lastPointRadius,
130
- "fill": resolveColor(lastPointColor),
131
- "stroke": resolveColor('chart-grid-border'),
132
- "strokeWidth": 4,
133
- "clipPath": "url(#".concat(uid, ")")
134
- })), animate && !loading && /*#__PURE__*/_react["default"].createElement("clipPath", _ref2.cn("clipPath", {
135
- "id": uid
136
- }), /*#__PURE__*/_react["default"].createElement("rect", _ref2.cn("rect", {
137
- "x": '0',
138
- "y": '0',
139
- "width": '100%',
140
- "height": '100%',
141
- "fill": 'black'
142
- }), /*#__PURE__*/_react["default"].createElement("animate", _ref2.cn("animate", {
143
- "dur": '500ms',
144
- "attributeName": 'width',
145
- "values": '0;100%'
146
- }))))));
147
- }
148
- }]);
149
- }(_Trend2.Trend);
150
- (0, _defineProperty2["default"])(TrendLineRoot, "enhance", [(0, _resolveColorEnhance["default"])(), (0, _uniqueID["default"])()]);
151
- (0, _defineProperty2["default"])(TrendLineRoot, "style", style);
152
- (0, _defineProperty2["default"])(TrendLineRoot, "defaultProps", {
87
+ "__excludeProps": ['data', ...__excludeProps]
88
+ }, _ref)
89
+ }), /*#__PURE__*/_react.default.createElement("svg", _ref2.cn("svg", {
90
+ "width": '100%',
91
+ "height": '100%',
92
+ "viewBox": `0 0 ${this.svgWidth} ${this.svgHeight}`,
93
+ "role": 'img',
94
+ ...extractedAriaProps
95
+ }), /*#__PURE__*/_react.default.createElement("polyline", _ref2.cn("polyline", {
96
+ "points": points.join(' '),
97
+ "stroke": this.color,
98
+ "strokeWidth": '4',
99
+ "fill": 'none',
100
+ "clipPath": `url(#${uid})`
101
+ })), withArea && /*#__PURE__*/_react.default.createElement("polyline", _ref2.cn("polyline", {
102
+ "points": `0,${this.defaultHeight} ${points.join(' ')} ${this.defaultWidth},${this.defaultHeight}`,
103
+ "fill": this.color,
104
+ "fillOpacity": 0.2,
105
+ "clipPath": `url(#${uid})`
106
+ })), lastPointColor && !loading && /*#__PURE__*/_react.default.createElement("circle", _ref2.cn("circle", {
107
+ "cx": step * (length - 1),
108
+ "cy": this.defaultHeight - this.data[length - 1],
109
+ "r": this.lastPointRadius,
110
+ "fill": resolveColor(lastPointColor),
111
+ "stroke": resolveColor('chart-grid-border'),
112
+ "strokeWidth": 4,
113
+ "clipPath": `url(#${uid})`
114
+ })), animate && !loading && /*#__PURE__*/_react.default.createElement("clipPath", _ref2.cn("clipPath", {
115
+ "id": uid
116
+ }), /*#__PURE__*/_react.default.createElement("rect", _ref2.cn("rect", {
117
+ "x": '0',
118
+ "y": '0',
119
+ "width": '100%',
120
+ "height": '100%',
121
+ "fill": 'black'
122
+ }), /*#__PURE__*/_react.default.createElement("animate", _ref2.cn("animate", {
123
+ "dur": '500ms',
124
+ "attributeName": 'width',
125
+ "values": '0;100%'
126
+ }))))));
127
+ }
128
+ }
129
+ (0, _defineProperty2.default)(TrendLineRoot, "enhance", [(0, _resolveColorEnhance.default)(), (0, _uniqueID.default)()]);
130
+ (0, _defineProperty2.default)(TrendLineRoot, "style", style);
131
+ (0, _defineProperty2.default)(TrendLineRoot, "defaultProps", {
153
132
  animate: true
154
133
  });
155
- var TrendLine = exports.TrendLine = (0, _core.createComponent)(TrendLineRoot);
134
+ const TrendLine = exports.TrendLine = (0, _core.createComponent)(TrendLineRoot);
156
135
  TrendLine.displayName = 'MiniChart.TrendLine';
157
- var TrendArea = exports.TrendArea = (0, _core.createComponent)(TrendLineRoot, {}, {
158
- enhancements: [function () {
136
+ const TrendArea = exports.TrendArea = (0, _core.createComponent)(TrendLineRoot, {}, {
137
+ enhancements: [() => {
159
138
  return {
160
- wrapperProps: function wrapperProps(props) {
139
+ wrapperProps: props => {
161
140
  return (0, _core.assignProps)(props, {
162
141
  withArea: true
163
142
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Line.js","names":["_core","require","_ariaProps","_resolveColorEnhance","_interopRequireDefault","_uniqueID","_flexBox","_react","_Trend2","style","sstyled","insert","TrendLineRoot","_Trend","_classCallCheck2","_callSuper2","arguments","_inherits2","_createClass2","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","Box","_this$asProps3","uid","withArea","animate","styles","points","length","step","i","push","concat","_extractAriaProps","extractAriaProps","__excludeProps","extractedAriaProps","createElement","cn","_objectSpread2","assignProps","containerRef","_toConsumableArray2","svgWidth","svgHeight","join","Trend","_defineProperty2","resolveColorEnhance","uniqueIDEnhancement","TrendLine","exports","createComponent","displayName","TrendArea","enhancements","wrapperProps","props"],"sources":["../../../../src/component/trend/Line.tsx"],"sourcesContent":["import { createComponent, type ComponentType, 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 { Box } from '@semcore/flex-box';\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\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.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MAAQ,EAAE,CACxD,CACE,CAET,CACK,CAAC;IAEjB;EAAC;AAAA,EA9GyBQ,aAAK;AAAA,IAAAC,gBAAA,aAA3BtD,aAAa,aACA,CAAC,IAAAuD,+BAAmB,EAAC,CAAC,EAAE,IAAAC,oBAAmB,EAAC,CAAC,CAAC;AAAA,IAAAF,gBAAA,aAD3DtD,aAAa,WAGFH,KAAK;AAAA,IAAAyD,gBAAA,aAHhBtD,aAAa,kBAKK;EACpBgC,OAAO,EAAE;AACX,CAAC;AA0GI,IAAMyB,SAA0D,GAAAC,OAAA,CAAAD,SAAA,GACrE,IAAAE,qBAAe,EAAC3D,aAAa,CAAC;AAEhCyD,SAAS,CAACG,WAAW,GAAG,qBAAqB;AAEtC,IAAMC,SAA0D,GAAAH,OAAA,CAAAG,SAAA,GAAG,IAAAF,qBAAe,EACvF3D,aAAa,EACb,CAAC,CAAC,EACF;EACE8D,YAAY,EAAE,CACZ,YAAM;IACJ,OAAO;MACLC,YAAY,EAAE,SAAdA,YAAYA,CAAGC,KAAqB,EAAK;QACvC,OAAO,IAAAjB,iBAAW,EAACiB,KAAK,EAAE;UAAEjC,QAAQ,EAAE;QAAK,CAAC,CAAC;MAC/C;IACF,CAAC;EACH,CAAC;AAEL,CACF,CAAC;AAED8B,SAAS,CAACD,WAAW,GAAG,qBAAqB","ignoreList":[]}
1
+ {"version":3,"file":"Line.js","names":["_core","require","_baseComponents","_ariaProps","_resolveColorEnhance","_interopRequireDefault","_uniqueID","_react","_Trend","style","sstyled","insert","TrendLineRoot","Trend","defaultData","lastPointRadius","asProps","data","loading","svgWidth","lastPointColor","defaultWidth","svgHeight","defaultHeight","color","resolveColor","render","_ref","_ref2","STrendLine","Box","uid","withArea","animate","styles","points","length","step","i","push","__excludeProps","extractedAriaProps","extractAriaProps","default","createElement","cn","assignProps","containerRef","join","_defineProperty2","resolveColorEnhance","uniqueIDEnhancement","TrendLine","exports","createComponent","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":";;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AADA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAD,sBAAA,C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AA,CAAAoC,OAAA,CAAAC,aAAA,YAAAhB,KAAA,CAAAiB,EAAA;MAAA,OAAa,OAAO;MAAA,iBAAe,OAAO;MAAA,UAAQ;IAAQ,EAAE,CACxD,CACE,CAET,CACK,CAAC;EAEjB;AACF;AAAC,IAAAI,gBAAA,CAAAN,OAAA,EA/GK/B,aAAa,aACA,CAAC,IAAAsC,4BAAmB,EAAC,CAAC,EAAE,IAAAC,iBAAmB,EAAC,CAAC,CAAC;AAAA,IAAAF,gBAAA,CAAAN,OAAA,EAD3D/B,aAAa,WAGFH,KAAK;AAAA,IAAAwC,gBAAA,CAAAN,OAAA,EAHhB/B,aAAa,kBAKK;EACpBqB,OAAO,EAAE;AACX,CAAC;AA0GI,MAAMmB,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAAE,qBAAe,EAA0D1C,aAAa,CAAC;AAEhHwC,SAAS,CAACG,WAAW,GAAG,qBAAqB;AAEtC,MAAMC,SAAS,GAAAH,OAAA,CAAAG,SAAA,GAAG,IAAAF,qBAAe,EACtC1C,aAAa,EACb,CAAC,CAAC,EACF;EACE6C,YAAY,EAAE,CACZ,MAAM;IACJ,OAAO;MACLC,YAAY,EAAGC,KAAqB,IAAK;QACvC,OAAO,IAAAb,iBAAW,EAACa,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,83 +1,61 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.Trend = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
9
  var _core = require("@semcore/core");
14
10
  var _react = _interopRequireDefault(require("react"));
15
- var Trend = exports.Trend = /*#__PURE__*/function (_Component) {
16
- function Trend() {
17
- var _this;
18
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
19
- args[_key] = arguments[_key];
20
- }
21
- (0, _classCallCheck2["default"])(this, Trend);
22
- _this = (0, _callSuper2["default"])(this, Trend, [].concat(args));
23
- (0, _defineProperty2["default"])(_this, "state", {
11
+ class Trend extends _core.Component {
12
+ constructor(...args) {
13
+ super(...args);
14
+ (0, _defineProperty2.default)(this, "state", {
24
15
  width: 200,
25
16
  height: 100
26
17
  });
27
- (0, _defineProperty2["default"])(_this, "containerRef", /*#__PURE__*/_react["default"].createRef());
28
- return _this;
18
+ (0, _defineProperty2.default)(this, "containerRef", /*#__PURE__*/_react.default.createRef());
19
+ }
20
+ componentDidMount() {
21
+ this.setSizes();
29
22
  }
30
- (0, _inherits2["default"])(Trend, _Component);
31
- return (0, _createClass2["default"])(Trend, [{
32
- key: "componentDidMount",
33
- value: function componentDidMount() {
23
+ componentDidUpdate(prevProps) {
24
+ if (prevProps.w !== this.props.w || prevProps.h !== this.props.h || prevProps.data !== this.props.data) {
34
25
  this.setSizes();
35
26
  }
36
- }, {
37
- key: "componentDidUpdate",
38
- value: function componentDidUpdate(prevProps) {
39
- if (prevProps.w !== this.props.w || prevProps.h !== this.props.h || prevProps.data !== this.props.data) {
40
- this.setSizes();
41
- }
42
- }
43
- }, {
44
- key: "defaultWidth",
45
- get: function get() {
46
- var _this$state = this.state,
47
- width = _this$state.width,
48
- height = _this$state.height;
49
- return width / height * this.defaultHeight;
50
- }
51
- }, {
52
- key: "defaultHeight",
53
- get: function get() {
54
- return 100;
55
- }
56
- }, {
57
- key: "svgWidth",
58
- get: function get() {
59
- return this.defaultWidth;
60
- }
61
- }, {
62
- key: "svgHeight",
63
- get: function get() {
64
- return this.defaultHeight;
65
- }
66
- }, {
67
- key: "setSizes",
68
- value: function setSizes() {
69
- if (this.containerRef.current) {
70
- var boundingClientRect = this.containerRef.current.getBoundingClientRect();
71
- var width = boundingClientRect.width,
72
- height = boundingClientRect.height;
73
- if (width > 0 && height > 0) {
74
- this.setState({
75
- width: width,
76
- height: height
77
- });
78
- }
27
+ }
28
+ get defaultWidth() {
29
+ const {
30
+ width,
31
+ height
32
+ } = this.state;
33
+ return width / height * this.defaultHeight;
34
+ }
35
+ get defaultHeight() {
36
+ return 100;
37
+ }
38
+ get svgWidth() {
39
+ return this.defaultWidth;
40
+ }
41
+ get svgHeight() {
42
+ return this.defaultHeight;
43
+ }
44
+ setSizes() {
45
+ if (this.containerRef.current) {
46
+ const boundingClientRect = this.containerRef.current.getBoundingClientRect();
47
+ const {
48
+ width,
49
+ height
50
+ } = boundingClientRect;
51
+ if (width > 0 && height > 0) {
52
+ this.setState({
53
+ width,
54
+ height
55
+ });
79
56
  }
80
57
  }
81
- }]);
82
- }(_core.Component);
58
+ }
59
+ }
60
+ exports.Trend = Trend;
83
61
  //# sourceMappingURL=Trend.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Trend.js","names":["_core","require","_react","_interopRequireDefault","Trend","exports","_Component","_this","_len","arguments","length","args","Array","_key","_classCallCheck2","_callSuper2","concat","_defineProperty2","width","height","React","createRef","_inherits2","_createClass2","key","value","componentDidMount","setSizes","componentDidUpdate","prevProps","w","props","h","data","get","_this$state","state","defaultHeight","defaultWidth","containerRef","current","boundingClientRect","getBoundingClientRect","setState","Component"],"sources":["../../../../src/component/trend/Trend.tsx"],"sourcesContent":["import { Component } from '@semcore/core';\nimport type { BoxProps } from '@semcore/flex-box';\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, {}, { 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\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,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA0B,IAqBJG,KAAK,GAAAC,OAAA,CAAAD,KAAA,0BAAAE,UAAA;EAAA,SAAAF,MAAA;IAAA,IAAAG,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;IAAA,IAAAC,gBAAA,mBAAAV,KAAA;IAAAG,KAAA,OAAAQ,WAAA,mBAAAX,KAAA,KAAAY,MAAA,CAAAL,IAAA;IAAA,IAAAM,gBAAA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AAA,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,IAAQxB,KAAK,GAAauB,kBAAkB,CAApCvB,KAAK;UAAEC,MAAM,GAAKsB,kBAAkB,CAA7BtB,MAAM;QAErB,IAAID,KAAK,GAAG,CAAC,IAAIC,MAAM,GAAG,CAAC,EAAE;UAC3B,IAAI,CAACwB,QAAQ,CAAC;YAAEzB,KAAK,EAALA,KAAK;YAAEC,MAAM,EAANA;UAAO,CAAC,CAAC;QAClC;MACF;IACF;EAAC;AAAA,EAlDOyB,eAAS","ignoreList":[]}
1
+ {"version":3,"file":"Trend.js","names":["_core","require","_react","_interopRequireDefault","Trend","Component","constructor","args","_defineProperty2","default","width","height","React","createRef","componentDidMount","setSizes","componentDidUpdate","prevProps","w","props","h","data","defaultWidth","state","defaultHeight","svgWidth","svgHeight","containerRef","current","boundingClientRect","getBoundingClientRect","setState","exports"],"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,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAqBO,MAAeG,KAAK,SAGjBC,eAAS,CAAwD;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,iBACjE;MACNC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE;IACV,CAAC;IAAA,IAAAH,gBAAA,CAAAC,OAAA,qCAEcG,cAAK,CAACC,SAAS,CAAiB,CAAC;EAAA;EAEhDC,iBAAiBA,CAAA,EAAG;IAClB,IAAI,CAACC,QAAQ,CAAC,CAAC;EACjB;EAEAC,kBAAkBA,CAACC,SAAY,EAAE;IAC/B,IACEA,SAAS,CAACC,CAAC,KAAK,IAAI,CAACC,KAAK,CAACD,CAAC,IAC5BD,SAAS,CAACG,CAAC,KAAK,IAAI,CAACD,KAAK,CAACC,CAAC,IAC5BH,SAAS,CAACI,IAAI,KAAK,IAAI,CAACF,KAAK,CAACE,IAAI,EAClC;MACA,IAAI,CAACN,QAAQ,CAAC,CAAC;IACjB;EACF;EAEA,IAAIO,YAAYA,CAAA,EAAW;IACzB,MAAM;MAAEZ,KAAK;MAAEC;IAAO,CAAC,GAAG,IAAI,CAACY,KAAK;IAEpC,OAAQb,KAAK,GAAGC,MAAM,GAAI,IAAI,CAACa,aAAa;EAC9C;EAEA,IAAIA,aAAaA,CAAA,EAAW;IAC1B,OAAO,GAAG;EACZ;EAEA,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACH,YAAY;EAC1B;EAEA,IAAII,SAASA,CAAA,EAAW;IACtB,OAAO,IAAI,CAACF,aAAa;EAC3B;EAEAT,QAAQA,CAAA,EAAG;IACT,IAAI,IAAI,CAACY,YAAY,CAACC,OAAO,EAAE;MAC7B,MAAMC,kBAAkB,GAAG,IAAI,CAACF,YAAY,CAACC,OAAO,CAACE,qBAAqB,CAAC,CAAC;MAE5E,MAAM;QAAEpB,KAAK;QAAEC;MAAO,CAAC,GAAGkB,kBAAkB;MAE5C,IAAInB,KAAK,GAAG,CAAC,IAAIC,MAAM,GAAG,CAAC,EAAE;QAC3B,IAAI,CAACoB,QAAQ,CAAC;UAAErB,KAAK;UAAEC;QAAO,CAAC,CAAC;MAClC;IACF;EACF;AACF;AAACqB,OAAA,CAAA5B,KAAA,GAAAA,KAAA","ignoreList":[]}
@@ -5,25 +5,25 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "TrendArea", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _Line.TrendArea;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "TrendBar", {
13
13
  enumerable: true,
14
- get: function get() {
14
+ get: function () {
15
15
  return _Bar.TrendBar;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "TrendHistogram", {
19
19
  enumerable: true,
20
- get: function get() {
20
+ get: function () {
21
21
  return _Bar.TrendHistogram;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "TrendLine", {
25
25
  enumerable: true,
26
- get: function get() {
26
+ get: function () {
27
27
  return _Line.TrendLine;
28
28
  }
29
29
  });
package/lib/cjs/index.js CHANGED
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports.default = void 0;
7
7
  var _score = require("./component/score");
8
8
  var _trend = require("./component/trend");
9
- var miniCharts = {
9
+ const miniCharts = {
10
10
  TrendLine: _trend.TrendLine,
11
11
  TrendArea: _trend.TrendArea,
12
12
  TrendBar: _trend.TrendBar,
@@ -15,5 +15,5 @@ var miniCharts = {
15
15
  ScoreDonut: _score.ScoreDonut,
16
16
  ScoreLine: _score.ScoreLine
17
17
  };
18
- var _default = exports["default"] = miniCharts;
18
+ var _default = exports.default = miniCharts;
19
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_score","require","_trend","miniCharts","TrendLine","TrendArea","TrendBar","TrendHistogram","ScoreSemiDonut","ScoreDonut","ScoreLine","_default","exports"],"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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAME,UAQL,GAAG;EACFC,SAAS,EAATA,gBAAS;EACTC,SAAS,EAATA,gBAAS;EACTC,QAAQ,EAARA,eAAQ;EACRC,cAAc,EAAdA,qBAAc;EACdC,cAAc,EAAdA,qBAAc;EACdC,UAAU,EAAVA,iBAAU;EACVC,SAAS,EAATA;AACF,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEaT,UAAU","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_score","require","_trend","miniCharts","TrendLine","TrendArea","TrendBar","TrendHistogram","ScoreSemiDonut","ScoreDonut","ScoreLine","_default","exports","default"],"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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,MAAME,UAQL,GAAG;EACFC,SAAS,EAATA,gBAAS;EACTC,SAAS,EAATA,gBAAS;EACTC,QAAQ,EAARA,eAAQ;EACRC,cAAc,EAAdA,qBAAc;EACdC,cAAc,EAAdA,qBAAc;EACdC,UAAU,EAAVA,iBAAU;EACVC,SAAS,EAATA;AACF,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaV,UAAU","ignoreList":[]}