Skip to content

Commit 61c681a

Browse files
committed
Update with suggestions
1 parent 981ca45 commit 61c681a

File tree

7 files changed

+1258
-837
lines changed

7 files changed

+1258
-837
lines changed

.babelrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

.babelrc-esm

Lines changed: 0 additions & 18 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
node_modules
22
coverage
3-
lib
4-
esm
3+
dist
54
npm-debug.log.*
65
.DS_Store

babel.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = api => {
2+
api.cache(true);
3+
4+
return {
5+
presets: [
6+
[
7+
'@babel/preset-env',
8+
{
9+
targets: 'last 2 versions, not dead',
10+
modules: process.env.CJS ? 'commonjs' : false,
11+
},
12+
],
13+
'@babel/preset-react',
14+
],
15+
plugins: [['babel-plugin-add-import-extension', { extension: process.env.CJS ? 'cjs' : 'mjs' }]],
16+
};
17+
};

index.d.ts

Lines changed: 126 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,132 @@
1-
declare module 'intro.js-react' {
2-
import * as React from 'react';
3-
import { IntroJs, Options } from 'intro.js';
1+
import * as React from 'react';
2+
import { IntroJs, Options } from 'intro.js';
43

5-
interface Step {
6-
/**
7-
* CSS selector or element to use for the step.
8-
*/
9-
element?: string | HTMLElement | Element;
10-
/**
11-
* The tooltip content.
12-
*/
13-
intro: string | React.ReactNode;
14-
/**
15-
* Position of the tooltip.
16-
*/
17-
position?: string;
18-
/**
19-
* The tooltip title.
20-
*/
21-
title?: string
22-
/**
23-
* CSS class of the tooltip.
24-
*/
25-
tooltipClass?: string;
26-
/**
27-
* CSS class of the helperLayer.
28-
*/
29-
highlightClass?: string;
30-
}
31-
32-
interface Hint {
33-
/**
34-
* CSS selector to use for the hint.
35-
*/
36-
element: string;
37-
/**
38-
* The tooltip text.
39-
*/
40-
hint: string;
41-
/**
42-
* Position of the tooltip.
43-
*/
44-
hintPosition?: string;
45-
}
4+
interface Step {
5+
/**
6+
* CSS selector or element to use for the step.
7+
*/
8+
element?: string | HTMLElement | Element;
9+
/**
10+
* The tooltip content.
11+
*/
12+
intro: string | React.ReactNode;
13+
/**
14+
* Position of the tooltip.
15+
*/
16+
position?: string;
17+
/**
18+
* The tooltip title.
19+
*/
20+
title?: string;
21+
/**
22+
* CSS class of the tooltip.
23+
*/
24+
tooltipClass?: string;
25+
/**
26+
* CSS class of the helperLayer.
27+
*/
28+
highlightClass?: string;
29+
}
4630

47-
interface StepsProps {
48-
/**
49-
* Defines if the steps are visible or not.
50-
* @default false
51-
*/
52-
enabled?: boolean;
53-
/**
54-
* Step index to start with when showing the steps.
55-
*/
56-
initialStep: number;
57-
/**
58-
* All the steps.
59-
*/
60-
steps: Step[];
61-
/**
62-
* Callback called when the steps are disabled.
63-
* Required to force keeping track of the state when the steps are dismissed with an Intro.js event and not the
64-
* enabled prop.
65-
*/
66-
onExit(stepIndex: number): void;
67-
/**
68-
* Callback called before exiting the intro.
69-
* If you want to prevent exiting the intro, you can return false in this callback (available since intro.js 0.2.7).
70-
*/
71-
onBeforeExit?(stepIndex: number): void | false;
72-
/**
73-
* Callback called when the steps are enabled.
74-
*/
75-
onStart?(stepIndex: number): void;
76-
/**
77-
* Callback called when the current step is changed.
78-
*/
79-
onChange?(nextStepIndex: number, nextElement: Element): void;
80-
/**
81-
* Callback called before changing the current step.
82-
* If you want to prevent the transition to the next / previous step, you can return false in this callback
83-
* (available since intro.js 2.8.0).
84-
*/
85-
onBeforeChange?(nextStepIndex: number, nextElement: Element): void | false | Promise<void | false>;
86-
/**
87-
* Callback called after changing the current step.
88-
*/
89-
onAfterChange?(newStepIndex: number, newElement: Element): void;
90-
/**
91-
* Callback called if you prevented transitioning to a new step by returning false in onBeforeChange.
92-
*/
93-
onPreventChange?(stepIndex: number): void;
94-
/**
95-
* Callback called when all the steps are completed.
96-
*/
97-
onComplete?(): void;
98-
/**
99-
* Intro.js options.
100-
*/
101-
options?: Options;
102-
}
31+
interface Hint {
32+
/**
33+
* CSS selector to use for the hint.
34+
*/
35+
element: string;
36+
/**
37+
* The tooltip text.
38+
*/
39+
hint: string;
40+
/**
41+
* Position of the tooltip.
42+
*/
43+
hintPosition?: string;
44+
}
10345

104-
interface HintsProps {
105-
/**
106-
* Defines if the hints are visible or not.
107-
* @default false
108-
*/
109-
enabled?: boolean;
110-
/**
111-
* All the hints.
112-
*/
113-
hints: Hint[];
114-
/**
115-
* Callback called when a hint is clicked.
116-
*/
117-
onClick?(): void;
118-
/**
119-
* Callback called when a hint is closed.
120-
*/
121-
onClose?(): void;
122-
/**
123-
* Intro.js options.
124-
*/
125-
options?: Options;
126-
}
46+
interface StepsProps {
47+
/**
48+
* Defines if the steps are visible or not.
49+
* @default false
50+
*/
51+
enabled?: boolean;
52+
/**
53+
* Step index to start with when showing the steps.
54+
*/
55+
initialStep: number;
56+
/**
57+
* All the steps.
58+
*/
59+
steps: Step[];
60+
/**
61+
* Callback called when the steps are disabled.
62+
* Required to force keeping track of the state when the steps are dismissed with an Intro.js event and not the
63+
* enabled prop.
64+
*/
65+
onExit(stepIndex: number): void;
66+
/**
67+
* Callback called before exiting the intro.
68+
* If you want to prevent exiting the intro, you can return false in this callback (available since intro.js 0.2.7).
69+
*/
70+
onBeforeExit?(stepIndex: number): void | false;
71+
/**
72+
* Callback called when the steps are enabled.
73+
*/
74+
onStart?(stepIndex: number): void;
75+
/**
76+
* Callback called when the current step is changed.
77+
*/
78+
onChange?(nextStepIndex: number, nextElement: Element): void;
79+
/**
80+
* Callback called before changing the current step.
81+
* If you want to prevent the transition to the next / previous step, you can return false in this callback
82+
* (available since intro.js 2.8.0).
83+
*/
84+
onBeforeChange?(nextStepIndex: number, nextElement: Element): void | false | Promise<void | false>;
85+
/**
86+
* Callback called after changing the current step.
87+
*/
88+
onAfterChange?(newStepIndex: number, newElement: Element): void;
89+
/**
90+
* Callback called if you prevented transitioning to a new step by returning false in onBeforeChange.
91+
*/
92+
onPreventChange?(stepIndex: number): void;
93+
/**
94+
* Callback called when all the steps are completed.
95+
*/
96+
onComplete?(): void;
97+
/**
98+
* Intro.js options.
99+
*/
100+
options?: Options;
101+
}
127102

128-
export class Steps extends React.Component<StepsProps> {
129-
public introJs: IntroJs;
130-
public updateStepElement(stepIndex: number): void;
131-
}
103+
interface HintsProps {
104+
/**
105+
* Defines if the hints are visible or not.
106+
* @default false
107+
*/
108+
enabled?: boolean;
109+
/**
110+
* All the hints.
111+
*/
112+
hints: Hint[];
113+
/**
114+
* Callback called when a hint is clicked.
115+
*/
116+
onClick?(): void;
117+
/**
118+
* Callback called when a hint is closed.
119+
*/
120+
onClose?(): void;
121+
/**
122+
* Intro.js options.
123+
*/
124+
options?: Options;
125+
}
132126

133-
export class Hints extends React.Component<HintsProps> {}
127+
export class Steps extends React.Component<StepsProps> {
128+
public introJs: IntroJs;
129+
public updateStepElement(stepIndex: number): void;
134130
}
131+
132+
export class Hints extends React.Component<HintsProps> {}

package.json

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,40 @@
22
"name": "intro.js-react",
33
"version": "0.7.1",
44
"description": "Intro.js React Wrapper",
5-
"main": "lib/index.js",
6-
"module": "esm/index.js",
5+
"main": "dist/lib/index.js",
6+
"module": "dist/esm/index.js",
77
"types": "index.d.ts",
8+
"exports": {
9+
"./package.json": "./package.json",
10+
".": {
11+
"types": "./index.d.ts",
12+
"import": "./dist/esm/index.mjs",
13+
"default": "./dist/cjs/index.cjs"
14+
}
15+
},
816
"scripts": {
917
"prebuild": "rimraf lib/* && rimraf esm/*",
10-
"build": "babel --ignore '**/*.test.js' --out-dir lib src",
11-
"build:esm": "babel --ignore '**/*.test.js' --out-dir esm --config-file ./.babelrc-esm --no-babelrc src",
12-
"build:watch": "npm run build -- --watch",
18+
"build": "yarn build:cjs && yarn build:esm",
19+
"build:cjs": "CJS=true babel --ignore '**/*.test.js' --out-dir dist/cjs --out-file-extension .cjs src && cp dist/cjs/index.cjs dist/cjs/index.js",
20+
"build:esm": "babel --ignore '**/*.test.js' --out-dir dist/esm --out-file-extension .mjs src && cp dist/esm/index.mjs dist/esm/index.js",
21+
"build:watch": "npm run build:esm -- --watch",
1322
"lint": "eslint src",
1423
"test": "jest",
1524
"test:watch": "jest --watch",
1625
"test:coverage": "jest --coverage && open coverage/index.html",
1726
"test:ci": "jest --coverage",
1827
"precommit": "lint-staged",
19-
"prepublish": "npm run build && npm run build:esm"
28+
"prepublish": "npm run build"
2029
},
2130
"devDependencies": {
22-
"@babel/cli": "7.8.4",
23-
"@babel/plugin-proposal-class-properties": "7.8.3",
24-
"@babel/plugin-proposal-object-rest-spread": "7.9.6",
25-
"@babel/preset-env": "7.9.6",
26-
"@babel/preset-react": "7.9.4",
31+
"@babel/cli": "7.21.0",
32+
"@babel/preset-env": "7.21.4",
33+
"@babel/preset-react": "7.18.6",
2734
"@types/intro.js": "3.0.1",
2835
"@types/react": "17.0.4",
2936
"babel-eslint": "^7.2.3",
3037
"babel-jest": "26.0.1",
38+
"babel-plugin-add-import-extension": "^1.6.0",
3139
"coveralls": "^3.0.1",
3240
"enzyme": "^2.8.2",
3341
"eslint": "7.0.0",
@@ -81,9 +89,7 @@
8189
]
8290
},
8391
"files": [
84-
"lib",
85-
"esm",
86-
"src",
92+
"dist",
8793
"index.d.ts"
8894
]
8995
}

0 commit comments

Comments
 (0)