tdesign-mobile-vue
Version:
tdesign-mobile-vue
65 lines (61 loc) • 1.7 kB
JavaScript
/**
* tdesign v1.9.3
* (c) 2025 TDesign Group
* @license MIT
*/
import dayjs from 'dayjs';
import { a as advancedFormat } from '../../../_chunks/dep-62c51e6d.js';
import { c as customParseFormat } from '../../../_chunks/dep-be103574.js';
import { EPickerCols, TIME_FORMAT } from './const.js';
import '../../../_chunks/dep-0d44b254.js';
dayjs.extend(advancedFormat);
dayjs.extend(customParseFormat);
function validateInputValue(value, format) {
return dayjs(value, format).format(format) === value;
}
function formatInputValue(value, format) {
return dayjs(value, format).format(format);
}
function closestLookup(availableArr, calcVal, step) {
if (step <= 1) return calcVal;
return availableArr.sort(function (a, b) {
return Math.abs(calcVal + 1 - a) - Math.abs(calcVal + 1 - b);
})[0];
}
function getPickerCols(format) {
var renderCol = [];
var meridiem = EPickerCols.meridiem,
hour = EPickerCols.hour,
minute = EPickerCols.minute,
second = EPickerCols.second,
milliSecond = EPickerCols.milliSecond;
var match = format.match(TIME_FORMAT);
match.forEach(function (m) {
switch (m) {
case "H":
case "HH":
case "h":
case "hh":
renderCol.push(hour);
break;
case "a":
case "A":
renderCol.push(meridiem);
break;
case "m":
case "mm":
renderCol.push(minute);
break;
case "s":
case "ss":
renderCol.push(second);
break;
case "SSS":
renderCol.push(milliSecond);
break;
}
});
return renderCol;
}
export { closestLookup, formatInputValue, getPickerCols, validateInputValue };
//# sourceMappingURL=utils.js.map