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

react-groove

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-groove - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

156

index.js

@@ -1,15 +0,147 @@

import React from 'react';
import { render } from 'react-dom';
import SimpleExample from './src/SimpleExample';
import './index.css';
'use strict';
const App = props => {
return (
<div className="container">
<SimpleExample />
{/* another demo... */}
</div>
);
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = require('react');
var React__default = _interopDefault(React);
var Workflow = function Workflow(_ref) {
var children = _ref.children,
_ref$step = _ref.step,
step = _ref$step === void 0 ? 0 : _ref$step;
return React__default.createElement(React__default.Fragment, null, children[step]);
};
render(<App />, document.getElementById('app'));
Workflow.Step = function (_ref2) {
var children = _ref2.children;
return React__default.createElement(React__default.Fragment, null, children);
};
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
var createReducer = function createReducer(steps) {
return function (state, action) {
if (!isNaN(steps)) return _objectSpread({}, state, {
active: action
});
return _objectSpread({}, steps[action](state), {
active: action
});
};
};
function useWorkflow(steps) {
var initialState = React.useMemo(function () {
return isNaN(steps) ? steps[0]() : {};
}, [steps]);
var _useReducer = React.useReducer(createReducer(steps), _objectSpread({}, initialState, {
active: 0
})),
_useReducer2 = _slicedToArray(_useReducer, 2),
state = _useReducer2[0],
dispatch = _useReducer2[1];
var length = React.useMemo(function () {
return steps.length || steps;
}); // TODO: consider allowing an updater function in next
var next = React.useCallback(function () {
if (state.active >= length - 1) return; // consider implicit reset at end?
dispatch(state.active + 1);
}, [state.active]);
var prev = React.useCallback(function () {
if (state.active <= 0) return; // hard stop at 0 is probably expected behavior
dispatch(state.active - 1);
}, [state.active]);
var reset = React.useCallback(function () {
dispatch(0);
});
var bind = React.useCallback(function () {
return {
step: state.active
};
}, [state]);
return [state, {
next: next,
prev: prev,
reset: reset
}, bind];
}
exports.Workflow = Workflow;
exports.useWorkflow = useWorkflow;

6

package.json
{
"name": "react-groove",
"version": "0.1.0",
"version": "0.1.1",
"description": "Simple and reusable React procedures",

@@ -42,5 +42,3 @@ "main": "index.js",

"peerDependencies": {
"prop-types": "^15.7.0",
"react": "^16.8.0",
"react-dom": "^16.8.0"
"react": "^16.8.0"
},

@@ -47,0 +45,0 @@ "husky": {

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