@hsu-react/ui 0.0.1 → 0.0.2

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 (147) hide show
  1. package/es/components/ChainGraph/index.module.less +1 -1
  2. package/es/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  3. package/es/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  4. package/es/components/Chat/ChatInput/index.module.less +2 -2
  5. package/es/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  6. package/es/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  7. package/es/components/Checkbox/index.module.less +13 -13
  8. package/es/components/CodeMirror/index.module.less +4 -4
  9. package/es/components/DatePicker/RangePicker/index.module.less +1 -1
  10. package/es/components/DatePicker/StepPicker/index.module.less +1 -1
  11. package/es/components/DatePicker/index.module.less +1 -1
  12. package/es/components/Form/DrawerForm/index.module.less +2 -2
  13. package/es/components/FormItem/FormRadio/index.module.less +9 -9
  14. package/es/components/FormItem/FormSegmented/index.module.less +2 -2
  15. package/es/components/FormItem/FormUpload/index.module.less +4 -4
  16. package/es/components/FormItem/ItemContainer/index.module.less +22 -22
  17. package/es/components/Icon/index.js +9 -24
  18. package/es/components/Input/Number/index.module.less +9 -9
  19. package/es/components/Input/Password/index.module.less +3 -3
  20. package/es/components/Input/Search/index.module.less +5 -5
  21. package/es/components/Input/TextArea/index.module.less +5 -5
  22. package/es/components/Input/index.module.less +4 -4
  23. package/es/components/Modal/index.module.less +2 -2
  24. package/es/components/Operate/index.module.less +2 -2
  25. package/es/components/Panel/IframePanel/index.module.less +1 -1
  26. package/es/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  27. package/es/components/Search/index.module.less +2 -2
  28. package/es/components/Select/AutoCompleteSelect/index.module.less +35 -35
  29. package/es/components/Select/IconSelect/index.module.less +3 -3
  30. package/es/components/Select/TreeSelect/index.module.less +17 -17
  31. package/es/components/Select/index.module.less +34 -34
  32. package/es/components/Slider/index.module.less +4 -4
  33. package/es/components/Spreadsheet/index.module.less +4 -4
  34. package/es/components/Table/_components/Pagination/index.module.less +23 -23
  35. package/es/components/Table/index.module.less +61 -61
  36. package/es/components/Tree/index.module.less +11 -11
  37. package/es/components/Upload/index.module.less +3 -3
  38. package/es/styles/antd-overload.less +1 -1
  39. package/lib/components/ChainGraph/index.module.less +1 -1
  40. package/lib/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  41. package/lib/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  42. package/lib/components/Chat/ChatInput/index.module.less +2 -2
  43. package/lib/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  44. package/lib/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  45. package/lib/components/Checkbox/index.module.less +13 -13
  46. package/lib/components/CodeMirror/index.module.less +4 -4
  47. package/lib/components/DatePicker/RangePicker/index.module.less +1 -1
  48. package/lib/components/DatePicker/StepPicker/index.module.less +1 -1
  49. package/lib/components/DatePicker/index.module.less +1 -1
  50. package/lib/components/Form/DrawerForm/index.module.less +2 -2
  51. package/lib/components/FormItem/FormRadio/index.module.less +9 -9
  52. package/lib/components/FormItem/FormSegmented/index.module.less +2 -2
  53. package/lib/components/FormItem/FormUpload/index.module.less +4 -4
  54. package/lib/components/FormItem/ItemContainer/index.module.less +22 -22
  55. package/lib/components/Icon/index.js +9 -27
  56. package/lib/components/Input/Number/index.module.less +9 -9
  57. package/lib/components/Input/Password/index.module.less +3 -3
  58. package/lib/components/Input/Search/index.module.less +5 -5
  59. package/lib/components/Input/TextArea/index.module.less +5 -5
  60. package/lib/components/Input/index.module.less +4 -4
  61. package/lib/components/Modal/index.module.less +2 -2
  62. package/lib/components/Operate/index.module.less +2 -2
  63. package/lib/components/Panel/IframePanel/index.module.less +1 -1
  64. package/lib/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  65. package/lib/components/Search/index.module.less +2 -2
  66. package/lib/components/Select/AutoCompleteSelect/index.module.less +35 -35
  67. package/lib/components/Select/IconSelect/index.module.less +3 -3
  68. package/lib/components/Select/TreeSelect/index.module.less +17 -17
  69. package/lib/components/Select/index.module.less +34 -34
  70. package/lib/components/Slider/index.module.less +4 -4
  71. package/lib/components/Spreadsheet/index.module.less +4 -4
  72. package/lib/components/Table/_components/Pagination/index.module.less +23 -23
  73. package/lib/components/Table/index.module.less +61 -61
  74. package/lib/components/Tree/index.module.less +11 -11
  75. package/lib/components/Upload/index.module.less +3 -3
  76. package/lib/styles/antd-overload.less +1 -1
  77. package/package.json +1 -1
  78. package/src/components/Button/index.md +2 -3
  79. package/src/components/ChainGraph/index.md +66 -1
  80. package/src/components/ChainGraph/index.module.less +1 -1
  81. package/src/components/Chart/index.md +78 -1
  82. package/src/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  83. package/src/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  84. package/src/components/Chat/ChatInput/index.module.less +2 -2
  85. package/src/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  86. package/src/components/Chat/index.md +97 -1
  87. package/src/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  88. package/src/components/Checkbox/index.md +53 -1
  89. package/src/components/Checkbox/index.module.less +13 -13
  90. package/src/components/CodeMirror/index.md +41 -1
  91. package/src/components/CodeMirror/index.module.less +4 -4
  92. package/src/components/DatePicker/RangePicker/index.module.less +1 -1
  93. package/src/components/DatePicker/StepPicker/index.module.less +1 -1
  94. package/src/components/DatePicker/index.md +43 -1
  95. package/src/components/DatePicker/index.module.less +1 -1
  96. package/src/components/Descriptions/index.md +45 -1
  97. package/src/components/Editor/index.md +40 -1
  98. package/src/components/FileCol/index.md +24 -1
  99. package/src/components/FilePreview/index.md +45 -1
  100. package/src/components/FlexFill/index.md +46 -1
  101. package/src/components/Form/DrawerForm/index.module.less +2 -2
  102. package/src/components/Form/index.md +92 -1
  103. package/src/components/FormItem/FormRadio/index.module.less +9 -9
  104. package/src/components/FormItem/FormSegmented/index.module.less +2 -2
  105. package/src/components/FormItem/FormUpload/index.module.less +4 -4
  106. package/src/components/FormItem/ItemContainer/index.module.less +22 -22
  107. package/src/components/FormItem/index.md +459 -1
  108. package/src/components/Icon/index.md +21 -3
  109. package/src/components/Icon/index.tsx +9 -37
  110. package/src/components/Input/Number/index.module.less +9 -9
  111. package/src/components/Input/Password/index.module.less +3 -3
  112. package/src/components/Input/Search/index.module.less +5 -5
  113. package/src/components/Input/TextArea/index.module.less +5 -5
  114. package/src/components/Input/index.md +35 -1
  115. package/src/components/Input/index.module.less +4 -4
  116. package/src/components/Markdown/index.md +71 -1
  117. package/src/components/Modal/index.md +43 -1
  118. package/src/components/Modal/index.module.less +2 -2
  119. package/src/components/Operate/index.md +43 -1
  120. package/src/components/Operate/index.module.less +2 -2
  121. package/src/components/Panel/IframePanel/index.module.less +1 -1
  122. package/src/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  123. package/src/components/Panel/index.md +146 -1
  124. package/src/components/Search/index.md +73 -1
  125. package/src/components/Search/index.module.less +2 -2
  126. package/src/components/SecondConf/index.md +39 -1
  127. package/src/components/Select/AutoCompleteSelect/index.module.less +35 -35
  128. package/src/components/Select/IconSelect/index.module.less +3 -3
  129. package/src/components/Select/TreeSelect/index.module.less +17 -17
  130. package/src/components/Select/index.md +47 -1
  131. package/src/components/Select/index.module.less +34 -34
  132. package/src/components/Slider/index.md +29 -1
  133. package/src/components/Slider/index.module.less +4 -4
  134. package/src/components/Spreadsheet/index.md +42 -1
  135. package/src/components/Spreadsheet/index.module.less +4 -4
  136. package/src/components/Switch/index.md +33 -1
  137. package/src/components/TabBar/index.md +53 -1
  138. package/src/components/Table/_components/Pagination/index.module.less +23 -23
  139. package/src/components/Table/index.md +60 -1
  140. package/src/components/Table/index.module.less +61 -61
  141. package/src/components/Tags/index.md +23 -1
  142. package/src/components/TextEllipsis/index.md +29 -1
  143. package/src/components/Tree/index.md +66 -1
  144. package/src/components/Tree/index.module.less +11 -11
  145. package/src/components/Upload/index.md +72 -1
  146. package/src/components/Upload/index.module.less +3 -3
  147. package/src/styles/antd-overload.less +1 -1
@@ -8,10 +8,69 @@ title: Table 表格
8
8
 
9
9
  # Table 表格
10
10
 
11
- > `Table` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ antd `Table` 之上封装,扩展了自定义列(权限、排序、省略 Tooltip)、内置分页、自动高度、行拖拽、自动滚动等能力。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Table } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { Table } from "@hsu-react/ui";
24
+
25
+ const columns = [
26
+ { title: "姓名", dataIndex: "name", width: 120 },
27
+ { title: "年龄", dataIndex: "age", width: 80 },
28
+ { title: "住址", dataIndex: "address" },
29
+ ];
30
+
31
+ const dataSource = [
32
+ { key: "1", name: "张三", age: 32, address: "西湖区湖底公园 1 号" },
33
+ { key: "2", name: "李四", age: 28, address: "滨江区江南大道 100 号" },
34
+ { key: "3", name: "王五", age: 45, address: "余杭区文一西路 998 号" },
35
+ ];
36
+
37
+ export default () => (
38
+ <Table columns={columns} dataSource={dataSource} pagination={false} />
39
+ );
40
+ ```
41
+
42
+ ## API
43
+
44
+ 在 [antd TableProps](https://ant.design/components/table-cn) 基础上扩展(`scroll`、`pagination`、`columns` 被重写),常用新增/重写属性如下:
45
+
46
+ | 属性 | 说明 | 类型 | 默认值 |
47
+ | --- | --- | --- | --- |
48
+ | columns | 列配置,使用自定义 `ColumnsType`(支持 `hidden`、`sort`、`hasPermi`、`help`、`mergeRow`、`fixedWidth`、`ellipsisPosition` 等) | `ColumnsType<RecordType>` | `[]` |
49
+ | scroll | 是否开启滚动;`{ y: false }` 可关闭纵向滚动 | `boolean \| { y: boolean }` | `false` |
50
+ | pagination | 分页配置;为 `false` 时不展示分页 | `false \| PaginationProps` | `{}` |
51
+ | autoWidth | 列宽自适应 | `boolean` | - |
52
+ | scrollAutoHeight | 自动计算并撑满可用高度 | `boolean` | `true` |
53
+ | hideScrollbar | 隐藏表头滚动条 | `boolean` | `true` |
54
+ | thPadding | 表头单元格内边距 | `string` | - |
55
+ | tdPadding | 表体单元格内边距 | `string` | - |
56
+ | expandedCellPadding | 展开行单元格内边距 | `string` | `tdPadding` |
57
+ | fillPanel | 撑满父级 Panel 高度 | `boolean` | - |
58
+ | staticDataSource | 使用静态数据源(前端分页) | `boolean` | `false` |
59
+ | serialNumberColumn | 是否展示序号列 | `boolean` | `false` |
60
+ | hideEmpty | 隐藏空数据占位 | `boolean` | `false` |
61
+ | ellipsisTooltipConfig | 文本省略 Tooltip 配置 | `EllipsisTooltipConfig` | - |
62
+ | onDragEnd | 行拖拽结束回调(开启后启用拖拽排序) | `DragProps["onDragEnd"]` | - |
63
+ | autoScrolling | 是否开启内容自动滚动 | `boolean` | - |
64
+ | autoScrollMode | 自动滚动模式 | `'smooth' \| 'row'` | - |
65
+ | autoScrollingSpeed | smooth 模式滚动速度(px/s) | `number` | `25` |
66
+ | autoScrollLoop | 滚动到末尾后是否循环 | `boolean` | `true` |
67
+ | autoScrollLoopMode | 循环模式 | `'reset' \| 'seamless'` | `'reset'` |
68
+ | onScrollEnd | 滚动到底部回调 | `() => void` | - |
69
+ | onAutoScrollEndAdd | 自动滚动到底部时追加数据 | `() => Promise<boolean>` | - |
70
+ | order | 当前排序 | `{ k: string; t: 'asc' \| 'desc' }` | - |
71
+ | onOrderChange | 排序变化回调 | `(order?) => void` | - |
72
+ | sorter | 是否启用排序 | `boolean` | - |
73
+ | showTotal | 自定义分页总数展示;为 `false` 时不展示 | `false \| ((total, range) => ReactNode)` | - |
74
+ | isExpandedCellTable | 是否为展开行内嵌表格样式 | `boolean` | `false` |
75
+
76
+ > 另导出 `TableDrag`,用于行拖拽排序场景。
@@ -15,16 +15,16 @@
15
15
  cursor: pointer;
16
16
  }
17
17
 
18
- .ant-table-container {
18
+ :global(.ant-table-container) {
19
19
  border-left: none !important;
20
20
  }
21
21
 
22
- .ant-table-thead {
22
+ :global(.ant-table-thead) {
23
23
  tr {
24
- .ant-table-cell {
24
+ :global(.ant-table-cell) {
25
25
  padding: var(--th-padding);
26
26
 
27
- &.ant-table-column-has-sorters {
27
+ &:global(.ant-table-column-has-sorters) {
28
28
  background: var(--cf-subtle);
29
29
 
30
30
  &:hover {
@@ -35,22 +35,22 @@
35
35
  }
36
36
  }
37
37
 
38
- .ant-table-tbody {
39
- .ant-table-placeholder {
38
+ :global(.ant-table-tbody) {
39
+ :global(.ant-table-placeholder) {
40
40
  height: 100%;
41
41
  }
42
42
 
43
- .ant-table-expanded-row {
44
- .ant-table-cell {
43
+ :global(.ant-table-expanded-row) {
44
+ :global(.ant-table-cell) {
45
45
  padding: var(--expanded-cell-padding);
46
46
  }
47
47
  }
48
48
 
49
- .ant-table-row {
50
- .ant-table-cell {
49
+ :global(.ant-table-row) {
50
+ :global(.ant-table-cell) {
51
51
  padding: var(--td-padding);
52
52
 
53
- &:not(.ant-table-cell-ellipsis):not(.noWarp) {
53
+ &:not(:global(.ant-table-cell-ellipsis)):not(.noWarp) {
54
54
  white-space: pre-wrap;
55
55
  word-break: break-all;
56
56
  }
@@ -59,21 +59,21 @@
59
59
  white-space: nowrap;
60
60
  }
61
61
 
62
- &.ant-table-column-sort {
62
+ &:global(.ant-table-column-sort) {
63
63
  background: transparent;
64
64
 
65
- &.ant-table-cell-row-hover {
65
+ &:global(.ant-table-cell-row-hover) {
66
66
  background: var(--cf-subtle);
67
67
  }
68
68
  }
69
69
  }
70
70
 
71
- &.ant-table-row-selected {
72
- .ant-table-cell {
73
- &.ant-table-column-sort {
71
+ &:global(.ant-table-row-selected) {
72
+ :global(.ant-table-cell) {
73
+ &:global(.ant-table-column-sort) {
74
74
  background: rgba(19, 194, 194, 0.12);
75
75
 
76
- &.ant-table-cell-row-hover {
76
+ &:global(.ant-table-cell-row-hover) {
77
77
  background: rgba(19, 194, 194, 0.22);
78
78
  }
79
79
  }
@@ -82,15 +82,15 @@
82
82
  }
83
83
  }
84
84
 
85
- .ant-table-summary {
85
+ :global(.ant-table-summary) {
86
86
  > tr {
87
- .ant-table-cell {
87
+ :global(.ant-table-cell) {
88
88
  padding: var(--td-padding);
89
89
 
90
- &.ant-table-column-sort {
90
+ &:global(.ant-table-column-sort) {
91
91
  background: transparent;
92
92
 
93
- &.ant-table-cell-row-hover {
93
+ &:global(.ant-table-cell-row-hover) {
94
94
  background: var(--cf-subtle);
95
95
  }
96
96
  }
@@ -98,11 +98,11 @@
98
98
  }
99
99
  }
100
100
 
101
- .ant-table-tbody-virtual-scrollbar {
101
+ :global(.ant-table-tbody-virtual-scrollbar) {
102
102
  display: none;
103
103
  }
104
104
 
105
- .ant-table-cell {
105
+ :global(.ant-table-cell) {
106
106
  &.hidden {
107
107
  width: 0px !important;
108
108
  overflow: hidden !important;
@@ -115,7 +115,7 @@
115
115
  }
116
116
  }
117
117
 
118
- .ant-table-row-expand-icon {
118
+ :global(.ant-table-row-expand-icon) {
119
119
  &::before {
120
120
  top: calc(50% - 0.5px);
121
121
  }
@@ -128,9 +128,9 @@
128
128
  content: none !important;
129
129
  }
130
130
 
131
- .ant-checkbox {
132
- &.ant-checkbox-checked {
133
- .ant-checkbox-inner {
131
+ :global(.ant-checkbox) {
132
+ &:global(.ant-checkbox-checked) {
133
+ :global(.ant-checkbox-inner) {
134
134
  &::after {
135
135
  top: 45%;
136
136
  inset-inline-start: 25%;
@@ -147,10 +147,10 @@
147
147
  .antdTable {
148
148
  border-color: var(--cf-border-weak);
149
149
 
150
- *:not(.ant-table-cell *) {
150
+ *:not(:global(.ant-table-cell) *) {
151
151
  border-color: inherit !important;
152
152
 
153
- .ant-table-cell::after {
153
+ :global(.ant-table-cell)::after {
154
154
  border-color: inherit !important;
155
155
  }
156
156
  }
@@ -164,15 +164,15 @@
164
164
  }
165
165
 
166
166
  &.hideEmpty {
167
- .ant-table-placeholder {
167
+ :global(.ant-table-placeholder) {
168
168
  display: none !important;
169
169
  }
170
170
  }
171
171
 
172
172
  &:not(.scroll) {
173
- .ant-table-bordered {
174
- .ant-table-container {
175
- .ant-table-content {
173
+ :global(.ant-table-bordered) {
174
+ :global(.ant-table-container) {
175
+ :global(.ant-table-content) {
176
176
  > table {
177
177
  border-left: 1px solid var(--cf-border-weak);
178
178
  }
@@ -181,12 +181,12 @@
181
181
  }
182
182
  }
183
183
 
184
- .ant-table {
184
+ :global(.ant-table) {
185
185
  line-height: normal;
186
186
  }
187
187
 
188
188
  &.isExpandedCellTable {
189
- .ant-table-tbody {
189
+ :global(.ant-table-tbody) {
190
190
  tr {
191
191
  &:last-child {
192
192
  td {
@@ -196,9 +196,9 @@
196
196
  }
197
197
  }
198
198
 
199
- .ant-table-bordered {
200
- .ant-table-container {
201
- > .ant-table-content {
199
+ :global(.ant-table-bordered) {
200
+ :global(.ant-table-container) {
201
+ > :global(.ant-table-content) {
202
202
  > table {
203
203
  border-radius: 0 !important;
204
204
  border-left: none !important;
@@ -212,7 +212,7 @@
212
212
  }
213
213
  }
214
214
 
215
- .ant-table-thead {
215
+ :global(.ant-table-thead) {
216
216
  tr {
217
217
  th {
218
218
  &:first-child {
@@ -235,23 +235,23 @@
235
235
  width: 100%;
236
236
  min-height: 0px;
237
237
 
238
- .ant-table-bordered {
239
- .ant-table-container {
240
- > .ant-table-header {
238
+ :global(.ant-table-bordered) {
239
+ :global(.ant-table-container) {
240
+ > :global(.ant-table-header) {
241
241
  > table {
242
242
  border-radius: 6px 6px 0 0;
243
243
  border-left: 1px solid var(--cf-border-weak);
244
244
  }
245
245
  }
246
246
 
247
- > .ant-table-body {
247
+ > :global(.ant-table-body) {
248
248
  > table {
249
249
  border-radius: 0px !important;
250
250
  border-left: 1px solid var(--cf-border-weak);
251
251
  }
252
252
  }
253
253
 
254
- > .ant-table-summary {
254
+ > :global(.ant-table-summary) {
255
255
  > table {
256
256
  border-radius: 0px !important;
257
257
  border-left: 1px solid var(--cf-border-weak);
@@ -262,23 +262,23 @@
262
262
  }
263
263
 
264
264
  &.isExpanded {
265
- .ant-table-bordered {
266
- .ant-table-container {
267
- > .ant-table-header {
265
+ :global(.ant-table-bordered) {
266
+ :global(.ant-table-container) {
267
+ > :global(.ant-table-header) {
268
268
  > table {
269
269
  border-radius: 0px !important;
270
270
  border-left: none !important;
271
271
  }
272
272
  }
273
273
 
274
- > .ant-table-body {
274
+ > :global(.ant-table-body) {
275
275
  > table {
276
276
  border-radius: 0px !important;
277
277
  border-left: none !important;
278
278
  }
279
279
  }
280
280
 
281
- > .ant-table-summary {
281
+ > :global(.ant-table-summary) {
282
282
  > table {
283
283
  border-radius: 0px !important;
284
284
  border-left: none !important;
@@ -289,38 +289,38 @@
289
289
  }
290
290
  }
291
291
 
292
- .ant-table-wrapper {
292
+ :global(.ant-table-wrapper) {
293
293
  width: 100%;
294
294
  height: 100%;
295
295
  }
296
296
 
297
- .ant-spin-nested-loading {
297
+ :global(.ant-spin-nested-loading) {
298
298
  width: 100%;
299
299
  height: 100%;
300
300
 
301
- .ant-spin-container {
301
+ :global(.ant-spin-container) {
302
302
  display: flex;
303
303
  flex-direction: column;
304
304
 
305
305
  width: 100%;
306
306
  height: 100%;
307
307
 
308
- .ant-table {
308
+ :global(.ant-table) {
309
309
  width: 100%;
310
310
  height: 100%;
311
311
 
312
- .ant-table-container {
312
+ :global(.ant-table-container) {
313
313
  display: flex;
314
314
  flex-direction: column;
315
315
 
316
316
  width: 100%;
317
317
  height: 100%;
318
318
 
319
- > .ant-table-header {
319
+ > :global(.ant-table-header) {
320
320
  min-height: max-content;
321
321
  }
322
322
 
323
- > .ant-table-body {
323
+ > :global(.ant-table-body) {
324
324
  position: relative;
325
325
 
326
326
  flex: 1;
@@ -344,11 +344,11 @@
344
344
  }
345
345
 
346
346
  &.y-unScroll {
347
- .ant-spin-nested-loading {
348
- .ant-spin-container {
349
- .ant-table {
350
- .ant-table-container {
351
- > .ant-table-body {
347
+ :global(.ant-spin-nested-loading) {
348
+ :global(.ant-spin-container) {
349
+ :global(.ant-table) {
350
+ :global(.ant-table-container) {
351
+ > :global(.ant-table-body) {
352
352
  overflow-y: visible !important;
353
353
  }
354
354
  }
@@ -8,10 +8,32 @@ title: Tags 标签
8
8
 
9
9
  # Tags 标签
10
10
 
11
- > `Tags` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 基于 antd `Tag` 的标签组,支持自动配色、对齐方式,并可在容器宽度不足时自动省略并收纳超出的标签。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Tags } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { Tags } from "@hsu-react/ui";
24
+
25
+ export default () => (
26
+ <Tags tags={["前端", "React", "TypeScript", "Ant Design", "dumi"]} />
27
+ );
28
+ ```
29
+
30
+ ## API
31
+
32
+ | 属性 | 说明 | 类型 | 默认值 |
33
+ | --- | --- | --- | --- |
34
+ | tags | 标签内容列表 | `string[]` | `[]` |
35
+ | colors | 自定义标签配色(按索引循环取用) | `string[]` | - |
36
+ | ellipsis | 容器宽度不足时是否自动省略并收纳多余标签 | `boolean` | `true` |
37
+ | align | 对齐方式 | `'left' \| 'center' \| 'right'` | `'left'` |
38
+ | gap | 标签之间的间距 | `number` | `8` |
39
+ | className | 自定义类名 | `string` | - |
@@ -8,10 +8,38 @@ title: TextEllipsis 文本省略
8
8
 
9
9
  # TextEllipsis 文本省略
10
10
 
11
- > `TextEllipsis` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 文本溢出时自动省略,并通过 antd `Tooltip` 展示完整内容,支持省略号位置切换。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { TextEllipsis } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { TextEllipsis } from "@hsu-react/ui";
24
+
25
+ export default () => (
26
+ <div style={{ width: 200 }}>
27
+ <TextEllipsis>
28
+ 这是一段很长的文本,当容器宽度不足以完整展示时会自动省略,并在悬停时显示完整内容。
29
+ </TextEllipsis>
30
+ </div>
31
+ );
32
+ ```
33
+
34
+ ## API
35
+
36
+ | 属性 | 说明 | 类型 | 默认值 |
37
+ | --- | --- | --- | --- |
38
+ | children | 要显示的文本内容 | `ReactNode` | - |
39
+ | width | 容器宽度,用于计算 Tooltip 宽度 | `number \| string` | - |
40
+ | tooltipConfig | Tooltip 配置(可附加 `defaultWidth`) | `Omit<TooltipProps, 'title' \| 'children'> & { defaultWidth?: number }` | - |
41
+ | disabled | 是否禁用 Tooltip(即使溢出也不显示) | `boolean` | `false` |
42
+ | ellipsisPosition | 省略号位置,`start` 省略前面,`end` 省略后面 | `'start' \| 'end'` | `'end'` |
43
+ | style | 文本自定义样式 | `React.CSSProperties` | - |
44
+ | className | 文本自定义类名 | `string` | - |
45
+ | containerStyle | 容器自定义样式 | `React.CSSProperties` | - |
@@ -8,10 +8,75 @@ title: Tree 树形控件
8
8
 
9
9
  # Tree 树形控件
10
10
 
11
- > `Tree` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ antd `Tree` 之上增强:内置标题栏、搜索过滤、按层级默认展开、勾选半选自动规范化、选中路径回调与权限控制。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Tree } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ 通过 `treeData` 传入树数据,开启 `search` 即可在标题栏内搜索过滤节点。
22
+
23
+ ```tsx
24
+ import React from "react";
25
+ import { Tree } from "@hsu-react/ui";
26
+
27
+ const treeData = [
28
+ {
29
+ title: "华东区",
30
+ key: "1",
31
+ value: "1",
32
+ children: [
33
+ { title: "上海", key: "1-1", value: "1-1" },
34
+ { title: "杭州", key: "1-2", value: "1-2" },
35
+ ],
36
+ },
37
+ {
38
+ title: "华南区",
39
+ key: "2",
40
+ value: "2",
41
+ children: [{ title: "广州", key: "2-1", value: "2-1" }],
42
+ },
43
+ ];
44
+
45
+ export default () => (
46
+ <div style={{ height: 280 }}>
47
+ <Tree
48
+ title="区域"
49
+ search
50
+ treeData={treeData}
51
+ defaultExpandLevel={1}
52
+ onSelectPath={(path) => console.log(path)}
53
+ />
54
+ </div>
55
+ );
56
+ ```
57
+
58
+ ## API
59
+
60
+ 在 [antd TreeProps](https://ant.design/components/tree-cn)(已 `Omit` 掉 `treeData`、`loadData`、`loadedKeys`、`titleRender`)基础上扩展:
61
+
62
+ | 属性 | 说明 | 类型 | 默认值 |
63
+ | --- | --- | --- | --- |
64
+ | treeData | 树数据 | `TreeData[]` | `[]` |
65
+ | title | 标题栏标题 | `ReactNode` | - |
66
+ | search | 是否显示搜索框 | `boolean` | - |
67
+ | searchProps | 搜索框(Input)属性 | `InputProps` | - |
68
+ | titleRender | 自定义节点渲染 | `(data: TreeData) => ReactNode` | - |
69
+ | onChange | 勾选变化回调 | `(checked: CheckedKeys) => void` | - |
70
+ | onSelectPath | 节点选中回调,返回选中节点的完整路径 | `(path: TreeData[] \| null, selectedKeys: Key[]) => void` | - |
71
+ | allowDeselect | 点击已选中节点时是否允许取消选中 | `boolean` | `true` |
72
+ | defaultExpandLevel | 默认展开层级(从 1 开始) | `number` | - |
73
+ | hideLeafExpand | 是否隐藏叶子节点的展开图标 | `boolean` | - |
74
+ | indent | 缩进单位宽度(px) | `number` | - |
75
+ | switchWidth | 展开/收起图标宽度(px) | `number` | - |
76
+ | switchGap | 展开/收起图标与节点的间距(px) | `number` | - |
77
+ | buttonGroup | 标题栏按钮组 | `ButtonProps[]` | - |
78
+ | btnPosition | 按钮组位置 | `'left' \| 'right'` | `'right'` |
79
+ | hasPermi | 权限码,无权限时不渲染 | `string[]` | - |
80
+ | treeClassName / treeContainerClassName / titleClassName / titleSearchBarClassName | 各区域自定义类名 | `string` | - |
81
+
82
+ `TreeData` 结构(继承 antd 节点字段):`title`、`key`、`value`、`selectable`、`disabled`、`disableCheckbox`、`isLeaf`、`checkable`、`icon`、`children`。
@@ -56,25 +56,25 @@
56
56
  overflow-y: auto;
57
57
  scrollbar-gutter: stable;
58
58
 
59
- .ant-tree-treenode {
59
+ :global(.ant-tree-treenode) {
60
60
  &:hover {
61
61
  background: var(--cf-subtle);
62
62
  }
63
63
 
64
- &:has(> .ant-tree-node-selected) {
64
+ &:has(> :global(.ant-tree-node-selected)) {
65
65
  background-color: #e6f4ff;
66
66
 
67
- .ant-tree-node-selected {
67
+ :global(.ant-tree-node-selected) {
68
68
  background-color: transparent;
69
69
  }
70
70
  }
71
71
  }
72
72
 
73
- .ant-tree-indent-unit {
73
+ :global(.ant-tree-indent-unit) {
74
74
  width: var(--tree-indent-unit-width);
75
75
  }
76
76
 
77
- .ant-tree-switcher {
77
+ :global(.ant-tree-switcher) {
78
78
  display: inline-flex;
79
79
  align-items: center;
80
80
  justify-content: center;
@@ -95,7 +95,7 @@
95
95
  }
96
96
  }
97
97
 
98
- .ant-tree-node-content-wrapper {
98
+ :global(.ant-tree-node-content-wrapper) {
99
99
  display: inline-flex;
100
100
  align-items: center;
101
101
  column-gap: 4px;
@@ -105,7 +105,7 @@
105
105
 
106
106
  padding: 2px 0px;
107
107
 
108
- .ant-tree-title {
108
+ :global(.ant-tree-title) {
109
109
  display: inline-block;
110
110
  }
111
111
 
@@ -113,7 +113,7 @@
113
113
  background: transparent;
114
114
  }
115
115
 
116
- .ant-tree-iconEle {
116
+ :global(.ant-tree-iconEle) {
117
117
  display: inline-flex;
118
118
  align-items: center;
119
119
 
@@ -123,17 +123,17 @@
123
123
  }
124
124
 
125
125
  &.hideLeafExpand {
126
- .ant-tree-switcher-noop {
126
+ :global(.ant-tree-switcher-noop) {
127
127
  display: none;
128
128
  }
129
129
  }
130
130
 
131
131
  &.legacyHasSelectedNodeBackground {
132
132
  .treeContainer {
133
- .ant-tree-treenode.ant-tree-treenode-selected {
133
+ :global(.ant-tree-treenode):global(.ant-tree-treenode-selected) {
134
134
  background-color: #e6f4ff;
135
135
 
136
- .ant-tree-node-selected {
136
+ :global(.ant-tree-node-selected) {
137
137
  background-color: transparent;
138
138
  }
139
139
  }