mirror of
https://github.com/zhigang1992/react.git
synced 2026-03-26 22:42:51 +08:00
Merge pull request #86 from unix/default-props
fix(union-type): fix union type overridden by default-props type
This commit is contained in:
@@ -11,7 +11,7 @@ interface Props {
|
||||
const defaultProps = {
|
||||
span: 24,
|
||||
offset: 0,
|
||||
component: 'div' as 'div',
|
||||
component: 'div' as keyof JSX.IntrinsicElements,
|
||||
className: '',
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ interface Props {
|
||||
}
|
||||
|
||||
const defaultProps = {
|
||||
title: 'Title',
|
||||
content: '',
|
||||
title: 'Title' as ReactNode | string,
|
||||
content: '' as ReactNode | string,
|
||||
className: '',
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ interface Props {
|
||||
}
|
||||
|
||||
const defaultProps = {
|
||||
caption: '',
|
||||
caption: '' as ReactNode | string,
|
||||
shadow: false,
|
||||
className: '',
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ const defaultProps = {
|
||||
value: '',
|
||||
label: '',
|
||||
disabled: false,
|
||||
title: '',
|
||||
subtitle: '',
|
||||
title: '' as string | ReactNode,
|
||||
subtitle: '' as string | ReactNode,
|
||||
className: '',
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ const defaultProps = {
|
||||
readOnly: false,
|
||||
clearable: false,
|
||||
width: 'initial',
|
||||
size: 'medium',
|
||||
status: 'default',
|
||||
size: 'medium' as NormalSizes,
|
||||
status: 'default' as NormalTypes,
|
||||
autoComplete: 'off',
|
||||
className: '',
|
||||
placeholder: '',
|
||||
|
||||
@@ -18,7 +18,9 @@ const defaultProps = {
|
||||
className: '',
|
||||
passive: false,
|
||||
disabled: false,
|
||||
onClick: (event: ModalActionEvent) => event.close && event.close(),
|
||||
onClick: ((event: ModalActionEvent) => {
|
||||
event.close && event.close()
|
||||
}) as (event: ModalActionEvent) => void,
|
||||
}
|
||||
|
||||
type NativeAttrs = Omit<React.ButtonHTMLAttributes<any>, keyof Props>
|
||||
|
||||
@@ -14,7 +14,7 @@ interface Props {
|
||||
|
||||
const defaultProps = {
|
||||
type: 'default' as NormalTypes,
|
||||
label: 'note',
|
||||
label: 'note' as string | boolean,
|
||||
small: false,
|
||||
filled: false,
|
||||
className: '',
|
||||
|
||||
@@ -5,7 +5,6 @@ import withDefaults from '../utils/with-defaults'
|
||||
interface Props {
|
||||
line?: boolean
|
||||
title?: boolean
|
||||
|
||||
}
|
||||
|
||||
const defaultProps = {
|
||||
|
||||
@@ -13,7 +13,7 @@ interface Props {
|
||||
|
||||
const defaultProps = {
|
||||
trigger: 'click' as TriggerTypes,
|
||||
placement: 'bottom',
|
||||
placement: 'bottom' as Placement,
|
||||
}
|
||||
|
||||
type ExcludeTooltipProps = {
|
||||
|
||||
@@ -15,9 +15,9 @@ interface Props {
|
||||
|
||||
const defaultProps = {
|
||||
gap: 0,
|
||||
justify: 'start' as 'start',
|
||||
align: 'top' as 'top',
|
||||
component: 'div' as 'div',
|
||||
justify: 'start' as Justify,
|
||||
align: 'top' as Align,
|
||||
component: 'div' as keyof JSX.IntrinsicElements,
|
||||
className: '',
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ interface Props {
|
||||
value?: string
|
||||
initialValue?: string
|
||||
placeholder?: React.ReactNode | string
|
||||
icon?: React.ReactNode
|
||||
icon?: React.ComponentType
|
||||
onChange?: (value: string) => void
|
||||
pure?: boolean
|
||||
className?: string
|
||||
@@ -24,7 +24,7 @@ interface Props {
|
||||
const defaultProps = {
|
||||
disabled: false,
|
||||
size: 'medium' as NormalSizes,
|
||||
icon: SelectIcon,
|
||||
icon: SelectIcon as React.ComponentType,
|
||||
pure: false,
|
||||
className: '',
|
||||
}
|
||||
|
||||
@@ -7,22 +7,26 @@ import useResize from '../utils/use-resize'
|
||||
import { TableContext, TableColumnItem, TableConfig } from './table-context'
|
||||
import useCurrentState from '../utils/use-current-state'
|
||||
|
||||
export type TableOnRow = (row: any, index: number) => void
|
||||
export type TableOnCell = (cell: any, index: number, colunm: number) => void
|
||||
export type TableOnChange = (data: any) => void
|
||||
|
||||
interface Props {
|
||||
data?: Array<any>
|
||||
emptyText?: string
|
||||
hover?: boolean
|
||||
onRow: (row: any, index: number) => void
|
||||
onCell: (cell: any, index: number, colunm: number) => void
|
||||
onChange: (data: any) => void
|
||||
onRow: TableOnRow
|
||||
onCell: TableOnCell
|
||||
onChange: TableOnChange
|
||||
className?: string
|
||||
}
|
||||
|
||||
const defaultProps = {
|
||||
hover: true,
|
||||
emptyText: '',
|
||||
onRow: () => {},
|
||||
onCell: () => {},
|
||||
onChange: () => {},
|
||||
onRow: (() => {}) as TableOnRow,
|
||||
onCell: (() => {}) as TableOnCell,
|
||||
onChange: (() => {}) as TableOnChange,
|
||||
className: '',
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import TooltipContent from './tooltip-content'
|
||||
import useClickAway from '../utils/use-click-away'
|
||||
import { TriggerTypes, Placement, SnippetTypes } from '../utils/prop-types'
|
||||
|
||||
export type TooltipOnVisibleChange = (visible: boolean) => void
|
||||
|
||||
interface Props {
|
||||
text: string | React.ReactNode
|
||||
type?: SnippetTypes
|
||||
@@ -17,7 +19,7 @@ interface Props {
|
||||
offset?: number
|
||||
className?: string
|
||||
portalClassName?: string
|
||||
onVisibleChange?: (visible: boolean) => void
|
||||
onVisibleChange?: TooltipOnVisibleChange
|
||||
}
|
||||
|
||||
const defaultProps = {
|
||||
@@ -25,13 +27,13 @@ const defaultProps = {
|
||||
hideArrow: false,
|
||||
type: 'default' as SnippetTypes,
|
||||
trigger: 'hover' as TriggerTypes,
|
||||
placement: 'top',
|
||||
placement: 'top' as Placement,
|
||||
enterDelay: 100,
|
||||
leaveDelay: 0,
|
||||
offset: 12,
|
||||
className: '',
|
||||
portalClassName: '',
|
||||
onVisibleChange: () => {},
|
||||
onVisibleChange: (() => {}) as TooltipOnVisibleChange,
|
||||
}
|
||||
|
||||
type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>
|
||||
|
||||
@@ -7,7 +7,7 @@ const withDefaults = <P, DP>(
|
||||
type Props = Partial<DP> & Omit<P, keyof DP>
|
||||
component.defaultProps = defaultProps
|
||||
|
||||
return (component as React.ComponentType<any>) as React.ComponentType<Props>
|
||||
return component as React.ComponentType<Props>
|
||||
}
|
||||
|
||||
export default withDefaults
|
||||
|
||||
@@ -79,7 +79,7 @@ Display a dropdown list of items.
|
||||
| **initialValue** | initial value | `string` | - | - |
|
||||
| **placeholder** | placeholder string | `string` | - | - |
|
||||
| **size** | select component size | `NormalSizes` | `'mini', 'small', 'medium', 'large'` | `medium` |
|
||||
| **icon** | icon component | `ReactNode` | - | `SVG Component` |
|
||||
| **icon** | icon component | `ComponentType` | - | `SVG Component` |
|
||||
| **pure** | remove icon component | `boolean` | - | `false` |
|
||||
| **disabled** | disable current radio | `boolean` | - | `false` |
|
||||
| **onChange** | selected value | `(val: string) => void` | - | - |
|
||||
|
||||
@@ -78,7 +78,7 @@ export const meta = {
|
||||
| **initialValue** | 选择器初始值 | `string` | - | - |
|
||||
| **placeholder** | 占位文本内容 | `string` | - | - |
|
||||
| **size** | 选择器组件大小 | `NormalSizes` | `'mini', 'small', 'medium', 'large'` | `medium` |
|
||||
| **icon** | 右侧图标组件 | `ReactNode` | - | `SVG Component` |
|
||||
| **icon** | 右侧图标组件 | `ComponentType` | - | `SVG Component` |
|
||||
| **pure** | 隐藏右侧图标组件 | `boolean` | - | `false` |
|
||||
| **disabled** | 禁用所有的交互 | `boolean` | - | `false` |
|
||||
| **onChange** | 选项被选中所触发的事件 | `(val: string) => void` | - | - |
|
||||
|
||||
Reference in New Issue
Block a user