@opensig/opendesign
Version:
172 lines (171 loc) • 6.62 kB
JavaScript
"use strict";
const vue = require("vue");
const InBox_vue_vue_type_script_setup_true_lang = require("../_components/in-box/InBox.vue.js");
const vueUtils = require("../_utils/vue-utils.js");
const provide = require("../time-picker/provide.js");
const types = require("./types.js");
const usePickerBase = require("./composables/use-picker-base.js");
const utils = require("./utils.js");
const InnerDatePicker_vue_vue_type_script_setup_true_lang = require("./components/InnerDatePicker.vue.js");
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "ODateTimePicker",
props: /* @__PURE__ */ vue.mergeModels(types.dateTimePickerProps, {
"modelValue": { default: void 0 },
"modelModifiers": {}
}),
emits: /* @__PURE__ */ vue.mergeModels(["change", "blur", "focus", "clear", "pressEnter"], ["update:modelValue"]),
setup(__props, { expose: __expose, emit: __emit }) {
const props = __props;
const emits = __emit;
const modelValue = vue.useModel(__props, "modelValue");
const { timestampValue, effectiveColor, inputId, isFocus, onFocus, onBlur, onClear, onPressEnter, notifyChange } = usePickerBase.usePickerBase({
props,
mode: "datetime",
modelValue,
emit: emits
});
const propsRefs = vue.toRefs(props);
vue.provide(provide.timePickerInjectKey, {
disabled: propsRefs.disabled,
readonly: propsRefs.readonly,
size: propsRefs.size,
round: propsRefs.round,
noResponsive: propsRefs.noResponsive,
popupPosition: propsRefs.popupPosition,
popupWrapper: propsRefs.popupWrapper,
transition: propsRefs.transition,
// 时间格式:从 format 中提取时间部分
format: vue.computed(() => {
const match = props.format.match(/HH:mm(?::ss)?/);
return match ? match[0] : "HH:mm:ss";
}),
// 时间约束:dateTimePickerProps 包含 timeConstraintProps,直接使用
hourStep: propsRefs.hourStep,
minuteStep: propsRefs.minuteStep,
secondStep: propsRefs.secondStep,
disabledHours: propsRefs.disabledHours,
disabledMinutes: propsRefs.disabledMinutes,
disabledSeconds: propsRefs.disabledSeconds,
minTime: vue.computed(() => {
var _a, _b, _c;
return ((_a = propsRefs.minTime) == null ? void 0 : _a.value) ?? (((_b = propsRefs.minDate) == null ? void 0 : _b.value) ? (_c = utils.parseValue(propsRefs.minDate.value)) == null ? void 0 : _c.format("HH:mm:ss") : void 0);
}),
maxTime: vue.computed(() => {
var _a, _b, _c;
return ((_a = propsRefs.maxTime) == null ? void 0 : _a.value) ?? (((_b = propsRefs.maxDate) == null ? void 0 : _b.value) ? (_c = utils.parseValue(propsRefs.maxDate.value)) == null ? void 0 : _c.format("HH:mm:ss") : void 0);
})
});
const onChange = (newVal, oldVal) => {
emits("change", newVal, oldVal);
notifyChange();
};
const inBoxRef = vue.ref();
const innerRef = vue.ref();
__expose({
/**
* @zh-CN 使输入框获取焦点,open 为 false 时仅聚焦不打开面板
* @en-US Focus the input. Pass false to focus without opening the panel.
*/
focus: (open = true) => {
var _a;
return (_a = innerRef.value) == null ? void 0 : _a.focus(open);
},
/**
* @zh-CN 使输入框失去焦点
* @en-US Blur the input
*/
blur: () => {
var _a;
return (_a = innerRef.value) == null ? void 0 : _a.blur();
},
/**
* @zh-CN 清除输入值
* @en-US Clear the input value
*/
clear: () => {
var _a;
return (_a = innerRef.value) == null ? void 0 : _a.clear();
},
/**
* @zh-CN 获取输入框 DOM 元素
* @en-US Get the input DOM element
*/
inputEl: () => {
var _a;
return (_a = innerRef.value) == null ? void 0 : _a.inputEl();
}
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(
vue.unref(InBox_vue_vue_type_script_setup_true_lang),
vue.mergeProps({
ref_key: "inBoxRef",
ref: inBoxRef
}, {
size: props.size,
variant: props.variant,
color: vue.unref(effectiveColor),
disabled: props.disabled,
readonly: props.readonly,
round: props.round,
focused: vue.unref(isFocus)
}, { class: ["o-date-picker", "o-datetime-picker", "o-input"] }),
vue.createSlots({
default: vue.withCtx(() => {
var _a;
return [
vue.createVNode(InnerDatePicker_vue_vue_type_script_setup_true_lang, {
ref_key: "innerRef",
ref: innerRef,
modelValue: vue.unref(timestampValue),
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vue.isRef(timestampValue) ? timestampValue.value = $event : null),
"in-box-ref": (_a = inBoxRef.value) == null ? void 0 : _a.$el,
"input-id": vue.unref(inputId),
"has-icon": "",
onFocus: vue.unref(onFocus),
onBlur: vue.unref(onBlur),
onClear: vue.unref(onClear),
onPressEnter: vue.unref(onPressEnter),
onChange
}, vue.createSlots({
_: 2
/* DYNAMIC */
}, [
!vue.unref(vueUtils.isEmptySlot)(_ctx.$slots.shortcut) ? {
name: "shortcut",
fn: vue.withCtx(({ setValue, emitChange }) => [
vue.renderSlot(_ctx.$slots, "shortcut", {
setValue,
emitChange
})
]),
key: "0"
} : void 0
]), 1032, ["modelValue", "in-box-ref", "input-id", "onFocus", "onBlur", "onClear", "onPressEnter"])
];
}),
_: 2
/* DYNAMIC */
}, [
!vue.unref(vueUtils.isEmptySlot)(_ctx.$slots.prepend) ? {
name: "prepend",
fn: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "prepend")
]),
key: "0"
} : void 0,
!vue.unref(vueUtils.isEmptySlot)(_ctx.$slots.append) ? {
name: "append",
fn: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "append")
]),
key: "1"
} : void 0
]),
1040
/* FULL_PROPS, DYNAMIC_SLOTS */
);
};
}
});
module.exports = _sfc_main;