@tsingroc/tsingroc-components 5.0.0-alpha.11 → 5.0.0-alpha.13
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/dist/components/Auth.d.ts +310 -0
- package/dist/components/Auth.js +267 -0
- package/dist/components/AutoResizedECharts.d.ts +21 -0
- package/dist/components/AutoResizedECharts.js +98 -0
- package/dist/components/Calendar.d.ts +50 -0
- package/dist/components/Calendar.js +130 -0
- package/dist/components/CircularProgress.d.ts +21 -0
- package/dist/components/CircularProgress.js +34 -0
- package/dist/components/ConnectedECharts.d.ts +31 -0
- package/dist/components/ConnectedECharts.js +100 -0
- package/dist/components/ECharts.d.ts +57 -0
- package/dist/components/ECharts.js +255 -0
- package/dist/components/Header.d.ts +67 -0
- package/dist/components/Header.js +171 -0
- package/dist/components/ImageBackground.d.ts +32 -0
- package/dist/components/ImageBackground.js +76 -0
- package/dist/components/IndicatorLight.d.ts +44 -0
- package/dist/components/IndicatorLight.js +124 -0
- package/dist/components/LeftAlignedECharts.d.ts +42 -0
- package/dist/components/LeftAlignedECharts.js +270 -0
- package/dist/components/LineChartEditor.d.ts +74 -0
- package/dist/components/LineChartEditor.js +458 -0
- package/dist/components/LineChartTable.d.ts +38 -0
- package/dist/components/LineChartTable.js +245 -0
- package/dist/components/LinkedLineChart.d.ts +45 -0
- package/dist/components/LinkedLineChart.js +159 -0
- package/dist/components/QuickDateRangePicker.d.ts +30 -0
- package/dist/components/QuickDateRangePicker.js +58 -0
- package/dist/components/SegmentedButtons.d.ts +22 -0
- package/dist/components/SegmentedButtons.js +86 -0
- package/dist/components/SelectableECharts.d.ts +22 -0
- package/dist/components/SelectableECharts.js +402 -0
- package/dist/components/Sidebar.d.ts +79 -0
- package/dist/components/Sidebar.js +178 -0
- package/dist/components/TsingrocDatePicker.d.ts +38 -0
- package/dist/components/TsingrocDatePicker.js +64 -0
- package/dist/components/TsingrocTheme.d.ts +15 -0
- package/dist/components/TsingrocTheme.js +72 -0
- package/dist/components/UserButton.d.ts +42 -0
- package/dist/components/UserButton.js +105 -0
- package/dist/components/VerticalColorLegend.d.ts +7 -0
- package/dist/components/VerticalColorLegend.js +208 -0
- package/dist/components/WeatherMap.d.ts +18 -0
- package/dist/components/WeatherMap.js +658 -0
- package/dist/deckgl/TiandituLayer.d.ts +13 -0
- package/dist/deckgl/TiandituLayer.js +44 -0
- package/dist/deckgl/WeatherData.d.ts +53 -0
- package/dist/deckgl/WeatherData.js +94 -0
- package/dist/deckgl/index.d.ts +1 -0
- package/dist/deckgl/index.js +1 -0
- package/dist/echarts/coordinateSystems/grid.d.ts +43 -0
- package/dist/echarts/coordinateSystems/grid.js +108 -0
- package/dist/echarts/coordinateSystems/index.js +2 -0
- package/dist/echarts/coordinateSystems/polar.d.ts +45 -0
- package/dist/echarts/coordinateSystems/polar.js +96 -0
- package/dist/echarts/gl-types.d.js +0 -0
- package/dist/echarts/gl.d.ts +115 -0
- package/dist/echarts/gl.js +47 -0
- package/dist/echarts/index.d.ts +46 -0
- package/dist/echarts/index.js +46 -0
- package/dist/echarts/legend.d.ts +17 -0
- package/dist/echarts/legend.js +15 -0
- package/dist/echarts/radar.d.ts +24 -0
- package/dist/echarts/radar.js +22 -0
- package/dist/echarts/series/barSeries.d.ts +23 -0
- package/dist/echarts/series/barSeries.js +18 -0
- package/dist/echarts/series/boxplotSeries.d.ts +21 -0
- package/dist/echarts/series/boxplotSeries.js +40 -0
- package/dist/echarts/series/index.js +7 -0
- package/dist/echarts/series/intervalSeries.d.ts +32 -0
- package/dist/echarts/series/intervalSeries.js +55 -0
- package/dist/echarts/series/lineSeries.d.ts +36 -0
- package/dist/echarts/series/lineSeries.js +45 -0
- package/dist/echarts/series/maxBarSeries.d.ts +18 -0
- package/dist/echarts/series/maxBarSeries.js +39 -0
- package/dist/echarts/series/pieSeries.d.ts +31 -0
- package/dist/echarts/series/pieSeries.js +47 -0
- package/dist/echarts/series/windLineSeries.d.ts +47 -0
- package/dist/echarts/series/windLineSeries.js +51 -0
- package/{src/echarts/tooltip.ts → dist/echarts/tooltip.d.ts} +1 -5
- package/dist/echarts/tooltip.js +22 -0
- package/dist/env.d.js +0 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +21 -0
- package/dist/utils/debug.d.ts +1 -0
- package/dist/utils/debug.js +25 -0
- package/dist/utils/destructureLineDataItem.d.ts +6 -0
- package/dist/utils/destructureLineDataItem.js +17 -0
- package/dist/utils/filterMap.d.ts +1 -0
- package/dist/utils/filterMap.js +11 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/math.d.ts +9 -0
- package/{src/utils/math.ts → dist/utils/math.js} +2 -2
- package/dist/utils/mock.d.ts +8 -0
- package/dist/utils/mock.js +40 -0
- package/dist/utils/normalizeIntoArray.d.ts +1 -0
- package/dist/utils/normalizeIntoArray.js +3 -0
- package/dist/utils/startOfQuarter.d.ts +2 -0
- package/dist/utils/startOfQuarter.js +4 -0
- package/dist/utils/timeAxisLabel.d.ts +5 -0
- package/dist/utils/timeAxisLabel.js +18 -0
- package/package.json +26 -14
- package/src/components/Auth.tsx +0 -623
- package/src/components/AutoResizedECharts.tsx +0 -70
- package/src/components/Calendar.tsx +0 -182
- package/src/components/CircularProgress.tsx +0 -38
- package/src/components/ConnectedECharts.tsx +0 -62
- package/src/components/ECharts.tsx +0 -206
- package/src/components/Header.tsx +0 -136
- package/src/components/ImageBackground.tsx +0 -58
- package/src/components/IndicatorLight.tsx +0 -106
- package/src/components/LeftAlignedECharts.tsx +0 -190
- package/src/components/LineChartEditor.tsx +0 -558
- package/src/components/LineChartTable.tsx +0 -286
- package/src/components/LinkedECharts.tsx +0 -51
- package/src/components/LinkedLineChart.tsx +0 -144
- package/src/components/QuickDateRangePicker.tsx +0 -84
- package/src/components/SegmentedButtons.tsx +0 -46
- package/src/components/Sidebar.tsx +0 -271
- package/src/components/StrictECharts.d.ts +0 -47
- package/src/components/StrictECharts.js +0 -1
- package/src/components/TsingrocDatePicker.tsx +0 -103
- package/src/components/TsingrocTheme.tsx +0 -48
- package/src/components/UserButton.tsx +0 -165
- package/src/components/VerticalColorLegend.tsx +0 -73
- package/src/components/WeatherMap.tsx +0 -522
- package/src/deckgl/TiandituLayer.ts +0 -56
- package/src/deckgl/WeatherData.ts +0 -157
- package/src/deckgl/index.ts +0 -4
- package/src/echarts/coordinateSystems/grid.ts +0 -143
- package/src/echarts/coordinateSystems/polar.ts +0 -148
- package/src/echarts/gl.ts +0 -159
- package/src/echarts/index.ts +0 -129
- package/src/echarts/legend.ts +0 -36
- package/src/echarts/radar.ts +0 -46
- package/src/echarts/series/barSeries.ts +0 -37
- package/src/echarts/series/boxplotSeries.ts +0 -62
- package/src/echarts/series/intervalSeries.ts +0 -70
- package/src/echarts/series/lineSeries.ts +0 -78
- package/src/echarts/series/maxBarSeries.ts +0 -55
- package/src/echarts/series/pieSeries.ts +0 -76
- package/src/echarts/series/windLineSeries.ts +0 -113
- package/src/index.ts +0 -120
- package/src/types.d.ts +0 -5
- package/src/utils/debug.ts +0 -39
- package/src/utils/mock.ts +0 -69
- package/src/utils/startOfQuarter.ts +0 -6
- /package/{src/echarts/coordinateSystems/index.ts → dist/echarts/coordinateSystems/index.d.ts} +0 -0
- /package/{src/echarts/series/index.ts → dist/echarts/series/index.d.ts} +0 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { GraphicComponent, MarkAreaComponent } from "echarts/components";
|
|
3
|
+
import * as echarts from "echarts/core";
|
|
4
|
+
import { useEffectEvent, useState } from "react";
|
|
5
|
+
import { debugAssert } from "../utils";
|
|
6
|
+
import { destructureLineDataItem } from "../utils/destructureLineDataItem";
|
|
7
|
+
import { normalizeIntoArray } from "../utils/normalizeIntoArray";
|
|
8
|
+
import "./ECharts";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const DEFAULT_SELECTED_INDICES = new Set();
|
|
11
|
+
const DEFAULT_SELECTION_BOX_STYLE = {
|
|
12
|
+
fill: "#000",
|
|
13
|
+
fillOpacity: 16 / 255,
|
|
14
|
+
stroke: "#000",
|
|
15
|
+
strokeOpacity: 176 / 255,
|
|
16
|
+
lineWidth: 1
|
|
17
|
+
};
|
|
18
|
+
const DEFAULT_MARK_AREA_STYLE = {
|
|
19
|
+
color: "#000",
|
|
20
|
+
opacity: 16 / 255
|
|
21
|
+
};
|
|
22
|
+
export const withSelectable = ECharts => function SelectableECharts(props) {
|
|
23
|
+
"use memo";
|
|
24
|
+
|
|
25
|
+
const $ = _c(31);
|
|
26
|
+
let inputMarkAreaWidth;
|
|
27
|
+
let inputOption;
|
|
28
|
+
let markArea;
|
|
29
|
+
let markAreaStyle;
|
|
30
|
+
let onInit;
|
|
31
|
+
let onSelectedIndicesChange;
|
|
32
|
+
let rest;
|
|
33
|
+
let selectionBoxStyle;
|
|
34
|
+
let seriesName;
|
|
35
|
+
let t0;
|
|
36
|
+
let t1;
|
|
37
|
+
if ($[0] !== props) {
|
|
38
|
+
({
|
|
39
|
+
option: inputOption,
|
|
40
|
+
onInit,
|
|
41
|
+
mode: t0,
|
|
42
|
+
seriesName,
|
|
43
|
+
selectedIndices: t1,
|
|
44
|
+
onSelectedIndicesChange,
|
|
45
|
+
selectionBoxStyle,
|
|
46
|
+
markArea,
|
|
47
|
+
markAreaStyle,
|
|
48
|
+
markAreaWidth: inputMarkAreaWidth,
|
|
49
|
+
...rest
|
|
50
|
+
} = props);
|
|
51
|
+
$[0] = props;
|
|
52
|
+
$[1] = inputMarkAreaWidth;
|
|
53
|
+
$[2] = inputOption;
|
|
54
|
+
$[3] = markArea;
|
|
55
|
+
$[4] = markAreaStyle;
|
|
56
|
+
$[5] = onInit;
|
|
57
|
+
$[6] = onSelectedIndicesChange;
|
|
58
|
+
$[7] = rest;
|
|
59
|
+
$[8] = selectionBoxStyle;
|
|
60
|
+
$[9] = seriesName;
|
|
61
|
+
$[10] = t0;
|
|
62
|
+
$[11] = t1;
|
|
63
|
+
} else {
|
|
64
|
+
inputMarkAreaWidth = $[1];
|
|
65
|
+
inputOption = $[2];
|
|
66
|
+
markArea = $[3];
|
|
67
|
+
markAreaStyle = $[4];
|
|
68
|
+
onInit = $[5];
|
|
69
|
+
onSelectedIndicesChange = $[6];
|
|
70
|
+
rest = $[7];
|
|
71
|
+
selectionBoxStyle = $[8];
|
|
72
|
+
seriesName = $[9];
|
|
73
|
+
t0 = $[10];
|
|
74
|
+
t1 = $[11];
|
|
75
|
+
}
|
|
76
|
+
const mode = t0 === undefined ? "add" : t0;
|
|
77
|
+
const selectedIndices = t1 === undefined ? DEFAULT_SELECTED_INDICES : t1;
|
|
78
|
+
echarts.use(GraphicComponent);
|
|
79
|
+
echarts.use(MarkAreaComponent);
|
|
80
|
+
const inputSeriesArray = normalizeIntoArray(inputOption?.series);
|
|
81
|
+
let t2;
|
|
82
|
+
if ($[12] !== seriesName) {
|
|
83
|
+
t2 = it => it.name === seriesName;
|
|
84
|
+
$[12] = seriesName;
|
|
85
|
+
$[13] = t2;
|
|
86
|
+
} else {
|
|
87
|
+
t2 = $[13];
|
|
88
|
+
}
|
|
89
|
+
const inputSeries = inputSeriesArray.find(t2);
|
|
90
|
+
if (inputSeries && inputSeries.type !== "line") {
|
|
91
|
+
throw new Error("only line series is supported");
|
|
92
|
+
}
|
|
93
|
+
const inputTooltip = normalizeIntoArray(inputOption?.tooltip);
|
|
94
|
+
let markAreaWidth = inputMarkAreaWidth;
|
|
95
|
+
if (inputSeries?.data && markArea && !markAreaWidth) {
|
|
96
|
+
markAreaWidth = Infinity;
|
|
97
|
+
const xValues = inputSeries.data.map(_temp);
|
|
98
|
+
for (let i = 1; i < xValues.length; i++) {
|
|
99
|
+
const prevX = xValues[i - 1];
|
|
100
|
+
const thisX = xValues[i];
|
|
101
|
+
if (typeof prevX === "number" && typeof thisX === "number") {
|
|
102
|
+
markAreaWidth = Math.min(markAreaWidth, thisX - prevX);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (markAreaWidth === Infinity) {
|
|
106
|
+
throw new Error("failed to automatically determine the width of mark area; please ensure the x axis value of the data points are number-typed, or provide the width manually");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const modelMatcher = inputSeries && ((inputSeries.xAxisId || inputSeries.xAxisIndex) && (inputSeries.yAxisId || inputSeries.yAxisIndex) || inputSeries.polarId || inputSeries.polarIndex) ? inputSeries : {
|
|
110
|
+
gridIndex: 0
|
|
111
|
+
};
|
|
112
|
+
const convertToPixel = (instance, t3) => {
|
|
113
|
+
const [px, py] = t3;
|
|
114
|
+
return px != null && py != null ? instance.convertToPixel(modelMatcher, [px, py]) : undefined;
|
|
115
|
+
};
|
|
116
|
+
const [mouseState, setMouseState] = useState();
|
|
117
|
+
let t4;
|
|
118
|
+
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
|
|
119
|
+
t4 = (instance_0, params) => setMouseState({
|
|
120
|
+
instance: instance_0,
|
|
121
|
+
start: [params.offsetX, params.offsetY]
|
|
122
|
+
});
|
|
123
|
+
$[14] = t4;
|
|
124
|
+
} else {
|
|
125
|
+
t4 = $[14];
|
|
126
|
+
}
|
|
127
|
+
const onMouseDown = useEffectEvent(t4);
|
|
128
|
+
let t5;
|
|
129
|
+
if ($[15] !== mouseState) {
|
|
130
|
+
t5 = params_0 => {
|
|
131
|
+
if (!mouseState) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
setMouseState({
|
|
135
|
+
...mouseState,
|
|
136
|
+
end: [params_0.offsetX, params_0.offsetY]
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
$[15] = mouseState;
|
|
140
|
+
$[16] = t5;
|
|
141
|
+
} else {
|
|
142
|
+
t5 = $[16];
|
|
143
|
+
}
|
|
144
|
+
const onMouseMove = useEffectEvent(t5);
|
|
145
|
+
const onMouseUp = useEffectEvent((instance_1, params_1) => {
|
|
146
|
+
if (!mouseState) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
let eventTriggered = false;
|
|
150
|
+
if (onSelectedIndicesChange && inputSeries?.data) {
|
|
151
|
+
if (mouseState.end) {
|
|
152
|
+
const [startX, startY] = mouseState.start;
|
|
153
|
+
const {
|
|
154
|
+
offsetX,
|
|
155
|
+
offsetY
|
|
156
|
+
} = params_1;
|
|
157
|
+
const [minX, maxX] = [startX, offsetX].sort(_temp2);
|
|
158
|
+
const [minY, maxY] = [startY, offsetY].sort(_temp3);
|
|
159
|
+
const newSelectedIndices = new Set(selectedIndices);
|
|
160
|
+
inputSeries.data.forEach((point, i_0) => {
|
|
161
|
+
const destructured = destructureLineDataItem(point, i_0);
|
|
162
|
+
if (destructured == null) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const pixelValue = convertToPixel(instance_1, destructured[0]);
|
|
166
|
+
if (pixelValue === undefined) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const [x, y] = pixelValue;
|
|
170
|
+
const selected = minX <= x && x <= maxX && minY <= y && y <= maxY;
|
|
171
|
+
if (selected) {
|
|
172
|
+
if (mode === "add") {
|
|
173
|
+
newSelectedIndices.add(i_0);
|
|
174
|
+
} else {
|
|
175
|
+
newSelectedIndices.delete(i_0);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
onSelectedIndicesChange(newSelectedIndices);
|
|
180
|
+
eventTriggered = true;
|
|
181
|
+
} else {
|
|
182
|
+
if (instance_1.containPixel(modelMatcher, mouseState.start)) {
|
|
183
|
+
let minDist = Infinity;
|
|
184
|
+
let minIdx = -1;
|
|
185
|
+
inputSeries.data.forEach((point_0, i_1) => {
|
|
186
|
+
const destructured_0 = destructureLineDataItem(point_0, i_1);
|
|
187
|
+
if (destructured_0 == null) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const pixelValue_0 = convertToPixel(instance_1, destructured_0[0]);
|
|
191
|
+
if (pixelValue_0 === undefined) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const [x_0] = pixelValue_0;
|
|
195
|
+
const dist = Math.abs(mouseState.start[0] - x_0);
|
|
196
|
+
if (dist < minDist) {
|
|
197
|
+
minDist = dist;
|
|
198
|
+
minIdx = i_1;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
if (minIdx > 0) {
|
|
202
|
+
const newSelectedIndices_0 = new Set(selectedIndices);
|
|
203
|
+
if (mode === "add") {
|
|
204
|
+
newSelectedIndices_0.add(minIdx);
|
|
205
|
+
} else {
|
|
206
|
+
newSelectedIndices_0.delete(minIdx);
|
|
207
|
+
}
|
|
208
|
+
onSelectedIndicesChange(newSelectedIndices_0);
|
|
209
|
+
eventTriggered = true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (!eventTriggered) {
|
|
215
|
+
for (let elem = params_1.target; elem; elem = elem.parent) {
|
|
216
|
+
if (elem._$handlers?.click) {
|
|
217
|
+
elem._$handlers?.click.forEach(_temp4);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
setMouseState(undefined);
|
|
222
|
+
});
|
|
223
|
+
const option = {
|
|
224
|
+
...inputOption
|
|
225
|
+
};
|
|
226
|
+
if (inputSeries) {
|
|
227
|
+
if (selectedIndices.size > 0 || mode === "add" && mouseState?.end) {
|
|
228
|
+
const series = {
|
|
229
|
+
...inputSeries,
|
|
230
|
+
showSymbol: true
|
|
231
|
+
};
|
|
232
|
+
const allSelectedIndices = new Set();
|
|
233
|
+
series.data = inputSeries.data?.map((point_1, i_2) => {
|
|
234
|
+
const destructured_1 = destructureLineDataItem(point_1, i_2);
|
|
235
|
+
if (destructured_1 == null) {
|
|
236
|
+
return point_1;
|
|
237
|
+
}
|
|
238
|
+
const [value, option_0] = destructured_1;
|
|
239
|
+
const stateSelected = selectedIndices.has(i_2);
|
|
240
|
+
let tempSelected = false;
|
|
241
|
+
if (mouseState?.end) {
|
|
242
|
+
const [minX_0, maxX_0] = [mouseState.start[0], mouseState.end[0]].sort(_temp5);
|
|
243
|
+
const [minY_0, maxY_0] = [mouseState.start[1], mouseState.end[1]].sort(_temp6);
|
|
244
|
+
const pixelValue_1 = convertToPixel(mouseState.instance, value);
|
|
245
|
+
if (pixelValue_1 !== undefined) {
|
|
246
|
+
const [x_1, y_0] = pixelValue_1;
|
|
247
|
+
tempSelected = minX_0 <= x_1 && x_1 <= maxX_0 && minY_0 <= y_0 && y_0 <= maxY_0;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (mode === "add" ? stateSelected || tempSelected : stateSelected && !tempSelected) {
|
|
251
|
+
allSelectedIndices.add(i_2);
|
|
252
|
+
return {
|
|
253
|
+
value,
|
|
254
|
+
...option_0,
|
|
255
|
+
symbol: "emptyCircle",
|
|
256
|
+
symbolSize: 6
|
|
257
|
+
};
|
|
258
|
+
} else {
|
|
259
|
+
return {
|
|
260
|
+
value,
|
|
261
|
+
symbol: "none",
|
|
262
|
+
...option_0
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
if (markArea) {
|
|
267
|
+
debugAssert(markAreaWidth !== undefined, "when markArea === true, markAreaWidth is guaranteed to be defined at the beginning of this function");
|
|
268
|
+
const markAreas = [];
|
|
269
|
+
if (inputSeries.data) {
|
|
270
|
+
for (const i_3 of allSelectedIndices) {
|
|
271
|
+
const destructured_2 = destructureLineDataItem(inputSeries.data[i_3], i_3);
|
|
272
|
+
if (destructured_2 == null) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
const [t6] = destructured_2;
|
|
276
|
+
const [xValue] = t6;
|
|
277
|
+
if (typeof xValue !== "number") {
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
markAreas.push([{
|
|
281
|
+
coord: [xValue - markAreaWidth / 2]
|
|
282
|
+
}, {
|
|
283
|
+
coord: [xValue + markAreaWidth / 2]
|
|
284
|
+
}]);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
series.markArea = {
|
|
288
|
+
itemStyle: {
|
|
289
|
+
...DEFAULT_MARK_AREA_STYLE,
|
|
290
|
+
...markAreaStyle
|
|
291
|
+
},
|
|
292
|
+
emphasis: {
|
|
293
|
+
disabled: true
|
|
294
|
+
},
|
|
295
|
+
data: markAreas
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
const seriesArray = [...inputSeriesArray];
|
|
299
|
+
seriesArray[seriesArray.indexOf(inputSeries)] = series;
|
|
300
|
+
option.series = seriesArray;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
let t6;
|
|
304
|
+
if ($[17] !== selectionBoxStyle) {
|
|
305
|
+
t6 = {
|
|
306
|
+
...DEFAULT_SELECTION_BOX_STYLE,
|
|
307
|
+
...selectionBoxStyle
|
|
308
|
+
};
|
|
309
|
+
$[17] = selectionBoxStyle;
|
|
310
|
+
$[18] = t6;
|
|
311
|
+
} else {
|
|
312
|
+
t6 = $[18];
|
|
313
|
+
}
|
|
314
|
+
let t7;
|
|
315
|
+
if ($[19] !== mouseState) {
|
|
316
|
+
t7 = mouseState?.end ? {
|
|
317
|
+
ignore: false,
|
|
318
|
+
shape: {
|
|
319
|
+
x: mouseState.start[0],
|
|
320
|
+
y: mouseState.start[1],
|
|
321
|
+
width: mouseState.end[0] - mouseState.start[0],
|
|
322
|
+
height: mouseState.end[1] - mouseState.start[1]
|
|
323
|
+
}
|
|
324
|
+
} : {
|
|
325
|
+
ignore: true
|
|
326
|
+
};
|
|
327
|
+
$[19] = mouseState;
|
|
328
|
+
$[20] = t7;
|
|
329
|
+
} else {
|
|
330
|
+
t7 = $[20];
|
|
331
|
+
}
|
|
332
|
+
let t8;
|
|
333
|
+
if ($[21] !== t6 || $[22] !== t7) {
|
|
334
|
+
t8 = {
|
|
335
|
+
id: "selectionBox",
|
|
336
|
+
type: "rect",
|
|
337
|
+
z: 1000,
|
|
338
|
+
style: t6,
|
|
339
|
+
...t7
|
|
340
|
+
};
|
|
341
|
+
$[21] = t6;
|
|
342
|
+
$[22] = t7;
|
|
343
|
+
$[23] = t8;
|
|
344
|
+
} else {
|
|
345
|
+
t8 = $[23];
|
|
346
|
+
}
|
|
347
|
+
option.graphic = [...normalizeIntoArray(option.graphic), t8];
|
|
348
|
+
if (inputTooltip.length) {
|
|
349
|
+
let t9;
|
|
350
|
+
if ($[24] !== mouseState?.end) {
|
|
351
|
+
t9 = it_1 => ({
|
|
352
|
+
...it_1,
|
|
353
|
+
show: mouseState?.end === undefined
|
|
354
|
+
});
|
|
355
|
+
$[24] = mouseState?.end;
|
|
356
|
+
$[25] = t9;
|
|
357
|
+
} else {
|
|
358
|
+
t9 = $[25];
|
|
359
|
+
}
|
|
360
|
+
option.tooltip = inputTooltip.map(t9);
|
|
361
|
+
}
|
|
362
|
+
let t9;
|
|
363
|
+
if ($[26] !== onInit || $[27] !== onMouseDown || $[28] !== onMouseMove || $[29] !== onMouseUp) {
|
|
364
|
+
t9 = instance_2 => {
|
|
365
|
+
const zr = instance_2.getZr();
|
|
366
|
+
zr.on("mousedown", params_2 => onMouseDown(instance_2, params_2));
|
|
367
|
+
zr.on("mousemove", onMouseMove);
|
|
368
|
+
zr.on("mouseup", params_3 => onMouseUp(instance_2, params_3));
|
|
369
|
+
return onInit?.(instance_2);
|
|
370
|
+
};
|
|
371
|
+
$[26] = onInit;
|
|
372
|
+
$[27] = onMouseDown;
|
|
373
|
+
$[28] = onMouseMove;
|
|
374
|
+
$[29] = onMouseUp;
|
|
375
|
+
$[30] = t9;
|
|
376
|
+
} else {
|
|
377
|
+
t9 = $[30];
|
|
378
|
+
}
|
|
379
|
+
return /*#__PURE__*/_jsx(ECharts, {
|
|
380
|
+
option: option,
|
|
381
|
+
onInit: t9,
|
|
382
|
+
...rest
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
function _temp(item, idx) {
|
|
386
|
+
return destructureLineDataItem(item, idx)?.[0][0];
|
|
387
|
+
}
|
|
388
|
+
function _temp2(a, b) {
|
|
389
|
+
return a - b;
|
|
390
|
+
}
|
|
391
|
+
function _temp3(a_0, b_0) {
|
|
392
|
+
return a_0 - b_0;
|
|
393
|
+
}
|
|
394
|
+
function _temp4(it_0) {
|
|
395
|
+
return it_0.h();
|
|
396
|
+
}
|
|
397
|
+
function _temp5(a_1, b_1) {
|
|
398
|
+
return a_1 - b_1;
|
|
399
|
+
}
|
|
400
|
+
function _temp6(a_2, b_2) {
|
|
401
|
+
return a_2 - b_2;
|
|
402
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type MenuProps } from "antd";
|
|
2
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
3
|
+
export type MenuItem = Required<MenuProps>["items"][number];
|
|
4
|
+
export interface SidebarProps extends MenuProps {
|
|
5
|
+
/**
|
|
6
|
+
* 侧边栏的宽度。
|
|
7
|
+
* @default 260
|
|
8
|
+
*/
|
|
9
|
+
width?: number | string;
|
|
10
|
+
/**
|
|
11
|
+
* 是否启用伸缩功能。
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
collapsible?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 网站 logo 的 URL。
|
|
17
|
+
*
|
|
18
|
+
* 建议导入图片,然后填入导入得到的地址,而不要硬编码地址。
|
|
19
|
+
*/
|
|
20
|
+
logo?: string;
|
|
21
|
+
/** 侧边栏的标题。*/
|
|
22
|
+
title?: string;
|
|
23
|
+
/**
|
|
24
|
+
* 侧边栏头部(logo 和标题部分)的高度。
|
|
25
|
+
* @default 116
|
|
26
|
+
*/
|
|
27
|
+
headerHeight?: number | string;
|
|
28
|
+
/**
|
|
29
|
+
* 侧边栏的头部(logo 和标题部分)。设置了该属性时,
|
|
30
|
+
* {@linkcode SidebarProps.logo | logo}、
|
|
31
|
+
* {@linkcode SidebarProps.title | title} 和
|
|
32
|
+
* {@linkcode SidebarProps.headerHeight | headerHeight} 将失去作用。
|
|
33
|
+
* 参数 `collapsed` 表示侧边栏是否收起。
|
|
34
|
+
* 填 `null` 可以隐藏掉默认值(与 `undefined` 不同!)。
|
|
35
|
+
*/
|
|
36
|
+
header?: ((collapsed: boolean) => ReactNode) | null;
|
|
37
|
+
/**
|
|
38
|
+
* 菜单项配置,默认与 TMS 系统的菜单相同。
|
|
39
|
+
*
|
|
40
|
+
* 该属性以及其余属性的用法可参考 [`Menu` 组件的文档][1]。
|
|
41
|
+
*
|
|
42
|
+
* [1]: https://ant-design.antgroup.com/components/menu-cn
|
|
43
|
+
*/
|
|
44
|
+
items?: MenuItem[];
|
|
45
|
+
/** 当前选中的菜单项 key 数组。 */
|
|
46
|
+
selectedKeys?: string[];
|
|
47
|
+
/** 当前展开的子菜单 key 数组。 */
|
|
48
|
+
openKeys?: string[];
|
|
49
|
+
/** 菜单项被选中时的回调函数。 */
|
|
50
|
+
onSelect?: MenuProps["onSelect"];
|
|
51
|
+
/** 子菜单展开/收起时的回调函数。 */
|
|
52
|
+
onOpenChange?: MenuProps["onOpenChange"];
|
|
53
|
+
/**
|
|
54
|
+
* 侧边栏底部的额外内容。参数 `collapsed` 表示侧边栏是否收起。
|
|
55
|
+
* 默认情况下使用 {@linkcode UserButton} 组件。
|
|
56
|
+
* 填 `null` 可以隐藏掉默认值(与 `undefined` 不同!)。
|
|
57
|
+
* @default (collapsed) => <UserButton compact={collapsed} />
|
|
58
|
+
*/
|
|
59
|
+
footer?: ((collapsed: boolean) => ReactNode) | null;
|
|
60
|
+
/** 额外的 `className`。*/
|
|
61
|
+
className?: string;
|
|
62
|
+
/** 额外的 CSS 样式。*/
|
|
63
|
+
style?: CSSProperties;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 出自 TMS 系统的侧边栏组件。该组件需要放置在 [Ant Design 的 `Layout` 组件][1]内部才能正常工作。
|
|
67
|
+
* 如果没有指定 {@linkcode SidebarProps.footer | footer} 属性,
|
|
68
|
+
* 那么还需要包裹在 {@linkcode AuthProvider} 内,并且经过 {@linkcode AuthCheck} 验证后
|
|
69
|
+
* 才能正常显示边栏底部的用户信息按钮。
|
|
70
|
+
*
|
|
71
|
+
* 一般来说,使用该组件时至少需要提供 `logo`、`items` 和 `onSelect` 三个属性,具体用法请参照范例。
|
|
72
|
+
*
|
|
73
|
+
* 除了文档中列出的属性之外,该组件会把额外的属性全部传递给内部的菜单 [`Menu` 组件][2]。
|
|
74
|
+
*
|
|
75
|
+
* [1]: https://ant-design.antgroup.com/components/layout-cn
|
|
76
|
+
* [2]: https://ant-design.antgroup.com/components/menu-cn
|
|
77
|
+
*/
|
|
78
|
+
declare function Sidebar(props: SidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
export default Sidebar;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { Button, Flex, Layout, Menu } from "antd";
|
|
2
|
+
import { createStyles } from "antd-style";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { BarChartOutlined, LeftOutlined, RightOutlined, SwapOutlined, TeamOutlined } from "@ant-design/icons";
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7
|
+
import { AuthCheck, AuthProvider } from "./Auth";
|
|
8
|
+
import UserButton from "./UserButton";
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const menuItem = (label, key, icon, children) => ({
|
|
11
|
+
key,
|
|
12
|
+
icon,
|
|
13
|
+
children,
|
|
14
|
+
label
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/** 默认菜单项配置,可以作为参考或默认值 */
|
|
18
|
+
const DEFAULT_MENU_ITEMS = [menuItem("数据看板", "data-board", /*#__PURE__*/_jsx(BarChartOutlined, {}), [menuItem("宏观数据", "macro-data"), menuItem("合约看板", "contract-overview"), menuItem("数据复盘", "data-review")]), menuItem("交易管理", "trade-management", /*#__PURE__*/_jsx(SwapOutlined, {}), [menuItem("日前交易", "day-ahead-trade"), menuItem("现货交易", "spot-trade"), menuItem("中长期交易", "long-term-trade")]), menuItem("合约管理", "customer-management", /*#__PURE__*/_jsx(TeamOutlined, {}), [menuItem("客户总览", "customer-overview"), menuItem("售电合约管理", "sales-contract"), menuItem("供应商管理", "supplier-management"), menuItem("购电合约管理", "purchase-contract")])];
|
|
19
|
+
/**
|
|
20
|
+
* 出自 TMS 系统的侧边栏组件。该组件需要放置在 [Ant Design 的 `Layout` 组件][1]内部才能正常工作。
|
|
21
|
+
* 如果没有指定 {@linkcode SidebarProps.footer | footer} 属性,
|
|
22
|
+
* 那么还需要包裹在 {@linkcode AuthProvider} 内,并且经过 {@linkcode AuthCheck} 验证后
|
|
23
|
+
* 才能正常显示边栏底部的用户信息按钮。
|
|
24
|
+
*
|
|
25
|
+
* 一般来说,使用该组件时至少需要提供 `logo`、`items` 和 `onSelect` 三个属性,具体用法请参照范例。
|
|
26
|
+
*
|
|
27
|
+
* 除了文档中列出的属性之外,该组件会把额外的属性全部传递给内部的菜单 [`Menu` 组件][2]。
|
|
28
|
+
*
|
|
29
|
+
* [1]: https://ant-design.antgroup.com/components/layout-cn
|
|
30
|
+
* [2]: https://ant-design.antgroup.com/components/menu-cn
|
|
31
|
+
*/
|
|
32
|
+
function Sidebar(props) {
|
|
33
|
+
const {
|
|
34
|
+
width = 260,
|
|
35
|
+
collapsible = false,
|
|
36
|
+
logo,
|
|
37
|
+
title,
|
|
38
|
+
headerHeight = 116,
|
|
39
|
+
header,
|
|
40
|
+
items = DEFAULT_MENU_ITEMS,
|
|
41
|
+
footer = collapsed => /*#__PURE__*/_jsx(UserButton, {
|
|
42
|
+
compact: collapsed,
|
|
43
|
+
style: {
|
|
44
|
+
marginBottom: token.paddingSM
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
className,
|
|
48
|
+
style,
|
|
49
|
+
...rest
|
|
50
|
+
} = props;
|
|
51
|
+
const [collapsed_0, setCollapsed] = useState(false);
|
|
52
|
+
// 默认展开到 selectedKeys
|
|
53
|
+
const [openKeys, setOpenKeys] = useState(() => rest.selectedKeys?.flatMap(key => findKeyPath(items, key) ?? []) ?? []);
|
|
54
|
+
const {
|
|
55
|
+
cx,
|
|
56
|
+
styles,
|
|
57
|
+
theme: token
|
|
58
|
+
} = useStyles(collapsed_0);
|
|
59
|
+
return /*#__PURE__*/_jsxs(Layout.Sider, {
|
|
60
|
+
theme: "light",
|
|
61
|
+
width: width,
|
|
62
|
+
collapsed: collapsible ? collapsed_0 : false,
|
|
63
|
+
collapsible: collapsible,
|
|
64
|
+
trigger: null,
|
|
65
|
+
className: cx(styles.sidebar, className),
|
|
66
|
+
style: style,
|
|
67
|
+
children: [header === null ? null : header ? header(collapsed_0) : /*#__PURE__*/_jsxs(Flex, {
|
|
68
|
+
vertical: true,
|
|
69
|
+
align: "center",
|
|
70
|
+
justify: "center",
|
|
71
|
+
className: cx(styles.sidebarHeader),
|
|
72
|
+
style: {
|
|
73
|
+
height: headerHeight
|
|
74
|
+
},
|
|
75
|
+
children: [/*#__PURE__*/_jsx("img", {
|
|
76
|
+
alt: "logo",
|
|
77
|
+
src: logo
|
|
78
|
+
}), /*#__PURE__*/_jsx("h1", {
|
|
79
|
+
style: {
|
|
80
|
+
color: token.colorText
|
|
81
|
+
},
|
|
82
|
+
children: title
|
|
83
|
+
})]
|
|
84
|
+
}), /*#__PURE__*/_jsx(Menu, {
|
|
85
|
+
mode: "inline",
|
|
86
|
+
items: items,
|
|
87
|
+
inlineCollapsed: collapsible ? collapsed_0 : false,
|
|
88
|
+
openKeys: openKeys,
|
|
89
|
+
onOpenChange: openKeys_0 => setOpenKeys(openKeys_0),
|
|
90
|
+
className: cx(styles.sidebarMenu),
|
|
91
|
+
...rest
|
|
92
|
+
}), footer === null ? null : footer(collapsed_0), collapsible && /*#__PURE__*/_jsx(Button, {
|
|
93
|
+
className: cx(styles.sidebarBtn),
|
|
94
|
+
icon: collapsed_0 ? /*#__PURE__*/_jsx(RightOutlined, {}) : /*#__PURE__*/_jsx(LeftOutlined, {}),
|
|
95
|
+
onClick: () => setCollapsed(!collapsed_0)
|
|
96
|
+
})]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
export default Sidebar;
|
|
100
|
+
const useStyles = createStyles(({
|
|
101
|
+
token,
|
|
102
|
+
css,
|
|
103
|
+
cx,
|
|
104
|
+
prefixCls
|
|
105
|
+
}, collapsed) => {
|
|
106
|
+
const sidebarHeader = css`
|
|
107
|
+
margin-top: ${token.marginXXS}px;
|
|
108
|
+
|
|
109
|
+
> img {
|
|
110
|
+
width: 40%;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
> h1 {
|
|
114
|
+
margin: ${collapsed ? 0 : token.marginXXS}px 0 0 0;
|
|
115
|
+
font-size: ${collapsed ? 0 : token.fontSize}px;
|
|
116
|
+
font-weight: normal;
|
|
117
|
+
line-height: 1;
|
|
118
|
+
transition:
|
|
119
|
+
margin-top ${token.motionDurationMid},
|
|
120
|
+
font-size ${token.motionDurationMid};
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
const sidebarMenu = css`
|
|
124
|
+
flex-basis: 100%;
|
|
125
|
+
overflow-y: auto;
|
|
126
|
+
`;
|
|
127
|
+
const sidebarBtn = css`
|
|
128
|
+
position: absolute;
|
|
129
|
+
top: 75%;
|
|
130
|
+
right: 0;
|
|
131
|
+
transform: translate(50%, -50%);
|
|
132
|
+
width: 32px;
|
|
133
|
+
height: 32px;
|
|
134
|
+
font-size: ${token.sizeSM}px;
|
|
135
|
+
|
|
136
|
+
transition: opacity ${token.motionDurationMid};
|
|
137
|
+
opacity: 100%;
|
|
138
|
+
`;
|
|
139
|
+
const sidebar = css`
|
|
140
|
+
position: relative;
|
|
141
|
+
box-shadow: rgba(0, 0, 0, 0.15) 0 0 8px;
|
|
142
|
+
|
|
143
|
+
> .${prefixCls}-layout-sider-children {
|
|
144
|
+
display: flex;
|
|
145
|
+
flex-direction: column;
|
|
146
|
+
}
|
|
147
|
+
& .${cx(sidebarMenu)}.${cx(sidebarMenu)} {
|
|
148
|
+
border-inline-end: none;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&:hover .${cx(sidebarBtn)} {
|
|
152
|
+
opacity: 100%;
|
|
153
|
+
}
|
|
154
|
+
`;
|
|
155
|
+
return {
|
|
156
|
+
sidebar,
|
|
157
|
+
sidebarHeader,
|
|
158
|
+
sidebarMenu,
|
|
159
|
+
sidebarBtn
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
function findKeyPath(items, key) {
|
|
163
|
+
for (const item of items) {
|
|
164
|
+
if (!item) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (item.key === key) {
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
if ("children" in item) {
|
|
171
|
+
const childrenResult = findKeyPath(item.children ?? [], key);
|
|
172
|
+
if (childrenResult) {
|
|
173
|
+
return [item.key, ...childrenResult];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type DatePickerProps as AntdDatePickerProps, type ButtonProps } from "antd";
|
|
2
|
+
import type { SpaceCompactProps } from "antd/es/space/Compact";
|
|
3
|
+
import type { Dayjs } from "dayjs";
|
|
4
|
+
export interface DatePickerProps extends Omit<SpaceCompactProps, "onChange"> {
|
|
5
|
+
value?: Dayjs;
|
|
6
|
+
onChange?: (value: Dayjs) => void;
|
|
7
|
+
/**
|
|
8
|
+
* 日期的单位。
|
|
9
|
+
* @default "month"
|
|
10
|
+
*/
|
|
11
|
+
dataType?: "day" | "week" | "month" | "year";
|
|
12
|
+
/**
|
|
13
|
+
* 是否禁用。
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 左右按钮的 `props`,见 [Ant Design 的 `Button` API][1]。
|
|
19
|
+
*
|
|
20
|
+
* [1]: https://ant-design.antgroup.com/components/button-cn#api
|
|
21
|
+
*/
|
|
22
|
+
buttonProps?: ButtonProps;
|
|
23
|
+
/**
|
|
24
|
+
* 日期选择器的 `props`,见 [Ant Design 的 `DatePicker` API][1]。
|
|
25
|
+
*
|
|
26
|
+
* [1]: https://ant-design.antgroup.com/components/date-picker-cn#api
|
|
27
|
+
*/
|
|
28
|
+
pickerProps?: AntdDatePickerProps;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 支持快速跳转的日/周/月/年选择器。
|
|
32
|
+
*
|
|
33
|
+
* 除了文档中列出的属性外,该组件会将其它属性传递给 [Ant Design 的 `Space.Compact` 组件][1]。
|
|
34
|
+
*
|
|
35
|
+
* [1]: https://ant-design.antgroup.com/components/space-cn#spacecompact
|
|
36
|
+
*/
|
|
37
|
+
declare function TsingrocDatePicker(props: DatePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export default TsingrocDatePicker;
|