Skip to content

Commit b69ed2b

Browse files
committed
chore: unchange demo
1 parent fa85621 commit b69ed2b

File tree

1 file changed

+60
-43
lines changed

1 file changed

+60
-43
lines changed

examples/mutiple-with-maxCount.tsx

Lines changed: 60 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,61 @@ import React, { useState } from 'react';
22
import TreeSelect from '../src';
33

44
export default () => {
5-
const [value, setValue] = useState<string[]>();
6-
const [checkValue, setCheckValue] = useState<string[]>();
5+
const [value, setValue] = useState<string[]>(['1']);
6+
const [checkValue, setCheckValue] = useState<string[]>(['1']);
77

88
const treeData = [
99
{
10-
title: 'Parent 1',
11-
value: 'parent1',
10+
key: '1',
11+
value: '1',
12+
title: '1',
1213
children: [
1314
{
14-
title: 'Child 1-1',
15-
value: 'child1-1',
15+
key: '1-1',
16+
value: '1-1',
17+
title: '1-1',
1618
},
1719
{
18-
title: 'Child 1-2',
19-
value: 'child1-2',
20+
key: '1-2',
21+
value: '1-2',
22+
title: '1-2',
23+
disabled: true,
2024
children: [
2125
{
22-
title: 'Child 1-2-1',
23-
value: 'child1-2-1',
24-
children: [
25-
{
26-
title: 'child 1-2-1-1',
27-
value: 'child1-2-1-1',
28-
children: [
29-
{
30-
title: 'child 1-2-1-1-1',
31-
value: 'child1-2-1-1-1',
32-
},
33-
],
34-
},
35-
{
36-
title: 'child 1-2-1-2',
37-
value: 'child1-2-1-2',
38-
},
39-
{
40-
title: 'child 1-2-1-3',
41-
value: 'child1-2-1-3',
42-
},
43-
],
26+
key: '1-2-1',
27+
value: '1-2-1',
28+
title: '1-2-1',
29+
disabled: true,
4430
},
4531
{
46-
title: 'Child 1-2-2',
47-
value: 'child1-2-2',
48-
},
49-
{
50-
title: 'Child 1-2-3',
51-
value: 'child1-2-3',
52-
},
53-
{
54-
title: 'Child 1-2-4',
55-
value: 'child1-2-4',
32+
key: '1-2-2',
33+
value: '1-2-2',
34+
title: '1-2-2',
5635
},
5736
],
5837
},
38+
{
39+
key: '1-3',
40+
value: '1-3',
41+
title: '1-3',
42+
},
5943
],
6044
},
45+
{
46+
key: '2',
47+
value: '2',
48+
title: '2',
49+
},
50+
{
51+
key: '3',
52+
value: '3',
53+
title: '3',
54+
},
55+
{
56+
key: '4',
57+
value: '4',
58+
title: '4',
59+
},
6160
];
6261

6362
const onChange = (val: string[]) => {
@@ -70,18 +69,36 @@ export default () => {
7069

7170
return (
7271
<>
73-
<h2>maxCount = 3</h2>
72+
<h2>multiple with maxCount</h2>
7473
<TreeSelect
7574
style={{ width: 300 }}
76-
treeCheckable
75+
fieldNames={{ value: 'value', label: 'title' }}
7776
multiple
77+
maxCount={3}
78+
treeData={treeData}
79+
/>
80+
<h2>checkable with maxCount</h2>
81+
<TreeSelect
82+
style={{ width: 300 }}
83+
treeCheckable
7884
// showCheckedStrategy="SHOW_ALL"
7985
// showCheckedStrategy="SHOW_PARENT"
80-
maxCount={3}
86+
maxCount={4}
8187
treeData={treeData}
8288
onChange={onChange}
8389
value={value}
8490
/>
91+
<h2>checkable with maxCount and treeCheckStrictly</h2>
92+
<TreeSelect
93+
style={{ width: 300 }}
94+
multiple
95+
treeCheckable
96+
treeCheckStrictly
97+
maxCount={3}
98+
treeData={treeData}
99+
onChange={onCheckChange}
100+
value={checkValue}
101+
/>
85102
</>
86103
);
87104
};

0 commit comments

Comments
 (0)