UNPKG

winbox-ui-next

Version:

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

40 lines (39 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports[Symbol.toStringTag] = "Module"; var vue = require("vue"); var is = require("../../_utils/is.js"); function getDefaultFormat(mode = "date", showTime = false) { switch (mode) { case "date": return showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD"; case "month": return "YYYY-MM"; case "year": return "YYYY"; case "week": return "gggg-wo"; case "quarter": return "YYYY-[Q]Q"; default: return "YYYY-MM-DD"; } } function useFormat(props) { const { format: propFormat, mode, showTime, valueFormat: propValueFormat } = vue.toRefs(props); const format = vue.computed(() => !is.isFunction(propFormat == null ? void 0 : propFormat.value) && (propFormat == null ? void 0 : propFormat.value) || getDefaultFormat(mode == null ? void 0 : mode.value, showTime == null ? void 0 : showTime.value)); const valueFormat = vue.computed(() => (propValueFormat == null ? void 0 : propValueFormat.value) || format.value); const parseValueFormat = vue.computed(() => ["timestamp", "Date"].includes(valueFormat.value) ? format.value : valueFormat.value); return { format, valueFormat, parseValueFormat }; } exports["default"] = useFormat; exports.getDefaultFormat = getDefaultFormat;