Skip to content

Commit

Permalink
feat(TreeSelect): support useDetailValue, close #3531 (#4771)
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
YSMJ1994 authored and eternalsky committed Jul 16, 2024
1 parent e90c3a7 commit 2d3c79e
Show file tree
Hide file tree
Showing 8 changed files with 494 additions and 242 deletions.
11 changes: 11 additions & 0 deletions components/tree-select/__docs__/demo/use-detail-value/index.md
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 components/tree-select/__docs__/demo/use-detail-value/index.tsx
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);
192 changes: 101 additions & 91 deletions components/tree-select/__docs__/index.en-us.md

Large diffs are not rendered by default.

127 changes: 64 additions & 63 deletions components/tree-select/__docs__/index.md

Large diffs are not rendered by default.

Loading

0 comments on commit 2d3c79e

Please sign in to comment.