react-joyride: Fix callback type definition and add test (#29716)

* Fix callback type definition and add test

* Update version

* Add disableScrolling and showSkipButton

* Fix trailing whitespace
This commit is contained in:
Kamran Ayub
2018-10-22 08:42:55 -07:00
committed by Sheetal Nandi
parent 66a936b0a7
commit 2ed0fa2d7e
2 changed files with 18 additions and 3 deletions
+12 -1
View File
@@ -1,6 +1,7 @@
// Type definitions for react-joyride 2.0
// Project: https://github.com/gilbarbara/react-joyride
// Definitions by: DongYoon Kang <https://github.com/kdy1>
// Kamran Ayub <https://github.com/kamranayub>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -106,7 +107,7 @@ export interface Props extends OverridableProps {
/**
* It will be called when Joyride's state changes. It returns a single parameter with the state.
*/
callback?(options: (data: State) => any): void;
callback?: (data: State) => any;
/**
* The tour is played sequentially with the Next button. Defaults to false.
@@ -135,6 +136,11 @@ export interface OverridableProps {
*/
showProgress?: boolean;
/**
* Display a button to skip the tour.
*/
showSkipButton?: boolean;
/**
* Disable closing the tooltip on ESC. Defaults to false.
*/
@@ -150,6 +156,11 @@ export interface OverridableProps {
*/
disableOverlayClose?: boolean;
/**
* Disable auto scrolling between steps.
*/
disableScrolling?: boolean;
/**
* The strings used in the tooltip. Defaults to `{ back: 'Back', close: 'Close', last: 'Last', next: 'Next', skip: 'Skip' }`
*/
+6 -2
View File
@@ -1,5 +1,5 @@
import * as React from "react";
import Joyride, { Step } from "react-joyride";
import Joyride, { Step, State } from "react-joyride";
class NewComponent extends React.Component<undefined, undefined> {
j: Joyride;
@@ -42,7 +42,7 @@ class NewComponent extends React.Component<undefined, undefined> {
}];
render() {
return <Joyride ref="j" run={true} steps={this.steps} />;
return <Joyride ref="j" run={true} steps={this.steps} callback={this.onCallback} />;
}
doStuff() {
@@ -56,4 +56,8 @@ class NewComponent extends React.Component<undefined, undefined> {
const { title, placement } = this.j.getProgress().step;
}
onCallback(data: State) {
return;
}
}