Skip to content

Commit

Permalink
refactor(antd/next): rewrite PreviewText to JSXComponent (#1509)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuweiGL authored May 26, 2021
1 parent 5a85314 commit 3f6c34d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
32 changes: 21 additions & 11 deletions packages/antd/src/preview-text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,27 @@ const TimeRangePicker: React.FC<TimeRangePickerProps> = (props) => {
)
}

export const PreviewText = {
Input,
Select,
TreeSelect,
Cascader,
DatePicker,
DateRangePicker,
TimePicker,
TimeRangePicker,
Placeholder,
usePlaceholder,
const Text = (props: React.PropsWithChildren<any>) => {
const prefixCls = usePrefixCls('form-text', props)

return (
<div className={cls(prefixCls, props.className)} style={props.style}>
{usePlaceholder(props.value)}
</div>
)
}

Text.Input = Input
Text.Select = Select
Text.TreeSelect = TreeSelect
Text.Cascader = Cascader
Text.DatePicker = DatePicker
Text.DateRangePicker = DateRangePicker
Text.TimePicker = TimePicker
Text.TimeRangePicker = TimeRangePicker
Text.Placeholder = Placeholder
Text.usePlaceholder = usePlaceholder

export const PreviewText = Text

export default PreviewText
30 changes: 20 additions & 10 deletions packages/next/src/preview-text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,26 @@ const TimePicker: React.FC<TimePickerProps> = (props) => {
return <div className={cls(prefixCls, props.className)}>{getLabels()}</div>
}

export const PreviewText = {
Input,
Select,
TreeSelect,
Cascader,
DatePicker,
DateRangePicker,
TimePicker,
Placeholder,
usePlaceholder,
const Text = (props: React.PropsWithChildren<any>) => {
const prefixCls = usePrefixCls('form-text', props)

return (
<div className={cls(prefixCls, props.className)} style={props.style}>
{usePlaceholder(props.value)}
</div>
)
}

Text.Input = Input
Text.Select = Select
Text.TreeSelect = TreeSelect
Text.Cascader = Cascader
Text.DatePicker = DatePicker
Text.DateRangePicker = DateRangePicker
Text.TimePicker = TimePicker
Text.Placeholder = Placeholder
Text.usePlaceholder = usePlaceholder

export const PreviewText = Text

export default PreviewText

0 comments on commit 3f6c34d

Please sign in to comment.