/
Popup.d.ts
151 lines (116 loc) · 4.45 KB
/
Popup.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
143
144
145
146
147
148
149
150
151
import * as React from 'react'
import * as Popper from '@popperjs/core'
import { SemanticShorthandItem } from '../../generic'
import { StrictPortalProps } from '../../addons/Portal'
import PopupContent, { PopupContentProps } from './PopupContent'
import PopupHeader, { PopupHeaderProps } from './PopupHeader'
type PopperOffsetsFunctionParams = {
popper: Popper.Rect
reference: Popper.Rect
placement: Popper.Placement
}
type PopperOffsetsFunction = (params: PopperOffsetsFunctionParams) => [number?, number?]
export interface PopupProps extends StrictPopupProps {
[key: string]: any
}
export interface StrictPopupProps extends StrictPortalProps {
/** An element type to render as (string or function). */
as?: any
/** Display the popup without the pointing arrow */
basic?: boolean
/** Primary content. */
children?: React.ReactNode
/** Additional classes. */
className?: string
/** Simple text content for the popover. */
content?: SemanticShorthandItem<PopupContentProps>
/** Existing element the pop-up should be bound to. */
context?: Document | Window | HTMLElement | React.RefObject<HTMLElement>
/** A disabled popup only renders its trigger. */
disabled?: boolean
/** Enables the Popper.js event listeners. */
eventsEnabled?: boolean
/** A flowing Popup has no maximum width and continues to flow to fit its content. */
flowing?: boolean
/** Header displayed above the content in bold. */
header?: SemanticShorthandItem<PopupHeaderProps>
/** Hide the Popup when scrolling the window. */
hideOnScroll?: boolean
/** Whether the popup should not close on hover. */
hoverable?: boolean
/** Invert the colors of the popup */
inverted?: boolean
/**
* Offset values in px unit to apply to rendered popup. The basic offset accepts an
* array with two numbers in the form [skidding, distance]:
* - `skidding` displaces the Popup along the reference element
* - `distance` displaces the Popup away from, or toward, the reference element in the direction of its placement. A positive number displaces it further away, while a negative number lets it overlap the reference.
*
* @see https://popper.js.org/docs/v2/modifiers/offset/
*/
offset?: [number, number?] | PopperOffsetsFunction
/** Events triggering the popup. */
on?: 'hover' | 'click' | 'focus' | ('hover' | 'click' | 'focus')[]
/**
* Called when a close event happens.
*
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All props.
*/
onClose?: (event: React.MouseEvent<HTMLElement>, data: PopupProps) => void
/**
* Called when the portal is mounted on the DOM.
*
* @param {null}
* @param {object} data - All props.
*/
onMount?: (nothing: null, data: PopupProps) => void
/**
* Called when an open event happens.
*
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All props.
*/
onOpen?: (event: React.MouseEvent<HTMLElement>, data: PopupProps) => void
/**
* Called when the portal is unmounted from the DOM.
*
* @param {null}
* @param {object} data - All props.
*/
onUnmount?: (nothing: null, data: PopupProps) => void
/** Disables automatic repositioning of the component, it will always be placed according to the position value. */
pinned?: boolean
/** Position for the popover. */
position?:
| 'top left'
| 'top right'
| 'bottom right'
| 'bottom left'
| 'right center'
| 'left center'
| 'top center'
| 'bottom center'
/** Tells `Popper.js` to use the `position: fixed` strategy to position the popover. */
positionFixed?: boolean
/** A wrapping element for an actual content that will be used for positioning. */
popper?: SemanticShorthandItem<React.HTMLAttributes<HTMLDivElement>>
/** An array containing custom settings for the Popper.js modifiers. */
popperModifiers?: any[]
/** A popup can have dependencies which update will schedule a position update. */
popperDependencies?: any[]
/** Popup size. */
size?: 'mini' | 'tiny' | 'small' | 'large' | 'huge'
/** Custom Popup style. */
style?: React.CSSProperties
/** Element to be rendered in-place where the popup is defined. */
trigger?: React.ReactNode
/** Popup width. */
wide?: boolean | 'very'
}
interface PopupComponent extends React.ComponentClass<PopupProps> {
Content: typeof PopupContent
Header: typeof PopupHeader
}
declare const Popup: PopupComponent
export default Popup