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

react-losen

Package Overview
Dependencies
Maintainers
4
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-6 to 2.0.0-7

6

dist-node/index.js

@@ -53,3 +53,3 @@ 'use strict';

}
}, [autoSkip]);
}, [autoSkip, validator]);

@@ -195,3 +195,3 @@ if (activeStep.name !== name) {

const next = findNextValid(steps, index);
const nextAction = findNextValid(steps, index) === index ? () => onComplete(steps[index].name) : () => setIndex(next);
const nextAction = next === index ? () => onComplete(steps[index].name) : () => setIndex(next);

@@ -201,3 +201,3 @@ if (validator) {

setLoadingState(true);
yield new Promise(validator);
yield validator();
nextAction();

@@ -204,0 +204,0 @@ } catch (error) {

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

"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)},StepContext=React.createContext(null),Step=({children:e,name:t,validator:n,autoSkip:r})=>{const o=React.useContext(StepContext),a=o.registerStep,i=o.activeStep,s=o.updateStep,l=o.initialized,c={name:t,validator:n,autoSkip:r};return React.useEffect(()=>{l||a(c)},[t]),React.useEffect(()=>{l&&s(c)},[r]),i.name!==t?null:e};function asyncGeneratorStep(e,t,n,r,o,a,i){try{var s=e[a](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).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 _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_nonIterableRest()}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var n=[],r=!0,o=!1,a=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){o=!0,a=e}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(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,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 e=s[o].validator,n=findNextValid(s,o),r=findNextValid(s,o)===o?()=>t(s[o].name):()=>a(n);if(e)try{d(!0),yield new Promise(e),r()}catch(e){if(!(e instanceof ValidationError))throw e;console.error("ReactLosen",e)}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 e=findPreviousValid(s,o);a(e)},isLoading:u,isFirst:findPreviousValid(s,o)===o,isLast:findNextValid(s,o)===o}},React__default.createElement(StepContext.Provider,{value:{registerStep:function(e){s.map(e=>e.name).includes(e.name)||l(t=>[...t,e])},activeStep:s[o]||{},initialized:!!s[o],updateStep:function(e){const t=s.findIndex(t=>t.name===e.name);l(n=>[...n.slice(0,t),e,...n.slice(t+1)])}}},e))};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)},StepContext=React.createContext(null),Step=({children:e,name:t,validator:n,autoSkip:r})=>{const o=React.useContext(StepContext),a=o.registerStep,i=o.activeStep,s=o.updateStep,l=o.initialized,c={name:t,validator:n,autoSkip:r};return React.useEffect(()=>{l||a(c)},[t]),React.useEffect(()=>{l&&s(c)},[r,n]),i.name!==t?null:e};function asyncGeneratorStep(e,t,n,r,o,a,i){try{var s=e[a](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).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 _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_nonIterableRest()}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var n=[],r=!0,o=!1,a=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){o=!0,a=e}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(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,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 e=s[o].validator,n=findNextValid(s,o),r=n===o?()=>t(s[o].name):()=>a(n);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()})).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 e=findPreviousValid(s,o);a(e)},isLoading:u,isFirst:findPreviousValid(s,o)===o,isLast:findNextValid(s,o)===o}},React__default.createElement(StepContext.Provider,{value:{registerStep:function(e){s.map(e=>e.name).includes(e.name)||l(t=>[...t,e])},activeStep:s[o]||{},initialized:!!s[o],updateStep:function(e){const t=s.findIndex(t=>t.name===e.name);l(n=>[...n.slice(0,t),e,...n.slice(t+1)])}}},e))};Wizard.defaultProps={debug:!1},exports.Controls=Controls,exports.ControlsContext=ControlsContext,exports.Step=Step,exports.StepContext=StepContext,exports.ValidationError=ValidationError,exports.Wizard=Wizard;
//# sourceMappingURL=index.min.js.map

@@ -30,3 +30,3 @@ import { useEffect, createContext, useContext } from 'react';

}
}, [autoSkip]);
}, [autoSkip, validator]);

@@ -33,0 +33,0 @@ if (activeStep.name !== name) {

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

const next = findNextValid(steps, index);
const nextAction = findNextValid(steps, index) === index ? () => onComplete(steps[index].name) : () => setIndex(next);
const nextAction = next === index ? () => onComplete(steps[index].name) : () => setIndex(next);

@@ -40,3 +40,3 @@ if (validator) {

setLoadingState(true);
await new Promise(validator);
await validator();
nextAction();

@@ -43,0 +43,0 @@ } catch (error) {

@@ -46,3 +46,3 @@ import React, { createContext, useContext, useEffect, useState } from 'react';

}
}, [autoSkip]);
}, [autoSkip, validator]);

@@ -188,3 +188,3 @@ if (activeStep.name !== name) {

const next = findNextValid(steps, index);
const nextAction = findNextValid(steps, index) === index ? () => onComplete(steps[index].name) : () => setIndex(next);
const nextAction = next === index ? () => onComplete(steps[index].name) : () => setIndex(next);

@@ -194,3 +194,3 @@ if (validator) {

setLoadingState(true);
yield new Promise(validator);
yield validator();
nextAction();

@@ -197,0 +197,0 @@ } catch (error) {

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

import React,{createContext,useContext,useEffect,useState}from"react";const ControlsContext=createContext(null),Controls=e=>{let t=e.render;const n=useContext(ControlsContext);return t(n.onNext,n.onPrevious,n.isFirst,n.isLast,n.isLoading)},StepContext=createContext(null),Step=e=>{let t=e.children,n=e.name,r=e.validator,o=e.autoSkip;const i=useContext(StepContext),a=i.registerStep,s=i.activeStep,l=i.updateStep,u=i.initialized,c={name:n,validator:r,autoSkip:o};return useEffect(()=>{u||a(c)},[n]),useEffect(()=>{u&&l(c)},[o]),s.name!==n?null:t};function asyncGeneratorStep(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){asyncGeneratorStep(i,r,o,a,s,"next",e)}function s(e){asyncGeneratorStep(i,r,o,a,s,"throw",e)}a(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){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(o)throw i}}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=e=>{let t=e.children,n=e.onComplete,r=e.debug;const o=_slicedToArray(useState(0),2),i=o[0],a=o[1],s=_slicedToArray(useState([]),2),l=s[0],u=s[1],c=_slicedToArray(useState(!1),2),d=c[0],f=c[1];function p(){return(p=_asyncToGenerator(function*(){const e=l[i].validator,t=findNextValid(l,i),r=findNextValid(l,i)===i?()=>n(l[i].name):()=>a(t);if(e)try{f(!0),yield new Promise(e),r()}catch(e){if(!(e instanceof ValidationError))throw e;console.error("ReactLosen",e)}finally{f(!1)}else r()})).apply(this,arguments)}return useEffect(()=>{r&&console.debug("steps updated",l)},[l]),React.createElement(ControlsContext.Provider,{value:{onNext:function(){return p.apply(this,arguments)},onPrevious:function(){const e=findPreviousValid(l,i);a(e)},isLoading:d,isFirst:findPreviousValid(l,i)===i,isLast:findNextValid(l,i)===i}},React.createElement(StepContext.Provider,{value:{registerStep:function(e){l.map(e=>e.name).includes(e.name)||u(t=>[...t,e])},activeStep:l[i]||{},initialized:!!l[i],updateStep:function(e){const t=l.findIndex(t=>t.name===e.name);u(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";const ControlsContext=createContext(null),Controls=e=>{let t=e.render;const n=useContext(ControlsContext);return t(n.onNext,n.onPrevious,n.isFirst,n.isLast,n.isLoading)},StepContext=createContext(null),Step=e=>{let t=e.children,n=e.name,r=e.validator,o=e.autoSkip;const i=useContext(StepContext),a=i.registerStep,s=i.activeStep,l=i.updateStep,u=i.initialized,c={name:n,validator:r,autoSkip:o};return useEffect(()=>{u||a(c)},[n]),useEffect(()=>{u&&l(c)},[o,r]),s.name!==n?null:t};function asyncGeneratorStep(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){asyncGeneratorStep(i,r,o,a,s,"next",e)}function s(e){asyncGeneratorStep(i,r,o,a,s,"throw",e)}a(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){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(o)throw i}}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=e=>{let t=e.children,n=e.onComplete,r=e.debug;const o=_slicedToArray(useState(0),2),i=o[0],a=o[1],s=_slicedToArray(useState([]),2),l=s[0],u=s[1],c=_slicedToArray(useState(!1),2),d=c[0],f=c[1];function p(){return(p=_asyncToGenerator(function*(){const e=l[i].validator,t=findNextValid(l,i),r=t===i?()=>n(l[i].name):()=>a(t);if(e)try{f(!0),yield e(),r()}catch(e){if(!(e instanceof ValidationError))throw e;console.error("ReactLosen",e)}finally{f(!1)}else r()})).apply(this,arguments)}return useEffect(()=>{r&&console.debug("steps updated",l)},[l]),React.createElement(ControlsContext.Provider,{value:{onNext:function(){return p.apply(this,arguments)},onPrevious:function(){const e=findPreviousValid(l,i);a(e)},isLoading:d,isFirst:findPreviousValid(l,i)===i,isLast:findNextValid(l,i)===i}},React.createElement(StepContext.Provider,{value:{registerStep:function(e){l.map(e=>e.name).includes(e.name)||u(t=>[...t,e])},activeStep:l[i]||{},initialized:!!l[i],updateStep:function(e){const t=l.findIndex(t=>t.name===e.name);u(n=>[...n.slice(0,t),e,...n.slice(t+1)])}}},t))};Wizard.defaultProps={debug:!1};export{Controls,ControlsContext,Step,StepContext,ValidationError,Wizard};
//# sourceMappingURL=index.min.js.map
{
"name": "react-losen",
"description": "A super customisable Wizard for React and React Native",
"version": "2.0.0-6",
"version": "2.0.0-7",
"license": "MIT",

@@ -6,0 +6,0 @@ "esnext": "dist-src/index.js",

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