seven-design-ui 0.0.7 → 0.0.8

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 (37) hide show
  1. package/docs/components/table.mdx +853 -0
  2. package/docs/doc_build/404.html +4 -4
  3. package/docs/doc_build/CHANGELOG.html +4 -14
  4. package/docs/doc_build/components/button.html +4 -28
  5. package/docs/doc_build/components/cascader.html +4 -34
  6. package/docs/doc_build/components/form.html +4 -47
  7. package/docs/doc_build/components/input.html +4 -28
  8. package/docs/doc_build/components/message.html +4 -34
  9. package/docs/doc_build/components/pagination.html +4 -28
  10. package/docs/doc_build/components/switch.html +4 -27
  11. package/docs/doc_build/components/table.html +15 -0
  12. package/docs/doc_build/guide/introduction.html +4 -45
  13. package/docs/doc_build/guide/quick-start.html +4 -87
  14. package/docs/doc_build/guide/theme.html +4 -128
  15. package/docs/doc_build/index.html +4 -4
  16. package/docs/doc_build/static/css/{styles.67114bef.css → styles.90fb98bd.css} +1 -1
  17. package/docs/doc_build/static/js/414.9945b82b.js +6 -0
  18. package/docs/doc_build/static/js/async/166.d636f95e.js +13 -0
  19. package/docs/doc_build/static/js/async/805.1240df33.js +1 -0
  20. package/docs/doc_build/static/js/async/816.948438b5.js +1 -0
  21. package/docs/doc_build/static/js/index.7edcc197.js +1 -0
  22. package/docs/doc_build/static/{search_index.767efa49.json → search_index.ba6ba2c0.json} +1 -1
  23. package/docs/rspress.config.ts +132 -128
  24. package/package.json +1 -1
  25. package/packages/components/src/index.ts +1 -0
  26. package/packages/components/src/message/index.ts +2 -1
  27. package/packages/components/src/table/Table.tsx +412 -0
  28. package/packages/components/src/table/index.ts +2 -0
  29. package/packages/components/src/table/table.css +274 -0
  30. package/play/src/App.tsx +115 -1
  31. package/play/src/main.tsx +1 -1
  32. package/play/vite.config.ts +11 -0
  33. package/docs/doc_build/static/js/414.4bd5c320.js +0 -6
  34. package/docs/doc_build/static/js/async/166.1ad39714.js +0 -13
  35. package/docs/doc_build/static/js/index.37901975.js +0 -1
  36. /package/docs/doc_build/static/js/{414.4bd5c320.js.LICENSE.txt → 414.9945b82b.js.LICENSE.txt} +0 -0
  37. /package/docs/doc_build/static/js/async/{166.1ad39714.js.LICENSE.txt → 166.d636f95e.js.LICENSE.txt} +0 -0
@@ -0,0 +1,853 @@
1
+ import { Table, Button } from '@seven-design-ui/components'
2
+ import React from 'react'
3
+
4
+ # Table 表格
5
+
6
+ 用于展示多条结构类似的数据,可以对数据进行排序、筛选、对比或其他自定义操作。
7
+
8
+ ## 基础用法
9
+
10
+ 基础的表格展示用法。
11
+
12
+ ```tsx preview
13
+ export default function Demo() {
14
+ const tableData = [
15
+ {
16
+ id: 1,
17
+ name: '张三',
18
+ age: 25,
19
+ gender: '男',
20
+ city: '北京',
21
+ score: 85
22
+ },
23
+ {
24
+ id: 2,
25
+ name: '李四',
26
+ age: 30,
27
+ gender: '女',
28
+ city: '上海',
29
+ score: 92
30
+ },
31
+ {
32
+ id: 3,
33
+ name: '王五',
34
+ age: 28,
35
+ gender: '男',
36
+ city: '广州',
37
+ score: 78
38
+ },
39
+ {
40
+ id: 4,
41
+ name: '赵六',
42
+ age: 22,
43
+ gender: '女',
44
+ city: '深圳',
45
+ score: 88
46
+ }
47
+ ]
48
+
49
+ const columns = [
50
+ {
51
+ prop: 'name',
52
+ label: '姓名',
53
+ width: 120
54
+ },
55
+ {
56
+ prop: 'age',
57
+ label: '年龄',
58
+ width: 80
59
+ },
60
+ {
61
+ prop: 'gender',
62
+ label: '性别',
63
+ width: 80
64
+ },
65
+ {
66
+ prop: 'city',
67
+ label: '城市',
68
+ width: 120
69
+ },
70
+ {
71
+ prop: 'score',
72
+ label: '分数',
73
+ width: 80
74
+ }
75
+ ]
76
+
77
+ return (
78
+ <Table
79
+ data={tableData}
80
+ columns={columns}
81
+ style={{ width: '100%' }}
82
+ />
83
+ )
84
+ }
85
+ ```
86
+
87
+ ## 带斑马纹表格
88
+
89
+ 使用带斑马纹的表格,可以更容易区分出不同行的数据。
90
+
91
+ `stripe` 可以创建带斑马纹的表格。 如果为 true, 表格将会带有斑马纹。
92
+
93
+ ```tsx preview
94
+ export default function Demo() {
95
+ const tableData = [
96
+ {
97
+ id: 1,
98
+ name: '张三',
99
+ age: 25,
100
+ gender: '男',
101
+ city: '北京',
102
+ score: 85
103
+ },
104
+ {
105
+ id: 2,
106
+ name: '李四',
107
+ age: 30,
108
+ gender: '女',
109
+ city: '上海',
110
+ score: 92
111
+ },
112
+ {
113
+ id: 3,
114
+ name: '王五',
115
+ age: 28,
116
+ gender: '男',
117
+ city: '广州',
118
+ score: 78
119
+ },
120
+ {
121
+ id: 4,
122
+ name: '赵六',
123
+ age: 22,
124
+ gender: '女',
125
+ city: '深圳',
126
+ score: 88
127
+ }
128
+ ]
129
+
130
+ const columns = [
131
+ {
132
+ prop: 'name',
133
+ label: '姓名',
134
+ width: 120
135
+ },
136
+ {
137
+ prop: 'age',
138
+ label: '年龄',
139
+ width: 80
140
+ },
141
+ {
142
+ prop: 'gender',
143
+ label: '性别',
144
+ width: 80
145
+ },
146
+ {
147
+ prop: 'city',
148
+ label: '城市',
149
+ width: 120
150
+ },
151
+ {
152
+ prop: 'score',
153
+ label: '分数',
154
+ width: 80
155
+ }
156
+ ]
157
+
158
+ return (
159
+ <Table
160
+ data={tableData}
161
+ columns={columns}
162
+ stripe={true}
163
+ style={{ width: '100%' }}
164
+ />
165
+ )
166
+ }
167
+ ```
168
+
169
+ ## 带边框表格
170
+
171
+ 默认情况下,Table 组件是不具有竖直方向的边框的,如果需要,可以使用 `border` 属性,把该属性设置为 true 即可启用。
172
+
173
+ ```tsx preview
174
+ export default function Demo() {
175
+ const tableData = [
176
+ {
177
+ id: 1,
178
+ name: '张三',
179
+ age: 25,
180
+ gender: '男',
181
+ city: '北京',
182
+ score: 85
183
+ },
184
+ {
185
+ id: 2,
186
+ name: '李四',
187
+ age: 30,
188
+ gender: '女',
189
+ city: '上海',
190
+ score: 92
191
+ },
192
+ {
193
+ id: 3,
194
+ name: '王五',
195
+ age: 28,
196
+ gender: '男',
197
+ city: '广州',
198
+ score: 78
199
+ },
200
+ {
201
+ id: 4,
202
+ name: '赵六',
203
+ age: 22,
204
+ gender: '女',
205
+ city: '深圳',
206
+ score: 88
207
+ }
208
+ ]
209
+
210
+ const columns = [
211
+ {
212
+ prop: 'name',
213
+ label: '姓名',
214
+ width: 120
215
+ },
216
+ {
217
+ prop: 'age',
218
+ label: '年龄',
219
+ width: 80
220
+ },
221
+ {
222
+ prop: 'gender',
223
+ label: '性别',
224
+ width: 80
225
+ },
226
+ {
227
+ prop: 'city',
228
+ label: '城市',
229
+ width: 120
230
+ },
231
+ {
232
+ prop: 'score',
233
+ label: '分数',
234
+ width: 80
235
+ }
236
+ ]
237
+
238
+ return (
239
+ <Table
240
+ data={tableData}
241
+ columns={columns}
242
+ border={true}
243
+ style={{ width: '100%' }}
244
+ />
245
+ )
246
+ }
247
+ ```
248
+
249
+ ## 带状态表格
250
+
251
+ 可将表格内容 highlight 显示,方便区分「成功、信息、警告、危险」等内容。
252
+
253
+ 可以通过指定 Table 组件的 `rowClassName` 属性来为 Table 中的某一行添加 class, 这样就可以自定义每一行的样式了。
254
+
255
+ ```tsx preview
256
+ export default function Demo() {
257
+ const tableData = [
258
+ {
259
+ id: 1,
260
+ name: '张三',
261
+ age: 25,
262
+ gender: '男',
263
+ city: '北京',
264
+ score: 85
265
+ },
266
+ {
267
+ id: 2,
268
+ name: '李四',
269
+ age: 30,
270
+ gender: '女',
271
+ city: '上海',
272
+ score: 92
273
+ },
274
+ {
275
+ id: 3,
276
+ name: '王五',
277
+ age: 28,
278
+ gender: '男',
279
+ city: '广州',
280
+ score: 78
281
+ },
282
+ {
283
+ id: 4,
284
+ name: '赵六',
285
+ age: 22,
286
+ gender: '女',
287
+ city: '深圳',
288
+ score: 88
289
+ }
290
+ ]
291
+
292
+ const columns = [
293
+ {
294
+ prop: 'name',
295
+ label: '姓名',
296
+ width: 120
297
+ },
298
+ {
299
+ prop: 'age',
300
+ label: '年龄',
301
+ width: 80
302
+ },
303
+ {
304
+ prop: 'gender',
305
+ label: '性别',
306
+ width: 80
307
+ },
308
+ {
309
+ prop: 'city',
310
+ label: '城市',
311
+ width: 120
312
+ },
313
+ {
314
+ prop: 'score',
315
+ label: '分数',
316
+ width: 80,
317
+ render: (value) => {
318
+ if (value >= 90) return <span style={{ color: '#67c23a' }}>{value} (优秀)</span>
319
+ if (value >= 80) return <span style={{ color: '#e6a23c' }}>{value} (良好)</span>
320
+ if (value >= 70) return <span style={{ color: '#f56c6c' }}>{value} (及格)</span>
321
+ return <span style={{ color: '#f56c6c' }}>{value} (不及格)</span>
322
+ }
323
+ }
324
+ ]
325
+
326
+ const getRowClassName = (row, index) => {
327
+ if (row.score >= 90) return 'seven-table__row--success'
328
+ if (row.score >= 80) return 'seven-table__row--warning'
329
+ if (row.score >= 70) return 'seven-table__row--info'
330
+ return 'seven-table__row--danger'
331
+ }
332
+
333
+ return (
334
+ <Table
335
+ data={tableData}
336
+ columns={columns}
337
+ rowClassName={getRowClassName}
338
+ style={{ width: '100%' }}
339
+ />
340
+ )
341
+ }
342
+ ```
343
+
344
+ ## 固定表头
345
+
346
+ 纵向内容过多时,可选择固定表头。
347
+
348
+ 只要在 `el-table` 元素中定义了 `height` 属性,即可实现固定表头的表格,而不需要额外的代码。
349
+
350
+ ```tsx preview
351
+ export default function Demo() {
352
+ const columns = [
353
+ {
354
+ prop: 'id',
355
+ label: 'ID',
356
+ width: 80
357
+ },
358
+ {
359
+ prop: 'name',
360
+ label: '姓名',
361
+ width: 120
362
+ },
363
+ {
364
+ prop: 'age',
365
+ label: '年龄',
366
+ width: 80
367
+ },
368
+ {
369
+ prop: 'gender',
370
+ label: '性别',
371
+ width: 80
372
+ },
373
+ {
374
+ prop: 'city',
375
+ label: '城市',
376
+ width: 120
377
+ },
378
+ {
379
+ prop: 'score',
380
+ label: '分数',
381
+ width: 80
382
+ },
383
+ {
384
+ prop: 'description',
385
+ label: '描述',
386
+ width: 200,
387
+ render: () => '这是一个很长的描述文本,用来测试固定表头的效果。当内容很长时,表头会保持固定在顶部。'
388
+ }
389
+ ]
390
+
391
+ const tableData = [
392
+ {
393
+ id: 1,
394
+ name: '张三',
395
+ age: 25,
396
+ gender: '男',
397
+ city: '北京',
398
+ score: 85
399
+ },
400
+ {
401
+ id: 2,
402
+ name: '李四',
403
+ age: 30,
404
+ gender: '女',
405
+ city: '上海',
406
+ score: 92
407
+ },
408
+ {
409
+ id: 3,
410
+ name: '王五',
411
+ age: 28,
412
+ gender: '男',
413
+ city: '广州',
414
+ score: 78
415
+ },
416
+ {
417
+ id: 4,
418
+ name: '赵六',
419
+ age: 22,
420
+ gender: '女',
421
+ city: '深圳',
422
+ score: 88
423
+ }
424
+ ]
425
+
426
+ // 生成更多数据
427
+ const moreData = Array.from({ length: 20 }, (_, index) => ({
428
+ ...tableData[index % tableData.length],
429
+ id: index + 1,
430
+ description: `描述 ${index + 1}`
431
+ }))
432
+
433
+ return (
434
+ <Table
435
+ data={moreData}
436
+ columns={columns}
437
+ height={300}
438
+ style={{ width: '100%' }}
439
+ />
440
+ )
441
+ }
442
+ ```
443
+
444
+ ## 固定列
445
+
446
+ 横向内容过多时,可选择固定列。
447
+
448
+ 固定列需要使用 `fixed` 属性,它接受 Boolean 值。如果为 true, 列将被左侧固定. 它还接受传入字符串,`left` 或 `right`,表示左边固定还是右边固定。
449
+
450
+ ```tsx preview
451
+ export default function Demo() {
452
+ const tableData = [
453
+ {
454
+ id: 1,
455
+ name: '张三',
456
+ age: 25,
457
+ gender: '男',
458
+ city: '北京',
459
+ score: 85
460
+ },
461
+ {
462
+ id: 2,
463
+ name: '李四',
464
+ age: 30,
465
+ gender: '女',
466
+ city: '上海',
467
+ score: 92
468
+ },
469
+ {
470
+ id: 3,
471
+ name: '王五',
472
+ age: 28,
473
+ gender: '男',
474
+ city: '广州',
475
+ score: 78
476
+ },
477
+ {
478
+ id: 4,
479
+ name: '赵六',
480
+ age: 22,
481
+ gender: '女',
482
+ city: '深圳',
483
+ score: 88
484
+ }
485
+ ]
486
+
487
+ const columns = [
488
+ {
489
+ prop: 'id',
490
+ label: 'ID',
491
+ width: 80,
492
+ fixed: true
493
+ },
494
+ {
495
+ prop: 'name',
496
+ label: '姓名',
497
+ width: 120,
498
+ fixed: true
499
+ },
500
+ {
501
+ prop: 'age',
502
+ label: '年龄',
503
+ width: 80
504
+ },
505
+ {
506
+ prop: 'gender',
507
+ label: '性别',
508
+ width: 80
509
+ },
510
+ {
511
+ prop: 'city',
512
+ label: '城市',
513
+ width: 120
514
+ },
515
+ {
516
+ prop: 'score',
517
+ label: '分数',
518
+ width: 80
519
+ },
520
+ {
521
+ prop: 'address',
522
+ label: '地址',
523
+ width: 200,
524
+ render: () => '北京市朝阳区建国门外大街1号中国国际贸易中心'
525
+ },
526
+ {
527
+ prop: 'phone',
528
+ label: '电话',
529
+ width: 150,
530
+ render: () => '138-0000-0000'
531
+ },
532
+ {
533
+ prop: 'email',
534
+ label: '邮箱',
535
+ width: 200,
536
+ render: () => 'user@example.com'
537
+ },
538
+ {
539
+ prop: 'action',
540
+ label: '操作',
541
+ width: 160,
542
+ fixed: 'right',
543
+ render: () => (
544
+ <div>
545
+ <Button type="primary">编辑</Button>
546
+ <Button type="danger">删除</Button>
547
+ </div>
548
+ )
549
+ }
550
+ ]
551
+
552
+ return (
553
+ <Table
554
+ data={tableData}
555
+ columns={columns}
556
+ height={300}
557
+ style={{ width: '100%' }}
558
+ />
559
+ )
560
+ }
561
+ ```
562
+
563
+ ## 固定列和表头
564
+
565
+ 当您有大量数据块放入表中,您可以同时固定表头和列。
566
+
567
+ 固定列和表头可以同时使用,只需要将上述两个属性分别设置好即可。
568
+
569
+ ```tsx preview
570
+ export default function Demo() {
571
+ const columns = [
572
+ {
573
+ prop: 'id',
574
+ label: 'ID',
575
+ width: 80,
576
+ fixed: true
577
+ },
578
+ {
579
+ prop: 'name',
580
+ label: '姓名',
581
+ width: 120,
582
+ fixed: true
583
+ },
584
+ {
585
+ prop: 'age',
586
+ label: '年龄',
587
+ width: 80
588
+ },
589
+ {
590
+ prop: 'gender',
591
+ label: '性别',
592
+ width: 80
593
+ },
594
+ {
595
+ prop: 'city',
596
+ label: '城市',
597
+ width: 120
598
+ },
599
+ {
600
+ prop: 'score',
601
+ label: '分数',
602
+ width: 80
603
+ },
604
+ {
605
+ prop: 'description',
606
+ label: '描述',
607
+ width: 300,
608
+ render: (value, row) => `${row.name}的详细描述信息,这里包含了很多文字内容,用来测试固定表头和固定列的效果。`
609
+ },
610
+ {
611
+ prop: 'action',
612
+ label: '操作',
613
+ width: 160,
614
+ fixed: 'right',
615
+ render: () => (
616
+ <div>
617
+ <Button type="primary">编辑</Button>
618
+ <Button type="danger">删除</Button>
619
+ </div>
620
+ )
621
+ }
622
+ ]
623
+
624
+ const tableData = [
625
+ {
626
+ id: 1,
627
+ name: '张三',
628
+ age: 25,
629
+ gender: '男',
630
+ city: '北京',
631
+ score: 85
632
+ },
633
+ {
634
+ id: 2,
635
+ name: '李四',
636
+ age: 30,
637
+ gender: '女',
638
+ city: '上海',
639
+ score: 92
640
+ },
641
+ {
642
+ id: 3,
643
+ name: '王五',
644
+ age: 28,
645
+ gender: '男',
646
+ city: '广州',
647
+ score: 78
648
+ },
649
+ {
650
+ id: 4,
651
+ name: '赵六',
652
+ age: 22,
653
+ gender: '女',
654
+ city: '深圳',
655
+ score: 88
656
+ }
657
+ ]
658
+
659
+ // 生成更多数据
660
+ const moreData = Array.from({ length: 50 }, (_, index) => ({
661
+ ...tableData[index % tableData.length],
662
+ id: index + 1
663
+ }))
664
+
665
+ return (
666
+ <Table
667
+ data={moreData}
668
+ columns={columns}
669
+ height={400}
670
+ style={{ width: '100%' }}
671
+ />
672
+ )
673
+ }
674
+ ```
675
+
676
+ ## 流体高度
677
+
678
+ 当数据量动态变化时,可以为 Table 设置一个最大高度。
679
+
680
+ 通过设置 `maxHeight` 属性为 Table 指定最大高度。此时若表格所需的高度大于最大高度,则会显示一个滚动条。
681
+
682
+ ```tsx preview
683
+ export default function Demo() {
684
+ const columns = [
685
+ {
686
+ prop: 'name',
687
+ label: '姓名',
688
+ width: 120
689
+ },
690
+ {
691
+ prop: 'age',
692
+ label: '年龄',
693
+ width: 80
694
+ },
695
+ {
696
+ prop: 'gender',
697
+ label: '性别',
698
+ width: 80
699
+ },
700
+ {
701
+ prop: 'city',
702
+ label: '城市',
703
+ width: 120
704
+ },
705
+ {
706
+ prop: 'score',
707
+ label: '分数',
708
+ width: 80
709
+ }
710
+ ]
711
+
712
+ // 生成大量数据
713
+ const largeData = Array.from({ length: 100 }, (_, index) => ({
714
+ id: index + 1,
715
+ name: `用户${index + 1}`,
716
+ age: 20 + (index % 30),
717
+ gender: index % 2 === 0 ? '男' : '女',
718
+ city: ['北京', '上海', '广州', '深圳', '杭州'][index % 5],
719
+ score: 60 + (index % 40)
720
+ }))
721
+
722
+ return (
723
+ <Table
724
+ data={largeData}
725
+ columns={columns}
726
+ maxHeight={400}
727
+ style={{ width: '100%' }}
728
+ />
729
+ )
730
+ }
731
+ ```
732
+
733
+ ## 排序
734
+
735
+ 对表格进行排序,可快速查找或对比数据。
736
+
737
+ 在列中设置 `sortable` 属性即可实现以该列为基准的排序,接受一个 Boolean,默认为 false。可以通过 Table 的 `defaultSort` 属性设置默认的排序列和排序顺序。可以使用 `sortMethod` 或者 `sortBy` 使用自定义的排序规则。如果需要后端排序,需将 `sortable` 设置为 `custom`,同时在 Table 上监听 `onSortChange` 事件,在事件回调中可以获取当前排序的字段名和排序顺序,从而向接口请求排序后的表格数据。
738
+
739
+ ```tsx preview
740
+ export default function Demo() {
741
+ const columns = [
742
+ {
743
+ prop: 'name',
744
+ label: '姓名',
745
+ width: 120,
746
+ },
747
+ {
748
+ prop: 'age',
749
+ label: '年龄',
750
+ width: 80,
751
+ sortable: true
752
+ },
753
+ {
754
+ prop: 'gender',
755
+ label: '性别',
756
+ width: 80,
757
+ sortable: true
758
+ },
759
+ {
760
+ prop: 'city',
761
+ label: '城市',
762
+ width: 120,
763
+ sortable: true
764
+ },
765
+ {
766
+ prop: 'score',
767
+ label: '分数',
768
+ width: 80,
769
+ sortable: true
770
+ }
771
+ ]
772
+
773
+ // 生成更多数据用于排序测试
774
+ const sortData = Array.from({ length: 10 }, (_, index) => ({
775
+ id: index + 1,
776
+ name: `用户${index + 1}`,
777
+ age: 20 + (index % 15),
778
+ gender: index % 2 === 0 ? '男' : '女',
779
+ city: ['北京', '上海', '广州', '深圳', '杭州'][index % 5],
780
+ score: 60 + (index % 40)
781
+ }))
782
+
783
+ return (
784
+ <Table
785
+ data={sortData}
786
+ columns={columns}
787
+ defaultSort={{ prop: 'score', order: 'descending' }}
788
+ style={{ width: '100%' }}
789
+ />
790
+ )
791
+ }
792
+ ```
793
+ ## API
794
+
795
+ ### Table Props
796
+
797
+ | 参数 | 说明 | 类型 | 可选值 | 默认值 |
798
+ | --- | --- | --- | --- | --- |
799
+ | data | 表格数据 | `T[]` | - | `[]` |
800
+ | columns | 表格列配置 | `TableColumn<T>[]` | - | `[]` |
801
+ | stripe | 是否显示斑马纹 | `boolean` | - | `false` |
802
+ | border | 是否显示边框 | `boolean` | - | `false` |
803
+ | height | 表格高度 | `string \| number` | - | - |
804
+ | maxHeight | 表格最大高度 | `string \| number` | - | - |
805
+ | rowClassName | 行类名函数 | `string \| ((row: T, index: number) => string)` | - | - |
806
+ | rowStyle | 行样式函数 | `(row: T, index: number) => React.CSSProperties` | - | - |
807
+ | defaultSort | 默认排序 | `SortState` | - | - |
808
+ | onSortChange | 排序变化回调 | `(sort: SortState \| null) => void` | - | - |
809
+ | onFilterChange | 筛选变化回调 | `(filters: FilterState[]) => void` | - | - |
810
+ | onRowClick | 行点击事件 | `(row: T, index: number, event: React.MouseEvent) => void` | - | - |
811
+ | onRowDoubleClick | 行双击事件 | `(row: T, index: number, event: React.MouseEvent) => void` | - | - |
812
+ | onCellClick | 单元格点击事件 | `(row: T, column: TableColumn<T>, cellValue: any, event: React.MouseEvent) => void` | - | - |
813
+
814
+ ### TableColumn Props
815
+
816
+ | 参数 | 说明 | 类型 | 可选值 | 默认值 |
817
+ | --- | --- | --- | --- | --- |
818
+ | prop | 列的字段名 | `string` | - | - |
819
+ | label | 列的标题 | `string` | - | - |
820
+ | width | 列宽度 | `string \| number` | - | - |
821
+ | minWidth | 列最小宽度 | `string \| number` | - | - |
822
+ | fixed | 是否固定列 | `boolean \| 'left' \| 'right'` | - | `false` |
823
+ | sortable | 是否可排序 | `boolean \| 'custom'` | - | `false` |
824
+ | sortMethod | 自定义排序方法 | `(a: T, b: T) => number` | - | - |
825
+ | sortBy | 自定义排序字段 | `string \| ((row: T, index: number) => any)` | - | - |
826
+ | render | 自定义渲染函数 | `(value: any, row: T, index: number) => ReactNode` | - | - |
827
+ | formatter | 格式化函数 | `(row: T, column: TableColumn<T>, cellValue: any, index: number) => any` | - | - |
828
+ | filters | 筛选选项 | `Array<{ text: string; value: any }>` | - | - |
829
+ | filterMethod | 自定义筛选方法 | `(value: any, row: T, column: TableColumn<T>) => boolean` | - | - |
830
+ | filteredValue | 筛选的初始值 | `any[]` | - | - |
831
+ | className | 列类名 | `string` | - | - |
832
+ | style | 列样式 | `React.CSSProperties` | - | - |
833
+ | align | 对齐方式 | `'left' \| 'center' \| 'right'` | - | `'left'` |
834
+ | headerAlign | 表头对齐方式 | `'left' \| 'center' \| 'right'` | - | - |
835
+
836
+ ### Table Methods
837
+
838
+ | 方法名 | 说明 | 参数 |
839
+ | --- | --- | --- |
840
+ | sort | 手动排序 | `(prop: string, order: 'ascending' \| 'descending') => void` |
841
+ | clearSort | 清除排序 | `() => void` |
842
+ | filter | 手动筛选 | `(prop: string, values: any[]) => void` |
843
+ | clearFilter | 清除筛选 | `(prop?: string) => void` |
844
+
845
+ ### Events
846
+
847
+ | 事件名 | 说明 | 回调参数 |
848
+ | --- | --- | --- |
849
+ | onSortChange | 排序变化时触发 | `(sort: SortState \| null) => void` |
850
+ | onFilterChange | 筛选变化时触发 | `(filters: FilterState[]) => void` |
851
+ | onRowClick | 行点击时触发 | `(row: T, index: number, event: React.MouseEvent) => void` |
852
+ | onRowDoubleClick | 行双击时触发 | `(row: T, index: number, event: React.MouseEvent) => void` |
853
+ | onCellClick | 单元格点击时触发 | `(row: T, column: TableColumn<T>, cellValue: any, event: React.MouseEvent) => void` |