UNPKG

tdesign-mobile-vue

Version:
78 lines (74 loc) 2.62 kB
/** * tdesign v1.9.3 * (c) 2025 TDesign Group * @license MIT */ import { _ as _slicedToArray } from '../_chunks/dep-26b97ced.mjs'; import { isNumber } from 'lodash-es'; import { usePrefixClass } from '../hooks/useClass.mjs'; import '../_chunks/dep-a953013f.mjs'; import 'vue'; import '../config-provider/useConfig.mjs'; import '../_chunks/dep-900db0e1.mjs'; import '../_chunks/dep-4915223e.mjs'; import '../config-provider/context.mjs'; import '../_common/js/global-config/mobile/default-config.mjs'; import '../_common/js/global-config/mobile/locale/zh_CN.mjs'; import '../_chunks/dep-bca0f578.mjs'; import '../_chunks/dep-6b2b02fd.mjs'; import '../_chunks/dep-c6f44a15.mjs'; import '../_chunks/dep-c984d53e.mjs'; import '../config-provider/type.mjs'; function toCamel(str) { return str.replace(/^\S/, function (m) { return m.toUpperCase(); }); } var isBrowser = typeof window !== "undefined"; var sleep = function sleep(ms) { return new Promise(function (resolve) { return setTimeout(resolve, ms); }); }; var uniqueFactory = function uniqueFactory(compName) { var number = 0; var prefixClass = usePrefixClass(); return function () { return "".concat(prefixClass.value, "-").concat(compName, "_").concat(number++); }; }; var convertUnit = function convertUnit(val) { if (val == null) return 0; return isNumber(val) ? "".concat(val, "px") : val; }; var reconvertUnit = function reconvertUnit(val) { if (val == null) return 0; return isNumber(val) ? Number(val) : Number(val.slice(0, -2)); }; var formatNumber = function formatNumber(value) { var allowDecimal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var allowNegative = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; if (allowDecimal) { var index = value.indexOf("."); if (index !== -1) { value = "".concat(value.slice(0, index + 1)).concat(value.slice(index).replace(/\./g, "")); } } else { var _value$split = value.split("."), _value$split2 = _slicedToArray(_value$split, 1), _value$split2$ = _value$split2[0], splitValue = _value$split2$ === void 0 ? "" : _value$split2$; value = splitValue; } if (allowNegative) { var _index = value.indexOf("-"); if (_index !== -1) { value = "".concat(value.slice(0, _index + 1)).concat(value.slice(_index).replace(/-/g, "")); } } else { value = value.replace(/-/g, ""); } return value.replace(/[^\d.-]/g, ""); }; export { convertUnit, formatNumber, isBrowser, reconvertUnit, sleep, toCamel, uniqueFactory }; //# sourceMappingURL=util.mjs.map