stepper-hook
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,633 +0,4 @@ | ||
import ke, { createContext as vr, useState as ne, useRef as pr, useContext as gr } from "react"; | ||
var ae = { exports: {} }, W = {}; | ||
/** | ||
* @license React | ||
* react-jsx-runtime.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
var xe; | ||
function hr() { | ||
if (xe) return W; | ||
xe = 1; | ||
var _ = ke, d = Symbol.for("react.element"), m = Symbol.for("react.fragment"), v = Object.prototype.hasOwnProperty, S = _.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, j = { key: !0, ref: !0, __self: !0, __source: !0 }; | ||
function P(O, c, R) { | ||
var p, y = {}, w = null, k = null; | ||
R !== void 0 && (w = "" + R), c.key !== void 0 && (w = "" + c.key), c.ref !== void 0 && (k = c.ref); | ||
for (p in c) v.call(c, p) && !j.hasOwnProperty(p) && (y[p] = c[p]); | ||
if (O && O.defaultProps) for (p in c = O.defaultProps, c) y[p] === void 0 && (y[p] = c[p]); | ||
return { $$typeof: d, type: O, key: w, ref: k, props: y, _owner: S.current }; | ||
} | ||
return W.Fragment = m, W.jsx = P, W.jsxs = P, W; | ||
} | ||
var L = {}; | ||
/** | ||
* @license React | ||
* react-jsx-runtime.development.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
var je; | ||
function yr() { | ||
return je || (je = 1, process.env.NODE_ENV !== "production" && function() { | ||
var _ = ke, d = Symbol.for("react.element"), m = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), S = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), P = Symbol.for("react.provider"), O = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), R = Symbol.for("react.suspense"), p = Symbol.for("react.suspense_list"), y = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), k = Symbol.for("react.offscreen"), V = Symbol.iterator, J = "@@iterator"; | ||
function q(e) { | ||
if (e === null || typeof e != "object") | ||
return null; | ||
var r = V && e[V] || e[J]; | ||
return typeof r == "function" ? r : null; | ||
} | ||
var b = _.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
function f(e) { | ||
{ | ||
for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++) | ||
t[n - 1] = arguments[n]; | ||
K("error", e, t); | ||
} | ||
} | ||
function K(e, r, t) { | ||
{ | ||
var n = b.ReactDebugCurrentFrame, i = n.getStackAddendum(); | ||
i !== "" && (r += "%s", t = t.concat([i])); | ||
var u = t.map(function(o) { | ||
return String(o); | ||
}); | ||
u.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, u); | ||
} | ||
} | ||
var Ae = !1, Fe = !1, Ie = !1, $e = !1, We = !1, oe; | ||
oe = Symbol.for("react.module.reference"); | ||
function Le(e) { | ||
return !!(typeof e == "string" || typeof e == "function" || e === v || e === j || We || e === S || e === R || e === p || $e || e === k || Ae || Fe || Ie || typeof e == "object" && e !== null && (e.$$typeof === w || e.$$typeof === y || e.$$typeof === P || e.$$typeof === O || e.$$typeof === c || // This needs to include all possible module reference object | ||
// types supported by any Flight configuration anywhere since | ||
// we don't know which Flight build this will end up being used | ||
// with. | ||
e.$$typeof === oe || e.getModuleId !== void 0)); | ||
} | ||
function Ye(e, r, t) { | ||
var n = e.displayName; | ||
if (n) | ||
return n; | ||
var i = r.displayName || r.name || ""; | ||
return i !== "" ? t + "(" + i + ")" : t; | ||
} | ||
function ie(e) { | ||
return e.displayName || "Context"; | ||
} | ||
function T(e) { | ||
if (e == null) | ||
return null; | ||
if (typeof e.tag == "number" && f("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function") | ||
return e.displayName || e.name || null; | ||
if (typeof e == "string") | ||
return e; | ||
switch (e) { | ||
case v: | ||
return "Fragment"; | ||
case m: | ||
return "Portal"; | ||
case j: | ||
return "Profiler"; | ||
case S: | ||
return "StrictMode"; | ||
case R: | ||
return "Suspense"; | ||
case p: | ||
return "SuspenseList"; | ||
} | ||
if (typeof e == "object") | ||
switch (e.$$typeof) { | ||
case O: | ||
var r = e; | ||
return ie(r) + ".Consumer"; | ||
case P: | ||
var t = e; | ||
return ie(t._context) + ".Provider"; | ||
case c: | ||
return Ye(e, e.render, "ForwardRef"); | ||
case y: | ||
var n = e.displayName || null; | ||
return n !== null ? n : T(e.type) || "Memo"; | ||
case w: { | ||
var i = e, u = i._payload, o = i._init; | ||
try { | ||
return T(o(u)); | ||
} catch { | ||
return null; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
var C = Object.assign, F = 0, ue, se, le, ce, fe, de, ve; | ||
function pe() { | ||
} | ||
pe.__reactDisabledLog = !0; | ||
function Ve() { | ||
{ | ||
if (F === 0) { | ||
ue = console.log, se = console.info, le = console.warn, ce = console.error, fe = console.group, de = console.groupCollapsed, ve = console.groupEnd; | ||
var e = { | ||
configurable: !0, | ||
enumerable: !0, | ||
value: pe, | ||
writable: !0 | ||
}; | ||
Object.defineProperties(console, { | ||
info: e, | ||
log: e, | ||
warn: e, | ||
error: e, | ||
group: e, | ||
groupCollapsed: e, | ||
groupEnd: e | ||
}); | ||
} | ||
F++; | ||
} | ||
} | ||
function Me() { | ||
{ | ||
if (F--, F === 0) { | ||
var e = { | ||
configurable: !0, | ||
enumerable: !0, | ||
writable: !0 | ||
}; | ||
Object.defineProperties(console, { | ||
log: C({}, e, { | ||
value: ue | ||
}), | ||
info: C({}, e, { | ||
value: se | ||
}), | ||
warn: C({}, e, { | ||
value: le | ||
}), | ||
error: C({}, e, { | ||
value: ce | ||
}), | ||
group: C({}, e, { | ||
value: fe | ||
}), | ||
groupCollapsed: C({}, e, { | ||
value: de | ||
}), | ||
groupEnd: C({}, e, { | ||
value: ve | ||
}) | ||
}); | ||
} | ||
F < 0 && f("disabledDepth fell below zero. This is a bug in React. Please file an issue."); | ||
} | ||
} | ||
var G = b.ReactCurrentDispatcher, z; | ||
function M(e, r, t) { | ||
{ | ||
if (z === void 0) | ||
try { | ||
throw Error(); | ||
} catch (i) { | ||
var n = i.stack.trim().match(/\n( *(at )?)/); | ||
z = n && n[1] || ""; | ||
} | ||
return ` | ||
` + z + e; | ||
} | ||
} | ||
var X = !1, U; | ||
{ | ||
var Ue = typeof WeakMap == "function" ? WeakMap : Map; | ||
U = new Ue(); | ||
} | ||
function ge(e, r) { | ||
if (!e || X) | ||
return ""; | ||
{ | ||
var t = U.get(e); | ||
if (t !== void 0) | ||
return t; | ||
} | ||
var n; | ||
X = !0; | ||
var i = Error.prepareStackTrace; | ||
Error.prepareStackTrace = void 0; | ||
var u; | ||
u = G.current, G.current = null, Ve(); | ||
try { | ||
if (r) { | ||
var o = function() { | ||
throw Error(); | ||
}; | ||
if (Object.defineProperty(o.prototype, "props", { | ||
set: function() { | ||
throw Error(); | ||
} | ||
}), typeof Reflect == "object" && Reflect.construct) { | ||
try { | ||
Reflect.construct(o, []); | ||
} catch (h) { | ||
n = h; | ||
} | ||
Reflect.construct(e, [], o); | ||
} else { | ||
try { | ||
o.call(); | ||
} catch (h) { | ||
n = h; | ||
} | ||
e.call(o.prototype); | ||
} | ||
} else { | ||
try { | ||
throw Error(); | ||
} catch (h) { | ||
n = h; | ||
} | ||
e(); | ||
} | ||
} catch (h) { | ||
if (h && n && typeof h.stack == "string") { | ||
for (var a = h.stack.split(` | ||
`), g = n.stack.split(` | ||
`), s = a.length - 1, l = g.length - 1; s >= 1 && l >= 0 && a[s] !== g[l]; ) | ||
l--; | ||
for (; s >= 1 && l >= 0; s--, l--) | ||
if (a[s] !== g[l]) { | ||
if (s !== 1 || l !== 1) | ||
do | ||
if (s--, l--, l < 0 || a[s] !== g[l]) { | ||
var E = ` | ||
` + a[s].replace(" at new ", " at "); | ||
return e.displayName && E.includes("<anonymous>") && (E = E.replace("<anonymous>", e.displayName)), typeof e == "function" && U.set(e, E), E; | ||
} | ||
while (s >= 1 && l >= 0); | ||
break; | ||
} | ||
} | ||
} finally { | ||
X = !1, G.current = u, Me(), Error.prepareStackTrace = i; | ||
} | ||
var A = e ? e.displayName || e.name : "", x = A ? M(A) : ""; | ||
return typeof e == "function" && U.set(e, x), x; | ||
} | ||
function Ne(e, r, t) { | ||
return ge(e, !1); | ||
} | ||
function Be(e) { | ||
var r = e.prototype; | ||
return !!(r && r.isReactComponent); | ||
} | ||
function N(e, r, t) { | ||
if (e == null) | ||
return ""; | ||
if (typeof e == "function") | ||
return ge(e, Be(e)); | ||
if (typeof e == "string") | ||
return M(e); | ||
switch (e) { | ||
case R: | ||
return M("Suspense"); | ||
case p: | ||
return M("SuspenseList"); | ||
} | ||
if (typeof e == "object") | ||
switch (e.$$typeof) { | ||
case c: | ||
return Ne(e.render); | ||
case y: | ||
return N(e.type, r, t); | ||
case w: { | ||
var n = e, i = n._payload, u = n._init; | ||
try { | ||
return N(u(i), r, t); | ||
} catch { | ||
} | ||
} | ||
} | ||
return ""; | ||
} | ||
var I = Object.prototype.hasOwnProperty, he = {}, ye = b.ReactDebugCurrentFrame; | ||
function B(e) { | ||
if (e) { | ||
var r = e._owner, t = N(e.type, e._source, r ? r.type : null); | ||
ye.setExtraStackFrame(t); | ||
} else | ||
ye.setExtraStackFrame(null); | ||
} | ||
function Je(e, r, t, n, i) { | ||
{ | ||
var u = Function.call.bind(I); | ||
for (var o in e) | ||
if (u(e, o)) { | ||
var a = void 0; | ||
try { | ||
if (typeof e[o] != "function") { | ||
var g = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); | ||
throw g.name = "Invariant Violation", g; | ||
} | ||
a = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); | ||
} catch (s) { | ||
a = s; | ||
} | ||
a && !(a instanceof Error) && (B(i), f("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), B(null)), a instanceof Error && !(a.message in he) && (he[a.message] = !0, B(i), f("Failed %s type: %s", t, a.message), B(null)); | ||
} | ||
} | ||
} | ||
var qe = Array.isArray; | ||
function H(e) { | ||
return qe(e); | ||
} | ||
function Ke(e) { | ||
{ | ||
var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object"; | ||
return t; | ||
} | ||
} | ||
function Ge(e) { | ||
try { | ||
return be(e), !1; | ||
} catch { | ||
return !0; | ||
} | ||
} | ||
function be(e) { | ||
return "" + e; | ||
} | ||
function Ee(e) { | ||
if (Ge(e)) | ||
return f("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ke(e)), be(e); | ||
} | ||
var $ = b.ReactCurrentOwner, ze = { | ||
key: !0, | ||
ref: !0, | ||
__self: !0, | ||
__source: !0 | ||
}, Re, _e, Z; | ||
Z = {}; | ||
function Xe(e) { | ||
if (I.call(e, "ref")) { | ||
var r = Object.getOwnPropertyDescriptor(e, "ref").get; | ||
if (r && r.isReactWarning) | ||
return !1; | ||
} | ||
return e.ref !== void 0; | ||
} | ||
function He(e) { | ||
if (I.call(e, "key")) { | ||
var r = Object.getOwnPropertyDescriptor(e, "key").get; | ||
if (r && r.isReactWarning) | ||
return !1; | ||
} | ||
return e.key !== void 0; | ||
} | ||
function Ze(e, r) { | ||
if (typeof e.ref == "string" && $.current && r && $.current.stateNode !== r) { | ||
var t = T($.current.type); | ||
Z[t] || (f('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', T($.current.type), e.ref), Z[t] = !0); | ||
} | ||
} | ||
function Qe(e, r) { | ||
{ | ||
var t = function() { | ||
Re || (Re = !0, f("%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://reactjs.org/link/special-props)", r)); | ||
}; | ||
t.isReactWarning = !0, Object.defineProperty(e, "key", { | ||
get: t, | ||
configurable: !0 | ||
}); | ||
} | ||
} | ||
function er(e, r) { | ||
{ | ||
var t = function() { | ||
_e || (_e = !0, f("%s: `ref` 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://reactjs.org/link/special-props)", r)); | ||
}; | ||
t.isReactWarning = !0, Object.defineProperty(e, "ref", { | ||
get: t, | ||
configurable: !0 | ||
}); | ||
} | ||
} | ||
var rr = function(e, r, t, n, i, u, o) { | ||
var a = { | ||
// This tag allows us to uniquely identify this as a React Element | ||
$$typeof: d, | ||
// Built-in properties that belong on the element | ||
type: e, | ||
key: r, | ||
ref: t, | ||
props: o, | ||
// Record the component responsible for creating this element. | ||
_owner: u | ||
}; | ||
return a._store = {}, Object.defineProperty(a._store, "validated", { | ||
configurable: !1, | ||
enumerable: !1, | ||
writable: !0, | ||
value: !1 | ||
}), Object.defineProperty(a, "_self", { | ||
configurable: !1, | ||
enumerable: !1, | ||
writable: !1, | ||
value: n | ||
}), Object.defineProperty(a, "_source", { | ||
configurable: !1, | ||
enumerable: !1, | ||
writable: !1, | ||
value: i | ||
}), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a; | ||
}; | ||
function tr(e, r, t, n, i) { | ||
{ | ||
var u, o = {}, a = null, g = null; | ||
t !== void 0 && (Ee(t), a = "" + t), He(r) && (Ee(r.key), a = "" + r.key), Xe(r) && (g = r.ref, Ze(r, i)); | ||
for (u in r) | ||
I.call(r, u) && !ze.hasOwnProperty(u) && (o[u] = r[u]); | ||
if (e && e.defaultProps) { | ||
var s = e.defaultProps; | ||
for (u in s) | ||
o[u] === void 0 && (o[u] = s[u]); | ||
} | ||
if (a || g) { | ||
var l = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; | ||
a && Qe(o, l), g && er(o, l); | ||
} | ||
return rr(e, a, g, i, n, $.current, o); | ||
} | ||
} | ||
var Q = b.ReactCurrentOwner, me = b.ReactDebugCurrentFrame; | ||
function D(e) { | ||
if (e) { | ||
var r = e._owner, t = N(e.type, e._source, r ? r.type : null); | ||
me.setExtraStackFrame(t); | ||
} else | ||
me.setExtraStackFrame(null); | ||
} | ||
var ee; | ||
ee = !1; | ||
function re(e) { | ||
return typeof e == "object" && e !== null && e.$$typeof === d; | ||
} | ||
function Se() { | ||
{ | ||
if (Q.current) { | ||
var e = T(Q.current.type); | ||
if (e) | ||
return ` | ||
Check the render method of \`` + e + "`."; | ||
} | ||
return ""; | ||
} | ||
} | ||
function nr(e) { | ||
return ""; | ||
} | ||
var Te = {}; | ||
function ar(e) { | ||
{ | ||
var r = Se(); | ||
if (!r) { | ||
var t = typeof e == "string" ? e : e.displayName || e.name; | ||
t && (r = ` | ||
Check the top-level render call using <` + t + ">."); | ||
} | ||
return r; | ||
} | ||
} | ||
function Oe(e, r) { | ||
{ | ||
if (!e._store || e._store.validated || e.key != null) | ||
return; | ||
e._store.validated = !0; | ||
var t = ar(r); | ||
if (Te[t]) | ||
return; | ||
Te[t] = !0; | ||
var n = ""; | ||
e && e._owner && e._owner !== Q.current && (n = " It was passed a child from " + T(e._owner.type) + "."), D(e), f('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), D(null); | ||
} | ||
} | ||
function we(e, r) { | ||
{ | ||
if (typeof e != "object") | ||
return; | ||
if (H(e)) | ||
for (var t = 0; t < e.length; t++) { | ||
var n = e[t]; | ||
re(n) && Oe(n, r); | ||
} | ||
else if (re(e)) | ||
e._store && (e._store.validated = !0); | ||
else if (e) { | ||
var i = q(e); | ||
if (typeof i == "function" && i !== e.entries) | ||
for (var u = i.call(e), o; !(o = u.next()).done; ) | ||
re(o.value) && Oe(o.value, r); | ||
} | ||
} | ||
} | ||
function or(e) { | ||
{ | ||
var r = e.type; | ||
if (r == null || typeof r == "string") | ||
return; | ||
var t; | ||
if (typeof r == "function") | ||
t = r.propTypes; | ||
else if (typeof r == "object" && (r.$$typeof === c || // Note: Memo only checks outer props here. | ||
// Inner props are checked in the reconciler. | ||
r.$$typeof === y)) | ||
t = r.propTypes; | ||
else | ||
return; | ||
if (t) { | ||
var n = T(r); | ||
Je(t, e.props, "prop", n, e); | ||
} else if (r.PropTypes !== void 0 && !ee) { | ||
ee = !0; | ||
var i = T(r); | ||
f("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i || "Unknown"); | ||
} | ||
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && f("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); | ||
} | ||
} | ||
function ir(e) { | ||
{ | ||
for (var r = Object.keys(e.props), t = 0; t < r.length; t++) { | ||
var n = r[t]; | ||
if (n !== "children" && n !== "key") { | ||
D(e), f("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), D(null); | ||
break; | ||
} | ||
} | ||
e.ref !== null && (D(e), f("Invalid attribute `ref` supplied to `React.Fragment`."), D(null)); | ||
} | ||
} | ||
var Pe = {}; | ||
function Ce(e, r, t, n, i, u) { | ||
{ | ||
var o = Le(e); | ||
if (!o) { | ||
var a = ""; | ||
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); | ||
var g = nr(); | ||
g ? a += g : a += Se(); | ||
var s; | ||
e === null ? s = "null" : H(e) ? s = "array" : e !== void 0 && e.$$typeof === d ? (s = "<" + (T(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : s = typeof e, f("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", s, a); | ||
} | ||
var l = tr(e, r, t, i, u); | ||
if (l == null) | ||
return l; | ||
if (o) { | ||
var E = r.children; | ||
if (E !== void 0) | ||
if (n) | ||
if (H(E)) { | ||
for (var A = 0; A < E.length; A++) | ||
we(E[A], e); | ||
Object.freeze && Object.freeze(E); | ||
} else | ||
f("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 | ||
we(E, e); | ||
} | ||
if (I.call(r, "key")) { | ||
var x = T(e), h = Object.keys(r).filter(function(dr) { | ||
return dr !== "key"; | ||
}), te = h.length > 0 ? "{key: someKey, " + h.join(": ..., ") + ": ...}" : "{key: someKey}"; | ||
if (!Pe[x + te]) { | ||
var fr = h.length > 0 ? "{" + h.join(": ..., ") + ": ...}" : "{}"; | ||
f(`A props object containing a "key" prop is being spread into JSX: | ||
let props = %s; | ||
<%s {...props} /> | ||
React keys must be passed directly to JSX without using spread: | ||
let props = %s; | ||
<%s key={someKey} {...props} />`, te, x, fr, x), Pe[x + te] = !0; | ||
} | ||
} | ||
return e === v ? ir(l) : or(l), l; | ||
} | ||
} | ||
function ur(e, r, t) { | ||
return Ce(e, r, t, !0); | ||
} | ||
function sr(e, r, t) { | ||
return Ce(e, r, t, !1); | ||
} | ||
var lr = sr, cr = ur; | ||
L.Fragment = v, L.jsx = lr, L.jsxs = cr; | ||
}()), L; | ||
} | ||
process.env.NODE_ENV === "production" ? ae.exports = hr() : ae.exports = yr(); | ||
var Y = ae.exports; | ||
const De = vr({ | ||
import { jsx as a, jsxs as P } from "react/jsx-runtime"; | ||
import { createContext as T, useState as l, useRef as b, useContext as A } from "react"; | ||
const d = T({ | ||
activeStep: 0, | ||
@@ -648,17 +19,17 @@ data: null, | ||
totalSteps: 0 | ||
}), br = ({ | ||
onComplete: _, | ||
totalSteps: d, | ||
children: m | ||
}), C = ({ | ||
onComplete: n, | ||
totalSteps: t, | ||
children: r | ||
}) => { | ||
const [v, S] = ne(0), [j, P] = ne(null), [O, c] = ne(!1), R = pr(null), p = v === d - 1, y = async (b, f = !1) => { | ||
if (b < 0 || b > d) | ||
const [e, o] = l(0), [f, v] = l(null), [h, i] = l(!1), c = b(null), p = e === t - 1, u = async (s, S = !1) => { | ||
if (s < 0 || s > t) | ||
throw new Error( | ||
`Invalid step ${b}, it should be between 0 and ${d}` | ||
`Invalid step ${s}, it should be between 0 and ${t}` | ||
); | ||
if (!f && R.current) | ||
if (!S && c.current) | ||
try { | ||
c(!0); | ||
const K = await R.current(); | ||
if (c(!1), !K) | ||
i(!0); | ||
const w = await c.current(); | ||
if (i(!1), !w) | ||
return; | ||
@@ -668,52 +39,52 @@ } catch { | ||
} | ||
if (!f && p && _) { | ||
_(); | ||
if (!S && p && n) { | ||
n(); | ||
return; | ||
} | ||
J(), S(b); | ||
}, w = () => y(v - 1, !0), k = () => y(v + 1), V = (b) => { | ||
R.current = b; | ||
}, J = () => { | ||
R.current = null; | ||
}, q = { | ||
activeStep: v, | ||
data: j, | ||
goToNextStep: k, | ||
goToPreviousStep: w, | ||
handleSubmit: V, | ||
isFirstStep: v === 0, | ||
y(), o(s); | ||
}, g = () => u(e - 1, !0), x = () => u(e + 1), m = (s) => { | ||
c.current = s; | ||
}, y = () => { | ||
c.current = null; | ||
}, L = { | ||
activeStep: e, | ||
data: f, | ||
goToNextStep: x, | ||
goToPreviousStep: g, | ||
handleSubmit: m, | ||
isFirstStep: e === 0, | ||
isLastStep: p, | ||
isLoading: O, | ||
setActiveStep: y, | ||
setData: P, | ||
setLoading: c, | ||
totalSteps: d | ||
isLoading: h, | ||
setActiveStep: u, | ||
setData: v, | ||
setLoading: i, | ||
totalSteps: t | ||
}; | ||
return /* @__PURE__ */ Y.jsx(De.Provider, { value: q, children: m }); | ||
return /* @__PURE__ */ a(d.Provider, { value: L, children: r }); | ||
}; | ||
function Er() { | ||
return gr(De); | ||
function I() { | ||
return A(d); | ||
} | ||
const Rr = ({ | ||
steps: _, | ||
stepComponentWrapper: d | ||
const $ = ({ | ||
steps: n, | ||
stepComponentWrapper: t | ||
}) => { | ||
const { activeStep: m } = Er(), v = _[m]; | ||
let S = /* @__PURE__ */ Y.jsx(v, {}, `step-${m}`); | ||
return d && (S = /* @__PURE__ */ Y.jsx(d, { children: S })), S; | ||
const { activeStep: r } = I(), e = n[r]; | ||
let o = /* @__PURE__ */ a(e, {}, `step-${r}`); | ||
return t && (o = /* @__PURE__ */ a(t, { children: o })), o; | ||
}; | ||
function mr({ | ||
onComplete: _, | ||
steps: d, | ||
stepComponentWrapper: m, | ||
children: v | ||
function F({ | ||
onComplete: n, | ||
steps: t, | ||
stepComponentWrapper: r, | ||
children: e | ||
}) { | ||
return /* @__PURE__ */ Y.jsxs(br, { totalSteps: d.length, onComplete: _, children: [ | ||
/* @__PURE__ */ Y.jsx(Rr, { steps: d, stepComponentWrapper: m }), | ||
v | ||
return /* @__PURE__ */ P(C, { totalSteps: t.length, onComplete: n, children: [ | ||
/* @__PURE__ */ a($, { steps: t, stepComponentWrapper: r }), | ||
e | ||
] }); | ||
} | ||
export { | ||
mr as Stepper, | ||
Er as useStepper | ||
F as Stepper, | ||
I as useStepper | ||
}; |
{ | ||
"name": "stepper-hook", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "React hook for creating custom stepper components", | ||
@@ -8,3 +8,3 @@ "author": { | ||
"email": "luca@velvetlab.tech", | ||
"url": "https://lucafaggianelli.com" | ||
"url": "https://lucafaggianelli.com/stepper-hook" | ||
}, | ||
@@ -15,2 +15,3 @@ "type": "module", | ||
], | ||
"types": "./dist/stepper-hook.d.ts", | ||
"main": "./dist/stepper-hook.umd.cjs", | ||
@@ -40,3 +41,4 @@ "module": "./dist/stepper-hook.js", | ||
"typescript-eslint": "^8.0.1", | ||
"vite": "^5.4.1" | ||
"vite": "^5.4.1", | ||
"vite-plugin-dts": "^4.0.3" | ||
}, | ||
@@ -43,0 +45,0 @@ "scripts": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
6
0
1
7002
13
119
1