UNPKG

@cafebazaar/emrooz

Version:

Emrooz is a multilingual calendar built for Vue3. It also supports both Shamsi (Persian / Jalali) and Gregorian (English) calendars.

1,514 lines 86.5 kB
var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); import { computed, inject, defineComponent, openBlock, createElementBlock, normalizeClass, unref, toDisplayString, createElementVNode, Fragment, renderList, createBlock, withCtx, createTextVNode, TransitionGroup, renderSlot, toRef, createVNode, toRefs, ref, watch, onMounted, onBeforeUnmount, createCommentVNode, withDirectives, vShow, pushScopeId, popScopeId, provide, reactive, resolveDynamicComponent, withModifiers, Transition } from "vue"; function useDirection(lang) { return computed(() => lang.value === "fa" ? "rtl" : "ltr"); } const JalaliDate = { g_days_in_month: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], j_days_in_month: [31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29] }; function toGregorian(j_y, j_m, j_d) { j_y = parseInt(j_y); j_m = parseInt(j_m) + 1; j_d = parseInt(j_d); const jy = j_y - 979; const jm = j_m - 1; const jd = j_d - 1; let j_day_no = 365 * jy + parseInt(String(jy / 33)) * 8 + parseInt(String((jy % 33 + 3) / 4)); for (var i = 0; i < jm; ++i) j_day_no += JalaliDate.j_days_in_month[i]; j_day_no += jd; let g_day_no = j_day_no + 79; let gy = 1600 + 400 * parseInt(String(g_day_no / 146097)); g_day_no %= 146097; let leap = true; if (g_day_no >= 36525) { g_day_no--; gy += 100 * parseInt(String(g_day_no / 36524)); g_day_no %= 36524; if (g_day_no >= 365) { g_day_no++; } else { leap = false; } } gy += 4 * parseInt(String(g_day_no / 1461)); g_day_no %= 1461; if (g_day_no >= 366) { leap = false; g_day_no--; gy += parseInt(String(g_day_no / 365)); g_day_no %= 365; } for (var i = 0; g_day_no >= JalaliDate.g_days_in_month[i] + Number(i == 1 && leap); i++) { g_day_no -= JalaliDate.g_days_in_month[i] + Number(i == 1 && leap); } const gm = i + 1; const gd = g_day_no + 1; return [gy, gm - 1, gd]; } function toJalali(g_y, g_m, g_d) { g_y = parseInt(String(g_y)); g_m = parseInt(String(g_m)) + 1; g_d = parseInt(String(g_d)); const gy = g_y - 1600; const gm = g_m - 1; const gd = g_d - 1; let g_day_no = 365 * gy + parseInt(String((gy + 3) / 4)) - parseInt(String((gy + 99) / 100)) + parseInt(String((gy + 399) / 400)); for (var i = 0; i < gm; ++i) { g_day_no += JalaliDate.g_days_in_month[i]; } if (gm > 1 && (gy % 4 == 0 && gy % 100 != 0 || gy % 400 == 0)) { ++g_day_no; } g_day_no += gd; let j_day_no = g_day_no - 79; const j_np = parseInt(String(j_day_no / 12053)); j_day_no %= 12053; let jy = 979 + 33 * j_np + 4 * parseInt(String(j_day_no / 1461)); j_day_no %= 1461; if (j_day_no >= 366) { jy += parseInt(String((j_day_no - 1) / 365)); j_day_no = (j_day_no - 1) % 365; } for (var i = 0; i < 11 && j_day_no >= JalaliDate.j_days_in_month[i]; ++i) { j_day_no -= JalaliDate.j_days_in_month[i]; } const jm = i + 1; const jd = j_day_no + 1; return [jy, jm - 1, jd]; } function useRangePicker() { return { date: inject("date"), strings: inject("strings"), fromDate: inject("fromDate"), toDate: inject("toDate"), currentDate: inject("currentDate"), direction: inject("direction"), commonDates: inject("commonDates"), setFromDate: inject("setFromDate"), setToDate: inject("setToDate"), allowedDates: inject("allowedDates"), selectRange: inject("selectRange"), currentFirstSliderDate: inject("currentFirstSliderDate"), setCurrentFirstSliderDate: inject("setCurrentFirstSliderDate") }; } var RangePickerCommonDatesItem_vue_vue_type_style_index_0_scoped_true_lang = ""; var _export_sfc = (sfc, props) => { for (const [key, val] of props) { sfc[key] = val; } return sfc; }; const _sfc_main$I = /* @__PURE__ */ defineComponent({ props: { from: null, to: null, label: null }, setup(__props) { const props = __props; const { setFromDate, setToDate, fromDate, toDate } = useRangePicker(); function setRange() { setFromDate(props.from); setToDate(props.to); } const isActive = computed(() => { var _a, _b; if (props.from.toString() === ((_a = fromDate.value) == null ? void 0 : _a.toString()) && props.to.toString() === ((_b = toDate.value) == null ? void 0 : _b.toString())) { return true; } return false; }); return (_ctx, _cache) => { return openBlock(), createElementBlock("li", { class: normalizeClass(["EMRangePickerCommonDatesItem", { "EMRangePickerCommonDatesItem--active": unref(isActive) }]), onClick: setRange }, toDisplayString(props.label), 3); }; } }); var RangePickerCommonDatesItem = /* @__PURE__ */ _export_sfc(_sfc_main$I, [["__scopeId", "data-v-25bef3bd"]]); var index_vue_vue_type_style_index_0_scoped_true_lang$9 = ""; const _hoisted_1$j = { class: "EMRangePickerCommonDates" }; const _hoisted_2$b = { class: "EMRangePickerCommonDates__title" }; const _hoisted_3$4 = { class: "EMRangePickerCommonDates__list" }; const _sfc_main$H = /* @__PURE__ */ defineComponent({ setup(__props) { const { commonDates } = useRangePicker(); const { strings: strings2 } = useRangePicker(); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1$j, [ createElementVNode("header", _hoisted_2$b, toDisplayString(unref(strings2).commonDates), 1), createElementVNode("ul", _hoisted_3$4, [ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(commonDates), ({ label, from, to }) => { return openBlock(), createBlock(RangePickerCommonDatesItem, { key: label, class: "EMRangePickerCommonDates__list-item", label, from, to }, { default: withCtx(() => [ createTextVNode(toDisplayString(label), 1) ]), _: 2 }, 1032, ["label", "from", "to"]); }), 128)) ]) ]); }; } }); var RangePickerCommonDates = /* @__PURE__ */ _export_sfc(_sfc_main$H, [["__scopeId", "data-v-4a5e9e2c"]]); var SlideAnimation_vue_vue_type_style_index_0_lang = ""; const _sfc_main$G = /* @__PURE__ */ defineComponent({ props: { isInverted: { default: false }, direction: null }, setup(__props) { const props = __props; const animationName = computed(() => { if (props.isInverted) { if (props.direction === "rtl") return "EMSlide-prev"; return "EMSlide"; } if (props.direction === "rtl") return "EMSlide"; return "EMSlide-prev"; }); return (_ctx, _cache) => { return openBlock(), createBlock(TransitionGroup, { name: unref(animationName), mode: "out-in" }, { default: withCtx(() => [ renderSlot(_ctx.$slots, "default") ]), _: 3 }, 8, ["name"]); }; } }); const MOBILE_WIDTH_VIEWPORT = "500px"; var Button_vue_vue_type_style_index_0_scoped_true_lang = ""; const _sfc_main$F = /* @__PURE__ */ defineComponent({ props: { icon: { default: false }, disabled: { default: false }, plain: null }, emits: ["click"], setup(__props, { emit }) { const props = __props; const icon = toRef(props, "icon"); const disabled = toRef(props, "disabled"); const plain = toRef(props, "plain"); function checkAndEmitClick() { if (!disabled.value) { emit("click"); } } return (_ctx, _cache) => { return openBlock(), createElementBlock("button", { class: normalizeClass(["EMButton", { "EMButton--icon": unref(icon), "EMButton--disabled": unref(disabled), "EMButton--plain": unref(plain) }]), onClick: checkAndEmitClick }, [ renderSlot(_ctx.$slots, "default", {}, void 0, true) ], 2); }; } }); var Button = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-78956a5c"]]); const _sfc_main$E = {}; const _hoisted_1$i = { width: "7", height: "11", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg" }; const _hoisted_2$a = /* @__PURE__ */ createElementVNode("path", { d: "M6.084 10.172 1.76 5.5 6.084.828A.431.431 0 0 0 6.208.52a.431.431 0 0 0-.124-.306A.39.39 0 0 0 5.516.2L.916 5.18a.45.45 0 0 0-.124.321.45.45 0 0 0 .124.321L5.502 10.8a.42.42 0 0 0 .298.117.375.375 0 0 0 .29-.132.445.445 0 0 0-.006-.613Z" }, null, -1); const _hoisted_3$3 = [ _hoisted_2$a ]; function _sfc_render$5(_ctx, _cache) { return openBlock(), createElementBlock("svg", _hoisted_1$i, _hoisted_3$3); } var ArrowLeft = /* @__PURE__ */ _export_sfc(_sfc_main$E, [["render", _sfc_render$5]]); const _sfc_main$D = {}; const _hoisted_1$h = { width: "7", height: "11", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg" }; const _hoisted_2$9 = /* @__PURE__ */ createElementVNode("path", { d: "M.916.828 5.24 5.5.916 10.172a.431.431 0 0 0-.124.307c0 .117.041.219.124.306a.39.39 0 0 0 .568.015l4.6-4.979a.45.45 0 0 0 .124-.321.45.45 0 0 0-.124-.321L1.498.2A.42.42 0 0 0 1.2.083a.375.375 0 0 0-.29.132.445.445 0 0 0 .006.613Z" }, null, -1); const _hoisted_3$2 = [ _hoisted_2$9 ]; function _sfc_render$4(_ctx, _cache) { return openBlock(), createElementBlock("svg", _hoisted_1$h, _hoisted_3$2); } var ArrowRight = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["render", _sfc_render$4]]); const _sfc_main$C = /* @__PURE__ */ defineComponent({ props: { direction: null }, emits: ["click"], setup(__props, { emit }) { const props = __props; const ArrowStart = computed(() => props.direction === "ltr" ? ArrowLeft : ArrowRight); return (_ctx, _cache) => { return openBlock(), createBlock(Button, { icon: true, onClick: _cache[0] || (_cache[0] = ($event) => emit("click")) }, { default: withCtx(() => [ createVNode(unref(ArrowStart)) ]), _: 1 }); }; } }); const _sfc_main$B = /* @__PURE__ */ defineComponent({ props: { direction: null }, emits: ["click"], setup(__props, { emit }) { const props = __props; const ArrowEnd = computed(() => props.direction === "ltr" ? ArrowRight : ArrowLeft); return (_ctx, _cache) => { return openBlock(), createBlock(Button, { icon: true, onClick: _cache[0] || (_cache[0] = ($event) => emit("click")) }, { default: withCtx(() => [ createVNode(unref(ArrowEnd)) ]), _: 1 }); }; } }); var RangePickerSliderControllers_vue_vue_type_style_index_0_scoped_true_lang = ""; const _hoisted_1$g = { class: "EMRangePickerSliderControllers" }; const _hoisted_2$8 = { class: "EMRangePickerSliderControllers__month-wrapper" }; const _sfc_main$A = /* @__PURE__ */ defineComponent({ props: { firstMonth: null, firstYear: null, secondMonth: null, secondYear: null, isAnimationInverted: null }, emits: ["next", "prev"], setup(__props, { emit }) { const props = __props; const { strings: strings2, direction } = useRangePicker(); function next() { emit("next"); } function prev() { emit("prev"); } return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1$g, [ createVNode(_sfc_main$C, { direction: unref(direction), onClick: prev }, null, 8, ["direction"]), createElementVNode("div", _hoisted_2$8, [ createVNode(_sfc_main$G, { direction: unref(direction), "is-inverted": __props.isAnimationInverted }, { default: withCtx(() => [ (openBlock(), createElementBlock("span", { key: `${props.firstYear}-${props.firstMonth}`, class: "EMRangePickerSliderControllers__month" }, toDisplayString(unref(strings2).monthNames[props.firstMonth]) + " " + toDisplayString(props.firstYear), 1)), (openBlock(), createElementBlock("span", { key: `${props.secondYear}-${props.secondMonth}`, class: "EMRangePickerSliderControllers__month" }, toDisplayString(unref(strings2).monthNames[props.secondMonth]) + " " + toDisplayString(props.secondYear), 1)) ]), _: 1 }, 8, ["direction", "is-inverted"]) ]), createVNode(_sfc_main$B, { direction: unref(direction), onClick: next }, null, 8, ["direction"]) ]); }; } }); var RangePickerSliderControllers = /* @__PURE__ */ _export_sfc(_sfc_main$A, [["__scopeId", "data-v-0f470638"]]); var GridItemUI_vue_vue_type_style_index_0_scoped_true_lang = ""; const _sfc_main$z = /* @__PURE__ */ defineComponent({ props: { isHeader: { default: false }, isActiveStart: { default: false }, isActiveEnd: { default: false }, isMiddle: { default: false }, isToday: { default: false }, isEmpty: { default: false }, isDisabled: { default: false }, isEdge: { default: false }, isClosed: { default: false } }, emits: ["click"], setup(__props, { emit }) { const props = __props; const { isHeader, isActiveStart, isActiveEnd, isMiddle, isToday, isEmpty, isDisabled, isEdge, isClosed } = toRefs(props); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", { class: normalizeClass(["EMGridItemUI", { "EMGridItemUI--header": unref(isHeader), "EMGridItemUI--empty": unref(isEmpty), "EMGridItemUI--active": unref(isMiddle), "EMGridItemUI--active-start": unref(isActiveStart), "EMGridItemUI--active-end": unref(isActiveEnd), "EMGridItemUI--disabled": unref(isDisabled), "EMGridItemUI--today": unref(isToday), "EMGridItemUI--closed": unref(isClosed) }]), onClick: _cache[0] || (_cache[0] = ($event) => emit("click")) }, [ createElementVNode("span", { class: normalizeClass(["EMGridItemUI__inner", { "EMGridItemUI__inner--active": unref(isEdge) }]) }, [ renderSlot(_ctx.$slots, "default", {}, void 0, true) ], 2) ], 2); }; } }); var GridItemUI = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-3b16e190"]]); function useRangeHelpers() { const { fromDate, toDate } = useRangePicker(); const isRangeSelected = computed(() => Boolean(fromDate.value && toDate.value)); return { isRangeSelected }; } function useDateCompares$1({ currentMonth, currentYear, currentDay }) { const { date: date2, currentDate, fromDate, toDate } = useRangePicker(); const { isRangeSelected } = useRangeHelpers(); const toBeComparedDayTuple = computed(() => [currentYear.value, currentMonth.value, currentDay.value]); const isStartingRangeEdge = computed(() => { if (!isRangeSelected.value) return false; if (fromDate.value && toBeComparedDayTuple.value.toString() === fromDate.value.toString()) { return true; } return false; }); const isEndingRangeEdge = computed(() => { if (!isRangeSelected.value) return false; if (toDate.value && toBeComparedDayTuple.value.toString() === toDate.value.toString()) { return true; } return false; }); const isEdge = computed(() => { if (fromDate.value && toBeComparedDayTuple.value.toString() === fromDate.value.toString()) { return true; } if (toDate.value && toBeComparedDayTuple.value.toString() === toDate.value.toString()) { return true; } return false; }); const isMiddle = computed(() => { if (!isRangeSelected.value) return false; if (date2.compare(fromDate.value, toBeComparedDayTuple.value) === 1 && date2.compare(toBeComparedDayTuple.value, toDate.value) === 1) return true; return false; }); const isMiddleEmpty = computed(() => { if (!isRangeSelected.value) return false; if (toBeComparedDayTuple.value[2] === 1 && date2.compare(fromDate.value, toBeComparedDayTuple.value) === 0) { return false; } const currentEndRangeEdgeMonthDays = date2.getMonthDays({ year: toBeComparedDayTuple.value[0], month: toBeComparedDayTuple.value[1] }); if (toBeComparedDayTuple.value[2] === currentEndRangeEdgeMonthDays && date2.compare(toDate.value, toBeComparedDayTuple.value) === 0) { return false; } if (date2.compare(fromDate.value, toBeComparedDayTuple.value) >= 0 && date2.compare(toBeComparedDayTuple.value, toDate.value) >= 0) return true; return false; }); const isBeforeStartingEdge = computed(() => { if (!fromDate.value) return false; return date2.compare(fromDate.value, toBeComparedDayTuple.value) === -1; }); const isToday = computed(() => currentDate.value.toString() === toBeComparedDayTuple.value.toString()); return { isBeforeStartingEdge, isMiddle, isEdge, isEndingRangeEdge, isStartingRangeEdge, isToday, isMiddleEmpty }; } const _sfc_main$y = /* @__PURE__ */ defineComponent({ props: { currentYear: null, currentMonth: null, currentDay: null }, setup(__props) { const props = __props; const { currentDay, currentMonth, currentYear } = toRefs(props); const { isMiddleEmpty } = useDateCompares$1({ currentMonth, currentYear, currentDay }); return (_ctx, _cache) => { return openBlock(), createBlock(GridItemUI, { "is-middle": unref(isMiddleEmpty), "is-empty": "" }, null, 8, ["is-middle"]); }; } }); const _sfc_main$x = /* @__PURE__ */ defineComponent({ props: { currentYear: null, currentMonth: null, currentDay: null }, emits: ["click"], setup(__props, { emit }) { const props = __props; const { allowedDates, date: date2 } = useRangePicker(); const { currentDay, currentMonth, currentYear } = toRefs(props); const { isMiddle, isStartingRangeEdge, isEndingRangeEdge, isToday, isEdge, isBeforeStartingEdge } = useDateCompares$1({ currentMonth, currentYear, currentDay }); const { isRangeSelected } = useRangeHelpers(); const dateOfTuple = computed(() => date2.tupleToDate([currentYear.value, currentMonth.value, currentDay.value])); const isDisabled = computed(() => { if (!isRangeSelected.value) { if (allowedDates) { return !allowedDates(dateOfTuple.value) || isBeforeStartingEdge.value; } return isBeforeStartingEdge.value; } if (allowedDates) { return !allowedDates(dateOfTuple.value); } return false; }); const isClosed = computed(() => date2.isClosed([currentYear.value, currentMonth.value, currentDay.value])); function checkAndEmitClicked() { if (isDisabled.value) return; emit("click"); } return (_ctx, _cache) => { return openBlock(), createBlock(GridItemUI, { "is-middle": unref(isMiddle), "is-active-start": unref(isStartingRangeEdge), "is-active-end": unref(isEndingRangeEdge), "is-today": unref(isToday), "is-edge": unref(isEdge), "is-disabled": unref(isDisabled), "is-closed": unref(isClosed), onClick: checkAndEmitClicked }, { default: withCtx(() => [ createTextVNode(toDisplayString(unref(currentDay)), 1) ]), _: 1 }, 8, ["is-middle", "is-active-start", "is-active-end", "is-today", "is-edge", "is-disabled", "is-closed"]); }; } }); var index_vue_vue_type_style_index_0_scoped_true_lang$8 = ""; const _hoisted_1$f = { class: "EMRangePickerSliderGrid" }; const _sfc_main$w = /* @__PURE__ */ defineComponent({ props: { headerNames: null, firstDayOfMonth: null, lastDayOfMonth: null, monthDays: null, currentYear: null, currentMonth: null }, emits: ["selectDate"], setup(__props, { emit }) { const props = __props; const currentMonth = toRef(props, "currentMonth"); const currentYear = toRef(props, "currentYear"); function selectDate(day) { emit("selectDate", day); } const fill = (count) => new Array(count).fill(0).map((_, index) => index + 1); const fillEmpty = (count) => new Array(count).fill(""); const emptyFirstDays = computed(() => fillEmpty(props.firstDayOfMonth)); const dayItems = computed(() => fill(props.monthDays)); const emptyLastDays = computed(() => fillEmpty(6 - props.lastDayOfMonth)); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1$f, [ (openBlock(true), createElementBlock(Fragment, null, renderList(props.headerNames, (i) => { return openBlock(), createBlock(GridItemUI, { key: i, "is-header": true }, { default: withCtx(() => [ createTextVNode(toDisplayString(i), 1) ]), _: 2 }, 1024); }), 128)), (openBlock(true), createElementBlock(Fragment, null, renderList(unref(emptyFirstDays), (_, index) => { return openBlock(), createBlock(_sfc_main$y, { key: `1-${index}`, "current-year": unref(currentYear), "current-month": unref(currentMonth), "current-day": 1 }, null, 8, ["current-year", "current-month"]); }), 128)), (openBlock(true), createElementBlock(Fragment, null, renderList(unref(dayItems), (currentDay) => { return openBlock(), createBlock(_sfc_main$x, { key: `${unref(currentYear)}-${unref(currentMonth)}-${currentDay}`, "current-year": unref(currentYear), "current-month": unref(currentMonth), "current-day": currentDay, onClick: () => selectDate(currentDay) }, null, 8, ["current-year", "current-month", "current-day", "onClick"]); }), 128)), (openBlock(true), createElementBlock(Fragment, null, renderList(unref(emptyLastDays), (_, index) => { return openBlock(), createBlock(_sfc_main$y, { key: `${__props.monthDays}-${index}`, "current-year": unref(currentYear), "current-month": unref(currentMonth), "current-day": __props.monthDays }, null, 8, ["current-year", "current-month", "current-day"]); }), 128)) ]); }; } }); var RangePickerSliderGrid = /* @__PURE__ */ _export_sfc(_sfc_main$w, [["__scopeId", "data-v-20120e3a"]]); const _sfc_main$v = /* @__PURE__ */ defineComponent({ props: { currentYear: null, currentMonth: null }, setup(__props) { const props = __props; const { date: date2, strings: strings2, fromDate, toDate, setFromDate, setToDate } = useRangePicker(); function selectDate(day) { const toBeSelectedDate = [props.currentYear, props.currentMonth, day]; if (!fromDate.value) { setFromDate(toBeSelectedDate); return; } if (!toDate.value) { if (fromDate.value.toString() === toBeSelectedDate.toString()) { setFromDate(null); return; } setToDate(toBeSelectedDate); return; } setFromDate(toBeSelectedDate); setToDate(null); } const firstDayOfMonth = computed(() => date2.getFirstDayOfMonth({ year: props.currentYear, month: props.currentMonth })); const lastDayOfMonth = computed(() => date2.getLastDayOfMonth({ year: props.currentYear, month: props.currentMonth })); const monthDays2 = computed(() => date2.getMonthDays({ year: props.currentYear, month: props.currentMonth })); return (_ctx, _cache) => { return openBlock(), createBlock(RangePickerSliderGrid, { "first-day-of-month": unref(firstDayOfMonth), "last-day-of-month": unref(lastDayOfMonth), "month-days": unref(monthDays2), "header-names": unref(strings2).dayHeaderNames, "current-month": props.currentMonth, "current-year": props.currentYear, onSelectDate: selectDate }, null, 8, ["first-day-of-month", "last-day-of-month", "month-days", "header-names", "current-month", "current-year"]); }; } }); var index_vue_vue_type_style_index_0_scoped_true_lang$7 = ""; const _hoisted_1$e = { class: "EMRangePickerSlider" }; const _hoisted_2$7 = { class: "EMRangePickerSlider__content" }; const _sfc_main$u = /* @__PURE__ */ defineComponent({ setup(__props) { const { date: date2, direction, currentFirstSliderDate, setCurrentFirstSliderDate } = useRangePicker(); const currentSecondDate = computed(() => date2.getNextMonth({ year: currentFirstSliderDate.value.year, month: currentFirstSliderDate.value.month })); const isAnimationInverted = ref(false); function incrementStartingMonth() { const { month, year } = date2.getNextMonth({ month: currentFirstSliderDate.value.month, year: currentFirstSliderDate.value.year }); setCurrentFirstSliderDate({ year, month }); } function decreaseStartingMonth() { const { month, year } = date2.getPrevMonth({ month: currentFirstSliderDate.value.month, year: currentFirstSliderDate.value.year }); setCurrentFirstSliderDate({ year, month }); } watch(currentFirstSliderDate, (old, newVal) => { if (date2.compare([old.year, old.month, 1], [newVal.year, newVal.month, 1]) === -1) { isAnimationInverted.value = false; } else { isAnimationInverted.value = true; } }); const isMobile = ref(false); let mql; function detectMobile(mqEvent) { if (mqEvent.matches) { isMobile.value = true; return; } isMobile.value = false; } onMounted(() => { mql = window.matchMedia(`(max-width: ${MOBILE_WIDTH_VIEWPORT})`); mql.addEventListener("change", detectMobile); isMobile.value = mql.matches; }); onBeforeUnmount(() => { mql.removeEventListener("change", detectMobile); }); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1$e, [ createElementVNode("header", null, [ createVNode(RangePickerSliderControllers, { "is-animation-inverted": isAnimationInverted.value, "first-month": unref(currentFirstSliderDate).month, "first-year": unref(currentFirstSliderDate).year, "second-month": unref(currentSecondDate).month, "second-year": unref(currentSecondDate).year, onPrev: decreaseStartingMonth, onNext: incrementStartingMonth }, null, 8, ["is-animation-inverted", "first-month", "first-year", "second-month", "second-year"]) ]), createElementVNode("div", _hoisted_2$7, [ createVNode(_sfc_main$G, { "is-inverted": isAnimationInverted.value, direction: unref(direction) }, { default: withCtx(() => [ (openBlock(), createElementBlock("div", { key: `${unref(currentFirstSliderDate).year}-${unref(currentFirstSliderDate).month}`, class: "EMRangePickerSlider__grid-item" }, [ createVNode(_sfc_main$v, { "current-month": unref(currentFirstSliderDate).month, "current-year": unref(currentFirstSliderDate).year }, null, 8, ["current-month", "current-year"]) ])), !isMobile.value ? (openBlock(), createElementBlock("div", { key: `${unref(currentSecondDate).year}-${unref(currentSecondDate).month}`, class: "EMRangePickerSlider__grid-item" }, [ createVNode(_sfc_main$v, { "current-month": unref(currentSecondDate).month, "current-year": unref(currentSecondDate).year }, null, 8, ["current-month", "current-year"]) ])) : createCommentVNode("", true) ]), _: 1 }, 8, ["is-inverted", "direction"]) ]) ]); }; } }); var RangePickerSlider = /* @__PURE__ */ _export_sfc(_sfc_main$u, [["__scopeId", "data-v-7162daa6"]]); var VerticalSlideAnimation_vue_vue_type_style_index_0_lang = ""; const _sfc_main$t = {}; function _sfc_render$3(_ctx, _cache) { return openBlock(), createBlock(TransitionGroup, { name: "EMVerticalSlide", mode: "out-in" }, { default: withCtx(() => [ renderSlot(_ctx.$slots, "default") ]), _: 3 }); } var VerticalSlideAnimation = /* @__PURE__ */ _export_sfc(_sfc_main$t, [["render", _sfc_render$3]]); const _sfc_main$s = {}; const _hoisted_1$d = { width: "12", height: "12", viewBox: "0 0 12 12", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg" }; const _hoisted_2$6 = /* @__PURE__ */ createElementVNode("path", { d: "M11.6498 0.349979C11.8943 0.594449 11.8943 0.974736 11.6498 1.21921L6.86907 5.99996L11.6498 10.7807C11.8943 11.0252 11.8943 11.4055 11.6498 11.6499C11.4053 11.8944 11.0251 11.8944 10.7806 11.6499L5.99984 6.86919L1.21908 11.6499C0.974614 11.8944 0.594327 11.8944 0.349857 11.6499C0.105386 11.4055 0.105386 11.0252 0.349857 10.7807L5.13061 5.99996L0.349857 1.21921C0.105386 0.974736 0.105386 0.594449 0.349857 0.349979C0.594327 0.105508 0.974614 0.105508 1.21908 0.349979L5.99984 5.13073L10.7806 0.349979C11.0251 0.105508 11.4053 0.105508 11.6498 0.349979Z" }, null, -1); const _hoisted_3$1 = [ _hoisted_2$6 ]; function _sfc_render$2(_ctx, _cache) { return openBlock(), createElementBlock("svg", _hoisted_1$d, _hoisted_3$1); } var RangePickerFooterClose = /* @__PURE__ */ _export_sfc(_sfc_main$s, [["render", _sfc_render$2]]); var index_vue_vue_type_style_index_0_scoped_true_lang$6 = ""; const _withScopeId = (n) => (pushScopeId("data-v-75608ba0"), n = n(), popScopeId(), n); const _hoisted_1$c = { class: "EMRangePickerFooter" }; const _hoisted_2$5 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "EMRangePickerFooter__sep" }, null, -1)); const _sfc_main$r = /* @__PURE__ */ defineComponent({ setup(__props) { const { strings: strings2, fromDate, toDate, selectRange, setToDate, setFromDate, setCurrentFirstSliderDate, currentDate } = useRangePicker(); const { isRangeSelected } = useRangeHelpers(); const datePreviewString = computed(() => { if (!fromDate.value || !toDate.value) return ""; return ` ${fromDate.value[2]} ${strings2.value.monthNames[fromDate.value[1]]} ${toDate.value[0]} ${strings2.value.to} ${toDate.value[2]} ${strings2.value.monthNames[toDate.value[1]]} ${toDate.value[0]} `; }); function removeRange() { setToDate(null); setFromDate(null); } function resetSlider() { setCurrentFirstSliderDate({ year: currentDate.value[0], month: currentDate.value[1] }); } return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1$c, [ createVNode(Button, { plain: true, onClick: resetSlider }, { default: withCtx(() => [ createTextVNode(toDisplayString(unref(strings2).goToToday), 1) ]), _: 1 }), _hoisted_2$5, createElementVNode("div", null, [ createVNode(VerticalSlideAnimation, null, { default: withCtx(() => [ withDirectives((openBlock(), createElementBlock("span", { key: unref(datePreviewString), class: "EMRangePickerFooter__report" }, [ createVNode(RangePickerFooterClose, { class: "EMRangePickerFooter__close", onClick: removeRange }), createTextVNode(" " + toDisplayString(unref(datePreviewString)), 1) ], 512)), [ [vShow, unref(datePreviewString)] ]) ]), _: 1 }) ]), createVNode(Button, { class: "EMRangePickerFooter__action", disabled: !unref(isRangeSelected), onClick: unref(selectRange) }, { default: withCtx(() => [ createTextVNode(toDisplayString(unref(strings2).action), 1) ]), _: 1 }, 8, ["disabled", "onClick"]) ]); }; } }); var RangePickerFooter = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["__scopeId", "data-v-75608ba0"]]); var index_vue_vue_type_style_index_0_scoped_true_lang$5 = ""; const _hoisted_1$b = { class: "EMRangePicker__content" }; const _hoisted_2$4 = { class: "EMRangePicker__footer" }; const _sfc_main$q = /* @__PURE__ */ defineComponent({ props: { date: null, strings: null, fromDate: null, toDate: null, currentDate: null, commonDates: null, direction: null, setFromDate: null, setToDate: null, allowedDates: null, selectRange: null }, setup(__props) { const props = __props; const refProps = toRefs(props); const currentFirstSliderDate = ref({ year: props.currentDate[0], month: props.currentDate[1] }); const setCurrentFirstSliderDate = (slideInfo) => { currentFirstSliderDate.value = { year: slideInfo.year, month: slideInfo.month }; }; provide("date", props.date); provide("strings", refProps.strings); provide("fromDate", refProps.fromDate); provide("toDate", refProps.toDate); provide("currentDate", refProps.currentDate); provide("direction", refProps.direction); provide("commonDates", reactive(refProps.commonDates.value)); provide("setFromDate", props.setFromDate); provide("setToDate", props.setToDate); provide("allowedDates", props.allowedDates); provide("selectRange", props.selectRange); provide("currentFirstSliderDate", currentFirstSliderDate); provide("setCurrentFirstSliderDate", setCurrentFirstSliderDate); return (_ctx, _cache) => { var _a, _b; return openBlock(), createElementBlock("div", { class: normalizeClass(["EMRangePicker", { "EMRangePicker--with-common-dates": (_a = __props.commonDates) == null ? void 0 : _a.length }]) }, [ createElementVNode("div", _hoisted_1$b, [ ((_b = __props.commonDates) == null ? void 0 : _b.length) ? (openBlock(), createBlock(RangePickerCommonDates, { key: 0, class: "EMRangePicker__common-dates" })) : createCommentVNode("", true), createVNode(RangePickerSlider, { class: "EMRangePicker__slider" }) ]), createElementVNode("footer", _hoisted_2$4, [ createVNode(RangePickerFooter) ]) ], 2); }; } }); var RangePicker = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-6513290a"]]); const monthDays$1 = [ () => 31, ({ year }) => { if (year % 400 === 0) return 29; if (year % 4 === 0) { if (year % 100 === 0) return 28; return 29; } return 28; }, () => 31, () => 30, () => 31, () => 30, () => 31, () => 31, () => 30, () => 31, () => 30, () => 31 ]; const miladiDate = { getMonthDays({ year, month }) { return monthDays$1[month]({ year }); }, getFirstDayOfMonth({ year, month }) { const dateObj = new Date(year, month, 1); return dateObj.getDay() % 7; }, getLastDayOfMonth({ year, month }) { const dateObj = new Date(year, month, this.getMonthDays({ year, month })); return dateObj.getDay() % 7; }, getNextMonth({ year, month }) { if (month >= 11) { return { month: 0, year: year + 1 }; } return { month: month + 1, year }; }, getPrevMonth({ year, month }) { if (month <= 0) { return { month: 11, year: year - 1 }; } return { month: month - 1, year }; }, tupleToDate(tuple) { return new Date(tuple[0], tuple[1], tuple[2]); }, isClosed(tuple) { const dateObj = new Date(tuple[0], tuple[1], tuple[2]); return [0, 6].includes(dateObj.getDay()); } }; const monthDays = [ () => 31, () => 31, () => 31, () => 31, () => 31, () => 31, () => 30, () => 30, () => 30, () => 30, () => 30, ({ year }) => { let isLeap = false; if (year > 1243 && year < 1473) { isLeap = [ 1, 5, 9, 13, 17, year < 1343 ? 21 : 22, 26, 30 ].includes(year % 33); } else { isLeap = year % 4 === (year <= 1243 ? 3 : 1); } return isLeap ? 30 : 29; } ]; const shamsiDate = { getMonthDays({ year, month }) { return monthDays[month]({ year }); }, getFirstDayOfMonth({ year, month }) { const gDate = toGregorian(year, month, 1); const dateObj = new Date(gDate[0], gDate[1], gDate[2]); return (dateObj.getDay() + 1) % 7; }, getLastDayOfMonth({ year, month }) { const gDate = toGregorian(year, month, this.getMonthDays({ year, month })); const dateObj = new Date(gDate[0], gDate[1], gDate[2]); return (dateObj.getDay() + 1) % 7; }, getNextMonth({ year, month }) { if (month >= 11) { return { month: 0, year: year + 1 }; } return { month: month + 1, year }; }, getPrevMonth({ year, month }) { if (month <= 0) { return { month: 11, year: year - 1 }; } return { month: month - 1, year }; }, tupleToDate(tuple) { const gDate = toGregorian(...tuple); return new Date(gDate[0], gDate[1], gDate[2]); }, isClosed(tuple) { const gDate = toGregorian(...tuple); const dateObj = new Date(gDate[0], gDate[1], gDate[2]); return dateObj.getDay() === 5; } }; const date$3 = __spreadProps(__spreadValues({}, shamsiDate), { compare(lDate, rDate) { const lGDate = toGregorian(...lDate); const rGDate = toGregorian(...rDate); const lDateObj = new Date(lGDate[0], lGDate[1], lGDate[2]); const rDateObj = new Date(rGDate[0], rGDate[1], rGDate[2]); if (lDateObj.valueOf() > rDateObj.valueOf()) { return -1; } if (lDateObj.valueOf() < rDateObj.valueOf()) { return 1; } return 0; } }); const shamsi = { en: { monthNames: [ "Farvardin", "Ordibehesht", "Khordad", "Tir", "Mordad", "Shahrivar", "Mehr", "Aban", "Azar", "Day", "Bahman", "Esfand" ], dayHeaderNames: [ "Sa", "Su", "M", "Tu", "W", "Th", "F" ] }, fa: { monthNames: [ "\u0641\u0631\u0648\u0631\u062F\u06CC\u0646", "\u0627\u0631\u062F\u06CC\u0628\u0647\u0634\u062A", "\u062E\u0631\u062F\u0627\u062F", "\u062A\u06CC\u0631", "\u0645\u0631\u062F\u0627\u062F", "\u0634\u0647\u0631\u06CC\u0648\u0631", "\u0645\u0647\u0631", "\u0622\u0628\u0627\u0646", "\u0622\u0630\u0631", "\u062F\u06CC", "\u0628\u0647\u0645\u0646", "\u0627\u0633\u0641\u0646\u062F" ], dayHeaderNames: [ "\u0634", "\u06CC", "\u062F", "\u0633", "\u0686", "\u067E", "\u062C" ] } }; const miladi = { en: { monthNames: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], dayHeaderNames: [ "Su", "M", "Tu", "W", "Th", "F", "Sa" ] }, fa: { monthNames: [ "\u0698\u0627\u0646\u0648\u06CC\u0647", "\u0641\u0648\u0631\u06CC\u0647", "\u0645\u0627\u0631\u0633", "\u0622\u0648\u0631\u06CC\u0644", "\u0645\u0647", "\u0698\u0648\u0626\u0646", "\u062C\u0648\u0644\u0627\u06CC", "\u0627\u0648\u062A", "\u0633\u067E\u062A\u0627\u0645\u0628\u0631", "\u0627\u06A9\u062A\u0628\u0631", "\u0646\u0648\u0627\u0645\u0628\u0631", "\u062F\u0633\u0627\u0645\u0628\u0631" ], dayHeaderNames: [ "\u06CC", "\u062F", "\u0633", "\u0686", "\u067E", "\u062C", "\u0634" ] } }; const general = { fa: { to: "\u062A\u0627", goToToday: "\u0628\u0631\u0648 \u0628\u0647 \u0627\u0645\u0631\u0648\u0632", apply: "\u0627\u0639\u0645\u0627\u0644 \u062A\u0627\u0631\u06CC\u062E", commonDates: "\u0632\u0645\u0627\u0646\u200C\u0647\u0627\u06CC \u067E\u0631 \u0627\u0633\u062A\u0641\u0627\u062F\u0647" }, en: { to: "To", goToToday: "Go to today", apply: "Apply", commonDates: "Common dates" } }; const strings$5 = { en: __spreadProps(__spreadValues({}, shamsi.en), { action: general.en.apply, to: general.en.to, commonDates: general.en.commonDates, goToToday: general.en.goToToday }), fa: __spreadProps(__spreadValues({}, shamsi.fa), { action: general.fa.apply, to: general.fa.to, commonDates: general.fa.commonDates, goToToday: general.fa.goToToday }) }; const _sfc_main$p = /* @__PURE__ */ defineComponent({ props: { lang: null, direction: null, fromDate: null, toDate: null, setFromDate: null, setToDate: null, commonDates: null, allowedDates: null, selectRange: null }, setup(__props) { const props = __props; const fromShamsiDate = computed(() => props.fromDate ? toJalali(props.fromDate.getFullYear(), props.fromDate.getMonth(), props.fromDate.getDate()) : null); const toShamsiDate = computed(() => props.toDate ? toJalali(props.toDate.getFullYear(), props.toDate.getMonth(), props.toDate.getDate()) : null); const currentDate = toJalali(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()); const setLocalFromDate = (fromDate) => { if (!fromDate) { props.setFromDate(fromDate); return; } const gDate = toGregorian(fromDate[0], fromDate[1], fromDate[2]); props.setFromDate(new Date(gDate[0], gDate[1], gDate[2])); }; const setLocalToDate = (toDate) => { if (!toDate) { props.setToDate(toDate); return; } const gDate = toGregorian(toDate[0], toDate[1], toDate[2]); props.setToDate(new Date(gDate[0], gDate[1], gDate[2])); }; const selectedLanguageStrings = computed(() => strings$5[props.lang]); const localCommonDates = computed(() => props.commonDates.map(({ from, to, label }) => ({ from: toJalali(from.getFullYear(), from.getMonth(), from.getDate()), to: toJalali(to.getFullYear(), to.getMonth(), to.getDate()), label }))); const allowedDates = toRef(props, "allowedDates"); return (_ctx, _cache) => { return openBlock(), createBlock(RangePicker, { date: unref(date$3), direction: __props.direction, "from-date": unref(fromShamsiDate), "to-date": unref(toShamsiDate), strings: unref(selectedLanguageStrings), "current-date": unref(currentDate), "common-dates": unref(localCommonDates), "allowed-dates": unref(allowedDates), "set-from-date": setLocalFromDate, "set-to-date": setLocalToDate, "select-range": props.selectRange }, null, 8, ["date", "direction", "from-date", "to-date", "strings", "current-date", "common-dates", "allowed-dates", "select-range"]); }; } }); const date$2 = __spreadProps(__spreadValues({}, miladiDate), { compare(lDate, rDate) { const lDateObj = new Date(lDate[0], lDate[1], lDate[2]); const rDateObj = new Date(rDate[0], rDate[1], rDate[2]); if (lDateObj.valueOf() > rDateObj.valueOf()) { return -1; } if (lDateObj.valueOf() < rDateObj.valueOf()) { return 1; } return 0; } }); const strings$4 = { en: __spreadProps(__spreadValues({}, miladi.en), { action: general.en.apply, to: general.en.to, commonDates: "Common Dates", goToToday: general.en.goToToday }), fa: __spreadProps(__spreadValues({}, miladi.fa), { action: general.fa.apply, to: general.fa.to, commonDates: "\u0632\u0645\u0627\u0646\u200C\u0647\u0627\u06CC \u067E\u0631 \u0627\u0633\u062A\u0641\u0627\u062F\u0647", goToToday: general.fa.goToToday }) }; const _sfc_main$o = /* @__PURE__ */ defineComponent({ props: { lang: null, direction: null, fromDate: null, toDate: null, setFromDate: null, setToDate: null, commonDates: null, allowedDates: null, selectRange: null }, setup(__props) { const props = __props; const fromDateTuple = computed(() => props.fromDate ? [ props.fromDate.getFullYear(), props.fromDate.getMonth(), props.fromDate.getDate() ] : null); const toDateTuple = computed(() => props.toDate ? [ props.toDate.getFullYear(), props.toDate.getMonth(), props.toDate.getDate() ] : null); const currentDate = [ new Date().getFullYear(), new Date().getMonth(), new Date().getDate() ]; const setLocalFromDate = (fromDate) => { if (!fromDate) { props.setFromDate(null); return; } props.setFromDate(new Date(fromDate[0], fromDate[1], fromDate[2])); }; const setLocalToDate = (toDate) => { if (!toDate) { props.setToDate(null); return; } props.setToDate(new Date(toDate[0], toDate[1], toDate[2])); }; const selectedLanguageStrings = computed(() => strings$4[props.lang]); const localCommonDates = computed(() => props.commonDates.map(({ from, to, label }) => ({ from: [from.getFullYear(), from.getMonth(), from.getDate()], to: [to.getFullYear(), to.getMonth(), to.getDate()], label }))); const allowedDates = toRef(props, "allowedDates"); return (_ctx, _cache) => { return openBlock(), createBlock(RangePicker, { date: unref(date$2), direction: __props.direction, "from-date": unref(fromDateTuple), "to-date": unref(toDateTuple), strings: unref(selectedLanguageStrings), "current-date": currentDate, "common-dates": unref(localCommonDates), "allowed-dates": unref(allowedDates), "set-from-date": setLocalFromDate, "set-to-date": setLocalToDate, "select-range": props.selectRange }, null, 8, ["date", "direction", "from-date", "to-date", "strings", "common-dates", "allowed-dates", "select-range"]); }; } }); const _hoisted_1$a = ["lang"]; const _sfc_main$n = /* @__PURE__ */ defineComponent({ props: { lang: { default: "fa" }, commonDates: { default: () => [] }, allowedDates: { default: () => null }, type: { default: "shamsi" }, rangePickerClass: { default: "" }, modelValue: { default: () => null } }, emits: ["update:modelValue"], setup(__props, { emit }) { var _a, _b; const props = __props; const RANGE_PICKER_TYPE_TO_COMPONENT = { shamsi: _sfc_main$p, miladi: _sfc_main$o }; const fromDate = ref(((_a = props.modelValue) == null ? void 0 : _a.from) || null); const toDate = ref(((_b = props.modelValue) == null ? void 0 : _b.to) || null); watch(() => props.modelValue, () => { var _a2, _b2; fromDate.value = ((_a2 = props.modelValue) == null ? void 0 : _a2.from) || null; toDate.value = ((_b2 = props.modelValue) == null ? void 0 : _b2.to) || null; }); const setFromDate = (date2) => { fromDate.value = date2; }; const setToDate = (date2) => { toDate.value = date2; }; const selectRange = () => { if (fromDate.value && toDate.value) { emit("update:modelValue", { from: fromDate.value, to: toDate.value }); } }; const lang = toRef(props, "lang"); const allowedDates = toRef(props, "allowedDates"); const CalendarComponent = computed(() => RANGE_PICKER_TYPE_TO_COMPONENT[props.type]); const direction = useDirection(lang); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", { class: "EMRoot", lang: unref(lang) }, [ (openBlock(), createBlock(resolveDynamicComponent(unref(CalendarComponent)), { lang: unref(lang), direction: unref(direction), "from-date": fromDate.value, "to-date": toDate.value, "set-from-date": setFromDate, "set-to-date": setToDate, "common-dates": __props.commonDates, "allowed-dates": unref(allowedDates), "select-range": selectRange, class: normalizeClass(props.rangePickerClass) }, null, 8, ["lang", "direction", "from-date", "to-date", "common-dates", "allowed-dates", "class"])) ], 8, _hoisted_1$a); }; } }); function useDatePicker() { return { date: inject("date")