UNPKG

vuux

Version:

Vue3 Nuxt3 Nuxt4 组件库

2 lines (1 loc) 1.15 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../day/index.cjs"),l=require("../date.cjs"),s=require("vue"),w=(c,u)=>{const v=a().year(),m=a().month()+1,d=s.ref(l.getMonthDate()),e=s.reactive({year:v,month:m}),n=()=>{d.value=l.getMonthDate(e.year,e.month)},y=(t="")=>{e.year=a(t||void 0).year(),e.month=a(t||void 0).month()+1,n()},D=()=>{e.month>1?e.month-=1:(e.year-=1,e.month=12),n()},i=()=>{e.month<12?e.month+=1:(e.year+=1,e.month=1),n()},f=()=>{e.year-=1,n()},M=()=>{e.year+=1,n()},$=t=>{const r=`${t.year}-${t.month}-${t.showDate}`,o=a(r).format("YYYY-MM-DD");c.value=o,u("change",o)},S=s.computed(()=>t=>a().isSame(a(`${t.year}-${t.month}-${t.date}`),"day")),Y=s.computed(()=>t=>{const r=t.date===t.showDate;let o=!1;if(t.date>0&&t.date<=t.showDate){const g=`${e.year}-${e.month}-${t.showDate}`;o=a(g).isSame(a(c.value))}let h="";return r&&(h+=" is-e"),o&&(h+=" is-selected"),h});return s.onMounted(()=>{y(c.value)}),{dateData:d,dateState:e,dateItemClassNames:Y,checkToday:S,init:y,handlePrveYear:f,handlePrveMonth:D,handleNextMonth:i,handleNextYear:M,handleSelectDateFn:$}};exports.useDate=w;