mirror of
https://github.com/zhigang1992/react.git
synced 2026-06-13 01:18:48 +08:00
* docs: add link to GH discussions * chore: upgrade deps * chore: update code style for prettier * chore: release v2.1.0-canary.3 * chore(deps): upgrade babel * chore: replace enzyme adapter with community repo to fit react.17 * test: updatee snapshots for auto typesetting * test(config): ignore unexported parts of the tools
24 lines
650 B
TypeScript
24 lines
650 B
TypeScript
import React, { MutableRefObject } from 'react'
|
|
import { NormalSizes } from '../utils/prop-types'
|
|
|
|
export interface SelectConfig {
|
|
value?: string | string[]
|
|
updateValue?: (next: string | undefined) => unknown
|
|
visible?: boolean
|
|
updateVisible?: (next: boolean) => unknown
|
|
size?: NormalSizes
|
|
disableAll?: boolean
|
|
ref?: MutableRefObject<HTMLElement | null>
|
|
}
|
|
|
|
const defaultContext = {
|
|
visible: false,
|
|
size: 'medium' as NormalSizes,
|
|
disableAll: false,
|
|
}
|
|
|
|
export const SelectContext = React.createContext<SelectConfig>(defaultContext)
|
|
|
|
export const useSelectContext = (): SelectConfig =>
|
|
React.useContext<SelectConfig>(SelectContext)
|