@catho/quantum
Version:
Catho react components
32 lines (31 loc) • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.percentToDegrees = exports.handlerValuePrepare = exports.handlerStepPrepare = void 0;
/* eslint-disable no-console */
var MAXIMUM_STEPS = 6;
var MINIMUM_STEPS = 1;
var handlerValuePrepare = exports.handlerValuePrepare = function handlerValuePrepare(total) {
if (total > MAXIMUM_STEPS && total > 0) return MAXIMUM_STEPS;
if (total < MINIMUM_STEPS) return MINIMUM_STEPS;
return total;
};
var handlerStepPrepare = exports.handlerStepPrepare = function handlerStepPrepare(index, total) {
if (index <= total) {
var _index = handlerValuePrepare(index);
return _index;
}
console.warn('Stepper component: the "index" prop can not be bigger than "total" prop. The index value was settled now to 1.');
return 1;
};
var handleProgressPosition = function handleProgressPosition(progressPercent, isOverHalf) {
var position = isOverHalf ? progressPercent - 50 : progressPercent;
return Math.round(position * 180 / 50) - 90;
};
var percentToDegrees = exports.percentToDegrees = function percentToDegrees(progressPercent) {
var isOverHalf = progressPercent > 50;
var firstDegree = isOverHalf ? -90 : 90;
var secondDegree = handleProgressPosition(progressPercent, isOverHalf);
return [firstDegree, secondDegree];
};