Skip to content

Commit bc9d420

Browse files
committed
Merge branch 'main' of https://github.com/devrnt/react-use-wizard into pr/ulken/90
2 parents 4b6a199 + ea41b9e commit bc9d420

File tree

8 files changed

+2566
-2835
lines changed

8 files changed

+2566
-2835
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*.log
22
.DS_Store
33
node_modules
4-
.cache
54
dist
5+
.parcel-cache

README.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,25 @@ const App = () => {
108108

109109
### useWizard
110110

111-
Used to retrieve all methods and properties related to your wizard. Make sure `Wizard` is wrapped around your component when calling `useWizard`.
111+
Used to retrieve all methods and properties related to your wizard. Make sure `Wizard` is wrapped around your component when calling `useWizard`.
112112

113113
`handleStep` is used to attach a handler to the step, can either be `async` or a `sync` function. This function will be invoked when calling `nextStep`.
114114

115115
**Remark** - You can't use `useWizard` in the same component where `Wizard` is used.
116116

117117
#### Methods
118118

119-
| name | type | description |
120-
| ------------ | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
121-
| nextStep | () => Promise<void> | Go to the next step |
122-
| previousStep | () => void | Go to the previous step index |
123-
| goToStep | (stepIndex: number) => void | Go to the given step index |
124-
| handleStep | (handler: Handler) => void | Attach a callback that will be called when calling `nextStep`. `handler` can be either sync or async |
125-
| isLoading | boolean | \* Will reflect the handler promise state: will be `true` if the handler promise is pending and `false` when the handler is either fulfilled or rejected |
126-
| activeStep | number | The current active step of the wizard |
127-
| stepCount | number | The total number of steps of the wizard |
128-
| isFirstStep | boolean | Indicate if the current step is the first step (aka no previous step) |
129-
| isLastStep | boolean | Indicate if the current step is the last step (aka no next step) |
119+
| name | type | description |
120+
| ------------ | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
121+
| nextStep | () => Promise<void> | Go to the next step |
122+
| previousStep | () => void | Go to the previous step index |
123+
| goToStep | (stepIndex: number) => void | Go to the given step index |
124+
| handleStep | (handler: Handler) => void | Attach a callback that will be called when calling `nextStep`. `handler` can be either sync or async |
125+
| isLoading | boolean | \* Will reflect the handler promise state: will be `true` if the handler promise is pending and `false` when the handler is either fulfilled or rejected |
126+
| activeStep | number | The current active step of the wizard |
127+
| stepCount | number | The total number of steps of the wizard |
128+
| isFirstStep | boolean | Indicate if the current step is the first step (aka no previous step) |
129+
| isLastStep | boolean | Indicate if the current step is the last step (aka no next step) |
130130
| |
131131

132132
#### Example
@@ -182,16 +182,20 @@ const Step1 = () => {
182182
It's recommended to pass the shared components to the `header` or `footer` in the `Wizard` to avoid duplication.
183183

184184
## Playground
185+
185186
Small playground to showcase the functionalities of `react-use-wizard`:
186187
[https://devrnt.github.io/react-use-wizard/](https://devrnt.github.io/react-use-wizard/)
187188

188189
Following use cases are available in the playground
189-
- Simple wizard with async and sync steps
190-
- Animated wizard with sync steps
191-
- Integration with [react-query](https://react-query.tanstack.com/) (mutation on next step)
192190

193-
Source code can be found [here](https://github.com/devrnt/react-use-wizard/tree/main/playground).
191+
- Simple wizard with async and sync steps
192+
- Animated wizard with sync steps
193+
- Integration with [react-query](https://react-query.tanstack.com/) (mutation on next step)
194+
195+
Source code can be found [here](https://github.com/devrnt/react-use-wizard/tree/main/playground).
196+
194197
## Examples
198+
195199
Go to [examples](https://github.com/devrnt/react-use-wizard/tree/master/examples) to check out some integrations (Gatsby, NextJS...).
196200

197201
## Async
@@ -232,9 +236,10 @@ If an async function is attached to `handleStep` the `isLoading` property will i
232236

233237
Since `react-use-wizard` is focused to manage the logic of a wizard it doesn't mean you can't add some animation by your own. Add any animation library that you like. I highly suggest [framer-motion](https://www.framer.com/motion/) to add your animations.
234238

235-
Checkout this [example](https://github.com/devrnt/react-use-wizard/blob/main/playground/components/animatedStep.tsx) to see how a step can be animated with framer motion.
239+
Checkout this [example](https://github.com/devrnt/react-use-wizard/blob/main/playground/components/animatedStep.tsx) to see how a step can be animated with framer motion.
236240

237241
## IE11
242+
238243
Since Internet Explorer 11 doesn't support promises or async functions you'll need to install a polyfill for the `regenerator-runtime`.
239244

240-
In general using [react-app-polyfill](https://www.npmjs.com/package/react-app-polyfill) is recommended, it includes polyfills for various browsers.
245+
In general using [react-app-polyfill](https://www.npmjs.com/package/react-app-polyfill) is recommended, it includes polyfills for various browsers.

examples/nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start": "next start"
99
},
1010
"dependencies": {
11-
"next": "11.1.1",
11+
"next": "11.1.3",
1212
"react": "17.0.2",
1313
"react-dom": "17.0.2",
1414
"react-use-wizard": "^1.1.2"

examples/nextjs/yarn.lock

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,20 @@
8080
resolved "https://registry.yarnpkg.com/@napi-rs/triples/-/triples-1.0.3.tgz#76d6d0c3f4d16013c61e45dfca5ff1e6c31ae53c"
8181
integrity sha512-jDJTpta+P4p1NZTFVLHJ/TLFVYVcOqv6l8xwOeBKNPMgY/zDYH/YH7SJbvrr/h1RcS9GzbPcLKGzpuK9cV56UA==
8282

83-
"@next/env@11.1.1":
84-
version "11.1.1"
85-
resolved "https://registry.yarnpkg.com/@next/env/-/env-11.1.1.tgz#d403282accbe8795aa2341f0e02c2e8bfc92bfb0"
86-
integrity sha512-UEAzlfKofotLmj9LIgNixAfXpRck9rt/1CU9Q4ZtNDueGBJQP3HUzPHlrLChltWY2TA5MOzDQGL82H0a3+i5Ag==
83+
"@next/env@11.1.3":
84+
version "11.1.3"
85+
resolved "https://registry.yarnpkg.com/@next/env/-/env-11.1.3.tgz#dc698e00259242012955e43a40788fcf21ba9e37"
86+
integrity sha512-5+vaeooJuWmICSlmVaAC8KG3O8hwKasACVfkHj58xQuCB5SW0TKW3hWxgxkBuefMBn1nM0yEVPKokXCsYjBtng==
8787

88-
"@next/polyfill-module@11.1.1":
89-
version "11.1.1"
90-
resolved "https://registry.yarnpkg.com/@next/polyfill-module/-/polyfill-module-11.1.1.tgz#89d5a70685a52a0fad79f05a1f97a6b15cc727aa"
91-
integrity sha512-9FyVSnz00WGdlLsgc2w1xL1Lm/Q25y6FYIyA+1WlJvT6LA2lbR78GKiHgedzUvrAatVGAcg/Og+d0d7B4tsJOg==
88+
"@next/polyfill-module@11.1.3":
89+
version "11.1.3"
90+
resolved "https://registry.yarnpkg.com/@next/polyfill-module/-/polyfill-module-11.1.3.tgz#95163973fe19f1827da32703d1fcb8198fb2c79a"
91+
integrity sha512-7yr9cr4a0SrBoVE8psxXWK1wTFc8UzsY8Wc2cWGL7qA0hgtqACHaXC47M1ByJB410hFZenGrpE+KFaT1unQMyw==
9292

93-
"@next/react-dev-overlay@11.1.1":
94-
version "11.1.1"
95-
resolved "https://registry.yarnpkg.com/@next/react-dev-overlay/-/react-dev-overlay-11.1.1.tgz#3cd99202a85412bada8ba9c8e3f4cf7c19294b24"
96-
integrity sha512-CXc/A0DbSk5VXYu4+zr0fHm52Zh/LhPlLyVPEctJOZL64ccxkls5xGoXvgolJCku9L0pLjJzvdfAmhNLOp5dyw==
93+
"@next/react-dev-overlay@11.1.3":
94+
version "11.1.3"
95+
resolved "https://registry.yarnpkg.com/@next/react-dev-overlay/-/react-dev-overlay-11.1.3.tgz#5d08336931e48ebdb07d82b566223d0ee5941d2a"
96+
integrity sha512-zIwtMliSUR+IKl917ToFNB+0fD7bI5kYMdjHU/UEKpfIXAZPnXRHHISCvPDsczlr+bRsbjlUFW1CsNiuFedeuQ==
9797
dependencies:
9898
"@babel/code-frame" "7.12.11"
9999
anser "1.4.9"
@@ -107,30 +107,30 @@
107107
stacktrace-parser "0.1.10"
108108
strip-ansi "6.0.0"
109109

110-
"@next/react-refresh-utils@11.1.1":
111-
version "11.1.1"
112-
resolved "https://registry.yarnpkg.com/@next/react-refresh-utils/-/react-refresh-utils-11.1.1.tgz#8d1a5432a53c9f987503d5ab07d3241230afb33f"
113-
integrity sha512-j186y+lWc8BHAuysAWvlOqO9Bp7E3BLK/d/Ju3W2sP5BCH5ZLyLG/p308zSy/O0MGTag0B038ZA1dCy/msouRQ==
110+
"@next/react-refresh-utils@11.1.3":
111+
version "11.1.3"
112+
resolved "https://registry.yarnpkg.com/@next/react-refresh-utils/-/react-refresh-utils-11.1.3.tgz#fc2c1a4f2403db1a0179d31caa0a4cc811b8ab58"
113+
integrity sha512-144kD8q2nChw67V3AJJlPQ6NUJVFczyn10bhTynn9o2rY5DEnkzuBipcyMuQl2DqfxMkV7sn+yOCOYbrLCk9zg==
114114

115-
"@next/swc-darwin-arm64@11.1.1":
116-
version "11.1.1"
117-
resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-11.1.1.tgz#ea9a76bcff00945df29a81bc43b3b22dd0a6cb53"
118-
integrity sha512-KyB0aLpfQ+B2dsyGYpkM0ZwK3PV0t4C4b9yjgQc1VoTVnIjzXdDPnNOuVvmD849ZNOHfj3x8e2rlbxkj0lPm3A==
115+
"@next/swc-darwin-arm64@11.1.3":
116+
version "11.1.3"
117+
resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-11.1.3.tgz#062eb7871048fdb313304e42ace5f91402dbc39f"
118+
integrity sha512-TwP4krjhs+uU9pesDYCShEXZrLSbJr78p12e7XnLBBaNf20SgWLlVmQUT9gX9KbWan5V0sUbJfmcS8MRNHgYuA==
119119

120-
"@next/swc-darwin-x64@11.1.1":
121-
version "11.1.1"
122-
resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-11.1.1.tgz#95838e9116897ae734d02fdbbfa601b6f52adaf3"
123-
integrity sha512-B3ZXgrGx0bQplbrk2oggPjKPPsmyg8Fl0PJLMTVQ+erQ8g1m5QzyS9P6tB3SiIZa180JgENuguTHlVK5qEj4UA==
120+
"@next/swc-darwin-x64@11.1.3":
121+
version "11.1.3"
122+
resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-11.1.3.tgz#8bd515768d02e4c1e0cd80d33f3f29456ee890ee"
123+
integrity sha512-ZSWmkg/PxccHFNUSeBdrfaH8KwSkoeUtewXKvuYYt7Ph0yRsbqSyNIvhUezDua96lApiXXq6EL2d1THfeWomvw==
124124

125-
"@next/swc-linux-x64-gnu@11.1.1":
126-
version "11.1.1"
127-
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-11.1.1.tgz#42c4973213a880977ebdfad01474217d7d71e8c2"
128-
integrity sha512-qvZL7gSKF+E+GZ3L1XiTnE3cOh9rk0wkqimT/q+wwcZA4E720Lu4lrT79I3HPuj6i/JPgGvmNskcnYrDeaoFaw==
125+
"@next/swc-linux-x64-gnu@11.1.3":
126+
version "11.1.3"
127+
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-11.1.3.tgz#40030577e6ee272afb0080b45468bea73208f46d"
128+
integrity sha512-PrTBN0iZudAuj4jSbtXcdBdmfpaDCPIneG4Oms4zcs93KwMgLhivYW082Mvlgx9QVEiRm7+RkFpIVtG/i7JitA==
129129

130-
"@next/swc-win32-x64-msvc@11.1.1":
131-
version "11.1.1"
132-
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-11.1.1.tgz#1ffcbd01a0155fa8558f7aefffea1066e9bebe74"
133-
integrity sha512-jhnCiA1De1L+kA0gmHG1AJijHoxOcrETWziDWy8fcqSrM1NlC4aJ5Mnu6k0QMcM9MnmXTA4TQZOEv3kF7vhJUQ==
130+
"@next/swc-win32-x64-msvc@11.1.3":
131+
version "11.1.3"
132+
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-11.1.3.tgz#2951cbc127f6ea57032a241fb94439cddb5d2482"
133+
integrity sha512-mRwbscVjRoHk+tDY7XbkT5d9FCwujFIQJpGp0XNb1i5OHCSDO8WW/C9cLEWS4LxKRbIZlTLYg1MTXqLQkvva8w==
134134

135135
"@node-rs/helper@1.2.1":
136136
version "1.2.1"
@@ -1090,17 +1090,17 @@ native-url@0.3.4:
10901090
dependencies:
10911091
querystring "^0.2.0"
10921092

1093-
next@11.1.1:
1094-
version "11.1.1"
1095-
resolved "https://registry.yarnpkg.com/next/-/next-11.1.1.tgz#ca15c6d6b4b4bf8c3e859f7fc4f9657ce59bcb63"
1096-
integrity sha512-vfLJDkwAHsZUho5R1K4w49nfYhftUMWNmeNSjCtulOvnRBuEFb7ROyRZOQk7f29rMz02eLQrPZ9yiAmPsexL2g==
1093+
next@11.1.3:
1094+
version "11.1.3"
1095+
resolved "https://registry.yarnpkg.com/next/-/next-11.1.3.tgz#0226b283cb9890e446aea759db8a867de2b279ef"
1096+
integrity sha512-ud/gKmnKQ8wtHC+pd1ZiqPRa7DdgulPkAk94MbpsspfNliwZkYs9SIYWhlLSyg+c661LzdUI2nZshvrtggSYWA==
10971097
dependencies:
10981098
"@babel/runtime" "7.15.3"
10991099
"@hapi/accept" "5.0.2"
1100-
"@next/env" "11.1.1"
1101-
"@next/polyfill-module" "11.1.1"
1102-
"@next/react-dev-overlay" "11.1.1"
1103-
"@next/react-refresh-utils" "11.1.1"
1100+
"@next/env" "11.1.3"
1101+
"@next/polyfill-module" "11.1.3"
1102+
"@next/react-dev-overlay" "11.1.3"
1103+
"@next/react-refresh-utils" "11.1.3"
11041104
"@node-rs/helper" "1.2.1"
11051105
assert "2.0.0"
11061106
ast-types "0.13.2"
@@ -1138,18 +1138,18 @@ next@11.1.1:
11381138
stream-browserify "3.0.0"
11391139
stream-http "3.1.1"
11401140
string_decoder "1.3.0"
1141-
styled-jsx "4.0.0"
1141+
styled-jsx "4.0.1"
11421142
timers-browserify "2.0.12"
11431143
tty-browserify "0.0.1"
11441144
use-subscription "1.5.1"
11451145
util "0.12.4"
11461146
vm-browserify "1.1.2"
11471147
watchpack "2.1.1"
11481148
optionalDependencies:
1149-
"@next/swc-darwin-arm64" "11.1.1"
1150-
"@next/swc-darwin-x64" "11.1.1"
1151-
"@next/swc-linux-x64-gnu" "11.1.1"
1152-
"@next/swc-win32-x64-msvc" "11.1.1"
1149+
"@next/swc-darwin-arm64" "11.1.3"
1150+
"@next/swc-darwin-x64" "11.1.3"
1151+
"@next/swc-linux-x64-gnu" "11.1.3"
1152+
"@next/swc-win32-x64-msvc" "11.1.3"
11531153

11541154
node-fetch@2.6.1:
11551155
version "2.6.1"
@@ -1660,10 +1660,10 @@ strip-ansi@6.0.0:
16601660
dependencies:
16611661
ansi-regex "^5.0.0"
16621662

1663-
styled-jsx@4.0.0:
1664-
version "4.0.0"
1665-
resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-4.0.0.tgz#f7b90e7889d0a4f4635f8d1ae9ac32f3acaedc57"
1666-
integrity sha512-2USeoWMoJ/Lx5s2y1PxuvLy/cz2Yrr8cTySV3ILHU1Vmaw1bnV7suKdblLPjnyhMD+qzN7B1SWyh4UZTARn/WA==
1663+
styled-jsx@4.0.1:
1664+
version "4.0.1"
1665+
resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-4.0.1.tgz#ae3f716eacc0792f7050389de88add6d5245b9e9"
1666+
integrity sha512-Gcb49/dRB1k8B4hdK8vhW27Rlb2zujCk1fISrizCcToIs+55B4vmUM0N9Gi4nnVfFZWe55jRdWpAqH1ldAKWvQ==
16671667
dependencies:
16681668
"@babel/plugin-syntax-jsx" "7.14.5"
16691669
"@babel/types" "7.15.0"

playground/.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node_modules
2-
.cache
2+
.parcel-cache
33
dist

playground/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818

1919
<body>
2020
<div id="root"></div>
21-
<script src="./index.tsx"></script>
21+
<script type="module" src="./index.tsx"></script>
2222
</body>
2323
</html>

playground/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "playground",
33
"version": "1.0.0",
4-
"main": "index.js",
54
"license": "MIT",
65
"private": true,
76
"homepage": "https://devrnt.github.io/react-use-wizard/",
@@ -25,7 +24,7 @@
2524
"@babel/preset-env": "7.13.12",
2625
"@types/react": "^17.0.3",
2726
"@types/react-dom": "^17.0.2",
28-
"parcel": "^1.12.4",
27+
"parcel": "^2.0.1",
2928
"typescript": "^4.2.3"
3029
}
3130
}

0 commit comments

Comments
 (0)