@semcore/d3-chart 3.18.1 → 3.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +1 -1
- package/lib/cjs/Area.js +9 -9
- package/lib/cjs/Axis.js +14 -14
- package/lib/cjs/Bar.js +8 -8
- package/lib/cjs/Bubble.js +10 -10
- package/lib/cjs/Donut.js +7 -7
- package/lib/cjs/Dots.js +10 -10
- package/lib/cjs/HorizontalBar.js +8 -8
- package/lib/cjs/Hover.js +3 -3
- package/lib/cjs/Line.js +13 -11
- package/lib/cjs/Line.js.map +1 -1
- package/lib/cjs/Plot.js +3 -3
- package/lib/cjs/Radar.js +17 -17
- package/lib/cjs/RadialTree.js +10 -10
- package/lib/cjs/ReferenceLine.js +9 -9
- package/lib/cjs/ScatterPlot.js +8 -8
- package/lib/cjs/ScatterPlot.js.map +1 -1
- package/lib/cjs/Tooltip.js +8 -8
- package/lib/cjs/Venn.js +7 -7
- package/lib/cjs/a11y/PlotA11yModule.js +2 -2
- package/lib/cjs/a11y/PlotA11yView.js +2 -2
- package/lib/cjs/component/Chart/AbstractChart.js +420 -0
- package/lib/cjs/component/Chart/AbstractChart.js.map +1 -0
- package/lib/cjs/component/Chart/AbstractChart.type.js +2 -0
- package/lib/cjs/component/Chart/AbstractChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/AreaChart.js +160 -0
- package/lib/cjs/component/Chart/AreaChart.js.map +1 -0
- package/lib/cjs/component/Chart/AreaChart.type.js +2 -0
- package/lib/cjs/component/Chart/AreaChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/BarChart.js +253 -0
- package/lib/cjs/component/Chart/BarChart.js.map +1 -0
- package/lib/cjs/component/Chart/BarChart.type.js +2 -0
- package/lib/cjs/component/Chart/BarChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/BubbleChart.js +145 -0
- package/lib/cjs/component/Chart/BubbleChart.js.map +1 -0
- package/lib/cjs/component/Chart/BubbleChart.type.js +2 -0
- package/lib/cjs/component/Chart/BubbleChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/DonutChart.js +117 -0
- package/lib/cjs/component/Chart/DonutChart.js.map +1 -0
- package/lib/cjs/component/Chart/DonutChart.type.js +2 -0
- package/lib/cjs/component/Chart/DonutChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/HistogramChart.js +189 -0
- package/lib/cjs/component/Chart/HistogramChart.js.map +1 -0
- package/lib/cjs/component/Chart/HistogramChart.type.js +2 -0
- package/lib/cjs/component/Chart/HistogramChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/LineChart.js +147 -0
- package/lib/cjs/component/Chart/LineChart.js.map +1 -0
- package/lib/cjs/component/Chart/LineChart.type.js +2 -0
- package/lib/cjs/component/Chart/LineChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/RadarChart.js +121 -0
- package/lib/cjs/component/Chart/RadarChart.js.map +1 -0
- package/lib/cjs/component/Chart/RadarChart.type.js +2 -0
- package/lib/cjs/component/Chart/RadarChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/ScatterPlotChart.js +159 -0
- package/lib/cjs/component/Chart/ScatterPlotChart.js.map +1 -0
- package/lib/cjs/component/Chart/ScatterPlotChart.type.js +2 -0
- package/lib/cjs/component/Chart/ScatterPlotChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/VennChart.js +144 -0
- package/lib/cjs/component/Chart/VennChart.js.map +1 -0
- package/lib/cjs/component/Chart/VennChart.type.js +2 -0
- package/lib/cjs/component/Chart/VennChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/index.js +28 -0
- package/lib/cjs/component/Chart/index.js.map +1 -0
- package/lib/cjs/component/ChartLegend/BaseLegend.type.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js +20 -17
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js +6 -7
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendTable/legend-table.shadow.css +5 -2
- package/lib/cjs/index.js +7 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/donut.shadow.css +3 -0
- package/lib/cjs/types/Line.d.js.map +1 -1
- package/lib/cjs/types/index.d.js +130 -1
- package/lib/cjs/types/index.d.js.map +1 -1
- package/lib/es6/Area.js +9 -9
- package/lib/es6/Axis.js +14 -14
- package/lib/es6/Bar.js +8 -8
- package/lib/es6/Bubble.js +10 -10
- package/lib/es6/Donut.js +7 -7
- package/lib/es6/Dots.js +10 -10
- package/lib/es6/HorizontalBar.js +8 -8
- package/lib/es6/Hover.js +3 -3
- package/lib/es6/Line.js +13 -11
- package/lib/es6/Line.js.map +1 -1
- package/lib/es6/Plot.js +3 -3
- package/lib/es6/Radar.js +17 -17
- package/lib/es6/RadialTree.js +10 -10
- package/lib/es6/ReferenceLine.js +9 -9
- package/lib/es6/ScatterPlot.js +8 -8
- package/lib/es6/ScatterPlot.js.map +1 -1
- package/lib/es6/Tooltip.js +8 -8
- package/lib/es6/Venn.js +7 -7
- package/lib/es6/a11y/PlotA11yModule.js +2 -2
- package/lib/es6/a11y/PlotA11yView.js +2 -2
- package/lib/es6/component/Chart/AbstractChart.js +412 -0
- package/lib/es6/component/Chart/AbstractChart.js.map +1 -0
- package/lib/es6/component/Chart/AbstractChart.type.js +2 -0
- package/lib/es6/component/Chart/AbstractChart.type.js.map +1 -0
- package/lib/es6/component/Chart/AreaChart.js +152 -0
- package/lib/es6/component/Chart/AreaChart.js.map +1 -0
- package/lib/es6/component/Chart/AreaChart.type.js +2 -0
- package/lib/es6/component/Chart/AreaChart.type.js.map +1 -0
- package/lib/es6/component/Chart/BarChart.js +245 -0
- package/lib/es6/component/Chart/BarChart.js.map +1 -0
- package/lib/es6/component/Chart/BarChart.type.js +2 -0
- package/lib/es6/component/Chart/BarChart.type.js.map +1 -0
- package/lib/es6/component/Chart/BubbleChart.js +137 -0
- package/lib/es6/component/Chart/BubbleChart.js.map +1 -0
- package/lib/es6/component/Chart/BubbleChart.type.js +2 -0
- package/lib/es6/component/Chart/BubbleChart.type.js.map +1 -0
- package/lib/es6/component/Chart/DonutChart.js +109 -0
- package/lib/es6/component/Chart/DonutChart.js.map +1 -0
- package/lib/es6/component/Chart/DonutChart.type.js +2 -0
- package/lib/es6/component/Chart/DonutChart.type.js.map +1 -0
- package/lib/es6/component/Chart/HistogramChart.js +181 -0
- package/lib/es6/component/Chart/HistogramChart.js.map +1 -0
- package/lib/es6/component/Chart/HistogramChart.type.js +2 -0
- package/lib/es6/component/Chart/HistogramChart.type.js.map +1 -0
- package/lib/es6/component/Chart/LineChart.js +139 -0
- package/lib/es6/component/Chart/LineChart.js.map +1 -0
- package/lib/es6/component/Chart/LineChart.type.js +2 -0
- package/lib/es6/component/Chart/LineChart.type.js.map +1 -0
- package/lib/es6/component/Chart/RadarChart.js +113 -0
- package/lib/es6/component/Chart/RadarChart.js.map +1 -0
- package/lib/es6/component/Chart/RadarChart.type.js +2 -0
- package/lib/es6/component/Chart/RadarChart.type.js.map +1 -0
- package/lib/es6/component/Chart/ScatterPlotChart.js +151 -0
- package/lib/es6/component/Chart/ScatterPlotChart.js.map +1 -0
- package/lib/es6/component/Chart/ScatterPlotChart.type.js +2 -0
- package/lib/es6/component/Chart/ScatterPlotChart.type.js.map +1 -0
- package/lib/es6/component/Chart/VennChart.js +136 -0
- package/lib/es6/component/Chart/VennChart.js.map +1 -0
- package/lib/es6/component/Chart/VennChart.type.js +2 -0
- package/lib/es6/component/Chart/VennChart.type.js.map +1 -0
- package/lib/es6/component/Chart/index.js +21 -0
- package/lib/es6/component/Chart/index.js.map +1 -0
- package/lib/es6/component/ChartLegend/BaseLegend.type.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js +20 -17
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js +6 -7
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendTable/legend-table.shadow.css +5 -2
- package/lib/es6/index.js +1 -0
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/donut.shadow.css +3 -0
- package/lib/es6/types/Line.d.js.map +1 -1
- package/lib/es6/types/index.d.js +12 -0
- package/lib/es6/types/index.d.js.map +1 -1
- package/lib/types/Line.d.ts +7 -2
- package/lib/types/component/Chart/AbstractChart.d.ts +50 -0
- package/lib/types/component/Chart/AbstractChart.type.d.ts +161 -0
- package/lib/types/component/Chart/AreaChart.d.ts +2 -0
- package/lib/types/component/Chart/AreaChart.type.d.ts +16 -0
- package/lib/types/component/Chart/BarChart.d.ts +2 -0
- package/lib/types/component/Chart/BarChart.type.d.ts +19 -0
- package/lib/types/component/Chart/BubbleChart.d.ts +2 -0
- package/lib/types/component/Chart/BubbleChart.type.d.ts +17 -0
- package/lib/types/component/Chart/DonutChart.d.ts +2 -0
- package/lib/types/component/Chart/DonutChart.type.d.ts +15 -0
- package/lib/types/component/Chart/HistogramChart.d.ts +2 -0
- package/lib/types/component/Chart/HistogramChart.type.d.ts +11 -0
- package/lib/types/component/Chart/LineChart.d.ts +2 -0
- package/lib/types/component/Chart/LineChart.type.d.ts +24 -0
- package/lib/types/component/Chart/RadarChart.d.ts +2 -0
- package/lib/types/component/Chart/RadarChart.type.d.ts +14 -0
- package/lib/types/component/Chart/ScatterPlotChart.d.ts +2 -0
- package/lib/types/component/Chart/ScatterPlotChart.type.d.ts +13 -0
- package/lib/types/component/Chart/VennChart.d.ts +2 -0
- package/lib/types/component/Chart/VennChart.type.d.ts +11 -0
- package/lib/types/component/Chart/index.d.ts +12 -0
- package/lib/types/component/ChartLegend/BaseLegend.type.d.ts +2 -2
- package/lib/types/index.d.ts +13 -0
- package/package.json +2 -2
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import createComponent from '@semcore/core';
|
|
10
|
+
import { scaleLinear, scaleTime } from 'd3-scale';
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
import { minMax, ScatterPlot } from '../..';
|
|
13
|
+
import { AbstractChart } from './AbstractChart';
|
|
14
|
+
import { Text } from '@semcore/typography';
|
|
15
|
+
var ScatterPlotChartComponent = /*#__PURE__*/function (_AbstractChart) {
|
|
16
|
+
_inherits(ScatterPlotChartComponent, _AbstractChart);
|
|
17
|
+
var _super = _createSuper(ScatterPlotChartComponent);
|
|
18
|
+
function ScatterPlotChartComponent() {
|
|
19
|
+
_classCallCheck(this, ScatterPlotChartComponent);
|
|
20
|
+
return _super.apply(this, arguments);
|
|
21
|
+
}
|
|
22
|
+
_createClass(ScatterPlotChartComponent, [{
|
|
23
|
+
key: "dataKeys",
|
|
24
|
+
get: function get() {
|
|
25
|
+
var _this$props = this.props,
|
|
26
|
+
data = _this$props.data,
|
|
27
|
+
groupKey = _this$props.groupKey,
|
|
28
|
+
valueKey = _this$props.valueKey;
|
|
29
|
+
return Object.keys(data[0]).filter(function (key) {
|
|
30
|
+
return key !== groupKey && key !== valueKey;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
key: "xScale",
|
|
35
|
+
get: function get() {
|
|
36
|
+
var _this$asProps = this.asProps,
|
|
37
|
+
xScale = _this$asProps.xScale,
|
|
38
|
+
_this$asProps$marginY = _this$asProps.marginY,
|
|
39
|
+
marginY = _this$asProps$marginY === void 0 ? 30 : _this$asProps$marginY,
|
|
40
|
+
plotWidth = _this$asProps.plotWidth,
|
|
41
|
+
data = _this$asProps.data,
|
|
42
|
+
groupKey = _this$asProps.groupKey;
|
|
43
|
+
if (xScale) {
|
|
44
|
+
return xScale;
|
|
45
|
+
}
|
|
46
|
+
var testItem = data[0][groupKey];
|
|
47
|
+
var range = [marginY, plotWidth - this.plotPadding];
|
|
48
|
+
var domain = minMax(data, groupKey);
|
|
49
|
+
if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {
|
|
50
|
+
return scaleTime([domain[0] * 0.8, domain[1] * 1.2], range);
|
|
51
|
+
}
|
|
52
|
+
return scaleLinear([domain[0] * 0.8, domain[1] * 1.2], range);
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "yScale",
|
|
56
|
+
get: function get() {
|
|
57
|
+
var _this$asProps2 = this.asProps,
|
|
58
|
+
yScale = _this$asProps2.yScale,
|
|
59
|
+
_this$asProps2$margin = _this$asProps2.marginX,
|
|
60
|
+
marginX = _this$asProps2$margin === void 0 ? 30 : _this$asProps2$margin,
|
|
61
|
+
plotHeight = _this$asProps2.plotHeight;
|
|
62
|
+
if (yScale) {
|
|
63
|
+
return yScale;
|
|
64
|
+
}
|
|
65
|
+
var flatValues = this.flatValues;
|
|
66
|
+
var max = Math.max.apply(Math, _toConsumableArray(flatValues));
|
|
67
|
+
var min = Math.min.apply(Math, _toConsumableArray(flatValues));
|
|
68
|
+
return scaleLinear().range([plotHeight - marginX, this.plotPadding]).domain([min * 0.8, max * 1.1]);
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "flatValues",
|
|
72
|
+
get: function get() {
|
|
73
|
+
var _this$asProps3 = this.asProps,
|
|
74
|
+
data = _this$asProps3.data,
|
|
75
|
+
groupKey = _this$asProps3.groupKey,
|
|
76
|
+
valueKey = _this$asProps3.valueKey;
|
|
77
|
+
var flatValues = data.reduce(function (result, item) {
|
|
78
|
+
Object.entries(item).forEach(function (_ref) {
|
|
79
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
80
|
+
key = _ref2[0],
|
|
81
|
+
value = _ref2[1];
|
|
82
|
+
if (key !== groupKey && key !== valueKey && typeof value === 'number') {
|
|
83
|
+
result.add(value);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return result;
|
|
87
|
+
}, new Set());
|
|
88
|
+
return flatValues;
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "renderChart",
|
|
92
|
+
value: function renderChart() {
|
|
93
|
+
var _this$asProps4 = this.asProps,
|
|
94
|
+
groupKey = _this$asProps4.groupKey,
|
|
95
|
+
valueKey = _this$asProps4.valueKey;
|
|
96
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
97
|
+
return dataDefinitions.map(function (item) {
|
|
98
|
+
return item.checked && /*#__PURE__*/React.createElement(ScatterPlot, {
|
|
99
|
+
x: groupKey,
|
|
100
|
+
y: item.id,
|
|
101
|
+
key: item.id,
|
|
102
|
+
color: item.color,
|
|
103
|
+
value: valueKey
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
key: "renderTooltip",
|
|
109
|
+
value: function renderTooltip() {
|
|
110
|
+
var _this = this;
|
|
111
|
+
var _this$asProps5 = this.asProps,
|
|
112
|
+
data = _this$asProps5.data,
|
|
113
|
+
groupKey = _this$asProps5.groupKey,
|
|
114
|
+
showTooltip = _this$asProps5.showTooltip;
|
|
115
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
116
|
+
if (!showTooltip) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return dataDefinitions.filter(function (item) {
|
|
120
|
+
return item.checked;
|
|
121
|
+
}).map(function (item) {
|
|
122
|
+
return /*#__PURE__*/React.createElement(ScatterPlot.Tooltip, {
|
|
123
|
+
key: item.id,
|
|
124
|
+
x: groupKey,
|
|
125
|
+
y: item.id,
|
|
126
|
+
wMin: 100
|
|
127
|
+
}, function (_ref3) {
|
|
128
|
+
var index = _ref3.index,
|
|
129
|
+
x = _ref3.x,
|
|
130
|
+
y = _ref3.y;
|
|
131
|
+
return {
|
|
132
|
+
children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ScatterPlot.Tooltip.Dot, {
|
|
133
|
+
color: item.color
|
|
134
|
+
}, "Data"), /*#__PURE__*/React.createElement(Text, {
|
|
135
|
+
tag: "div"
|
|
136
|
+
}, "X axis ", _this.tooltipValueFormatter(data[index][x])), /*#__PURE__*/React.createElement(Text, {
|
|
137
|
+
tag: "div"
|
|
138
|
+
}, "Y axis ", _this.tooltipValueFormatter(data[index][y])))
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}]);
|
|
144
|
+
return ScatterPlotChartComponent;
|
|
145
|
+
}(AbstractChart);
|
|
146
|
+
_defineProperty(ScatterPlotChartComponent, "displayName", 'Chart.ScatterPlot');
|
|
147
|
+
_defineProperty(ScatterPlotChartComponent, "defaultProps", {
|
|
148
|
+
showLegend: false
|
|
149
|
+
});
|
|
150
|
+
export var ScatterPlotChart = createComponent(ScatterPlotChartComponent);
|
|
151
|
+
//# sourceMappingURL=ScatterPlotChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScatterPlotChart.js","names":["React","createComponent","scaleLinear","scaleTime","minMax","ScatterPlot","AbstractChart","Text","ScatterPlotChartComponent","_AbstractChart","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","get","_this$props","props","data","groupKey","valueKey","Object","keys","filter","_this$asProps","asProps","xScale","_this$asProps$marginY","marginY","plotWidth","testItem","range","plotPadding","domain","Date","Number","isNaN","getMilliseconds","_this$asProps2","yScale","_this$asProps2$margin","marginX","plotHeight","flatValues","max","Math","_toConsumableArray","min","_this$asProps3","reduce","result","item","entries","forEach","_ref","_ref2","_slicedToArray","value","add","Set","renderChart","_this$asProps4","dataDefinitions","state","map","checked","createElement","x","y","id","color","renderTooltip","_this","_this$asProps5","showTooltip","Tooltip","wMin","_ref3","index","children","Fragment","Dot","tag","tooltipValueFormatter","_defineProperty","showLegend","ScatterPlotChart"],"sources":["../../../../src/component/Chart/ScatterPlotChart.tsx"],"sourcesContent":["import React from 'react';\nimport createComponent from '@semcore/core';\nimport { ScaleLinear, scaleLinear, scaleTime } from 'd3-scale';\n// @ts-ignore\nimport { minMax, ScatterPlot } from '../..';\nimport { AbstractChart } from './AbstractChart';\nimport {\n ScatterPlotChartData,\n ScatterPlotChartProps,\n ScatterPlotChartType,\n} from './ScatterPlotChart.type';\nimport { Text } from '@semcore/typography';\n\nclass ScatterPlotChartComponent extends AbstractChart<ScatterPlotChartData, ScatterPlotChartProps> {\n static displayName = 'Chart.ScatterPlot';\n static defaultProps: Partial<ScatterPlotChartProps> = {\n showLegend: false,\n };\n\n protected get dataKeys(): string[] {\n const { data, groupKey, valueKey } = this.props;\n\n return Object.keys(data[0]).filter((key) => key !== groupKey && key !== valueKey);\n }\n\n protected get xScale() {\n const { xScale, marginY = 30, plotWidth, data, groupKey } = this.asProps;\n\n if (xScale) {\n return xScale;\n }\n\n const testItem = data[0][groupKey];\n const range = [marginY, plotWidth - this.plotPadding];\n const domain = minMax(data, groupKey);\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n return scaleTime([domain[0] * 0.8, domain[1] * 1.2], range);\n }\n\n return scaleLinear([domain[0] * 0.8, domain[1] * 1.2], range);\n }\n\n protected get yScale(): ScaleLinear<any, any> {\n const { yScale, marginX = 30, plotHeight } = this.asProps;\n\n if (yScale) {\n return yScale;\n }\n\n const flatValues = this.flatValues;\n\n const max = Math.max(...flatValues);\n const min = Math.min(...flatValues);\n\n return scaleLinear()\n .range([plotHeight - marginX, this.plotPadding])\n .domain([min * 0.8, max * 1.1]);\n }\n\n protected get flatValues(): Set<number> {\n const { data, groupKey, valueKey } = this.asProps;\n\n const flatValues = data.reduce<Set<number>>((result, item) => {\n Object.entries(item).forEach(([key, value]) => {\n if (key !== groupKey && key !== valueKey && typeof value === 'number') {\n result.add(value);\n }\n });\n\n return result;\n }, new Set());\n\n return flatValues;\n }\n\n protected renderChart() {\n const { groupKey, valueKey } = this.asProps;\n const { dataDefinitions } = this.state;\n\n return dataDefinitions.map((item) => {\n return (\n item.checked && (\n <ScatterPlot x={groupKey} y={item.id} key={item.id} color={item.color} value={valueKey} />\n )\n );\n });\n }\n\n protected renderTooltip() {\n const { data, groupKey, showTooltip } = this.asProps;\n const { dataDefinitions } = this.state;\n\n if (!showTooltip) {\n return null;\n }\n\n return dataDefinitions\n .filter((item) => item.checked)\n .map((item) => {\n return (\n <ScatterPlot.Tooltip key={item.id} x={groupKey} y={item.id} wMin={100}>\n {({ index, x, y }: any) => {\n return {\n children: (\n <>\n <ScatterPlot.Tooltip.Dot color={item.color}>Data</ScatterPlot.Tooltip.Dot>\n <Text tag='div'>X axis {this.tooltipValueFormatter(data[index][x])}</Text>\n <Text tag='div'>Y axis {this.tooltipValueFormatter(data[index][y])}</Text>\n </>\n ),\n };\n }}\n </ScatterPlot.Tooltip>\n );\n });\n }\n}\n\nexport const ScatterPlotChart: ScatterPlotChartType = createComponent(ScatterPlotChartComponent);\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,MAAM,eAAe;AAC3C,SAAsBC,WAAW,EAAEC,SAAS,QAAQ,UAAU;AAC9D;AACA,SAASC,MAAM,EAAEC,WAAW,QAAQ,OAAO;AAC3C,SAASC,aAAa,QAAQ,iBAAiB;AAM/C,SAASC,IAAI,QAAQ,qBAAqB;AAAC,IAErCC,yBAAyB,0BAAAC,cAAA;EAAAC,SAAA,CAAAF,yBAAA,EAAAC,cAAA;EAAA,IAAA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CAACX,CAAC,CAAC,CAAC,CAAQ,eAC1EtE,KAAA,CAAAqE,aAAA,CAAC9D,IAAI;cAAC8E,GAAG,EAAC;YAAK,GAAC,SAAO,EAACV,KAAI,CAACW,qBAAqB,CAACjE,IAAI,CAAC4D,KAAK,CAAC,CAACV,CAAC,CAAC,CAAC,CAAQ;UAGhF,CAAC;QACH,CAAC,CACmB;MAE1B,CAAC,CAAC;IACN;EAAC;EAAA,OAAA/D,yBAAA;AAAA,EAvGqCF,aAAa;AAAAiF,eAAA,CAA/C/E,yBAAyB,iBACR,mBAAmB;AAAA+E,eAAA,CADpC/E,yBAAyB,kBAEyB;EACpDgF,UAAU,EAAE;AACd,CAAC;AAsGH,OAAO,IAAMC,gBAAsC,GAAGxF,eAAe,CAACO,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScatterPlotChart.type.js","names":[],"sources":["../../../../src/component/Chart/ScatterPlotChart.type.ts"],"sourcesContent":["import { Intergalactic } from '@semcore/core';\nimport { Flex } from '@semcore/flex-box';\nimport { interpolateValue } from '../../utils';\nimport { ScaleLinear, ScaleTime } from 'd3-scale';\nimport { BaseChartProps } from './AbstractChart.type';\n\nexport type ScatterPlotChartData = Array<Record<string, number | typeof interpolateValue | Date>>;\n\nexport type ScatterPlotChartProps = BaseChartProps<ScatterPlotChartData> & {\n groupKey: string;\n xScale?: ScaleLinear<any, any> | ScaleTime<any, any>;\n yScale?: ScaleLinear<any, any>;\n valueKey?: string;\n};\n\nexport type ScatterPlotChartType = Intergalactic.Component<typeof Flex, ScatterPlotChartProps>;\n"],"mappings":""}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
5
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import createComponent from '@semcore/core';
|
|
8
|
+
import { scaleLinear } from 'd3-scale';
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
import { Venn } from '../..';
|
|
11
|
+
import { AbstractChart } from './AbstractChart';
|
|
12
|
+
import { Text } from '@semcore/typography';
|
|
13
|
+
var VennChartComponent = /*#__PURE__*/function (_AbstractChart) {
|
|
14
|
+
_inherits(VennChartComponent, _AbstractChart);
|
|
15
|
+
var _super = _createSuper(VennChartComponent);
|
|
16
|
+
function VennChartComponent() {
|
|
17
|
+
_classCallCheck(this, VennChartComponent);
|
|
18
|
+
return _super.apply(this, arguments);
|
|
19
|
+
}
|
|
20
|
+
_createClass(VennChartComponent, [{
|
|
21
|
+
key: "xScale",
|
|
22
|
+
get: function get() {
|
|
23
|
+
var xScale = this.asProps.xScale;
|
|
24
|
+
if (xScale) {
|
|
25
|
+
return xScale;
|
|
26
|
+
}
|
|
27
|
+
return scaleLinear();
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
key: "yScale",
|
|
31
|
+
get: function get() {
|
|
32
|
+
var yScale = this.asProps.yScale;
|
|
33
|
+
if (yScale) {
|
|
34
|
+
return yScale;
|
|
35
|
+
}
|
|
36
|
+
return scaleLinear();
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "dataKeys",
|
|
40
|
+
get: function get() {
|
|
41
|
+
var _this$props = this.props,
|
|
42
|
+
data = _this$props.data,
|
|
43
|
+
groupKey = _this$props.groupKey;
|
|
44
|
+
var legendKeys = Object.keys(data).filter(function (item) {
|
|
45
|
+
var isIntersection = /\//.test(item);
|
|
46
|
+
return !isIntersection;
|
|
47
|
+
});
|
|
48
|
+
return legendKeys;
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "defaultLegendProps",
|
|
52
|
+
value: function defaultLegendProps() {
|
|
53
|
+
return {
|
|
54
|
+
legendType: 'Table'
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "renderChart",
|
|
59
|
+
value: function renderChart() {
|
|
60
|
+
var data = this.asProps.data;
|
|
61
|
+
var _this$state = this.state,
|
|
62
|
+
dataDefinitions = _this$state.dataDefinitions,
|
|
63
|
+
highlightedLine = _this$state.highlightedLine;
|
|
64
|
+
var checkedLegendItems = dataDefinitions.filter(function (item) {
|
|
65
|
+
return item.checked;
|
|
66
|
+
});
|
|
67
|
+
var checkedLegendItemsMap = checkedLegendItems.reduce(function (result, item) {
|
|
68
|
+
result[item.id] = item;
|
|
69
|
+
return result;
|
|
70
|
+
}, {});
|
|
71
|
+
var intersections = Object.keys(data).reduce(function (result, dataKey) {
|
|
72
|
+
var isIntersection = /\//.test(dataKey);
|
|
73
|
+
if (isIntersection) {
|
|
74
|
+
result.push(dataKey);
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}, []);
|
|
78
|
+
return /*#__PURE__*/React.createElement(Venn, null, checkedLegendItems.map(function (item, index) {
|
|
79
|
+
return /*#__PURE__*/React.createElement(Venn.Circle, {
|
|
80
|
+
key: item.id,
|
|
81
|
+
dataKey: item.id,
|
|
82
|
+
name: item.label,
|
|
83
|
+
color: item.color,
|
|
84
|
+
transparent: highlightedLine !== -1 && highlightedLine !== index
|
|
85
|
+
});
|
|
86
|
+
}), intersections.map(function (intersectionKey) {
|
|
87
|
+
var intersectionKeys = intersectionKey.split('/');
|
|
88
|
+
var hasDisabledItems = intersectionKeys.some(function (key) {
|
|
89
|
+
return checkedLegendItemsMap[key] === undefined;
|
|
90
|
+
});
|
|
91
|
+
if (hasDisabledItems) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
var name = intersectionKeys.map(function (id) {
|
|
95
|
+
var _dataDefinitions$find;
|
|
96
|
+
return ((_dataDefinitions$find = dataDefinitions.find(function (legendItem) {
|
|
97
|
+
return legendItem.id === id;
|
|
98
|
+
})) === null || _dataDefinitions$find === void 0 ? void 0 : _dataDefinitions$find.label) || '';
|
|
99
|
+
}).join(' & ');
|
|
100
|
+
return /*#__PURE__*/React.createElement(Venn.Intersection, {
|
|
101
|
+
key: intersectionKey,
|
|
102
|
+
dataKey: intersectionKey,
|
|
103
|
+
name: name
|
|
104
|
+
});
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
key: "renderTooltip",
|
|
109
|
+
value: function renderTooltip() {
|
|
110
|
+
var showTooltip = this.asProps.showTooltip;
|
|
111
|
+
if (!showTooltip) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
return /*#__PURE__*/React.createElement(Venn.Tooltip, null, function (_ref) {
|
|
115
|
+
var name = _ref.name,
|
|
116
|
+
dataKey = _ref.dataKey,
|
|
117
|
+
data = _ref.data;
|
|
118
|
+
return {
|
|
119
|
+
children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Venn.Tooltip.Title, null, name), /*#__PURE__*/React.createElement(Text, {
|
|
120
|
+
bold: true
|
|
121
|
+
}, data[dataKey]))
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}]);
|
|
126
|
+
return VennChartComponent;
|
|
127
|
+
}(AbstractChart);
|
|
128
|
+
_defineProperty(VennChartComponent, "displayName", 'Chart.Venn');
|
|
129
|
+
_defineProperty(VennChartComponent, "defaultProps", {
|
|
130
|
+
direction: 'row-reverse',
|
|
131
|
+
alignItems: 'flex-start',
|
|
132
|
+
marginY: 0,
|
|
133
|
+
marginX: 0
|
|
134
|
+
});
|
|
135
|
+
export var VennChart = createComponent(VennChartComponent);
|
|
136
|
+
//# sourceMappingURL=VennChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VennChart.js","names":["React","createComponent","scaleLinear","Venn","AbstractChart","Text","VennChartComponent","_AbstractChart","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","get","xScale","asProps","yScale","_this$props","props","data","groupKey","legendKeys","Object","keys","filter","item","isIntersection","test","value","defaultLegendProps","legendType","renderChart","_this$state","state","dataDefinitions","highlightedLine","checkedLegendItems","checked","checkedLegendItemsMap","reduce","result","id","intersections","dataKey","push","createElement","map","index","Circle","name","label","color","transparent","intersectionKey","intersectionKeys","split","hasDisabledItems","some","undefined","_dataDefinitions$find","find","legendItem","join","Intersection","renderTooltip","showTooltip","Tooltip","_ref","children","Fragment","Title","bold","_defineProperty","direction","alignItems","marginY","marginX","VennChart"],"sources":["../../../../src/component/Chart/VennChart.tsx"],"sourcesContent":["import React from 'react';\nimport createComponent from '@semcore/core';\nimport { BaseChartProps } from './AbstractChart.type';\nimport { scaleLinear } from 'd3-scale';\n// @ts-ignore\nimport { Venn } from '../..';\nimport { AbstractChart } from './AbstractChart';\nimport { Text } from '@semcore/typography';\nimport { VennChartData, VennChartProps, VennChartType } from './VennChart.type';\nimport { LegendItem } from '../ChartLegend/LegendItem/LegendItem.type';\n\nclass VennChartComponent extends AbstractChart<VennChartData, VennChartProps> {\n static displayName = 'Chart.Venn';\n\n static defaultProps: Partial<BaseChartProps<VennChartData>> = {\n direction: 'row-reverse',\n alignItems: 'flex-start',\n marginY: 0,\n marginX: 0,\n };\n\n get xScale() {\n const { xScale } = this.asProps;\n\n if (xScale) {\n return xScale;\n }\n\n return scaleLinear();\n }\n\n get yScale() {\n const { yScale } = this.asProps;\n\n if (yScale) {\n return yScale;\n }\n\n return scaleLinear();\n }\n\n protected get dataKeys(): string[] {\n const { data, groupKey } = this.props;\n\n const legendKeys: string[] = Object.keys(data).filter((item) => {\n const isIntersection = /\\//.test(item);\n\n return !isIntersection;\n });\n\n return legendKeys;\n }\n\n defaultLegendProps() {\n return {\n legendType: 'Table' as const,\n };\n }\n\n renderChart() {\n const { data } = this.asProps;\n const { dataDefinitions, highlightedLine } = this.state;\n\n const checkedLegendItems = dataDefinitions.filter((item) => item.checked);\n const checkedLegendItemsMap = checkedLegendItems.reduce<Record<string, LegendItem>>(\n (result, item) => {\n result[item.id] = item;\n\n return result;\n },\n {},\n );\n\n const intersections = Object.keys(data).reduce<string[]>((result, dataKey) => {\n const isIntersection = /\\//.test(dataKey);\n\n if (isIntersection) {\n result.push(dataKey);\n }\n\n return result;\n }, []);\n\n return (\n <Venn>\n {checkedLegendItems.map((item, index) => {\n return (\n <Venn.Circle\n key={item.id}\n dataKey={item.id}\n name={item.label}\n color={item.color}\n transparent={highlightedLine !== -1 && highlightedLine !== index}\n />\n );\n })}\n\n {intersections.map((intersectionKey) => {\n const intersectionKeys = intersectionKey.split('/');\n\n const hasDisabledItems = intersectionKeys.some((key) => {\n return checkedLegendItemsMap[key] === undefined;\n });\n\n if (hasDisabledItems) {\n return null;\n }\n\n const name = intersectionKeys\n .map((id) => {\n return dataDefinitions.find((legendItem) => legendItem.id === id)?.label || '';\n })\n .join(' & ');\n\n return <Venn.Intersection key={intersectionKey} dataKey={intersectionKey} name={name} />;\n })}\n </Venn>\n );\n }\n\n renderTooltip() {\n const { showTooltip } = this.asProps;\n\n if (!showTooltip) {\n return null;\n }\n\n return (\n <Venn.Tooltip>\n {({ name, dataKey, data }: any) => {\n return {\n children: (\n <>\n <Venn.Tooltip.Title>{name}</Venn.Tooltip.Title>\n <Text bold>{data[dataKey]}</Text>\n </>\n ),\n };\n }}\n </Venn.Tooltip>\n );\n }\n}\n\nexport const VennChart: VennChartType = createComponent(VennChartComponent);\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,MAAM,eAAe;AAE3C,SAASC,WAAW,QAAQ,UAAU;AACtC;AACA,SAASC,IAAI,QAAQ,OAAO;AAC5B,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,IAAI,QAAQ,qBAAqB;AAAC,IAIrCC,kBAAkB,0BAAAC,cAAA;EAAAC,SAAA,CAAAF,kBAAA,EAAAC,cAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,kBAAA;EAAA,S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AErB,IAAI,CAAsB,eAC/CpD,KAAA,CAAAgD,aAAA,CAAC3C,IAAI;YAACqE,IAAI;UAAA,GAAEpD,IAAI,CAACwB,OAAO,CAAC,CAAQ;QAGvC,CAAC;MACH,CAAC,CACY;IAEnB;EAAC;EAAA,OAAAxC,kBAAA;AAAA,EAlI8BF,aAAa;AAAAuE,eAAA,CAAxCrE,kBAAkB,iBACD,YAAY;AAAAqE,eAAA,CAD7BrE,kBAAkB,kBAGwC;EAC5DsE,SAAS,EAAE,aAAa;EACxBC,UAAU,EAAE,YAAY;EACxBC,OAAO,EAAE,CAAC;EACVC,OAAO,EAAE;AACX,CAAC;AA6HH,OAAO,IAAMC,SAAwB,GAAG/E,eAAe,CAACK,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VennChart.type.js","names":[],"sources":["../../../../src/component/Chart/VennChart.type.ts"],"sourcesContent":["import { Intergalactic } from '@semcore/core';\nimport { Flex } from '@semcore/flex-box';\nimport { ScaleLinear } from 'd3-scale';\nimport { BaseChartProps } from './AbstractChart.type';\n\nexport type VennChartData = Record<string, number>;\n\nexport type VennChartProps = BaseChartProps<VennChartData> & {\n groupKey?: never;\n xScale?: ScaleLinear<any, any>;\n yScale?: ScaleLinear<any, any>;\n};\n\nexport type VennChartType = Intergalactic.Component<typeof Flex, VennChartProps>;\n"],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LineChart } from './LineChart';
|
|
2
|
+
import { BarChart } from './BarChart';
|
|
3
|
+
import { HistogramChart } from './HistogramChart';
|
|
4
|
+
import { ScatterPlotChart } from './ScatterPlotChart';
|
|
5
|
+
import { AreaChart } from './AreaChart';
|
|
6
|
+
import { BubbleChart } from './BubbleChart';
|
|
7
|
+
import { DonutChart } from './DonutChart';
|
|
8
|
+
import { VennChart } from './VennChart';
|
|
9
|
+
import { RadarChart } from './RadarChart';
|
|
10
|
+
export default {
|
|
11
|
+
Line: LineChart,
|
|
12
|
+
Bar: BarChart,
|
|
13
|
+
Histogram: HistogramChart,
|
|
14
|
+
ScatterPlot: ScatterPlotChart,
|
|
15
|
+
Area: AreaChart,
|
|
16
|
+
Bubble: BubbleChart,
|
|
17
|
+
Donut: DonutChart,
|
|
18
|
+
Venn: VennChart,
|
|
19
|
+
Radar: RadarChart
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["LineChart","BarChart","HistogramChart","ScatterPlotChart","AreaChart","BubbleChart","DonutChart","VennChart","RadarChart","Line","Bar","Histogram","ScatterPlot","Area","Bubble","Donut","Venn","Radar"],"sources":["../../../../src/component/Chart/index.ts"],"sourcesContent":["import { LineChart } from './LineChart';\nimport { BarChart } from './BarChart';\nimport { HistogramChart } from './HistogramChart';\nimport { ScatterPlotChart } from './ScatterPlotChart';\nimport { AreaChart } from './AreaChart';\nimport { BubbleChart } from './BubbleChart';\nimport { DonutChart } from './DonutChart';\nimport { VennChart } from './VennChart';\nimport { RadarChart } from './RadarChart';\n\nexport default {\n Line: LineChart,\n Bar: BarChart,\n Histogram: HistogramChart,\n ScatterPlot: ScatterPlotChart,\n Area: AreaChart,\n Bubble: BubbleChart,\n Donut: DonutChart,\n Venn: VennChart,\n Radar: RadarChart,\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa;AACvC,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,UAAU,QAAQ,cAAc;AAEzC,eAAe;EACbC,IAAI,EAAET,SAAS;EACfU,GAAG,EAAET,QAAQ;EACbU,SAAS,EAAET,cAAc;EACzBU,WAAW,EAAET,gBAAgB;EAC7BU,IAAI,EAAET,SAAS;EACfU,MAAM,EAAET,WAAW;EACnBU,KAAK,EAAET,UAAU;EACjBU,IAAI,EAAET,SAAS;EACfU,KAAK,EAAET;AACT,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseLegend.type.js","names":[],"sources":["../../../../src/component/ChartLegend/BaseLegend.type.ts"],"sourcesContent":["import { BoxProps } from '@semcore/flex-box';\nimport { LegendItem, LegendItemKey, ShapeType } from './LegendItem/LegendItem.type';\nimport { DataStructureHints } from '../../a11y/hints';\n\nexport type LSize = 'm' | 'l';\n\nexport type BaseChartLegendProps = {\n /**\n * Size for legend items\n */\n size?: LSize;\n /**\n * Shape of data item on Legend panel\n */\n shape?: ShapeType;\n /**\n * Handler for change visible for data items. Doesn't work if Shape one of 'Circle' | 'Line' | 'Square'\n */\n onChangeVisibleItem?: (key: LegendItemKey, isVisible: boolean) => void;\n\n onMouseEnterItem?: (key: LegendItemKey, e?: React.SyntheticEvent) => void;\n\n onMouseLeaveItem?: (key: LegendItemKey, e?: React.SyntheticEvent) => void;\n\n dataHints?: DataStructureHints;\n};\n\nexport type LegendProps = BoxProps &\n BaseChartLegendProps & {\n /**\n * Legend items\n */\n items: LegendItem[];\n };\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"BaseLegend.type.js","names":[],"sources":["../../../../src/component/ChartLegend/BaseLegend.type.ts"],"sourcesContent":["import { BoxProps, FlexProps } from '@semcore/flex-box';\nimport { LegendItem, LegendItemKey, ShapeType } from './LegendItem/LegendItem.type';\nimport { DataStructureHints } from '../../a11y/hints';\n\nexport type LSize = 'm' | 'l';\n\nexport type BaseChartLegendProps = FlexProps & {\n /**\n * Size for legend items\n */\n size?: LSize;\n /**\n * Shape of data item on Legend panel\n */\n shape?: ShapeType;\n /**\n * Handler for change visible for data items. Doesn't work if Shape one of 'Circle' | 'Line' | 'Square'\n */\n onChangeVisibleItem?: (key: LegendItemKey, isVisible: boolean) => void;\n\n onMouseEnterItem?: (key: LegendItemKey, e?: React.SyntheticEvent) => void;\n\n onMouseLeaveItem?: (key: LegendItemKey, e?: React.SyntheticEvent) => void;\n\n dataHints?: DataStructureHints;\n};\n\nexport type LegendProps = BoxProps &\n BaseChartLegendProps & {\n /**\n * Legend items\n */\n items: LegendItem[];\n };\n"],"mappings":""}
|
|
@@ -10,10 +10,10 @@ import React from 'react';
|
|
|
10
10
|
import createComponent, { sstyled, Root } from '@semcore/core';
|
|
11
11
|
import { Flex } from '@semcore/flex-box';
|
|
12
12
|
/*__reshadow-styles__:"./legend-flex.shadow.css"*/
|
|
13
|
-
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".
|
|
14
|
-
"__SLegendFlex": "
|
|
15
|
-
"_direction_row": "
|
|
16
|
-
"_direction_column": "
|
|
13
|
+
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SLegendFlex_gusls_gg_._direction_row_gusls_gg_{align-items:center;flex-wrap:wrap;gap:8px 16px}.___SLegendFlex_gusls_gg_._direction_column_gusls_gg_{align-items:flex-start;flex-wrap:wrap;gap:8px}" /*__inner_css_end__*/, "gusls_gg_") /*__reshadow_css_end__*/, {
|
|
14
|
+
"__SLegendFlex": "___SLegendFlex_gusls_gg_",
|
|
15
|
+
"_direction_row": "_direction_row_gusls_gg_",
|
|
16
|
+
"_direction_column": "_direction_column_gusls_gg_"
|
|
17
17
|
});
|
|
18
18
|
import { LegendItemComponent } from '../LegendItem/LegendItem';
|
|
19
19
|
import Divider from '@semcore/divider';
|
|
@@ -19,23 +19,24 @@ import { Flex, Box } from '@semcore/flex-box';
|
|
|
19
19
|
import Checkbox from '@semcore/checkbox';
|
|
20
20
|
import { Text as TypographyText } from '@semcore/typography';
|
|
21
21
|
/*__reshadow-styles__:"./legend-item.shadow.css"*/
|
|
22
|
-
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".
|
|
23
|
-
"__SLegendItem": "
|
|
24
|
-
"_disabled": "
|
|
25
|
-
"__SPointShape": "
|
|
26
|
-
"_color": "
|
|
27
|
-
"--color": "--
|
|
28
|
-
"_shape_Circle": "
|
|
29
|
-
"_size_l": "
|
|
30
|
-
"_size_m": "
|
|
31
|
-
"_shape_Line": "
|
|
32
|
-
"_shape_Square": "
|
|
33
|
-
"__SIcon": "
|
|
34
|
-
"__SLabel": "
|
|
35
|
-
"__SAdditionalLabel": "
|
|
36
|
-
"__SCount": "
|
|
22
|
+
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SLegendItem_1dy0i_gg_{align-items:flex-start}@media (hover:hover){.___SLegendItem_1dy0i_gg_:hover{cursor:pointer}.___SLegendItem_1dy0i_gg_.__disabled_1dy0i_gg_:hover{cursor:default}}.___SPointShape_1dy0i_gg_.__color_1dy0i_gg_{background-color:var(--color_1dy0i);margin-right:8px}.___SPointShape_1dy0i_gg_._shape_Circle_1dy0i_gg_._size_l_1dy0i_gg_{width:16px;height:16px;border-radius:8px;margin-top:4px}.___SPointShape_1dy0i_gg_._shape_Circle_1dy0i_gg_._size_m_1dy0i_gg_{width:12px;height:12px;border-radius:6px;margin-top:4px}.___SPointShape_1dy0i_gg_._shape_Line_1dy0i_gg_._size_l_1dy0i_gg_{width:16px;height:4px;border-radius:3px;margin-top:9px}.___SPointShape_1dy0i_gg_._shape_Line_1dy0i_gg_._size_m_1dy0i_gg_{width:12px;height:4px;border-radius:3px;margin-top:8px}.___SPointShape_1dy0i_gg_._shape_Square_1dy0i_gg_._size_l_1dy0i_gg_{width:16px;height:16px;border-radius:2px;margin-top:4px}.___SPointShape_1dy0i_gg_._shape_Square_1dy0i_gg_._size_m_1dy0i_gg_{width:12px;height:12px;border-radius:2px;margin-top:4px}.___SIcon_1dy0i_gg_{line-height:0;margin-right:4px}.___SIcon_1dy0i_gg_._size_l_1dy0i_gg_{margin-top:4px}.___SIcon_1dy0i_gg_._size_m_1dy0i_gg_{margin-top:2px}.___SAdditionalLabel_1dy0i_gg_._size_l_1dy0i_gg_,.___SCount_1dy0i_gg_._size_l_1dy0i_gg_,.___SLabel_1dy0i_gg_._size_l_1dy0i_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%)}.___SAdditionalLabel_1dy0i_gg_._size_m_1dy0i_gg_,.___SCount_1dy0i_gg_._size_m_1dy0i_gg_,.___SLabel_1dy0i_gg_._size_m_1dy0i_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SAdditionalLabel_1dy0i_gg_,.___SCount_1dy0i_gg_{margin-left:4px}.___SAdditionalLabel_1dy0i_gg_{white-space:nowrap;display:flex;align-items:flex-start}.___SAdditionalLabel_1dy0i_gg_::before{content:\"\";display:inline-block;background-color:var(--intergalactic-text-secondary, #6c6e79);height:4px;width:4px;border-radius:2px;margin-right:4px}.___SAdditionalLabel_1dy0i_gg_._size_l_1dy0i_gg_::before{margin-top:10px}.___SAdditionalLabel_1dy0i_gg_._size_m_1dy0i_gg_::before{margin-top:8px}" /*__inner_css_end__*/, "1dy0i_gg_") /*__reshadow_css_end__*/, {
|
|
23
|
+
"__SLegendItem": "___SLegendItem_1dy0i_gg_",
|
|
24
|
+
"_disabled": "__disabled_1dy0i_gg_",
|
|
25
|
+
"__SPointShape": "___SPointShape_1dy0i_gg_",
|
|
26
|
+
"_color": "__color_1dy0i_gg_",
|
|
27
|
+
"--color": "--color_1dy0i",
|
|
28
|
+
"_shape_Circle": "_shape_Circle_1dy0i_gg_",
|
|
29
|
+
"_size_l": "_size_l_1dy0i_gg_",
|
|
30
|
+
"_size_m": "_size_m_1dy0i_gg_",
|
|
31
|
+
"_shape_Line": "_shape_Line_1dy0i_gg_",
|
|
32
|
+
"_shape_Square": "_shape_Square_1dy0i_gg_",
|
|
33
|
+
"__SIcon": "___SIcon_1dy0i_gg_",
|
|
34
|
+
"__SLabel": "___SLabel_1dy0i_gg_",
|
|
35
|
+
"__SAdditionalLabel": "___SAdditionalLabel_1dy0i_gg_",
|
|
36
|
+
"__SCount": "___SCount_1dy0i_gg_"
|
|
37
37
|
});
|
|
38
38
|
import { StaticShapes } from './LegendItem.type';
|
|
39
|
+
import resolveColorEnhance from '@semcore/utils/src/enhances/resolveColorEnhance';
|
|
39
40
|
var LegendItemRoot = /*#__PURE__*/function (_Component) {
|
|
40
41
|
_inherits(LegendItemRoot, _Component);
|
|
41
42
|
var _super = _createSuper(LegendItemRoot);
|
|
@@ -53,13 +54,14 @@ var LegendItemRoot = /*#__PURE__*/function (_Component) {
|
|
|
53
54
|
label = _this$asProps.label,
|
|
54
55
|
id = _this$asProps.id,
|
|
55
56
|
size = _this$asProps.size,
|
|
56
|
-
onClick = _this$asProps.onClick
|
|
57
|
+
onClick = _this$asProps.onClick,
|
|
58
|
+
resolveColor = _this$asProps.resolveColor;
|
|
57
59
|
return {
|
|
58
60
|
id: id,
|
|
59
61
|
label: label,
|
|
60
62
|
shape: shape,
|
|
61
63
|
checked: checked,
|
|
62
|
-
color: color,
|
|
64
|
+
color: resolveColor(color),
|
|
63
65
|
size: size,
|
|
64
66
|
onKeyUp: function onKeyUp(e) {
|
|
65
67
|
if (onClick && e.key === ' ') {
|
|
@@ -126,6 +128,7 @@ var LegendItemRoot = /*#__PURE__*/function (_Component) {
|
|
|
126
128
|
}(Component);
|
|
127
129
|
_defineProperty(LegendItemRoot, "displayName", 'LegendItem');
|
|
128
130
|
_defineProperty(LegendItemRoot, "style", style);
|
|
131
|
+
_defineProperty(LegendItemRoot, "enhance", [resolveColorEnhance()]);
|
|
129
132
|
_defineProperty(LegendItemRoot, "defaultProps", function () {
|
|
130
133
|
return {
|
|
131
134
|
children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LegendItemComponent.Shape, null), /*#__PURE__*/React.createElement(LegendItemComponent.Icon, null), /*#__PURE__*/React.createElement(LegendItemComponent.Label, null), /*#__PURE__*/React.createElement(LegendItemComponent.AdditionalLabel, null), /*#__PURE__*/React.createElement(LegendItemComponent.Count, null))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendItem.js","names":["React","createComponent","Component","sstyled","Root","Flex","Box","Checkbox","Text","TypographyText","style","_sstyled","insert","StaticShapes","LegendItemRoot","_Component","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","value","getShapeProps","_this$asProps","asProps","checked","color","shape","label","id","size","onClick","onKeyUp","e","getIconProps","props","_objectSpread","children","icon","getLabelProps","_this$asProps2","_objectWithoutProperties","_excluded","getAdditionalLabelProps","additionalInfo","concat","undefined","getCountProps","count","render","_ref","_ref7","SLegendItem","_this$asProps3","styles","Children","disabled","includes","createElement","cn","_assignProps","_defineProperty","Fragment","LegendItemComponent","Shape","Icon","Label","AdditionalLabel","Count","_ref2","arguments[0]","_ref8","SPointShape","hasChildren","theme","_assignProps2","_ref13","_ref3","_ref9","SIcon","_assignProps3","displayName","_ref14","_ref4","_ref10","SLabel","_assignProps4","_ref15","_ref5","_ref11","SAdditionalLabel","_assignProps5","_ref16","_ref6","_ref12","SCount","_assignProps6"],"sources":["../../../../../src/component/ChartLegend/LegendItem/LegendItem.tsx"],"sourcesContent":["import React, { DOMAttributes } from 'react';\nimport createComponent, { Component, sstyled, Root, IRootComponentProps } from '@semcore/core';\nimport { Flex, Box } from '@semcore/flex-box';\nimport Checkbox, { CheckboxProps } from '@semcore/checkbox';\nimport { Text as TypographyText } from '@semcore/typography';\n\nimport style from './legend-item.shadow.css';\nimport {\n ShapeProps,\n LegendItemProps,\n LegendItemType,\n LegendItem,\n StaticShapes,\n} from './LegendItem.type';\n\nclass LegendItemRoot extends Component<LegendItemProps> {\n static displayName = 'LegendItem';\n static style = style;\n\n static defaultProps = () => ({\n children: (\n <>\n <LegendItemComponent.Shape />\n <LegendItemComponent.Icon />\n <LegendItemComponent.Label />\n <LegendItemComponent.AdditionalLabel />\n <LegendItemComponent.Count />\n </>\n ),\n });\n\n getShapeProps(): ShapeProps & DOMAttributes<HTMLLabelElement> {\n const { checked, color, shape, label, id, size, onClick } = this.asProps;\n\n return {\n id,\n label,\n shape,\n checked,\n color,\n size,\n onKeyUp: (e: React.KeyboardEvent<HTMLLabelElement>) => {\n if (onClick && e.key === ' ') {\n onClick();\n }\n },\n };\n }\n\n getIconProps(): LegendItem & IRootComponentProps {\n const props = this.asProps;\n\n return {\n ...props,\n children: props.icon,\n };\n }\n\n getLabelProps(): Omit<LegendItem, 'color'> & IRootComponentProps {\n const { color, ...props } = this.asProps;\n\n return {\n ...props,\n children: props.label,\n };\n }\n\n getAdditionalLabelProps(): LegendItem & IRootComponentProps {\n const props = this.asProps;\n\n const { additionalInfo } = props;\n\n return {\n ...props,\n children: additionalInfo && 'label' in additionalInfo ? `${additionalInfo.label}` : undefined,\n };\n }\n\n getCountProps(): LegendItem & IRootComponentProps {\n const props = this.asProps;\n\n const { additionalInfo } = props;\n\n return {\n ...props,\n children:\n additionalInfo && 'count' in additionalInfo ? `(${additionalInfo.count})` : undefined,\n };\n }\n\n render() {\n const SLegendItem = Root;\n const { styles, Children, shape } = this.asProps;\n\n // @ts-ignore\n const disabled = StaticShapes.includes(shape);\n\n return sstyled(styles)(\n <SLegendItem render={Flex} disabled={disabled}>\n <Children />\n </SLegendItem>,\n );\n }\n}\n\nfunction Shape(props: IRootComponentProps & ShapeProps & DOMAttributes<HTMLLabelElement>) {\n const SPointShape = Root;\n const {\n styles,\n size,\n shape,\n checked,\n color,\n Children,\n children: hasChildren,\n onKeyUp,\n label,\n } = props;\n\n if (hasChildren) {\n return <Children />;\n }\n\n if (shape === 'Checkbox') {\n return (\n <Checkbox\n size={size}\n checked={checked}\n theme={checked ? color : undefined}\n onKeyUp={onKeyUp}\n aria-label={label}\n />\n );\n }\n\n return sstyled(styles)(\n <SPointShape render={Box}>\n <Children />\n </SPointShape>,\n );\n}\n\nfunction Icon({ styles, children: hasChildren, Children }: IRootComponentProps) {\n const SIcon = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SIcon render={Box} tag={'span'}>\n <Children />\n </SIcon>,\n );\n}\nIcon.displayName = 'Icon';\n\nfunction Label({ styles, children: hasChildren, Children }: IRootComponentProps) {\n const SLabel = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SLabel render={TypographyText} use={'primary'}>\n <Children />\n </SLabel>,\n );\n}\nLabel.displayName = 'Label';\n\nfunction AdditionalLabel({ styles, children: hasChildren, Children }: IRootComponentProps) {\n const SAdditionalLabel = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SAdditionalLabel render={TypographyText} use={'secondary'}>\n <Children />\n </SAdditionalLabel>,\n );\n}\nAdditionalLabel.displayName = 'AdditionalLabel';\n\nfunction Count({ styles, children: hasChildren, Children }: IRootComponentProps) {\n const SCount = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SCount render={TypographyText} use={'secondary'}>\n <Children />\n </SCount>,\n );\n}\nCount.displayName = 'Count';\n\nexport const LegendItemComponent: LegendItemType = createComponent(LegendItemRoot, {\n Shape,\n Icon,\n Label,\n AdditionalLabel,\n Count,\n});\n"],"mappings":";;;;;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAyB,OAAO;AAC5C,OAAOC,eAAe,IAAIC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAA6B,eAAe;AAC9F,SAASC,IAAI,EAAEC,GAAG,QAAQ,mBAAmB;AAC7C,OAAOC,QAAQ,MAAyB,mBAAmB;AAC3D,SAASC,IAAI,IAAIC,cAAc,QAAQ,qBAAqB;AAAC;AAAA,IAAAC,KAAA,+BAAAC,QAAA,CAAAC,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAG7D,SAKEC,YAAY,QACP,mBAAmB;AAAC,IAErBC,cAAc,0BAAAC,UAAA;EAAAC,SAAA,CAAAF,cAAA,EA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B,EAAA,iBAAG,CACK;AAEvB;AACAQ,eAAe,CAACc,WAAW,GAAG,iBAAiB;AAE/C,SAASb,KAAKA,CAAAwB,MAAA,EAAmE;EAAA,IAAAC,KAAA,GAAAvB,YAAA;IAAAwB,MAAA;EAAA,IAAhExC,MAAM,GAAAsC,MAAA,CAANtC,MAAM;IAAYmB,WAAW,GAAAmB,MAAA,CAArBvD,QAAQ;IAAekB,QAAQ,GAAAqC,MAAA,CAARrC,QAAQ;EACtD,IAAMwC,MAAM,GAOMzF,cAAc;EALhC,IAAI,CAACmE,WAAW,EAAE;IAChB,OAAO,IAAI;EACb;EAEA,OAAAqB,MAAA,GAAO9F,OAAO,CAACsD,MAAM,CAAC,eACpBzD,KAAA,CAAA6D,aAAA,CAACqC,MAAM,EAAAD,MAAA,CAAAnC,EAAA,WAAAvB,aAAA,KAAA4D,aAAA;IAAA,OAA8B;EAAW,GAAAH,KAAA,kBAC9ChG,KAAA,CAAA6D,aAAA,CAACH,QAAQ,EAAAuC,MAAA,CAAAnC,EAAA,iBAAG,CACL;AAEb;AACAS,KAAK,CAACa,WAAW,GAAG,OAAO;AAE3B,OAAO,IAAMlB,mBAAmC,GAAGjE,eAAe,CAACa,cAAc,EAAE;EACjFqD,KAAK,EAALA,KAAK;EACLC,IAAI,EAAJA,IAAI;EACJC,KAAK,EAALA,KAAK;EACLC,eAAe,EAAfA,eAAe;EACfC,KAAK,EAALA;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"LegendItem.js","names":["React","createComponent","Component","sstyled","Root","Flex","Box","Checkbox","Text","TypographyText","style","_sstyled","insert","StaticShapes","resolveColorEnhance","LegendItemRoot","_Component","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","value","getShapeProps","_this$asProps","asProps","checked","color","shape","label","id","size","onClick","resolveColor","onKeyUp","e","getIconProps","props","_objectSpread","children","icon","getLabelProps","_this$asProps2","_objectWithoutProperties","_excluded","getAdditionalLabelProps","additionalInfo","concat","undefined","getCountProps","count","render","_ref","_ref7","SLegendItem","_this$asProps3","styles","Children","disabled","includes","createElement","cn","_assignProps","_defineProperty","Fragment","LegendItemComponent","Shape","Icon","Label","AdditionalLabel","Count","_ref2","arguments[0]","_ref8","SPointShape","hasChildren","theme","_assignProps2","_ref13","_ref3","_ref9","SIcon","_assignProps3","displayName","_ref14","_ref4","_ref10","SLabel","_assignProps4","_ref15","_ref5","_ref11","SAdditionalLabel","_assignProps5","_ref16","_ref6","_ref12","SCount","_assignProps6"],"sources":["../../../../../src/component/ChartLegend/LegendItem/LegendItem.tsx"],"sourcesContent":["import React, { DOMAttributes } from 'react';\nimport createComponent, { Component, sstyled, Root, IRootComponentProps } from '@semcore/core';\nimport { Flex, Box } from '@semcore/flex-box';\nimport Checkbox from '@semcore/checkbox';\nimport { Text as TypographyText } from '@semcore/typography';\n\nimport style from './legend-item.shadow.css';\nimport {\n ShapeProps,\n LegendItemProps,\n LegendItemType,\n LegendItem,\n StaticShapes,\n} from './LegendItem.type';\nimport resolveColorEnhance from '@semcore/utils/src/enhances/resolveColorEnhance';\n\nclass LegendItemRoot extends Component<\n LegendItemProps & { resolveColor: ReturnType<typeof resolveColorEnhance> }\n> {\n static displayName = 'LegendItem';\n static style = style;\n\n static enhance = [resolveColorEnhance()];\n\n static defaultProps = () => ({\n children: (\n <>\n <LegendItemComponent.Shape />\n <LegendItemComponent.Icon />\n <LegendItemComponent.Label />\n <LegendItemComponent.AdditionalLabel />\n <LegendItemComponent.Count />\n </>\n ),\n });\n\n getShapeProps(): ShapeProps & DOMAttributes<HTMLLabelElement> {\n const { checked, color, shape, label, id, size, onClick, resolveColor } = this.asProps;\n\n return {\n id,\n label,\n shape,\n checked,\n color: resolveColor(color),\n size,\n onKeyUp: (e: React.KeyboardEvent<HTMLLabelElement>) => {\n if (onClick && e.key === ' ') {\n onClick();\n }\n },\n };\n }\n\n getIconProps(): LegendItem & IRootComponentProps {\n const props = this.asProps;\n\n return {\n ...props,\n children: props.icon,\n };\n }\n\n getLabelProps(): Omit<LegendItem, 'color'> & IRootComponentProps {\n const { color, ...props } = this.asProps;\n\n return {\n ...props,\n children: props.label,\n };\n }\n\n getAdditionalLabelProps(): LegendItem & IRootComponentProps {\n const props = this.asProps;\n\n const { additionalInfo } = props;\n\n return {\n ...props,\n children: additionalInfo && 'label' in additionalInfo ? `${additionalInfo.label}` : undefined,\n };\n }\n\n getCountProps(): LegendItem & IRootComponentProps {\n const props = this.asProps;\n\n const { additionalInfo } = props;\n\n return {\n ...props,\n children:\n additionalInfo && 'count' in additionalInfo ? `(${additionalInfo.count})` : undefined,\n };\n }\n\n render() {\n const SLegendItem = Root;\n const { styles, Children, shape } = this.asProps;\n\n // @ts-ignore\n const disabled = StaticShapes.includes(shape);\n\n return sstyled(styles)(\n <SLegendItem render={Flex} disabled={disabled}>\n <Children />\n </SLegendItem>,\n );\n }\n}\n\nfunction Shape(props: IRootComponentProps & ShapeProps & DOMAttributes<HTMLLabelElement>) {\n const SPointShape = Root;\n const {\n styles,\n size,\n shape,\n checked,\n color,\n Children,\n children: hasChildren,\n onKeyUp,\n label,\n } = props;\n\n if (hasChildren) {\n return <Children />;\n }\n\n if (shape === 'Checkbox') {\n return (\n <Checkbox\n size={size}\n checked={checked}\n theme={checked ? color : undefined}\n onKeyUp={onKeyUp}\n aria-label={label}\n />\n );\n }\n\n return sstyled(styles)(\n <SPointShape render={Box}>\n <Children />\n </SPointShape>,\n );\n}\n\nfunction Icon({ styles, children: hasChildren, Children }: IRootComponentProps) {\n const SIcon = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SIcon render={Box} tag={'span'}>\n <Children />\n </SIcon>,\n );\n}\nIcon.displayName = 'Icon';\n\nfunction Label({ styles, children: hasChildren, Children }: IRootComponentProps) {\n const SLabel = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SLabel render={TypographyText} use={'primary'}>\n <Children />\n </SLabel>,\n );\n}\nLabel.displayName = 'Label';\n\nfunction AdditionalLabel({ styles, children: hasChildren, Children }: IRootComponentProps) {\n const SAdditionalLabel = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SAdditionalLabel render={TypographyText} use={'secondary'}>\n <Children />\n </SAdditionalLabel>,\n );\n}\nAdditionalLabel.displayName = 'AdditionalLabel';\n\nfunction Count({ styles, children: hasChildren, Children }: IRootComponentProps) {\n const SCount = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SCount render={TypographyText} use={'secondary'}>\n <Children />\n </SCount>,\n );\n}\nCount.displayName = 'Count';\n\nexport const LegendItemComponent: LegendItemType = createComponent(LegendItemRoot, {\n Shape,\n Icon,\n Label,\n AdditionalLabel,\n Count,\n});\n"],"mappings":";;;;;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAyB,OAAO;AAC5C,OAAOC,eAAe,IAAIC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAA6B,eAAe;AAC9F,SAASC,IAAI,EAAEC,GAAG,QAAQ,mBAAmB;AAC7C,OAAOC,QAAQ,MAAM,mBAAmB;AACxC,SAASC,IAAI,IAAIC,cAAc,QAAQ,qBAAqB;AAAC;AAAA,IAAAC,KAAA,+BAAAC,QAAA,CAAAC,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAG7D,SAKEC,YAAY,QACP,mBAAmB;AAC1B,OAAOC,mBAAmB,MAAM,iDAAiD;AAAC,IAE5EC,cAAc,0BAAAC,UAAA;EAAAC,SAAA,CAAAF,cAAA,EAAAC,UAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,cAAA;EAAA,SAAAA,eAAA;IAAAK,eAAA,OAAAL,cAAA;IAAA,OAAAG,MAAA,CAAAG,KAAA,OAAAC,SAAA;EAAA;EAAAC,YAAA,CAAAR,cAAA;IAAAS,GAAA;IAAAC,KAAA,EAoBlB,SAAAC,cAA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AmE;EAAA,IAAAC,KAAA,GAAAvB,YAAA;IAAAwB,MAAA;EAAA,IAAhExC,MAAM,GAAAsC,MAAA,CAANtC,MAAM;IAAYmB,WAAW,GAAAmB,MAAA,CAArBvD,QAAQ;IAAekB,QAAQ,GAAAqC,MAAA,CAARrC,QAAQ;EACtD,IAAMwC,MAAM,GAOM3F,cAAc;EALhC,IAAI,CAACqE,WAAW,EAAE;IAChB,OAAO,IAAI;EACb;EAEA,OAAAqB,MAAA,GAAOhG,OAAO,CAACwD,MAAM,CAAC,eACpB3D,KAAA,CAAA+D,aAAA,CAACqC,MAAM,EAAAD,MAAA,CAAAnC,EAAA,WAAAvB,aAAA,KAAA4D,aAAA;IAAA,OAA8B;EAAW,GAAAH,KAAA,kBAC9ClG,KAAA,CAAA+D,aAAA,CAACH,QAAQ,EAAAuC,MAAA,CAAAnC,EAAA,iBAAG,CACL;AAEb;AACAS,KAAK,CAACa,WAAW,GAAG,OAAO;AAE3B,OAAO,IAAMlB,mBAAmC,GAAGnE,eAAe,CAACc,cAAc,EAAE;EACjFsD,KAAK,EAALA,KAAK;EACLC,IAAI,EAAJA,IAAI;EACJC,KAAK,EAALA,KAAK;EACLC,eAAe,EAAfA,eAAe;EACfC,KAAK,EAALA;AACF,CAAC,CAAC"}
|
|
@@ -11,13 +11,12 @@ import React from 'react';
|
|
|
11
11
|
import createComponent, { sstyled, Root } from '@semcore/core';
|
|
12
12
|
import { Box } from '@semcore/flex-box';
|
|
13
13
|
/*__reshadow-styles__:"./legend-table.shadow.css"*/
|
|
14
|
-
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".
|
|
15
|
-
"__SLegendTable": "
|
|
16
|
-
"_columns-count": "__columns-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"_size_m": "_size_m_9p6c1_gg_"
|
|
14
|
+
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SLegendTable_16qmu_gg_.__columns-count_16qmu_gg_{font-feature-settings:\"tnum\";font-variant-numeric:tabular-nums;display:grid;grid-template-columns:auto .2fr .2fr;align-items:center;height:-moz-fit-content;height:fit-content;grid-column-gap:16px;grid-row-gap:8px}.___SColumnItem_16qmu_gg_._size_l_16qmu_gg_{font-size:var(--intergalactic-fs-300, 16px);text-align:right}.___SColumnItem_16qmu_gg_._size_m_16qmu_gg_{font-size:var(--intergalactic-fs-200, 14px);text-align:right}" /*__inner_css_end__*/, "16qmu_gg_") /*__reshadow_css_end__*/, {
|
|
15
|
+
"__SLegendTable": "___SLegendTable_16qmu_gg_",
|
|
16
|
+
"_columns-count": "__columns-count_16qmu_gg_",
|
|
17
|
+
"__SColumnItem": "___SColumnItem_16qmu_gg_",
|
|
18
|
+
"_size_l": "_size_l_16qmu_gg_",
|
|
19
|
+
"_size_m": "_size_m_16qmu_gg_"
|
|
21
20
|
});
|
|
22
21
|
import { LegendItemComponent } from '../LegendItem/LegendItem';
|
|
23
22
|
import { BaseLegend } from '../BaseLegend';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendTable.js","names":["React","createComponent","sstyled","Root","Box","style","_sstyled","insert","LegendItemComponent","BaseLegend","LegendTableRoot","_BaseLegend","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","value","render","_ref","asProps","_ref3","_items$","SLegendTable","_this$asProps","styles","Children","_this$asProps$size","size","items","columnsCount","columns","length","createElement","cn","_objectSpread","_assignProps","map","_ref5","index","id","_ref5$columns","Fragment","item","concat","LegendTable","Column","_defineProperty","children","LegendItem","ColumnComponent","props","_ref2","arguments[0]","_ref4","SColumnItem","_assignProps2","gridColumnStart","gridColumnEnd"],"sources":["../../../../../src/component/ChartLegend/LegendTable/LegendTable.tsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { sstyled, Root, IRootComponentProps } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport { LegendTableType, LegendTableProps, LegendColumnProps } from './LegendTable.type';\nimport style from './legend-table.shadow.css';\nimport { LegendItemComponent } from '../LegendItem/LegendItem';\nimport { BaseLegend } from '../BaseLegend';\n\nclass LegendTableRoot extends BaseLegend<LegendTableProps> {\n static displayName = 'LegendTable';\n static style = style;\n\n static defaultProps = () => ({\n children: <LegendTable.LegendItem />,\n });\n\n render() {\n const SLegendTable = Root;\n const { styles, Children, size = 'm', items } = this.asProps;\n const columnsCount = items[0]?.columns.length;\n\n return sstyled(styles)(\n <SLegendTable render={Box} columns-count={columnsCount + 1}>\n {items.map(({ id, columns = [] }, index) => {\n return (\n <React.Fragment key={id}>\n <Children />\n {columns.map((item, index) => {\n return (\n <React.Fragment key={`${id}__${index}`}>\n <LegendTable.Column index={index} size={size} styles={styles}>\n {item}\n </LegendTable.Column>\n </React.Fragment>\n );\n })}\n </React.Fragment>\n );\n })}\n </SLegendTable>,\n );\n }\n}\n\nfunction ColumnComponent(props: LegendColumnProps & IRootComponentProps) {\n const SColumnItem = Root;\n const { styles, index, size, Children } = props;\n\n return sstyled(styles)(\n <SColumnItem\n style={{ gridColumnStart: `${index + 2}`, gridColumnEnd: `${index + 3}` }}\n render={Box}\n size={size}\n >\n <Children />\n </SColumnItem>,\n );\n}\n\nexport const LegendTable: LegendTableType = createComponent(LegendTableRoot, {\n LegendItem: LegendItemComponent,\n Column: ColumnComponent,\n});\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,IAAIC,OAAO,EAAEC,IAAI,QAA6B,eAAe;AACnF,SAASC,GAAG,QAAQ,mBAAmB;AAAC;AAAA,IAAAC,KAAA,+BAAAC,QAAA,CAAAC,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA;
|
|
1
|
+
{"version":3,"file":"LegendTable.js","names":["React","createComponent","sstyled","Root","Box","style","_sstyled","insert","LegendItemComponent","BaseLegend","LegendTableRoot","_BaseLegend","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","value","render","_ref","asProps","_ref3","_items$","SLegendTable","_this$asProps","styles","Children","_this$asProps$size","size","items","columnsCount","columns","length","createElement","cn","_objectSpread","_assignProps","map","_ref5","index","id","_ref5$columns","Fragment","item","concat","LegendTable","Column","_defineProperty","children","LegendItem","ColumnComponent","props","_ref2","arguments[0]","_ref4","SColumnItem","_assignProps2","gridColumnStart","gridColumnEnd"],"sources":["../../../../../src/component/ChartLegend/LegendTable/LegendTable.tsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { sstyled, Root, IRootComponentProps } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport { LegendTableType, LegendTableProps, LegendColumnProps } from './LegendTable.type';\nimport style from './legend-table.shadow.css';\nimport { LegendItemComponent } from '../LegendItem/LegendItem';\nimport { BaseLegend } from '../BaseLegend';\n\nclass LegendTableRoot extends BaseLegend<LegendTableProps> {\n static displayName = 'LegendTable';\n static style = style;\n\n static defaultProps = () => ({\n children: <LegendTable.LegendItem />,\n });\n\n render() {\n const SLegendTable = Root;\n const { styles, Children, size = 'm', items } = this.asProps;\n const columnsCount = items[0]?.columns.length;\n\n return sstyled(styles)(\n <SLegendTable render={Box} columns-count={columnsCount + 1}>\n {items.map(({ id, columns = [] }, index) => {\n return (\n <React.Fragment key={id}>\n <Children />\n {columns.map((item, index) => {\n return (\n <React.Fragment key={`${id}__${index}`}>\n <LegendTable.Column index={index} size={size} styles={styles}>\n {item}\n </LegendTable.Column>\n </React.Fragment>\n );\n })}\n </React.Fragment>\n );\n })}\n </SLegendTable>,\n );\n }\n}\n\nfunction ColumnComponent(props: LegendColumnProps & IRootComponentProps) {\n const SColumnItem = Root;\n const { styles, index, size, Children } = props;\n\n return sstyled(styles)(\n <SColumnItem\n style={{ gridColumnStart: `${index + 2}`, gridColumnEnd: `${index + 3}` }}\n render={Box}\n size={size}\n >\n <Children />\n </SColumnItem>,\n );\n}\n\nexport const LegendTable: LegendTableType = createComponent(LegendTableRoot, {\n LegendItem: LegendItemComponent,\n Column: ColumnComponent,\n});\n"],"mappings":";;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