birdpaper-ui
Version:
一个通用的 vue3 UI组件库。A common vue3 UI component library.
82 lines (81 loc) • 2.64 kB
JavaScript
"use strict";
const vue = require("vue");
const dateTable = require("./components/date-table.vue.js");
const monthTable = require("./components/month-table.vue.js");
const yearTable = require("./components/year-table.vue.js");
const types = require("./types.js");
const name = "bp-date-picker-panel";
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "pickerPanel",
setup(__props) {
const currentTable = vue.ref("date");
const tableMap = {
date: dateTable,
month: monthTable,
year: yearTable
};
let ctx = null;
ctx = vue.inject(types.dateInjectionKey);
const tableRef = vue.ref();
const onChangePicker = (typeName) => {
currentTable.value = typeName;
};
const setNowTime = () => {
tableRef.value.setNow();
};
const confirmBtnDisabled = vue.computed(() => {
if (tableRef.value) {
const { currentVal, currentTimeVal } = tableRef.value;
return !currentVal || !currentTimeVal;
}
return true;
});
const onConfirm = () => {
const val = tableRef.value.getValue() || "";
ctx.onSelect(val, {}, true);
};
return (_ctx, _cache) => {
const _component_bp_button = vue.resolveComponent("bp-button");
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass(name)
}, [
vue.createElementVNode("div", {
class: vue.normalizeClass(`${name}-wrapper`)
}, [
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tableMap[currentTable.value]), {
ref_key: "tableRef",
ref: tableRef,
onChangePicker
}, null, 544))
], 2),
vue.unref(ctx).showTime && currentTable.value === "date" ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: vue.normalizeClass(`${name}-footer`)
}, [
vue.createVNode(_component_bp_button, {
size: "mini",
onClick: setNowTime
}, {
default: vue.withCtx(() => [
vue.createTextVNode("此刻")
]),
_: 1
}),
vue.createVNode(_component_bp_button, {
size: "mini",
type: "primary",
disabled: confirmBtnDisabled.value,
status: "primary",
onClick: onConfirm
}, {
default: vue.withCtx(() => [
vue.createTextVNode("确定")
]),
_: 1
}, 8, ["disabled"])
], 2)) : vue.createCommentVNode("", true)
]);
};
}
});
module.exports = _sfc_main;