@kne/super-select 0.1.33 → 0.1.34
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 +875 -75
- package/dist/index.css +328 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +963 -79
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +962 -89
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,74 +1,71 @@
|
|
|
1
|
-
|
|
2
1
|
# super-select
|
|
3
2
|
|
|
4
|
-
|
|
5
3
|
### 描述
|
|
6
4
|
|
|
7
5
|
React 复杂信息选择组件库,提供列表、表格、树形等多种选择模式,支持单选/多选、搜索、全选等功能
|
|
8
6
|
|
|
9
|
-
|
|
10
7
|
### 安装
|
|
11
8
|
|
|
12
9
|
```shell
|
|
13
10
|
npm i --save @kne/super-select
|
|
14
11
|
```
|
|
15
12
|
|
|
16
|
-
|
|
17
13
|
### 概述
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
一个功能强大的 React 组件库,专门用于处理复杂的信息选择场景。提供了一系列灵活且可组合的组件,使得在 React
|
|
16
|
+
应用中实现复杂的选择功能变得简单直观。
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
#### 主要功能
|
|
22
19
|
|
|
23
20
|
- 支持多种选择模式(单选、多选)
|
|
21
|
+
- 支持下拉框和弹窗两种展示模式
|
|
24
22
|
- 提供灵活的列表和表格展示方式
|
|
25
23
|
- 内置标签式选中项展示
|
|
26
24
|
- 支持全选/反选功能
|
|
27
25
|
- 内置国际化支持(中文和英文)
|
|
28
|
-
- 自定义样式支持(基于CSS Modules)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
- 自定义样式支持(基于 CSS Modules)
|
|
27
|
+
- 标签溢出处理:单选文本省略、多选标签自动折叠显示 +N
|
|
28
|
+
|
|
29
|
+
#### 组件列表
|
|
30
|
+
|
|
31
|
+
| 组件名称 | 功能描述 |
|
|
32
|
+
|-----------------|-----------------------------|
|
|
33
|
+
| SelectInput | 基础选择输入组件,用于自定义构建其他选择组件的核心基础 |
|
|
34
|
+
| SelectList | 列表选择组件,适用于常规列表选择场景 |
|
|
35
|
+
| SelectTableList | 表格形式选择组件,支持多列数据展示 |
|
|
36
|
+
| SelectedAll | 全选功能组件,提供一键选择/取消选择 |
|
|
37
|
+
| SelectTree | 树形选择组件,适用于层级数据 |
|
|
38
|
+
| SelectedTagList | 已选项标签列表组件 |
|
|
39
|
+
| SelectCascader | 级联选择组件,支持父子关联、搜索过滤 |
|
|
40
|
+
|
|
41
|
+
#### 快速选择指南
|
|
42
|
+
|
|
43
|
+
| 需求 | 推荐组件 |
|
|
44
|
+
|----------|-----------------------------|
|
|
45
|
+
| 自定义选择组件 | SelectInput |
|
|
46
|
+
| 简单列表选择 | SelectList |
|
|
47
|
+
| 需要展示多列数据 | SelectTableList |
|
|
48
|
+
| 层级数据选择 | SelectTree 或 SelectCascader |
|
|
49
|
+
| 全选/反选功能 | SelectedAll |
|
|
50
|
+
| 已选项标签展示 | SelectedTagList |
|
|
51
|
+
|
|
52
|
+
#### 快速开始
|
|
40
53
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
#### SelectTree
|
|
45
|
-
树形选择组件,适用于层级数据的展示和选择。支持展开/折叠节点,并提供灵活的节点渲染方式。
|
|
46
|
-
|
|
47
|
-
#### SelectedTagList
|
|
48
|
-
已选项标签列表组件,以标签形式展示已选中的项目。支持单个标签删除和清空所有已选项。
|
|
49
|
-
|
|
50
|
-
### 使用场景
|
|
51
|
-
|
|
52
|
-
- 复杂的数据筛选和选择
|
|
53
|
-
- 多条件组合查询
|
|
54
|
-
- 批量操作数据
|
|
55
|
-
- 表格数据的多选处理
|
|
56
|
-
- 带标签展示的数据选择
|
|
57
|
-
- 需要全选/反选功能的列表操作
|
|
54
|
+
```jsx
|
|
55
|
+
import { SelectInput, SelectList, SelectCascader } from '@kne/super-select';
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
// 自定义选择组件
|
|
58
|
+
<SelectInput placeholder="请选择" onChange={handleChange}>
|
|
59
|
+
{(props) => <CustomDropdown {...props} />}
|
|
60
|
+
</SelectInput>
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
- 模块化设计,组件可独立使用
|
|
65
|
-
- 支持主题定制
|
|
66
|
-
- 完善的类型定义支持
|
|
62
|
+
// 级联选择
|
|
63
|
+
<SelectCascader options={cascadeData} onChange={handleChange} />
|
|
64
|
+
```
|
|
67
65
|
|
|
68
66
|
|
|
69
67
|
### 示例
|
|
70
68
|
|
|
71
|
-
|
|
72
69
|
#### 示例样式
|
|
73
70
|
|
|
74
71
|
```scss
|
|
@@ -240,6 +237,134 @@ render(<BaseExample />);
|
|
|
240
237
|
|
|
241
238
|
```
|
|
242
239
|
|
|
240
|
+
- SelectInput 边界情况测试
|
|
241
|
+
- 测试超多选项(100项)、超长Label文本、大量已选项展示等边界场景
|
|
242
|
+
- _SuperSelect(@kne/current-lib_super-select)[import * as _SuperSelect from "@kne/super-select"],antd(antd),(@kne/current-lib_super-select/dist/index.css)
|
|
243
|
+
|
|
244
|
+
```jsx
|
|
245
|
+
const { SelectInput } = _SuperSelect;
|
|
246
|
+
const { Flex, Tag } = antd;
|
|
247
|
+
const { useState } = React;
|
|
248
|
+
|
|
249
|
+
// 超多选项测试示例(100项)
|
|
250
|
+
const ManyOptionsExample = () => {
|
|
251
|
+
const manyOptions = Array.from({ length: 100 }, (_, i) => ({
|
|
252
|
+
value: `user_${i + 1}`,
|
|
253
|
+
label: `用户${i + 1}`
|
|
254
|
+
}));
|
|
255
|
+
|
|
256
|
+
// 直接预选10项测试
|
|
257
|
+
const [value, setValue] = useState(manyOptions.slice(0, 10));
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
<Flex vertical gap={12}>
|
|
261
|
+
<span>超多选项显示测试(已选10项):</span>
|
|
262
|
+
<SelectInput
|
|
263
|
+
value={value}
|
|
264
|
+
onChange={setValue}
|
|
265
|
+
placeholder="请选择用户"
|
|
266
|
+
style={{ width: 400 }}
|
|
267
|
+
>
|
|
268
|
+
{() => <div style={{ padding: 12 }}>下拉内容</div>}
|
|
269
|
+
</SelectInput>
|
|
270
|
+
<Tag color="blue">已选择 {value.length} 项</Tag>
|
|
271
|
+
</Flex>
|
|
272
|
+
);
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// 超长Label测试示例
|
|
276
|
+
const LongLabelExample = () => {
|
|
277
|
+
const longLabelOptions = [
|
|
278
|
+
{ value: 'dept-1', label: '人工智能与机器学习应用技术研发中心' },
|
|
279
|
+
{ value: 'dept-2', label: '自然语言处理与智能对话系统研发组' },
|
|
280
|
+
{ value: 'dept-3', label: '大语言模型训练与优化专项小组' },
|
|
281
|
+
{ value: 'dept-4', label: '云计算与大数据平台架构设计及实施运维中心' },
|
|
282
|
+
{ value: 'dept-5', label: '网络安全与数据隐私保护技术保障中心' },
|
|
283
|
+
{ value: 'dept-6', label: '物联网设备智能互联与边缘计算技术研发中心' },
|
|
284
|
+
{ value: 'dept-7', label: '智能客服机器人产品研发团队-多模态交互技术组' },
|
|
285
|
+
{ value: 'dept-8', label: '金融科技创新应用与区块链技术研发实验室' }
|
|
286
|
+
];
|
|
287
|
+
|
|
288
|
+
const [value, setValue] = useState(longLabelOptions);
|
|
289
|
+
|
|
290
|
+
return (
|
|
291
|
+
<Flex vertical gap={12}>
|
|
292
|
+
<span>超长Label文本省略测试:</span>
|
|
293
|
+
<SelectInput
|
|
294
|
+
value={value}
|
|
295
|
+
onChange={setValue}
|
|
296
|
+
placeholder="请选择部门"
|
|
297
|
+
style={{ width: 280 }}
|
|
298
|
+
>
|
|
299
|
+
{() => <div style={{ padding: 12 }}>下拉内容</div>}
|
|
300
|
+
</SelectInput>
|
|
301
|
+
</Flex>
|
|
302
|
+
);
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// 单选模式下超长Label测试
|
|
306
|
+
const SingleLongLabelExample = () => {
|
|
307
|
+
const [value, setValue] = useState({
|
|
308
|
+
value: 1,
|
|
309
|
+
label: '人工智能与机器学习应用技术研发中心-自然语言处理与智能对话系统研发组-大语言模型训练与优化专项小组'
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
return (
|
|
313
|
+
<Flex vertical gap={12}>
|
|
314
|
+
<span>单选模式 - 超长Label:</span>
|
|
315
|
+
<SelectInput
|
|
316
|
+
single
|
|
317
|
+
value={value}
|
|
318
|
+
onChange={setValue}
|
|
319
|
+
placeholder="请选择部门"
|
|
320
|
+
style={{ width: 240 }}
|
|
321
|
+
>
|
|
322
|
+
{() => <div style={{ padding: 12 }}>下拉内容</div>}
|
|
323
|
+
</SelectInput>
|
|
324
|
+
{value && <Tag color="green">已选:{value.label}</Tag>}
|
|
325
|
+
</Flex>
|
|
326
|
+
);
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
// 大量已选项展示测试
|
|
330
|
+
const ManySelectedExample = () => {
|
|
331
|
+
const [value, setValue] = useState(
|
|
332
|
+
Array.from({ length: 20 }, (_, i) => ({
|
|
333
|
+
value: `item_${i + 1}`,
|
|
334
|
+
label: `选项${i + 1}`
|
|
335
|
+
}))
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
return (
|
|
339
|
+
<Flex vertical gap={12}>
|
|
340
|
+
<span>大量已选项展示(默认已选20项):</span>
|
|
341
|
+
<SelectInput
|
|
342
|
+
value={value}
|
|
343
|
+
onChange={setValue}
|
|
344
|
+
placeholder="请选择"
|
|
345
|
+
style={{ width: 400 }}
|
|
346
|
+
>
|
|
347
|
+
{() => <div style={{ padding: 12 }}>下拉内容</div>}
|
|
348
|
+
</SelectInput>
|
|
349
|
+
</Flex>
|
|
350
|
+
);
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
const BaseExample = () => {
|
|
354
|
+
return (
|
|
355
|
+
<Flex vertical gap={24}>
|
|
356
|
+
<ManyOptionsExample />
|
|
357
|
+
<LongLabelExample />
|
|
358
|
+
<SingleLongLabelExample />
|
|
359
|
+
<ManySelectedExample />
|
|
360
|
+
</Flex>
|
|
361
|
+
);
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
render(<BaseExample />);
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
|
|
243
368
|
- SuperSelect 列表选择
|
|
244
369
|
- 通用列表选择组件,支持单选/多选、搜索、全选、数量限制、弹窗模式等功能
|
|
245
370
|
- _SuperSelect(@kne/current-lib_super-select)[import * as _SuperSelect from "@kne/super-select"],antd(antd),(@kne/current-lib_super-select/dist/index.css)
|
|
@@ -261,9 +386,9 @@ const departmentOptions = [
|
|
|
261
386
|
|
|
262
387
|
// 模拟用户数据
|
|
263
388
|
const userOptions = Array.from({ length: 30 }).map((_, index) => ({
|
|
264
|
-
value:
|
|
265
|
-
label:
|
|
266
|
-
email:
|
|
389
|
+
value: `user_${index + 1}`,
|
|
390
|
+
label: `用户${index + 1}`,
|
|
391
|
+
email: `user${index + 1}@company.com`,
|
|
267
392
|
department: departmentOptions[index % departmentOptions.length].label,
|
|
268
393
|
disabled: index === 5
|
|
269
394
|
}));
|
|
@@ -392,7 +517,7 @@ const CustomRenderExample = () => {
|
|
|
392
517
|
const { value } = context;
|
|
393
518
|
return (
|
|
394
519
|
<Button type="primary" {...props}>
|
|
395
|
-
{value.length > 0 ?
|
|
520
|
+
{value.length > 0 ? `已选择 ${value.length} 项` : '点击选择部门'}
|
|
396
521
|
</Button>
|
|
397
522
|
);
|
|
398
523
|
}}
|
|
@@ -449,13 +574,13 @@ const { useState } = React;
|
|
|
449
574
|
|
|
450
575
|
// 模拟员工数据
|
|
451
576
|
const employeeOptions = Array.from({ length: 25 }).map((_, index) => ({
|
|
452
|
-
id:
|
|
453
|
-
name:
|
|
454
|
-
email:
|
|
577
|
+
id: `emp_${index + 1}`,
|
|
578
|
+
name: `员工${index + 1}`,
|
|
579
|
+
email: `employee${index + 1}@company.com`,
|
|
455
580
|
department: ['技术研发部', '产品设计部', '运营部', '市场部'][index % 4],
|
|
456
581
|
position: ['工程师', '设计师', '经理', '专员'][index % 4],
|
|
457
582
|
status: index === 3 ? 'inactive' : 'active',
|
|
458
|
-
joinDate:
|
|
583
|
+
joinDate: `2023-${String((index % 12) + 1).padStart(2, '0')}-15`
|
|
459
584
|
}));
|
|
460
585
|
|
|
461
586
|
// 员工列表列配置
|
|
@@ -516,8 +641,8 @@ const employeeColumns = [
|
|
|
516
641
|
|
|
517
642
|
// 产品数据
|
|
518
643
|
const productOptions = Array.from({ length: 20 }).map((_, index) => ({
|
|
519
|
-
id:
|
|
520
|
-
productName:
|
|
644
|
+
id: `prod_${index + 1}`,
|
|
645
|
+
productName: `产品${index + 1}`,
|
|
521
646
|
category: ['电子产品', '服装', '食品', '家居'][index % 4],
|
|
522
647
|
price: Math.floor(Math.random() * 1000) + 100,
|
|
523
648
|
stock: Math.floor(Math.random() * 500),
|
|
@@ -542,7 +667,7 @@ const productColumns = [
|
|
|
542
667
|
name: 'price',
|
|
543
668
|
title: '价格',
|
|
544
669
|
span: 4,
|
|
545
|
-
getValueOf: (item) =>
|
|
670
|
+
getValueOf: (item) => `¥${item.price}`
|
|
546
671
|
},
|
|
547
672
|
{
|
|
548
673
|
name: 'stock',
|
|
@@ -730,8 +855,7 @@ const DirectRenderExample = () => {
|
|
|
730
855
|
<div style={{
|
|
731
856
|
border: '1px solid #d9d9d9',
|
|
732
857
|
borderRadius: 6,
|
|
733
|
-
padding: 16
|
|
734
|
-
backgroundColor: '#fafafa'
|
|
858
|
+
padding: 16
|
|
735
859
|
}}>
|
|
736
860
|
{content}
|
|
737
861
|
</div>
|
|
@@ -1200,18 +1324,18 @@ const FullRefExample = () => {
|
|
|
1200
1324
|
const [log, setLog] = useState([]);
|
|
1201
1325
|
|
|
1202
1326
|
const addLog = (msg) => {
|
|
1203
|
-
setLog(prev => [...prev,
|
|
1327
|
+
setLog(prev => [...prev, `[${new Date().toLocaleTimeString()}] ${msg}`]);
|
|
1204
1328
|
};
|
|
1205
1329
|
|
|
1206
1330
|
const userOptions = Array.from({ length: 15 }).map((_, i) => ({
|
|
1207
|
-
value:
|
|
1208
|
-
label:
|
|
1331
|
+
value: `user_${i + 1}`,
|
|
1332
|
+
label: `用户${i + 1}`
|
|
1209
1333
|
}));
|
|
1210
1334
|
|
|
1211
1335
|
const handleGetValue = () => {
|
|
1212
1336
|
const currentValue = selectRef.current?.value || [];
|
|
1213
|
-
addLog(
|
|
1214
|
-
message.info(
|
|
1337
|
+
addLog(`当前值: ${JSON.stringify(currentValue.map(v => v.label))}`);
|
|
1338
|
+
message.info(`已选 ${currentValue.length} 项`);
|
|
1215
1339
|
};
|
|
1216
1340
|
|
|
1217
1341
|
const handleClear = () => {
|
|
@@ -1223,7 +1347,7 @@ const FullRefExample = () => {
|
|
|
1223
1347
|
const firstOption = userOptions[0];
|
|
1224
1348
|
if (firstOption) {
|
|
1225
1349
|
selectRef.current?.onSelect(firstOption);
|
|
1226
|
-
addLog(
|
|
1350
|
+
addLog(`已选择: ${firstOption.label}`);
|
|
1227
1351
|
}
|
|
1228
1352
|
};
|
|
1229
1353
|
|
|
@@ -1328,6 +1452,595 @@ render(<BaseExample />);
|
|
|
1328
1452
|
|
|
1329
1453
|
```
|
|
1330
1454
|
|
|
1455
|
+
- SelectCascader 级联选择
|
|
1456
|
+
- 级联选择组件,支持多列菜单展示、父子关联选择、末级选择限制、搜索过滤等功能
|
|
1457
|
+
- _SuperSelect(@kne/current-lib_super-select)[import * as _SuperSelect from "@kne/super-select"],antd(antd),(@kne/current-lib_super-select/dist/index.css)
|
|
1458
|
+
|
|
1459
|
+
```jsx
|
|
1460
|
+
const { SelectCascader } = _SuperSelect;
|
|
1461
|
+
const { Space, Button, Flex, Divider, Tag, Switch, message } = antd;
|
|
1462
|
+
const { useState, useRef } = React;
|
|
1463
|
+
|
|
1464
|
+
// 中国地区数据
|
|
1465
|
+
const regionData = [
|
|
1466
|
+
{
|
|
1467
|
+
id: 'beijing',
|
|
1468
|
+
name: '北京市',
|
|
1469
|
+
children: [
|
|
1470
|
+
{ id: 'haidian', name: '海淀区' },
|
|
1471
|
+
{ id: 'chaoyang', name: '朝阳区' },
|
|
1472
|
+
{ id: 'dongcheng', name: '东城区' },
|
|
1473
|
+
{ id: 'xicheng', name: '西城区' }
|
|
1474
|
+
]
|
|
1475
|
+
},
|
|
1476
|
+
{
|
|
1477
|
+
id: 'shanghai',
|
|
1478
|
+
name: '上海市',
|
|
1479
|
+
children: [
|
|
1480
|
+
{ id: 'pudong', name: '浦东新区' },
|
|
1481
|
+
{ id: 'huangpu', name: '黄浦区' },
|
|
1482
|
+
{ id: 'jingan', name: '静安区' },
|
|
1483
|
+
{ id: 'xuhui', name: '徐汇区' }
|
|
1484
|
+
]
|
|
1485
|
+
},
|
|
1486
|
+
{
|
|
1487
|
+
id: 'guangdong',
|
|
1488
|
+
name: '广东省',
|
|
1489
|
+
children: [
|
|
1490
|
+
{
|
|
1491
|
+
id: 'guangzhou',
|
|
1492
|
+
name: '广州市',
|
|
1493
|
+
children: [
|
|
1494
|
+
{ id: 'tianhe', name: '天河区' },
|
|
1495
|
+
{ id: 'yuexiu', name: '越秀区' },
|
|
1496
|
+
{ id: 'panyu', name: '番禺区' }
|
|
1497
|
+
]
|
|
1498
|
+
},
|
|
1499
|
+
{
|
|
1500
|
+
id: 'shenzhen',
|
|
1501
|
+
name: '深圳市',
|
|
1502
|
+
children: [
|
|
1503
|
+
{ id: 'nanshan', name: '南山区' },
|
|
1504
|
+
{ id: 'futian', name: '福田区' },
|
|
1505
|
+
{ id: 'luohu', name: '罗湖区' }
|
|
1506
|
+
]
|
|
1507
|
+
},
|
|
1508
|
+
{ id: 'dongguan', name: '东莞市' }
|
|
1509
|
+
]
|
|
1510
|
+
},
|
|
1511
|
+
{
|
|
1512
|
+
id: 'zhejiang',
|
|
1513
|
+
name: '浙江省',
|
|
1514
|
+
children: [
|
|
1515
|
+
{
|
|
1516
|
+
id: 'hangzhou',
|
|
1517
|
+
name: '杭州市',
|
|
1518
|
+
children: [
|
|
1519
|
+
{ id: 'xihu', name: '西湖区' },
|
|
1520
|
+
{ id: 'binjiang', name: '滨江区' }
|
|
1521
|
+
]
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
id: 'ningbo',
|
|
1525
|
+
name: '宁波市',
|
|
1526
|
+
children: [
|
|
1527
|
+
{ id: 'haishu', name: '海曙区' },
|
|
1528
|
+
{ id: 'yinzhou', name: '鄞州区' }
|
|
1529
|
+
]
|
|
1530
|
+
}
|
|
1531
|
+
]
|
|
1532
|
+
},
|
|
1533
|
+
{
|
|
1534
|
+
id: 'jiangsu',
|
|
1535
|
+
name: '江苏省',
|
|
1536
|
+
children: [
|
|
1537
|
+
{
|
|
1538
|
+
id: 'nanjing',
|
|
1539
|
+
name: '南京市',
|
|
1540
|
+
children: [
|
|
1541
|
+
{ id: 'xuanwu', name: '玄武区' },
|
|
1542
|
+
{ id: 'qinhuai', name: '秦淮区' }
|
|
1543
|
+
]
|
|
1544
|
+
},
|
|
1545
|
+
{
|
|
1546
|
+
id: 'suzhou',
|
|
1547
|
+
name: '苏州市',
|
|
1548
|
+
children: [
|
|
1549
|
+
{ id: 'gusu', name: '姑苏区' },
|
|
1550
|
+
{ id: 'industrial', name: '工业园区' }
|
|
1551
|
+
]
|
|
1552
|
+
}
|
|
1553
|
+
]
|
|
1554
|
+
}
|
|
1555
|
+
];
|
|
1556
|
+
|
|
1557
|
+
// 组织架构数据
|
|
1558
|
+
const organizationData = [
|
|
1559
|
+
{
|
|
1560
|
+
id: 'tech',
|
|
1561
|
+
name: '技术研发中心',
|
|
1562
|
+
code: 'TECH',
|
|
1563
|
+
children: [
|
|
1564
|
+
{
|
|
1565
|
+
id: 'tech-fe',
|
|
1566
|
+
name: '前端开发组',
|
|
1567
|
+
code: 'FE',
|
|
1568
|
+
children: [
|
|
1569
|
+
{ id: 'fe-react', name: 'React 团队', code: 'REACT' },
|
|
1570
|
+
{ id: 'fe-vue', name: 'Vue 团队', code: 'VUE' }
|
|
1571
|
+
]
|
|
1572
|
+
},
|
|
1573
|
+
{
|
|
1574
|
+
id: 'tech-be',
|
|
1575
|
+
name: '后端开发组',
|
|
1576
|
+
code: 'BE',
|
|
1577
|
+
children: [
|
|
1578
|
+
{ id: 'be-java', name: 'Java 团队', code: 'JAVA' },
|
|
1579
|
+
{ id: 'be-go', name: 'Go 团队', code: 'GO' }
|
|
1580
|
+
]
|
|
1581
|
+
},
|
|
1582
|
+
{ id: 'tech-qa', name: '质量保障组', code: 'QA' }
|
|
1583
|
+
]
|
|
1584
|
+
},
|
|
1585
|
+
{
|
|
1586
|
+
id: 'product',
|
|
1587
|
+
name: '产品设计中心',
|
|
1588
|
+
code: 'PRODUCT',
|
|
1589
|
+
children: [
|
|
1590
|
+
{ id: 'product-design', name: 'UI设计组', code: 'DESIGN' },
|
|
1591
|
+
{ id: 'product-pm', name: '产品经理组', code: 'PM' }
|
|
1592
|
+
]
|
|
1593
|
+
},
|
|
1594
|
+
{
|
|
1595
|
+
id: 'operation',
|
|
1596
|
+
name: '运营中心',
|
|
1597
|
+
code: 'OP',
|
|
1598
|
+
children: [
|
|
1599
|
+
{ id: 'op-marketing', name: '市场营销组', code: 'MARKETING' },
|
|
1600
|
+
{ id: 'op-cs', name: '客户服务组', code: 'CS' }
|
|
1601
|
+
]
|
|
1602
|
+
}
|
|
1603
|
+
];
|
|
1604
|
+
|
|
1605
|
+
// 商品分类数据
|
|
1606
|
+
const categoryData = [
|
|
1607
|
+
{
|
|
1608
|
+
id: 'electronics',
|
|
1609
|
+
name: '电子产品',
|
|
1610
|
+
children: [
|
|
1611
|
+
{
|
|
1612
|
+
id: 'phone',
|
|
1613
|
+
name: '手机',
|
|
1614
|
+
children: [
|
|
1615
|
+
{ id: 'iphone', name: 'iPhone' },
|
|
1616
|
+
{ id: 'android', name: '安卓手机' }
|
|
1617
|
+
]
|
|
1618
|
+
},
|
|
1619
|
+
{
|
|
1620
|
+
id: 'computer',
|
|
1621
|
+
name: '电脑',
|
|
1622
|
+
children: [
|
|
1623
|
+
{ id: 'laptop', name: '笔记本' },
|
|
1624
|
+
{ id: 'desktop', name: '台式机' }
|
|
1625
|
+
]
|
|
1626
|
+
}
|
|
1627
|
+
]
|
|
1628
|
+
},
|
|
1629
|
+
{
|
|
1630
|
+
id: 'clothing',
|
|
1631
|
+
name: '服装',
|
|
1632
|
+
children: [
|
|
1633
|
+
{
|
|
1634
|
+
id: 'mens',
|
|
1635
|
+
name: '男装',
|
|
1636
|
+
children: [
|
|
1637
|
+
{ id: 'mens-shirt', name: '衬衫' },
|
|
1638
|
+
{ id: 'mens-pants', name: '裤子' }
|
|
1639
|
+
]
|
|
1640
|
+
},
|
|
1641
|
+
{
|
|
1642
|
+
id: 'womens',
|
|
1643
|
+
name: '女装',
|
|
1644
|
+
children: [
|
|
1645
|
+
{ id: 'womens-dress', name: '连衣裙' },
|
|
1646
|
+
{ id: 'womens-blouse', name: '上衣' }
|
|
1647
|
+
]
|
|
1648
|
+
}
|
|
1649
|
+
]
|
|
1650
|
+
}
|
|
1651
|
+
];
|
|
1652
|
+
|
|
1653
|
+
// 超长文字测试数据
|
|
1654
|
+
const longTextData = [
|
|
1655
|
+
{
|
|
1656
|
+
id: 'dept-1',
|
|
1657
|
+
name: '人工智能与机器学习应用技术研发中心',
|
|
1658
|
+
children: [
|
|
1659
|
+
{
|
|
1660
|
+
id: 'dept-1-1',
|
|
1661
|
+
name: '自然语言处理与智能对话系统研发组',
|
|
1662
|
+
children: [
|
|
1663
|
+
{ id: 'dept-1-1-1', name: '大语言模型训练与优化专项小组' },
|
|
1664
|
+
{ id: 'dept-1-1-2', name: '智能客服机器人产品研发团队' },
|
|
1665
|
+
{ id: 'dept-1-1-3', name: '多语言机器翻译引擎研发组' },
|
|
1666
|
+
{ id: 'dept-1-1-4', name: '知识图谱构建与智能问答系统研发小组' },
|
|
1667
|
+
{ id: 'dept-1-1-5', name: '文本挖掘与情感分析技术研发团队' }
|
|
1668
|
+
]
|
|
1669
|
+
},
|
|
1670
|
+
{
|
|
1671
|
+
id: 'dept-1-2',
|
|
1672
|
+
name: '计算机视觉与图像识别技术研发组',
|
|
1673
|
+
children: [
|
|
1674
|
+
{ id: 'dept-1-2-1', name: '工业质检视觉检测算法研发小组' },
|
|
1675
|
+
{ id: 'dept-1-2-2', name: '人脸识别与活体检测技术研发团队' },
|
|
1676
|
+
{ id: 'dept-1-2-3', name: '医疗影像AI辅助诊断研发组' },
|
|
1677
|
+
{ id: 'dept-1-2-4', name: '自动驾驶视觉感知算法研发小组' },
|
|
1678
|
+
{ id: 'dept-1-2-5', name: '视频内容理解与智能分析研发团队' }
|
|
1679
|
+
]
|
|
1680
|
+
},
|
|
1681
|
+
{
|
|
1682
|
+
id: 'dept-1-3',
|
|
1683
|
+
name: '语音识别与合成技术研发小组',
|
|
1684
|
+
children: [
|
|
1685
|
+
{ id: 'dept-1-3-1', name: '端到端语音识别引擎研发团队' },
|
|
1686
|
+
{ id: 'dept-1-3-2', name: '多风格语音合成与情感表达研发组' }
|
|
1687
|
+
]
|
|
1688
|
+
},
|
|
1689
|
+
{
|
|
1690
|
+
id: 'dept-1-4',
|
|
1691
|
+
name: '强化学习与决策智能研发组',
|
|
1692
|
+
children: [
|
|
1693
|
+
{ id: 'dept-1-4-1', name: '智能博弈与游戏AI研发团队' },
|
|
1694
|
+
{ id: 'dept-1-4-2', name: '机器人控制与路径规划算法研发组' }
|
|
1695
|
+
]
|
|
1696
|
+
}
|
|
1697
|
+
]
|
|
1698
|
+
},
|
|
1699
|
+
{
|
|
1700
|
+
id: 'dept-2',
|
|
1701
|
+
name: '云计算与大数据平台技术中心',
|
|
1702
|
+
children: [
|
|
1703
|
+
{
|
|
1704
|
+
id: 'dept-2-1',
|
|
1705
|
+
name: '分布式存储与计算架构研发组',
|
|
1706
|
+
children: [
|
|
1707
|
+
{ id: 'dept-2-1-1', name: '高可用分布式数据库内核研发团队' },
|
|
1708
|
+
{ id: 'dept-2-1-2', name: '云原生容器编排与调度系统研发组' },
|
|
1709
|
+
{ id: 'dept-2-1-3', name: '对象存储与分布式文件系统研发小组' },
|
|
1710
|
+
{ id: 'dept-2-1-4', name: '微服务架构与服务网格技术研发团队' }
|
|
1711
|
+
]
|
|
1712
|
+
},
|
|
1713
|
+
{
|
|
1714
|
+
id: 'dept-2-2',
|
|
1715
|
+
name: '数据中台与数据治理解决方案团队',
|
|
1716
|
+
children: [
|
|
1717
|
+
{ id: 'dept-2-2-1', name: '企业级数据仓库建模与ETL开发组' },
|
|
1718
|
+
{ id: 'dept-2-2-2', name: '实时数据流处理与计算引擎研发组' },
|
|
1719
|
+
{ id: 'dept-2-2-3', name: '数据资产管理与元数据管理研发小组' },
|
|
1720
|
+
{ id: 'dept-2-2-4', name: '数据质量监控与异常检测系统研发团队' }
|
|
1721
|
+
]
|
|
1722
|
+
},
|
|
1723
|
+
{
|
|
1724
|
+
id: 'dept-2-3',
|
|
1725
|
+
name: '云安全与合规性保障研发组',
|
|
1726
|
+
children: [
|
|
1727
|
+
{ id: 'dept-2-3-1', name: '云原生安全架构与容器安全研发团队' },
|
|
1728
|
+
{ id: 'dept-2-3-2', name: '数据加密与密钥管理系统研发组' }
|
|
1729
|
+
]
|
|
1730
|
+
}
|
|
1731
|
+
]
|
|
1732
|
+
},
|
|
1733
|
+
{
|
|
1734
|
+
id: 'dept-3',
|
|
1735
|
+
name: '网络安全与隐私保护技术中心',
|
|
1736
|
+
children: [
|
|
1737
|
+
{
|
|
1738
|
+
id: 'dept-3-1',
|
|
1739
|
+
name: '网络攻防与安全应急响应团队',
|
|
1740
|
+
children: [
|
|
1741
|
+
{ id: 'dept-3-1-1', name: '威胁情报分析与安全态势感知研发组' },
|
|
1742
|
+
{ id: 'dept-3-1-2', name: '零信任安全架构与企业安全网关研发组' },
|
|
1743
|
+
{ id: 'dept-3-1-3', name: '漏洞挖掘与渗透测试技术研发小组' },
|
|
1744
|
+
{ id: 'dept-3-1-4', name: '安全编排自动化与响应(SOAR)平台研发团队' }
|
|
1745
|
+
]
|
|
1746
|
+
},
|
|
1747
|
+
{
|
|
1748
|
+
id: 'dept-3-2',
|
|
1749
|
+
name: '数据隐私计算与联邦学习研发小组',
|
|
1750
|
+
children: [
|
|
1751
|
+
{ id: 'dept-3-2-1', name: '多方安全计算与隐私求交技术研发团队' },
|
|
1752
|
+
{ id: 'dept-3-2-2', name: '联邦学习平台与隐私保护机器学习研发组' }
|
|
1753
|
+
]
|
|
1754
|
+
}
|
|
1755
|
+
]
|
|
1756
|
+
},
|
|
1757
|
+
{
|
|
1758
|
+
id: 'dept-4',
|
|
1759
|
+
name: '智能硬件与物联网技术研发中心',
|
|
1760
|
+
children: [
|
|
1761
|
+
{
|
|
1762
|
+
id: 'dept-4-1',
|
|
1763
|
+
name: '嵌入式系统与边缘计算研发组',
|
|
1764
|
+
children: [
|
|
1765
|
+
{ id: 'dept-4-1-1', name: '物联网设备固件与操作系统研发团队' },
|
|
1766
|
+
{ id: 'dept-4-1-2', name: '边缘AI推理与模型优化部署研发小组' },
|
|
1767
|
+
{ id: 'dept-4-1-3', name: '工业物联网网关与协议转换研发组' }
|
|
1768
|
+
]
|
|
1769
|
+
},
|
|
1770
|
+
{
|
|
1771
|
+
id: 'dept-4-2',
|
|
1772
|
+
name: '智能传感器与MEMS技术研发团队',
|
|
1773
|
+
children: [
|
|
1774
|
+
{ id: 'dept-4-2-1', name: '多模态传感器融合算法研发小组' },
|
|
1775
|
+
{ id: 'dept-4-2-2', name: '环境感知与智能检测传感器研发组' }
|
|
1776
|
+
]
|
|
1777
|
+
},
|
|
1778
|
+
{
|
|
1779
|
+
id: 'dept-4-3',
|
|
1780
|
+
name: '智能家居与消费电子解决方案团队',
|
|
1781
|
+
children: [
|
|
1782
|
+
{ id: 'dept-4-3-1', name: '智能音箱与语音交互产品研发小组' },
|
|
1783
|
+
{ id: 'dept-4-3-2', name: '智能穿戴设备与健康监测研发团队' },
|
|
1784
|
+
{ id: 'dept-4-3-3', name: '智能家居控制中枢与生态系统研发组' }
|
|
1785
|
+
]
|
|
1786
|
+
}
|
|
1787
|
+
]
|
|
1788
|
+
},
|
|
1789
|
+
{
|
|
1790
|
+
id: 'dept-5',
|
|
1791
|
+
name: '企业数字化转型与咨询服务事业部',
|
|
1792
|
+
children: [
|
|
1793
|
+
{
|
|
1794
|
+
id: 'dept-5-1',
|
|
1795
|
+
name: '行业解决方案与数字化咨询团队',
|
|
1796
|
+
children: [
|
|
1797
|
+
{ id: 'dept-5-1-1', name: '金融行业数字化解决方案与实施团队' },
|
|
1798
|
+
{ id: 'dept-5-1-2', name: '制造业智能制造与工业互联网咨询组' },
|
|
1799
|
+
{ id: 'dept-5-1-3', name: '医疗健康行业数字化转型解决方案团队' },
|
|
1800
|
+
{ id: 'dept-5-1-4', name: '零售电商与新零售数字化咨询研发组' }
|
|
1801
|
+
]
|
|
1802
|
+
},
|
|
1803
|
+
{
|
|
1804
|
+
id: 'dept-5-2',
|
|
1805
|
+
name: '项目交付与技术支持服务团队',
|
|
1806
|
+
children: [
|
|
1807
|
+
{ id: 'dept-5-2-1', name: '企业级系统架构设计与集成实施小组' },
|
|
1808
|
+
{ id: 'dept-5-2-2', name: '客户成功与售后技术支持服务团队' }
|
|
1809
|
+
]
|
|
1810
|
+
}
|
|
1811
|
+
]
|
|
1812
|
+
}
|
|
1813
|
+
];
|
|
1814
|
+
|
|
1815
|
+
// 基础级联选择
|
|
1816
|
+
const BasicExample = ({ isPopup }) => {
|
|
1817
|
+
const [value, setValue] = useState([]);
|
|
1818
|
+
return (
|
|
1819
|
+
<Flex vertical gap={8}>
|
|
1820
|
+
<span>地区多选(父子关联):</span>
|
|
1821
|
+
<SelectCascader
|
|
1822
|
+
options={regionData}
|
|
1823
|
+
value={value}
|
|
1824
|
+
onChange={setValue}
|
|
1825
|
+
isPopup={isPopup}
|
|
1826
|
+
valueKey="id"
|
|
1827
|
+
labelKey="name"
|
|
1828
|
+
placeholder="请选择地区"
|
|
1829
|
+
menuItemWidth={160}
|
|
1830
|
+
style={{ width: 320 }}
|
|
1831
|
+
/>
|
|
1832
|
+
{value.length > 0 && (
|
|
1833
|
+
<Flex wrap gap={4}>
|
|
1834
|
+
{value.map(item => (
|
|
1835
|
+
<Tag key={item.id} color="blue">{item.name}</Tag>
|
|
1836
|
+
))}
|
|
1837
|
+
</Flex>
|
|
1838
|
+
)}
|
|
1839
|
+
</Flex>
|
|
1840
|
+
);
|
|
1841
|
+
};
|
|
1842
|
+
|
|
1843
|
+
// 单选模式
|
|
1844
|
+
const SingleExample = ({ isPopup }) => {
|
|
1845
|
+
const [value, setValue] = useState(null);
|
|
1846
|
+
return (
|
|
1847
|
+
<Flex vertical gap={8}>
|
|
1848
|
+
<span>地区单选:</span>
|
|
1849
|
+
<SelectCascader
|
|
1850
|
+
single
|
|
1851
|
+
options={regionData}
|
|
1852
|
+
value={value}
|
|
1853
|
+
onChange={setValue}
|
|
1854
|
+
isPopup={isPopup}
|
|
1855
|
+
valueKey="id"
|
|
1856
|
+
labelKey="name"
|
|
1857
|
+
placeholder="请选择地区"
|
|
1858
|
+
menuItemWidth={160}
|
|
1859
|
+
style={{ width: 320 }}
|
|
1860
|
+
/>
|
|
1861
|
+
{value && <Tag color="green">已选:{value.name}</Tag>}
|
|
1862
|
+
</Flex>
|
|
1863
|
+
);
|
|
1864
|
+
};
|
|
1865
|
+
|
|
1866
|
+
// 只选末级
|
|
1867
|
+
const OnlyLastLevelExample = ({ isPopup }) => {
|
|
1868
|
+
const [value, setValue] = useState([]);
|
|
1869
|
+
|
|
1870
|
+
return (
|
|
1871
|
+
<Flex vertical gap={8}>
|
|
1872
|
+
<span>只允许选择末级节点:</span>
|
|
1873
|
+
<SelectCascader
|
|
1874
|
+
options={organizationData}
|
|
1875
|
+
value={value}
|
|
1876
|
+
onChange={setValue}
|
|
1877
|
+
isPopup={isPopup}
|
|
1878
|
+
valueKey="id"
|
|
1879
|
+
labelKey="name"
|
|
1880
|
+
onlyAllowLastLevel
|
|
1881
|
+
placeholder="请选择团队"
|
|
1882
|
+
menuItemWidth={180}
|
|
1883
|
+
style={{ width: 360 }}
|
|
1884
|
+
/>
|
|
1885
|
+
{value.length > 0 && (
|
|
1886
|
+
<div>
|
|
1887
|
+
已选团队:{value.map(item => item.name).join('、')}
|
|
1888
|
+
</div>
|
|
1889
|
+
)}
|
|
1890
|
+
</Flex>
|
|
1891
|
+
);
|
|
1892
|
+
};
|
|
1893
|
+
|
|
1894
|
+
// 数量限制
|
|
1895
|
+
const MaxLimitExample = ({ isPopup }) => {
|
|
1896
|
+
const [value, setValue] = useState([]);
|
|
1897
|
+
|
|
1898
|
+
return (
|
|
1899
|
+
<Flex vertical gap={8}>
|
|
1900
|
+
<span>最多选择 3 项:</span>
|
|
1901
|
+
<SelectCascader
|
|
1902
|
+
options={regionData}
|
|
1903
|
+
value={value}
|
|
1904
|
+
onChange={setValue}
|
|
1905
|
+
isPopup={isPopup}
|
|
1906
|
+
valueKey="id"
|
|
1907
|
+
labelKey="name"
|
|
1908
|
+
maxLength={3}
|
|
1909
|
+
placeholder="请选择地区(最多3项)"
|
|
1910
|
+
menuItemWidth={160}
|
|
1911
|
+
style={{ width: 320 }}
|
|
1912
|
+
/>
|
|
1913
|
+
<Tag color={value.length >= 3 ? 'red' : 'blue'}>
|
|
1914
|
+
已选择 {value.length}/3 项
|
|
1915
|
+
</Tag>
|
|
1916
|
+
</Flex>
|
|
1917
|
+
);
|
|
1918
|
+
};
|
|
1919
|
+
|
|
1920
|
+
// 带搜索功能
|
|
1921
|
+
const SearchExample = ({ isPopup }) => {
|
|
1922
|
+
const [value, setValue] = useState([]);
|
|
1923
|
+
|
|
1924
|
+
return (
|
|
1925
|
+
<Flex vertical gap={8}>
|
|
1926
|
+
<span>带搜索功能:</span>
|
|
1927
|
+
<SelectCascader
|
|
1928
|
+
options={regionData}
|
|
1929
|
+
value={value}
|
|
1930
|
+
onChange={setValue}
|
|
1931
|
+
isPopup={isPopup}
|
|
1932
|
+
valueKey="id"
|
|
1933
|
+
labelKey="name"
|
|
1934
|
+
onSearch={(searchText, { mapping }) => {
|
|
1935
|
+
return Array.from(mapping.values()).filter(item =>
|
|
1936
|
+
item.name.toLowerCase().includes(searchText.toLowerCase())
|
|
1937
|
+
);
|
|
1938
|
+
}}
|
|
1939
|
+
searchPlaceholder="搜索地区名称"
|
|
1940
|
+
placeholder="搜索并选择地区"
|
|
1941
|
+
menuItemWidth={160}
|
|
1942
|
+
style={{ width: 360 }}
|
|
1943
|
+
/>
|
|
1944
|
+
</Flex>
|
|
1945
|
+
);
|
|
1946
|
+
};
|
|
1947
|
+
|
|
1948
|
+
// 商品分类选择
|
|
1949
|
+
const CategoryExample = ({ isPopup }) => {
|
|
1950
|
+
const [value, setValue] = useState([]);
|
|
1951
|
+
|
|
1952
|
+
return (
|
|
1953
|
+
<Flex vertical gap={8}>
|
|
1954
|
+
<span>商品分类选择:</span>
|
|
1955
|
+
<SelectCascader
|
|
1956
|
+
options={categoryData}
|
|
1957
|
+
value={value}
|
|
1958
|
+
onChange={setValue}
|
|
1959
|
+
isPopup={isPopup}
|
|
1960
|
+
valueKey="id"
|
|
1961
|
+
labelKey="name"
|
|
1962
|
+
placeholder="请选择商品分类"
|
|
1963
|
+
menuItemWidth={160}
|
|
1964
|
+
style={{ width: 320 }}
|
|
1965
|
+
/>
|
|
1966
|
+
{value.length > 0 && (
|
|
1967
|
+
<div>
|
|
1968
|
+
已选分类:{value.map(item => item.name).join(' > ')}
|
|
1969
|
+
</div>
|
|
1970
|
+
)}
|
|
1971
|
+
</Flex>
|
|
1972
|
+
);
|
|
1973
|
+
};
|
|
1974
|
+
|
|
1975
|
+
// 超长文字测试
|
|
1976
|
+
const LongTextExample = ({ isPopup }) => {
|
|
1977
|
+
const [value, setValue] = useState([]);
|
|
1978
|
+
|
|
1979
|
+
return (
|
|
1980
|
+
<Flex vertical gap={8}>
|
|
1981
|
+
<span>超长文字省略测试(部门选择):</span>
|
|
1982
|
+
<SelectCascader
|
|
1983
|
+
options={longTextData}
|
|
1984
|
+
value={value}
|
|
1985
|
+
onChange={setValue}
|
|
1986
|
+
isPopup={isPopup}
|
|
1987
|
+
valueKey="id"
|
|
1988
|
+
labelKey="name"
|
|
1989
|
+
placeholder="请选择部门"
|
|
1990
|
+
menuItemWidth={200}
|
|
1991
|
+
style={{ width: 400 }}
|
|
1992
|
+
/>
|
|
1993
|
+
{value.length > 0 && (
|
|
1994
|
+
<Flex wrap gap={4}>
|
|
1995
|
+
{value.map(item => (
|
|
1996
|
+
<Tag key={item.id} color="purple" style={{ maxWidth: 200, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
|
1997
|
+
{item.name}
|
|
1998
|
+
</Tag>
|
|
1999
|
+
))}
|
|
2000
|
+
</Flex>
|
|
2001
|
+
)}
|
|
2002
|
+
</Flex>
|
|
2003
|
+
);
|
|
2004
|
+
};
|
|
2005
|
+
|
|
2006
|
+
const BaseExample = () => {
|
|
2007
|
+
const [isPopup, setIsPopup] = useState(true);
|
|
2008
|
+
|
|
2009
|
+
return (
|
|
2010
|
+
<Flex vertical gap={24}>
|
|
2011
|
+
<Flex align="center" gap={12}>
|
|
2012
|
+
<span>展示模式:</span>
|
|
2013
|
+
<Switch
|
|
2014
|
+
checked={isPopup}
|
|
2015
|
+
onChange={setIsPopup}
|
|
2016
|
+
checkedChildren="下拉"
|
|
2017
|
+
unCheckedChildren="弹窗"
|
|
2018
|
+
/>
|
|
2019
|
+
<span style={{ color: '#666', fontSize: 12 }}>
|
|
2020
|
+
{isPopup ? '点击输入框展开下拉菜单' : '点击输入框打开弹窗'}
|
|
2021
|
+
</span>
|
|
2022
|
+
</Flex>
|
|
2023
|
+
<Divider />
|
|
2024
|
+
<BasicExample isPopup={isPopup} />
|
|
2025
|
+
<Divider />
|
|
2026
|
+
<SingleExample isPopup={isPopup} />
|
|
2027
|
+
<Divider />
|
|
2028
|
+
<OnlyLastLevelExample isPopup={isPopup} />
|
|
2029
|
+
<Divider />
|
|
2030
|
+
<MaxLimitExample isPopup={isPopup} />
|
|
2031
|
+
<Divider />
|
|
2032
|
+
<SearchExample isPopup={isPopup} />
|
|
2033
|
+
<Divider />
|
|
2034
|
+
<CategoryExample isPopup={isPopup} />
|
|
2035
|
+
<Divider />
|
|
2036
|
+
<LongTextExample isPopup={isPopup} />
|
|
2037
|
+
</Flex>
|
|
2038
|
+
);
|
|
2039
|
+
};
|
|
2040
|
+
|
|
2041
|
+
render(<BaseExample />);
|
|
2042
|
+
|
|
2043
|
+
```
|
|
1331
2044
|
|
|
1332
2045
|
### API
|
|
1333
2046
|
|
|
@@ -1337,24 +2050,45 @@ render(<BaseExample />);
|
|
|
1337
2050
|
|
|
1338
2051
|
| 属性名 | 说明 | 类型 | 默认值 |
|
|
1339
2052
|
|-------------------|-------------------|-------------------------------|---------------------|
|
|
1340
|
-
| value | 当前选中的值 | array
|
|
1341
|
-
|
|
|
1342
|
-
|
|
|
1343
|
-
|
|
|
1344
|
-
|
|
|
1345
|
-
| max | 最多可选数量 | number | - |
|
|
2053
|
+
| value | 当前选中的值 | array \| object | [] |
|
|
2054
|
+
| defaultValue | 默认选中的值 | array \| object | [] |
|
|
2055
|
+
| onChange | 选中值变化时的回调函数 | function(value) | - |
|
|
2056
|
+
| single | 是否单选模式 | boolean | false |
|
|
2057
|
+
| maxLength | 最多可选数量(多选模式) | number | - |
|
|
1346
2058
|
| disabled | 是否禁用 | boolean | false |
|
|
1347
|
-
| readOnly | 是否只读 | boolean | false |
|
|
1348
2059
|
| size | 选择框尺寸 | 'small' \| 'default' \| 'large' | 'default' |
|
|
2060
|
+
| placeholder | 输入框占位符 | string | '请选择' |
|
|
2061
|
+
| labelKey | 数据项显示文本字段 | string | 'label' |
|
|
2062
|
+
| valueKey | 数据项唯一标识字段 | string | 'value' |
|
|
2063
|
+
| isPopup | 是否下拉模式(false 为弹窗)| boolean | true |
|
|
2064
|
+
| placement | 下拉菜单位置 | string | 'bottomLeft' |
|
|
2065
|
+
| overlayWidth | 下拉菜单宽度 | number \| string | 同输入框宽度 |
|
|
2066
|
+
| overlayClassName | 下拉菜单自定义类名 | string | - |
|
|
2067
|
+
| labelWrap | 标签是否换行显示 | boolean | false |
|
|
2068
|
+
| allowClear | 是否允许清空 | boolean | true |
|
|
2069
|
+
| allowSelectedAll | 是否显示全选按钮 | boolean | false |
|
|
2070
|
+
| selectedAllValue | 全选项的值配置 | object | { value: 'all', label: '全选' } |
|
|
2071
|
+
| prefix | 输入框前缀 | ReactNode \| function | - |
|
|
2072
|
+
| suffix | 输入框后缀 | ReactNode \| function | - |
|
|
1349
2073
|
| className | 自定义类名 | string | - |
|
|
1350
2074
|
| style | 自定义样式 | object | - |
|
|
1351
2075
|
| children | 自定义渲染内容 | function(props) | - |
|
|
1352
|
-
|
|
|
1353
|
-
|
|
|
1354
|
-
|
|
|
1355
|
-
|
|
|
1356
|
-
|
|
|
1357
|
-
|
|
|
2076
|
+
| renderModal | 自定义弹窗渲染(非 isPopup 模式)| function(contextProps) | 默认 Modal 弹窗 |
|
|
2077
|
+
| renderContent | 自定义内容渲染 | function(children) | - |
|
|
2078
|
+
| inputRender | 自定义输入框渲染 | function(props, contextProps) | - |
|
|
2079
|
+
| open | 是否打开下拉菜单 | boolean | - |
|
|
2080
|
+
| defaultOpen | 默认是否打开 | boolean | false |
|
|
2081
|
+
| onOpenChange | 下拉菜单状态变化回调 | function(open) | - |
|
|
2082
|
+
|
|
2083
|
+
##### 标签溢出处理
|
|
2084
|
+
|
|
2085
|
+
组件内置了标签溢出处理功能:
|
|
2086
|
+
|
|
2087
|
+
- **单选模式**:文本超出输入框宽度时显示省略号
|
|
2088
|
+
- **多选模式**:
|
|
2089
|
+
- 单个标签最大宽度为 `min(150px, 容器宽度 - 60px)`
|
|
2090
|
+
- 超出容器宽度的标签自动隐藏,显示 `+N` 标签表示隐藏数量
|
|
2091
|
+
- 标签宽度根据实际内容动态计算,确保精确显示
|
|
1358
2092
|
|
|
1359
2093
|
#### SelectList
|
|
1360
2094
|
|
|
@@ -1513,3 +2247,69 @@ import { zhCN, enUS } from '@kne/super-select/locale';
|
|
|
1513
2247
|
| items | 项文案 | 项 |
|
|
1514
2248
|
| exceed | 超出限制提示文案 | 最多只能选择 {max} 项 |
|
|
1515
2249
|
|
|
2250
|
+
#### SelectCascader
|
|
2251
|
+
|
|
2252
|
+
级联选择组件,适用于地区选择、组织架构、商品分类等层级数据的选择场景。支持多列菜单展示、父子关联选择、末级限制、搜索过滤等功能。
|
|
2253
|
+
|
|
2254
|
+
| 属性名 | 说明 | 类型 | 默认值 |
|
|
2255
|
+
|-------------------|-------------------|-------------------------------|---------------------|
|
|
2256
|
+
| options | 级联数据源 | array | [] |
|
|
2257
|
+
| value | 当前选中的值 | array \| object | [] |
|
|
2258
|
+
| onChange | 选中值变化时的回调函数 | function(value) | - |
|
|
2259
|
+
| defaultValue | 默认选中的值 | array | [] |
|
|
2260
|
+
| single | 是否单选模式 | boolean | false |
|
|
2261
|
+
| maxLength | 最多可选数量 | number | Number.MAX_VALUE |
|
|
2262
|
+
| onlyAllowLastLevel | 是否只允许选择末级节点 | boolean | false |
|
|
2263
|
+
| openLoadData | 是否开启懒加载 | boolean | false |
|
|
2264
|
+
| onLoadMore | 懒加载回调函数 | function({ [parentIdKey]: id }) | - |
|
|
2265
|
+
| parentIdKey | 父节点ID字段名 | string | 'id' |
|
|
2266
|
+
| menuItemWidth | 每列菜单宽度 | number | 180 |
|
|
2267
|
+
| isPopup | 是否下拉模式(false 为弹窗)| boolean | true |
|
|
2268
|
+
| searchPlaceholder| 搜索框占位符 | string | '搜索...' |
|
|
2269
|
+
| onSearch | 搜索回调函数 | function(searchText, { mapping }) | - |
|
|
2270
|
+
| valueKey | 数据项唯一标识字段 | string | 'id' |
|
|
2271
|
+
| labelKey | 数据项显示文本字段 | string | 'label' |
|
|
2272
|
+
| placeholder | 输入框占位符 | string | '请选择' |
|
|
2273
|
+
| disabled | 是否禁用 | boolean | false |
|
|
2274
|
+
| size | 选择框尺寸 | 'small' \| 'default' \| 'large' | 'default' |
|
|
2275
|
+
| overlayWidth | 下拉菜单宽度 | number | menuItemWidth * 2 |
|
|
2276
|
+
|
|
2277
|
+
##### options 数据结构
|
|
2278
|
+
|
|
2279
|
+
```javascript
|
|
2280
|
+
[
|
|
2281
|
+
{
|
|
2282
|
+
id: 'node1', // 唯一标识,字段名可通过 valueKey 配置
|
|
2283
|
+
name: '节点名称', // 显示文本,字段名可通过 labelKey 配置
|
|
2284
|
+
children: [ // 子节点
|
|
2285
|
+
{
|
|
2286
|
+
id: 'node1-1',
|
|
2287
|
+
name: '子节点1',
|
|
2288
|
+
children: []
|
|
2289
|
+
}
|
|
2290
|
+
]
|
|
2291
|
+
}
|
|
2292
|
+
]
|
|
2293
|
+
```
|
|
2294
|
+
|
|
2295
|
+
##### 父子关联选择
|
|
2296
|
+
|
|
2297
|
+
组件默认支持父子关联选择:
|
|
2298
|
+
- 选中父节点时,自动选中所有子节点
|
|
2299
|
+
- 取消父节点时,自动取消所有子节点
|
|
2300
|
+
- 当所有子节点都被选中时,父节点自动选中
|
|
2301
|
+
|
|
2302
|
+
##### 搜索功能
|
|
2303
|
+
|
|
2304
|
+
通过 `onSearch` 属性开启搜索功能:
|
|
2305
|
+
|
|
2306
|
+
```jsx
|
|
2307
|
+
<SelectCascader
|
|
2308
|
+
options={data}
|
|
2309
|
+
onSearch={(searchText, { mapping }) => {
|
|
2310
|
+
return Array.from(mapping.values()).filter(item =>
|
|
2311
|
+
item.name.includes(searchText)
|
|
2312
|
+
);
|
|
2313
|
+
}}
|
|
2314
|
+
/>
|
|
2315
|
+
```
|