Skip to content

Commit

Permalink
refactor: decoupling
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Apr 23, 2024
1 parent 48fdd9f commit beded34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
10 changes: 4 additions & 6 deletions src/components/dropdown/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ export type DropdownItemProps = {

const Item: FC<DropdownItemProps> = props => {
const { dropdown: componentConfig = {} } = useConfig()
const { active, arrowIcon, arrow, highlight, onClick, title } = mergeProps(
componentConfig,
props
)
const mergedProps = mergeProps(componentConfig, props)
const { active, highlight, onClick, title } = mergedProps
const cls = classNames(classPrefix, {
[`${classPrefix}-active`]: active,
[`${classPrefix}-highlight`]: highlight ?? active,
Expand All @@ -41,8 +39,8 @@ const Item: FC<DropdownItemProps> = props => {
const mergedArrowIcon = mergeProp(
<DownFill />,
contextArrowIcon,
arrow,
arrowIcon
mergedProps.arrow,
mergedProps.arrowIcon
)

return withNativeProps(
Expand Down
15 changes: 6 additions & 9 deletions src/components/form/form-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ type FormItemLayoutProps = Pick<
| 'layout'
| 'extra'
| 'clickable'
| 'arrowIcon'
| 'arrow'
| 'arrowIcon'
| 'description'
| 'childElementPosition'
> & {
Expand All @@ -98,10 +98,6 @@ type FormItemLayoutProps = Pick<
children: ReactNode
} & NativeProps

const defaultProps = {
helpIcon: <QuestionCircleOutline />,
}

const FormItemLayout: FC<FormItemLayoutProps> = props => {
const { locale, form: componentConfig = {} } = useConfig()

Expand All @@ -115,10 +111,10 @@ const FormItemLayout: FC<FormItemLayoutProps> = props => {
children,
htmlFor,
hidden,
arrowIcon,
arrow,
arrowIcon,
childElementPosition = 'normal',
} = mergeProps(defaultProps, componentConfig, props)
} = mergeProps(componentConfig, props)

const context = useContext(FormContext)

Expand Down Expand Up @@ -172,7 +168,7 @@ const FormItemLayout: FC<FormItemLayoutProps> = props => {
e.preventDefault()
}}
>
{helpIcon}
{helpIcon || <QuestionCircleOutline />}
</span>
</Popover>
)}
Expand Down Expand Up @@ -353,7 +349,8 @@ export const FormItem: FC<FormItemProps> = props => {
layout={layout}
childElementPosition={childElementPosition}
clickable={clickable}
arrowIcon={arrowIcon || arrow}
arrow={arrow}
arrowIcon={arrowIcon}
>
<NoStyleItemContext.Provider value={onSubMetaChange}>
{baseChildren}
Expand Down

0 comments on commit beded34

Please sign in to comment.