Repository URL to install this package:
|
Version:
2.8.4 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const state_1 = require("@skava/state");
const exotic_1 = require("exotic");
const state_2 = require("./state");
function initMediaCarouselState() {
return new state_2.MediaCarouselState();
}
exports.initMediaCarouselState = initMediaCarouselState;
function toMediaCarouselState(props) {
if (props.state === undefined) {
const state = initMediaCarouselState();
state.update(props);
return state;
} else {
return props.state;
}
}
exports.toMediaCarouselState = toMediaCarouselState;
/**
* @todo make common in @skava/state
*
*/
const getDeviceType = () => {
return state_1.application.isDesktop ? 'desktop' : state_1.application.isTablet ? 'tablet' : 'mobile';
};
exports.getDeviceType = getDeviceType;
const getValidNumber = val => {
/**
* @todo validation must be done
*/
let validNumber;
if (exotic_1.isNumber(val)) {
validNumber = val;
} else if (exotic_1.isString(val) && val.includes('px')) {
val.replace('px', '');
validNumber = exotic_1.toNumber(val);
} else if (exotic_1.isString(val)) {
validNumber = exotic_1.toNumber(val);
}
return validNumber;
};
exports.getValidNumber = getValidNumber;
const getDeviceColSpan = props => {
const currentDevice = getDeviceType();
return props[currentDevice + 'ColSpan'];
};
exports.getDeviceColSpan = getDeviceColSpan;
const getCarouselPanelWidth = props => {
const {
list
} = props;
if (exotic_1.isArray(list) !== undefined) {
const deviceColSpan = getDeviceColSpan(props);
const colSpan = deviceColSpan > list.length ? list.length : deviceColSpan;
return 100 / colSpan;
} else {
return 100;
}
};
exports.getCarouselPanelWidth = getCarouselPanelWidth; //# sourceMappingURL=deps.js.map