-
Notifications
You must be signed in to change notification settings - Fork 99
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(check-select&check-tree-select&check-cascader): #2528
- Loading branch information
Showing
15 changed files
with
317 additions
and
8 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,7 @@ | ||
--- | ||
"@hi-ui/check-cascader": minor | ||
"@hi-ui/check-select": minor | ||
"@hi-ui/check-tree-select": minor | ||
--- | ||
|
||
feat: 增加 tagInputProps API,支持显示内容高度自适应 |
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,6 @@ | ||
--- | ||
"@hi-ui/hiui": patch | ||
--- | ||
|
||
- CheckSelect CheckCascader CheckTreeSelect feat: 增加 tagInputProps API,支持显示内容高度自适应 | ||
- Popper TagInput fix: 优化 wrap 模式下代码 |
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,6 @@ | ||
--- | ||
"@hi-ui/popper": patch | ||
"@hi-ui/tag-input": patch | ||
--- | ||
|
||
优化 wrap 模式下代码 |
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
97 changes: 97 additions & 0 deletions
97
packages/ui/check-cascader/stories/tag-input-wrap.stories.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,97 @@ | ||
import React from 'react' | ||
import CheckCascader from '../src' | ||
|
||
/** | ||
* @title 换行展示选中内容 | ||
* @desc 设置后,选中内容超出宽度时会换行展示 | ||
*/ | ||
export const TagInputWrap = () => { | ||
const [dataOnlyLeafCheckable] = React.useState(() => { | ||
const data = [ | ||
{ | ||
id: '手机', | ||
title: '手机t', | ||
children: [ | ||
{ | ||
id: '小米', | ||
title: '小米t', | ||
children: [ | ||
{ | ||
id: '小米3', | ||
title: '小米3t', | ||
}, | ||
{ | ||
id: '小米4', | ||
title: '小米4t', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: '红米', | ||
title: '红米t', | ||
children: [ | ||
{ | ||
id: '红米3', | ||
title: '红米3t', | ||
}, | ||
{ | ||
id: '红米4', | ||
title: '红米4t', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
id: '电视', | ||
title: '电视t', | ||
children: [ | ||
{ | ||
id: '小米电视4A', | ||
title: '小米电视4At', | ||
}, | ||
{ | ||
id: '小米电视4C', | ||
title: '小米电视4Ct', | ||
}, | ||
], | ||
}, | ||
] | ||
|
||
const getDataOnlyLeafCheckable = (data: any) => { | ||
return data.map((item: any) => { | ||
if (item.children) { | ||
item.checkable = item.checkable ?? false | ||
item.children = getDataOnlyLeafCheckable(item.children) | ||
} | ||
|
||
return item | ||
}) | ||
} | ||
|
||
const dataOnlyLeafCheckable = getDataOnlyLeafCheckable(data) | ||
|
||
return dataOnlyLeafCheckable | ||
}) | ||
|
||
return ( | ||
<> | ||
<h1>换行展示选中内容</h1> | ||
<div className="cascader-tag-input-wrap__wrap"> | ||
<CheckCascader | ||
style={{ width: 240 }} | ||
searchable={false} | ||
// clearable | ||
placeholder="请选择品类" | ||
defaultValue={[['手机', '红米', '红米4']]} | ||
changeOnSelect | ||
data={dataOnlyLeafCheckable} | ||
onChange={console.log} | ||
tagInputProps={{ | ||
wrap: true, | ||
}} | ||
></CheckCascader> | ||
</div> | ||
</> | ||
) | ||
} |
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
41 changes: 41 additions & 0 deletions
41
packages/ui/check-select/stories/tag-input-wrap.stories.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,41 @@ | ||
import React from 'react' | ||
import CheckSelect from '../src' | ||
|
||
/** | ||
* @title 换行展示选中内容 | ||
* @desc 设置后,选中内容超出宽度时会换行展示 | ||
*/ | ||
export const TagInputWrap = () => { | ||
const [data] = React.useState([ | ||
{ title: '手机', id: '2' }, | ||
{ title: '小米2', id: '2-1' }, | ||
{ title: '小米3', id: '2-2' }, | ||
{ title: '小米4', id: '2-3' }, | ||
{ title: '小米5', id: '2-4' }, | ||
{ title: '电脑', id: '3' }, | ||
{ title: '笔记本', id: '4' }, | ||
{ | ||
title: '生活周边超长文案展示超长文案展示超长文案展示超长文案展示超长文案展示', | ||
id: '5', | ||
}, | ||
{ title: '其它', id: '6' }, | ||
]) | ||
|
||
return ( | ||
<> | ||
<h1>换行展示选中内容</h1> | ||
<div className="check-select-tag-input-wrap__wrap"> | ||
<CheckSelect | ||
style={{ width: 240 }} | ||
placeholder="请选择" | ||
searchable | ||
clearable | ||
data={data} | ||
tagInputProps={{ | ||
wrap: true, | ||
}} | ||
/> | ||
</div> | ||
</> | ||
) | ||
} |
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
105 changes: 105 additions & 0 deletions
105
packages/ui/check-tree-select/stories/tag-input-wrap.stories.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,105 @@ | ||
import React from 'react' | ||
import CheckTreeSelect from '../src' | ||
|
||
/** | ||
* @title 换行展示选中内容 | ||
* @desc 设置后,选中内容超出宽度时会换行展示 | ||
*/ | ||
export const TagInputWrap = () => { | ||
const [data] = React.useState([ | ||
{ | ||
title: '手机类', | ||
id: '0', | ||
children: [ | ||
{ | ||
title: 'Redmi系列', | ||
id: '0-0', | ||
disabled: true, | ||
children: [ | ||
{ | ||
id: '0-0-1', | ||
title: 'Redmi K30', | ||
}, | ||
{ | ||
id: '0-0-2', | ||
title: 'Redmi K30 Pro', | ||
}, | ||
{ | ||
id: '0-0-3', | ||
title: 'Redmi 10X 5G', | ||
}, | ||
{ | ||
id: '0-0-4', | ||
title: 'Redmi Note 8', | ||
}, | ||
{ | ||
id: '0-0-5', | ||
title: 'Redmi 9', | ||
}, | ||
{ | ||
id: '0-0-6', | ||
title: 'Redmi 9A', | ||
}, | ||
], | ||
}, | ||
{ | ||
title: '小米手机', | ||
id: '0-1', | ||
children: [ | ||
{ | ||
id: '0-1-1', | ||
title: '小米10 Pro', | ||
}, | ||
{ | ||
id: '0-1-2', | ||
title: '小米10', | ||
}, | ||
{ | ||
id: '0-1-3', | ||
title: '小米10 青春版 5G', | ||
}, | ||
{ | ||
id: '0-1-4', | ||
title: '小米MIX Alpha', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
title: '电视', | ||
id: '1', | ||
children: [ | ||
{ | ||
title: '小米电视 大师 65英寸OLED', | ||
id: '1-0', | ||
}, | ||
{ | ||
title: 'Redmi 智能电视 MAX 98', | ||
id: '1-1', | ||
}, | ||
{ | ||
title: '小米电视4A 60英寸', | ||
id: '1-2', | ||
}, | ||
], | ||
}, | ||
]) | ||
|
||
return ( | ||
<> | ||
<h1>换行展示选中内容</h1> | ||
<div className="check-tree-select-tag-input-wrap__wrap"> | ||
<CheckTreeSelect | ||
style={{ width: 240 }} | ||
data={data} | ||
checkedMode="PARENT" | ||
onChange={console.log} | ||
tagInputProps={{ | ||
wrap: true, | ||
}} | ||
/> | ||
</div> | ||
</> | ||
) | ||
} |
Oops, something went wrong.