UNPKG

tdesign-mobile-vue

Version:
68 lines (64 loc) 1.81 kB
/** * tdesign v1.9.3 * (c) 2025 TDesign Group * @license MIT */ import { d as dayjs } from '../../../_chunks/dep-c6f44a15.mjs'; import { a as advancedFormat } from '../../../_chunks/dep-0cc6f8bc.mjs'; import { c as customParseFormat } from '../../../_chunks/dep-4c894577.mjs'; import { EPickerCols, TIME_FORMAT } from './const.mjs'; import '../../../_chunks/dep-4915223e.mjs'; import '../../../_chunks/dep-6b2b02fd.mjs'; 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; default: break; } }); return renderCol; } export { closestLookup, formatInputValue, getPickerCols, validateInputValue }; //# sourceMappingURL=utils.mjs.map