-
Notifications
You must be signed in to change notification settings - Fork 199
feat: TreeSelect support maxCount #596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
fb8e621
feat: TreeSelect support maxCount
aojunhao123 95c7747
feat: sync activeKey state
aojunhao123 aa28c56
feat: sync disabled state
aojunhao123 8d63a07
feat: sync disabled state
aojunhao123 baf5f26
docs: improve maxCount demo
aojunhao123 828b5ee
test: add maxCount test cases
aojunhao123 ca8d966
chore: remove deadCode
aojunhao123 751e850
Merge branch 'master' into feat-maxCount
aojunhao123 cc3b839
test: add test cases for keyboard operations
aojunhao123 5039213
chore: remove useless code
aojunhao123 bd6b5ff
test: add test case
aojunhao123 15472c5
test: improve test case
aojunhao123 043527f
docs: add maxCount description
aojunhao123 182add5
feat: forbid check when checkedKeys more than maxCount
aojunhao123 ac9010c
chore: demo improvement
aojunhao123 c77d585
feat: adjust maxCount implement logic
aojunhao123 3559f12
fix: lint fix
aojunhao123 c72c25f
test: add test cases for maxCount
aojunhao123 c178539
chore: hoist state to context
aojunhao123 e9b59f9
chore: hoist traverse operation to TreeSelect
aojunhao123 feb012d
feat: improve keyboard navigation when reach maxCount
aojunhao123 06ee328
feat: improve keyboard navigation when reach maxCount
aojunhao123 ff9f216
perf: use cache to improve navigation performance
aojunhao123 a5625a1
refactor: reuse formatStrategyValues
aojunhao123 856be00
feat: add disabledStrategy
aojunhao123 e489e17
feat: add code comment
aojunhao123 06dee72
test: supplement test case for keyboard operation
aojunhao123 667dc46
chore: handle git conflicts manually
aojunhao123 a76ac30
Merge branch 'master' into feat-maxCount
aojunhao123 f8e5f61
chore: remove useless code
aojunhao123 7df686a
chore: memories displayValues
aojunhao123 c69fcae
refactor: use InternalContext
aojunhao123 f352161
chore: adjust context api
aojunhao123 2bd8a5c
chore: bump rc-tree version to 5.11.0 for support maxCount
aojunhao123 142385a
fix: test coverage
aojunhao123 73e9ae7
fix: fix some case
aojunhao123 f737832
chore: remove keyboard operation logic
aojunhao123 4c23314
chore: optimized code logic
aojunhao123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.