This commit is contained in:
2023-08-11 10:45:20 +08:00
commit 161ca982f3
31850 changed files with 2706500 additions and 0 deletions

60
node_modules/vant/lib/utils/format/number.js generated vendored Normal file
View File

@ -0,0 +1,60 @@
"use strict";
exports.__esModule = true;
exports.range = range;
exports.formatNumber = formatNumber;
exports.addNumber = addNumber;
function range(num, min, max) {
return Math.min(Math.max(num, min), max);
}
function trimExtraChar(value, _char, regExp) {
var index = value.indexOf(_char);
var prefix = '';
if (index === -1) {
return value;
}
if (_char === '-' && index !== 0) {
return value.slice(0, index);
}
if (_char === '.' && value.match(/^(\.|-\.)/)) {
prefix = index ? '-0' : '0';
}
return prefix + value.slice(0, index + 1) + value.slice(index).replace(regExp, '');
}
function formatNumber(value, allowDot, allowMinus) {
if (allowDot === void 0) {
allowDot = true;
}
if (allowMinus === void 0) {
allowMinus = true;
}
if (allowDot) {
value = trimExtraChar(value, '.', /\./g);
} else {
value = value.split('.')[0];
}
if (allowMinus) {
value = trimExtraChar(value, '-', /-/g);
} else {
value = value.replace(/-/, '');
}
var regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
return value.replace(regExp, '');
} // add num and avoid float number
function addNumber(num1, num2) {
var cardinal = Math.pow(10, 10);
return Math.round((num1 + num2) * cardinal) / cardinal;
}

26
node_modules/vant/lib/utils/format/string.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
"use strict";
exports.__esModule = true;
exports.camelize = camelize;
exports.padZero = padZero;
var camelizeRE = /-(\w)/g;
function camelize(str) {
return str.replace(camelizeRE, function (_, c) {
return c.toUpperCase();
});
}
function padZero(num, targetLength) {
if (targetLength === void 0) {
targetLength = 2;
}
var str = num + '';
while (str.length < targetLength) {
str = '0' + str;
}
return str;
}

68
node_modules/vant/lib/utils/format/unit.js generated vendored Normal file
View File

@ -0,0 +1,68 @@
"use strict";
exports.__esModule = true;
exports.addUnit = addUnit;
exports.unitToPx = unitToPx;
var _ = require("..");
var _number = require("../validate/number");
function addUnit(value) {
if (!(0, _.isDef)(value)) {
return undefined;
}
value = String(value);
return (0, _number.isNumeric)(value) ? value + "px" : value;
} // cache
var rootFontSize;
function getRootFontSize() {
if (!rootFontSize) {
var doc = document.documentElement;
var fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
rootFontSize = parseFloat(fontSize);
}
return rootFontSize;
}
function convertRem(value) {
value = value.replace(/rem/g, '');
return +value * getRootFontSize();
}
function convertVw(value) {
value = value.replace(/vw/g, '');
return +value * window.innerWidth / 100;
}
function convertVh(value) {
value = value.replace(/vh/g, '');
return +value * window.innerHeight / 100;
}
function unitToPx(value) {
if (typeof value === 'number') {
return value;
}
if (_.inBrowser) {
if (value.indexOf('rem') !== -1) {
return convertRem(value);
}
if (value.indexOf('vw') !== -1) {
return convertVw(value);
}
if (value.indexOf('vh') !== -1) {
return convertVh(value);
}
}
return parseFloat(value);
}