UNPKG

@nextcloud/vue

Version:
70 lines (69 loc) 5.01 kB
import "../assets/index.css"; import { t as o } from "../chunks/l10n-9a5a6afc.mjs"; import i from "./NcTimezonePicker.mjs"; import s from "./NcPopover.mjs"; import { l as p } from "../chunks/l10n-05baf7da.mjs"; import m from "vue-material-design-icons/CalendarBlank.vue"; import c from "vue-material-design-icons/Web.vue"; import { getMonthNames as u, getMonthNamesShort as d, getDayNames as h, getDayNamesShort as f, getDayNamesMin as y, getFirstDay as k } from "@nextcloud/l10n"; import w from "vue2-datepicker"; import { n as g } from "../chunks/_plugin-vue2_normalizer-5b4c43a4.mjs"; import { S as v } from "../chunks/ScopeComponent-dbcd0e07.mjs"; const n = { date: "YYYY-MM-DD", datetime: "YYYY-MM-DD H:mm:ss", year: "YYYY", month: "YYYY-MM", time: "H:mm:ss", week: "w" }, z = { name: "NcDatetimePicker", components: { CalendarBlank: m, DatePicker: w, NcPopover: s, NcTimezonePicker: i, Web: c }, mixins: [p], inheritAttrs: !1, props: { clearable: { type: Boolean, default: !1 }, minuteStep: { type: Number, default: 10 }, type: { type: String, default: "date" }, format: { type: String, default: null }, formatter: { type: Object, default: null }, lang: { type: Object, default: null }, value: { default: () => /* @__PURE__ */ new Date() }, timezoneId: { type: String, default: "UTC" }, showTimezoneSelect: { type: Boolean, default: !1 }, highlightTimezone: { type: Boolean, default: !1 }, appendToBody: { type: Boolean, default: !1 }, showWeekNumber: { type: Boolean, default: !1 }, placeholder: { type: String, default: null } }, emits: ["update:value", "update:timezone-id"], data() { return { showTimezonePopover: !1, tzVal: this.timezoneId }; }, computed: { defaultLang() { return { formatLocale: { months: u(), monthsShort: d(), weekdays: h(), weekdaysShort: f(), weekdaysMin: y(), firstDayOfWeek: k() }, monthFormat: "MMM" }; }, defaultPlaceholder() { return this.type === "time" ? o("Pick a time") : this.type === "month" ? o("Pick a month") : this.type === "year" ? o("Pick a year") : this.type === "week" ? o("Pick a week") : this.type === "date" ? o("Pick a date") : o("Pick a date and a time"); }, formatTypeMap() { var e; return (e = n[this.type]) != null ? e : n.date; } }, methods: { handleSelectYear(e) { const t = this.$refs.datepicker.currentValue; if (t) try { const a = new Date(new Date(t).setFullYear(e)); this.$refs.datepicker.selectDate(a); } catch { console.error("Invalid value", t, e); } }, handleSelectMonth(e) { const t = this.$refs.datepicker.currentValue; if (t) try { const a = new Date(new Date(t).setMonth(e)); this.$refs.datepicker.selectDate(a); } catch { console.error("Invalid value", t, e); } }, toggleTimezonePopover() { this.showTimezoneSelect && (this.showTimezonePopover = !this.showTimezonePopover); } } }; var P = function() { var e = this, t = e._self._c; return t("DatePicker", e._g(e._b({ ref: "datepicker", attrs: { "append-to-body": e.appendToBody, clearable: e.clearable, format: e.format ? e.format : e.formatTypeMap, formatter: e.formatter, lang: e.lang ? e.lang : e.defaultLang, "minute-step": e.minuteStep, placeholder: e.placeholder ? e.placeholder : e.defaultPlaceholder, "popup-class": { "show-week-number": e.showWeekNumber }, "show-week-number": e.showWeekNumber, type: e.type, value: e.value }, on: { "select-year": e.handleSelectYear, "select-month": e.handleSelectMonth, "update:value": function(a) { return e.$emit("update:value", e.value); } }, scopedSlots: e._u([{ key: "icon-calendar", fn: function() { return [e.showTimezoneSelect ? t("NcPopover", { attrs: { shown: e.showTimezonePopover, "popover-base-class": "timezone-select__popper" }, on: { "update:shown": function(a) { e.showTimezonePopover = a; } }, scopedSlots: e._u([{ key: "trigger", fn: function() { return [t("button", { staticClass: "datetime-picker-inline-icon", class: { "datetime-picker-inline-icon--highlighted": e.highlightTimezone }, on: { mousedown: function(a) { return a.stopPropagation(), a.preventDefault(), (() => { }).apply(null, arguments); } } }, [t("Web", { attrs: { size: 20 } })], 1)]; }, proxy: !0 }], null, !1, 3375037618) }, [t("div", { staticClass: "timezone-popover-wrapper__label" }, [t("strong", [e._v(" " + e._s(e.t("Please select a time zone:")) + " ")])]), t("NcTimezonePicker", { staticClass: "timezone-popover-wrapper__timezone-select", on: { input: function(a) { return e.$emit("update:timezone-id", arguments[0]); } }, model: { value: e.tzVal, callback: function(a) { e.tzVal = a; }, expression: "tzVal" } })], 1) : t("CalendarBlank", { attrs: { size: 20 } })]; }, proxy: !0 }, e._l(e.$scopedSlots, function(a, r) { return { key: r, fn: function(l) { return [e._t(r, null, null, l)]; } }; })], null, !0) }, "DatePicker", e.$attrs, !1), e.$listeners)); }, D = [], S = g(z, P, D, !1, null, "a0af66c9", null, null); const b = S.exports; v(b); export { b as default };