Repository URL to install this package:
|
Version:
3.0.12 ▾
|
"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;
const getDeviceColSpan = props => {
const currentDevice = state_1.application.deviceType;
return props[currentDevice + 'ColSpan'];
};
exports.getDeviceColSpan = getDeviceColSpan;
const getCarouselPanelWidth = props => {
const {
list
} = props;
if (exotic_1.isArray(list) !== undefined) {
const deviceColSpan = getDeviceColSpan(props);
const deviceColSpanAsNumber = getValidNumber(deviceColSpan);
const colSpan = deviceColSpanAsNumber > list.length ? list.length : deviceColSpanAsNumber;
return 100 / colSpan;
} else {
return 100;
}
};
exports.getCarouselPanelWidth = getCarouselPanelWidth; // Added temporarily :: Needs to be imported from mono-libraries exotic
function getValidString(str) {
if (str) {
const trimmedStr = str.trim();
if (trimmedStr && trimmedStr.length > 0) {
return trimmedStr;
}
}
return '';
}
exports.getValidString = getValidString; // Added temporarily :: Needs to be imported from mono-libraries exotic
function getValidNumber(num) {
/**
* @todo
* 10px -> 10
* 10 -> 10
* remove special characters (1 0 px -> 10)
* return as Number data type
*/
if (exotic_1.isNumber(num)) {
return num;
}
const validNumberString = getValidString(num);
const formatNumber = validNumberString.replace(/[^0-9-.]+/, '');
console.log('formatNumber', formatNumber);
return +formatNumber;
}
exports.getValidNumber = getValidNumber; // Added temporarily :: Needs to be imported from mono-libraries exotic
function addProtocolsWithURL(url) {
const validURL = getValidString(url);
if (validURL && validURL.length > 0) {
const noProtocolURL = validURL.replace(/(^\w+:|^)\/\//, '');
const updatedURL = '//' + noProtocolURL;
return updatedURL;
}
return validURL;
}
exports.addProtocolsWithURL = addProtocolsWithURL; //# sourceMappingURL=deps.js.map