Skip to content

Commit 4552e0e

Browse files
committed
Tweak type definitions
1 parent 14ff1ec commit 4552e0e

File tree

4 files changed

+59
-119
lines changed

4 files changed

+59
-119
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535
"experimentalObjectRestSpread": true
3636
}
3737
}
38-
}
38+
}

index.d.ts

Lines changed: 26 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
declare module 'intro.js-react' {
2+
import * as React from 'react';
3+
import { IntroJs, Options } from 'intro.js';
4+
25
interface Step {
36
/**
47
* CSS selector to use for the step.
@@ -7,7 +10,7 @@ declare module 'intro.js-react' {
710
/**
811
* The tooltip content.
912
*/
10-
intro: string | JSX.Element;
13+
intro: string | React.ReactNode;
1114
/**
1215
* Position of the tooltip.
1316
*/
@@ -34,106 +37,7 @@ declare module 'intro.js-react' {
3437
/**
3538
* Position of the tooltip.
3639
*/
37-
hintPosition?: String;
38-
}
39-
40-
interface Options {
41-
/**
42-
* Next button label.
43-
*/
44-
nextLabel?: string;
45-
/**
46-
* Previous button label.
47-
*/
48-
prevLabel?: string;
49-
/**
50-
* Skip button label.
51-
*/
52-
skipLabel?: string;
53-
/**
54-
* Done button label.
55-
*/
56-
doneLabel?: string;
57-
/**
58-
* Hides the Previous button in the first step.
59-
*/
60-
hidePrev?: boolean;
61-
/**
62-
* Hide the Next button in the last step.
63-
*/
64-
hideNext?: boolean;
65-
/**
66-
* Position of the tooltips.
67-
*/
68-
tooltipPosition?: string;
69-
/**
70-
* CSS class of the tooltips.
71-
*/
72-
tooltipClass?: string;
73-
/**
74-
* CSS class of the helperLayer.
75-
*/
76-
highlightClass?: string;
77-
/**
78-
* Exit by pressing Escape.
79-
*/
80-
exitOnEsc?: boolean;
81-
/**
82-
* Exit by clicking on the overlay layer.
83-
*/
84-
exitOnOverlayClick?: boolean;
85-
/**
86-
* Show steps number in a red circle.
87-
*/
88-
showStepNumbers?: boolean;
89-
/**
90-
* Allows navigation between steps using the keyboard.
91-
*/
92-
keyboardNavigation?: boolean;
93-
/**
94-
* Show navigation buttons.
95-
*/
96-
showButtons?: boolean;
97-
/**
98-
* Show bullets.
99-
*/
100-
showBullets?: boolean;
101-
/**
102-
* Show progress indicator.
103-
*/
104-
showProgress?: boolean;
105-
/**
106-
* Enables scrolling to hidden elements.
107-
*/
108-
scrollToElement?: boolean;
109-
/**
110-
* Opacity of the overlay.
111-
*/
112-
overlayOpacity?: number;
113-
/**
114-
* Padding when automatically scrolling to an element.
115-
*/
116-
scrollPadding?: number;
117-
/**
118-
* Precedence of positions.
119-
*/
120-
positionPrecedence?: string[];
121-
/**
122-
* Disables interaction inside elements.
123-
*/
124-
disableInteraction?: boolean;
125-
/**
126-
* Position of the hints.
127-
*/
12840
hintPosition?: string;
129-
/**
130-
* Hint button label.
131-
*/
132-
hintButtonLabel?: string;
133-
/**
134-
* Enables hint animations.
135-
*/
136-
hintAnimation?: boolean;
13741
}
13842

13943
interface StepsProps {
@@ -151,42 +55,44 @@ declare module 'intro.js-react' {
15155
*/
15256
steps: Step[];
15357
/**
154-
* Callback called when the steps are disabled
155-
* Required to force keeping track of the state when the steps are dismissed with an Intro.js event and not the enabled prop.
58+
* Callback called when the steps are disabled.
59+
* Required to force keeping track of the state when the steps are dismissed with an Intro.js event and not the
60+
* enabled prop.
15661
*/
157-
onExit(stepIndex: number): any;
62+
onExit(stepIndex: number): void;
15863
/**
15964
* Callback called before exiting the intro.
16065
* If you want to prevent exiting the intro, you can return false in this callback (available since intro.js 0.2.7).
16166
*/
162-
onBeforeExit?(stepIndex: number): any;
67+
onBeforeExit?(stepIndex: number): void | false;
16368
/**
16469
* Callback called when the steps are enabled.
16570
*/
166-
onStart?(stepIndex: number): any;
71+
onStart?(stepIndex: number): void;
16772
/**
16873
* Callback called when the current step is changed.
16974
*/
170-
onChange?(nextStepIndex: number, nextElement: Element): any;
75+
onChange?(nextStepIndex: number, nextElement: Element): void;
17176
/**
17277
* Callback called before changing the current step.
173-
* If you want to prevent the transition to the next / previous step, you can return false in this callback (available since intro.js 2.8.0).
78+
* If you want to prevent the transition to the next / previous step, you can return false in this callback
79+
* (available since intro.js 2.8.0).
17480
*/
175-
onBeforeChange?(nextStepIndex: number): any;
81+
onBeforeChange?(nextStepIndex: number): void | false;
17682
/**
17783
* Callback called after changing the current step.
17884
*/
179-
onAfterChange?(newStepIndex: number, newElement: Element): any;
85+
onAfterChange?(newStepIndex: number, newElement: Element): void;
18086
/**
18187
* Callback called if you prevented transitioning to a new step by returning false in onBeforeChange.
18288
*/
183-
onPreventChange?(stepIndex: number): any;
89+
onPreventChange?(stepIndex: number): void;
18490
/**
18591
* Callback called when all the steps are completed.
18692
*/
187-
onComplete?(): any;
93+
onComplete?(): void;
18894
/**
189-
* Intro.js options.
95+
* Intro.js options.
19096
*/
19197
options?: Options;
19298
}
@@ -198,23 +104,26 @@ declare module 'intro.js-react' {
198104
*/
199105
enabled?: boolean;
200106
/**
201-
* All the hints. Hint[]
107+
* All the hints.
202108
*/
203109
hints: Hint[];
204110
/**
205111
* Callback called when a hint is clicked.
206112
*/
207-
onClick?(): any;
113+
onClick?(): void;
208114
/**
209115
* Callback called when a hint is closed.
210116
*/
211-
onClose?(): any;
117+
onClose?(): void;
212118
/**
213119
* Intro.js options.
214120
*/
215121
options?: Options;
216122
}
217123

218-
function Steps(props: StepsProps): JSX.Element;
219-
function Hints(props: HintsProps): JSX.Element;
124+
export class Steps extends React.Component<StepsProps> {
125+
introJs: IntroJs;
126+
}
127+
128+
export class Hints extends React.Component<HintsProps> {}
220129
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
"@babel/plugin-proposal-object-rest-spread": "7.9.6",
2323
"@babel/preset-env": "7.9.6",
2424
"@babel/preset-react": "7.9.4",
25+
"@types/intro.js": "3.0.1",
26+
"@types/react": "17.0.4",
2527
"babel-eslint": "^7.2.3",
2628
"babel-jest": "26.0.1",
2729
"coveralls": "^3.0.1",
@@ -80,4 +82,4 @@
8082
"lib",
8183
"src"
8284
]
83-
}
85+
}

yarn.lock

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,11 @@
11391139
dependencies:
11401140
"@types/node" "*"
11411141

1142+
1143+
version "3.0.1"
1144+
resolved "https://registry.yarnpkg.com/@types/intro.js/-/intro.js-3.0.1.tgz#2a5272d6ceb715676f496fd0060eedc70d98c6fe"
1145+
integrity sha512-L4vCKY/4ZFpRgILDHd3oacARWYKYpz3oJfjweoc0ooM+OoM1HEtGRFM0JuNYQNTrgUXe+R4rUyLDYSeSnrmdLw==
1146+
11421147
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
11431148
version "2.0.2"
11441149
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.2.tgz#79d7a78bad4219f4c03d6557a1c72d9ca6ba62d5"
@@ -1174,6 +1179,25 @@
11741179
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.0.0.tgz#dc85454b953178cc6043df5208b9e949b54a3bc4"
11751180
integrity sha512-/rM+sWiuOZ5dvuVzV37sUuklsbg+JPOP8d+nNFlo2ZtfpzPiPvh1/gc8liWOLBqe+sR+ZM7guPaIcTt6UZTo7Q==
11761181

1182+
"@types/prop-types@*":
1183+
version "15.7.3"
1184+
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
1185+
integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==
1186+
1187+
1188+
version "17.0.4"
1189+
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.4.tgz#a67c6f7a460d2660e950d9ccc1c2f18525c28220"
1190+
integrity sha512-onz2BqScSFMoTRdJUZUDD/7xrusM8hBA2Fktk2qgaTYPCgPvWnDEgkrOs8hhPUf2jfcIXkJ5yK6VfYormJS3Jw==
1191+
dependencies:
1192+
"@types/prop-types" "*"
1193+
"@types/scheduler" "*"
1194+
csstype "^3.0.2"
1195+
1196+
"@types/scheduler@*":
1197+
version "0.16.1"
1198+
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.1.tgz#18845205e86ff0038517aab7a18a62a6b9f71275"
1199+
integrity sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==
1200+
11771201
"@types/stack-utils@^1.0.1":
11781202
version "1.0.1"
11791203
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
@@ -2051,6 +2075,11 @@ cssstyle@^2.2.0:
20512075
dependencies:
20522076
cssom "~0.3.6"
20532077

2078+
csstype@^3.0.2:
2079+
version "3.0.8"
2080+
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.8.tgz#d2266a792729fb227cd216fb572f43728e1ad340"
2081+
integrity sha512-jXKhWqXPmlUeoQnF/EhTtTl4C9SnrxSH/jZUih3jmO6lBKr99rP3/+FmrMj4EFpOXzMtXHAZkd3x0E6h6Fgflw==
2082+
20542083
damerau-levenshtein@^1.0.0:
20552084
version "1.0.6"
20562085
resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.6.tgz#143c1641cb3d85c60c32329e26899adea8701791"

0 commit comments

Comments
 (0)