@kne/super-select 0.1.40 → 0.1.42
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 +475 -278
- package/dist/index.css +30 -21
- package/dist/index.css.map +1 -1
- package/dist/index.js +207 -118
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +186 -98
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -28,26 +28,27 @@ npm i --save @kne/super-select
|
|
|
28
28
|
|
|
29
29
|
#### 组件列表
|
|
30
30
|
|
|
31
|
-
| 组件名称
|
|
32
|
-
|
|
33
|
-
| SelectInput | 基础选择输入组件,用于自定义构建其他选择组件的核心基础
|
|
34
|
-
| SelectList | 列表选择组件,适用于常规列表选择场景
|
|
35
|
-
| SelectTableList |
|
|
36
|
-
| SelectedAll | 全选功能组件,提供一键选择/取消选择
|
|
37
|
-
| SelectTree | 树形选择组件,适用于层级数据
|
|
38
|
-
| SelectedTagList | 已选项标签列表组件
|
|
39
|
-
| SelectCascader | 级联选择组件,支持父子关联、搜索过滤
|
|
31
|
+
| 组件名称 | 功能描述 |
|
|
32
|
+
| --------------- | ------------------------------------------------------- |
|
|
33
|
+
| SelectInput | 基础选择输入组件,用于自定义构建其他选择组件的核心基础 |
|
|
34
|
+
| SelectList | 列表选择组件,适用于常规列表选择场景 |
|
|
35
|
+
| SelectTableList | 表格形式选择组件,支持多列数据与 tree/treeList 树形选择 |
|
|
36
|
+
| SelectedAll | 全选功能组件,提供一键选择/取消选择 |
|
|
37
|
+
| SelectTree | 树形选择组件,适用于层级数据 |
|
|
38
|
+
| SelectedTagList | 已选项标签列表组件 |
|
|
39
|
+
| SelectCascader | 级联选择组件,支持父子关联、搜索过滤 |
|
|
40
40
|
|
|
41
41
|
#### 快速选择指南
|
|
42
42
|
|
|
43
|
-
| 需求
|
|
44
|
-
|
|
45
|
-
| 自定义选择组件
|
|
46
|
-
| 简单列表选择
|
|
47
|
-
| 需要展示多列数据 | SelectTableList
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
43
|
+
| 需求 | 推荐组件 |
|
|
44
|
+
| ---------------- | ----------------------------------------- |
|
|
45
|
+
| 自定义选择组件 | SelectInput |
|
|
46
|
+
| 简单列表选择 | SelectList |
|
|
47
|
+
| 需要展示多列数据 | SelectTableList |
|
|
48
|
+
| 表格内树形选择 | SelectTableList(dataType=tree/treeList) |
|
|
49
|
+
| 层级数据选择 | SelectTree 或 SelectCascader |
|
|
50
|
+
| 全选/反选功能 | SelectedAll |
|
|
51
|
+
| 已选项标签展示 | SelectedTagList |
|
|
51
52
|
|
|
52
53
|
#### 快速开始
|
|
53
54
|
|
|
@@ -564,12 +565,12 @@ render(<BaseExample />);
|
|
|
564
565
|
```
|
|
565
566
|
|
|
566
567
|
- SelectTableList 表格选择
|
|
567
|
-
- 表格形式的选择组件,适合复杂数据的展示和选择,支持自定义列、搜索、单选/多选、renderMobile 自定义移动端卡片等
|
|
568
|
+
- 表格形式的选择组件,适合复杂数据的展示和选择,支持自定义列、搜索、单选/多选、tree/treeList 树形、checkRelation、懒加载、renderMobile 自定义移动端卡片等
|
|
568
569
|
- _SuperSelect(@kne/current-lib_super-select)[import * as _SuperSelect from "@kne/super-select"],antd(antd),(@kne/current-lib_super-select/dist/index.css)
|
|
569
570
|
|
|
570
571
|
```jsx
|
|
571
|
-
const { SelectTableList } = _SuperSelect;
|
|
572
|
-
const { Space, Button, Flex, Divider, Tag, Avatar, Switch, Checkbox } = antd;
|
|
572
|
+
const { SelectTableList, mergeTreeChildren } = _SuperSelect;
|
|
573
|
+
const { Space, Button, Flex, Divider, Tag, Avatar, Switch, Checkbox, Radio } = antd;
|
|
573
574
|
const { useState } = React;
|
|
574
575
|
|
|
575
576
|
// 模拟员工数据
|
|
@@ -589,7 +590,7 @@ const employeeColumns = [
|
|
|
589
590
|
name: 'name',
|
|
590
591
|
title: '姓名',
|
|
591
592
|
span: 6,
|
|
592
|
-
getValueOf:
|
|
593
|
+
getValueOf: item => (
|
|
593
594
|
<Flex align="center" gap={8}>
|
|
594
595
|
<Avatar size="small" style={{ backgroundColor: '#1677ff' }}>
|
|
595
596
|
{item.name.slice(-2)}
|
|
@@ -612,9 +613,7 @@ const employeeColumns = [
|
|
|
612
613
|
name: 'email',
|
|
613
614
|
title: '邮箱',
|
|
614
615
|
span: 6,
|
|
615
|
-
getValueOf:
|
|
616
|
-
<span style={{ color: '#666', fontSize: 12 }}>{item.email}</span>
|
|
617
|
-
)
|
|
616
|
+
getValueOf: item => <span style={{ color: '#666', fontSize: 12 }}>{item.email}</span>
|
|
618
617
|
},
|
|
619
618
|
{
|
|
620
619
|
name: 'options',
|
|
@@ -627,7 +626,7 @@ const employeeColumns = [
|
|
|
627
626
|
size="small"
|
|
628
627
|
danger
|
|
629
628
|
disabled={item.status === 'inactive'}
|
|
630
|
-
onClick={
|
|
629
|
+
onClick={e => {
|
|
631
630
|
e.stopPropagation();
|
|
632
631
|
console.log('删除员工:', item.name);
|
|
633
632
|
}}
|
|
@@ -659,35 +658,25 @@ const productColumns = [
|
|
|
659
658
|
name: 'category',
|
|
660
659
|
title: '分类',
|
|
661
660
|
span: 4,
|
|
662
|
-
getValueOf:
|
|
663
|
-
<Tag color="blue">{item.category}</Tag>
|
|
664
|
-
)
|
|
661
|
+
getValueOf: item => <Tag color="blue">{item.category}</Tag>
|
|
665
662
|
},
|
|
666
663
|
{
|
|
667
664
|
name: 'price',
|
|
668
665
|
title: '价格',
|
|
669
666
|
span: 4,
|
|
670
|
-
getValueOf:
|
|
667
|
+
getValueOf: item => `¥${item.price}`
|
|
671
668
|
},
|
|
672
669
|
{
|
|
673
670
|
name: 'stock',
|
|
674
671
|
title: '库存',
|
|
675
672
|
span: 4,
|
|
676
|
-
getValueOf:
|
|
677
|
-
<span style={{ color: item.stock < 50 ? 'red' : 'green' }}>
|
|
678
|
-
{item.stock}
|
|
679
|
-
</span>
|
|
680
|
-
)
|
|
673
|
+
getValueOf: item => <span style={{ color: item.stock < 50 ? 'red' : 'green' }}>{item.stock}</span>
|
|
681
674
|
},
|
|
682
675
|
{
|
|
683
676
|
name: 'status',
|
|
684
677
|
title: '状态',
|
|
685
678
|
span: 4,
|
|
686
|
-
getValueOf:
|
|
687
|
-
<Tag color={item.status === '在售' ? 'success' : 'default'}>
|
|
688
|
-
{item.status}
|
|
689
|
-
</Tag>
|
|
690
|
-
)
|
|
679
|
+
getValueOf: item => <Tag color={item.status === '在售' ? 'success' : 'default'}>{item.status}</Tag>
|
|
691
680
|
}
|
|
692
681
|
];
|
|
693
682
|
|
|
@@ -698,19 +687,11 @@ const BasicTableExample = ({ isPopup }) => {
|
|
|
698
687
|
return (
|
|
699
688
|
<Flex vertical gap={8}>
|
|
700
689
|
<span>多选表格:</span>
|
|
701
|
-
<SelectTableList
|
|
702
|
-
options={employeeOptions}
|
|
703
|
-
columns={employeeColumns}
|
|
704
|
-
valueKey="id"
|
|
705
|
-
labelKey="name"
|
|
706
|
-
value={value}
|
|
707
|
-
onChange={setValue}
|
|
708
|
-
isPopup={isPopup}
|
|
709
|
-
placeholder="请选择员工"
|
|
710
|
-
style={{ width: 600 }}
|
|
711
|
-
/>
|
|
690
|
+
<SelectTableList options={employeeOptions} columns={employeeColumns} valueKey="id" labelKey="name" value={value} onChange={setValue} isPopup={isPopup} placeholder="请选择员工" style={{ width: 600 }} />
|
|
712
691
|
{value.length > 0 && (
|
|
713
|
-
<div
|
|
692
|
+
<div>
|
|
693
|
+
已选 {value.length} 人:{value.map(item => item.name).join('、')}
|
|
694
|
+
</div>
|
|
714
695
|
)}
|
|
715
696
|
</Flex>
|
|
716
697
|
);
|
|
@@ -723,18 +704,7 @@ const SingleTableExample = ({ isPopup }) => {
|
|
|
723
704
|
return (
|
|
724
705
|
<Flex vertical gap={8}>
|
|
725
706
|
<span>单选表格:</span>
|
|
726
|
-
<SelectTableList
|
|
727
|
-
single
|
|
728
|
-
options={productOptions}
|
|
729
|
-
columns={productColumns}
|
|
730
|
-
valueKey="id"
|
|
731
|
-
labelKey="productName"
|
|
732
|
-
value={value}
|
|
733
|
-
onChange={setValue}
|
|
734
|
-
isPopup={isPopup}
|
|
735
|
-
placeholder="请选择产品"
|
|
736
|
-
style={{ width: 600 }}
|
|
737
|
-
/>
|
|
707
|
+
<SelectTableList single options={productOptions} columns={productColumns} valueKey="id" labelKey="productName" value={value} onChange={setValue} isPopup={isPopup} placeholder="请选择产品" style={{ width: 600 }} />
|
|
738
708
|
{value && <div>已选:{value.productName}</div>}
|
|
739
709
|
</Flex>
|
|
740
710
|
);
|
|
@@ -759,11 +729,7 @@ const SearchableTableExample = ({ isPopup }) => {
|
|
|
759
729
|
getSearchCallback={({ searchText }, item) => {
|
|
760
730
|
if (!searchText) return true;
|
|
761
731
|
const keyword = searchText.toLowerCase();
|
|
762
|
-
return (
|
|
763
|
-
item.name.toLowerCase().includes(keyword) ||
|
|
764
|
-
item.email.toLowerCase().includes(keyword) ||
|
|
765
|
-
item.department.toLowerCase().includes(keyword)
|
|
766
|
-
);
|
|
732
|
+
return item.name.toLowerCase().includes(keyword) || item.email.toLowerCase().includes(keyword) || item.department.toLowerCase().includes(keyword);
|
|
767
733
|
}}
|
|
768
734
|
style={{ width: 600 }}
|
|
769
735
|
/>
|
|
@@ -844,19 +810,17 @@ const DirectRenderExample = () => {
|
|
|
844
810
|
getSearchCallback={({ searchText }, item) => {
|
|
845
811
|
if (!searchText) return true;
|
|
846
812
|
const keyword = searchText.toLowerCase();
|
|
847
|
-
return (
|
|
848
|
-
item.name.toLowerCase().includes(keyword) ||
|
|
849
|
-
item.email.toLowerCase().includes(keyword) ||
|
|
850
|
-
item.department.toLowerCase().includes(keyword)
|
|
851
|
-
);
|
|
813
|
+
return item.name.toLowerCase().includes(keyword) || item.email.toLowerCase().includes(keyword) || item.department.toLowerCase().includes(keyword);
|
|
852
814
|
}}
|
|
853
815
|
style={{ width: '100%' }}
|
|
854
|
-
renderContent={
|
|
855
|
-
<div
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
816
|
+
renderContent={content => (
|
|
817
|
+
<div
|
|
818
|
+
style={{
|
|
819
|
+
border: '1px solid #d9d9d9',
|
|
820
|
+
borderRadius: 6,
|
|
821
|
+
padding: 16
|
|
822
|
+
}}
|
|
823
|
+
>
|
|
860
824
|
{content}
|
|
861
825
|
</div>
|
|
862
826
|
)}
|
|
@@ -893,13 +857,7 @@ const EmployeeMobileCard = ({ item, checked, disabled, onToggle }) => {
|
|
|
893
857
|
cursor: disabled ? 'not-allowed' : 'pointer'
|
|
894
858
|
}}
|
|
895
859
|
>
|
|
896
|
-
<Checkbox
|
|
897
|
-
checked={checked}
|
|
898
|
-
disabled={disabled}
|
|
899
|
-
onClick={e => e.stopPropagation()}
|
|
900
|
-
onChange={onToggle}
|
|
901
|
-
style={{ marginTop: 2, flexShrink: 0 }}
|
|
902
|
-
/>
|
|
860
|
+
<Checkbox checked={checked} disabled={disabled} onClick={e => e.stopPropagation()} onChange={onToggle} style={{ marginTop: 2, flexShrink: 0 }} />
|
|
903
861
|
<div style={{ flex: 1, minWidth: 0 }}>
|
|
904
862
|
{/* 主信息:姓名 + 状态 */}
|
|
905
863
|
<Flex justify="space-between" align="center" gap={8} style={{ marginBottom: 6 }}>
|
|
@@ -949,9 +907,7 @@ const CustomMobileCardExample = ({ isPopup }) => {
|
|
|
949
907
|
return (
|
|
950
908
|
<Flex vertical gap={8}>
|
|
951
909
|
<span>自定义移动端卡片(renderMobile):</span>
|
|
952
|
-
<div style={{ color: '#666', fontSize: 12, lineHeight: 1.6 }}>
|
|
953
|
-
仅移动端生效。主信息为大号姓名,次要为部门/职位,辅助为邮箱与入职日期。桌面端仍为普通表格。
|
|
954
|
-
</div>
|
|
910
|
+
<div style={{ color: '#666', fontSize: 12, lineHeight: 1.6 }}>仅移动端生效。主信息为大号姓名,次要为部门/职位,辅助为邮箱与入职日期。桌面端仍为普通表格。</div>
|
|
955
911
|
<SelectTableList
|
|
956
912
|
options={employeeOptions}
|
|
957
913
|
columns={employeeColumns}
|
|
@@ -964,11 +920,7 @@ const CustomMobileCardExample = ({ isPopup }) => {
|
|
|
964
920
|
getSearchCallback={({ searchText }, item) => {
|
|
965
921
|
if (!searchText) return true;
|
|
966
922
|
const keyword = searchText.toLowerCase();
|
|
967
|
-
return (
|
|
968
|
-
item.name.toLowerCase().includes(keyword) ||
|
|
969
|
-
item.email.toLowerCase().includes(keyword) ||
|
|
970
|
-
item.department.toLowerCase().includes(keyword)
|
|
971
|
-
);
|
|
923
|
+
return item.name.toLowerCase().includes(keyword) || item.email.toLowerCase().includes(keyword) || item.department.toLowerCase().includes(keyword);
|
|
972
924
|
}}
|
|
973
925
|
style={{ width: 600 }}
|
|
974
926
|
renderMobile={({ list, value: selected, setValue: setSelected, props: selectProps, isSelectedAll }) => (
|
|
@@ -989,9 +941,7 @@ const CustomMobileCardExample = ({ isPopup }) => {
|
|
|
989
941
|
setSelected([item]);
|
|
990
942
|
return;
|
|
991
943
|
}
|
|
992
|
-
setSelected(prev =>
|
|
993
|
-
isChecked ? prev.filter(target => target.id !== item.id) : [...prev, item]
|
|
994
|
-
);
|
|
944
|
+
setSelected(prev => (isChecked ? prev.filter(target => target.id !== item.id) : [...prev, item]));
|
|
995
945
|
}}
|
|
996
946
|
/>
|
|
997
947
|
);
|
|
@@ -1000,7 +950,240 @@ const CustomMobileCardExample = ({ isPopup }) => {
|
|
|
1000
950
|
)}
|
|
1001
951
|
/>
|
|
1002
952
|
{value.length > 0 && (
|
|
1003
|
-
<div
|
|
953
|
+
<div>
|
|
954
|
+
已选 {value.length} 人:{value.map(item => item.name).join('、')}
|
|
955
|
+
</div>
|
|
956
|
+
)}
|
|
957
|
+
</Flex>
|
|
958
|
+
);
|
|
959
|
+
};
|
|
960
|
+
|
|
961
|
+
const orgTreeColumns = [
|
|
962
|
+
{ name: 'name', title: '名称', span: 8 },
|
|
963
|
+
{ name: 'code', title: '编码', span: 6 },
|
|
964
|
+
{ name: 'owner', title: '负责人', span: 6 },
|
|
965
|
+
{
|
|
966
|
+
name: 'employeeCount',
|
|
967
|
+
title: '人数',
|
|
968
|
+
span: 4,
|
|
969
|
+
getValueOf: item => item.employeeCount ?? '-'
|
|
970
|
+
}
|
|
971
|
+
];
|
|
972
|
+
|
|
973
|
+
const orgTreeData = [
|
|
974
|
+
{
|
|
975
|
+
id: 'east',
|
|
976
|
+
name: '华东区',
|
|
977
|
+
code: 'EAST',
|
|
978
|
+
owner: '张三',
|
|
979
|
+
employeeCount: 120,
|
|
980
|
+
children: [
|
|
981
|
+
{
|
|
982
|
+
id: 'east-sh',
|
|
983
|
+
name: '上海',
|
|
984
|
+
code: 'SH',
|
|
985
|
+
owner: '李四',
|
|
986
|
+
employeeCount: 80,
|
|
987
|
+
children: [
|
|
988
|
+
{ id: 'east-sh-pd', name: '浦东分部', code: 'SH-PD', owner: '王五', employeeCount: 40 },
|
|
989
|
+
{ id: 'east-sh-xh', name: '徐汇分部', code: 'SH-XH', owner: '赵六', employeeCount: 40 }
|
|
990
|
+
]
|
|
991
|
+
},
|
|
992
|
+
{ id: 'east-hz', name: '杭州', code: 'HZ', owner: '钱七', employeeCount: 40 }
|
|
993
|
+
]
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
id: 'north',
|
|
997
|
+
name: '华北区',
|
|
998
|
+
code: 'NORTH',
|
|
999
|
+
owner: '孙八',
|
|
1000
|
+
employeeCount: 60,
|
|
1001
|
+
children: [{ id: 'north-bj', name: '北京', code: 'BJ', owner: '周九', employeeCount: 60 }]
|
|
1002
|
+
}
|
|
1003
|
+
];
|
|
1004
|
+
|
|
1005
|
+
const orgTreeListData = [
|
|
1006
|
+
{ id: 'east', name: '华东区', code: 'EAST', owner: '张三', employeeCount: 120, parentId: null },
|
|
1007
|
+
{ id: 'east-sh', name: '上海', code: 'SH', owner: '李四', employeeCount: 80, parentId: 'east' },
|
|
1008
|
+
{ id: 'east-sh-pd', name: '浦东分部', code: 'SH-PD', owner: '王五', employeeCount: 40, parentId: 'east-sh' },
|
|
1009
|
+
{ id: 'east-sh-xh', name: '徐汇分部', code: 'SH-XH', owner: '赵六', employeeCount: 40, parentId: 'east-sh' },
|
|
1010
|
+
{ id: 'east-hz', name: '杭州', code: 'HZ', owner: '钱七', employeeCount: 40, parentId: 'east' },
|
|
1011
|
+
{ id: 'north', name: '华北区', code: 'NORTH', owner: '孙八', employeeCount: 60, parentId: '' },
|
|
1012
|
+
{ id: 'north-bj', name: '北京', code: 'BJ', owner: '周九', employeeCount: 60, parentId: 'north' }
|
|
1013
|
+
];
|
|
1014
|
+
|
|
1015
|
+
const lazyRootData = [
|
|
1016
|
+
{ id: 'org-1', name: '集团总部', code: 'HQ', owner: '张三', parentId: null, hasChildren: true },
|
|
1017
|
+
{ id: 'org-2', name: '分公司', code: 'BR', owner: '李四', parentId: null, hasChildren: true }
|
|
1018
|
+
];
|
|
1019
|
+
|
|
1020
|
+
const lazyChildrenMap = {
|
|
1021
|
+
'org-1': [
|
|
1022
|
+
{ id: 'org-1-1', name: '研发中心', code: 'RD', owner: '王五', hasChildren: true },
|
|
1023
|
+
{ id: 'org-1-2', name: '市场部', code: 'MKT', owner: '赵六', hasChildren: false }
|
|
1024
|
+
],
|
|
1025
|
+
'org-1-1': [
|
|
1026
|
+
{ id: 'org-1-1-1', name: '前端组', code: 'FE', owner: '钱七', hasChildren: false },
|
|
1027
|
+
{ id: 'org-1-1-2', name: '后端组', code: 'BE', owner: '孙八', hasChildren: false }
|
|
1028
|
+
],
|
|
1029
|
+
'org-2': [{ id: 'org-2-1', name: '华南办', code: 'SC', owner: '周九', hasChildren: false }]
|
|
1030
|
+
};
|
|
1031
|
+
|
|
1032
|
+
// dataType=tree:嵌套 children
|
|
1033
|
+
const TreeTableExample = ({ isPopup }) => {
|
|
1034
|
+
const [value, setValue] = useState([]);
|
|
1035
|
+
|
|
1036
|
+
return (
|
|
1037
|
+
<Flex vertical gap={8}>
|
|
1038
|
+
<span>树形表格(dataType=tree):</span>
|
|
1039
|
+
<div style={{ color: '#666', fontSize: 12, lineHeight: 1.6 }}>嵌套 children 数据;默认展开;多选时父子勾选关联为 parent(勾父级只保留父级值)。</div>
|
|
1040
|
+
<SelectTableList
|
|
1041
|
+
dataType="tree"
|
|
1042
|
+
defaultExpandedKeys
|
|
1043
|
+
options={orgTreeData}
|
|
1044
|
+
columns={orgTreeColumns}
|
|
1045
|
+
valueKey="id"
|
|
1046
|
+
labelKey="name"
|
|
1047
|
+
value={value}
|
|
1048
|
+
onChange={setValue}
|
|
1049
|
+
isPopup={isPopup}
|
|
1050
|
+
placeholder="请选择组织节点"
|
|
1051
|
+
getSearchCallback={({ searchText }, item) => {
|
|
1052
|
+
if (!searchText) return true;
|
|
1053
|
+
const keyword = searchText.toLowerCase();
|
|
1054
|
+
return item.name.toLowerCase().includes(keyword) || item.code.toLowerCase().includes(keyword) || (item.owner || '').toLowerCase().includes(keyword);
|
|
1055
|
+
}}
|
|
1056
|
+
style={{ width: 600 }}
|
|
1057
|
+
/>
|
|
1058
|
+
{value.length > 0 && (
|
|
1059
|
+
<div>
|
|
1060
|
+
已选 {value.length} 项:{value.map(item => item.name).join('、')}
|
|
1061
|
+
</div>
|
|
1062
|
+
)}
|
|
1063
|
+
</Flex>
|
|
1064
|
+
);
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
// dataType=treeList:扁平 parentId
|
|
1068
|
+
const TreeListTableExample = ({ isPopup }) => {
|
|
1069
|
+
const [value, setValue] = useState([]);
|
|
1070
|
+
|
|
1071
|
+
return (
|
|
1072
|
+
<Flex vertical gap={8}>
|
|
1073
|
+
<span>树形表格(dataType=treeList):</span>
|
|
1074
|
+
<div style={{ color: '#666', fontSize: 12, lineHeight: 1.6 }}>扁平列表按 parentId 组装为树;支持搜索时保留匹配节点的祖先路径。</div>
|
|
1075
|
+
<SelectTableList
|
|
1076
|
+
dataType="treeList"
|
|
1077
|
+
defaultExpandedKeys
|
|
1078
|
+
options={orgTreeListData}
|
|
1079
|
+
columns={orgTreeColumns}
|
|
1080
|
+
valueKey="id"
|
|
1081
|
+
labelKey="name"
|
|
1082
|
+
parentKey="parentId"
|
|
1083
|
+
value={value}
|
|
1084
|
+
onChange={setValue}
|
|
1085
|
+
isPopup={isPopup}
|
|
1086
|
+
placeholder="请选择组织节点"
|
|
1087
|
+
getSearchCallback={({ searchText }, item) => {
|
|
1088
|
+
if (!searchText) return true;
|
|
1089
|
+
const keyword = searchText.toLowerCase();
|
|
1090
|
+
return item.name.toLowerCase().includes(keyword) || item.code.toLowerCase().includes(keyword);
|
|
1091
|
+
}}
|
|
1092
|
+
style={{ width: 600 }}
|
|
1093
|
+
/>
|
|
1094
|
+
{value.length > 0 && (
|
|
1095
|
+
<div>
|
|
1096
|
+
已选 {value.length} 项:{value.map(item => item.name).join('、')}
|
|
1097
|
+
</div>
|
|
1098
|
+
)}
|
|
1099
|
+
</Flex>
|
|
1100
|
+
);
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1103
|
+
// checkRelation:parent / all / independent
|
|
1104
|
+
const TreeCheckRelationExample = ({ isPopup }) => {
|
|
1105
|
+
const [value, setValue] = useState([]);
|
|
1106
|
+
const [checkRelation, setCheckRelation] = useState('parent');
|
|
1107
|
+
|
|
1108
|
+
return (
|
|
1109
|
+
<Flex vertical gap={8}>
|
|
1110
|
+
<span>树形勾选关联(checkRelation):</span>
|
|
1111
|
+
<Radio.Group
|
|
1112
|
+
value={checkRelation}
|
|
1113
|
+
optionType="button"
|
|
1114
|
+
options={[
|
|
1115
|
+
{ label: 'parent', value: 'parent' },
|
|
1116
|
+
{ label: 'all', value: 'all' },
|
|
1117
|
+
{ label: 'independent', value: 'independent' }
|
|
1118
|
+
]}
|
|
1119
|
+
onChange={e => {
|
|
1120
|
+
setCheckRelation(e.target.value);
|
|
1121
|
+
setValue([]);
|
|
1122
|
+
}}
|
|
1123
|
+
/>
|
|
1124
|
+
<div style={{ color: '#666', fontSize: 12, lineHeight: 1.6 }}>parent:勾父级只留父级值;all:值含父级与全部子孙;independent:父子互不影响。</div>
|
|
1125
|
+
<SelectTableList
|
|
1126
|
+
dataType="treeList"
|
|
1127
|
+
defaultExpandedKeys
|
|
1128
|
+
checkRelation={checkRelation}
|
|
1129
|
+
options={orgTreeListData}
|
|
1130
|
+
columns={orgTreeColumns}
|
|
1131
|
+
valueKey="id"
|
|
1132
|
+
labelKey="name"
|
|
1133
|
+
value={value}
|
|
1134
|
+
onChange={setValue}
|
|
1135
|
+
isPopup={isPopup}
|
|
1136
|
+
placeholder="请选择组织节点"
|
|
1137
|
+
style={{ width: 600 }}
|
|
1138
|
+
/>
|
|
1139
|
+
{value.length > 0 && <div>已选 key:{value.map(item => item.id).join(', ')}</div>}
|
|
1140
|
+
</Flex>
|
|
1141
|
+
);
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
// 懒加载:hasChildren + onLoadChildren + mergeTreeChildren
|
|
1145
|
+
const TreeLazyLoadExample = ({ isPopup }) => {
|
|
1146
|
+
const [value, setValue] = useState([]);
|
|
1147
|
+
const [lazyData, setLazyData] = useState(lazyRootData);
|
|
1148
|
+
|
|
1149
|
+
const handleLoadChildren = (item, { key }) =>
|
|
1150
|
+
new Promise(resolve => {
|
|
1151
|
+
setTimeout(() => {
|
|
1152
|
+
const children = lazyChildrenMap[key] || [];
|
|
1153
|
+
setLazyData(prev =>
|
|
1154
|
+
mergeTreeChildren(prev, children, {
|
|
1155
|
+
parentKeyValue: key,
|
|
1156
|
+
dataType: 'treeList',
|
|
1157
|
+
rowKey: 'id',
|
|
1158
|
+
parentKey: 'parentId',
|
|
1159
|
+
hasChildrenKey: 'hasChildren'
|
|
1160
|
+
})
|
|
1161
|
+
);
|
|
1162
|
+
resolve();
|
|
1163
|
+
}, 600);
|
|
1164
|
+
});
|
|
1165
|
+
|
|
1166
|
+
return (
|
|
1167
|
+
<Flex vertical gap={8}>
|
|
1168
|
+
<span>树形懒加载:</span>
|
|
1169
|
+
<div style={{ color: '#666', fontSize: 12, lineHeight: 1.6 }}>hasChildren=true 且本地无子节点时展开触发 onLoadChildren,用 mergeTreeChildren 合并子节点。</div>
|
|
1170
|
+
<SelectTableList
|
|
1171
|
+
dataType="treeList"
|
|
1172
|
+
options={lazyData}
|
|
1173
|
+
columns={orgTreeColumns}
|
|
1174
|
+
valueKey="id"
|
|
1175
|
+
labelKey="name"
|
|
1176
|
+
value={value}
|
|
1177
|
+
onChange={setValue}
|
|
1178
|
+
isPopup={isPopup}
|
|
1179
|
+
placeholder="请选择组织节点"
|
|
1180
|
+
onLoadChildren={handleLoadChildren}
|
|
1181
|
+
style={{ width: 600 }}
|
|
1182
|
+
/>
|
|
1183
|
+
{value.length > 0 && (
|
|
1184
|
+
<div>
|
|
1185
|
+
已选 {value.length} 项:{value.map(item => item.name).join('、')}
|
|
1186
|
+
</div>
|
|
1004
1187
|
)}
|
|
1005
1188
|
</Flex>
|
|
1006
1189
|
);
|
|
@@ -1013,15 +1196,8 @@ const BaseExample = () => {
|
|
|
1013
1196
|
<Flex vertical gap={24}>
|
|
1014
1197
|
<Flex align="center" gap={12}>
|
|
1015
1198
|
<span>展示模式:</span>
|
|
1016
|
-
<Switch
|
|
1017
|
-
|
|
1018
|
-
onChange={setIsPopup}
|
|
1019
|
-
checkedChildren="下拉"
|
|
1020
|
-
unCheckedChildren="弹窗"
|
|
1021
|
-
/>
|
|
1022
|
-
<span style={{ color: '#666', fontSize: 12 }}>
|
|
1023
|
-
{isPopup ? '点击输入框展开下拉菜单' : '点击输入框打开弹窗'}
|
|
1024
|
-
</span>
|
|
1199
|
+
<Switch checked={isPopup} onChange={setIsPopup} checkedChildren="下拉" unCheckedChildren="弹窗" />
|
|
1200
|
+
<span style={{ color: '#666', fontSize: 12 }}>{isPopup ? '点击输入框展开下拉菜单' : '点击输入框打开弹窗'}</span>
|
|
1025
1201
|
</Flex>
|
|
1026
1202
|
<Divider />
|
|
1027
1203
|
<BasicTableExample isPopup={isPopup} />
|
|
@@ -1036,6 +1212,14 @@ const BaseExample = () => {
|
|
|
1036
1212
|
<Divider />
|
|
1037
1213
|
<CustomMobileCardExample isPopup={isPopup} />
|
|
1038
1214
|
<Divider />
|
|
1215
|
+
<TreeTableExample isPopup={isPopup} />
|
|
1216
|
+
<Divider />
|
|
1217
|
+
<TreeListTableExample isPopup={isPopup} />
|
|
1218
|
+
<Divider />
|
|
1219
|
+
<TreeCheckRelationExample isPopup={isPopup} />
|
|
1220
|
+
<Divider />
|
|
1221
|
+
<TreeLazyLoadExample isPopup={isPopup} />
|
|
1222
|
+
<Divider />
|
|
1039
1223
|
<DirectRenderExample />
|
|
1040
1224
|
</Flex>
|
|
1041
1225
|
);
|
|
@@ -2186,37 +2370,37 @@ render(<BaseExample />);
|
|
|
2186
2370
|
|
|
2187
2371
|
基础选择输入组件,提供核心的选择功能和状态管理。
|
|
2188
2372
|
|
|
2189
|
-
| 属性名
|
|
2190
|
-
|
|
2191
|
-
| value
|
|
2192
|
-
| defaultValue
|
|
2193
|
-
| onChange
|
|
2194
|
-
| single
|
|
2195
|
-
| maxLength
|
|
2196
|
-
| disabled
|
|
2197
|
-
| size
|
|
2198
|
-
| placeholder
|
|
2199
|
-
| labelKey
|
|
2200
|
-
| valueKey
|
|
2201
|
-
| isPopup
|
|
2202
|
-
| placement
|
|
2203
|
-
| overlayWidth
|
|
2204
|
-
| overlayClassName
|
|
2205
|
-
| labelWrap
|
|
2206
|
-
| allowClear
|
|
2207
|
-
| allowSelectedAll
|
|
2208
|
-
| selectedAllValue
|
|
2209
|
-
| prefix
|
|
2210
|
-
| suffix
|
|
2211
|
-
| className
|
|
2212
|
-
| style
|
|
2213
|
-
| children
|
|
2214
|
-
| renderModal
|
|
2215
|
-
| renderContent
|
|
2216
|
-
| inputRender
|
|
2217
|
-
| open
|
|
2218
|
-
| defaultOpen
|
|
2219
|
-
| onOpenChange
|
|
2373
|
+
| 属性名 | 说明 | 类型 | 默认值 |
|
|
2374
|
+
| ---------------- | --------------------------------- | ------------------------------- | ------------------------------- |
|
|
2375
|
+
| value | 当前选中的值 | array \| object | [] |
|
|
2376
|
+
| defaultValue | 默认选中的值 | array \| object | [] |
|
|
2377
|
+
| onChange | 选中值变化时的回调函数 | function(value) | - |
|
|
2378
|
+
| single | 是否单选模式 | boolean | false |
|
|
2379
|
+
| maxLength | 最多可选数量(多选模式) | number | - |
|
|
2380
|
+
| disabled | 是否禁用 | boolean | false |
|
|
2381
|
+
| size | 选择框尺寸 | 'small' \| 'default' \| 'large' | 'default' |
|
|
2382
|
+
| placeholder | 输入框占位符 | string | '请选择' |
|
|
2383
|
+
| labelKey | 数据项显示文本字段 | string | 'label' |
|
|
2384
|
+
| valueKey | 数据项唯一标识字段 | string | 'value' |
|
|
2385
|
+
| isPopup | 是否下拉模式(false 为弹窗) | boolean | true |
|
|
2386
|
+
| placement | 下拉菜单位置 | string | 'bottomLeft' |
|
|
2387
|
+
| overlayWidth | 下拉菜单宽度 | number \| string | 同输入框宽度 |
|
|
2388
|
+
| overlayClassName | 下拉菜单自定义类名 | string | - |
|
|
2389
|
+
| labelWrap | 标签是否换行显示 | boolean | false |
|
|
2390
|
+
| allowClear | 是否允许清空 | boolean | true |
|
|
2391
|
+
| allowSelectedAll | 是否显示全选按钮 | boolean | false |
|
|
2392
|
+
| selectedAllValue | 全选项的值配置 | object | { value: 'all', label: '全选' } |
|
|
2393
|
+
| prefix | 输入框前缀 | ReactNode \| function | - |
|
|
2394
|
+
| suffix | 输入框后缀 | ReactNode \| function | - |
|
|
2395
|
+
| className | 自定义类名 | string | - |
|
|
2396
|
+
| style | 自定义样式 | object | - |
|
|
2397
|
+
| children | 自定义渲染内容 | function(props) | - |
|
|
2398
|
+
| renderModal | 自定义弹窗渲染(非 isPopup 模式) | function(contextProps) | 默认 Modal 弹窗 |
|
|
2399
|
+
| renderContent | 自定义内容渲染 | function(children) | - |
|
|
2400
|
+
| inputRender | 自定义输入框渲染 | function(props, contextProps) | - |
|
|
2401
|
+
| open | 是否打开下拉菜单 | boolean | - |
|
|
2402
|
+
| defaultOpen | 默认是否打开 | boolean | false |
|
|
2403
|
+
| onOpenChange | 下拉菜单状态变化回调 | function(open) | - |
|
|
2220
2404
|
|
|
2221
2405
|
##### 标签溢出处理
|
|
2222
2406
|
|
|
@@ -2232,54 +2416,62 @@ render(<BaseExample />);
|
|
|
2232
2416
|
|
|
2233
2417
|
基于 SelectInput 的列表选择组件,适用于常规的列表选择场景。
|
|
2234
2418
|
|
|
2235
|
-
| 属性名
|
|
2236
|
-
|
|
2237
|
-
| value | 当前选中的值
|
|
2238
|
-
| onChange | 选中值变化时的回调函数
|
|
2239
|
-
| dataSource | 数据源
|
|
2240
|
-
| idField | 数据项唯一标识字段
|
|
2241
|
-
| multiple | 是否支持多选
|
|
2242
|
-
| max | 最多可选数量
|
|
2243
|
-
| disabled | 是否禁用
|
|
2244
|
-
| readOnly | 是否只读
|
|
2245
|
-
| className | 自定义类名
|
|
2246
|
-
| style | 自定义样式
|
|
2247
|
-
| renderItem | 自定义列表项渲染
|
|
2248
|
-
| emptyContent | 无数据时的显示内容
|
|
2249
|
-
| locale | 国际化配置
|
|
2250
|
-
| onExceed | 超出最大可选数量时的回调 | function(value, item) | -
|
|
2251
|
-
| onSelect | 选择时的回调
|
|
2252
|
-
| onDeselect | 取消选择时的回调
|
|
2253
|
-
| itemClassName | 列表项自定义类名
|
|
2254
|
-
| itemStyle | 列表项自定义样式
|
|
2419
|
+
| 属性名 | 说明 | 类型 | 默认值 |
|
|
2420
|
+
| ------------- | ------------------------ | ----------------------------- | -------- |
|
|
2421
|
+
| value | 当前选中的值 | array | [] |
|
|
2422
|
+
| onChange | 选中值变化时的回调函数 | function(value, item, {type}) | - |
|
|
2423
|
+
| dataSource | 数据源 | array | [] |
|
|
2424
|
+
| idField | 数据项唯一标识字段 | string | 'id' |
|
|
2425
|
+
| multiple | 是否支持多选 | boolean | false |
|
|
2426
|
+
| max | 最多可选数量 | number | - |
|
|
2427
|
+
| disabled | 是否禁用 | boolean | false |
|
|
2428
|
+
| readOnly | 是否只读 | boolean | false |
|
|
2429
|
+
| className | 自定义类名 | string | - |
|
|
2430
|
+
| style | 自定义样式 | object | - |
|
|
2431
|
+
| renderItem | 自定义列表项渲染 | function(item, index) | - |
|
|
2432
|
+
| emptyContent | 无数据时的显示内容 | ReactNode | - |
|
|
2433
|
+
| locale | 国际化配置 | object | 默认中文 |
|
|
2434
|
+
| onExceed | 超出最大可选数量时的回调 | function(value, item) | - |
|
|
2435
|
+
| onSelect | 选择时的回调 | function(value, item) | - |
|
|
2436
|
+
| onDeselect | 取消选择时的回调 | function(value, item) | - |
|
|
2437
|
+
| itemClassName | 列表项自定义类名 | string | - |
|
|
2438
|
+
| itemStyle | 列表项自定义样式 | object | - |
|
|
2255
2439
|
|
|
2256
2440
|
#### SelectTableList
|
|
2257
2441
|
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
| 属性名
|
|
2261
|
-
|
|
2262
|
-
| value
|
|
2263
|
-
| onChange
|
|
2264
|
-
|
|
|
2265
|
-
|
|
|
2266
|
-
|
|
|
2267
|
-
|
|
|
2268
|
-
|
|
|
2269
|
-
|
|
|
2270
|
-
|
|
|
2271
|
-
|
|
|
2272
|
-
|
|
|
2273
|
-
|
|
|
2274
|
-
|
|
|
2275
|
-
|
|
|
2276
|
-
|
|
|
2277
|
-
|
|
|
2278
|
-
|
|
|
2279
|
-
|
|
|
2280
|
-
|
|
|
2281
|
-
|
|
|
2282
|
-
|
|
|
2442
|
+
表格形式的选择组件,适用于需要展示多列数据的选择场景。基于 `@kne/table-view`,支持普通列表与树形(`tree` / `treeList`)选择。
|
|
2443
|
+
|
|
2444
|
+
| 属性名 | 说明 | 类型 | 默认值 |
|
|
2445
|
+
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | --------------- |
|
|
2446
|
+
| value | 当前选中的值 | array | [] |
|
|
2447
|
+
| onChange | 选中值变化时的回调函数 | function(value) | - |
|
|
2448
|
+
| options | 本地数据源(与 `api` 二选一) | array | - |
|
|
2449
|
+
| api | 远程分页加载配置 | object | - |
|
|
2450
|
+
| columns | 表格列配置 | array | [] |
|
|
2451
|
+
| valueKey | 数据项唯一标识字段 | string | `'value'` |
|
|
2452
|
+
| labelKey | 数据项展示字段 | string | `'label'` |
|
|
2453
|
+
| single | 是否单选 | boolean | false |
|
|
2454
|
+
| allowSelectedAll | 是否显示全选 | boolean | false |
|
|
2455
|
+
| className | 自定义类名 | string | - |
|
|
2456
|
+
| style | 自定义样式 | object | - |
|
|
2457
|
+
| renderMobile | 移动端自定义卡片渲染;为 `false` 时关闭移动端卡片;为 function 时接管列表区渲染(仅移动端),参数含 `list` / `displayDataSource` / `value` / `setValue` / `renderBody` / 树形辅助方法等 | boolean \| function | 默认卡片 List |
|
|
2458
|
+
| dataType | 数据形态。`list` 扁平列表;`tree` 使用 `childrenKey` 嵌套;`treeList` 按 `parentKey` 组装为树 | `'list'` \| `'tree'` \| `'treeList'` | `'list'` |
|
|
2459
|
+
| parentKey | `treeList` 父子关联字段 | string | `'parentId'` |
|
|
2460
|
+
| childrenKey | 子节点字段名 | string | `'children'` |
|
|
2461
|
+
| hasChildrenKey | 懒加载节点是否仍有子级的标记字段 | string | `'hasChildren'` |
|
|
2462
|
+
| treeTitleKey | 移动端树形面包屑文案字段;默认取 `labelKey` | string \| function | `labelKey` |
|
|
2463
|
+
| checkRelation | 树形 checkbox 父子勾选关联:`parent` / `all` / `independent` | string | `'parent'` |
|
|
2464
|
+
| onLoadChildren | 懒加载回调 `(item, { key }) => void \| Promise`;需配合 `mergeTreeChildren` 合并子节点 | function | - |
|
|
2465
|
+
| expandedKeys | 受控展开:`true` 全开 / `false` 全关 / key 数组 | boolean \| array | - |
|
|
2466
|
+
| defaultExpandedKeys | 非受控初始展开 | boolean \| array | `false` |
|
|
2467
|
+
| onExpandedKeysChange | 展开变化回调 `(keys) => void` | function | - |
|
|
2468
|
+
| indentSize | 树形每层缩进(px) | number | `16` |
|
|
2469
|
+
|
|
2470
|
+
树形说明:
|
|
2471
|
+
|
|
2472
|
+
- `tree` / `treeList` 能力透传自 `@kne/table-view`(展开收起、缩进、半选、移动端面包屑等)
|
|
2473
|
+
- 搜索(`getSearchCallback`)在 `tree` 下递归过滤并保留祖先;在 `treeList` 下匹配节点时自动带上祖先路径
|
|
2474
|
+
- 懒加载示例:`onLoadChildren` 内用包导出的 `mergeTreeChildren` 更新 `options`
|
|
2283
2475
|
|
|
2284
2476
|
```jsx
|
|
2285
2477
|
<SelectTableList
|
|
@@ -2292,83 +2484,88 @@ render(<BaseExample />);
|
|
|
2292
2484
|
))}
|
|
2293
2485
|
</Flex>
|
|
2294
2486
|
)}
|
|
2295
|
-
|
|
2487
|
+
/>;
|
|
2488
|
+
|
|
2489
|
+
{
|
|
2490
|
+
/* 树形 */
|
|
2491
|
+
}
|
|
2492
|
+
<SelectTableList dataType="treeList" defaultExpandedKeys checkRelation="parent" options={treeListOptions} columns={columns} valueKey="id" labelKey="name" />;
|
|
2296
2493
|
```
|
|
2297
2494
|
|
|
2298
2495
|
##### columns 配置项
|
|
2299
2496
|
|
|
2300
|
-
| 属性名
|
|
2301
|
-
|
|
2302
|
-
| title | 列标题
|
|
2303
|
-
| dataIndex | 列数据在数据项中对应的路径 | string | -
|
|
2304
|
-
| key | React key
|
|
2305
|
-
| render | 自定义渲染函数
|
|
2306
|
-
| width | 列宽度
|
|
2307
|
-
| className | 列自定义类名
|
|
2308
|
-
| style | 列自定义样式
|
|
2497
|
+
| 属性名 | 说明 | 类型 | 默认值 |
|
|
2498
|
+
| --------- | -------------------------- | ----------------------------- | ------ |
|
|
2499
|
+
| title | 列标题 | ReactNode | - |
|
|
2500
|
+
| dataIndex | 列数据在数据项中对应的路径 | string | - |
|
|
2501
|
+
| key | React key | string | - |
|
|
2502
|
+
| render | 自定义渲染函数 | function(text, record, index) | - |
|
|
2503
|
+
| width | 列宽度 | string \| number | - |
|
|
2504
|
+
| className | 列自定义类名 | string | - |
|
|
2505
|
+
| style | 列自定义样式 | object | - |
|
|
2309
2506
|
|
|
2310
2507
|
#### SelectedAll
|
|
2311
2508
|
|
|
2312
2509
|
全选功能组件,提供一键选择/取消选择所有项的功能。
|
|
2313
2510
|
|
|
2314
|
-
| 属性名
|
|
2315
|
-
|
|
2316
|
-
| value | 当前选中的值
|
|
2317
|
-
| onChange | 选中值变化时的回调函数 | function(value, {type}) | -
|
|
2318
|
-
| dataSource | 数据源
|
|
2319
|
-
| idField | 数据项唯一标识字段
|
|
2320
|
-
| disabled | 是否禁用
|
|
2321
|
-
| readOnly | 是否只读
|
|
2322
|
-
| className | 自定义类名
|
|
2323
|
-
| style | 自定义样式
|
|
2324
|
-
| children | 自定义渲染内容
|
|
2325
|
-
| locale | 国际化配置
|
|
2511
|
+
| 属性名 | 说明 | 类型 | 默认值 |
|
|
2512
|
+
| ---------- | ---------------------- | ----------------------- | -------- |
|
|
2513
|
+
| value | 当前选中的值 | array | [] |
|
|
2514
|
+
| onChange | 选中值变化时的回调函数 | function(value, {type}) | - |
|
|
2515
|
+
| dataSource | 数据源 | array | [] |
|
|
2516
|
+
| idField | 数据项唯一标识字段 | string | 'id' |
|
|
2517
|
+
| disabled | 是否禁用 | boolean | false |
|
|
2518
|
+
| readOnly | 是否只读 | boolean | false |
|
|
2519
|
+
| className | 自定义类名 | string | - |
|
|
2520
|
+
| style | 自定义样式 | object | - |
|
|
2521
|
+
| children | 自定义渲染内容 | function(props) | - |
|
|
2522
|
+
| locale | 国际化配置 | object | 默认中文 |
|
|
2326
2523
|
|
|
2327
2524
|
#### SelectTree
|
|
2328
2525
|
|
|
2329
2526
|
树形选择组件,适用于层级数据的展示和选择。
|
|
2330
2527
|
|
|
2331
|
-
| 属性名
|
|
2332
|
-
|
|
2333
|
-
| value
|
|
2334
|
-
| onChange
|
|
2335
|
-
| dataSource
|
|
2336
|
-
| idField
|
|
2337
|
-
| multiple
|
|
2338
|
-
| max
|
|
2339
|
-
| disabled
|
|
2340
|
-
| readOnly
|
|
2341
|
-
| className
|
|
2342
|
-
| style
|
|
2343
|
-
| renderItem
|
|
2344
|
-
| emptyContent
|
|
2345
|
-
| locale
|
|
2346
|
-
| onExceed
|
|
2347
|
-
| onSelect
|
|
2348
|
-
| onDeselect
|
|
2528
|
+
| 属性名 | 说明 | 类型 | 默认值 |
|
|
2529
|
+
| ------------ | ------------------------ | ----------------------------- | -------- |
|
|
2530
|
+
| value | 当前选中的值 | array | [] |
|
|
2531
|
+
| onChange | 选中值变化时的回调函数 | function(value, item, {type}) | - |
|
|
2532
|
+
| dataSource | 数据源 | array | [] |
|
|
2533
|
+
| idField | 数据项唯一标识字段 | string | 'id' |
|
|
2534
|
+
| multiple | 是否支持多选 | boolean | false |
|
|
2535
|
+
| max | 最多可选数量 | number | - |
|
|
2536
|
+
| disabled | 是否禁用 | boolean | false |
|
|
2537
|
+
| readOnly | 是否只读 | boolean | false |
|
|
2538
|
+
| className | 自定义类名 | string | - |
|
|
2539
|
+
| style | 自定义样式 | object | - |
|
|
2540
|
+
| renderItem | 自定义树节点渲染 | function(item, index) | - |
|
|
2541
|
+
| emptyContent | 无数据时的显示内容 | ReactNode | - |
|
|
2542
|
+
| locale | 国际化配置 | object | 默认中文 |
|
|
2543
|
+
| onExceed | 超出最大可选数量时的回调 | function(value, item) | - |
|
|
2544
|
+
| onSelect | 选择时的回调 | function(value, item) | - |
|
|
2545
|
+
| onDeselect | 取消选择时的回调 | function(value, item) | - |
|
|
2349
2546
|
|
|
2350
2547
|
#### SelectedTagList
|
|
2351
2548
|
|
|
2352
2549
|
已选项标签列表组件,以标签形式展示已选中的项目。
|
|
2353
2550
|
|
|
2354
|
-
| 属性名
|
|
2355
|
-
|
|
2356
|
-
| value | 当前选中的值
|
|
2357
|
-
| onChange | 选中值变化时的回调函数 | function(value, item, {type}) | -
|
|
2358
|
-
| dataSource | 数据源
|
|
2359
|
-
| idField | 数据项唯一标识字段
|
|
2360
|
-
| disabled | 是否禁用
|
|
2361
|
-
| readOnly | 是否只读
|
|
2362
|
-
| className | 自定义类名
|
|
2363
|
-
| style | 自定义样式
|
|
2364
|
-
| renderItem | 自定义标签渲染
|
|
2365
|
-
| emptyContent | 无数据时的显示内容
|
|
2366
|
-
| locale | 国际化配置
|
|
2367
|
-
| onRemove | 移除标签时的回调
|
|
2368
|
-
| onClear | 清空所有标签时的回调
|
|
2369
|
-
| showClear | 是否显示清空按钮
|
|
2370
|
-
| tagClassName | 标签自定义类名
|
|
2371
|
-
| tagStyle | 标签自定义样式
|
|
2551
|
+
| 属性名 | 说明 | 类型 | 默认值 |
|
|
2552
|
+
| ------------ | ---------------------- | ----------------------------- | -------- |
|
|
2553
|
+
| value | 当前选中的值 | array | [] |
|
|
2554
|
+
| onChange | 选中值变化时的回调函数 | function(value, item, {type}) | - |
|
|
2555
|
+
| dataSource | 数据源 | array | [] |
|
|
2556
|
+
| idField | 数据项唯一标识字段 | string | 'id' |
|
|
2557
|
+
| disabled | 是否禁用 | boolean | false |
|
|
2558
|
+
| readOnly | 是否只读 | boolean | false |
|
|
2559
|
+
| className | 自定义类名 | string | - |
|
|
2560
|
+
| style | 自定义样式 | object | - |
|
|
2561
|
+
| renderItem | 自定义标签渲染 | function(item, index) | - |
|
|
2562
|
+
| emptyContent | 无数据时的显示内容 | ReactNode | - |
|
|
2563
|
+
| locale | 国际化配置 | object | 默认中文 |
|
|
2564
|
+
| onRemove | 移除标签时的回调 | function(value, item) | - |
|
|
2565
|
+
| onClear | 清空所有标签时的回调 | function(value) | - |
|
|
2566
|
+
| showClear | 是否显示清空按钮 | boolean | true |
|
|
2567
|
+
| tagClassName | 标签自定义类名 | string | - |
|
|
2568
|
+
| tagStyle | 标签自定义样式 | object | - |
|
|
2372
2569
|
|
|
2373
2570
|
#### 国际化配置
|
|
2374
2571
|
|
|
@@ -2391,50 +2588,51 @@ import { zhCN, enUS } from '@kne/super-select/locale';
|
|
|
2391
2588
|
|
|
2392
2589
|
##### 可配置的文案
|
|
2393
2590
|
|
|
2394
|
-
| 键名
|
|
2395
|
-
|
|
2396
|
-
| empty | 无数据时的提示文案 | 暂无数据
|
|
2397
|
-
| selectAll | 全选按钮文案
|
|
2398
|
-
| clearAll | 清空按钮文案
|
|
2399
|
-
| selected | 已选文案
|
|
2400
|
-
| items | 项文案
|
|
2401
|
-
| exceed | 超出限制提示文案
|
|
2591
|
+
| 键名 | 说明 | 默认中文值 |
|
|
2592
|
+
| --------- | ------------------ | --------------------- |
|
|
2593
|
+
| empty | 无数据时的提示文案 | 暂无数据 |
|
|
2594
|
+
| selectAll | 全选按钮文案 | 全选 |
|
|
2595
|
+
| clearAll | 清空按钮文案 | 清空 |
|
|
2596
|
+
| selected | 已选文案 | 已选 |
|
|
2597
|
+
| items | 项文案 | 项 |
|
|
2598
|
+
| exceed | 超出限制提示文案 | 最多只能选择 {max} 项 |
|
|
2402
2599
|
|
|
2403
2600
|
#### SelectCascader
|
|
2404
2601
|
|
|
2405
2602
|
级联选择组件,适用于地区选择、组织架构、商品分类等层级数据的选择场景。支持多列菜单展示、父子关联选择、末级限制、搜索过滤等功能。
|
|
2406
2603
|
|
|
2407
|
-
| 属性名
|
|
2408
|
-
|
|
2409
|
-
| options
|
|
2410
|
-
| value
|
|
2411
|
-
| onChange
|
|
2412
|
-
| defaultValue
|
|
2413
|
-
| single
|
|
2414
|
-
| maxLength
|
|
2415
|
-
| onlyAllowLastLevel | 是否只允许选择末级节点
|
|
2416
|
-
| openLoadData
|
|
2417
|
-
| onLoadMore
|
|
2418
|
-
| parentIdKey
|
|
2419
|
-
| menuItemWidth
|
|
2420
|
-
| isPopup
|
|
2421
|
-
| searchPlaceholder| 搜索框占位符
|
|
2422
|
-
| onSearch
|
|
2423
|
-
| valueKey
|
|
2424
|
-
| labelKey
|
|
2425
|
-
| placeholder
|
|
2426
|
-
| disabled
|
|
2427
|
-
| size
|
|
2428
|
-
| overlayWidth
|
|
2604
|
+
| 属性名 | 说明 | 类型 | 默认值 |
|
|
2605
|
+
| ------------------ | ---------------------------- | --------------------------------- | ----------------- |
|
|
2606
|
+
| options | 级联数据源 | array | [] |
|
|
2607
|
+
| value | 当前选中的值 | array \| object | [] |
|
|
2608
|
+
| onChange | 选中值变化时的回调函数 | function(value) | - |
|
|
2609
|
+
| defaultValue | 默认选中的值 | array | [] |
|
|
2610
|
+
| single | 是否单选模式 | boolean | false |
|
|
2611
|
+
| maxLength | 最多可选数量 | number | Number.MAX_VALUE |
|
|
2612
|
+
| onlyAllowLastLevel | 是否只允许选择末级节点 | boolean | false |
|
|
2613
|
+
| openLoadData | 是否开启懒加载 | boolean | false |
|
|
2614
|
+
| onLoadMore | 懒加载回调函数 | function({ [parentIdKey]: id }) | - |
|
|
2615
|
+
| parentIdKey | 父节点ID字段名 | string | 'id' |
|
|
2616
|
+
| menuItemWidth | 每列菜单宽度 | number | 180 |
|
|
2617
|
+
| isPopup | 是否下拉模式(false 为弹窗) | boolean | true |
|
|
2618
|
+
| searchPlaceholder | 搜索框占位符 | string | '搜索...' |
|
|
2619
|
+
| onSearch | 搜索回调函数 | function(searchText, { mapping }) | - |
|
|
2620
|
+
| valueKey | 数据项唯一标识字段 | string | 'id' |
|
|
2621
|
+
| labelKey | 数据项显示文本字段 | string | 'label' |
|
|
2622
|
+
| placeholder | 输入框占位符 | string | '请选择' |
|
|
2623
|
+
| disabled | 是否禁用 | boolean | false |
|
|
2624
|
+
| size | 选择框尺寸 | 'small' \| 'default' \| 'large' | 'default' |
|
|
2625
|
+
| overlayWidth | 下拉菜单宽度 | number | menuItemWidth * 2 |
|
|
2429
2626
|
|
|
2430
2627
|
##### options 数据结构
|
|
2431
2628
|
|
|
2432
2629
|
```javascript
|
|
2433
2630
|
[
|
|
2434
2631
|
{
|
|
2435
|
-
id: 'node1',
|
|
2436
|
-
name: '节点名称',
|
|
2437
|
-
children: [
|
|
2632
|
+
id: 'node1', // 唯一标识,字段名可通过 valueKey 配置
|
|
2633
|
+
name: '节点名称', // 显示文本,字段名可通过 labelKey 配置
|
|
2634
|
+
children: [
|
|
2635
|
+
// 子节点
|
|
2438
2636
|
{
|
|
2439
2637
|
id: 'node1-1',
|
|
2440
2638
|
name: '子节点1',
|
|
@@ -2442,12 +2640,13 @@ import { zhCN, enUS } from '@kne/super-select/locale';
|
|
|
2442
2640
|
}
|
|
2443
2641
|
]
|
|
2444
2642
|
}
|
|
2445
|
-
]
|
|
2643
|
+
];
|
|
2446
2644
|
```
|
|
2447
2645
|
|
|
2448
2646
|
##### 父子关联选择
|
|
2449
2647
|
|
|
2450
2648
|
组件默认支持父子关联选择:
|
|
2649
|
+
|
|
2451
2650
|
- 选中父节点时,自动选中所有子节点
|
|
2452
2651
|
- 取消父节点时,自动取消所有子节点
|
|
2453
2652
|
- 当所有子节点都被选中时,父节点自动选中
|
|
@@ -2460,9 +2659,7 @@ import { zhCN, enUS } from '@kne/super-select/locale';
|
|
|
2460
2659
|
<SelectCascader
|
|
2461
2660
|
options={data}
|
|
2462
2661
|
onSearch={(searchText, { mapping }) => {
|
|
2463
|
-
return Array.from(mapping.values()).filter(item =>
|
|
2464
|
-
item.name.includes(searchText)
|
|
2465
|
-
);
|
|
2662
|
+
return Array.from(mapping.values()).filter(item => item.name.includes(searchText));
|
|
2466
2663
|
}}
|
|
2467
2664
|
/>
|
|
2468
2665
|
```
|