Skip to content

Commit

Permalink
Merge branch 'master' into feature/cascader(#2594)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyprepare authored Sep 25, 2023
2 parents 90ea1ea + fbe2939 commit 41056f0
Show file tree
Hide file tree
Showing 34 changed files with 666 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-snails-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/select": minor
---

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

Select feat: add size api
5 changes: 5 additions & 0 deletions .changeset/funny-waves-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/check-select": minor
---

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

CheckCascader feat: add size api
5 changes: 5 additions & 0 deletions .changeset/metal-fireants-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/check-cascader": minor
---

feat: add size api
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/ninety-seals-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

CheckSelect feat: add size api
5 changes: 5 additions & 0 deletions .changeset/proud-turkeys-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/cascader": minor
---

feat: add size api
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/spotty-tools-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

Cascader 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
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
8 changes: 7 additions & 1 deletion packages/ui/cascader/src/Cascader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { forwardRef, useState, useMemo, useEffect } from 'react'
import type { HiBaseAppearanceEnum } from '@hi-ui/core'
import type { HiBaseAppearanceEnum, HiBaseSizeEnum } from '@hi-ui/core'
import { cx, getPrefixCls } from '@hi-ui/classname'
import { __DEV__ } from '@hi-ui/env'
import { useUncontrolledToggle } from '@hi-ui/use-toggle'
Expand Down Expand Up @@ -52,6 +52,7 @@ export const Cascader = forwardRef<HTMLDivElement | null, CascaderProps>((props,
data = NOOP_ARRAY,
flattedSearchResult = true,
visible,
size = 'md',
onOpen,
onClose,
renderExtraFooter,
Expand Down Expand Up @@ -230,6 +231,7 @@ export const Cascader = forwardRef<HTMLDivElement | null, CascaderProps>((props,
onSearch={callAllFuncs(onSearchProp, onSearch)}
trigger={
<MockInput
size={size}
clearable={clearable}
placeholder={placeholder}
displayRender={displayRender as any}
Expand Down Expand Up @@ -320,6 +322,10 @@ export interface CascaderProps
* 自定义下拉菜单每列渲染
*/
dropdownColumnRender?: (menu: React.ReactElement, level: number) => React.ReactNode
/**
* 设置尺寸
*/
size?: HiBaseSizeEnum
}

if (__DEV__) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/cascader/src/styles/cascader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ $prefix: '#{$component-prefix}-cascader' !default;

&-item {
width: 100%;
padding: use-spacing(2) 0;
padding: use-spacing(1) 0;
position: relative;
cursor: pointer;
display: flex;
Expand All @@ -90,7 +90,7 @@ $prefix: '#{$component-prefix}-cascader' !default;
&-option {
padding: 0 use-spacing(4);
box-sizing: border-box;
height: 32px;
height: use-height-size(7);
width: 100%;
display: flex;
align-items: center;
Expand Down
1 change: 1 addition & 0 deletions packages/ui/cascader/stories/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import Cascader from '../src'

export * from './basic.stories'
export * from './size.stories'
export * from './disabled.stories'
export * from './search.stories'
export * from './filter-options.stories'
Expand Down
102 changes: 102 additions & 0 deletions packages/ui/cascader/stories/size.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React from 'react'
import Cascader from '../src'

/**
* @title 不同尺寸
*/
export const Size = () => {
const [data] = React.useState([
{
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',
},
],
},
])

return (
<>
<h1>Size</h1>
<div className="cascader-size__wrap">
<h2>sm</h2>
<Cascader
style={{ width: 240 }}
size="sm"
clearable
placeholder="请选择品类"
defaultValue={['手机', '红米', '红米4']}
data={data}
onChange={(...args) => {
console.log('onChange', ...args)
}}
></Cascader>
<h2>md</h2>
<Cascader
style={{ width: 240 }}
size="md"
clearable
placeholder="请选择品类"
defaultValue={['手机', '红米', '红米4']}
data={data}
onChange={(...args) => {
console.log('onChange', ...args)
}}
></Cascader>
<h2>lg</h2>
<Cascader
style={{ width: 240 }}
size="lg"
clearable
placeholder="请选择品类"
defaultValue={['手机', '红米', '红米4']}
data={data}
onChange={(...args) => {
console.log('onChange', ...args)
}}
></Cascader>
</div>
</>
)
}
8 changes: 7 additions & 1 deletion packages/ui/check-cascader/src/CheckCascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { flattenTreeData } from './utils'
import { getNodeAncestorsWithMe, getTopDownAncestors } from '@hi-ui/tree-utils'
import { useLatestCallback } from '@hi-ui/use-latest'
import { isArrayNonEmpty, isUndef } from '@hi-ui/type-assertion'
import { HiBaseAppearanceEnum, useLocaleContext } from '@hi-ui/core'
import { HiBaseAppearanceEnum, HiBaseSizeEnum, useLocaleContext } from '@hi-ui/core'

import { callAllFuncs } from '@hi-ui/func-utils'

Expand Down Expand Up @@ -69,6 +69,7 @@ export const CheckCascader = forwardRef<HTMLDivElement | null, CheckCascaderProp
onOpen,
onClose,
tagInputProps,
size = 'md',
...rest
},
ref
Expand Down Expand Up @@ -225,6 +226,7 @@ export const CheckCascader = forwardRef<HTMLDivElement | null, CheckCascaderProp
trigger={
<TagInputMock
{...tagInputProps}
size={size}
clearable={clearable}
placeholder={placeholder}
// @ts-ignore
Expand Down Expand Up @@ -369,6 +371,10 @@ export interface CheckCascaderProps extends Omit<PickerProps, 'trigger' | 'scrol
* TagInput 参数设置
*/
tagInputProps?: TagInputMockProps
/**
* 设置尺寸
*/
size?: HiBaseSizeEnum
}

if (__DEV__) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/check-cascader/src/styles/check-cascader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ $prefix: '#{$component-prefix}-check-cascader' !default;

&-item {
width: 100%;
padding: use-spacing(2) 0;
padding: use-spacing(1) 0;
position: relative;
cursor: pointer;
display: flex;
Expand All @@ -109,7 +109,7 @@ $prefix: '#{$component-prefix}-check-cascader' !default;
&-option {
padding: 0 use-spacing(4);
box-sizing: border-box;
height: 32px;
height: use-height-size(7);
width: 100%;
display: flex;
align-items: center;
Expand Down
1 change: 1 addition & 0 deletions packages/ui/check-cascader/stories/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import CheckCascader from '../src'

export * from './basic.stories'
export * from './tag-input-wrap.stories'
export * from './size.stories'
export * from './disabled.stories'
export * from './search.stories'
export * from './select-change.stories'
Expand Down
Loading

0 comments on commit 41056f0

Please sign in to comment.