Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stepper-hook

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stepper-hook - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

18

dist/stepper-hook.d.ts
import { JSX as JSX_2 } from 'react/jsx-runtime';
import { PropsWithChildren } from 'react';
declare type Handler = () => Promise<boolean> | boolean;
declare interface Props extends PropsWithChildren {

@@ -19,3 +17,15 @@ onComplete?: () => void;

goToPreviousStep: () => Promise<void>;
handleSubmit: (hanler: Handler) => void;
/**
* Used to register a validation handler for the current step.
* The validator function is called when the user tries to navigate to the next step.
* If the validation fails, the navigation is blocked.
*
* The handler can be an async or sync function that returns a boolean or throws an error:
* the validation is considered successful if the function returns true, and failed if it returns false
* or throws an error.
*
* @param hanler
* @returns
*/
handleStepValidation: (hanler: ValidationHandler) => void;
isFirstStep: boolean;

@@ -31,2 +41,4 @@ isLastStep: boolean;

declare type ValidationHandler = () => Promise<boolean> | boolean;
export { }

56

dist/stepper-hook.js

@@ -1,4 +0,4 @@

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({
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({
activeStep: 0,

@@ -10,3 +10,3 @@ data: null,

},
handleSubmit: () => !0,
handleStepValidation: () => !0,
isFirstStep: !0,

@@ -20,3 +20,3 @@ isLastStep: !1,

totalSteps: 0
}), C = ({
}), I = ({
onComplete: n,

@@ -26,3 +26,3 @@ totalSteps: t,

}) => {
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) => {
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) => {
if (s < 0 || s > t)

@@ -32,7 +32,7 @@ throw new Error(

);
if (!S && c.current)
if (!S && a.current)
try {
i(!0);
const w = await c.current();
if (i(!1), !w)
const P = await a.current();
if (i(!1), !P)
return;

@@ -46,8 +46,8 @@ } catch {

}
y(), o(s);
}, g = () => u(e - 1, !0), x = () => u(e + 1), m = (s) => {
c.current = s;
}, y = () => {
c.current = null;
}, L = {
L(), o(s);
}, g = () => u(e - 1, !0), x = () => u(e + 1), y = (s) => {
a.current = s;
}, L = () => {
a.current = null;
}, w = {
activeStep: e,

@@ -57,3 +57,3 @@ data: f,

goToPreviousStep: g,
handleSubmit: m,
handleStepValidation: y,
isFirstStep: e === 0,

@@ -67,16 +67,16 @@ isLastStep: p,

};
return /* @__PURE__ */ a(d.Provider, { value: L, children: r });
return /* @__PURE__ */ c(d.Provider, { value: w, children: r });
};
function I() {
return A(d);
function $() {
return C(d);
}
const $ = ({
const j = ({
steps: n,
stepComponentWrapper: t
}) => {
const { activeStep: r } = I(), e = n[r];
let o = /* @__PURE__ */ a(e, {}, `step-${r}`);
return t && (o = /* @__PURE__ */ a(t, { children: o })), o;
const { activeStep: r } = $(), e = n[r];
let o = /* @__PURE__ */ c(e, {}, `step-${r}`);
return t && (o = /* @__PURE__ */ c(t, { children: o })), o;
};
function F({
function N({
onComplete: n,

@@ -87,4 +87,4 @@ steps: t,

}) {
return /* @__PURE__ */ P(C, { totalSteps: t.length, onComplete: n, children: [
/* @__PURE__ */ a($, { steps: t, stepComponentWrapper: r }),
return /* @__PURE__ */ T(I, { totalSteps: t.length, onComplete: n, children: [
/* @__PURE__ */ c(j, { steps: t, stepComponentWrapper: r }),
e

@@ -94,4 +94,4 @@ ] });

export {
F as Stepper,
I as useStepper
N as Stepper,
$ as useStepper
};
{
"name": "stepper-hook",
"version": "0.1.1",
"version": "0.2.0",
"description": "React hook for creating custom stepper components",

@@ -5,0 +5,0 @@ "author": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc