Skip to content
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

Feature/tree select(add size api) #2603

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nasty-geckos-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/tree-select": minor
---

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

TreeSelect feat: add size api
9 changes: 8 additions & 1 deletion packages/ui/tree-select/src/TreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { uniqBy } from '@hi-ui/array-utils'
import { Highlighter } from '@hi-ui/highlighter'
import { MockInput } from '@hi-ui/input'
import { DownOutlined, UpOutlined } from '@hi-ui/icons'
import { HiBaseAppearanceEnum, useLocaleContext } from '@hi-ui/core'
import { HiBaseAppearanceEnum, HiBaseSizeEnum, useLocaleContext } from '@hi-ui/core'

import { callAllFuncs } from '@hi-ui/func-utils'
import { UseDataSource } from '@hi-ui/use-data-source'
Expand Down Expand Up @@ -74,6 +74,7 @@ export const TreeSelect = forwardRef<HTMLDivElement | null, TreeSelectProps>(
virtual,
itemHeight,
height,
size = 'md',
...rest
},
ref
Expand Down Expand Up @@ -245,6 +246,7 @@ export const TreeSelect = forwardRef<HTMLDivElement | null, TreeSelectProps>(
trigger={
<MockInput
// disabled={disabled}
size={size}
clearable={clearable}
placeholder={placeholder}
displayRender={displayRenderProp}
Expand All @@ -261,6 +263,7 @@ export const TreeSelect = forwardRef<HTMLDivElement | null, TreeSelectProps>(
>
{isArrayNonEmpty(treeProps.data) ? (
<Tree
size={'md'}
className={`${prefixCls}__tree`}
selectable
selectedId={value}
Expand Down Expand Up @@ -393,6 +396,10 @@ export interface TreeSelectProps
* 设置 `true` 开启虚拟滚动
*/
virtual?: boolean
/**
* 设置尺寸
*/
size?: HiBaseSizeEnum
}

if (__DEV__) {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/tree-select/stories/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from './basic.stories'
export * from './controlled.stories'
export * from './uncontrolled.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/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 TreeSelect from '../src'

/**
* @title 不同尺寸
*/
export const Size = () => {
const [data] = React.useState([
{
title: '手机类',
id: '0',
disabled: true,
children: [
{
title: 'Redmi系列',
id: '0-0',
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="tree-select-size__wrap">
<h2>sm</h2>
<TreeSelect
size="sm"
data={data}
onChange={(checkedIds, selectItem) => {
console.log('TreeSelect onChange: ', checkedIds, selectItem)
}}
/>
<h2>md</h2>
<TreeSelect
size="md"
data={data}
onChange={(checkedIds, selectItem) => {
console.log('TreeSelect onChange: ', checkedIds, selectItem)
}}
/>
<h2>lg</h2>
<TreeSelect
size="lg"
data={data}
onChange={(checkedIds, selectItem) => {
console.log('TreeSelect onChange: ', checkedIds, selectItem)
}}
/>
</div>
</>
)
}