@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,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;
@@ -0,0 +1,64 @@
1
+ import { Button, DatePicker, Space } from "antd";
2
+ import { useState } from "react";
3
+ import { LeftOutlined, RightOutlined } from "@ant-design/icons";
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ /**
6
+ * 支持快速跳转的日/周/月/年选择器。
7
+ *
8
+ * 除了文档中列出的属性外,该组件会将其它属性传递给 [Ant Design 的 `Space.Compact` 组件][1]。
9
+ *
10
+ * [1]: https://ant-design.antgroup.com/components/space-cn#spacecompact
11
+ */
12
+ function TsingrocDatePicker(props) {
13
+ const {
14
+ value,
15
+ onChange: propsOnChange,
16
+ dataType = "month",
17
+ disabled,
18
+ buttonProps,
19
+ pickerProps,
20
+ ...rest
21
+ } = props;
22
+ const [dateValue, setDateValue] = value === undefined ?
23
+ // eslint-disable-next-line react-hooks/rules-of-hooks
24
+ useState(undefined) : [value, () => {}];
25
+ /**
26
+ * 快速增减一定时间,如果当前未选择日期则无效。
27
+ * @param delta 增减的时间量,按传入的时间单位 `dataType` 计算
28
+ */
29
+ const quickSwitch = delta => {
30
+ if (!dateValue) return;
31
+ const temp = dateValue.add(delta, dataType);
32
+ setDateValue(temp);
33
+ propsOnChange?.(temp);
34
+ };
35
+ const onChange = value => {
36
+ setDateValue(value);
37
+ propsOnChange?.(value);
38
+ };
39
+ return /*#__PURE__*/_jsxs(Space.Compact, {
40
+ ...rest,
41
+ children: [/*#__PURE__*/_jsx(Button, {
42
+ onClick: () => quickSwitch(-1),
43
+ icon: /*#__PURE__*/_jsx(LeftOutlined, {}),
44
+ disabled: disabled,
45
+ className: props.className,
46
+ ...buttonProps
47
+ }), /*#__PURE__*/_jsx(DatePicker, {
48
+ picker: dataType == "day" ? "date" : dataType,
49
+ value: dateValue,
50
+ onChange: onChange,
51
+ disabled: disabled,
52
+ className: props.className,
53
+ ...pickerProps
54
+ }), /*#__PURE__*/_jsx(Button
55
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion
56
+ , {
57
+ onClick: () => quickSwitch(+1),
58
+ icon: /*#__PURE__*/_jsx(RightOutlined, {}),
59
+ disabled: disabled,
60
+ ...buttonProps
61
+ })]
62
+ });
63
+ }
64
+ export default TsingrocDatePicker;
@@ -0,0 +1,15 @@
1
+ import type { ReactNode } from "react";
2
+ export interface TsingrocThemeProps {
3
+ /** 是否开启黑暗模式。*/
4
+ dark?: boolean;
5
+ /** 是否开启紧凑模式。*/
6
+ compact?: boolean;
7
+ /** 主题覆盖的页面内容。*/
8
+ children: ReactNode;
9
+ }
10
+ /**
11
+ * 清鹏智能的公共 Ant Design 主题,会影响内部的所有 Ant Design 组件的样式。
12
+ * 请将该组件放置在整个 React 项目的顶层。
13
+ */
14
+ declare function TsingrocTheme(props: TsingrocThemeProps): import("react/jsx-runtime").JSX.Element;
15
+ export default TsingrocTheme;
@@ -0,0 +1,72 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { ConfigProvider, theme } from "antd";
3
+ import antdZhCN from "antd/es/locale/zh_CN";
4
+ import dayjs from "dayjs";
5
+ import dayjsZhCN from "dayjs/locale/zh-cn";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ /**
8
+ * 清鹏智能的公共 Ant Design 主题,会影响内部的所有 Ant Design 组件的样式。
9
+ * 请将该组件放置在整个 React 项目的顶层。
10
+ */
11
+ function TsingrocTheme(props) {
12
+ const $ = _c(11);
13
+ dayjs.locale(dayjsZhCN);
14
+ let algorithm;
15
+ if ($[0] !== props.compact || $[1] !== props.dark) {
16
+ algorithm = [];
17
+ if (props.compact) {
18
+ algorithm.push(theme.compactAlgorithm);
19
+ }
20
+ if (props.dark) {
21
+ algorithm.push(theme.darkAlgorithm);
22
+ }
23
+ $[0] = props.compact;
24
+ $[1] = props.dark;
25
+ $[2] = algorithm;
26
+ } else {
27
+ algorithm = $[2];
28
+ }
29
+ let t0;
30
+ if ($[3] !== props.dark) {
31
+ t0 = props.dark ? {
32
+ colorPrimary: "#9b5efd",
33
+ colorInfo: "#9b5efd",
34
+ colorSuccess: "#1ac489"
35
+ } : {
36
+ colorPrimary: "#5200d7",
37
+ colorInfo: "#5200d7",
38
+ colorSuccess: "#1ac489"
39
+ };
40
+ $[3] = props.dark;
41
+ $[4] = t0;
42
+ } else {
43
+ t0 = $[4];
44
+ }
45
+ let t1;
46
+ if ($[5] !== algorithm || $[6] !== t0) {
47
+ t1 = {
48
+ algorithm,
49
+ token: t0
50
+ };
51
+ $[5] = algorithm;
52
+ $[6] = t0;
53
+ $[7] = t1;
54
+ } else {
55
+ t1 = $[7];
56
+ }
57
+ let t2;
58
+ if ($[8] !== props.children || $[9] !== t1) {
59
+ t2 = /*#__PURE__*/_jsx(ConfigProvider, {
60
+ locale: antdZhCN,
61
+ theme: t1,
62
+ children: props.children
63
+ });
64
+ $[8] = props.children;
65
+ $[9] = t1;
66
+ $[10] = t2;
67
+ } else {
68
+ t2 = $[10];
69
+ }
70
+ return t2;
71
+ }
72
+ export default TsingrocTheme;
@@ -0,0 +1,42 @@
1
+ import { type ButtonProps, type DropdownProps } from "antd";
2
+ export interface UserButtonProps extends ButtonProps {
3
+ /**
4
+ * 是否显示为缩小形态(只显示头像)。
5
+ * @default false
6
+ */
7
+ compact?: boolean;
8
+ /**
9
+ * 使用边栏布局还是顶栏布局。
10
+ * @default "sidebar"
11
+ */
12
+ layout?: "sidebar" | "header";
13
+ /** 点击“账户”时的操作。若省略,默认通过 Casdoor SDK 获取用户主页链接并跳转。*/
14
+ onOpenProfile?: () => void;
15
+ /**
16
+ * 点击“登出”时的操作。默认先登出,然后跳转到主页。
17
+ *
18
+ * @default
19
+ * () => {
20
+ * auth.logout(); // auth = useAuth()
21
+ * location.href = "/";
22
+ * }
23
+ */
24
+ onLogout?: () => void;
25
+ /**
26
+ * 下拉菜单的属性,见 [Ant Design 文档][1]。你可以在这里覆盖弹出菜单的内容和样式。
27
+ *
28
+ * [1]: https://ant-design.antgroup.com/components/dropdown-cn
29
+ */
30
+ dropdownProps?: DropdownProps;
31
+ }
32
+ /**
33
+ * 显示用户信息的按钮,点击弹出登出或跳转到账户页的菜单。
34
+ * 该组件必须包裹在 {@linkcode AuthProvider} 内,并且经过 {@linkcode AuthCheck} 验证后,
35
+ * 才能正常显示用户信息,否则只会显示占位数据。
36
+ *
37
+ * 除了文档中列出的属性以外,该组件会把额外的属性传递给内部的 [`Button`][1] 组件。
38
+ *
39
+ * [1]: https://ant-design.antgroup.com/components/button-cn
40
+ */
41
+ declare function UserButton(props: UserButtonProps): import("react/jsx-runtime").JSX.Element;
42
+ export default UserButton;
@@ -0,0 +1,105 @@
1
+ import { Avatar, Button, Dropdown, theme } from "antd";
2
+ import { DownOutlined, LogoutOutlined, UpOutlined, UserOutlined } from "@ant-design/icons";
3
+ import { AuthCheck,
4
+ // eslint-disable-line @typescript-eslint/no-unused-vars
5
+ AuthProvider,
6
+ // eslint-disable-line @typescript-eslint/no-unused-vars
7
+ useAuth } from "./Auth";
8
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ /**
10
+ * 显示用户信息的按钮,点击弹出登出或跳转到账户页的菜单。
11
+ * 该组件必须包裹在 {@linkcode AuthProvider} 内,并且经过 {@linkcode AuthCheck} 验证后,
12
+ * 才能正常显示用户信息,否则只会显示占位数据。
13
+ *
14
+ * 除了文档中列出的属性以外,该组件会把额外的属性传递给内部的 [`Button`][1] 组件。
15
+ *
16
+ * [1]: https://ant-design.antgroup.com/components/button-cn
17
+ */
18
+ function UserButton(props) {
19
+ const {
20
+ token
21
+ } = theme.useToken();
22
+ const auth = useAuth("UserButton");
23
+ const {
24
+ compact,
25
+ layout = "sidebar",
26
+ onOpenProfile = auth.mode === "casdoor" ? () => {
27
+ const account = auth.accessToken === undefined ? undefined : {
28
+ accessToken: auth.accessToken
29
+ };
30
+ location.href = auth.sdk.getMyProfileUrl(account, location.href);
31
+ } : undefined,
32
+ onLogout = () => {
33
+ auth.logout();
34
+ location.href = "/";
35
+ },
36
+ dropdownProps,
37
+ ...rest
38
+ } = props;
39
+ return /*#__PURE__*/_jsx(Dropdown, {
40
+ trigger: ["click"],
41
+ placement: layout === "sidebar" ? "topLeft" : "bottomRight",
42
+ ...dropdownProps,
43
+ menu: {
44
+ items: [onOpenProfile ? {
45
+ key: "profile",
46
+ label: /*#__PURE__*/_jsx(_Fragment, {
47
+ children: "\u8D26\u6237"
48
+ }),
49
+ // 如果使用字符串,在缩小时会被裁剪,即使宽度足够
50
+ icon: /*#__PURE__*/_jsx(UserOutlined, {}),
51
+ title: "",
52
+ // 若不设置,在缩小时总是会显示工具提示,即使宽度足够
53
+ onClick: onOpenProfile
54
+ } : null, {
55
+ key: "logout",
56
+ icon: /*#__PURE__*/_jsx(LogoutOutlined, {}),
57
+ label: /*#__PURE__*/_jsx(_Fragment, {
58
+ children: "\u9000\u51FA\u767B\u5F55"
59
+ }),
60
+ title: "",
61
+ onClick: onLogout
62
+ }],
63
+ ...dropdownProps?.menu,
64
+ style: {
65
+ minWidth: "100%",
66
+ ...dropdownProps?.menu?.style
67
+ }
68
+ },
69
+ children: /*#__PURE__*/_jsx(Button, {
70
+ type: "text",
71
+ icon: /*#__PURE__*/_jsx(Avatar, {
72
+ alt: "\u5934\u50CF",
73
+ src: auth.mode === "casdoor" ? auth.userInfo?.picture : undefined,
74
+ icon: /*#__PURE__*/_jsx(UserOutlined, {})
75
+ }),
76
+ ...rest,
77
+ styles: {
78
+ icon: {
79
+ display: "inline-flex",
80
+ alignItems: "center",
81
+ ...rest.styles?.icon
82
+ }
83
+ },
84
+ style: {
85
+ margin: token.marginXXS,
86
+ ...(layout === "sidebar" ? {
87
+ width: "auto",
88
+ padding: token.paddingXXS
89
+ } : {
90
+ paddingBlock: token.padding + token.paddingXS
91
+ }),
92
+ ...rest.style
93
+ },
94
+ children: !compact && /*#__PURE__*/_jsxs(_Fragment, {
95
+ children: [/*#__PURE__*/_jsx("span", {
96
+ style: {
97
+ marginRight: token.marginXXS
98
+ },
99
+ children: (auth.mode === "casdoor" ? auth.userInfo?.name ?? auth.userInfo?.prefered_username : auth.userInfo?.displayName ?? auth.userInfo?.username) ?? "平台用户"
100
+ }), layout === "sidebar" ? /*#__PURE__*/_jsx(UpOutlined, {}) : /*#__PURE__*/_jsx(DownOutlined, {})]
101
+ })
102
+ })
103
+ });
104
+ }
105
+ export default UserButton;
@@ -0,0 +1,7 @@
1
+ import type { HTMLAttributes } from "react";
2
+ export interface VerticalColorLegendProps extends HTMLAttributes<HTMLDivElement> {
3
+ title?: string;
4
+ palette: [number, [number, number, number]][];
5
+ }
6
+ declare function VerticalColorLegend(props: VerticalColorLegendProps): import("react/jsx-runtime").JSX.Element;
7
+ export default VerticalColorLegend;