forked from jcoreio/material-ui-popup-state
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.d.ts
142 lines (130 loc) · 3.53 KB
/
core.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import { SyntheticEvent } from 'react'
export type Variant = 'popover' | 'popper'
export type PopupState = {
open: (eventOrAnchorEl?: SyntheticEvent<any> | HTMLElement | null) => void
close: () => void
toggle: (eventOrAnchorEl?: SyntheticEvent<any> | HTMLElement | null) => void
onMouseLeave: (event: SyntheticEvent<any>) => void
setOpen: (
open: boolean,
eventOrAnchorEl?: SyntheticEvent<any> | HTMLElement
) => void
isOpen: boolean
anchorEl: HTMLElement | undefined
setAnchorEl: (anchorEl: HTMLElement) => any
setAnchorElUsed: boolean
popupId: string | undefined
variant: Variant
_childPopupState: PopupState | undefined
_setChildPopupState: (popupState: PopupState | null | undefined) => void
}
export type CoreState = {
isOpen: boolean
setAnchorElUsed: boolean
anchorEl: HTMLElement | undefined
hovered: boolean
_childPopupState: PopupState | undefined
}
export const initCoreState: CoreState
export function createPopupState(options: {
state: CoreState
setState: (state: Partial<CoreState>) => any
popupId: string | undefined
variant: Variant
parentPopupState?: PopupState | null
}): PopupState
/**
* Creates a ref that sets the anchorEl for the popup.
*
* @param {object} popupState the argument passed to the child function of
* `PopupState`
*/
export function anchorRef(
popupState: PopupState
): (popupState: HTMLElement | undefined) => any
/**
* Creates props for a component that opens the popup when clicked.
*
* @param {object} popupState the argument passed to the child function of
* `PopupState`
*/
export function bindTrigger(
popupState: PopupState
): {
'aria-controls'?: string | undefined
'aria-describedby'?: string | undefined
'aria-haspopup': true | undefined
onClick: (event: SyntheticEvent<any>) => void
}
/**
* Creates props for a component that toggles the popup when clicked.
*
* @param {object} popupState the argument passed to the child function of
* `PopupState`
*/
export function bindToggle(
popupState: PopupState
): {
'aria-controls'?: string
'aria-describedby'?: string
'aria-haspopup': true | undefined
onClick: (event: SyntheticEvent<any>) => void
}
/**
* Creates props for a component that opens the popup while hovered.
*
* @param {object} popupState the argument passed to the child function of
* `PopupState`
*/
export function bindHover(
popupState: PopupState
): {
'aria-controls'?: string
'aria-describedby'?: string
'aria-haspopup': true | undefined
onMouseEnter: (event: SyntheticEvent<any>) => any
onMouseLeave: (event: SyntheticEvent<any>) => any
}
/**
* Creates props for a `Popover` component.
*
* @param {object} popupState the argument passed to the child function of
* `PopupState`
*/
export function bindPopover(
popupState: PopupState
): {
id: string | undefined
anchorEl: HTMLElement | undefined
open: boolean
onClose: () => void
onMouseLeave: (event: SyntheticEvent<any>) => void
}
/**
* Creates props for a `Menu` component.
*
* @param {object} popupState the argument passed to the child function of
* `PopupState`
*/
export function bindMenu(
popupState: PopupState
): {
id: string | undefined
anchorEl: HTMLElement | undefined
open: boolean
onClose: () => void
onMouseLeave: (event: SyntheticEvent<any>) => void
}
/**
* Creates props for a `Popper` component.
*
* @param {object} popupState the argument passed to the child function of
* `PopupState`
*/
export function bindPopper(
popupState: PopupState
): {
id: string | undefined
anchorEl: HTMLElement | undefined
open: boolean
}