reactjs-multi-stepper 1.2.1 โ†’ 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,9 +12,12 @@ It allows you to create step-based workflows such as onboarding, multi-step form
12
12
  ## ๐Ÿš€ Features
13
13
 
14
14
  - โœ… Easy to use and integrate into any React project
15
- - ๐ŸŽจ Fully customizable step styles (active, completed)
15
+ - ๐ŸŽจ Fully customizable step styles (active, completed, loading, error)
16
16
  - โšก Built with **TypeScript** for type safety
17
- - ๐Ÿงฉ Includes context + hooks for flexible state management
17
+ - ๐Ÿงฉ Context-based state management with hooks
18
+ - ๐Ÿ”„ Built-in step validation and status management
19
+ - ๐ŸŽฏ Support for async operations with loading states
20
+ - โŒ Error handling for failed step validations
18
21
  - ๐Ÿงช Tested with **Vitest** + **React Testing Library**
19
22
 
20
23
  ---
@@ -29,36 +32,171 @@ yarn add react-multi-stepper
29
32
 
30
33
  ---
31
34
 
32
- ## ๐Ÿ”จ Usage
35
+ ## ๐Ÿ”จ Basic Usage
36
+
37
+ ### 1. Wrap your app with MultiStepperProvider
33
38
 
34
39
  ```javascript
35
40
  import React from "react";
36
- import { MultiStepper } from "react-multi-stepper";
41
+ import { MultiStepperProvider, MultiStepper, useMultiStepper } from "react-multi-stepper";
37
42
 
38
- const steps = [
39
- { title: "Step 1", description: "Personal Info", active: true, completed: false },
40
- { title: "Step 2", description: "Address Details", active: false, completed: false },
41
- { title: "Step 3", description: "Review", active: false, completed: false },
42
- ];
43
+ function App() {
44
+ return (
45
+ <MultiStepperProvider steppers={[
46
+ {
47
+ id: 1,
48
+ title: "Personal Info",
49
+ description: "Enter your personal details",
50
+ children: <PersonalInfoForm />
51
+ },
52
+ {
53
+ id: 2,
54
+ title: "Address",
55
+ description: "Enter your address details",
56
+ children: <AddressForm />
57
+ },
58
+ {
59
+ id: 3,
60
+ title: "Review",
61
+ description: "Review and confirm",
62
+ children: <ReviewStep />
63
+ }
64
+ ]}>
65
+ <MyMultiStepper />
66
+ </MultiStepperProvider>
67
+ );
68
+ }
69
+ ```
70
+
71
+ ### 2. Create your stepper component
43
72
 
44
- export default function App() {
45
- const handleNext = (currentStep:number) => {
46
- console.log("Next step clicked",currentStep);
73
+ ```javascript
74
+ function MyMultiStepper() {
75
+ const { handleNextStep, setStepStatus } = useMultiStepper();
76
+
77
+ const validateAndProceed = async () => {
78
+ // Set loading state
79
+ setStepStatus("loading");
80
+
81
+ try {
82
+ // Simulate async validation
83
+ await validateCurrentStep();
84
+
85
+ // Mark as completed and move to next
86
+ setStepStatus("completed");
87
+ handleNextStep();
88
+ } catch (error) {
89
+ // Show error state
90
+ setStepStatus("error");
91
+ }
47
92
  };
48
93
 
49
- return (
50
- <MultiStepper steps={steps} onClickNext={handleNext} />
51
- );
94
+ return <MultiStepper onClickNext={validateAndProceed} />;
95
+ }
96
+ ```
97
+
98
+ ---
99
+
100
+ ## ๐Ÿ”ง Advanced Usage
101
+
102
+ ### Step Validation with Custom Logic
103
+
104
+ ```javascript
105
+ function ReactMultiStepper() {
106
+ const { handleNextStep, setStepStatus, currentStep } = useMultiStepper();
107
+
108
+ const validateStepContent = async () => {
109
+ setStepStatus("loading");
110
+
111
+ try {
112
+ // Custom validation based on current step
113
+ switch (currentStep) {
114
+ case 1:
115
+ await validatePersonalInfo();
116
+ break;
117
+ case 2:
118
+ await validateAddress();
119
+ break;
120
+ case 3:
121
+ await submitForm();
122
+ break;
123
+ }
124
+
125
+ setStepStatus("completed");
126
+ handleNextStep();
127
+ } catch (error) {
128
+ setStepStatus("error");
129
+ console.error("Step validation failed:", error);
130
+ }
131
+ };
132
+
133
+ return <MultiStepper onClickNext={validateStepContent} />;
52
134
  }
53
135
  ```
54
136
 
137
+ ### Custom Step Content
138
+
139
+ ```javascript
140
+ const steppers = [
141
+ {
142
+ id: 1,
143
+ title: "Step One",
144
+ description: "Step one description",
145
+ children: (
146
+ <div className="custom-step">
147
+ <h3>Custom Step Content</h3>
148
+ <form>
149
+ <input type="text" placeholder="Enter data..." />
150
+ </form>
151
+ </div>
152
+ )
153
+ },
154
+ // ... more steps
155
+ ];
156
+ ```
157
+
55
158
  ---
56
159
 
57
160
  ## ๐Ÿงฉ API Reference
58
161
 
162
+ ### MultiStepperProvider Props
163
+
164
+ | Prop | Type | Required | Description |
165
+ | ------------- | ------------ | -------- | -------------------------------------------------------------- |
166
+ | `steppers` | `StepperType[]` | โœ… | Array of step configurations |
167
+ | `children` | `ReactNode` | โœ… | Child components that will have access to stepper context |
168
+
169
+ ### StepperType Interface
170
+
171
+ | Property | Type | Required | Description |
172
+ | ------------- | ------------ | -------- | -------------------------------------------------------------- |
173
+ | `id` | `number` | โœ… | Unique identifier for the step |
174
+ | `title` | `string` | โœ… | Step title displayed in the stepper |
175
+ | `description` | `string` | โœ… | Step description or subtitle |
176
+ | `children` | `ReactNode` | โœ… | Content to render for this step |
177
+
59
178
  ### MultiStepper Props
60
179
 
61
- | Prop | Type | Required | Description |
180
+ | Prop | Type | Required | Description |
62
181
  | ------------- | ------------ | -------- | -------------------------------------------------------------- |
63
- | `steps` | `StepType[]` | โœ… | Array of steps (`title`, `description`, `active`, `completed`) |
64
- | `onClickNext` | `(currentStep:number) => void` | โœ… | Callback triggered when the "Next" button is clicked |
182
+ | `onClickNext` | `() => void` | โœ… | Callback triggered when the "Next" button is clicked |
183
+
184
+ ### useMultiStepper Hook
185
+
186
+ | Method/Property | Type | Description |
187
+ | ------------- | ------------ | -------------------------------------------------------------- |
188
+ | `handleNextStep` | `() => void` | Move to the next step |
189
+ | `setStepStatus` | `(status: StepStatus) => void` | Update current step status |
190
+ | `currentStep` | `number` | Current active step number |
191
+ | `totalSteps` | `number` | Total number of steps |
192
+
193
+ ### Step Status Types
194
+
195
+ | Status | Description |
196
+ | ------------- | -------------------------------------------------------------- |
197
+ | `"active"` | Step is currently active and ready for user interaction |
198
+ | `"loading"` | Step is processing/validating (shows loading indicator) |
199
+ | `"completed"` | Step has been successfully completed |
200
+ | `"error"` | Step has validation errors or failed processing |
201
+
202
+ ---
@@ -1,5 +1,5 @@
1
- import ce, { createContext as le, useContext as ie, useState as W, useEffect as ue, useCallback as C, useMemo as V, Fragment as z } from "react";
2
- import './index.css';var S = { exports: {} }, R = {};
1
+ import ce, { createContext as le, useContext as ie, useState as q, useEffect as ue, useCallback as k, useMemo as G, Fragment as $ } from "react";
2
+ import './index.css';var g = { exports: {} }, R = {};
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.js
@@ -9,27 +9,27 @@ import './index.css';var S = { exports: {} }, R = {};
9
9
  * This source code is licensed under the MIT license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
- var U;
12
+ var J;
13
13
  function fe() {
14
- if (U) return R;
15
- U = 1;
16
- var t = Symbol.for("react.transitional.element"), s = Symbol.for("react.fragment");
17
- function o(v, c, l) {
18
- var m = null;
19
- if (l !== void 0 && (m = "" + l), c.key !== void 0 && (m = "" + c.key), "key" in c) {
20
- l = {};
21
- for (var p in c)
22
- p !== "key" && (l[p] = c[p]);
23
- } else l = c;
24
- return c = l.ref, {
14
+ if (J) return R;
15
+ J = 1;
16
+ var t = Symbol.for("react.transitional.element"), o = Symbol.for("react.fragment");
17
+ function n(h, l, i) {
18
+ var u = null;
19
+ if (i !== void 0 && (u = "" + i), l.key !== void 0 && (u = "" + l.key), "key" in l) {
20
+ i = {};
21
+ for (var x in l)
22
+ x !== "key" && (i[x] = l[x]);
23
+ } else i = l;
24
+ return l = i.ref, {
25
25
  $$typeof: t,
26
- type: v,
27
- key: m,
28
- ref: c !== void 0 ? c : null,
29
- props: l
26
+ type: h,
27
+ key: u,
28
+ ref: l !== void 0 ? l : null,
29
+ props: i
30
30
  };
31
31
  }
32
- return R.Fragment = s, R.jsx = o, R.jsxs = o, R;
32
+ return R.Fragment = o, R.jsx = n, R.jsxs = n, R;
33
33
  }
34
34
  var j = {};
35
35
  /**
@@ -41,16 +41,16 @@ var j = {};
41
41
  * This source code is licensed under the MIT license found in the
42
42
  * LICENSE file in the root directory of this source tree.
43
43
  */
44
- var q;
44
+ var V;
45
45
  function de() {
46
- return q || (q = 1, process.env.NODE_ENV !== "production" && function() {
46
+ return V || (V = 1, process.env.NODE_ENV !== "production" && function() {
47
47
  function t(e) {
48
48
  if (e == null) return null;
49
49
  if (typeof e == "function")
50
50
  return e.$$typeof === se ? null : e.displayName || e.name || null;
51
51
  if (typeof e == "string") return e;
52
52
  switch (e) {
53
- case g:
53
+ case O:
54
54
  return "Fragment";
55
55
  case B:
56
56
  return "Profiler";
@@ -67,7 +67,7 @@ function de() {
67
67
  switch (typeof e.tag == "number" && console.error(
68
68
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
69
69
  ), e.$$typeof) {
70
- case X:
70
+ case v:
71
71
  return "Portal";
72
72
  case Q:
73
73
  return (e.displayName || "Context") + ".Provider";
@@ -87,28 +87,28 @@ function de() {
87
87
  }
88
88
  return null;
89
89
  }
90
- function s(e) {
90
+ function o(e) {
91
91
  return "" + e;
92
92
  }
93
- function o(e) {
93
+ function n(e) {
94
94
  try {
95
- s(e);
95
+ o(e);
96
96
  var r = !1;
97
97
  } catch {
98
98
  r = !0;
99
99
  }
100
100
  if (r) {
101
101
  r = console;
102
- var a = r.error, u = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
102
+ var a = r.error, d = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
103
103
  return a.call(
104
104
  r,
105
105
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
106
- u
107
- ), s(e);
106
+ d
107
+ ), o(e);
108
108
  }
109
109
  }
110
- function v(e) {
111
- if (e === g) return "<>";
110
+ function h(e) {
111
+ if (e === O) return "<>";
112
112
  if (typeof e == "object" && e !== null && e.$$typeof === F)
113
113
  return "<...>";
114
114
  try {
@@ -118,23 +118,23 @@ function de() {
118
118
  return "<...>";
119
119
  }
120
120
  }
121
- function c() {
122
- var e = P.A;
121
+ function l() {
122
+ var e = A.A;
123
123
  return e === null ? null : e.getOwner();
124
124
  }
125
- function l() {
125
+ function i() {
126
126
  return Error("react-stack-top-frame");
127
127
  }
128
- function m(e) {
129
- if (Y.call(e, "key")) {
128
+ function u(e) {
129
+ if (M.call(e, "key")) {
130
130
  var r = Object.getOwnPropertyDescriptor(e, "key").get;
131
131
  if (r && r.isReactWarning) return !1;
132
132
  }
133
133
  return e.key !== void 0;
134
134
  }
135
- function p(e, r) {
135
+ function x(e, r) {
136
136
  function a() {
137
- $ || ($ = !0, console.error(
137
+ I || (I = !0, console.error(
138
138
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
139
139
  r
140
140
  ));
@@ -146,16 +146,16 @@ function de() {
146
146
  }
147
147
  function T() {
148
148
  var e = t(this.type);
149
- return M[e] || (M[e] = !0, console.error(
149
+ return D[e] || (D[e] = !0, console.error(
150
150
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
151
151
  )), e = this.props.ref, e !== void 0 ? e : null;
152
152
  }
153
- function k(e, r, a, u, E, x, A, w) {
154
- return a = x.ref, e = {
155
- $$typeof: h,
153
+ function S(e, r, a, d, E, b, y, C) {
154
+ return a = b.ref, e = {
155
+ $$typeof: c,
156
156
  type: e,
157
157
  key: r,
158
- props: x,
158
+ props: b,
159
159
  _owner: E
160
160
  }, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
161
161
  enumerable: !1,
@@ -174,218 +174,234 @@ function de() {
174
174
  configurable: !1,
175
175
  enumerable: !1,
176
176
  writable: !0,
177
- value: A
177
+ value: y
178
178
  }), Object.defineProperty(e, "_debugTask", {
179
179
  configurable: !1,
180
180
  enumerable: !1,
181
181
  writable: !0,
182
- value: w
182
+ value: C
183
183
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
184
184
  }
185
- function d(e, r, a, u, E, x, A, w) {
186
- var f = r.children;
187
- if (f !== void 0)
188
- if (u)
189
- if (oe(f)) {
190
- for (u = 0; u < f.length; u++)
191
- b(f[u]);
192
- Object.freeze && Object.freeze(f);
185
+ function N(e, r, a, d, E, b, y, C) {
186
+ var m = r.children;
187
+ if (m !== void 0)
188
+ if (d)
189
+ if (oe(m)) {
190
+ for (d = 0; d < m.length; d++)
191
+ f(m[d]);
192
+ Object.freeze && Object.freeze(m);
193
193
  } else
194
194
  console.error(
195
195
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
196
196
  );
197
- else b(f);
198
- if (Y.call(r, "key")) {
199
- f = t(e);
197
+ else f(m);
198
+ if (M.call(r, "key")) {
199
+ m = t(e);
200
200
  var _ = Object.keys(r).filter(function(ae) {
201
201
  return ae !== "key";
202
202
  });
203
- u = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", L[f + u] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
203
+ d = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", U[m + d] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
204
204
  `A props object containing a "key" prop is being spread into JSX:
205
205
  let props = %s;
206
206
  <%s {...props} />
207
207
  React keys must be passed directly to JSX without using spread:
208
208
  let props = %s;
209
209
  <%s key={someKey} {...props} />`,
210
- u,
211
- f,
210
+ d,
211
+ m,
212
212
  _,
213
- f
214
- ), L[f + u] = !0);
213
+ m
214
+ ), U[m + d] = !0);
215
215
  }
216
- if (f = null, a !== void 0 && (o(a), f = "" + a), m(r) && (o(r.key), f = "" + r.key), "key" in r) {
216
+ if (m = null, a !== void 0 && (n(a), m = "" + a), u(r) && (n(r.key), m = "" + r.key), "key" in r) {
217
217
  a = {};
218
- for (var y in r)
219
- y !== "key" && (a[y] = r[y]);
218
+ for (var Y in r)
219
+ Y !== "key" && (a[Y] = r[Y]);
220
220
  } else a = r;
221
- return f && p(
221
+ return m && x(
222
222
  a,
223
223
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
224
- ), k(
224
+ ), S(
225
225
  e,
226
- f,
227
- x,
226
+ m,
227
+ b,
228
228
  E,
229
- c(),
229
+ l(),
230
230
  a,
231
- A,
232
- w
231
+ y,
232
+ C
233
233
  );
234
234
  }
235
- function b(e) {
236
- typeof e == "object" && e !== null && e.$$typeof === h && e._store && (e._store.validated = 1);
235
+ function f(e) {
236
+ typeof e == "object" && e !== null && e.$$typeof === c && e._store && (e._store.validated = 1);
237
237
  }
238
- var i = ce, h = Symbol.for("react.transitional.element"), X = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), H = Symbol.for("react.strict_mode"), B = Symbol.for("react.profiler"), Z = Symbol.for("react.consumer"), Q = Symbol.for("react.context"), K = Symbol.for("react.forward_ref"), ee = Symbol.for("react.suspense"), re = Symbol.for("react.suspense_list"), te = Symbol.for("react.memo"), F = Symbol.for("react.lazy"), ne = Symbol.for("react.activity"), se = Symbol.for("react.client.reference"), P = i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Y = Object.prototype.hasOwnProperty, oe = Array.isArray, O = console.createTask ? console.createTask : function() {
238
+ var p = ce, c = Symbol.for("react.transitional.element"), v = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), H = Symbol.for("react.strict_mode"), B = Symbol.for("react.profiler"), Z = Symbol.for("react.consumer"), Q = Symbol.for("react.context"), K = Symbol.for("react.forward_ref"), ee = Symbol.for("react.suspense"), re = Symbol.for("react.suspense_list"), te = Symbol.for("react.memo"), F = Symbol.for("react.lazy"), ne = Symbol.for("react.activity"), se = Symbol.for("react.client.reference"), A = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, M = Object.prototype.hasOwnProperty, oe = Array.isArray, w = console.createTask ? console.createTask : function() {
239
239
  return null;
240
240
  };
241
- i = {
241
+ p = {
242
242
  react_stack_bottom_frame: function(e) {
243
243
  return e();
244
244
  }
245
245
  };
246
- var $, M = {}, I = i.react_stack_bottom_frame.bind(
247
- i,
248
- l
249
- )(), D = O(v(l)), L = {};
250
- j.Fragment = g, j.jsx = function(e, r, a, u, E) {
251
- var x = 1e4 > P.recentlyCreatedOwnerStacks++;
252
- return d(
246
+ var I, D = {}, L = p.react_stack_bottom_frame.bind(
247
+ p,
248
+ i
249
+ )(), W = w(h(i)), U = {};
250
+ j.Fragment = O, j.jsx = function(e, r, a, d, E) {
251
+ var b = 1e4 > A.recentlyCreatedOwnerStacks++;
252
+ return N(
253
253
  e,
254
254
  r,
255
255
  a,
256
256
  !1,
257
- u,
257
+ d,
258
258
  E,
259
- x ? Error("react-stack-top-frame") : I,
260
- x ? O(v(e)) : D
259
+ b ? Error("react-stack-top-frame") : L,
260
+ b ? w(h(e)) : W
261
261
  );
262
- }, j.jsxs = function(e, r, a, u, E) {
263
- var x = 1e4 > P.recentlyCreatedOwnerStacks++;
264
- return d(
262
+ }, j.jsxs = function(e, r, a, d, E) {
263
+ var b = 1e4 > A.recentlyCreatedOwnerStacks++;
264
+ return N(
265
265
  e,
266
266
  r,
267
267
  a,
268
268
  !0,
269
- u,
269
+ d,
270
270
  E,
271
- x ? Error("react-stack-top-frame") : I,
272
- x ? O(v(e)) : D
271
+ b ? Error("react-stack-top-frame") : L,
272
+ b ? w(h(e)) : W
273
273
  );
274
274
  };
275
275
  }()), j;
276
276
  }
277
- var J;
277
+ var z;
278
278
  function me() {
279
- return J || (J = 1, process.env.NODE_ENV === "production" ? S.exports = fe() : S.exports = de()), S.exports;
279
+ return z || (z = 1, process.env.NODE_ENV === "production" ? g.exports = fe() : g.exports = de()), g.exports;
280
280
  }
281
- var n = me();
282
- const G = le(
281
+ var s = me();
282
+ const X = le(
283
283
  void 0
284
- ), N = () => {
285
- const t = ie(G);
284
+ ), P = () => {
285
+ const t = ie(X);
286
286
  if (!t)
287
287
  throw new Error(
288
288
  "useMultiStepperForm must be used within a MultiStepperProvider"
289
289
  );
290
290
  return t;
291
- }, pe = ({ children: t, steppers: s }) => {
292
- const [o, v] = W(0), [c, l] = W([]);
291
+ }, Ee = ({ children: t, steppers: o }) => {
292
+ const [n, h] = q(0), [l, i] = q([]);
293
293
  ue(() => {
294
- if (s.length) {
295
- const d = [...s];
296
- d[0].active = !0, l(d);
294
+ if (o.length) {
295
+ const f = [...o];
296
+ f[0].active = !0, i(f);
297
297
  }
298
- }, [s.length]);
299
- const m = C((d) => {
300
- l((b) => {
301
- const i = [...b];
302
- if (d > b.length - 1) return b;
303
- i[o] && (i[o] = { ...i[o], active: !1 }), i[d] && (i[d] = { ...i[d], active: !0 });
304
- for (let h = 0; h < d; h++)
305
- i[h] = { ...i[h], completed: !0 };
306
- for (let h = d; h < i.length; h++)
307
- i[h] = { ...i[h], completed: !1 };
308
- return i;
309
- }), v(d);
310
- }, [o]), p = C(() => {
311
- o < c.length - 1 ? m(o + 1) : l((d) => {
312
- const b = [...d];
313
- return b[o] = { ...b[o], completed: !0 }, b;
298
+ }, [o, o.length]);
299
+ const u = k((f) => {
300
+ i((p) => {
301
+ const c = [...p];
302
+ if (f > p.length - 1) return p;
303
+ c[n] && (c[n] = { ...c[n], active: !1 }), c[f] && (c[f] = { ...c[f], active: !0 });
304
+ for (let v = 0; v < f; v++)
305
+ c[v] = { ...c[v], completed: !0 };
306
+ for (let v = f; v < c.length; v++)
307
+ c[v] = { ...c[v], completed: !1 };
308
+ return c;
309
+ }), h(f);
310
+ }, [n]), x = k(() => {
311
+ n < l.length - 1 ? u(n + 1) : i((f) => {
312
+ const p = [...f];
313
+ return p[n] = { ...p[n], completed: !0 }, p;
314
314
  });
315
- }, [o, c.length, m]), T = C(() => {
316
- o > 0 && m(o - 1);
317
- }, [o, m]), k = V(
315
+ }, [n, l.length, u]), T = k(() => {
316
+ n > 0 && u(n - 1);
317
+ }, [n, u]), S = k(
318
+ (f) => {
319
+ i((p) => {
320
+ const c = [...p];
321
+ return c[n] && (c[n] = {
322
+ ...c[n],
323
+ error: !1,
324
+ loading: !1,
325
+ active: !1,
326
+ completed: !1
327
+ }, c[n][f] = !0), c;
328
+ });
329
+ },
330
+ [n]
331
+ ), N = G(
318
332
  () => ({
319
- currentStep: o,
320
- steps: c,
321
- handleNextStep: p,
333
+ currentStep: n,
334
+ steps: l,
335
+ handleNextStep: x,
322
336
  handlePrevStep: T,
323
- updateSteps: m
337
+ updateSteps: u,
338
+ setStepStatus: S
324
339
  }),
325
- [o, c, p, T, m]
340
+ [n, l, x, T, u, S]
326
341
  );
327
- return /* @__PURE__ */ n.jsx(G.Provider, { value: k, children: t });
328
- }, ve = ({
329
- step: t,
330
- index: s
331
- }) => {
332
- const { steps: o } = N();
333
- return o.length ? t.loading ? /* @__PURE__ */ n.jsx("div", { className: "step step-loading", children: /* @__PURE__ */ n.jsx("div", { className: "spinner", role: "status", "aria-label": "Loading" }) }) : t.error ? /* @__PURE__ */ n.jsx("div", { className: "step step-error", children: t.icon ?? /* @__PURE__ */ n.jsx("span", { className: "text-white", children: "โœ—" }) }) : t.completed ? /* @__PURE__ */ n.jsx("div", { className: "step step-complete", children: t.icon ?? /* @__PURE__ */ n.jsx("span", { className: "text-white", children: "โœ“" }) }) : t.finshed ? /* @__PURE__ */ n.jsx("div", { className: "step step-complete", children: t.icon }) : t.active ? /* @__PURE__ */ n.jsx("div", { className: "step step-active", children: t.icon ?? /* @__PURE__ */ n.jsx("h2", { className: "text-white", children: s }) }) : /* @__PURE__ */ n.jsx("div", { className: "step step-default", children: t.icon ?? /* @__PURE__ */ n.jsx("h2", { children: s }) }) : /* @__PURE__ */ n.jsx(z, {});
334
- }, he = () => {
335
- const { steps: t } = N();
336
- return t.length ? /* @__PURE__ */ n.jsx("div", { className: "app-container", children: /* @__PURE__ */ n.jsx("ol", { className: "stepper-header", children: t.map((s, o) => /* @__PURE__ */ n.jsxs(
337
- "div",
338
- {
339
- className: `step-item ${s.active && "active"} ${s.completed && "complete"} `,
340
- children: [
341
- /* @__PURE__ */ n.jsx(ve, { index: o + 1, step: s }),
342
- /* @__PURE__ */ n.jsxs("div", { className: "step-text", children: [
343
- s.title && /* @__PURE__ */ n.jsx("h3", { className: "step-title", children: s.title }),
344
- s.description && /* @__PURE__ */ n.jsx("h3", { className: "step-description", children: s.description })
345
- ] })
346
- ]
347
- },
348
- o
349
- )) }) }) : /* @__PURE__ */ n.jsx(z, {});
350
- }, be = ({ onClickNext: t }) => {
351
- const { handleNextStep: s, handlePrevStep: o, currentStep: v, steps: c } = N(), l = v === c.length - 1, m = () => {
352
- c[v].completed || (s(), t(v + 1));
353
- }, p = V(() => ({
342
+ return /* @__PURE__ */ s.jsx(X.Provider, { value: N, children: t });
343
+ }, pe = () => {
344
+ const { steps: t, currentStep: o } = P();
345
+ return /* @__PURE__ */ s.jsx("div", { className: "stepper-content", children: t[o] && t[o].children && t[o].children });
346
+ }, ve = ({ onClickNext: t }) => {
347
+ const { handlePrevStep: o, currentStep: n, steps: h } = P(), l = n === h.length - 1, i = () => {
348
+ h[n].completed || t();
349
+ }, u = G(() => ({
354
350
  button: "stepper-button",
355
351
  fill: "stepper-button-fill"
356
352
  }), []);
357
- return /* @__PURE__ */ n.jsxs("div", { className: "stepper-footer", children: [
358
- /* @__PURE__ */ n.jsx(
353
+ return /* @__PURE__ */ s.jsxs("div", { className: "stepper-footer", children: [
354
+ /* @__PURE__ */ s.jsx(
359
355
  "button",
360
356
  {
361
357
  type: "button",
362
- className: p.button,
358
+ className: u.button,
363
359
  onClick: o,
364
- disabled: v < 0,
360
+ disabled: n < 0,
365
361
  children: "Prev"
366
362
  }
367
363
  ),
368
- /* @__PURE__ */ n.jsx(
364
+ /* @__PURE__ */ s.jsx(
369
365
  "button",
370
366
  {
371
367
  type: "button",
372
- className: `${l ? `${p.button} ${p.fill}` : p.button}`,
373
- onClick: m,
368
+ className: `${l ? `${u.button} ${u.fill}` : u.button}`,
369
+ onClick: i,
374
370
  children: l ? "Finish" : "Next"
375
371
  }
376
372
  )
377
373
  ] });
378
- }, xe = () => {
379
- const { steps: t, currentStep: s } = N();
380
- return /* @__PURE__ */ n.jsx("div", { className: "stepper-content", children: t[s] && t[s].children && t[s].children });
374
+ }, he = ({
375
+ step: t,
376
+ index: o
377
+ }) => {
378
+ const { steps: n } = P();
379
+ return n.length ? t.loading ? /* @__PURE__ */ s.jsx("div", { className: "step step-active", children: /* @__PURE__ */ s.jsx("div", { className: "spinner", role: "status", "aria-label": "Loading" }) }) : t.error ? /* @__PURE__ */ s.jsx("div", { className: "step step-error", children: t.icon ?? /* @__PURE__ */ s.jsx("span", { className: "text-white", children: "โœ—" }) }) : t.completed ? /* @__PURE__ */ s.jsx("div", { className: "step step-complete", children: t.icon ?? /* @__PURE__ */ s.jsx("span", { className: "text-white", children: "โœ“" }) }) : t.finshed ? /* @__PURE__ */ s.jsx("div", { className: "step step-complete", children: t.icon }) : t.active ? /* @__PURE__ */ s.jsx("div", { className: "step step-active", children: t.icon ?? /* @__PURE__ */ s.jsx("h2", { className: "text-white", children: o }) }) : /* @__PURE__ */ s.jsx("div", { className: "step step-default", children: t.icon ?? /* @__PURE__ */ s.jsx("h2", { children: o }) }) : /* @__PURE__ */ s.jsx($, {});
380
+ }, be = () => {
381
+ const { steps: t } = P();
382
+ return t.length ? /* @__PURE__ */ s.jsx("div", { className: "app-container", children: /* @__PURE__ */ s.jsx("ol", { className: "stepper-header", children: t.map((o, n) => /* @__PURE__ */ s.jsxs(
383
+ "div",
384
+ {
385
+ className: `step-item ${o.active && "active"} ${o.completed && "complete"} `,
386
+ children: [
387
+ /* @__PURE__ */ s.jsx(he, { index: n + 1, step: o }),
388
+ /* @__PURE__ */ s.jsxs("div", { className: "step-text", children: [
389
+ o.title && /* @__PURE__ */ s.jsx("h3", { className: "step-title", children: o.title }),
390
+ o.description && /* @__PURE__ */ s.jsx("h3", { className: "step-description", children: o.description })
391
+ ] })
392
+ ]
393
+ },
394
+ n
395
+ )) }) }) : /* @__PURE__ */ s.jsx($, {});
381
396
  }, _e = ({
382
- steps: t,
383
- onClickNext: s
384
- }) => t ? /* @__PURE__ */ n.jsxs(pe, { steppers: t, children: [
385
- /* @__PURE__ */ n.jsx(he, {}),
386
- /* @__PURE__ */ n.jsx(xe, {}),
387
- /* @__PURE__ */ n.jsx(be, { onClickNext: s })
388
- ] }) : /* @__PURE__ */ n.jsx(n.Fragment, {});
397
+ onClickNext: t
398
+ }) => /* @__PURE__ */ s.jsxs($, { children: [
399
+ /* @__PURE__ */ s.jsx(be, {}),
400
+ /* @__PURE__ */ s.jsx(pe, {}),
401
+ /* @__PURE__ */ s.jsx(ve, { onClickNext: t })
402
+ ] });
389
403
  export {
390
- _e as MultiStepper
404
+ _e as MultiStepper,
405
+ Ee as MultiStepperProvider,
406
+ P as useMultiStepper
391
407
  };
@@ -1,5 +1,5 @@
1
- (function(j,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],c):(j=typeof globalThis<"u"?globalThis:j||self,c(j["multi-stepper"]={},j.React))})(this,function(j,c){"use strict";var M=document.createElement("style");M.textContent=`:root{--color-primary: #0284c7;--color-primary-light: #38bdf8;--color-success: #16a34a;--color-error: #ef4444;--color-text: #111827;--color-text-light: #4b5563;--color-black: #000;--color-white: #fff;--color-border: #d1d5db;--color-border-light: #e2e8f0;--spacing-xs: .375rem;--spacing-sm: .5rem;--spacing-md: 1rem;--spacing-lg: 1.5rem;--spacing-xl: 2rem;--step-size: 2.5rem;--step-font-weight: 600;--step-radius: 50%;--spinner-size: 1.5rem;--spinner-thickness: 3px;--spinner-color: #3b82f6;--spinner-track: #e5e7eb;--spinner-speed: .8s}body{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif}h1,h2,h3,h4,h5,h6,p{margin:0;padding:0}.app-container{padding:var(--spacing-lg)}.stepper-header{display:flex;justify-content:space-between}.step-item{position:relative;display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%}.step-item:not(:first-child):before{content:"";background-color:var(--color-border-light);position:absolute;width:calc(100% - var(--step-size));height:3px;right:calc(50% + (var(--step-size) / 2));top:calc(var(--step-size) / 2 - .125rem);transition:all .2s}.step{width:var(--step-size);height:var(--step-size);display:flex;align-items:center;justify-content:center;z-index:10;position:relative;border-radius:var(--step-radius);font-weight:var(--step-font-weight);color:var(--color-black);transition:all .2s;border:1px solid var(--color-border)}.step-active{border-color:var(--color-primary);background-color:var(--color-primary);color:var(--color-white)}.step-complete{border-color:var(--color-success);background-color:var(--color-success);color:var(--color-white)}.step-error{background-color:var(--color-error);color:var(--color-white)}.step-finished{background-color:var(--color-success);color:var(--color-white)}.complete:not(:first-child):before,.active:not(:first-child):before{background-color:var(--color-success)}.step-title{font-size:1rem;color:var(--color-text);font-weight:500;margin-top:var(--spacing-md)}.step-description{font-size:.85rem;color:var(--color-text-light);font-weight:300;margin-top:var(--spacing-sm)}.stepper-content{display:flex;justify-content:center;align-items:center}.stepper-footer{display:flex;justify-content:space-around;align-items:center;padding:var(--spacing-lg) var(--spacing-xl)}.stepper-button{padding:var(--spacing-xs) var(--spacing-xl);font-size:1rem;border-radius:.375rem;border:1px solid #9ca3af;background-color:transparent;color:inherit;cursor:pointer}.stepper-button-fill{border-color:var(--color-primary);background-color:var(--color-primary);color:var(--color-white)}.spinner{width:var(--spinner-size);height:var(--spinner-size);border-radius:50%;border:var(--spinner-thickness) solid var(--spinner-track);border-top-color:var(--spinner-color);animation:spin var(--spinner-speed) linear infinite}@media (prefers-reduced-motion: reduce){.spinner{animation:none;border-top-color:var(--spinner-track)}}@keyframes spin{to{transform:rotate(360deg)}}.test-step{padding:10vh;display:flex;justify-content:center;align-items:center;border-radius:1rem;width:50%;margin-block:2rem}.test-step h3{color:#fff}.step-text{text-align:center}
2
- /*$vite$:1*/`,document.head.appendChild(M);var y={exports:{}},k={};/**
1
+ (function(x,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],c):(x=typeof globalThis<"u"?globalThis:x||self,c(x["multi-stepper"]={},x.React))})(this,function(x,c){"use strict";var z=document.createElement("style");z.textContent=`:root{--color-primary: #0284c7;--color-primary-light: #38bdf8;--color-success: #16a34a;--color-error: #ef4444;--color-text: #111827;--color-text-light: #4b5563;--color-black: #000;--color-white: #fff;--color-border: #d1d5db;--color-border-light: #e2e8f0;--spacing-xs: .375rem;--spacing-sm: .5rem;--spacing-md: 1rem;--spacing-lg: 1.5rem;--spacing-xl: 2rem;--step-size: 2.5rem;--step-font-weight: 600;--step-radius: 50%;--spinner-size: 1.5rem;--spinner-thickness: 3px;--spinner-color: #3b82f6;--spinner-track: #e5e7eb;--spinner-speed: .8s}body{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif}h1,h2,h3,h4,h5,h6,p{margin:0;padding:0}.app-container{padding:var(--spacing-lg)}.stepper-header{display:flex;justify-content:space-between}.step-item{position:relative;display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%}.step-item:not(:first-child):before{content:"";background-color:var(--color-border-light);position:absolute;width:calc(100% - var(--step-size));height:3px;right:calc(50% + (var(--step-size) / 2));top:calc(var(--step-size) / 2 - .125rem);transition:all .2s}.step{width:var(--step-size);height:var(--step-size);display:flex;align-items:center;justify-content:center;z-index:10;position:relative;border-radius:var(--step-radius);font-weight:var(--step-font-weight);color:var(--color-black);transition:all .2s;border:1px solid var(--color-border)}.step-active{border-color:var(--color-primary);background-color:var(--color-primary);color:var(--color-white)}.step-complete{border-color:var(--color-success);background-color:var(--color-success);color:var(--color-white)}.step-error{background-color:var(--color-error);color:var(--color-white)}.step-finished{background-color:var(--color-success);color:var(--color-white)}.complete:not(:first-child):before,.active:not(:first-child):before{background-color:var(--color-success)}.step-title{font-size:1rem;color:var(--color-text);font-weight:500;margin-top:var(--spacing-md)}.step-description{font-size:.85rem;color:var(--color-text-light);font-weight:300;margin-top:var(--spacing-sm)}.stepper-content{display:flex;justify-content:center;align-items:center}.stepper-footer{display:flex;justify-content:space-around;align-items:center;padding:var(--spacing-lg) var(--spacing-xl)}.stepper-button{padding:var(--spacing-xs) var(--spacing-xl);font-size:1rem;border-radius:.375rem;border:1px solid #9ca3af;background-color:transparent;color:inherit;cursor:pointer}.stepper-button-fill{border-color:var(--color-primary);background-color:var(--color-primary);color:var(--color-white)}.spinner{width:var(--spinner-size);height:var(--spinner-size);border-radius:50%;border:var(--spinner-thickness) solid var(--spinner-track);border-top-color:var(--spinner-color);animation:spin var(--spinner-speed) linear infinite}@media (prefers-reduced-motion: reduce){.spinner{animation:none;border-top-color:var(--spinner-track)}}@keyframes spin{to{transform:rotate(360deg)}}.test-step{padding:10vh;display:flex;justify-content:center;align-items:center;border-radius:1rem;width:50%;margin-block:2rem}.test-step h3{color:#fff}.step-text{text-align:center}
2
+ /*$vite$:1*/`,document.head.appendChild(z);var y={exports:{}},k={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
5
5
  *
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var z;function H(){if(z)return k;z=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function s(h,i,l){var m=null;if(l!==void 0&&(m=""+l),i.key!==void 0&&(m=""+i.key),"key"in i){l={};for(var v in i)v!=="key"&&(l[v]=i[v])}else l=i;return i=l.ref,{$$typeof:t,type:h,key:m,ref:i!==void 0?i:null,props:l}}return k.Fragment=o,k.jsx=s,k.jsxs=s,k}var R={};/**
10
+ */var Y;function B(){if(Y)return k;Y=1;var t=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function n(b,l,u){var d=null;if(u!==void 0&&(d=""+u),l.key!==void 0&&(d=""+l.key),"key"in l){u={};for(var E in l)E!=="key"&&(u[E]=l[E])}else u=l;return l=u.ref,{$$typeof:t,type:b,key:d,ref:l!==void 0?l:null,props:u}}return k.Fragment=s,k.jsx=n,k.jsxs=n,k}var R={};/**
11
11
  * @license React
12
12
  * react-jsx-runtime.development.js
13
13
  *
@@ -15,9 +15,9 @@
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var Y;function B(){return Y||(Y=1,process.env.NODE_ENV!=="production"&&function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===pe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case oe:return"Profiler";case ne:return"StrictMode";case ce:return"Suspense";case le:return"SuspenseList";case de:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case te:return"Portal";case ae:return(e.displayName||"Context")+".Provider";case se:return(e._context.displayName||"Context")+".Consumer";case ie:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ue:return r=e.displayName||null,r!==null?r:t(e.type)||"Memo";case L:r=e._payload,e=e._init;try{return t(e(r))}catch{}}return null}function o(e){return""+e}function s(e){try{o(e);var r=!1}catch{r=!0}if(r){r=console;var a=r.error,d=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",d),o(e)}}function h(e){if(e===w)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===L)return"<...>";try{var r=t(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function i(){var e=O.A;return e===null?null:e.getOwner()}function l(){return Error("react-stack-top-frame")}function m(e){if(U.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function v(e,r){function a(){W||(W=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}function T(){var e=t(this.type);return J[e]||(J[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function N(e,r,a,d,E,x,A,C){return a=x.ref,e={$$typeof:b,type:e,key:r,props:x,_owner:E},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:T}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:C}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function f(e,r,a,d,E,x,A,C){var p=r.children;if(p!==void 0)if(d)if(fe(p)){for(d=0;d<p.length;d++)g(p[d]);Object.freeze&&Object.freeze(p)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else g(p);if(U.call(r,"key")){p=t(e);var _=Object.keys(r).filter(function(me){return me!=="key"});d=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",X[p+d]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ */var I;function Z(){return I||(I=1,process.env.NODE_ENV!=="production"&&function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===pe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case P:return"Fragment";case oe:return"Profiler";case ne:return"StrictMode";case ce:return"Suspense";case le:return"SuspenseList";case de:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case h:return"Portal";case ae:return(e.displayName||"Context")+".Provider";case se:return(e._context.displayName||"Context")+".Consumer";case ie:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ue:return r=e.displayName||null,r!==null?r:t(e.type)||"Memo";case U:r=e._payload,e=e._init;try{return t(e(r))}catch{}}return null}function s(e){return""+e}function n(e){try{s(e);var r=!1}catch{r=!0}if(r){r=console;var a=r.error,f=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",f),s(e)}}function b(e){if(e===P)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===U)return"<...>";try{var r=t(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function l(){var e=O.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function d(e){if(W.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function E(e,r){function a(){J||(J=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}function T(){var e=t(this.type);return V[e]||(V[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function w(e,r,a,f,_,g,C,M){return a=g.ref,e={$$typeof:i,type:e,key:r,props:g,_owner:_},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:T}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:C}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function N(e,r,a,f,_,g,C,M){var m=r.children;if(m!==void 0)if(f)if(fe(m)){for(f=0;f<m.length;f++)p(m[f]);Object.freeze&&Object.freeze(m)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(m);if(W.call(r,"key")){m=t(e);var j=Object.keys(r).filter(function(me){return me!=="key"});f=0<j.length?"{key: someKey, "+j.join(": ..., ")+": ...}":"{key: someKey}",H[m+f]||(j=0<j.length?"{"+j.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
19
19
  let props = %s;
20
20
  <%s {...props} />
21
21
  React keys must be passed directly to JSX without using spread:
22
22
  let props = %s;
23
- <%s key={someKey} {...props} />`,d,p,_,p),X[p+d]=!0)}if(p=null,a!==void 0&&(s(a),p=""+a),m(r)&&(s(r.key),p=""+r.key),"key"in r){a={};for(var F in r)F!=="key"&&(a[F]=r[F])}else a=r;return p&&v(a,typeof e=="function"?e.displayName||e.name||"Unknown":e),N(e,p,x,E,i(),a,A,C)}function g(e){typeof e=="object"&&e!==null&&e.$$typeof===b&&e._store&&(e._store.validated=1)}var u=c,b=Symbol.for("react.transitional.element"),te=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),ne=Symbol.for("react.strict_mode"),oe=Symbol.for("react.profiler"),se=Symbol.for("react.consumer"),ae=Symbol.for("react.context"),ie=Symbol.for("react.forward_ref"),ce=Symbol.for("react.suspense"),le=Symbol.for("react.suspense_list"),ue=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),de=Symbol.for("react.activity"),pe=Symbol.for("react.client.reference"),O=u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=Object.prototype.hasOwnProperty,fe=Array.isArray,P=console.createTask?console.createTask:function(){return null};u={react_stack_bottom_frame:function(e){return e()}};var W,J={},V=u.react_stack_bottom_frame.bind(u,l)(),G=P(h(l)),X={};R.Fragment=w,R.jsx=function(e,r,a,d,E){var x=1e4>O.recentlyCreatedOwnerStacks++;return f(e,r,a,!1,d,E,x?Error("react-stack-top-frame"):V,x?P(h(e)):G)},R.jsxs=function(e,r,a,d,E){var x=1e4>O.recentlyCreatedOwnerStacks++;return f(e,r,a,!0,d,E,x?Error("react-stack-top-frame"):V,x?P(h(e)):G)}}()),R}var I;function Z(){return I||(I=1,process.env.NODE_ENV==="production"?y.exports=H():y.exports=B()),y.exports}var n=Z();const D=c.createContext(void 0),S=()=>{const t=c.useContext(D);if(!t)throw new Error("useMultiStepperForm must be used within a MultiStepperProvider");return t},Q=({children:t,steppers:o})=>{const[s,h]=c.useState(0),[i,l]=c.useState([]);c.useEffect(()=>{if(o.length){const f=[...o];f[0].active=!0,l(f)}},[o.length]);const m=c.useCallback(f=>{l(g=>{const u=[...g];if(f>g.length-1)return g;u[s]&&(u[s]={...u[s],active:!1}),u[f]&&(u[f]={...u[f],active:!0});for(let b=0;b<f;b++)u[b]={...u[b],completed:!0};for(let b=f;b<u.length;b++)u[b]={...u[b],completed:!1};return u}),h(f)},[s]),v=c.useCallback(()=>{s<i.length-1?m(s+1):l(f=>{const g=[...f];return g[s]={...g[s],completed:!0},g})},[s,i.length,m]),T=c.useCallback(()=>{s>0&&m(s-1)},[s,m]),N=c.useMemo(()=>({currentStep:s,steps:i,handleNextStep:v,handlePrevStep:T,updateSteps:m}),[s,i,v,T,m]);return n.jsx(D.Provider,{value:N,children:t})},K=({step:t,index:o})=>{const{steps:s}=S();return s.length?t.loading?n.jsx("div",{className:"step step-loading",children:n.jsx("div",{className:"spinner",role:"status","aria-label":"Loading"})}):t.error?n.jsx("div",{className:"step step-error",children:t.icon??n.jsx("span",{className:"text-white",children:"โœ—"})}):t.completed?n.jsx("div",{className:"step step-complete",children:t.icon??n.jsx("span",{className:"text-white",children:"โœ“"})}):t.finshed?n.jsx("div",{className:"step step-complete",children:t.icon}):t.active?n.jsx("div",{className:"step step-active",children:t.icon??n.jsx("h2",{className:"text-white",children:o})}):n.jsx("div",{className:"step step-default",children:t.icon??n.jsx("h2",{children:o})}):n.jsx(c.Fragment,{})},q=()=>{const{steps:t}=S();return t.length?n.jsx("div",{className:"app-container",children:n.jsx("ol",{className:"stepper-header",children:t.map((o,s)=>n.jsxs("div",{className:`step-item ${o.active&&"active"} ${o.completed&&"complete"} `,children:[n.jsx(K,{index:s+1,step:o}),n.jsxs("div",{className:"step-text",children:[o.title&&n.jsx("h3",{className:"step-title",children:o.title}),o.description&&n.jsx("h3",{className:"step-description",children:o.description})]})]},s))})}):n.jsx(c.Fragment,{})},$=({onClickNext:t})=>{const{handleNextStep:o,handlePrevStep:s,currentStep:h,steps:i}=S(),l=h===i.length-1,m=()=>{i[h].completed||(o(),t(h+1))},v=c.useMemo(()=>({button:"stepper-button",fill:"stepper-button-fill"}),[]);return n.jsxs("div",{className:"stepper-footer",children:[n.jsx("button",{type:"button",className:v.button,onClick:s,disabled:h<0,children:"Prev"}),n.jsx("button",{type:"button",className:`${l?`${v.button} ${v.fill}`:v.button}`,onClick:m,children:l?"Finish":"Next"})]})},ee=()=>{const{steps:t,currentStep:o}=S();return n.jsx("div",{className:"stepper-content",children:t[o]&&t[o].children&&t[o].children})},re=({steps:t,onClickNext:o})=>t?n.jsxs(Q,{steppers:t,children:[n.jsx(q,{}),n.jsx(ee,{}),n.jsx($,{onClickNext:o})]}):n.jsx(n.Fragment,{});j.MultiStepper=re,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
23
+ <%s key={someKey} {...props} />`,f,m,j,m),H[m+f]=!0)}if(m=null,a!==void 0&&(n(a),m=""+a),d(r)&&(n(r.key),m=""+r.key),"key"in r){a={};for(var F in r)F!=="key"&&(a[F]=r[F])}else a=r;return m&&E(a,typeof e=="function"?e.displayName||e.name||"Unknown":e),w(e,m,g,_,l(),a,C,M)}function p(e){typeof e=="object"&&e!==null&&e.$$typeof===i&&e._store&&(e._store.validated=1)}var v=c,i=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),ne=Symbol.for("react.strict_mode"),oe=Symbol.for("react.profiler"),se=Symbol.for("react.consumer"),ae=Symbol.for("react.context"),ie=Symbol.for("react.forward_ref"),ce=Symbol.for("react.suspense"),le=Symbol.for("react.suspense_list"),ue=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),de=Symbol.for("react.activity"),pe=Symbol.for("react.client.reference"),O=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=Object.prototype.hasOwnProperty,fe=Array.isArray,A=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(e){return e()}};var J,V={},G=v.react_stack_bottom_frame.bind(v,u)(),X=A(b(u)),H={};R.Fragment=P,R.jsx=function(e,r,a,f,_){var g=1e4>O.recentlyCreatedOwnerStacks++;return N(e,r,a,!1,f,_,g?Error("react-stack-top-frame"):G,g?A(b(e)):X)},R.jsxs=function(e,r,a,f,_){var g=1e4>O.recentlyCreatedOwnerStacks++;return N(e,r,a,!0,f,_,g?Error("react-stack-top-frame"):G,g?A(b(e)):X)}}()),R}var D;function Q(){return D||(D=1,process.env.NODE_ENV==="production"?y.exports=B():y.exports=Z()),y.exports}var o=Q();const L=c.createContext(void 0),S=()=>{const t=c.useContext(L);if(!t)throw new Error("useMultiStepperForm must be used within a MultiStepperProvider");return t},K=({children:t,steppers:s})=>{const[n,b]=c.useState(0),[l,u]=c.useState([]);c.useEffect(()=>{if(s.length){const p=[...s];p[0].active=!0,u(p)}},[s,s.length]);const d=c.useCallback(p=>{u(v=>{const i=[...v];if(p>v.length-1)return v;i[n]&&(i[n]={...i[n],active:!1}),i[p]&&(i[p]={...i[p],active:!0});for(let h=0;h<p;h++)i[h]={...i[h],completed:!0};for(let h=p;h<i.length;h++)i[h]={...i[h],completed:!1};return i}),b(p)},[n]),E=c.useCallback(()=>{n<l.length-1?d(n+1):u(p=>{const v=[...p];return v[n]={...v[n],completed:!0},v})},[n,l.length,d]),T=c.useCallback(()=>{n>0&&d(n-1)},[n,d]),w=c.useCallback(p=>{u(v=>{const i=[...v];return i[n]&&(i[n]={...i[n],error:!1,loading:!1,active:!1,completed:!1},i[n][p]=!0),i})},[n]),N=c.useMemo(()=>({currentStep:n,steps:l,handleNextStep:E,handlePrevStep:T,updateSteps:d,setStepStatus:w}),[n,l,E,T,d,w]);return o.jsx(L.Provider,{value:N,children:t})},q=()=>{const{steps:t,currentStep:s}=S();return o.jsx("div",{className:"stepper-content",children:t[s]&&t[s].children&&t[s].children})},$=({onClickNext:t})=>{const{handlePrevStep:s,currentStep:n,steps:b}=S(),l=n===b.length-1,u=()=>{b[n].completed||t()},d=c.useMemo(()=>({button:"stepper-button",fill:"stepper-button-fill"}),[]);return o.jsxs("div",{className:"stepper-footer",children:[o.jsx("button",{type:"button",className:d.button,onClick:s,disabled:n<0,children:"Prev"}),o.jsx("button",{type:"button",className:`${l?`${d.button} ${d.fill}`:d.button}`,onClick:u,children:l?"Finish":"Next"})]})},ee=({step:t,index:s})=>{const{steps:n}=S();return n.length?t.loading?o.jsx("div",{className:"step step-active",children:o.jsx("div",{className:"spinner",role:"status","aria-label":"Loading"})}):t.error?o.jsx("div",{className:"step step-error",children:t.icon??o.jsx("span",{className:"text-white",children:"โœ—"})}):t.completed?o.jsx("div",{className:"step step-complete",children:t.icon??o.jsx("span",{className:"text-white",children:"โœ“"})}):t.finshed?o.jsx("div",{className:"step step-complete",children:t.icon}):t.active?o.jsx("div",{className:"step step-active",children:t.icon??o.jsx("h2",{className:"text-white",children:s})}):o.jsx("div",{className:"step step-default",children:t.icon??o.jsx("h2",{children:s})}):o.jsx(c.Fragment,{})},re=()=>{const{steps:t}=S();return t.length?o.jsx("div",{className:"app-container",children:o.jsx("ol",{className:"stepper-header",children:t.map((s,n)=>o.jsxs("div",{className:`step-item ${s.active&&"active"} ${s.completed&&"complete"} `,children:[o.jsx(ee,{index:n+1,step:s}),o.jsxs("div",{className:"step-text",children:[s.title&&o.jsx("h3",{className:"step-title",children:s.title}),s.description&&o.jsx("h3",{className:"step-description",children:s.description})]})]},n))})}):o.jsx(c.Fragment,{})},te=({onClickNext:t})=>o.jsxs(c.Fragment,{children:[o.jsx(re,{}),o.jsx(q,{}),o.jsx($,{onClickNext:t})]});x.MultiStepper=te,x.MultiStepperProvider=K,x.useMultiStepper=S,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./dist/multi-stepper.umd.js",
4
4
  "module": "./dist/multi-stepper.es.js",
5
5
  "types": "./dist/index.d.ts",
6
- "version": "1.2.1",
6
+ "version": "1.2.3",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "url": "https://github.com/UppiliSrinivas/react-stepper/tree/multi-stepper"
@@ -31,7 +31,6 @@
31
31
  "@vitejs/plugin-react-swc": "^3.11.0",
32
32
  "react": "^19.1.0",
33
33
  "react-dom": "^19.1.0",
34
- "reactjs-multi-stepper": "^1.1.4",
35
34
  "vite-plugin-dts": "^4.5.4",
36
35
  "vite-plugin-lib-inject-css": "^2.2.2"
37
36
  },