@hsu-react/ui 0.0.7 → 0.0.9

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 (53) hide show
  1. package/es/components/Chart/Bar/index.d.ts +5 -1
  2. package/es/components/Chart/Bar/index.js +84 -9
  3. package/es/components/Chart/Line/index.d.ts +5 -1
  4. package/es/components/Chart/Line/index.js +84 -9
  5. package/es/components/Chart/_utils/autoSmooth.d.ts +2 -0
  6. package/es/components/Chart/_utils/autoSmooth.js +12 -2
  7. package/es/components/Chart/_utils/cartesian.d.ts +11 -0
  8. package/es/components/Chart/_utils/cartesian.js +19 -0
  9. package/es/components/Chart/chartUtils/chartTooltipFormatter.d.ts +2 -0
  10. package/es/components/Chart/chartUtils/chartTooltipFormatter.js +13 -3
  11. package/es/components/Chart/chartUtils/index.d.ts +5 -2
  12. package/es/components/Chart/chartUtils/index.js +3 -1
  13. package/es/components/Chart/chartUtils/useDataZoomWindow.d.ts +19 -0
  14. package/es/components/Chart/chartUtils/useDataZoomWindow.js +37 -0
  15. package/es/components/Chart/chartUtils/useLegendSelection.d.ts +14 -0
  16. package/es/components/Chart/chartUtils/useLegendSelection.js +35 -0
  17. package/es/components/Modal/index.module.scss +1 -0
  18. package/es/components/Panel/ListPanel/ListModalPanel/index.js +33 -5
  19. package/es/components/Panel/ListPanel/ListModalPanel/index.module.scss +17 -2
  20. package/es/components/Panel/ListPanel/index.module.scss +11 -12
  21. package/lib/components/Chart/Bar/index.d.ts +5 -1
  22. package/lib/components/Chart/Bar/index.js +68 -4
  23. package/lib/components/Chart/Line/index.d.ts +5 -1
  24. package/lib/components/Chart/Line/index.js +68 -4
  25. package/lib/components/Chart/_utils/autoSmooth.d.ts +2 -0
  26. package/lib/components/Chart/_utils/autoSmooth.js +11 -1
  27. package/lib/components/Chart/_utils/cartesian.d.ts +11 -0
  28. package/lib/components/Chart/_utils/cartesian.js +21 -1
  29. package/lib/components/Chart/chartUtils/chartTooltipFormatter.d.ts +2 -0
  30. package/lib/components/Chart/chartUtils/chartTooltipFormatter.js +5 -3
  31. package/lib/components/Chart/chartUtils/index.d.ts +5 -2
  32. package/lib/components/Chart/chartUtils/index.js +14 -0
  33. package/lib/components/Chart/chartUtils/useDataZoomWindow.d.ts +19 -0
  34. package/lib/components/Chart/chartUtils/useDataZoomWindow.js +31 -0
  35. package/lib/components/Chart/chartUtils/useLegendSelection.d.ts +14 -0
  36. package/lib/components/Chart/chartUtils/useLegendSelection.js +26 -0
  37. package/lib/components/Modal/index.module.scss +1 -0
  38. package/lib/components/Panel/ListPanel/ListModalPanel/index.js +21 -2
  39. package/lib/components/Panel/ListPanel/ListModalPanel/index.module.scss +17 -2
  40. package/lib/components/Panel/ListPanel/index.module.scss +11 -12
  41. package/package.json +2 -2
  42. package/src/components/Chart/Bar/index.tsx +132 -2
  43. package/src/components/Chart/Line/index.tsx +132 -2
  44. package/src/components/Chart/_utils/autoSmooth.ts +181 -164
  45. package/src/components/Chart/_utils/cartesian.ts +28 -0
  46. package/src/components/Chart/chartUtils/chartTooltipFormatter.ts +11 -2
  47. package/src/components/Chart/chartUtils/index.ts +53 -37
  48. package/src/components/Chart/chartUtils/useDataZoomWindow.ts +61 -0
  49. package/src/components/Chart/chartUtils/useLegendSelection.ts +35 -0
  50. package/src/components/Modal/index.module.scss +1 -0
  51. package/src/components/Panel/ListPanel/ListModalPanel/index.module.scss +17 -2
  52. package/src/components/Panel/ListPanel/ListModalPanel/index.tsx +261 -233
  53. package/src/components/Panel/ListPanel/index.module.scss +11 -12
@@ -1,233 +1,261 @@
1
- import React, { ReactNode, useEffect, useMemo, useState } from "react";
2
- import Search, {
3
- SearchModeKeys,
4
- SearchModePropsMap,
5
- } from "../../../Search";
6
- import Table, { ColumnsType, TableProps } from "../../../Table";
7
-
8
- import { ChakraButtonProps as BasicButtonProps } from "../../../Button";
9
- import { TabBarProps } from "../../../TabBar";
10
- import classNames from "classnames";
11
- import { cloneDeep } from "lodash";
12
- import styles from "./index.module.scss";
13
- import usePermissions from "../../../../hooks/usePermissions";
14
- import Modal, { ModalProps } from "../../../Modal";
15
- import ToolBar from "../_components/ToolBar";
16
- import ColumnMgt from "../_components/ColumnMgt";
17
-
18
- interface ButtonProps extends Omit<BasicButtonProps, "children" | "title"> {
19
- title?: ReactNode;
20
- children?: ReactNode;
21
- }
22
-
23
- interface TableTools {
24
- onTableRefresh?: () => void;
25
- columnMgt?: IColumnMgt;
26
- }
27
-
28
- export interface ListModalPanelTabelProps extends Omit<TableProps, "title"> {
29
- title?: string;
30
- buttonGroup?: ButtonProps[];
31
- tabBarProps?: TabBarProps;
32
- tableTools?: TableTools;
33
- tableContainerClassName?: string;
34
- tips?: ReactNode;
35
- otherTool?: ReactNode;
36
- }
37
-
38
- interface ColumnMgtDataSource {
39
- hidden: boolean;
40
- title: string;
41
- dataIndex: string;
42
- sort: number;
43
- width?: number;
44
- ellipsis?: boolean;
45
- }
46
-
47
- export interface IColumnMgt {
48
- columnCount?: {
49
- max?: number;
50
- min?: number;
51
- };
52
- fixedDisplay?: string[];
53
- fixedPosition?: string[];
54
- onSelectionChange?: (
55
- selectedDataIndexes: string[],
56
- dataSource: Array<ColumnMgtDataSource>,
57
- ) => void;
58
- }
59
-
60
- export interface ListModalPanelProps<
61
- T extends SearchModeKeys = "Default",
62
- > extends ModalProps {
63
- modalClassName?: string;
64
- className?: string;
65
- searchProps?: SearchModePropsMap[T];
66
- /** Search 组件模式:default-基础 | Advanced-高级筛选 | Collapsible-可折叠 | WithFilter-带筛选器 | WithMore-带更多项 | Card-卡片式 */
67
- searchMode?: T;
68
- tableProps?: ListModalPanelTabelProps;
69
- hasPermi?: string[];
70
- extraContent?: ReactNode;
71
- }
72
-
73
- const ListModalPanel: React.FC<ListModalPanelProps<SearchModeKeys>> = (
74
- props,
75
- ) => {
76
- const {
77
- modalClassName,
78
- className,
79
- searchProps,
80
- searchMode = "Default",
81
- tableProps = {},
82
- hasPermi,
83
- extraContent,
84
- ...modalConfig
85
- } = props;
86
- const {
87
- title,
88
- buttonGroup,
89
- className: tableClassName,
90
- columns,
91
- tabBarProps,
92
- tableTools = {},
93
- tableContainerClassName,
94
- tips,
95
- otherTool,
96
- ...tableConfig
97
- } = tableProps;
98
- const { columnMgt } = tableTools;
99
- const { permitted } = usePermissions(hasPermi);
100
- const [_columns, setColumns] = useState<ColumnsType | undefined>(columns);
101
- const [showColumnMgt, setShowColumnMgt] = useState<boolean>(false);
102
-
103
- useEffect(() => {
104
- if (columnMgt && columns?.length) {
105
- const _columns = columns?.map((col) => {
106
- return {
107
- ...col,
108
- sort: !col?.dataIndex
109
- ? typeof col.sort === "number"
110
- ? col.sort
111
- : 999
112
- : 0,
113
- };
114
- });
115
-
116
- setColumns(_columns);
117
- } else {
118
- setColumns(columns);
119
- }
120
- }, [columnMgt, columns]);
121
-
122
- // 根据 searchMode 渲染对应的 Search 组件
123
- const SearchComponent = useMemo(() => {
124
- const searchClassName = classNames(searchProps?.className, styles.search);
125
-
126
- switch (searchMode) {
127
- case "Advanced":
128
- return (
129
- <Search.Advanced
130
- baseWidth={1400}
131
- {...(searchProps as SearchModePropsMap["Advanced"])}
132
- className={searchClassName}
133
- />
134
- );
135
- case "Collapsible":
136
- return (
137
- <Search.Collapsible
138
- baseWidth={1400}
139
- {...(searchProps as SearchModePropsMap["Collapsible"])}
140
- className={searchClassName}
141
- />
142
- );
143
- case "WithFilter":
144
- return (
145
- <Search.WithFilter
146
- baseWidth={1400}
147
- {...(searchProps as SearchModePropsMap["WithFilter"])}
148
- className={searchClassName}
149
- />
150
- );
151
- case "WithMore":
152
- return (
153
- <Search.WithMore
154
- baseWidth={1400}
155
- {...(searchProps as SearchModePropsMap["WithMore"])}
156
- className={searchClassName}
157
- />
158
- );
159
- case "Card":
160
- return (
161
- <Search.Card
162
- {...(searchProps as SearchModePropsMap["Card"])}
163
- className={searchClassName}
164
- />
165
- );
166
- default:
167
- return (
168
- <Search
169
- baseWidth={1400}
170
- {...(searchProps as SearchModePropsMap["Default"])}
171
- className={searchClassName}
172
- />
173
- );
174
- }
175
- }, [searchMode, searchProps]);
176
-
177
- if (!permitted) {
178
- return null;
179
- }
180
-
181
- return (
182
- <>
183
- <Modal
184
- width={1400}
185
- className={classNames(modalClassName)}
186
- {...modalConfig}
187
- >
188
- <div className={classNames(styles.ListModalPanel, className)}>
189
- {extraContent}
190
- {SearchComponent}
191
- <div
192
- className={classNames(
193
- styles.tableContainer,
194
- tableContainerClassName,
195
- )}
196
- >
197
- <ToolBar
198
- columns={columns}
199
- title={title}
200
- tabBarProps={tabBarProps}
201
- buttonGroup={buttonGroup}
202
- tableTools={tableTools}
203
- setShowColumnMgt={setShowColumnMgt}
204
- tips={tips}
205
- otherTool={otherTool}
206
- />
207
- <Table
208
- className={`${styles.table} ${tableClassName ?? ""}`}
209
- {...{
210
- scroll: true,
211
- serialNumberColumn: true,
212
- bordered: true,
213
- ...tableConfig,
214
- columns: _columns,
215
- }}
216
- />
217
- </div>
218
- </div>
219
- </Modal>
220
- <ColumnMgt
221
- open={showColumnMgt}
222
- onClose={() => setShowColumnMgt(false)}
223
- onOk={(columns) => setColumns(cloneDeep(columns))}
224
- columns={_columns}
225
- defaultColumns={columns}
226
- onSelectionChange={columnMgt?.onSelectionChange}
227
- {...columnMgt}
228
- />
229
- </>
230
- );
231
- };
232
-
233
- export default ListModalPanel;
1
+ import React, { ReactNode, useEffect, useMemo, useState } from "react";
2
+ import Search, {
3
+ SearchModeKeys,
4
+ SearchModePropsMap,
5
+ } from "../../../Search";
6
+ import Table, { ColumnsType, TableProps } from "../../../Table";
7
+
8
+ import { ChakraButtonProps as BasicButtonProps } from "../../../Button";
9
+ import { TabBarProps } from "../../../TabBar";
10
+ import {
11
+ FullscreenExitOutlined,
12
+ FullscreenOutlined,
13
+ } from "@ant-design/icons";
14
+ import classNames from "classnames";
15
+ import { cloneDeep } from "lodash";
16
+ import styles from "./index.module.scss";
17
+ import usePermissions from "../../../../hooks/usePermissions";
18
+ import Modal, { ModalProps } from "../../../Modal";
19
+ import ToolBar from "../_components/ToolBar";
20
+ import ColumnMgt from "../_components/ColumnMgt";
21
+
22
+ interface ButtonProps extends Omit<BasicButtonProps, "children" | "title"> {
23
+ title?: ReactNode;
24
+ children?: ReactNode;
25
+ }
26
+
27
+ interface TableTools {
28
+ onTableRefresh?: () => void;
29
+ columnMgt?: IColumnMgt;
30
+ }
31
+
32
+ export interface ListModalPanelTabelProps extends Omit<TableProps, "title"> {
33
+ title?: string;
34
+ buttonGroup?: ButtonProps[];
35
+ tabBarProps?: TabBarProps;
36
+ tableTools?: TableTools;
37
+ tableContainerClassName?: string;
38
+ tips?: ReactNode;
39
+ otherTool?: ReactNode;
40
+ }
41
+
42
+ interface ColumnMgtDataSource {
43
+ hidden: boolean;
44
+ title: string;
45
+ dataIndex: string;
46
+ sort: number;
47
+ width?: number;
48
+ ellipsis?: boolean;
49
+ }
50
+
51
+ export interface IColumnMgt {
52
+ columnCount?: {
53
+ max?: number;
54
+ min?: number;
55
+ };
56
+ fixedDisplay?: string[];
57
+ fixedPosition?: string[];
58
+ onSelectionChange?: (
59
+ selectedDataIndexes: string[],
60
+ dataSource: Array<ColumnMgtDataSource>,
61
+ ) => void;
62
+ }
63
+
64
+ export interface ListModalPanelProps<
65
+ T extends SearchModeKeys = "Default",
66
+ > extends ModalProps {
67
+ modalClassName?: string;
68
+ className?: string;
69
+ searchProps?: SearchModePropsMap[T];
70
+ /** Search 组件模式:default-基础 | Advanced-高级筛选 | Collapsible-可折叠 | WithFilter-带筛选器 | WithMore-带更多项 | Card-卡片式 */
71
+ searchMode?: T;
72
+ tableProps?: ListModalPanelTabelProps;
73
+ hasPermi?: string[];
74
+ extraContent?: ReactNode;
75
+ }
76
+
77
+ const ListModalPanel: React.FC<ListModalPanelProps<SearchModeKeys>> = (
78
+ props,
79
+ ) => {
80
+ const {
81
+ modalClassName,
82
+ className,
83
+ searchProps,
84
+ searchMode = "Default",
85
+ tableProps = {},
86
+ hasPermi,
87
+ extraContent,
88
+ ...modalConfig
89
+ } = props;
90
+ const {
91
+ title,
92
+ buttonGroup,
93
+ className: tableClassName,
94
+ columns,
95
+ tabBarProps,
96
+ tableTools = {},
97
+ tableContainerClassName,
98
+ tips,
99
+ otherTool,
100
+ ...tableConfig
101
+ } = tableProps;
102
+ const { columnMgt } = tableTools;
103
+ const { permitted } = usePermissions(hasPermi);
104
+ const [_columns, setColumns] = useState<ColumnsType | undefined>(columns);
105
+ const [showColumnMgt, setShowColumnMgt] = useState<boolean>(false);
106
+ const [isFullscreen, setIsFullscreen] = useState<boolean>(false);
107
+
108
+ useEffect(() => {
109
+ if (modalConfig.open) {
110
+ setIsFullscreen(false);
111
+ }
112
+ }, [modalConfig.open]);
113
+
114
+ useEffect(() => {
115
+ if (columnMgt && columns?.length) {
116
+ const _columns = columns?.map((col) => {
117
+ return {
118
+ ...col,
119
+ sort: !col?.dataIndex
120
+ ? typeof col.sort === "number"
121
+ ? col.sort
122
+ : 999
123
+ : 0,
124
+ };
125
+ });
126
+
127
+ setColumns(_columns);
128
+ } else {
129
+ setColumns(columns);
130
+ }
131
+ }, [columnMgt, columns]);
132
+
133
+ // 根据 searchMode 渲染对应的 Search 组件
134
+ const SearchComponent = useMemo(() => {
135
+ const searchClassName = classNames(searchProps?.className, styles.search);
136
+
137
+ switch (searchMode) {
138
+ case "Advanced":
139
+ return (
140
+ <Search.Advanced
141
+ baseWidth={1400}
142
+ {...(searchProps as SearchModePropsMap["Advanced"])}
143
+ className={searchClassName}
144
+ />
145
+ );
146
+ case "Collapsible":
147
+ return (
148
+ <Search.Collapsible
149
+ baseWidth={1400}
150
+ {...(searchProps as SearchModePropsMap["Collapsible"])}
151
+ className={searchClassName}
152
+ />
153
+ );
154
+ case "WithFilter":
155
+ return (
156
+ <Search.WithFilter
157
+ baseWidth={1400}
158
+ {...(searchProps as SearchModePropsMap["WithFilter"])}
159
+ className={searchClassName}
160
+ />
161
+ );
162
+ case "WithMore":
163
+ return (
164
+ <Search.WithMore
165
+ baseWidth={1400}
166
+ {...(searchProps as SearchModePropsMap["WithMore"])}
167
+ className={searchClassName}
168
+ />
169
+ );
170
+ case "Card":
171
+ return (
172
+ <Search.Card
173
+ {...(searchProps as SearchModePropsMap["Card"])}
174
+ className={searchClassName}
175
+ />
176
+ );
177
+ default:
178
+ return (
179
+ <Search
180
+ baseWidth={1400}
181
+ {...(searchProps as SearchModePropsMap["Default"])}
182
+ className={searchClassName}
183
+ />
184
+ );
185
+ }
186
+ }, [searchMode, searchProps]);
187
+
188
+ if (!permitted) {
189
+ return null;
190
+ }
191
+
192
+ return (
193
+ <>
194
+ <Modal
195
+ {...modalConfig}
196
+ width={isFullscreen ? "100vw" : (modalConfig.width ?? 1400)}
197
+ {...(isFullscreen ? { full: true } : {})}
198
+ className={classNames(styles.modal, modalClassName, {
199
+ [styles.fullscreen]: isFullscreen,
200
+ })}
201
+ titleButtonGroup={[
202
+ {
203
+ type: "text",
204
+ icon: isFullscreen ? (
205
+ <FullscreenExitOutlined />
206
+ ) : (
207
+ <FullscreenOutlined />
208
+ ),
209
+ title: isFullscreen ? "退出全屏" : "全屏",
210
+ onClick: () => setIsFullscreen((v) => !v),
211
+ },
212
+ ...(modalConfig.titleButtonGroup ?? []),
213
+ ]}
214
+ >
215
+ <div className={classNames(styles.ListModalPanel, className)}>
216
+ {extraContent}
217
+ {SearchComponent}
218
+ <div
219
+ className={classNames(
220
+ styles.tableContainer,
221
+ tableContainerClassName,
222
+ )}
223
+ >
224
+ <ToolBar
225
+ columns={columns}
226
+ title={title}
227
+ tabBarProps={tabBarProps}
228
+ buttonGroup={buttonGroup}
229
+ tableTools={tableTools}
230
+ setShowColumnMgt={setShowColumnMgt}
231
+ tips={tips}
232
+ otherTool={otherTool}
233
+ />
234
+ <Table
235
+ className={`${styles.table} ${tableClassName ?? ""}`}
236
+ {...{
237
+ scroll: true,
238
+ serialNumberColumn: true,
239
+ bordered: true,
240
+ fillPanel: true,
241
+ ...tableConfig,
242
+ columns: _columns,
243
+ }}
244
+ />
245
+ </div>
246
+ </div>
247
+ </Modal>
248
+ <ColumnMgt
249
+ open={showColumnMgt}
250
+ onClose={() => setShowColumnMgt(false)}
251
+ onOk={(columns) => setColumns(cloneDeep(columns))}
252
+ columns={_columns}
253
+ defaultColumns={columns}
254
+ onSelectionChange={columnMgt?.onSelectionChange}
255
+ {...columnMgt}
256
+ />
257
+ </>
258
+ );
259
+ };
260
+
261
+ export default ListModalPanel;
@@ -87,7 +87,7 @@
87
87
 
88
88
  width: 100%;
89
89
  min-height: 0px;
90
- padding: 14px 16px;
90
+ padding: 10px;
91
91
 
92
92
  background: var(--cf-surface);
93
93
 
@@ -102,23 +102,22 @@
102
102
  align-items: center;
103
103
  justify-content: space-between;
104
104
  column-gap: 10px;
105
+ }
105
106
 
106
- padding: 10px;
107
+ // 页面级页签:无底色容器,页签拆成独立圆角块、块间留空;
108
+ // margin/radius 需 !important 压过 TabBar 内部的连体分段样式(负 margin + 首尾切角)
109
+ .headerTabBar {
110
+ column-gap: 4px;
107
111
 
108
- background: var(--cf-subtle);
112
+ > div {
113
+ margin-left: 0 !important;
114
+ border-radius: 6px !important;
109
115
 
110
- border-radius: 8px 8px 0px 0px;
111
- border: 1px solid var(--cf-border);
116
+ background: var(--cf-surface);
117
+ }
112
118
  }
113
119
 
114
120
  &.hasHeaderTabBar {
115
- .search {
116
- padding: 10px;
117
- margin-top: -10px;
118
-
119
- border-radius: 0px 0px 8px 8px;
120
- }
121
-
122
121
  &:not(:has(.search)) {
123
122
  .headerTabBarContainer {
124
123
  border-radius: 8px;