@tsingroc/tsingroc-components 5.0.0-alpha.10 → 5.0.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/components/Auth.d.ts +310 -0
  2. package/dist/components/Auth.js +267 -0
  3. package/dist/components/AutoResizedECharts.d.ts +21 -0
  4. package/dist/components/AutoResizedECharts.js +98 -0
  5. package/dist/components/Calendar.d.ts +50 -0
  6. package/dist/components/Calendar.js +130 -0
  7. package/dist/components/CircularProgress.d.ts +21 -0
  8. package/dist/components/CircularProgress.js +34 -0
  9. package/dist/components/ConnectedECharts.d.ts +31 -0
  10. package/dist/components/ConnectedECharts.js +100 -0
  11. package/dist/components/ECharts.d.ts +57 -0
  12. package/dist/components/ECharts.js +255 -0
  13. package/dist/components/Header.d.ts +67 -0
  14. package/dist/components/Header.js +171 -0
  15. package/dist/components/ImageBackground.d.ts +32 -0
  16. package/dist/components/ImageBackground.js +76 -0
  17. package/dist/components/IndicatorLight.d.ts +44 -0
  18. package/dist/components/IndicatorLight.js +124 -0
  19. package/dist/components/LeftAlignedECharts.d.ts +42 -0
  20. package/dist/components/LeftAlignedECharts.js +270 -0
  21. package/dist/components/LineChartEditor.d.ts +74 -0
  22. package/dist/components/LineChartEditor.js +458 -0
  23. package/dist/components/LineChartTable.d.ts +38 -0
  24. package/dist/components/LineChartTable.js +245 -0
  25. package/dist/components/LinkedLineChart.d.ts +45 -0
  26. package/dist/components/LinkedLineChart.js +159 -0
  27. package/dist/components/QuickDateRangePicker.d.ts +30 -0
  28. package/dist/components/QuickDateRangePicker.js +58 -0
  29. package/dist/components/SegmentedButtons.d.ts +22 -0
  30. package/dist/components/SegmentedButtons.js +86 -0
  31. package/dist/components/Sidebar.d.ts +79 -0
  32. package/dist/components/Sidebar.js +178 -0
  33. package/dist/components/TsingrocDatePicker.d.ts +38 -0
  34. package/dist/components/TsingrocDatePicker.js +64 -0
  35. package/dist/components/TsingrocTheme.d.ts +15 -0
  36. package/dist/components/TsingrocTheme.js +72 -0
  37. package/dist/components/UserButton.d.ts +42 -0
  38. package/dist/components/UserButton.js +105 -0
  39. package/dist/components/VerticalColorLegend.d.ts +7 -0
  40. package/dist/components/VerticalColorLegend.js +208 -0
  41. package/dist/components/WeatherMap.d.ts +18 -0
  42. package/dist/components/WeatherMap.js +658 -0
  43. package/dist/deckgl/TiandituLayer.d.ts +13 -0
  44. package/dist/deckgl/TiandituLayer.js +44 -0
  45. package/dist/deckgl/WeatherData.d.ts +53 -0
  46. package/dist/deckgl/WeatherData.js +94 -0
  47. package/dist/deckgl/index.d.ts +1 -0
  48. package/dist/deckgl/index.js +1 -0
  49. package/dist/echarts/coordinateSystems/grid.d.ts +43 -0
  50. package/dist/echarts/coordinateSystems/grid.js +107 -0
  51. package/dist/echarts/coordinateSystems/index.js +2 -0
  52. package/dist/echarts/coordinateSystems/polar.d.ts +45 -0
  53. package/dist/echarts/coordinateSystems/polar.js +96 -0
  54. package/dist/echarts/gl-types.d.js +0 -0
  55. package/dist/echarts/gl.d.ts +115 -0
  56. package/dist/echarts/gl.js +47 -0
  57. package/dist/echarts/index.d.ts +46 -0
  58. package/dist/echarts/index.js +46 -0
  59. package/dist/echarts/legend.d.ts +17 -0
  60. package/dist/echarts/legend.js +15 -0
  61. package/dist/echarts/radar.d.ts +24 -0
  62. package/dist/echarts/radar.js +22 -0
  63. package/dist/echarts/series/barSeries.d.ts +23 -0
  64. package/dist/echarts/series/barSeries.js +18 -0
  65. package/dist/echarts/series/boxplotSeries.d.ts +21 -0
  66. package/dist/echarts/series/boxplotSeries.js +40 -0
  67. package/dist/echarts/series/index.js +7 -0
  68. package/dist/echarts/series/intervalSeries.d.ts +32 -0
  69. package/dist/echarts/series/intervalSeries.js +55 -0
  70. package/dist/echarts/series/lineSeries.d.ts +36 -0
  71. package/dist/echarts/series/lineSeries.js +45 -0
  72. package/dist/echarts/series/maxBarSeries.d.ts +18 -0
  73. package/dist/echarts/series/maxBarSeries.js +39 -0
  74. package/dist/echarts/series/pieSeries.d.ts +31 -0
  75. package/dist/echarts/series/pieSeries.js +47 -0
  76. package/dist/echarts/series/windLineSeries.d.ts +47 -0
  77. package/dist/echarts/series/windLineSeries.js +51 -0
  78. package/{src/echarts/tooltip.ts → dist/echarts/tooltip.d.ts} +1 -5
  79. package/dist/echarts/tooltip.js +18 -0
  80. package/dist/env.d.js +0 -0
  81. package/dist/index.d.ts +20 -0
  82. package/dist/index.js +20 -0
  83. package/dist/utils/debug.d.ts +1 -0
  84. package/dist/utils/debug.js +25 -0
  85. package/dist/utils/index.d.ts +4 -0
  86. package/dist/utils/index.js +4 -0
  87. package/dist/utils/math.d.ts +9 -0
  88. package/{src/utils/math.ts → dist/utils/math.js} +2 -2
  89. package/dist/utils/mock.d.ts +8 -0
  90. package/dist/utils/mock.js +40 -0
  91. package/dist/utils/startOfQuarter.d.ts +2 -0
  92. package/dist/utils/startOfQuarter.js +4 -0
  93. package/package.json +26 -14
  94. package/src/components/Auth.tsx +0 -623
  95. package/src/components/AutoResizedECharts.tsx +0 -70
  96. package/src/components/Calendar.tsx +0 -182
  97. package/src/components/CircularProgress.tsx +0 -38
  98. package/src/components/ConnectedECharts.tsx +0 -62
  99. package/src/components/ECharts.tsx +0 -206
  100. package/src/components/Header.tsx +0 -136
  101. package/src/components/ImageBackground.tsx +0 -58
  102. package/src/components/IndicatorLight.tsx +0 -106
  103. package/src/components/LeftAlignedECharts.tsx +0 -190
  104. package/src/components/LineChartEditor.tsx +0 -558
  105. package/src/components/LineChartTable.tsx +0 -286
  106. package/src/components/LinkedECharts.tsx +0 -51
  107. package/src/components/LinkedLineChart.tsx +0 -144
  108. package/src/components/QuickDateRangePicker.tsx +0 -84
  109. package/src/components/SegmentedButtons.tsx +0 -46
  110. package/src/components/Sidebar.tsx +0 -271
  111. package/src/components/StrictECharts.d.ts +0 -47
  112. package/src/components/StrictECharts.js +0 -1
  113. package/src/components/TsingrocDatePicker.tsx +0 -103
  114. package/src/components/TsingrocTheme.tsx +0 -48
  115. package/src/components/UserButton.tsx +0 -165
  116. package/src/components/VerticalColorLegend.tsx +0 -73
  117. package/src/components/WeatherMap.tsx +0 -522
  118. package/src/deckgl/TiandituLayer.ts +0 -56
  119. package/src/deckgl/WeatherData.ts +0 -157
  120. package/src/deckgl/index.ts +0 -4
  121. package/src/echarts/coordinateSystems/grid.ts +0 -143
  122. package/src/echarts/coordinateSystems/polar.ts +0 -148
  123. package/src/echarts/gl.ts +0 -159
  124. package/src/echarts/index.ts +0 -129
  125. package/src/echarts/legend.ts +0 -36
  126. package/src/echarts/radar.ts +0 -46
  127. package/src/echarts/series/barSeries.ts +0 -37
  128. package/src/echarts/series/boxplotSeries.ts +0 -62
  129. package/src/echarts/series/intervalSeries.ts +0 -70
  130. package/src/echarts/series/lineSeries.ts +0 -78
  131. package/src/echarts/series/maxBarSeries.ts +0 -55
  132. package/src/echarts/series/pieSeries.ts +0 -76
  133. package/src/echarts/series/windLineSeries.ts +0 -113
  134. package/src/index.ts +0 -118
  135. package/src/types.d.ts +0 -5
  136. package/src/utils/debug.ts +0 -39
  137. package/src/utils/mock.ts +0 -69
  138. package/src/utils/startOfQuarter.ts +0 -6
  139. /package/{src/echarts/coordinateSystems/index.ts → dist/echarts/coordinateSystems/index.d.ts} +0 -0
  140. /package/{src/echarts/series/index.ts → dist/echarts/series/index.d.ts} +0 -0
@@ -0,0 +1,245 @@
1
+ import { ConfigProvider, Flex, Table, theme } from "antd";
2
+ import { createStyles } from "antd-style";
3
+ import { useContext, useEffect, useMemo, useRef, useState } from "react";
4
+ import * as echarts from "../echarts";
5
+ import ECharts from "./ECharts";
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ const EMPTY = [];
8
+
9
+ /**
10
+ * 折线图与表格的组合,用鼠标指向表格中的数据时会高亮折线图中的对应数据,反之亦然。
11
+ *
12
+ * 除了文档列出的属性外,多余的属性会被传递给最外层的 [Flex][1] 组件。
13
+ *
14
+ * [1]: https://ant-design.antgroup.com/components/flex-cn#api
15
+ */
16
+ function LineChartTable(props) {
17
+ const {
18
+ xData,
19
+ xName = "时间",
20
+ yName = "数值",
21
+ yUnit,
22
+ series = [],
23
+ chartHeight = 175,
24
+ ...rest
25
+ } = props;
26
+ // TODO i18n
27
+ const unitString = yUnit !== undefined ? `(${yUnit})` : "";
28
+ const {
29
+ cx,
30
+ styles,
31
+ theme: token
32
+ } = useStyles();
33
+ const isDark = useContext(ConfigProvider.ConfigContext).theme?.algorithm === theme.darkAlgorithm;
34
+ const echartsRef = useRef(null);
35
+ const tableRef = useRef(null);
36
+ const [[hoverSource, hoverXIndex, hoverY], setHover] = useState(EMPTY);
37
+ let closestYIndex;
38
+ let closestY;
39
+ if (hoverXIndex !== undefined && hoverY !== undefined) {
40
+ let minDist = Infinity;
41
+ series.forEach((series_0, index) => {
42
+ const y = series_0.data[hoverXIndex];
43
+ const dist = Math.abs(y - hoverY);
44
+ if (dist < minDist) {
45
+ closestYIndex = index;
46
+ closestY = y;
47
+ minDist = dist;
48
+ }
49
+ });
50
+ }
51
+ const option = echarts.buildEChartsOption({
52
+ backgroundColor: "transparent"
53
+ }, echarts.useGrid({
54
+ option: {
55
+ id: "grid",
56
+ left: 12,
57
+ right: 42,
58
+ bottom: 40
59
+ },
60
+ xAxis: {
61
+ name: xName,
62
+ data: xData,
63
+ axisPointer: {
64
+ value: xData[hoverXIndex ?? 0],
65
+ status: hoverXIndex !== undefined ? "show" : "hide"
66
+ }
67
+ },
68
+ yAxis: {
69
+ name: yName + unitString,
70
+ axisPointer: {
71
+ value: closestY,
72
+ status: closestY !== undefined ? "show" : "hide"
73
+ }
74
+ },
75
+ series: series.map(series_1 => echarts.lineSeries(series_1))
76
+ }), echarts.legend({
77
+ data: series.map(series_2 => series_2.name),
78
+ option: {
79
+ right: 42
80
+ }
81
+ }), {
82
+ axisPointer: [{
83
+ show: true,
84
+ triggerOn: "none"
85
+ }],
86
+ dataZoom: [{
87
+ orient: "horizontal",
88
+ bottom: 8,
89
+ filterMode: "empty"
90
+ }]
91
+ });
92
+ useEffect(() => {
93
+ const inst = echartsRef.current?.instance?.getZr();
94
+ if (!inst) return () => {};
95
+ const onMousemove = event => {
96
+ const inst_0 = echartsRef.current?.instance;
97
+ if (!inst_0) return;
98
+ const coord = [event.offsetX, event.offsetY];
99
+ if (inst_0.containPixel("grid", coord)) {
100
+ const [x, y_0] = inst_0.convertFromPixel("grid", coord);
101
+ setHover(["chart", x, y_0]);
102
+ } else {
103
+ setHover(EMPTY);
104
+ }
105
+ };
106
+ const onGlobalout = () => setHover(EMPTY);
107
+ inst.on("mousemove", onMousemove);
108
+ inst.on("globalout", onGlobalout);
109
+ return () => {
110
+ inst.off("mousemove", onMousemove);
111
+ inst.off("globalout", onGlobalout);
112
+ };
113
+ }, []);
114
+ useEffect(() => {
115
+ const inst_1 = echartsRef.current?.instance;
116
+ if (!inst_1) return;
117
+ if (hoverXIndex !== undefined) {
118
+ inst_1.dispatchAction({
119
+ type: "highlight",
120
+ seriesIndex: closestYIndex,
121
+ dataIndex: hoverXIndex
122
+ });
123
+ if (hoverSource === "chart") {
124
+ // eslint-disable-next-line react-hooks/immutability
125
+ tableScrollTo(hoverXIndex);
126
+ }
127
+ } else {
128
+ inst_1.dispatchAction({
129
+ type: "downplay"
130
+ });
131
+ }
132
+ }, [hoverSource, hoverXIndex, closestYIndex]);
133
+ const tableDataWithoutHover = useMemo(() => {
134
+ const data = xData.map((x_0, i) => ({
135
+ key: i,
136
+ x: x_0
137
+ }));
138
+ series.forEach(series_3 => series_3.data.forEach((y_1, i_0) => data[i_0][`y${series_3.name}`] = y_1));
139
+ return data;
140
+ }, [xData, series]);
141
+ const tableData = useMemo(() => {
142
+ if (hoverSource === "chart" && hoverXIndex !== undefined) {
143
+ const data_0 = [...tableDataWithoutHover];
144
+ data_0[hoverXIndex] = {
145
+ ...data_0[hoverXIndex],
146
+ hover: closestYIndex ?? true
147
+ };
148
+ return data_0;
149
+ } else {
150
+ return tableDataWithoutHover;
151
+ }
152
+ }, [tableDataWithoutHover, hoverSource, hoverXIndex, closestYIndex]);
153
+ const tableColumns = useMemo(() => {
154
+ const columnWidth = `${100 / series.length}%`;
155
+ return [{
156
+ key: "x",
157
+ dataIndex: "x",
158
+ title: xName,
159
+ onCell: (data_1, index_0) => ({
160
+ className: cx({
161
+ [styles.rowHovered]: data_1.hover !== undefined
162
+ }),
163
+ onMouseEnter: () => setHover(["table", index_0]),
164
+ onMouseLeave: () => setHover(EMPTY)
165
+ })
166
+ }, ...series.map((series_4, yIndex) => ({
167
+ key: `y${series_4.name}`,
168
+ dataIndex: `y${series_4.name}`,
169
+ title: series_4.name + unitString,
170
+ width: columnWidth,
171
+ onCell: (data_2, xIndex) => ({
172
+ className: cx(styles.cell, {
173
+ [styles.rowHovered]: data_2.hover !== undefined,
174
+ [styles.cellHovered]: data_2.hover === yIndex
175
+ }),
176
+ onMouseEnter: () => setHover(["table", xIndex, data_2[`y${series_4.name}`]]),
177
+ onMouseLeave: () => setHover(EMPTY)
178
+ })
179
+ }))];
180
+ }, [cx, styles, xName, series, unitString]);
181
+ const tableScrollTo = index_1 => {
182
+ const table = tableRef.current?.nativeElement;
183
+ if (table) {
184
+ const header = table.getElementsByTagName("thead")[0];
185
+ const row = table.getElementsByTagName("tr")[index_1];
186
+ table.scrollTo({
187
+ top: row.offsetTop + row.offsetHeight / 2 - (table.offsetHeight - header.offsetHeight) / 2,
188
+ behavior: "smooth"
189
+ });
190
+ }
191
+ };
192
+ return /*#__PURE__*/_jsxs(Flex, {
193
+ vertical: true,
194
+ gap: token.marginXS,
195
+ ...rest,
196
+ children: [/*#__PURE__*/_jsx(ECharts, {
197
+ ref: echartsRef,
198
+ option: option,
199
+ theme: isDark ? "dark" : undefined,
200
+ style: {
201
+ height: chartHeight,
202
+ flexShrink: 0
203
+ }
204
+ }), useMemo(() => /*#__PURE__*/_jsx(Table, {
205
+ ref: tableRef,
206
+ dataSource: tableData,
207
+ columns: tableColumns,
208
+ size: "small",
209
+ pagination: false,
210
+ style: {
211
+ flexBasis: "100%",
212
+ overflowY: "auto"
213
+ },
214
+ onHeaderRow: () => ({
215
+ style: {
216
+ position: "sticky",
217
+ top: 0,
218
+ zIndex: 1
219
+ }
220
+ })
221
+ }), [tableData, tableColumns])]
222
+ });
223
+ }
224
+ export default LineChartTable;
225
+ const useStyles = createStyles(({
226
+ css,
227
+ token
228
+ }) => {
229
+ const rowHovered = css`
230
+ background: ${token.colorFillQuaternary};
231
+ `;
232
+ const cell = css`
233
+ [class] > &:hover:hover {
234
+ background: ${token.colorFillSecondary};
235
+ }
236
+ `;
237
+ const cellHovered = css`
238
+ background: ${token.colorFillSecondary};
239
+ `;
240
+ return {
241
+ rowHovered,
242
+ cell,
243
+ cellHovered
244
+ };
245
+ });
@@ -0,0 +1,45 @@
1
+ import type { LineSeriesOption } from "echarts";
2
+ import { type ReactNode } from "react";
3
+ import type { EChartsProps } from "./ECharts";
4
+ export interface LineChartLinkProviderProps {
5
+ /** X 轴的数据。*/
6
+ xData: (string | number)[];
7
+ /**
8
+ * X 轴的名称。
9
+ * @default "时间"
10
+ */
11
+ xName?: string;
12
+ /** 包裹的内容,其中包含需要联动的 {@linkcode LinkedLineChart} 组件。*/
13
+ children: ReactNode;
14
+ }
15
+ /**
16
+ * {@linkcode LinkedLineChart} 联动上下文的 Provider。
17
+ *
18
+ * 用于包裹需要联动的 {@linkcode LinkedLineChart} 组件。
19
+ */
20
+ export declare function LineChartLinkProvider(props: LineChartLinkProviderProps): import("react/jsx-runtime").JSX.Element;
21
+ export interface LinkedLineChartProps extends Omit<EChartsProps, "option"> {
22
+ /**
23
+ * Y 轴的名称。
24
+ * @default "数值"
25
+ */
26
+ yName?: string;
27
+ /** Y 轴的单位,默认不显示。*/
28
+ yUnit?: string;
29
+ /** 各个曲线的名称、数据和其它选项(颜色、插值模式等)。*/
30
+ series?: {
31
+ name: string;
32
+ data: number[];
33
+ option?: LineSeriesOption;
34
+ }[];
35
+ /**
36
+ * 是否启用横轴下方的缩放条(`dataZoom`)
37
+ * @default true
38
+ */
39
+ dataZoom?: boolean;
40
+ }
41
+ /**
42
+ * 折线图组件,支持多条数据曲线和横轴联动。鼠标悬停在图表上时会触发联动高亮。
43
+ */
44
+ declare function LinkedLineChart(props: LinkedLineChartProps): import("react/jsx-runtime").JSX.Element;
45
+ export default LinkedLineChart;
@@ -0,0 +1,159 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { ConfigProvider, theme } from "antd";
3
+ import { createContext, useContext } from "react";
4
+ import * as echarts from "../echarts";
5
+ import ConnectedECharts, { EChartsConnector } from "./ConnectedECharts";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const LineChartLinkContext = /*#__PURE__*/createContext({
8
+ xData: [],
9
+ xName: "时间"
10
+ });
11
+ /**
12
+ * {@linkcode LinkedLineChart} 联动上下文的 Provider。
13
+ *
14
+ * 用于包裹需要联动的 {@linkcode LinkedLineChart} 组件。
15
+ */
16
+ export function LineChartLinkProvider(props) {
17
+ const $ = _c(6);
18
+ const t0 = props.xName ?? "\u65F6\u95F4";
19
+ let t1;
20
+ if ($[0] !== props.xData || $[1] !== t0) {
21
+ t1 = {
22
+ xData: props.xData,
23
+ xName: t0
24
+ };
25
+ $[0] = props.xData;
26
+ $[1] = t0;
27
+ $[2] = t1;
28
+ } else {
29
+ t1 = $[2];
30
+ }
31
+ let t2;
32
+ if ($[3] !== props.children || $[4] !== t1) {
33
+ t2 = /*#__PURE__*/_jsx(EChartsConnector, {
34
+ children: /*#__PURE__*/_jsx(LineChartLinkContext.Provider, {
35
+ value: t1,
36
+ children: props.children
37
+ })
38
+ });
39
+ $[3] = props.children;
40
+ $[4] = t1;
41
+ $[5] = t2;
42
+ } else {
43
+ t2 = $[5];
44
+ }
45
+ return t2;
46
+ }
47
+ /**
48
+ * 折线图组件,支持多条数据曲线和横轴联动。鼠标悬停在图表上时会触发联动高亮。
49
+ */
50
+ function LinkedLineChart(props) {
51
+ const $ = _c(10);
52
+ let rest;
53
+ let t0;
54
+ let t1;
55
+ let t2;
56
+ let yUnit;
57
+ if ($[0] !== props) {
58
+ ({
59
+ yName: t0,
60
+ yUnit,
61
+ series: t1,
62
+ dataZoom: t2,
63
+ ...rest
64
+ } = props);
65
+ $[0] = props;
66
+ $[1] = rest;
67
+ $[2] = t0;
68
+ $[3] = t1;
69
+ $[4] = t2;
70
+ $[5] = yUnit;
71
+ } else {
72
+ rest = $[1];
73
+ t0 = $[2];
74
+ t1 = $[3];
75
+ t2 = $[4];
76
+ yUnit = $[5];
77
+ }
78
+ const yName = t0 === undefined ? "\u6570\u503C" : t0;
79
+ const series = t1 === undefined ? [] : t1;
80
+ const dataZoom = t2 === undefined ? true : t2;
81
+ const unitString = yUnit !== undefined ? `(${yUnit})` : "";
82
+ const isDark = useContext(ConfigProvider.ConfigContext).theme?.algorithm === theme.darkAlgorithm;
83
+ const {
84
+ xData,
85
+ xName
86
+ } = useContext(LineChartLinkContext);
87
+ const option = echarts.buildEChartsOption({
88
+ backgroundColor: "transparent"
89
+ }, echarts.useGrid({
90
+ option: {
91
+ id: "grid",
92
+ left: 12,
93
+ right: 42,
94
+ bottom: dataZoom ? 40 : 0
95
+ },
96
+ xAxis: {
97
+ name: xName,
98
+ data: xData,
99
+ axisPointer: {
100
+ show: true
101
+ }
102
+ },
103
+ yAxis: {
104
+ name: yName + unitString,
105
+ axisPointer: {
106
+ show: false
107
+ }
108
+ },
109
+ series: series.map(_temp)
110
+ }), echarts.legend({
111
+ data: series.map(_temp2),
112
+ option: {
113
+ right: 42
114
+ }
115
+ }), echarts.tooltip({
116
+ trigger: "axis",
117
+ position: _temp3
118
+ }), {
119
+ dataZoom: [{
120
+ show: dataZoom,
121
+ orient: "horizontal",
122
+ bottom: 8,
123
+ filterMode: "empty"
124
+ }]
125
+ });
126
+ const t3 = isDark ? "dark" : undefined;
127
+ let t4;
128
+ if ($[6] !== option || $[7] !== rest || $[8] !== t3) {
129
+ t4 = /*#__PURE__*/_jsx(ConnectedECharts, {
130
+ option: option,
131
+ theme: t3,
132
+ ...rest
133
+ });
134
+ $[6] = option;
135
+ $[7] = rest;
136
+ $[8] = t3;
137
+ $[9] = t4;
138
+ } else {
139
+ t4 = $[9];
140
+ }
141
+ return t4;
142
+ }
143
+ function _temp3(t0, _params, _dom, _rect, t1) {
144
+ const [x] = t0;
145
+ const {
146
+ contentSize: t2,
147
+ viewSize: t3
148
+ } = t1;
149
+ const [popupWidth] = t2;
150
+ const [chartWidth] = t3;
151
+ return [x + 10 + popupWidth <= chartWidth ? x + 10 : x - 10 - popupWidth, 20];
152
+ }
153
+ function _temp2(series_1) {
154
+ return series_1.name;
155
+ }
156
+ function _temp(series_0) {
157
+ return echarts.lineSeries(series_0);
158
+ }
159
+ export default LinkedLineChart;
@@ -0,0 +1,30 @@
1
+ import { type ButtonProps, type SpaceProps } from "antd";
2
+ import type { RangePickerProps } from "antd/es/date-picker";
3
+ import { type Dayjs } from "dayjs";
4
+ import type { NoUndefinedRangeValueType } from "rc-picker/lib/PickerInput/RangePicker";
5
+ export interface QuickDateRangePickerProps extends Omit<SpaceProps, "onChange"> {
6
+ /** 一个二元组 `[start, end]`,表示时间段的开始和结束。*/
7
+ value?: NoUndefinedRangeValueType<Dayjs>;
8
+ onChange?: (range: NoUndefinedRangeValueType<Dayjs>) => void;
9
+ /**
10
+ * 内部按钮的属性,参见 [Ant Design 的 `Button` API][1]。
11
+ *
12
+ * [1]: https://ant-design.antgroup.com/components/button-cn#api
13
+ */
14
+ buttonProps?: ButtonProps;
15
+ /**
16
+ * 内部日期范围选择器的属性,参见 [Ant Design 的 `DatePicker.RangePicker` API][1]。
17
+ *
18
+ * [1]: https://ant-design.antgroup.com/components/date-picker-cn#rangepicker
19
+ */
20
+ pickerProps?: RangePickerProps;
21
+ }
22
+ /**
23
+ * 带有快速选择最近 3/5/7 天功能的日期范围选择器。
24
+ *
25
+ * 除了文档中列出的属性外,该组件会将其它属性传递给 [Ant Design 的 `Space` 组件][1]。
26
+ *
27
+ * [1]: https://ant-design.antgroup.com/components/space-cn#api
28
+ */
29
+ declare function QuickDateRangePicker(props: QuickDateRangePickerProps): import("react/jsx-runtime").JSX.Element;
30
+ export default QuickDateRangePicker;
@@ -0,0 +1,58 @@
1
+ import { Button, DatePicker, Space } from "antd";
2
+ import dayjs from "dayjs";
3
+ import { useState } from "react";
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ const QUICK_PICK_RANGES = [{
6
+ value: 3,
7
+ label: "最近 3 天"
8
+ }, {
9
+ value: 5,
10
+ label: "最近 5 天"
11
+ }, {
12
+ value: 7,
13
+ label: "最近 7 天"
14
+ }];
15
+
16
+ /**
17
+ * 带有快速选择最近 3/5/7 天功能的日期范围选择器。
18
+ *
19
+ * 除了文档中列出的属性外,该组件会将其它属性传递给 [Ant Design 的 `Space` 组件][1]。
20
+ *
21
+ * [1]: https://ant-design.antgroup.com/components/space-cn#api
22
+ */
23
+ function QuickDateRangePicker(props) {
24
+ const {
25
+ value,
26
+ onChange,
27
+ buttonProps,
28
+ pickerProps,
29
+ ...rest
30
+ } = props;
31
+ const [range, setRange] = value === undefined ?
32
+ // eslint-disable-next-line react-hooks/rules-of-hooks
33
+ useState(undefined) : [value, () => {}];
34
+ function quickPick(value) {
35
+ const end = dayjs();
36
+ const start = end.subtract(value - 1, "day");
37
+ const newRange = [start, end];
38
+ setRange(newRange);
39
+ onChange?.(newRange);
40
+ }
41
+ return /*#__PURE__*/_jsxs(Space, {
42
+ ...rest,
43
+ children: [QUICK_PICK_RANGES.map((item, index) => /*#__PURE__*/_jsx(Button, {
44
+ onClick: () => quickPick(item.value),
45
+ ...buttonProps,
46
+ children: item.label
47
+ }, index)), /*#__PURE__*/_jsx(DatePicker.RangePicker, {
48
+ value: range,
49
+ allowClear: false,
50
+ onChange: range => {
51
+ setRange(range);
52
+ onChange?.(range); // 由于 allowClear=false,这里 range 不可能为 null
53
+ },
54
+ ...pickerProps
55
+ })]
56
+ });
57
+ }
58
+ export default QuickDateRangePicker;
@@ -0,0 +1,22 @@
1
+ import { type RadioGroupProps } from "antd";
2
+ /**
3
+ * 分段单选按钮。
4
+ *
5
+ * 该组件是 [Ant Design 的 `Radio.Group optionType="button"`][1] 的别名。
6
+ *
7
+ * [1]: https://ant-design.antgroup.com/components/radio-cn#radiogroup
8
+ */
9
+ declare function SegmentedButtons(props: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
10
+ export interface TimeUnitSwitcherProps extends Omit<RadioGroupProps, "onChange"> {
11
+ value?: "day" | "week" | "month";
12
+ onChange?: (value: "day" | "week" | "month") => void;
13
+ }
14
+ /**
15
+ * 时间单位(日/周/月)切换按钮。
16
+ *
17
+ * 该组件是 {@linkcode SegmentedButtons} 的特化版本。更多属性参见 [`Radio.Group`][1]。
18
+ *
19
+ * [1]: https://ant-design.antgroup.com/components/radio-cn#radiogroup
20
+ */
21
+ export declare function TimeUnitSwitcher(props: TimeUnitSwitcherProps): import("react/jsx-runtime").JSX.Element;
22
+ export default SegmentedButtons;
@@ -0,0 +1,86 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Radio } from "antd";
3
+
4
+ /**
5
+ * 分段单选按钮。
6
+ *
7
+ * 该组件是 [Ant Design 的 `Radio.Group optionType="button"`][1] 的别名。
8
+ *
9
+ * [1]: https://ant-design.antgroup.com/components/radio-cn#radiogroup
10
+ */
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ function SegmentedButtons(props) {
13
+ const $ = _c(2);
14
+ let t0;
15
+ if ($[0] !== props) {
16
+ t0 = /*#__PURE__*/_jsx(Radio.Group, {
17
+ optionType: "button",
18
+ ...props
19
+ });
20
+ $[0] = props;
21
+ $[1] = t0;
22
+ } else {
23
+ t0 = $[1];
24
+ }
25
+ return t0;
26
+ }
27
+
28
+ // TODO i18n
29
+ const TIME_UNIT_OPTIONS = [{
30
+ label: "日",
31
+ value: "day"
32
+ }, {
33
+ label: "周",
34
+ value: "week"
35
+ }, {
36
+ label: "月",
37
+ value: "month"
38
+ }];
39
+ /**
40
+ * 时间单位(日/周/月)切换按钮。
41
+ *
42
+ * 该组件是 {@linkcode SegmentedButtons} 的特化版本。更多属性参见 [`Radio.Group`][1]。
43
+ *
44
+ * [1]: https://ant-design.antgroup.com/components/radio-cn#radiogroup
45
+ */
46
+ export function TimeUnitSwitcher(props) {
47
+ const $ = _c(8);
48
+ let onChange;
49
+ let rest;
50
+ if ($[0] !== props) {
51
+ ({
52
+ onChange,
53
+ ...rest
54
+ } = props);
55
+ $[0] = props;
56
+ $[1] = onChange;
57
+ $[2] = rest;
58
+ } else {
59
+ onChange = $[1];
60
+ rest = $[2];
61
+ }
62
+ let t0;
63
+ if ($[3] !== onChange) {
64
+ t0 = e => onChange?.(e.target.value);
65
+ $[3] = onChange;
66
+ $[4] = t0;
67
+ } else {
68
+ t0 = $[4];
69
+ }
70
+ let t1;
71
+ if ($[5] !== rest || $[6] !== t0) {
72
+ t1 = /*#__PURE__*/_jsx(Radio.Group, {
73
+ optionType: "button",
74
+ options: TIME_UNIT_OPTIONS,
75
+ onChange: t0,
76
+ ...rest
77
+ });
78
+ $[5] = rest;
79
+ $[6] = t0;
80
+ $[7] = t1;
81
+ } else {
82
+ t1 = $[7];
83
+ }
84
+ return t1;
85
+ }
86
+ export default SegmentedButtons;