├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── babel.config.js
├── package.json
├── prettier.config.js
├── public
└── index.html
├── src
├── App.test.tsx
├── App.tsx
├── index.tsx
├── lib-ts
│ └── index.tsx
├── react-app-env.d.ts
└── style.css
├── tsconfig.json
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | node_modules/
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 | /src/dist
25 | /src/lib
26 | .babelrc
27 | debug.log
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Hello, contributor!
2 |
3 | Thanks for your interest in react-step-builder.
4 |
5 | In order to make any type of contribution to the library, please follow steps below:
6 |
7 | 1. Fork the repository and clone it in your local machine.
8 |
9 | 2. To add a feature the only file you want to interact is `lib-ts/index.tsx`. Make required changes in the file.
10 |
11 | 3. Add your test cases in `App.test.tsx` file.
12 |
13 | 4. Run `npm run test` or `yarn test` to make sure your tests are passing.
14 |
15 | 5. If everything looks good, create a Pull Request along with the library and test updates as well as updated CRA app that you did your manual testing in.
16 |
17 | 6. When your PR is accepted, library maintainer will download your code, build it, version it, and publish on the NPM registry.
18 |
19 | 7. Thank you for your time.
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Samet Mutevelli
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React Step Builder  [](https://www.npmjs.com/package/react-step-builder)
2 |
3 | React Step Builder is a headless, unopinionated, multi-step interface builder.
4 |
5 | > Version 3 introduces some breaking changes. If you are upgrading from earlier versions, please read the documentation carefully.
6 |
7 | > Global state management methods are removed from the library. React Step Builder will only focus on building step-by-step interfaces starting from version 3. You may use a state management tool of your choice. If this is bad news for you, I am sorry 🙇♂️
8 |
9 |
10 |
11 | # Installation
12 |
13 | Using [npm](https://www.npmjs.com/):
14 |
15 | ```
16 | npm install react-step-builder
17 | ```
18 |
19 |
20 |
21 | # Usage
22 |
23 | Example:
24 |
25 | ```jsx
26 | import { Steps, StepsProvider, useSteps } from "react-step-builder";
27 |
28 | const App = () => {
29 | return (
30 |
31 |
32 |
33 | );
34 | };
35 |
36 | const MySteps = () => {
37 | const { next, prev } = useSteps();
38 |
39 | return (
40 |
41 |
42 |
Step 1
43 |
44 |
45 |
Step 2
46 |
47 |
48 |
Step 3
49 |
50 |
51 | );
52 | };
53 |
54 | export default App;
55 | ```
56 |
57 | # Documentation
58 |
59 | ### **``**
60 |
61 | A component whose each direct sibling is treated as a step. **Do not add anything else inside `Steps` component** as they will be treated as a separate step.
62 |
63 | ❌ Incorrect:
64 |
65 | ```jsx
66 |
67 |
68 |
69 |
70 |
71 | ```
72 |
73 | ✅ Correct:
74 |
75 | ```jsx
76 |
77 |
78 |
79 |
80 |
81 |
82 | ```
83 |
84 | This reason for this method is due to React's _composition over inheritance_ principle. It also allows you to manage your state easily in the parent component.
85 |
86 | | Property | Type | Description |
87 | | -------------- | ------------ | ---------------------------------------------------------- |
88 | | `onStepChange` | `() => void` | Runs on every step change. Does not run on initial render. |
89 |
90 |
91 |