1
0
Fork 0
react-playground/node_modules/@mui/x-date-pickers/internals/utils/createStepNavigation.js
Techognito fc0f69dacb Added Statistics calculation
Statistics now show calculated values
2025-09-04 17:30:00 +02:00

52 lines
No EOL
1.8 KiB
JavaScript

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DEFAULT_STEP_NAVIGATION = void 0;
exports.createStepNavigation = createStepNavigation;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
const DEFAULT_STEP_NAVIGATION = exports.DEFAULT_STEP_NAVIGATION = {
hasNextStep: false,
hasSeveralSteps: false,
goToNextStep: () => {},
areViewsInSameStep: () => true
};
/**
* Create an object that determines whether there is a next step and allows to go to the next step.
* @param {CreateStepNavigationParameters<TStep>} parameters The parameters of the createStepNavigation function
* @returns {CreateStepNavigationReturnValue} The return value of the createStepNavigation function
*/
function createStepNavigation(parameters) {
const {
steps,
isViewMatchingStep,
onStepChange
} = parameters;
return parametersBis => {
if (steps == null) {
return DEFAULT_STEP_NAVIGATION;
}
const currentStepIndex = steps.findIndex(step => isViewMatchingStep(parametersBis.view, step));
const nextStep = currentStepIndex === -1 || currentStepIndex === steps.length - 1 ? null : steps[currentStepIndex + 1];
return {
hasNextStep: nextStep != null,
hasSeveralSteps: steps.length > 1,
goToNextStep: () => {
if (nextStep == null) {
return;
}
onStepChange((0, _extends2.default)({}, parametersBis, {
step: nextStep
}));
},
areViewsInSameStep: (viewA, viewB) => {
const stepA = steps.find(step => isViewMatchingStep(viewA, step));
const stepB = steps.find(step => isViewMatchingStep(viewB, step));
return stepA === stepB;
}
};
};
}