mirror of
https://github.com/zhigang1992/react.git
synced 2026-02-10 17:13:54 +08:00
21 lines
588 B
TypeScript
21 lines
588 B
TypeScript
import React, { MutableRefObject } from 'react'
|
|
import { NormalSizes } from '../utils/prop-types'
|
|
|
|
export interface AutoCompleteConfig {
|
|
value?: string
|
|
updateValue?: Function
|
|
visible?: boolean
|
|
updateVisible?: Function
|
|
size?: NormalSizes
|
|
ref?: MutableRefObject<HTMLElement | null>
|
|
}
|
|
|
|
const defaultContext = {
|
|
visible: false,
|
|
size: 'medium' as NormalSizes,
|
|
}
|
|
|
|
export const AutoCompleteContext = React.createContext<AutoCompleteConfig>(defaultContext)
|
|
|
|
export const useAutoCompleteContext = (): AutoCompleteConfig => React.useContext<AutoCompleteConfig>(AutoCompleteContext)
|