Skip to content

Commit

Permalink
Merge pull request #2604 from XiaoMi/feature/check-tree-select(add-si…
Browse files Browse the repository at this point in the history
…ze-api)

Feature/check tree select(add size api)
  • Loading branch information
solarjoker authored Sep 22, 2023
2 parents 3e105a5 + 3acef9f commit 5777a20
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/real-masks-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/check-tree-select": minor
---

feat: add size api
5 changes: 5 additions & 0 deletions .changeset/wise-teachers-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

CheckTreeSelect feat: add size api
9 changes: 8 additions & 1 deletion packages/ui/check-tree-select/src/CheckTreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { uniqBy } from '@hi-ui/array-utils'
import { Highlighter } from '@hi-ui/highlighter'
import { TagInputMock, TagInputMockProps } from '@hi-ui/tag-input'
import { UpOutlined, DownOutlined } from '@hi-ui/icons'
import { useLocaleContext } from '@hi-ui/core'
import { HiBaseSizeEnum, useLocaleContext } from '@hi-ui/core'
import { callAllFuncs } from '@hi-ui/func-utils'
import Checkbox from '@hi-ui/checkbox'
// import { UseDataSource } from '@hi-ui/use-data-source'
Expand Down Expand Up @@ -89,6 +89,7 @@ export const CheckTreeSelect = forwardRef<HTMLDivElement | null, CheckTreeSelect
height,
showCheckAll,
tagInputProps,
size = 'md',
...rest
},
ref
Expand Down Expand Up @@ -345,6 +346,7 @@ export const CheckTreeSelect = forwardRef<HTMLDivElement | null, CheckTreeSelect
trigger={
<TagInputMock
{...tagInputProps}
size={size}
// ref={targetElementRef}
// onClick={openMenu}
// disabled={disabled}
Expand All @@ -370,6 +372,7 @@ export const CheckTreeSelect = forwardRef<HTMLDivElement | null, CheckTreeSelect
{isArrayNonEmpty(treeProps.data) ? (
// 只做渲染,不做逻辑处理(比如搜索过滤后,check操作的是对过滤后的data操作,这是不符合预期的)
<Tree
size={'md'}
className={`${prefixCls}__tree`}
selectable={false}
checkable
Expand Down Expand Up @@ -531,6 +534,10 @@ export interface CheckTreeSelectProps
* TagInput 参数设置
*/
tagInputProps?: TagInputMockProps
/**
* 设置尺寸
*/
size?: HiBaseSizeEnum
}

if (__DEV__) {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/check-tree-select/stories/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './controlled.stories'
export * from './uncontrolled.stories'
export * from './tag-input-wrap.stories'
export * from './appearance.stories'
export * from './size.stories'
export * from './clearable.stories'
export * from './searchable.stories'
// export * from './field-names.stories'
Expand Down
119 changes: 119 additions & 0 deletions packages/ui/check-tree-select/stories/size.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import React from 'react'
import CheckTreeSelect from '../src'

/**
* @title 不同尺寸
*/
export const Size = () => {
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>Size</h1>
<div className="check-tree-select-size__wrap">
<h2>sm</h2>
<CheckTreeSelect
style={{ width: 240 }}
size="sm"
data={data}
checkedMode="PARENT"
onChange={console.log}
/>
<h2>md</h2>
<CheckTreeSelect
style={{ width: 240 }}
size="md"
data={data}
checkedMode="PARENT"
onChange={console.log}
/>
<h2>lg</h2>
<CheckTreeSelect
style={{ width: 240 }}
size="lg"
data={data}
checkedMode="PARENT"
onChange={console.log}
/>
</div>
</>
)
}

0 comments on commit 5777a20

Please sign in to comment.