Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 147
feat: support dropdownStyle and merge dropdownMenuColumnStyle to styles prop#413
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
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import type { BuildInPlacements } from '@rc-component/trigger/lib/interface'; | ||
| import type { BaseSelectProps,BaseSelectPropsWithoutPrivate,BaseSelectRef } from 'rc-select'; | ||
| import type { BaseSelectProps,BaseSelectPropsWithoutPrivate,BaseSelectRef } from 'rc-select'; | ||
| import { BaseSelect } from 'rc-select'; | ||
| import type { DisplayValueType,Placement } from 'rc-select/lib/BaseSelect'; | ||
| import type { DisplayValueType,Placement } from 'rc-select/lib/BaseSelect'; | ||
| import useId from 'rc-select/lib/hooks/useId'; | ||
| import { conductCheck } from 'rc-tree/lib/utils/conductUtil'; | ||
| import useMergedState from 'rc-util/lib/hooks/useMergedState'; | ||
| @@ -14,9 +14,9 @@ import useRefFunc from './hooks/useRefFunc'; | ||
| import useSearchConfig from './hooks/useSearchConfig'; | ||
| import useSearchOptions from './hooks/useSearchOptions'; | ||
| import OptionList from './OptionList'; | ||
| import { fillFieldNames,SHOW_CHILD,SHOW_PARENT,toPathKey,toPathKeys } from './utils/commonUtil'; | ||
| import { formatStrategyValues,toPathOptions } from './utils/treeUtil'; | ||
| import warningProps,{ warningNullOptions } from './utils/warningPropsUtil'; | ||
| import { fillFieldNames,SHOW_CHILD,SHOW_PARENT,toPathKey,toPathKeys } from './utils/commonUtil'; | ||
| import { formatStrategyValues,toPathOptions } from './utils/treeUtil'; | ||
| import warningProps,{ warningNullOptions } from './utils/warningPropsUtil'; | ||
| export interface ShowSearchType<OptionType extends BaseOptionType = DefaultOptionType> { | ||
| filter?: (inputValue: string, options: OptionType[], fieldNames: FieldNames) => boolean; | ||
| @@ -57,7 +57,7 @@ export interface DefaultOptionType extends BaseOptionType { | ||
| disableCheckbox?: boolean; | ||
| } | ||
| interface BaseCascaderProps<OptionType extends BaseOptionType = DefaultOptionType> | ||
| export interface BaseCascaderProps<OptionType extends BaseOptionType = DefaultOptionType> | ||
| extends Omit< | ||
| BaseSelectPropsWithoutPrivate, | ||
| 'tokenSeparators' | 'labelInValue' | 'mode' | 'showSearch' | ||
| @@ -97,8 +97,15 @@ interface BaseCascaderProps<OptionType extends BaseOptionType = DefaultOptionTyp | ||
| /** @deprecated Use `dropdownClassName` instead */ | ||
| popupClassName?: string; | ||
| dropdownClassName?: string; | ||
| /** @deprecated Use `styles.popupColumn` instead */ | ||
| dropdownMenuColumnStyle?: React.CSSProperties; | ||
| // styles | ||
| styles?: { | ||
| popup?: React.CSSProperties; | ||
| popupColumn?: React.CSSProperties; | ||
| }; | ||
| /** @deprecated Use `placement` instead */ | ||
| popupPlacement?: Placement; | ||
| placement?: Placement; | ||
| @@ -197,8 +204,11 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | ||
| popupVisible, | ||
| open, | ||
| styles, | ||
| popupClassName, | ||
| dropdownClassName, | ||
| dropdownStyle, | ||
| dropdownMenuColumnStyle, | ||
| popupPlacement, | ||
| @@ -448,7 +458,7 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | ||
| expandTrigger, | ||
| expandIcon, | ||
| loadingIcon, | ||
| dropdownMenuColumnStyle, | ||
| dropdownMenuColumnStyle: styles?.popupColumn ?? dropdownMenuColumnStyle, | ||
| }), | ||
| [ | ||
| mergedOptions, | ||
| @@ -465,6 +475,7 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | ||
| expandIcon, | ||
| loadingIcon, | ||
| dropdownMenuColumnStyle, | ||
| styles?.popupColumn, | ||
| ], | ||
| ); | ||
| @@ -473,14 +484,21 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | ||
| // ============================================================== | ||
| const emptyOptions = !(mergedSearchValue ? searchOptions : mergedOptions).length; | ||
| const dropdownStyle: React.CSSProperties = | ||
| const mergedDropdownStyle: React.CSSProperties = | ||
| // Search to match width | ||
| (mergedSearchValue && searchConfig.matchInputWidth) || | ||
| // Empty keep the width | ||
| styles?.popup ?? | ||
| dropdownStyle ?? | ||
| (mergedSearchValue && searchConfig.matchInputWidth) ?? | ||
| emptyOptions | ||
| ? {} | ||
| ? // Empty keep the width | ||
| { | ||
| ...styles?.popup, | ||
| ...dropdownStyle, | ||
| } | ||
| : { | ||
| minWidth: 'auto', | ||
BoyYangzai marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ...styles?.popup, | ||
| ...dropdownStyle, | ||
| }; | ||
| return ( | ||
| @@ -492,7 +510,7 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | ||
| id={mergedId} | ||
| prefixCls={prefixCls} | ||
| dropdownMatchSelectWidth={dropdownMatchSelectWidth} | ||
| dropdownStyle={dropdownStyle} | ||
| dropdownStyle={mergedDropdownStyle} | ||
| // Value | ||
| displayValues={displayValues} | ||
| onDisplayValuesChange={onDisplayValuesChange} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| import warning from 'rc-util/lib/warning'; | ||
| import type { DefaultOptionType, FieldNames, InternalCascaderProps } from '../Cascader'; | ||
| import type { DefaultOptionType, FieldNames, BaseCascaderProps } from '../Cascader'; | ||
| function warningProps(props: InternalCascaderProps) { | ||
| const { onPopupVisibleChange, popupVisible, popupClassName, popupPlacement} = props; | ||
| function warningProps(props: BaseCascaderProps) { | ||
| const { onPopupVisibleChange, popupVisible, popupClassName, popupPlacement,dropdownMenuColumnStyle} = props; | ||
| warning( | ||
| !onPopupVisibleChange, | ||
| @@ -17,6 +17,10 @@ function warningProps(props: InternalCascaderProps) { | ||
| popupPlacement === undefined, | ||
| '`popupPlacement` is deprecated. Please use `placement` instead.', | ||
| ); | ||
| warning( | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 上面还有 popupXX 废弃请用 dropdown 的wanring 也需要清理掉 | ||
| dropdownMenuColumnStyle === undefined, | ||
| '`dropdownMenuColumnStyle` is deprecated. Please use `styles.popupColumn` instead.', | ||
| ); | ||
| } | ||
| // value in Cascader options should not be null | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
上面的
popupClassNamedropdownClassName备注也更新一下~