@hsu-react/ui 0.0.1 → 0.0.3
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/README.md +2 -0
- package/es/components/ChainGraph/_components/SearchSelect/index.js +13 -10
- package/es/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
- package/es/components/ChainGraph/index.module.less +1 -1
- package/es/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
- package/es/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
- package/es/components/Chat/ChatInput/index.module.less +2 -2
- package/es/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
- package/es/components/Checkbox/CheckboxGroup/index.module.less +16 -16
- package/es/components/Checkbox/index.module.less +13 -13
- package/es/components/CodeMirror/index.module.less +4 -4
- package/es/components/DatePicker/RangePicker/index.module.less +1 -1
- package/es/components/DatePicker/StepPicker/index.module.less +1 -1
- package/es/components/DatePicker/index.module.less +2 -1
- package/es/components/Form/DrawerForm/index.module.less +2 -2
- package/es/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -2
- package/es/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
- package/es/components/FormItem/FormRadio/index.module.less +9 -9
- package/es/components/FormItem/FormSegmented/index.module.less +2 -2
- package/es/components/FormItem/FormUpload/index.module.less +4 -4
- package/es/components/FormItem/ItemContainer/index.module.less +22 -22
- package/es/components/Icon/index.js +9 -24
- package/es/components/Input/Number/index.module.less +9 -9
- package/es/components/Input/Password/index.module.less +3 -3
- package/es/components/Input/Range/index.module.less +4 -4
- package/es/components/Input/Search/index.module.less +5 -5
- package/es/components/Input/TextArea/index.module.less +5 -5
- package/es/components/Input/index.module.less +7 -4
- package/es/components/Modal/index.module.less +2 -2
- package/es/components/Operate/index.module.less +2 -2
- package/es/components/Panel/IframePanel/index.module.less +1 -1
- package/es/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
- package/es/components/Search/index.module.less +2 -2
- package/es/components/Select/AutoCompleteSelect/index.module.less +35 -35
- package/es/components/Select/IconSelect/index.module.less +3 -3
- package/es/components/Select/TreeSelect/index.module.less +17 -17
- package/es/components/Select/_utils/getElementPosition.d.ts +6 -2
- package/es/components/Select/_utils/getElementPosition.js +8 -6
- package/es/components/Select/index.module.less +37 -34
- package/es/components/Slider/index.module.less +5 -4
- package/es/components/Spreadsheet/index.module.less +4 -4
- package/es/components/Switch/index.js +12 -8
- package/es/components/Switch/index.module.less +7 -0
- package/es/components/Table/_components/Pagination/index.module.less +23 -23
- package/es/components/Table/index.module.less +61 -61
- package/es/components/Tree/index.module.less +11 -11
- package/es/components/Upload/index.module.less +3 -3
- package/es/styles/antd-overload.less +1 -1
- package/lib/components/ChainGraph/_components/SearchSelect/index.js +10 -7
- package/lib/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
- package/lib/components/ChainGraph/index.module.less +1 -1
- package/lib/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
- package/lib/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
- package/lib/components/Chat/ChatInput/index.module.less +2 -2
- package/lib/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
- package/lib/components/Checkbox/CheckboxGroup/index.module.less +16 -16
- package/lib/components/Checkbox/index.module.less +13 -13
- package/lib/components/CodeMirror/index.module.less +4 -4
- package/lib/components/DatePicker/RangePicker/index.module.less +1 -1
- package/lib/components/DatePicker/StepPicker/index.module.less +1 -1
- package/lib/components/DatePicker/index.module.less +2 -1
- package/lib/components/Form/DrawerForm/index.module.less +2 -2
- package/lib/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -1
- package/lib/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
- package/lib/components/FormItem/FormRadio/index.module.less +9 -9
- package/lib/components/FormItem/FormSegmented/index.module.less +2 -2
- package/lib/components/FormItem/FormUpload/index.module.less +4 -4
- package/lib/components/FormItem/ItemContainer/index.module.less +22 -22
- package/lib/components/Icon/index.js +9 -27
- package/lib/components/Input/Number/index.module.less +9 -9
- package/lib/components/Input/Password/index.module.less +3 -3
- package/lib/components/Input/Range/index.module.less +4 -4
- package/lib/components/Input/Search/index.module.less +5 -5
- package/lib/components/Input/TextArea/index.module.less +5 -5
- package/lib/components/Input/index.module.less +7 -4
- package/lib/components/Modal/index.module.less +2 -2
- package/lib/components/Operate/index.module.less +2 -2
- package/lib/components/Panel/IframePanel/index.module.less +1 -1
- package/lib/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
- package/lib/components/Search/index.module.less +2 -2
- package/lib/components/Select/AutoCompleteSelect/index.module.less +35 -35
- package/lib/components/Select/IconSelect/index.module.less +3 -3
- package/lib/components/Select/TreeSelect/index.module.less +17 -17
- package/lib/components/Select/_utils/getElementPosition.d.ts +6 -2
- package/lib/components/Select/_utils/getElementPosition.js +8 -6
- package/lib/components/Select/index.module.less +37 -34
- package/lib/components/Slider/index.module.less +5 -4
- package/lib/components/Spreadsheet/index.module.less +4 -4
- package/lib/components/Switch/index.js +8 -4
- package/lib/components/Switch/index.module.less +7 -0
- package/lib/components/Table/_components/Pagination/index.module.less +23 -23
- package/lib/components/Table/index.module.less +61 -61
- package/lib/components/Tree/index.module.less +11 -11
- package/lib/components/Upload/index.module.less +3 -3
- package/lib/styles/antd-overload.less +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.md +20 -4
- package/src/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
- package/src/components/ChainGraph/_components/SearchSelect/index.tsx +18 -16
- package/src/components/ChainGraph/index.md +67 -1
- package/src/components/ChainGraph/index.module.less +1 -1
- package/src/components/Chart/index.md +351 -1
- package/src/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
- package/src/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
- package/src/components/Chat/ChatInput/index.module.less +2 -2
- package/src/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
- package/src/components/Chat/index.md +140 -1
- package/src/components/Checkbox/CheckboxGroup/index.module.less +16 -16
- package/src/components/Checkbox/index.md +85 -1
- package/src/components/Checkbox/index.module.less +13 -13
- package/src/components/CodeMirror/index.md +41 -1
- package/src/components/CodeMirror/index.module.less +4 -4
- package/src/components/Copy/index.md +1 -1
- package/src/components/DatePicker/RangePicker/index.module.less +1 -1
- package/src/components/DatePicker/StepPicker/index.module.less +1 -1
- package/src/components/DatePicker/index.md +82 -1
- package/src/components/DatePicker/index.module.less +2 -1
- package/src/components/Descriptions/index.md +45 -1
- package/src/components/Editor/index.md +40 -1
- package/src/components/FileCol/index.md +24 -1
- package/src/components/FilePreview/index.md +45 -1
- package/src/components/FlexFill/index.md +46 -1
- package/src/components/Form/DrawerForm/index.module.less +2 -2
- package/src/components/Form/index.md +179 -1
- package/src/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
- package/src/components/FormItem/FormInput/FormPasswordStrength/index.tsx +2 -2
- package/src/components/FormItem/FormRadio/index.module.less +9 -9
- package/src/components/FormItem/FormSegmented/index.module.less +2 -2
- package/src/components/FormItem/FormUpload/index.module.less +4 -4
- package/src/components/FormItem/ItemContainer/index.module.less +22 -22
- package/src/components/FormItem/index.md +514 -1
- package/src/components/Icon/index.md +24 -4
- package/src/components/Icon/index.tsx +9 -37
- package/src/components/Input/Number/index.module.less +9 -9
- package/src/components/Input/Password/index.module.less +3 -3
- package/src/components/Input/Range/index.module.less +4 -4
- package/src/components/Input/Search/index.module.less +5 -5
- package/src/components/Input/TextArea/index.module.less +5 -5
- package/src/components/Input/index.md +148 -1
- package/src/components/Input/index.module.less +7 -4
- package/src/components/Markdown/index.md +73 -1
- package/src/components/Modal/index.md +43 -1
- package/src/components/Modal/index.module.less +2 -2
- package/src/components/Operate/index.md +43 -1
- package/src/components/Operate/index.module.less +2 -2
- package/src/components/Panel/IframePanel/index.module.less +1 -1
- package/src/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
- package/src/components/Panel/index.md +193 -1
- package/src/components/Search/index.md +248 -1
- package/src/components/Search/index.module.less +2 -2
- package/src/components/SecondConf/index.md +39 -1
- package/src/components/Select/AutoCompleteSelect/index.module.less +35 -35
- package/src/components/Select/IconSelect/index.module.less +3 -3
- package/src/components/Select/TreeSelect/index.module.less +17 -17
- package/src/components/Select/_utils/getElementPosition.ts +8 -6
- package/src/components/Select/index.md +47 -1
- package/src/components/Select/index.module.less +37 -34
- package/src/components/Slider/index.md +28 -1
- package/src/components/Slider/index.module.less +5 -4
- package/src/components/Spreadsheet/index.md +42 -1
- package/src/components/Spreadsheet/index.module.less +4 -4
- package/src/components/Switch/index.md +33 -1
- package/src/components/Switch/index.module.less +7 -0
- package/src/components/Switch/index.tsx +14 -11
- package/src/components/TabBar/index.md +70 -1
- package/src/components/Table/_components/Pagination/index.module.less +23 -23
- package/src/components/Table/index.md +60 -1
- package/src/components/Table/index.module.less +61 -61
- package/src/components/Tags/index.md +23 -1
- package/src/components/TextEllipsis/index.md +29 -1
- package/src/components/Tree/index.md +66 -1
- package/src/components/Tree/index.module.less +11 -11
- package/src/components/Upload/index.md +72 -1
- package/src/components/Upload/index.module.less +3 -3
- package/src/styles/antd-overload.less +1 -1
|
@@ -8,10 +8,202 @@ title: Panel 页面容器
|
|
|
8
8
|
|
|
9
9
|
# Panel 页面容器
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
页面级容器集合,封装了「左侧树 + 顶部搜索 + 表格」的列表页、内嵌 iframe 页以及通用内容页等常见布局形态。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Panel } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 子组件一览
|
|
20
|
+
|
|
21
|
+
| 组件 | 说明 |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| `Panel.List` | 列表页容器,集成 `Search`、`Table`、`TabBar`、`Tree`、列管理与工具栏 |
|
|
24
|
+
| `Panel.List.Modal` | 弹窗内的列表页容器,用于在 `Modal` 中复用列表布局 |
|
|
25
|
+
| `Panel.Iframe` | iframe 内容容器,带加载态与全屏按钮 |
|
|
26
|
+
| `Panel.Default` | 通用内容容器,可选左侧树与面包屑 |
|
|
27
|
+
|
|
28
|
+
## 列表页
|
|
29
|
+
|
|
30
|
+
`Panel.List` 通过 `searchProps`(搜索区)、`tableProps`(表格区)组合出标准增删改查列表页。下方为可交互示例:输入姓名搜索会实时过滤行,点击「新增」「编辑」有反馈。
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import React, { useState } from "react";
|
|
34
|
+
import { Panel, Button } from "@hsu-react/ui";
|
|
35
|
+
import { message } from "antd";
|
|
36
|
+
|
|
37
|
+
const ALL = [
|
|
38
|
+
{ id: 1, name: "张三", role: "管理员", status: "启用" },
|
|
39
|
+
{ id: 2, name: "李四", role: "成员", status: "启用" },
|
|
40
|
+
{ id: 3, name: "王五", role: "成员", status: "禁用" },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
export default () => {
|
|
44
|
+
const [data, setData] = useState(ALL);
|
|
45
|
+
|
|
46
|
+
const columns = [
|
|
47
|
+
{ title: "姓名", dataIndex: "name" },
|
|
48
|
+
{ title: "角色", dataIndex: "role" },
|
|
49
|
+
{ title: "状态", dataIndex: "status" },
|
|
50
|
+
{
|
|
51
|
+
title: "操作",
|
|
52
|
+
dataIndex: "op",
|
|
53
|
+
render: (_, row) => (
|
|
54
|
+
<Button type="link" onClick={() => message.info("编辑:" + row.name)}>
|
|
55
|
+
编辑
|
|
56
|
+
</Button>
|
|
57
|
+
),
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
// Panel.List 为页面级宽组件;窄屏时外层横向滚动,避免溢出预览框。
|
|
63
|
+
// overflowY:hidden 去掉垂直滚动条;wrapperClassName 放开组件内层
|
|
64
|
+
// ListPanelWrapper 的 overflow:hidden(否则搜索区右侧约 24px 会被裁)。
|
|
65
|
+
<div style={{ overflowX: "auto", overflowY: "hidden" }}>
|
|
66
|
+
<div style={{ minWidth: 1000, height: 300 }}>
|
|
67
|
+
<Panel.List
|
|
68
|
+
wrapperClassName="hsu-demo-panel-wrapper"
|
|
69
|
+
searchProps={{
|
|
70
|
+
searchItems: [{ type: "INPUT", name: "name", label: "姓名" }],
|
|
71
|
+
onSearch: (v) =>
|
|
72
|
+
setData(ALL.filter((x) => !v.name || x.name.includes(v.name))),
|
|
73
|
+
onReset: () => setData(ALL),
|
|
74
|
+
beforeButtonGroup: [
|
|
75
|
+
{
|
|
76
|
+
title: "新增",
|
|
77
|
+
colorPalette: "blue",
|
|
78
|
+
onClick: () => message.success("点击了新增"),
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
}}
|
|
82
|
+
tableProps={{
|
|
83
|
+
columns,
|
|
84
|
+
dataSource: data,
|
|
85
|
+
rowKey: "id",
|
|
86
|
+
pagination: false,
|
|
87
|
+
scrollAutoHeight: false,
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 内容页
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
import React from "react";
|
|
100
|
+
import { Panel } from "@hsu-react/ui";
|
|
101
|
+
|
|
102
|
+
export default () => (
|
|
103
|
+
// 与列表页一致:外层 overflowX 横向滚动 + overflowY:hidden 去垂直滚动条;
|
|
104
|
+
// wrapperClassName 放开 DefaultPanel 内层的 overflow:hidden。
|
|
105
|
+
<div style={{ overflowX: "auto", overflowY: "hidden" }}>
|
|
106
|
+
<div style={{ minWidth: 1000, height: 200 }}>
|
|
107
|
+
<Panel.Default wrapperClassName="hsu-demo-panel-wrapper">
|
|
108
|
+
<div style={{ padding: 16 }}>这里是通用内容区域(窄屏时可横向滚动查看)</div>
|
|
109
|
+
</Panel.Default>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## 内嵌页
|
|
116
|
+
|
|
117
|
+
`Panel.Iframe` 用于内嵌外部页面,带加载态与全屏按钮(外部站点受 X-Frame-Options 限制,此处仅示意用法):
|
|
118
|
+
|
|
119
|
+
```tsx | pure
|
|
120
|
+
import React from "react";
|
|
121
|
+
import { Panel } from "@hsu-react/ui";
|
|
122
|
+
|
|
123
|
+
export default () => <Panel.Iframe src="https://example.com" fullBtn />;
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## 弹窗内列表
|
|
127
|
+
|
|
128
|
+
`Panel.List.Modal` 在 `Modal` 内复用列表布局,本身继承 `ModalProps`(`open` / `onClose` 等),并通过 `searchProps`、`tableProps` 配置搜索区与表格区。常用于从某条记录弹出其关联子列表。
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import React, { useState } from "react";
|
|
132
|
+
import { Panel, Button } from "@hsu-react/ui";
|
|
133
|
+
|
|
134
|
+
const ALL = [
|
|
135
|
+
{ id: 1, name: "明细一", status: "启用" },
|
|
136
|
+
{ id: 2, name: "明细二", status: "禁用" },
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
export default () => {
|
|
140
|
+
const [open, setOpen] = useState(false);
|
|
141
|
+
const [data, setData] = useState(ALL);
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<>
|
|
145
|
+
<Button type="primary" onClick={() => setOpen(true)}>
|
|
146
|
+
打开子列表
|
|
147
|
+
</Button>
|
|
148
|
+
<Panel.List.Modal
|
|
149
|
+
open={open}
|
|
150
|
+
onCancel={() => setOpen(false)}
|
|
151
|
+
title="关联明细"
|
|
152
|
+
footer={null}
|
|
153
|
+
searchProps={{
|
|
154
|
+
searchItems: [{ type: "INPUT", name: "name", label: "名称" }],
|
|
155
|
+
onSearch: (v) =>
|
|
156
|
+
setData(ALL.filter((x) => !v.name || x.name.includes(v.name))),
|
|
157
|
+
onReset: () => setData(ALL),
|
|
158
|
+
}}
|
|
159
|
+
tableProps={{
|
|
160
|
+
columns: [
|
|
161
|
+
{ title: "名称", dataIndex: "name" },
|
|
162
|
+
{ title: "状态", dataIndex: "status" },
|
|
163
|
+
],
|
|
164
|
+
dataSource: data,
|
|
165
|
+
rowKey: "id",
|
|
166
|
+
pagination: false,
|
|
167
|
+
}}
|
|
168
|
+
/>
|
|
169
|
+
</>
|
|
170
|
+
);
|
|
171
|
+
};
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## API
|
|
175
|
+
|
|
176
|
+
### Panel.List(ListPanelProps)
|
|
177
|
+
|
|
178
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
179
|
+
| --- | --- | --- | --- |
|
|
180
|
+
| searchMode | Search 组件模式:`Default` / `Advanced` / `Collapsible` / `WithFilter` / `WithMore` / `Card` | `SearchModeKeys` | `'Default'` |
|
|
181
|
+
| searchProps | 搜索区配置(随 `searchMode` 变化) | `SearchModePropsMap[T]` | - |
|
|
182
|
+
| tableProps | 表格区配置,含 `title`、`buttonGroup`、`tabBarProps`、`tableTools` 等 | `ListPanelTabelProps` | - |
|
|
183
|
+
| treeProps | 左侧树配置 | `TreeProps` | - |
|
|
184
|
+
| headerTabBarProps | 顶部页签配置 | `TabBarProps` | - |
|
|
185
|
+
| headerTabBarChildren | 顶部页签区自定义内容 | `ReactNode` | - |
|
|
186
|
+
| hasPermi | 权限码,无权限时不渲染 | `string[]` | - |
|
|
187
|
+
| baseTreeBreadcrumb | 树面包屑的基础项 | `BreadcrumbProps['items']` | - |
|
|
188
|
+
| showTreeBreadcrumb | 是否展示树面包屑 | `boolean` | `true` |
|
|
189
|
+
| treeResize | 左侧树可拖拽调宽配置(`enabled`/`defaultWidth`/`minWidth`/`maxWidth`/`minContentWidth`) | `object` | - |
|
|
190
|
+
| className / wrapperClassName | 自定义类名 | `string` | - |
|
|
191
|
+
|
|
192
|
+
### Panel.Iframe(IframePanelProps)
|
|
193
|
+
|
|
194
|
+
继承原生 `<iframe>` 属性,并扩展:
|
|
195
|
+
|
|
196
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
197
|
+
| --- | --- | --- | --- |
|
|
198
|
+
| fullBtn | 是否显示全屏按钮 | `boolean` | - |
|
|
199
|
+
| children | 自定义内容(传入后替代 iframe 渲染) | `ReactNode` | - |
|
|
200
|
+
|
|
201
|
+
### Panel.Default(DefaultPanelProps)
|
|
202
|
+
|
|
203
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
204
|
+
| --- | --- | --- | --- |
|
|
205
|
+
| children | 内容区 | `ReactNode` | - |
|
|
206
|
+
| treeProps | 左侧树配置(传入即展示树) | `TreeProps` | - |
|
|
207
|
+
| baseTreeBreadcrumb | 树面包屑的基础项 | `BreadcrumbProps['items']` | - |
|
|
208
|
+
| showTreeBreadcrumb | 是否展示树面包屑 | `boolean` | `true` |
|
|
209
|
+
| className / contentClassName / wrapperClassName | 自定义类名 | `string` | - |
|
|
@@ -8,10 +8,257 @@ title: Search 搜索
|
|
|
8
8
|
|
|
9
9
|
# Search 搜索
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
配置驱动的搜索栏组件,通过 `searchItems` 描述搜索项,内置查询 / 重置按钮、列自适应与展开收起能力。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Search } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 搜索
|
|
20
|
+
|
|
21
|
+
`Search` 通过 `searchItems`(复用 `FormItem` 的配置)定义搜索项,`onSearch` / `onReset` 接收回调:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import React from "react";
|
|
25
|
+
import { Search } from "@hsu-react/ui";
|
|
26
|
+
|
|
27
|
+
export default () => {
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<Search
|
|
31
|
+
columnNum={3}
|
|
32
|
+
searchItems={[
|
|
33
|
+
{ type: "INPUT", name: "keyword", label: "关键字" },
|
|
34
|
+
{
|
|
35
|
+
type: "SELECT",
|
|
36
|
+
name: "status",
|
|
37
|
+
label: "状态",
|
|
38
|
+
componentProps: {
|
|
39
|
+
options: [
|
|
40
|
+
{ label: "启用", value: 1 },
|
|
41
|
+
{ label: "停用", value: 0 },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{ type: "RANGEPICKER", name: "date", label: "时间范围" },
|
|
46
|
+
]}
|
|
47
|
+
onSearch={(data) => console.log("search", data)}
|
|
48
|
+
onReset={() => console.log("reset")}
|
|
49
|
+
/>
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`Search` 在基础形态外,额外提供多种搜索形态。除 `Search.Card` 使用 `options` 配置外,其余均复用 `searchItems`(`FormItemProps[]`)+ `onSearch` / `onReset`。
|
|
56
|
+
|
|
57
|
+
## 高级筛选
|
|
58
|
+
|
|
59
|
+
不显示标签,通过抽屉承载更多筛选项;配合 `setFilter` 可显示筛选项下拉。
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import React from "react";
|
|
63
|
+
import { Search } from "@hsu-react/ui";
|
|
64
|
+
|
|
65
|
+
export default () => (
|
|
66
|
+
<>
|
|
67
|
+
<Search.Advanced
|
|
68
|
+
columnNum={3}
|
|
69
|
+
setFilter
|
|
70
|
+
searchItems={[
|
|
71
|
+
{ type: "INPUT", name: "name", label: "姓名" },
|
|
72
|
+
{
|
|
73
|
+
type: "SELECT",
|
|
74
|
+
name: "status",
|
|
75
|
+
label: "状态",
|
|
76
|
+
componentProps: {
|
|
77
|
+
options: [
|
|
78
|
+
{ label: "启用", value: 1 },
|
|
79
|
+
{ label: "禁用", value: 0 },
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
]}
|
|
84
|
+
moreSearchItems={[{ type: "INPUT", name: "remark", label: "备注" }]}
|
|
85
|
+
onSearch={(data) => console.log("search", data)}
|
|
86
|
+
onReset={() => console.log("reset")}
|
|
87
|
+
/>
|
|
88
|
+
</>
|
|
89
|
+
);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 可折叠搜索
|
|
93
|
+
|
|
94
|
+
整块搜索区可折叠 / 展开,通过 `defaultExpanded` 控制初始状态,`onCollapseToggle` 监听折叠变化。
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import React from "react";
|
|
98
|
+
import { Search } from "@hsu-react/ui";
|
|
99
|
+
|
|
100
|
+
export default () => (
|
|
101
|
+
<>
|
|
102
|
+
<Search.Collapsible
|
|
103
|
+
columnNum={3}
|
|
104
|
+
defaultExpanded
|
|
105
|
+
searchItems={[
|
|
106
|
+
{ type: "INPUT", name: "name", label: "姓名" },
|
|
107
|
+
{
|
|
108
|
+
type: "SELECT",
|
|
109
|
+
name: "status",
|
|
110
|
+
label: "状态",
|
|
111
|
+
componentProps: {
|
|
112
|
+
options: [
|
|
113
|
+
{ label: "启用", value: 1 },
|
|
114
|
+
{ label: "禁用", value: 0 },
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
]}
|
|
119
|
+
onCollapseToggle={(c) => console.log("collapse", c)}
|
|
120
|
+
onSearch={(data) => console.log("search", data)}
|
|
121
|
+
onReset={() => console.log("reset")}
|
|
122
|
+
/>
|
|
123
|
+
</>
|
|
124
|
+
);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 带筛选器搜索
|
|
128
|
+
|
|
129
|
+
在按钮组旁内置筛选下拉,允许用户动态勾选要显示的搜索项,`onFilterChange` 接收勾选变化。
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import React from "react";
|
|
133
|
+
import { Search } from "@hsu-react/ui";
|
|
134
|
+
|
|
135
|
+
export default () => (
|
|
136
|
+
<>
|
|
137
|
+
<Search.WithFilter
|
|
138
|
+
columnNum={3}
|
|
139
|
+
searchItems={[
|
|
140
|
+
{ type: "INPUT", name: "name", label: "姓名" },
|
|
141
|
+
{
|
|
142
|
+
type: "SELECT",
|
|
143
|
+
name: "status",
|
|
144
|
+
label: "状态",
|
|
145
|
+
componentProps: {
|
|
146
|
+
options: [
|
|
147
|
+
{ label: "启用", value: 1 },
|
|
148
|
+
{ label: "禁用", value: 0 },
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
{ type: "INPUT", name: "phone", label: "电话" },
|
|
153
|
+
]}
|
|
154
|
+
onFilterChange={(items) => console.log("filter", items)}
|
|
155
|
+
onSearch={(data) => console.log("search", data)}
|
|
156
|
+
onReset={() => console.log("reset")}
|
|
157
|
+
/>
|
|
158
|
+
</>
|
|
159
|
+
);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## 带更多项搜索
|
|
163
|
+
|
|
164
|
+
把搜索项分为基础项(`searchItems`)与更多项(`moreSearchItems`,必填),始终展示全部并提供展开收起。
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import React from "react";
|
|
168
|
+
import { Search } from "@hsu-react/ui";
|
|
169
|
+
|
|
170
|
+
export default () => (
|
|
171
|
+
<>
|
|
172
|
+
<Search.WithMore
|
|
173
|
+
columnNum={3}
|
|
174
|
+
searchItems={[
|
|
175
|
+
{ type: "INPUT", name: "name", label: "姓名" },
|
|
176
|
+
{
|
|
177
|
+
type: "SELECT",
|
|
178
|
+
name: "status",
|
|
179
|
+
label: "状态",
|
|
180
|
+
componentProps: {
|
|
181
|
+
options: [
|
|
182
|
+
{ label: "启用", value: 1 },
|
|
183
|
+
{ label: "禁用", value: 0 },
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
]}
|
|
188
|
+
moreSearchItems={[
|
|
189
|
+
{ type: "INPUT", name: "phone", label: "电话" },
|
|
190
|
+
{ type: "INPUT", name: "remark", label: "备注" },
|
|
191
|
+
]}
|
|
192
|
+
onSearch={(data) => console.log("search", data)}
|
|
193
|
+
onReset={() => console.log("reset")}
|
|
194
|
+
/>
|
|
195
|
+
</>
|
|
196
|
+
);
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## 卡片式搜索
|
|
200
|
+
|
|
201
|
+
标签式快捷筛选,使用 `options`(`SearchCardOption[]`)而非 `searchItems`,`onChange` 返回当前选中值;支持 `multiple` 多选与 `showSearchBox` 搜索框。
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
import React from "react";
|
|
205
|
+
import { Search } from "@hsu-react/ui";
|
|
206
|
+
|
|
207
|
+
export default () => (
|
|
208
|
+
<>
|
|
209
|
+
<Search.Card
|
|
210
|
+
options={[
|
|
211
|
+
{
|
|
212
|
+
label: "状态",
|
|
213
|
+
name: "status",
|
|
214
|
+
items: [
|
|
215
|
+
{ label: "启用", value: 1 },
|
|
216
|
+
{ label: "禁用", value: 0 },
|
|
217
|
+
],
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
label: "类型",
|
|
221
|
+
name: "type",
|
|
222
|
+
multiple: true,
|
|
223
|
+
items: [
|
|
224
|
+
{ label: "普通", value: "normal" },
|
|
225
|
+
{ label: "重要", value: "important" },
|
|
226
|
+
{ label: "紧急", value: "urgent" },
|
|
227
|
+
],
|
|
228
|
+
},
|
|
229
|
+
]}
|
|
230
|
+
onChange={(data) => console.log("change", data)}
|
|
231
|
+
/>
|
|
232
|
+
</>
|
|
233
|
+
);
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## API
|
|
237
|
+
|
|
238
|
+
`SearchProps` 继承自 `BaseSearchProps`:
|
|
239
|
+
|
|
240
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
241
|
+
| --- | --- | --- | --- |
|
|
242
|
+
| searchItems | 搜索项配置(复用 `FormItemProps`) | `FormItemProps[]` | `[]` |
|
|
243
|
+
| moreSearchItems | 展开后显示的更多搜索项 | `FormItemProps[]` | `[]` |
|
|
244
|
+
| onSearch | 点击查询的回调,返回收集到的表单值 | `(data?: Partial<T>) => void` | - |
|
|
245
|
+
| onReset | 点击重置的回调 | `() => void` | - |
|
|
246
|
+
| externalForm | 外部传入的表单实例 | `FormInstance` | - |
|
|
247
|
+
| hasPermi | 权限码;无权限时不渲染 | `string[]` | - |
|
|
248
|
+
| columnNum | 搜索项列数(按钮组额外占一列) | `number` | `4` |
|
|
249
|
+
| beforeButtonGroup | 查询 / 重置按钮前的附加按钮 | `ChakraButtonProps[]` | - |
|
|
250
|
+
| affterButtonGroup | 查询 / 重置按钮后的附加按钮 | `ChakraButtonProps[]` | - |
|
|
251
|
+
| searchData | 搜索项的初始值 | `Record<string, unknown>` | - |
|
|
252
|
+
| minLabelWidth | 标签最小宽度,或是否启用最小宽度 | `boolean \| number` | - |
|
|
253
|
+
| defaultExpanded | 默认是否展开 | `boolean` | `false` |
|
|
254
|
+
| onExpandChange | 展开状态变化回调 | `(expand: boolean) => void` | - |
|
|
255
|
+
| autoAdaptWidth | 是否启用基于宽度的自适应布局 | `boolean` | `true` |
|
|
256
|
+
| baseWidth | 自适应布局的基准宽度 | `number` | - |
|
|
257
|
+
| onValuesChange | 表单值变化回调 | `(value, values) => void` | - |
|
|
258
|
+
| searchDisabled | 是否禁用查询按钮 | `boolean` | `false` |
|
|
259
|
+
| showAllSearchItems | 是否一次性展示全部搜索项 | `boolean` | `false` |
|
|
260
|
+
| searchText | 查询按钮文本 | `ReactNode` | - |
|
|
261
|
+
| resetText | 重置按钮文本 | `ReactNode` | - |
|
|
262
|
+
| columnOffsetWidth | 列宽计算的偏移量 | `number` | `0` |
|
|
263
|
+
|
|
264
|
+
> 另提供多种搜索形态:`Search.Card`、`Search.Advanced`、`Search.Collapsible`、`Search.WithFilter`(带筛选下拉)、`Search.WithMore`。
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
justify-content: flex-start;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.ant-btn-icon {
|
|
51
|
+
:global(.ant-btn-icon) {
|
|
52
52
|
font-size: 16px;
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
.filterDropdown {
|
|
169
|
-
.ant-dropdown-menu {
|
|
169
|
+
:global(.ant-dropdown-menu) {
|
|
170
170
|
height: max-content;
|
|
171
171
|
max-height: 500px;
|
|
172
172
|
|
|
@@ -8,10 +8,48 @@ title: SecondConf 二次确认
|
|
|
8
8
|
|
|
9
9
|
# SecondConf 二次确认
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
基于 `Modal` 封装的二次确认弹窗,内置问号图标,自动拼接「确认{contentTitle}吗?」标题与说明文案。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { SecondConf } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 二次确认
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import React, { useState } from "react";
|
|
23
|
+
import { SecondConf } from "@hsu-react/ui";
|
|
24
|
+
import { Button } from "antd";
|
|
25
|
+
|
|
26
|
+
export default () => {
|
|
27
|
+
const [open, setOpen] = useState(false);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<Button danger onClick={() => setOpen(true)}>
|
|
32
|
+
删除
|
|
33
|
+
</Button>
|
|
34
|
+
<SecondConf
|
|
35
|
+
open={open}
|
|
36
|
+
contentTitle="删除该条数据"
|
|
37
|
+
contentText="删除后将无法恢复,请谨慎操作。"
|
|
38
|
+
onOk={() => setOpen(false)}
|
|
39
|
+
onCancel={() => setOpen(false)}
|
|
40
|
+
/>
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
在 `Modal`(即 antd `ModalProps`)基础上扩展(`title` 已被内部接管):
|
|
49
|
+
|
|
50
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
51
|
+
| --- | --- | --- | --- |
|
|
52
|
+
| contentTitle | 标题中「确认 … 吗?」的中间内容 | `ReactNode` | - |
|
|
53
|
+
| contentText | 标题下方的补充说明文案 | `ReactNode` | - |
|
|
54
|
+
|
|
55
|
+
> 其余属性(`open`、`onOk`、`onCancel`、`width`、`confirmLoading` 等)与 `Modal` 一致;组件内部默认 `width={800}`、`centered`、`maskClosable={false}`、`mask={false}`。
|