UNPKG

@opensig/opendesign

Version:

139 lines (138 loc) 4.96 kB
"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 types = require("./types.js"); const usePickerBase = require("./composables/use-picker-base.js"); const InnerDatePicker_vue_vue_type_script_setup_true_lang = require("./components/InnerDatePicker.vue.js"); const _sfc_main = /* @__PURE__ */ vue.defineComponent({ __name: "OMonthPicker", props: /* @__PURE__ */ vue.mergeModels(types.monthPickerProps, { "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: "month", modelValue, emit: emits }); 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-month-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;