UNPKG

code-monkey-ui

Version:

A Component Library for Vue 3

83 lines (80 loc) 2.92 kB
import { defineComponent, provide, reactive, toRef, ref, createVNode, mergeProps } from 'vue'; import dayjs from 'dayjs'; import customParseFormat from 'dayjs/plugin/customParseFormat.js'; import advancedFormat from 'dayjs/plugin/advancedFormat.js'; import localeData from 'dayjs/plugin/localeData.js'; import weekOfYear from 'dayjs/plugin/weekOfYear.js'; import weekYear from 'dayjs/plugin/weekYear.js'; import dayOfYear from 'dayjs/plugin/dayOfYear.js'; import isSameOrAfter from 'dayjs/plugin/isSameOrAfter.js'; import isSameOrBefore from 'dayjs/plugin/isSameOrBefore.js'; import '../../../hooks/index.mjs'; import '../../time-picker/index.mjs'; import WeekPickPanel from './date-picker-com/panel-week-pick.mjs'; import { ROOT_WEEK_PICKER_INJECTION_KEY } from './constants.mjs'; import { weekPickerProps } from './props/week-picker.mjs'; import { useNamespace } from '../../../hooks/use-namespace/index.mjs'; import { DEFAULT_FORMATS_DATEPICKER, DEFAULT_FORMATS_DATE } from '../../time-picker/src/constants.mjs'; import CommonPicker from '../../time-picker/src/common/picker.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); var WeekPicker = defineComponent({ name: "ElWeekPicker", install: null, props: weekPickerProps, emits: ["update:modelValue"], setup(props, { expose, emit, slots }) { const ns = useNamespace("picker-panel"); provide("ElPopperOptions", reactive(toRef(props, "popperOptions"))); provide(ROOT_WEEK_PICKER_INJECTION_KEY, { slots, pickerNs: ns }); const commonPicker = ref(); const refProps = { focus: (focusStartInput = true) => { var _a; (_a = commonPicker.value) == null ? void 0 : _a.focus(focusStartInput); }, handleOpen: () => { var _a; (_a = commonPicker.value) == null ? void 0 : _a.handleOpen(); }, handleClose: () => { var _a; (_a = commonPicker.value) == null ? void 0 : _a.handleClose(); } }; expose(refProps); const onModelValueUpdated = (val) => { emit("update:modelValue", val); }; return () => { var _a; const format = (_a = props.format) != null ? _a : DEFAULT_FORMATS_DATEPICKER[props.type] || DEFAULT_FORMATS_DATE; return createVNode(CommonPicker, mergeProps(props, { "format": format, "type": "week", "ref": commonPicker, "onUpdate:modelValue": onModelValueUpdated }), { default: (scopedProps) => createVNode(WeekPickPanel, mergeProps(scopedProps, { "weekStart": props.weekStart }), slots), "range-separator": slots["range-separator"] }); }; } }); export { WeekPicker as default }; //# sourceMappingURL=week-picker.mjs.map