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

react-losen

Package Overview
Dependencies
Maintainers
6
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-losen - npm Package Compare versions

Comparing version 2.0.0-8 to 2.0.0-9

dist-src/state-managers/url-state-manager.js

61

dist-node/index.js

@@ -20,5 +20,6 @@ 'use strict';

isLast = _useContext.isLast,
isLoading = _useContext.isLoading;
isLoading = _useContext.isLoading,
activeIndex = _useContext.activeIndex;
return render(onNext, onPrevious, isFirst, isLast, isLoading);
return render(onNext, onPrevious, isFirst, isLast, isLoading, activeIndex);
};

@@ -146,3 +147,2 @@

// flow
function findNextValid(steps, currentIndex) {

@@ -162,2 +162,3 @@ const nextValid = currentIndex + steps.slice(currentIndex + 1).findIndex(el => !el.autoSkip);

onComplete,
stateManager,
debug

@@ -184,3 +185,3 @@ }) => {

if (!alreadyRegistered) {
setSteps(prevSteps => [...prevSteps, step]);
setSteps(previousSteps => [...previousSteps, step]);
}

@@ -191,3 +192,3 @@ }

const stepIndex = steps.findIndex(el => el.name === step.name);
setSteps(prevSteps => [...prevSteps.slice(0, stepIndex), step, ...prevSteps.slice(stepIndex + 1)]);
setSteps(previousSteps => [...previousSteps.slice(0, stepIndex), step, ...previousSteps.slice(stepIndex + 1)]);
}

@@ -222,2 +223,8 @@

}
if (stateManager) {
const currentStep = steps[index];
const nextStep = steps[index + 1];
stateManager.updateStep(currentStep.name, nextStep.name);
}
});

@@ -230,2 +237,8 @@ return _onNext.apply(this, arguments);

setIndex(prev);
if (stateManager) {
const currentStep = steps[index];
const previousStep = steps[index - 1];
stateManager.updateStep(currentStep.name, previousStep.name);
}
}

@@ -238,3 +251,12 @@

}
}, [steps]);
if (stateManager) {
const activeStep = stateManager.getActiveStep();
const activeIndex = steps.findIndex(step => step.name === activeStep);
if (activeIndex > -1) {
setIndex(activeIndex);
}
}
}, [steps, debug, stateManager]);
return React__default.createElement(ControlsContext.Provider, {

@@ -246,3 +268,4 @@ value: {

isFirst: findPreviousValid(steps, index) === index,
isLast: findNextValid(steps, index) === index
isLast: findNextValid(steps, index) === index,
activeIndex: index
}

@@ -260,5 +283,26 @@ }, React__default.createElement(StepContext.Provider, {

Wizard.defaultProps = {
debug: false
debug: false,
stateManager: undefined
};
const UrlStateManager = {
updateStep: (currentStepName, nextStepName) => {
const currentUrl = window.location.href;
const basePath = currentUrl.includes('?') ? currentUrl.split('?')[0] : currentUrl;
const searchParams = new URLSearchParams(new URL(currentUrl).searchParams);
searchParams.set('step', nextStepName);
window.history.pushState({
activeStep: currentStepName
}, '', currentUrl);
window.history.replaceState({
activeStep: nextStepName
}, '', `${basePath}?${searchParams.toString()}`);
},
getActiveStep: () => {
const href = window.location.href;
const searchParams = new URLSearchParams(new URL(href).searchParams);
return searchParams.get('step');
}
};
exports.Controls = Controls;

@@ -268,3 +312,4 @@ exports.ControlsContext = ControlsContext;

exports.StepContext = StepContext;
exports.UrlStateManager = UrlStateManager;
exports.ValidationError = ValidationError;
exports.Wizard = Wizard;

2

dist-node/index.min.js

@@ -1,2 +0,2 @@

"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),React__default=_interopDefault(React);const ControlsContext=React.createContext(null),Controls=({render:t})=>{const e=React.useContext(ControlsContext);return t(e.onNext,e.onPrevious,e.isFirst,e.isLast,e.isLoading)},StepContext=React.createContext(null),Step=({children:t,name:e,validator:n,autoSkip:r})=>{const o=React.useContext(StepContext),a=o.registerStep,i=o.activeStep,s=o.updateStep,l=o.initialized,c={name:e,validator:n,autoSkip:r};return React.useEffect(()=>{l||a(c)},[e]),React.useEffect(()=>{l&&s(c)},[r,n]),i.name!==e?null:t};function asyncGeneratorStep(t,e,n,r,o,a,i){try{var s=t[a](i),l=s.value}catch(t){return void n(t)}s.done?e(l):Promise.resolve(l).then(r,o)}function _asyncToGenerator(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var a=t.apply(e,n);function i(t){asyncGeneratorStep(a,r,o,i,s,"next",t)}function s(t){asyncGeneratorStep(a,r,o,i,s,"throw",t)}i(void 0)})}}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_nonIterableRest()}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _iterableToArrayLimit(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],r=!0,o=!1,a=void 0;try{for(var i,s=t[Symbol.iterator]();!(r=(i=s.next()).done)&&(n.push(i.value),!e||n.length!==e);r=!0);}catch(t){o=!0,a=t}finally{try{r||null==s.return||s.return()}finally{if(o)throw a}}return n}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function findNextValid(t,e){const n=e+t.slice(e+1).findIndex(t=>!t.autoSkip);return t.length>n?n+1:n}function findPreviousValid(t,e){return e-1-[...t].reverse().slice(t.length-e).findIndex(t=>!t.autoSkip)}Step.defaultProps={validator:null,autoSkip:!1};class ValidationError extends Error{}const Wizard=({children:t,onComplete:e,debug:n})=>{const r=_slicedToArray(React.useState(0),2),o=r[0],a=r[1],i=_slicedToArray(React.useState([]),2),s=i[0],l=i[1],c=_slicedToArray(React.useState(!1),2),u=c[0],d=c[1];function f(){return(f=_asyncToGenerator(function*(){const t=s[o].validator,n=findNextValid(s,o),r=n===o?()=>e(s[o].name):()=>a(n);if(t)try{d(!0),yield t(),r()}catch(t){if(!(t instanceof ValidationError))throw t;console.error("ReactLosen",t)}finally{d(!1)}else r()})).apply(this,arguments)}return React.useEffect(()=>{n&&console.debug("steps updated",s)},[s]),React__default.createElement(ControlsContext.Provider,{value:{onNext:function(){return f.apply(this,arguments)},onPrevious:function(){const t=findPreviousValid(s,o);a(t)},isLoading:u,isFirst:findPreviousValid(s,o)===o,isLast:findNextValid(s,o)===o}},React__default.createElement(StepContext.Provider,{value:{registerStep:function(t){s.map(t=>t.name).includes(t.name)||l(e=>[...e,t])},activeStep:s[o]||{},initialized:!!s[o],updateStep:function(t){const e=s.findIndex(e=>e.name===t.name);l(n=>[...n.slice(0,e),t,...n.slice(e+1)])}}},t))};Wizard.defaultProps={debug:!1},exports.Controls=Controls,exports.ControlsContext=ControlsContext,exports.Step=Step,exports.StepContext=StepContext,exports.ValidationError=ValidationError,exports.Wizard=Wizard;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),React__default=_interopDefault(React);const ControlsContext=React.createContext(null),Controls=({render:e})=>{const t=React.useContext(ControlsContext);return e(t.onNext,t.onPrevious,t.isFirst,t.isLast,t.isLoading,t.activeIndex)},StepContext=React.createContext(null),Step=({children:e,name:t,validator:n,autoSkip:r})=>{const a=React.useContext(StepContext),o=a.registerStep,i=a.activeStep,s=a.updateStep,c=a.initialized,l={name:t,validator:n,autoSkip:r};return React.useEffect(()=>{c||o(l)},[t]),React.useEffect(()=>{c&&s(l)},[r,n]),i.name!==t?null:e};function asyncGeneratorStep(e,t,n,r,a,o,i){try{var s=e[o](i),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,a)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var o=e.apply(t,n);function i(e){asyncGeneratorStep(o,r,a,i,s,"next",e)}function s(e){asyncGeneratorStep(o,r,a,i,s,"throw",e)}i(void 0)})}}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_nonIterableRest()}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],r=!0,a=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(r=(i=s.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(a)throw o}}return n}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function findNextValid(e,t){const n=t+e.slice(t+1).findIndex(e=>!e.autoSkip);return e.length>n?n+1:n}function findPreviousValid(e,t){return t-1-[...e].reverse().slice(e.length-t).findIndex(e=>!e.autoSkip)}Step.defaultProps={validator:null,autoSkip:!1};class ValidationError extends Error{}const Wizard=({children:e,onComplete:t,stateManager:n,debug:r})=>{const a=_slicedToArray(React.useState(0),2),o=a[0],i=a[1],s=_slicedToArray(React.useState([]),2),c=s[0],l=s[1],u=_slicedToArray(React.useState(!1),2),d=u[0],p=u[1];function f(){return(f=_asyncToGenerator(function*(){const e=c[o].validator,r=findNextValid(c,o),a=r===o?()=>t(c[o].name):()=>i(r);if(e)try{p(!0),yield e(),a()}catch(e){if(!(e instanceof ValidationError))throw e;console.error("ReactLosen",e)}finally{p(!1)}else a();if(n){const e=c[o],t=c[o+1];n.updateStep(e.name,t.name)}})).apply(this,arguments)}return React.useEffect(()=>{if(r&&console.debug("steps updated",c),n){const e=n.getActiveStep(),t=c.findIndex(t=>t.name===e);t>-1&&i(t)}},[c,r,n]),React__default.createElement(ControlsContext.Provider,{value:{onNext:function(){return f.apply(this,arguments)},onPrevious:function(){const e=findPreviousValid(c,o);if(i(e),n){const e=c[o],t=c[o-1];n.updateStep(e.name,t.name)}},isLoading:d,isFirst:findPreviousValid(c,o)===o,isLast:findNextValid(c,o)===o,activeIndex:o}},React__default.createElement(StepContext.Provider,{value:{registerStep:function(e){c.map(e=>e.name).includes(e.name)||l(t=>[...t,e])},activeStep:c[o]||{},initialized:!!c[o],updateStep:function(e){const t=c.findIndex(t=>t.name===e.name);l(n=>[...n.slice(0,t),e,...n.slice(t+1)])}}},e))};Wizard.defaultProps={debug:!1,stateManager:void 0};const UrlStateManager={updateStep:(e,t)=>{const n=window.location.href,r=n.includes("?")?n.split("?")[0]:n,a=new URLSearchParams(new URL(n).searchParams);a.set("step",t),window.history.pushState({activeStep:e},"",n),window.history.replaceState({activeStep:t},"",`${r}?${a.toString()}`)},getActiveStep:()=>{const e=window.location.href;return new URLSearchParams(new URL(e).searchParams).get("step")}};exports.Controls=Controls,exports.ControlsContext=ControlsContext,exports.Step=Step,exports.StepContext=StepContext,exports.UrlStateManager=UrlStateManager,exports.ValidationError=ValidationError,exports.Wizard=Wizard;
//# sourceMappingURL=index.min.js.map

@@ -12,7 +12,8 @@ import { createContext, useContext } from 'react';

isLast,
isLoading
isLoading,
activeIndex
} = useContext(ControlsContext);
return render(onNext, onPrevious, isFirst, isLast, isLoading);
return render(onNext, onPrevious, isFirst, isLast, isLoading, activeIndex);
};
export default Controls;
import Controls, { ControlsContext } from "./Controls.js";
import Step, { StepContext } from "./Step.js";
import Wizard, { ValidationError } from "./Wizard.js";
export { Controls, ControlsContext, Step, StepContext, ValidationError, Wizard };
import { UrlStateManager } from "./state-managers/url-state-manager.js";
export { Controls, ControlsContext, Step, StepContext, ValidationError, Wizard, UrlStateManager };

@@ -1,2 +0,2 @@

import Controls,{ControlsContext}from"./Controls.js";import Step,{StepContext}from"./Step.js";import Wizard,{ValidationError}from"./Wizard.js";export{Controls,ControlsContext,Step,StepContext,ValidationError,Wizard};
import Controls,{ControlsContext}from"./Controls.js";import Step,{StepContext}from"./Step.js";import Wizard,{ValidationError}from"./Wizard.js";import{UrlStateManager}from"./state-managers/url-state-manager.js";export{Controls,ControlsContext,Step,StepContext,ValidationError,Wizard,UrlStateManager};
//# sourceMappingURL=index.min.js.map

@@ -1,2 +0,1 @@

// flow
export function findNextValid(steps, currentIndex) {

@@ -3,0 +2,0 @@ const nextValid = currentIndex + steps.slice(currentIndex + 1).findIndex(el => !el.autoSkip);

@@ -10,2 +10,3 @@ import React, { useState, useEffect } from 'react';

onComplete,
stateManager,
debug

@@ -21,3 +22,3 @@ }) => {

if (!alreadyRegistered) {
setSteps(prevSteps => [...prevSteps, step]);
setSteps(previousSteps => [...previousSteps, step]);
}

@@ -28,3 +29,3 @@ }

const stepIndex = steps.findIndex(el => el.name === step.name);
setSteps(prevSteps => [...prevSteps.slice(0, stepIndex), step, ...prevSteps.slice(stepIndex + 1)]);
setSteps(previousSteps => [...previousSteps.slice(0, stepIndex), step, ...previousSteps.slice(stepIndex + 1)]);
}

@@ -56,2 +57,8 @@

}
if (stateManager) {
const currentStep = steps[index];
const nextStep = steps[index + 1];
stateManager.updateStep(currentStep.name, nextStep.name);
}
}

@@ -62,2 +69,8 @@

setIndex(prev);
if (stateManager) {
const currentStep = steps[index];
const previousStep = steps[index - 1];
stateManager.updateStep(currentStep.name, previousStep.name);
}
}

@@ -70,3 +83,12 @@

}
}, [steps]);
if (stateManager) {
const activeStep = stateManager.getActiveStep();
const activeIndex = steps.findIndex(step => step.name === activeStep);
if (activeIndex > -1) {
setIndex(activeIndex);
}
}
}, [steps, debug, stateManager]);
return React.createElement(ControlsContext.Provider, {

@@ -78,3 +100,4 @@ value: {

isFirst: findPreviousValid(steps, index) === index,
isLast: findNextValid(steps, index) === index
isLast: findNextValid(steps, index) === index,
activeIndex: index
}

@@ -92,4 +115,5 @@ }, React.createElement(StepContext.Provider, {

Wizard.defaultProps = {
debug: false
debug: false,
stateManager: undefined
};
export default Wizard;

@@ -14,5 +14,6 @@ import React, { createContext, useContext, useEffect, useState } from 'react';

isLast,
isLoading
isLoading,
activeIndex
} = useContext(ControlsContext);
return render(onNext, onPrevious, isFirst, isLast, isLoading);
return render(onNext, onPrevious, isFirst, isLast, isLoading, activeIndex);
};

@@ -99,3 +100,2 @@

// flow
function findNextValid(steps, currentIndex) {

@@ -116,2 +116,3 @@ var nextValid = currentIndex + steps.slice(currentIndex + 1).findIndex(el => !el.autoSkip);

onComplete,
stateManager,
debug

@@ -127,3 +128,3 @@ } = _ref;

if (!alreadyRegistered) {
setSteps(prevSteps => [...prevSteps, step]);
setSteps(previousSteps => [...previousSteps, step]);
}

@@ -134,3 +135,3 @@ }

var stepIndex = steps.findIndex(el => el.name === step.name);
setSteps(prevSteps => [...prevSteps.slice(0, stepIndex), step, ...prevSteps.slice(stepIndex + 1)]);
setSteps(previousSteps => [...previousSteps.slice(0, stepIndex), step, ...previousSteps.slice(stepIndex + 1)]);
}

@@ -167,2 +168,8 @@

}
if (stateManager) {
var currentStep = steps[index];
var nextStep = steps[index + 1];
stateManager.updateStep(currentStep.name, nextStep.name);
}
});

@@ -175,2 +182,8 @@ return _onNext.apply(this, arguments);

setIndex(prev);
if (stateManager) {
var currentStep = steps[index];
var previousStep = steps[index - 1];
stateManager.updateStep(currentStep.name, previousStep.name);
}
}

@@ -183,3 +196,12 @@

}
}, [steps]);
if (stateManager) {
var activeStep = stateManager.getActiveStep();
var activeIndex = steps.findIndex(step => step.name === activeStep);
if (activeIndex > -1) {
setIndex(activeIndex);
}
}
}, [steps, debug, stateManager]);
return React.createElement(ControlsContext.Provider, {

@@ -191,3 +213,4 @@ value: {

isFirst: findPreviousValid(steps, index) === index,
isLast: findNextValid(steps, index) === index
isLast: findNextValid(steps, index) === index,
activeIndex: index
}

@@ -205,5 +228,28 @@ }, React.createElement(StepContext.Provider, {

Wizard.defaultProps = {
debug: false
debug: false,
stateManager: undefined
};
export { Controls, ControlsContext, Step, StepContext, ValidationError, Wizard };
var UrlStateManager = {
updateStep: (currentStepName, nextStepName) => {
var currentUrl = window.location.href;
var basePath = currentUrl.includes('?') ? currentUrl.split('?')[0] : currentUrl;
var searchParams = new URLSearchParams(new URL(currentUrl).searchParams);
searchParams.set('step', nextStepName);
window.history.pushState({
activeStep: currentStepName
}, '', currentUrl);
window.history.replaceState({
activeStep: nextStepName
}, '', "".concat(basePath, "?").concat(searchParams.toString()));
},
getActiveStep: () => {
var {
href
} = window.location;
var searchParams = new URLSearchParams(new URL(href).searchParams);
return searchParams.get('step');
}
};
export { Controls, ControlsContext, Step, StepContext, UrlStateManager, ValidationError, Wizard };

@@ -1,2 +0,2 @@

import React,{createContext,useContext,useEffect,useState}from"react";var ControlsContext=createContext(null),Controls=e=>{var{render:t}=e,{onNext:n,onPrevious:r,isFirst:o,isLast:a,isLoading:i}=useContext(ControlsContext);return t(n,r,o,a,i)},StepContext=createContext(null),Step=e=>{var{children:t,name:n,validator:r,autoSkip:o}=e,{registerStep:a,activeStep:i,updateStep:s,initialized:u}=useContext(StepContext),l={name:n,validator:r,autoSkip:o};return useEffect(()=>{u||a(l)},[n]),useEffect(()=>{u&&s(l)},[o,r]),i.name!==n?null:t};function asyncGeneratorStep(e,t,n,r,o,a,i){try{var s=e[a](i),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,o)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){asyncGeneratorStep(a,r,o,i,s,"next",e)}function s(e){asyncGeneratorStep(a,r,o,i,s,"throw",e)}i(void 0)})}}function findNextValid(e,t){var n=t+e.slice(t+1).findIndex(e=>!e.autoSkip);return e.length>n?n+1:n}function findPreviousValid(e,t){return t-1-[...e].reverse().slice(e.length-t).findIndex(e=>!e.autoSkip)}Step.defaultProps={validator:null,autoSkip:!1};class ValidationError extends Error{}var Wizard=e=>{var{children:t,onComplete:n,debug:r}=e,[o,a]=useState(0),[i,s]=useState([]),[u,l]=useState(!1);function d(){return(d=_asyncToGenerator(function*(){var{validator:e}=i[o],t=findNextValid(i,o),r=t===o?()=>n(i[o].name):()=>a(t);if(e)try{l(!0),yield e(),r()}catch(e){if(!(e instanceof ValidationError))throw e;console.error("ReactLosen",e)}finally{l(!1)}else r()})).apply(this,arguments)}return useEffect(()=>{r&&console.debug("steps updated",i)},[i]),React.createElement(ControlsContext.Provider,{value:{onNext:function(){return d.apply(this,arguments)},onPrevious:function(){var e=findPreviousValid(i,o);a(e)},isLoading:u,isFirst:findPreviousValid(i,o)===o,isLast:findNextValid(i,o)===o}},React.createElement(StepContext.Provider,{value:{registerStep:function(e){i.map(e=>e.name).includes(e.name)||s(t=>[...t,e])},activeStep:i[o]||{},initialized:!!i[o],updateStep:function(e){var t=i.findIndex(t=>t.name===e.name);s(n=>[...n.slice(0,t),e,...n.slice(t+1)])}}},t))};Wizard.defaultProps={debug:!1};export{Controls,ControlsContext,Step,StepContext,ValidationError,Wizard};
import React,{createContext,useContext,useEffect,useState}from"react";var ControlsContext=createContext(null),Controls=e=>{var{render:t}=e,{onNext:n,onPrevious:a,isFirst:r,isLast:i,isLoading:o,activeIndex:s}=useContext(ControlsContext);return t(n,a,r,i,o,s)},StepContext=createContext(null),Step=e=>{var{children:t,name:n,validator:a,autoSkip:r}=e,{registerStep:i,activeStep:o,updateStep:s,initialized:c}=useContext(StepContext),u={name:n,validator:a,autoSkip:r};return useEffect(()=>{c||i(u)},[n]),useEffect(()=>{c&&s(u)},[r,a]),o.name!==n?null:t};function asyncGeneratorStep(e,t,n,a,r,i,o){try{var s=e[i](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(a,r)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise(function(a,r){var i=e.apply(t,n);function o(e){asyncGeneratorStep(i,a,r,o,s,"next",e)}function s(e){asyncGeneratorStep(i,a,r,o,s,"throw",e)}o(void 0)})}}function findNextValid(e,t){var n=t+e.slice(t+1).findIndex(e=>!e.autoSkip);return e.length>n?n+1:n}function findPreviousValid(e,t){return t-1-[...e].reverse().slice(e.length-t).findIndex(e=>!e.autoSkip)}Step.defaultProps={validator:null,autoSkip:!1};class ValidationError extends Error{}var Wizard=e=>{var{children:t,onComplete:n,stateManager:a,debug:r}=e,[i,o]=useState(0),[s,c]=useState([]),[u,d]=useState(!1);function l(){return(l=_asyncToGenerator(function*(){var{validator:e}=s[i],t=findNextValid(s,i),r=t===i?()=>n(s[i].name):()=>o(t);if(e)try{d(!0),yield e(),r()}catch(e){if(!(e instanceof ValidationError))throw e;console.error("ReactLosen",e)}finally{d(!1)}else r();if(a){var c=s[i],u=s[i+1];a.updateStep(c.name,u.name)}})).apply(this,arguments)}return useEffect(()=>{if(r&&console.debug("steps updated",s),a){var e=a.getActiveStep(),t=s.findIndex(t=>t.name===e);t>-1&&o(t)}},[s,r,a]),React.createElement(ControlsContext.Provider,{value:{onNext:function(){return l.apply(this,arguments)},onPrevious:function(){var e=findPreviousValid(s,i);if(o(e),a){var t=s[i],n=s[i-1];a.updateStep(t.name,n.name)}},isLoading:u,isFirst:findPreviousValid(s,i)===i,isLast:findNextValid(s,i)===i,activeIndex:i}},React.createElement(StepContext.Provider,{value:{registerStep:function(e){s.map(e=>e.name).includes(e.name)||c(t=>[...t,e])},activeStep:s[i]||{},initialized:!!s[i],updateStep:function(e){var t=s.findIndex(t=>t.name===e.name);c(n=>[...n.slice(0,t),e,...n.slice(t+1)])}}},t))};Wizard.defaultProps={debug:!1,stateManager:void 0};var UrlStateManager={updateStep:(e,t)=>{var n=window.location.href,a=n.includes("?")?n.split("?")[0]:n,r=new URLSearchParams(new URL(n).searchParams);r.set("step",t),window.history.pushState({activeStep:e},"",n),window.history.replaceState({activeStep:t},"","".concat(a,"?").concat(r.toString()))},getActiveStep:()=>{var{href:e}=window.location;return new URLSearchParams(new URL(e).searchParams).get("step")}};export{Controls,ControlsContext,Step,StepContext,UrlStateManager,ValidationError,Wizard};
//# sourceMappingURL=index.min.js.map
{
"name": "react-losen",
"description": "A super customisable Wizard for React and React Native",
"version": "2.0.0-8",
"version": "2.0.0-9",
"license": "MIT",

@@ -44,2 +44,4 @@ "files": [

"docz-theme-default": "^0.13.7",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.15.1",
"eslint": "^5.13.0",

@@ -55,3 +57,3 @@ "eslint-config-airbnb": "^17.1.0",

"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^1.2.0",
"eslint-plugin-react-hooks": "^2.3.0",
"flow-bin": "^0.96.0",

@@ -61,4 +63,5 @@ "jest": "^24.1.0",

"prettier": "^1.16.4",
"react-dom": "16",
"tachyons": "^4.11.1"
}
}

@@ -59,2 +59,6 @@ ---

Include the following polyfills to support older browsers:
- `array-findindex-polyfill`
- `url-search-params-polyfill`
### Developing

@@ -61,0 +65,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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