stepper-hook
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -1,4 +0,4 @@ | ||
import { jsx as c, jsxs as T } from "react/jsx-runtime"; | ||
import { createContext as m, useState as l, useRef as A, useContext as C } from "react"; | ||
const d = m({ | ||
import { jsx as o, jsxs as T } from "react/jsx-runtime"; | ||
import { createContext as $, useState as u, useRef as m, useContext as A } from "react"; | ||
const S = $({ | ||
activeStep: 0, | ||
@@ -19,8 +19,8 @@ data: null, | ||
totalSteps: 0 | ||
}), I = ({ | ||
onComplete: n, | ||
}), C = ({ | ||
onComplete: r, | ||
totalSteps: t, | ||
children: r | ||
children: n | ||
}) => { | ||
const [e, o] = l(0), [f, v] = l(null), [h, i] = l(!1), a = A(null), p = e === t - 1, u = async (s, S = !1) => { | ||
const [e, d] = u(0), [f, v] = u(null), [h, c] = u(!1), a = m(null), p = e === t - 1, i = async (s, l = !1) => { | ||
if (s < 0 || s > t) | ||
@@ -30,7 +30,7 @@ throw new Error( | ||
); | ||
if (!S && a.current) | ||
if (!l && a.current) | ||
try { | ||
i(!0); | ||
c(!0); | ||
const P = await a.current(); | ||
if (i(!1), !P) | ||
if (c(!1), !P) | ||
return; | ||
@@ -40,8 +40,8 @@ } catch { | ||
} | ||
if (!S && p && n) { | ||
n(); | ||
if (!l && p && r) { | ||
r(); | ||
return; | ||
} | ||
L(), o(s); | ||
}, g = () => u(e - 1, !0), x = () => u(e + 1), y = (s) => { | ||
L(), d(s); | ||
}, g = () => i(e - 1, !0), x = () => i(e + 1), y = (s) => { | ||
a.current = s; | ||
@@ -59,28 +59,27 @@ }, L = () => { | ||
isLoading: h, | ||
setActiveStep: u, | ||
setActiveStep: i, | ||
setData: v, | ||
setLoading: i, | ||
setLoading: c, | ||
totalSteps: t | ||
}; | ||
return /* @__PURE__ */ c(d.Provider, { value: w, children: r }); | ||
return /* @__PURE__ */ o(S.Provider, { value: w, children: n }); | ||
}; | ||
function $() { | ||
return C(d); | ||
function I() { | ||
return A(S); | ||
} | ||
const j = ({ | ||
steps: n, | ||
steps: r, | ||
stepComponentWrapper: t | ||
}) => { | ||
const { activeStep: r } = $(), e = n[r]; | ||
let o = /* @__PURE__ */ c(e, {}, `step-${r}`); | ||
return t && (o = /* @__PURE__ */ c(t, { children: o })), o; | ||
const { activeStep: n } = I(), e = r[n]; | ||
return t ? /* @__PURE__ */ o(t, { children: /* @__PURE__ */ o(e, {}, `step-${n}`) }) : /* @__PURE__ */ o(e, {}, `step-${n}`); | ||
}; | ||
function N({ | ||
onComplete: n, | ||
onComplete: r, | ||
steps: t, | ||
stepComponentWrapper: r, | ||
stepComponentWrapper: n, | ||
children: e | ||
}) { | ||
return /* @__PURE__ */ T(I, { totalSteps: t.length, onComplete: n, children: [ | ||
/* @__PURE__ */ c(j, { steps: t, stepComponentWrapper: r }), | ||
return /* @__PURE__ */ T(C, { totalSteps: t.length, onComplete: r, children: [ | ||
/* @__PURE__ */ o(j, { steps: t, stepComponentWrapper: n }), | ||
e | ||
@@ -91,3 +90,3 @@ ] }); | ||
N as Stepper, | ||
$ as useStepper | ||
I as useStepper | ||
}; |
{ | ||
"name": "stepper-hook", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "React hook for creating custom stepper components", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7613
130