use-wizard
Version:
A dead-easy-to-use light-weight react hook to handle multi-paths wizards (and simple wizards too) and navigate into them.
27 lines • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNextStep = void 0;
var isStepLastOfLasts_1 = require("./isStepLastOfLasts");
var isStepLastOfItsLevel_1 = require("./isStepLastOfItsLevel");
var getNextStepWhenItsNotLast_1 = require("./getNextStep/getNextStepWhenItsNotLast");
var getNextStepWhenItsLast_1 = require("./getNextStep/getNextStepWhenItsLast");
function getNextStep(step, options) {
var _a;
if (typeof step === "number") {
throw new Error("Wizard: internal error, step must be a string");
}
if (!options) {
throw new Error("Wizard: a map must exist");
}
if (isStepLastOfLasts_1.isStepLastOfLasts(options, step)) {
console.log("Wizard: next() should not be called on the last element");
return step;
}
var stepIsLastOfItsLevel = (_a = isStepLastOfItsLevel_1.isStepLastOfItsLevel(options, step)) !== null && _a !== void 0 ? _a : false;
if (stepIsLastOfItsLevel) {
return getNextStepWhenItsLast_1.getNextStepWhenItsLast(options, step);
}
return getNextStepWhenItsNotLast_1.getNextStepWhenItsNotLast(options, step);
}
exports.getNextStep = getNextStep;
//# sourceMappingURL=getNextStep.js.map