UNPKG

birdpaper-ui

Version:

一个通用的 vue3 UI组件库。A common vue3 UI component library.

48 lines (47 loc) 1.55 kB
"use strict"; const vue = require("vue"); const dayjs = require("dayjs"); const types = require("../types.js"); const core = require("../core.js"); const birdpaperIcon = require("birdpaper-icon"); const _sfc_main = vue.defineComponent({ name: "MonthTable", components: { IconArrowLeftDoubleFill: birdpaperIcon.IconArrowLeftDoubleFill, IconArrowRightDoubleFill: birdpaperIcon.IconArrowRightDoubleFill }, emits: ["change-picker"], setup(props, { emit }) { const name = "bp-month-table"; let ctx = null; ctx = vue.inject(types.dateInjectionKey); const { toDay, current, currentYear, monthCell, setMonthCell, changeYear } = core.useDayJs(ctx.langs, ctx.modelValue.value); const currentVal = vue.ref(current.value && current.value.format(ctx.valueFormat)); setMonthCell(ctx.valueFormat); const handleChange = (type, step = 1) => { let val = currentYear.value; val = type === "next" ? val + step : val - step; changeYear(val); setMonthCell(ctx.valueFormat); }; const handleSelect = (date) => { currentVal.value = date.value; ctx.onSelect(currentVal.value, {}, false); emit("change-picker", "date"); }; const handleChangePicker = (typeName, val) => { emit("change-picker", typeName, val); }; return { name, ctx, toDay, currentVal, currentYear, monthCell, handleSelect, handleChange, handleChangePicker, PanelType: types.PanelType, dayjs }; } }); module.exports = _sfc_main;