-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(TreeSelect): support useDetailValue, close #3531 * chore(TreeSelect): improve useDetailValue tc and demos by codereview * test(TreeSelect): add control mode spec for useDetailValue
- Loading branch information
1 parent
e90c3a7
commit 2d3c79e
Showing
8 changed files
with
494 additions
and
242 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
components/tree-select/__docs__/demo/use-detail-value/index.md
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,11 @@ | ||
# zh-CN order=8 | ||
|
||
# 对象数据 | ||
|
||
`useDetailValue` 把 `value`、`defaultValue`、`onChange 第一个参数`从字符串变成对象 | ||
|
||
# en-US order=8 | ||
|
||
# useDetailValue | ||
|
||
`useDetailValue` change `value`、`defaultValue`、`first arg of onChange` from string to object |
79 changes: 79 additions & 0 deletions
79
components/tree-select/__docs__/demo/use-detail-value/index.tsx
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,79 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { TreeSelect } from '@alifd/next'; | ||
|
||
const TreeNode = TreeSelect.Node; | ||
const dataSource = [ | ||
{ | ||
value: '1', | ||
label: 'Component', | ||
children: [ | ||
{ | ||
label: 'Form', | ||
value: '2', | ||
children: [ | ||
{ | ||
label: 'Input', | ||
value: '4', | ||
}, | ||
{ | ||
label: 'Select', | ||
value: '5', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
value: '3', | ||
label: 'Display', | ||
children: [ | ||
{ | ||
label: 'Table', | ||
value: '6', | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
function App() { | ||
function handleChange(...args: unknown[]) { | ||
console.log('onChange', ...args); | ||
} | ||
|
||
return ( | ||
<div> | ||
<div>DataSource mode</div> | ||
<TreeSelect | ||
useDetailValue | ||
defaultValue={{ label: 'Form', value: '2' }} | ||
onChange={handleChange.bind(undefined, 'from dataSource mode')} | ||
dataSource={dataSource} | ||
style={{ width: 150 }} | ||
treeDefaultExpandAll | ||
/> | ||
<br /> | ||
<br /> | ||
<div>Children mode</div> | ||
<TreeSelect | ||
useDetailValue | ||
defaultValue={{ label: 'Form', value: '2' }} | ||
onChange={handleChange.bind(undefined, 'from children mode')} | ||
style={{ width: 150 }} | ||
treeDefaultExpandAll | ||
> | ||
<TreeNode key="1" value="1" label="Component"> | ||
<TreeNode key="2" value="2" label="Form"> | ||
<TreeNode key="4" value="4" label="Input" /> | ||
<TreeNode key="5" value="5" label="Select" disabled /> | ||
</TreeNode> | ||
<TreeNode key="3" value="3" label="Display"> | ||
<TreeNode key="6" value="6" label="Table" /> | ||
</TreeNode> | ||
</TreeNode> | ||
</TreeSelect> | ||
</div> | ||
); | ||
} | ||
|
||
ReactDOM.render(<App />, mountNode); |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.