-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: TreeSelect support maxCount (#596)
* feat: TreeSelect support maxCount * feat: sync activeKey state * feat: sync disabled state * feat: sync disabled state * docs: improve maxCount demo * test: add maxCount test cases * chore: remove deadCode * test: add test cases for keyboard operations * chore: remove useless code * test: add test case * test: improve test case * docs: add maxCount description * feat: forbid check when checkedKeys more than maxCount * chore: demo improvement * feat: adjust maxCount implement logic * fix: lint fix * test: add test cases for maxCount * chore: hoist state to context * chore: hoist traverse operation to TreeSelect * feat: improve keyboard navigation when reach maxCount * feat: improve keyboard navigation when reach maxCount * perf: use cache to improve navigation performance * refactor: reuse formatStrategyValues * feat: add disabledStrategy * feat: add code comment * test: supplement test case for keyboard operation * chore: handle git conflicts manually * chore: remove useless code * chore: memories displayValues * refactor: use InternalContext * chore: adjust context api * chore: bump rc-tree version to 5.11.0 for support maxCount * fix: test coverage * fix: fix some case * chore: remove keyboard operation logic * chore: optimized code logic
- Loading branch information
1 parent
c3bf3cb
commit b961a86
Showing
13 changed files
with
777 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: mutiple-with-maxCount | ||
nav: | ||
title: Demo | ||
path: /demo | ||
--- | ||
|
||
<code src="../../examples/mutiple-with-maxCount.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React, { useState } from 'react'; | ||
import TreeSelect from '../src'; | ||
|
||
export default () => { | ||
const [value, setValue] = useState<string[]>(['1']); | ||
const [checkValue, setCheckValue] = useState<string[]>(['1']); | ||
|
||
const treeData = [ | ||
{ | ||
key: '1', | ||
value: '1', | ||
title: '1', | ||
children: [ | ||
{ | ||
key: '1-1', | ||
value: '1-1', | ||
title: '1-1', | ||
}, | ||
{ | ||
key: '1-2', | ||
value: '1-2', | ||
title: '1-2', | ||
}, | ||
{ | ||
key: '1-3', | ||
value: '1-3', | ||
title: '1-3', | ||
}, | ||
], | ||
}, | ||
{ | ||
key: '2', | ||
value: '2', | ||
title: '2', | ||
}, | ||
{ | ||
key: '3', | ||
value: '3', | ||
title: '3', | ||
}, | ||
{ | ||
key: '4', | ||
value: '4', | ||
title: '4', | ||
}, | ||
]; | ||
|
||
const onChange = (val: string[]) => { | ||
setValue(val); | ||
}; | ||
|
||
const onCheckChange = (val: string[]) => { | ||
setCheckValue(val); | ||
}; | ||
|
||
return ( | ||
<> | ||
<h2>multiple with maxCount</h2> | ||
<TreeSelect | ||
style={{ width: 300 }} | ||
fieldNames={{ value: 'value', label: 'title' }} | ||
multiple | ||
maxCount={3} | ||
treeData={treeData} | ||
/> | ||
|
||
<h2>checkable with maxCount</h2> | ||
<TreeSelect | ||
style={{ width: 300 }} | ||
multiple | ||
treeCheckable | ||
// showCheckedStrategy="SHOW_ALL" | ||
showCheckedStrategy="SHOW_PARENT" | ||
// showCheckedStrategy="SHOW_CHILD" | ||
maxCount={4} | ||
treeData={treeData} | ||
onChange={onChange} | ||
value={value} | ||
/> | ||
|
||
<h2>checkable with maxCount and treeCheckStrictly</h2> | ||
<TreeSelect | ||
style={{ width: 300 }} | ||
multiple | ||
treeCheckable | ||
treeCheckStrictly | ||
maxCount={3} | ||
treeData={treeData} | ||
onChange={onCheckChange} | ||
value={checkValue} | ||
/> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.