jobiqo-cl
Version:
[](https://circleci.com/gh/jobiqo/jobiqo-cl)
58 lines (52 loc) • 2.56 kB
JavaScript
;
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 index = require('../../02-atoms/01-forms/01-button/index.js');
var index$1 = require('../../02-atoms/06-layout/07-spacing/index.js');
var ArrowLongRight = require('../../../icons/ArrowLongRight.js');
var index$2 = require('./context/index.js');
var index$3 = require('./styles/index.js');
/**
* @file index.tsx
*
* @fileoverview Renders a multi-step wizard.
*/
/**
* Called when user clicks next.
*/
const handleNextChanged = (currentStep, setCurrentStep, onNext) => {
setCurrentStep(currentStep + 1);
if (onNext) {
onNext();
}
};
/**
* Called when user clicks next.
*/
const handlePreviousChanged = (currentStep, setCurrentStep, onPrevious) => {
setCurrentStep(currentStep - 1);
if (onPrevious) {
onPrevious();
}
};
/**
* A multistep wizard that can be used for long forms or things that need a lot of
* input from a user and where detailed information
* about each information group is important.
*/
const Wizard = ({ children, nextLabel, previousLabel, numberSteps, steps, finishLabel, onFinish, onNext, onPrevious }) => {
const [currentStep, setCurrentStep] = React.useState(1);
return (React__default.createElement(index$2.WizardContext.Provider, { value: { currentStep, numberSteps, steps } },
children,
React__default.createElement(index$1.Spacing, { size: "large" }),
React__default.createElement(index$3.WizardActions, null,
currentStep < numberSteps && (React__default.createElement(index.Button, { type: "button", buttonStyle: "secondary", onClick: e => handleNextChanged(currentStep, setCurrentStep, onNext) },
nextLabel,
"\u00A0",
React__default.createElement(ArrowLongRight.ArrowLongRightIcon, { title: "Next" }))),
currentStep === numberSteps && (React__default.createElement(index.Button, Object.assign({ type: "button", buttonStyle: "secondary" }, (onFinish ? { onClick: onFinish } : null)), finishLabel)),
currentStep > 1 && (React__default.createElement(index.Button, { type: "button", buttonStyle: "secondary", raised: false, onClick: e => handlePreviousChanged(currentStep, setCurrentStep, onPrevious) }, previousLabel)))));
};
exports.Wizard = Wizard;