Skip to content

Commit

Permalink
Update react-sizeme.d.ts (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
NNNaix authored and ctrlplusb committed Oct 11, 2019
1 parent 56cf111 commit 62e9c91
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions react-sizeme.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,40 @@

import { Component, ComponentType, ReactNode, ReactElement } from 'react'

type Omit<T, K> = Pick<T, Exclude<keyof T, K>>
declare namespace sizeMe {
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>

export interface SizeMeProps {
size: {
width: number | null
height: number | null
export interface SizeMeProps {
size: {
width: number | null
height: number | null
}
}
}

export interface SizeMeOptions {
monitorWidth?: boolean
monitorHeight?: boolean
monitorPosition?: boolean
refreshRate?: number
refreshMode?: 'throttle' | 'debounce'
noPlaceholder?: boolean
}

export interface SizeMeRenderProps extends SizeMeOptions {
children: (props: SizeMeProps) => ReactElement
}
export interface SizeMeOptions {
monitorWidth?: boolean
monitorHeight?: boolean
monitorPosition?: boolean
refreshRate?: number
refreshMode?: 'throttle' | 'debounce'
noPlaceholder?: boolean
}

export class SizeMe extends Component<SizeMeRenderProps> {}
export interface SizeMeRenderProps extends SizeMeOptions {
children: (props: SizeMeProps) => ReactElement
}
export class SizeMe extends Component<SizeMeRenderProps> {}

export const withSize: (
options?: SizeMeOptions,
) => <P extends object = {}>(
export const withSize: (
options?: SizeMeOptions,
) => <P extends object = {}>(
component: ComponentType<P>,
) => ComponentType<Omit<P, 'size'>>
}
declare function sizeMe(
options?: sizeMe.SizeMeOptions,
): <P extends object = {}>(
component: ComponentType<P>,
) => ComponentType<Omit<P, 'size'>>
) => ComponentType<sizeMe.Omit<P, 'size'>>

export = sizeMe

0 comments on commit 62e9c91

Please sign in to comment.