forked from elrumordelaluz/reactour
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
344 lines (283 loc) · 8.19 KB
/
index.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
/*
* Source:
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/reactour/index.d.ts
*/
// Type definitions for reactour 1.17
// Project: https://github.com/elrumordelaluz/reactour#readme
// Definitions by: Paweł Dąbrowski <https://github.com/paolostyle>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
// ---------------------
// Step interfaces
// ---------------------
export type ReactourStepPosition = 'top' | 'right' | 'bottom' | 'left' | 'center';
export interface ReactourStepContentArgs {
close: () => void;
goTo: (step: number) => void;
inDOM: boolean;
step: number;
}
export interface ReactourStep {
/**
* Content of the step
*/
content: React.ReactNode | ((args: ReactourStepContentArgs) => React.ReactNode);
/**
* Action that can be executed on target element of the step
*/
action?: (domNode: any) => void;
/**
* Position of step content
*/
position?: ReactourStepPosition | [number, number];
/**
* DOM selector to find the target element
*/
selector?: string;
/**
* Disable interaction for this specific step.
* Could be enabled passing `true`
* when `disableInteraction` prop is present in Tour
*/
stepInteraction?: boolean;
/**
* Additional styles
*/
style?: React.CSSProperties;
/**
* Text read to screen reader software for this step's navigation dot
*/
navDotAriaLabel?: string;
}
export interface ReactourAccessibilityOptions {
// attribute to associate the dialog with a title for screen readers
ariaLabelledBy?: string;
// aria-label attribute for the close button
closeButtonAriaLabel?: string;
// Show/Hide Navigation Dots for screen reader software
showNavigationScreenReaders?: boolean;
}
export interface ReactourProps {
/**
* You know…
*/
isOpen: boolean;
/**
* Array of elements to highlight with special info and props
*/
steps: ReactourStep[];
/**
* Function to close the _Tour_
*/
onRequestClose: (event: React.MouseEvent<HTMLDivElement>) => void;
/**
* Change `--reactour-accent` _(defaults to accentColor on IE)_ css custom prop to apply color in _Helper_, number, dots, etc
* @default #007aff
*/
accentColor?: string;
/**
* Customize _Badge_ content using `current` and `total` steps values
*/
badgeContent?: (current: number, total: number) => React.ReactNode;
/**
* Content to be rendered inside the _Helper_
*/
children?: React.ReactNode;
/**
* Custom class name to add to the _Helper_
*/
className?: string;
/**
* Close the _Tour_ by clicking the _Mask_
* @default true
*/
closeWithMask?: boolean;
/**
* Disable interactivity with _Dots_ navigation in _Helper_
*/
disableDotsNavigation?: boolean;
/**
* Disable the ability to click or intercat in any way with the _Highlighted_ element
*/
disableInteraction?: boolean;
/**
* Disable all keyboard navigation (next and prev step) when true, disable only selected keys when array
*/
disableKeyboardNavigation?: boolean | Array<'esc' | 'right' | 'left'>;
/**
* Function triggered each time current step change
*/
getCurrentStep?: (currentStep: number) => void;
/**
* Programmatically change current step after the first render, when the value changes
*/
goToStep?: number;
/**
* Custom class name to add to the element which is the overlay for the target element when `disableInteraction`
*/
highlightedMaskClassName?: string;
/**
* Tolerance in pixels to add when calculating if an element is outside viewport to scroll into view
*/
inViewThreshold?: number;
/**
* Change Next button in last step into a custom button to close the Tour
*/
lastStepNextButton?: React.ReactNode;
/**
* Custom class name to add to the _Mask_
*/
maskClassName?: string;
/**
* Extra Space between in pixels between _Highlighted_ element and _Mask_
*/
maskSpace?: number;
/**
* Renders as next button navigation
*/
nextButton?: React.ReactNode;
/**
* Overrides default `nextStep` internal function
*/
nextStep?: () => void;
/**
* Do something after _Tour_ is opened
*/
onAfterOpen?: (target: HTMLDivElement) => void;
/**
* Do something before _Tour_ is closed
*/
onBeforeClose?: (target: HTMLDivElement) => void;
/**
* Renders as prev button navigation
*/
prevButton?: React.ReactNode;
/**
* Overrides default `prevStep` internal function
*/
prevStep?: () => void;
/**
* Beautify _Helper_ and _Mask_ with `border-radius` (in px)
* @default 0
*/
rounded?: number;
/**
* Smooth scroll duration when positioning the target element (in ms)
* @default 1
*/
scrollDuration?: number;
/**
* Offset when positioning the target element after scroll to it, by default it's a calculation to the center of the viewport
*/
scrollOffset?: number;
/**
* Show/Hide _Helper_ Navigation buttons
* @default true
*/
showButtons?: boolean;
/**
* Show/Hide _Helper_ Close button
* @default true
*/
showCloseButton?: boolean;
/**
* Show/Hide _Helper_ Navigation Dots
* @default true
*/
showNavigation?: boolean;
/**
* Show/Hide number when hovers on each Navigation Dot
* @default true
*/
showNavigationNumber?: boolean;
/**
* Show/Hide _Helper_ Number Badge
* @default true
*/
showNumber?: boolean;
/**
* Starting step when _Tour_ is open the first time
*/
startAt?: number;
/**
* Value to listen if a forced update is needed
*/
update?: string;
/**
* Delay time when forcing update. Useful when there are known animation/transitions
* @default 1
*/
updateDelay?: number;
/**
* Disable FocusLock component
* @default false
*/
disableFocusLock?: boolean;
/**
* Configure accessibility related accessibility options
*/
accessibilityOptions?: ReactourAccessibilityOptions;
/**
* Disable next step button
* @default false
*/
disableNextStepButton?: boolean;
/**
* Disable previous step button
* @default false
*/
disablePrevStepButton?: boolean;
}
export interface ReactourState {
isOpen: boolean;
current: number;
top: number;
right: number;
bottom: number;
left: number;
width: number;
height: number;
w: number;
h: number;
inDOM: boolean;
observer: MutationObserver | null;
focusUnlocked: boolean;
helperWidth?: number;
helperHeight?: number;
helperPosition?: ReactourStepPosition;
}
declare class Tour extends React.Component<ReactourProps, ReactourState> {}
export default Tour;
// Components below are all styled components
// Arrow and Close are styled SVG components
// and the rest are simply made with `styled[htmlTagName]`
export interface ArrowProps {
onClick: React.MouseEventHandler<HTMLButtonElement>;
className?: string;
disabled?: boolean;
inverted?: boolean;
label?: React.ReactNode;
}
export function Arrow(props: ArrowProps): React.ReactElement;
export interface BadgeProps extends React.ComponentPropsWithRef<'span'> {
accentColor?: string;
}
export const Badge: React.FC<BadgeProps>;
export interface CloseProps {
onClick: React.MouseEventHandler<HTMLButtonElement>;
className?: string;
}
export function Close(props: CloseProps): React.ReactElement;
export interface ControlsProps extends React.ComponentPropsWithRef<'div'> {}
export const Controls: React.FC<ControlsProps>;
export interface DotProps extends React.ComponentPropsWithRef<'button'> {
disabled?: boolean;
current?: number;
index?: number;
showNumber?: boolean;
accentColor?: string;
}
export const Dot: React.FC<DotProps>;
export type NavigationProps = React.ComponentPropsWithRef<'nav'>;
export const Navigation: React.FC<NavigationProps>;