You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.9 KiB

import { defineComponent, provide, ref, h, renderSlot } from 'vue';
import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import advancedFormat from 'dayjs/plugin/advancedFormat';
import localeData from 'dayjs/plugin/localeData';
import weekOfYear from 'dayjs/plugin/weekOfYear';
import weekYear from 'dayjs/plugin/weekYear';
import dayOfYear from 'dayjs/plugin/dayOfYear';
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
import '../../time-picker/index.mjs';
import './date-picker-com/panel-date-pick.mjs';
import './date-picker-com/panel-date-range.mjs';
import './date-picker-com/panel-month-range.mjs';
import { ROOT_PICKER_INJECTION_KEY } from './date-picker.type.mjs';
import script from './date-picker-com/panel-date-range.vue_vue_type_script_lang.mjs';
import script$1 from './date-picker-com/panel-month-range.vue_vue_type_script_lang.mjs';
import script$2 from './date-picker-com/panel-date-pick.vue_vue_type_script_lang.mjs';
import { timePickerDefaultProps } from '../../time-picker/src/common/props.mjs';
import { DEFAULT_FORMATS_DATEPICKER, DEFAULT_FORMATS_DATE } from '../../time-picker/src/common/constant.mjs';
import script$3 from '../../time-picker/src/common/picker.vue_vue_type_script_lang.mjs';
dayjs.extend(localeData);
dayjs.extend(advancedFormat);
dayjs.extend(customParseFormat);
dayjs.extend(weekOfYear);
dayjs.extend(weekYear);
dayjs.extend(dayOfYear);
dayjs.extend(isSameOrAfter);
dayjs.extend(isSameOrBefore);
const getPanel = function(type) {
if (type === "daterange" || type === "datetimerange") {
return script;
} else if (type === "monthrange") {
return script$1;
}
return script$2;
};
var DatePicker = defineComponent({
name: "ElDatePicker",
install: null,
props: {
...timePickerDefaultProps,
type: {
type: String,
default: "date"
}
},
emits: ["update:modelValue"],
setup(props, ctx) {
provide("ElPopperOptions", props.popperOptions);
provide(ROOT_PICKER_INJECTION_KEY, {
ctx
});
const commonPicker = ref(null);
const refProps = {
...props,
focus: (focusStartInput = true) => {
var _a;
(_a = commonPicker.value) == null ? void 0 : _a.focus(focusStartInput);
}
};
ctx.expose(refProps);
return () => {
var _a;
const format = (_a = props.format) != null ? _a : DEFAULT_FORMATS_DATEPICKER[props.type] || DEFAULT_FORMATS_DATE;
return h(script$3, {
...props,
format,
type: props.type,
ref: commonPicker,
"onUpdate:modelValue": (value) => ctx.emit("update:modelValue", value)
}, {
default: (scopedProps) => h(getPanel(props.type), scopedProps),
"range-separator": () => renderSlot(ctx.slots, "range-separator")
});
};
}
});
export { DatePicker as default };
//# sourceMappingURL=date-picker.mjs.map