Merge pull request #86 from unix/default-props

fix(union-type): fix union type overridden by default-props type
This commit is contained in:
witt
2020-04-11 20:56:12 +08:00
committed by GitHub
16 changed files with 36 additions and 29 deletions

View File

@@ -11,7 +11,7 @@ interface Props {
const defaultProps = {
span: 24,
offset: 0,
component: 'div' as 'div',
component: 'div' as keyof JSX.IntrinsicElements,
className: '',
}

View File

@@ -9,8 +9,8 @@ interface Props {
}
const defaultProps = {
title: 'Title',
content: '',
title: 'Title' as ReactNode | string,
content: '' as ReactNode | string,
className: '',
}

View File

@@ -10,7 +10,7 @@ interface Props {
}
const defaultProps = {
caption: '',
caption: '' as ReactNode | string,
shadow: false,
className: '',
}

View File

@@ -20,8 +20,8 @@ const defaultProps = {
value: '',
label: '',
disabled: false,
title: '',
subtitle: '',
title: '' as string | ReactNode,
subtitle: '' as string | ReactNode,
className: '',
}

View File

@@ -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: '',

View File

@@ -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>

View File

@@ -14,7 +14,7 @@ interface Props {
const defaultProps = {
type: 'default' as NormalTypes,
label: 'note',
label: 'note' as string | boolean,
small: false,
filled: false,
className: '',

View File

@@ -5,7 +5,6 @@ import withDefaults from '../utils/with-defaults'
interface Props {
line?: boolean
title?: boolean
}
const defaultProps = {

View File

@@ -13,7 +13,7 @@ interface Props {
const defaultProps = {
trigger: 'click' as TriggerTypes,
placement: 'bottom',
placement: 'bottom' as Placement,
}
type ExcludeTooltipProps = {

View File

@@ -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: '',
}

View File

@@ -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: '',
}

View File

@@ -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: '',
}

View File

@@ -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>

View File

@@ -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

View File

@@ -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` | - | - |

View File

@@ -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` | - | - |