define(["require", "exports", "../common/index", "@syncfusion/ej2-base"], function (require, exports, index_1, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function checkIsNumberAndGetNumber(cell, locale, groupSep, decimalSep, currencySym) {
var cellValue = cell.value;
if (index_1.isNumber(cellValue)) {
return { isNumber: true, value: cellValue };
}
if (cellValue && typeof cellValue === 'string') {
if (currencySym && cellValue.includes(currencySym) && (cell.format.includes(currencySym) || cell.format.includes('$'))) {
cellValue = cellValue.replace(currencySym, '').trim();
}
if (groupSep && cellValue.includes(groupSep) && parseThousandSeparator(cellValue, locale, groupSep, decimalSep)) {
cellValue = cellValue.split(groupSep).join('').trim();
}
if (!decimalSep) {
decimalSep = ej2_base_1.getNumericObject(locale).decimal;
}
if (decimalSep !== '.' && cellValue.includes(decimalSep)) {
cellValue = cellValue.replace(decimalSep, '.').trim();
}
if (index_1.isNumber(cellValue)) {
return { isNumber: true, value: cellValue };
}
}
return { isNumber: false, value: cellValue };
}
exports.checkIsNumberAndGetNumber = checkIsNumberAndGetNumber;
function parseThousandSeparator(value, locale, groupSep, decimalSep) {
var isParsed = false;
var number = 123456;
var parsedNum = number.toLocaleString(locale);
var splitedNum = parsedNum.split(groupSep).reverse();
var splitedValue = value.split(decimalSep)[0].split(groupSep);
for (var i = 0; i < splitedValue.length; i++) {
if (i === splitedValue.length - 1) {
isParsed = splitedValue[i].length === splitedNum[0].length;
}
else {
isParsed = !ej2_base_1.isUndefined(splitedNum[1]) && (i === 0 ? splitedValue[i].length <= splitedNum[1].length :
splitedValue[i].length === splitedNum[1].length);
}
if (!isParsed) {
break;
}
}
return isParsed;
}
exports.parseThousandSeparator = parseThousandSeparator;
});
|