UNPKG

maz-ui

Version:

A standalone components library for Vue.Js 3 & Nuxt.Js 3

1 lines 2.88 kB
import{t as _plugin_vue_export_helper_default}from"../../chunks/_plugin-vue_export-helper.ChmETRGw.js";import{t as MazBtn_default}from"../../chunks/MazBtn.DJj8H23m.js";import{computed,createElementBlock,createTextVNode,createVNode,defineComponent,openBlock,toDisplayString,unref,withCtx}from"vue";import{MazChevronLeft}from"@maz-ui/icons/static/MazChevronLeft";import{formatDate}from"@maz-ui/utils/helpers/formatDate";import dayjs from"dayjs";import{capitalize}from"@maz-ui/utils/helpers/capitalize";import '../../assets/MazPickerCalendarSwitcher.DKH3zzWP.css';var _hoisted_1={class:`m-date-picker-calendar-switcher`};var MazPickerCalendarSwitcher_default=_plugin_vue_export_helper_default(defineComponent({__name:`MazPickerCalendarSwitcher`,props:{calendarDate:{type:String,default:void 0},locale:{type:String,required:!0},double:{type:Boolean,required:!0}},emits:[`previous`,`next`,`open-month-switcher`,`open-year-switcher`,`update:calendar-date`],setup(__props,{emit:__emit}){let props=__props;let emits=__emit;let calendarDate2=computed(()=>dayjs(props.calendarDate));let monthLabel=computed(()=>props.double?`${capitalize(formatDate(calendarDate2.value.format(),props.locale,{month:`short`})??calendarDate2.value.format())} - ${capitalize(formatDate(calendarDate2.value.add(1,`month`).format(),props.locale,{month:`short`})??calendarDate2.value.add(1,`month`).format())}`:capitalize(formatDate(calendarDate2.value.format(),props.locale,{month:`short`})??calendarDate2.value.format()));let yearLabel=computed(()=>formatDate(calendarDate2.value.format(),props.locale,{year:`numeric`}));function previousMonth(){emits(`update:calendar-date`,dayjs(props.calendarDate).subtract(1,`month`).format())}function nextMonth(){emits(`update:calendar-date`,dayjs(props.calendarDate).add(1,`month`).format())}return(_ctx,_cache)=>(openBlock(),createElementBlock(`div`,_hoisted_1,[createVNode(MazBtn_default,{size:`xs`,color:`transparent`,type:`button`,onClick:previousMonth},{default:withCtx(()=>[createVNode(unref(MazChevronLeft),{class:`maz-text-lg`})]),_:1}),createVNode(MazBtn_default,{size:`sm`,color:`transparent`,type:`button`,class:`m-date-picker-calendar-switcher__date`,onClick:_cache[0]||=$event=>_ctx.$emit(`open-month-switcher`,$event)},{default:withCtx(()=>[createTextVNode(toDisplayString(monthLabel.value),1)]),_:1}),createVNode(MazBtn_default,{size:`sm`,color:`transparent`,type:`button`,class:`m-date-picker-calendar-switcher__date`,onClick:_cache[1]||=$event=>_ctx.$emit(`open-year-switcher`,$event)},{default:withCtx(()=>[createTextVNode(toDisplayString(yearLabel.value),1)]),_:1}),createVNode(MazBtn_default,{size:`xs`,color:`transparent`,type:`button`,onClick:nextMonth},{default:withCtx(()=>[createVNode(unref(MazChevronLeft),{class:`maz-rotate-180 maz-text-lg`})]),_:1})]))}}),[[`__scopeId`,`data-v-063d74d1`]]);export{MazPickerCalendarSwitcher_default as default};