@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.
Files changed (175) hide show
  1. package/README.md +2 -0
  2. package/es/components/ChainGraph/_components/SearchSelect/index.js +13 -10
  3. package/es/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
  4. package/es/components/ChainGraph/index.module.less +1 -1
  5. package/es/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  6. package/es/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  7. package/es/components/Chat/ChatInput/index.module.less +2 -2
  8. package/es/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  9. package/es/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  10. package/es/components/Checkbox/index.module.less +13 -13
  11. package/es/components/CodeMirror/index.module.less +4 -4
  12. package/es/components/DatePicker/RangePicker/index.module.less +1 -1
  13. package/es/components/DatePicker/StepPicker/index.module.less +1 -1
  14. package/es/components/DatePicker/index.module.less +2 -1
  15. package/es/components/Form/DrawerForm/index.module.less +2 -2
  16. package/es/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -2
  17. package/es/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
  18. package/es/components/FormItem/FormRadio/index.module.less +9 -9
  19. package/es/components/FormItem/FormSegmented/index.module.less +2 -2
  20. package/es/components/FormItem/FormUpload/index.module.less +4 -4
  21. package/es/components/FormItem/ItemContainer/index.module.less +22 -22
  22. package/es/components/Icon/index.js +9 -24
  23. package/es/components/Input/Number/index.module.less +9 -9
  24. package/es/components/Input/Password/index.module.less +3 -3
  25. package/es/components/Input/Range/index.module.less +4 -4
  26. package/es/components/Input/Search/index.module.less +5 -5
  27. package/es/components/Input/TextArea/index.module.less +5 -5
  28. package/es/components/Input/index.module.less +7 -4
  29. package/es/components/Modal/index.module.less +2 -2
  30. package/es/components/Operate/index.module.less +2 -2
  31. package/es/components/Panel/IframePanel/index.module.less +1 -1
  32. package/es/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  33. package/es/components/Search/index.module.less +2 -2
  34. package/es/components/Select/AutoCompleteSelect/index.module.less +35 -35
  35. package/es/components/Select/IconSelect/index.module.less +3 -3
  36. package/es/components/Select/TreeSelect/index.module.less +17 -17
  37. package/es/components/Select/_utils/getElementPosition.d.ts +6 -2
  38. package/es/components/Select/_utils/getElementPosition.js +8 -6
  39. package/es/components/Select/index.module.less +37 -34
  40. package/es/components/Slider/index.module.less +5 -4
  41. package/es/components/Spreadsheet/index.module.less +4 -4
  42. package/es/components/Switch/index.js +12 -8
  43. package/es/components/Switch/index.module.less +7 -0
  44. package/es/components/Table/_components/Pagination/index.module.less +23 -23
  45. package/es/components/Table/index.module.less +61 -61
  46. package/es/components/Tree/index.module.less +11 -11
  47. package/es/components/Upload/index.module.less +3 -3
  48. package/es/styles/antd-overload.less +1 -1
  49. package/lib/components/ChainGraph/_components/SearchSelect/index.js +10 -7
  50. package/lib/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
  51. package/lib/components/ChainGraph/index.module.less +1 -1
  52. package/lib/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  53. package/lib/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  54. package/lib/components/Chat/ChatInput/index.module.less +2 -2
  55. package/lib/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  56. package/lib/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  57. package/lib/components/Checkbox/index.module.less +13 -13
  58. package/lib/components/CodeMirror/index.module.less +4 -4
  59. package/lib/components/DatePicker/RangePicker/index.module.less +1 -1
  60. package/lib/components/DatePicker/StepPicker/index.module.less +1 -1
  61. package/lib/components/DatePicker/index.module.less +2 -1
  62. package/lib/components/Form/DrawerForm/index.module.less +2 -2
  63. package/lib/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -1
  64. package/lib/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
  65. package/lib/components/FormItem/FormRadio/index.module.less +9 -9
  66. package/lib/components/FormItem/FormSegmented/index.module.less +2 -2
  67. package/lib/components/FormItem/FormUpload/index.module.less +4 -4
  68. package/lib/components/FormItem/ItemContainer/index.module.less +22 -22
  69. package/lib/components/Icon/index.js +9 -27
  70. package/lib/components/Input/Number/index.module.less +9 -9
  71. package/lib/components/Input/Password/index.module.less +3 -3
  72. package/lib/components/Input/Range/index.module.less +4 -4
  73. package/lib/components/Input/Search/index.module.less +5 -5
  74. package/lib/components/Input/TextArea/index.module.less +5 -5
  75. package/lib/components/Input/index.module.less +7 -4
  76. package/lib/components/Modal/index.module.less +2 -2
  77. package/lib/components/Operate/index.module.less +2 -2
  78. package/lib/components/Panel/IframePanel/index.module.less +1 -1
  79. package/lib/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  80. package/lib/components/Search/index.module.less +2 -2
  81. package/lib/components/Select/AutoCompleteSelect/index.module.less +35 -35
  82. package/lib/components/Select/IconSelect/index.module.less +3 -3
  83. package/lib/components/Select/TreeSelect/index.module.less +17 -17
  84. package/lib/components/Select/_utils/getElementPosition.d.ts +6 -2
  85. package/lib/components/Select/_utils/getElementPosition.js +8 -6
  86. package/lib/components/Select/index.module.less +37 -34
  87. package/lib/components/Slider/index.module.less +5 -4
  88. package/lib/components/Spreadsheet/index.module.less +4 -4
  89. package/lib/components/Switch/index.js +8 -4
  90. package/lib/components/Switch/index.module.less +7 -0
  91. package/lib/components/Table/_components/Pagination/index.module.less +23 -23
  92. package/lib/components/Table/index.module.less +61 -61
  93. package/lib/components/Tree/index.module.less +11 -11
  94. package/lib/components/Upload/index.module.less +3 -3
  95. package/lib/styles/antd-overload.less +1 -1
  96. package/package.json +1 -1
  97. package/src/components/Button/index.md +20 -4
  98. package/src/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
  99. package/src/components/ChainGraph/_components/SearchSelect/index.tsx +18 -16
  100. package/src/components/ChainGraph/index.md +67 -1
  101. package/src/components/ChainGraph/index.module.less +1 -1
  102. package/src/components/Chart/index.md +351 -1
  103. package/src/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  104. package/src/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  105. package/src/components/Chat/ChatInput/index.module.less +2 -2
  106. package/src/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  107. package/src/components/Chat/index.md +140 -1
  108. package/src/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  109. package/src/components/Checkbox/index.md +85 -1
  110. package/src/components/Checkbox/index.module.less +13 -13
  111. package/src/components/CodeMirror/index.md +41 -1
  112. package/src/components/CodeMirror/index.module.less +4 -4
  113. package/src/components/Copy/index.md +1 -1
  114. package/src/components/DatePicker/RangePicker/index.module.less +1 -1
  115. package/src/components/DatePicker/StepPicker/index.module.less +1 -1
  116. package/src/components/DatePicker/index.md +82 -1
  117. package/src/components/DatePicker/index.module.less +2 -1
  118. package/src/components/Descriptions/index.md +45 -1
  119. package/src/components/Editor/index.md +40 -1
  120. package/src/components/FileCol/index.md +24 -1
  121. package/src/components/FilePreview/index.md +45 -1
  122. package/src/components/FlexFill/index.md +46 -1
  123. package/src/components/Form/DrawerForm/index.module.less +2 -2
  124. package/src/components/Form/index.md +179 -1
  125. package/src/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
  126. package/src/components/FormItem/FormInput/FormPasswordStrength/index.tsx +2 -2
  127. package/src/components/FormItem/FormRadio/index.module.less +9 -9
  128. package/src/components/FormItem/FormSegmented/index.module.less +2 -2
  129. package/src/components/FormItem/FormUpload/index.module.less +4 -4
  130. package/src/components/FormItem/ItemContainer/index.module.less +22 -22
  131. package/src/components/FormItem/index.md +514 -1
  132. package/src/components/Icon/index.md +24 -4
  133. package/src/components/Icon/index.tsx +9 -37
  134. package/src/components/Input/Number/index.module.less +9 -9
  135. package/src/components/Input/Password/index.module.less +3 -3
  136. package/src/components/Input/Range/index.module.less +4 -4
  137. package/src/components/Input/Search/index.module.less +5 -5
  138. package/src/components/Input/TextArea/index.module.less +5 -5
  139. package/src/components/Input/index.md +148 -1
  140. package/src/components/Input/index.module.less +7 -4
  141. package/src/components/Markdown/index.md +73 -1
  142. package/src/components/Modal/index.md +43 -1
  143. package/src/components/Modal/index.module.less +2 -2
  144. package/src/components/Operate/index.md +43 -1
  145. package/src/components/Operate/index.module.less +2 -2
  146. package/src/components/Panel/IframePanel/index.module.less +1 -1
  147. package/src/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  148. package/src/components/Panel/index.md +193 -1
  149. package/src/components/Search/index.md +248 -1
  150. package/src/components/Search/index.module.less +2 -2
  151. package/src/components/SecondConf/index.md +39 -1
  152. package/src/components/Select/AutoCompleteSelect/index.module.less +35 -35
  153. package/src/components/Select/IconSelect/index.module.less +3 -3
  154. package/src/components/Select/TreeSelect/index.module.less +17 -17
  155. package/src/components/Select/_utils/getElementPosition.ts +8 -6
  156. package/src/components/Select/index.md +47 -1
  157. package/src/components/Select/index.module.less +37 -34
  158. package/src/components/Slider/index.md +28 -1
  159. package/src/components/Slider/index.module.less +5 -4
  160. package/src/components/Spreadsheet/index.md +42 -1
  161. package/src/components/Spreadsheet/index.module.less +4 -4
  162. package/src/components/Switch/index.md +33 -1
  163. package/src/components/Switch/index.module.less +7 -0
  164. package/src/components/Switch/index.tsx +14 -11
  165. package/src/components/TabBar/index.md +70 -1
  166. package/src/components/Table/_components/Pagination/index.module.less +23 -23
  167. package/src/components/Table/index.md +60 -1
  168. package/src/components/Table/index.module.less +61 -61
  169. package/src/components/Tags/index.md +23 -1
  170. package/src/components/TextEllipsis/index.md +29 -1
  171. package/src/components/Tree/index.md +66 -1
  172. package/src/components/Tree/index.module.less +11 -11
  173. package/src/components/Upload/index.md +72 -1
  174. package/src/components/Upload/index.module.less +3 -3
  175. package/src/styles/antd-overload.less +1 -1
@@ -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
  }
@@ -8,10 +8,81 @@ title: Upload 上传
8
8
 
9
9
  # Upload 上传
10
10
 
11
- > `Upload` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ antd `Upload` 之上封装,内置普通上传与分片(断点)上传、上传进度、文件列表自定义渲染、下载与文件预览能力。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Upload } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 上传
20
+
21
+ > 演示用的 `action` 为占位地址,真实使用时需替换为可用的上传接口(普通上传用 `action`,分片上传用 `chunkAction` / `mergeChunkAction`)。
22
+
23
+ ```tsx
24
+ import React, { useState } from "react";
25
+ import { Upload } from "@hsu-react/ui";
26
+ import { Button } from "antd";
27
+
28
+ export default () => {
29
+ const [fileList, setFileList] = useState([]);
30
+
31
+ return (
32
+ <Upload
33
+ action="/api/upload"
34
+ data={{ bizType: "demo" }}
35
+ fileList={fileList}
36
+ onChange={({ fileList }) => setFileList(fileList)}
37
+ >
38
+ <Button>点击上传</Button>
39
+ </Upload>
40
+ );
41
+ };
42
+ ```
43
+
44
+ 拖拽上传,通过 `drop` 开启:
45
+
46
+ ```tsx
47
+ import React, { useState } from "react";
48
+ import { Upload } from "@hsu-react/ui";
49
+
50
+ export default () => {
51
+ const [fileList, setFileList] = useState([]);
52
+
53
+ return (
54
+ <Upload
55
+ drop
56
+ action="/api/upload"
57
+ accept=".zip,.pdf"
58
+ fileList={fileList}
59
+ onChange={({ fileList }) => setFileList(fileList)}
60
+ >
61
+ <p style={{ padding: 16, margin: 0 }}>将文件拖到此处,或点击上传</p>
62
+ </Upload>
63
+ );
64
+ };
65
+ ```
66
+
67
+ ## API
68
+
69
+ 继承 antd [UploadProps](https://ant.design/components/upload-cn)(移除原 `action`、`data` 后重新定义),新增/重写属性如下:
70
+
71
+ | 属性 | 说明 | 类型 | 默认值 |
72
+ | --- | --- | --- | --- |
73
+ | action | 普通上传地址 | `string` | - |
74
+ | data | 上传时附带的额外参数 | `Partial<Record<string, string>>` | - |
75
+ | drop | 是否使用拖拽上传 | `true` | - |
76
+ | sharding | 是否启用分片上传 | `boolean` | - |
77
+ | chunkAction | 分片上传地址 | `string` | - |
78
+ | mergeChunkAction | 分片合并地址 | `string` | - |
79
+ | chunkNum | 分片并发数 | `number` | `3` |
80
+ | size | 文件大小限制(MB) | `number` | - |
81
+ | onUploading | 上传中文件列表变化回调 | `(fileList: UploadFile[]) => void` | - |
82
+ | onUploadingList | 上传中(含取消器)列表变化回调 | `(list: Record<string, Canceler[]>) => void` | - |
83
+ | onUploadSuccess | 单个文件上传成功回调 | `() => void` | - |
84
+ | rmFile | 需要从列表中移除的文件标识 | `string` | - |
85
+ | listProps | 文件列表项渲染配置(名称、进度、下载、预览、删除等) | `object` | - |
86
+ | en | 是否使用英文文案 | `boolean` | - |
87
+
88
+ > 文件列表项内置下载与预览(依赖 `FilePreview`),可通过 `listProps.itemPreview.formatInfo` / `listProps.itemDownload.formatUrl` 自定义。
@@ -4,18 +4,18 @@
4
4
  width: 100%;
5
5
  height: 100%;
6
6
 
7
- span.ant-upload {
7
+ span:global(.ant-upload) {
8
8
  display: inline-flex;
9
9
  }
10
10
 
11
- .ant-upload-list {
11
+ :global(.ant-upload-list) {
12
12
  display: flex;
13
13
  flex-direction: column;
14
14
  row-gap: 5px;
15
15
 
16
16
  width: 100%;
17
17
 
18
- &.ant-upload-list-picture-card {
18
+ &:global(.ant-upload-list-picture-card) {
19
19
  flex-direction: row;
20
20
  flex-wrap: wrap;
21
21
  gap: 5px;
@@ -130,4 +130,4 @@
130
130
  }
131
131
  }
132
132
  }
133
- }
133
+ }