UNPKG

@arco-design/web-vue

Version:

Arco Design Vue 2.0: A Vue.js 3 UI Library

73 lines (72 loc) 2.34 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); var is = require("../../_utils/is.js"); function newArray(length) { return [...Array(length)]; } function normalizeRangeValue(value) { if (is.isUndefined(value)) { return void 0; } return is.isArray(value) ? value : [value, void 0]; } function isCompleteRangeValue(value) { return !!value && is.isDayjs(value[0]) && is.isDayjs(value[1]); } function isValidRangeValue(value) { return is.isUndefined(value) || value.length === 0 || isCompleteRangeValue(value); } function mergeValueWithTime(defaultValue, dateValue, timeValue) { const dateVal = dateValue || defaultValue; const timeVal = timeValue || defaultValue; return timeVal.set("year", dateVal.year()).set("month", dateVal.month()).set("date", dateVal.date()); } function isDisabledDate(cellDate, disabledDate, mode = "date") { if (typeof disabledDate !== "function") return false; const checkDate = (date) => disabledDate(date.toDate()); switch (mode) { case "date": case "week": return checkDate(cellDate); case "month": { const days = cellDate.daysInMonth(); for (let d = 1; d <= days; d++) { if (!checkDate(cellDate.date(d))) return false; } return true; } case "quarter": { const startMonth = Math.floor(cellDate.month() / 3) * 3; for (let m = startMonth; m < startMonth + 3; m++) { const monthDate = cellDate.month(m); const days = monthDate.daysInMonth(); for (let d = 1; d <= days; d++) { if (!checkDate(monthDate.date(d))) return false; } } return true; } case "year": { for (let m = 0; m < 12; m++) { const monthDate = cellDate.month(m); const days = monthDate.daysInMonth(); for (let d = 1; d <= days; d++) { if (!checkDate(monthDate.date(d))) return false; } } return true; } default: return false; } } exports.isCompleteRangeValue = isCompleteRangeValue; exports.isDisabledDate = isDisabledDate; exports.isValidRangeValue = isValidRangeValue; exports.mergeValueWithTime = mergeValueWithTime; exports.newArray = newArray; exports.normalizeRangeValue = normalizeRangeValue;