mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-28 12:15:32 +08:00
feat: export all types related to components (#562)
* feat: export all types related to components fix(tooltip): fix the vertical offset of the arrow * refactor: optimize events of all popup related components * test: append testcases for popup base component * test: add testcase for visible events * test: update snapshots
This commit is contained in:
@@ -18,6 +18,8 @@ import { pickChild } from '../utils/collections'
|
||||
import useCurrentState from '../utils/use-current-state'
|
||||
import useScaleable, { filterScaleableProps, withScaleable } from '../use-scaleable'
|
||||
|
||||
export type AutoCompleteTypes = NormalTypes
|
||||
|
||||
export type AutoCompleteOption = {
|
||||
label: string
|
||||
value: string
|
||||
@@ -29,7 +31,7 @@ export type AutoCompleteOptions = Array<
|
||||
|
||||
interface Props {
|
||||
options?: AutoCompleteOptions
|
||||
type?: NormalTypes
|
||||
type?: AutoCompleteTypes
|
||||
initialValue?: string
|
||||
value?: string
|
||||
onChange?: (value: string) => void
|
||||
@@ -50,7 +52,7 @@ const defaultProps = {
|
||||
initialValue: '',
|
||||
disabled: false,
|
||||
clearable: false,
|
||||
type: 'default' as NormalTypes,
|
||||
type: 'default' as AutoCompleteTypes,
|
||||
disableMatchWidth: false,
|
||||
disableFreeSolo: false,
|
||||
className: '',
|
||||
@@ -135,10 +137,10 @@ const AutoCompleteComponent = React.forwardRef<
|
||||
}
|
||||
return childrenToOptionsNode(options as Array<AutoCompleteOption>)
|
||||
}, [searching, options])
|
||||
const showClearIcon = useMemo(() => clearable && searching === undefined, [
|
||||
clearable,
|
||||
searching,
|
||||
])
|
||||
const showClearIcon = useMemo(
|
||||
() => clearable && searching === undefined,
|
||||
[clearable, searching],
|
||||
)
|
||||
|
||||
const updateValue = (val: string) => {
|
||||
if (disabled) return
|
||||
|
||||
@@ -14,4 +14,10 @@ export type AutoCompleteComponentType = typeof AutoComplete & {
|
||||
;(AutoComplete as AutoCompleteComponentType).Searching = AutoCompleteSearching
|
||||
;(AutoComplete as AutoCompleteComponentType).Empty = AutoCompleteEmpty
|
||||
|
||||
export type {
|
||||
AutoCompleteOption,
|
||||
AutoCompleteOptions,
|
||||
AutoCompleteProps,
|
||||
AutoCompleteTypes,
|
||||
} from './auto-complete'
|
||||
export default AutoComplete as AutoCompleteComponentType
|
||||
|
||||
Reference in New Issue
Block a user