@element-plus/nightly 0.0.20220109 → 0.0.20220113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/attributes.json +1 -1
- package/dist/index.css +1 -1
- package/dist/index.full.js +417 -437
- package/dist/index.full.min.js +8 -8
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +8 -8
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +421 -442
- package/es/components/calendar/src/calendar.vue_vue_type_script_lang.mjs +4 -4
- package/es/components/calendar/src/calendar.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/calendar/src/calendar.vue_vue_type_template_id_76705c76_lang.mjs.map +1 -1
- package/es/components/cascader/index.d.ts +18 -2
- package/es/components/cascader/src/index.vue.d.ts +9 -1
- package/es/components/cascader/src/index.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/cascader/src/index.vue_vue_type_template_id_0429c2db_lang.mjs +5 -3
- package/es/components/cascader/src/index.vue_vue_type_template_id_0429c2db_lang.mjs.map +1 -1
- package/es/components/date-picker/src/date-picker-com/panel-date-pick.vue_vue_type_script_lang.mjs +6 -0
- package/es/components/date-picker/src/date-picker-com/panel-date-pick.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/date-picker/src/date-picker-com/panel-date-pick.vue_vue_type_template_id_78e07aa7_lang.mjs.map +1 -1
- package/es/components/descriptions/index.d.ts +4 -4
- package/es/components/descriptions/src/description-item.d.ts +2 -2
- package/es/components/dropdown/index.d.ts +19 -7
- package/es/components/dropdown/src/dropdown-item-impl.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/dropdown/src/dropdown-item-impl.vue_vue_type_template_id_6daab4f2_lang.mjs +32 -26
- package/es/components/dropdown/src/dropdown-item-impl.vue_vue_type_template_id_6daab4f2_lang.mjs.map +1 -1
- package/es/components/dropdown/src/dropdown-item.vue.d.ts +3 -2
- package/es/components/dropdown/src/dropdown-item.vue_vue_type_script_lang.mjs +6 -3
- package/es/components/dropdown/src/dropdown-item.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/dropdown/src/dropdown-item.vue_vue_type_template_id_396ed16b_lang.mjs.map +1 -1
- package/es/components/dropdown/src/dropdown-menu.vue.d.ts +1 -0
- package/es/components/dropdown/src/dropdown-menu.vue_vue_type_script_lang.mjs +8 -7
- package/es/components/dropdown/src/dropdown-menu.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/dropdown/src/dropdown-menu.vue_vue_type_template_id_617b3492_lang.mjs +1 -1
- package/es/components/dropdown/src/dropdown-menu.vue_vue_type_template_id_617b3492_lang.mjs.map +1 -1
- package/es/components/dropdown/src/dropdown.vue.d.ts +11 -3
- package/es/components/index.mjs +1 -0
- package/es/components/index.mjs.map +1 -1
- package/es/components/message-box/src/index.vue.d.ts +2 -2
- package/es/components/pagination/index.d.ts +2 -2
- package/es/components/pagination/src/pagination.d.ts +2 -2
- package/es/components/popover/index.d.ts +18 -2
- package/es/components/popover/src/index.vue.d.ts +9 -1
- package/es/components/popper/src/content.vue_vue_type_script_lang.mjs +2 -1
- package/es/components/popper/src/content.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/popper/src/content.vue_vue_type_template_id_611b76f0_lang.mjs.map +1 -1
- package/es/components/popper/src/trigger.vue.d.ts +3 -3
- package/es/components/popper/src/trigger.vue_vue_type_script_lang.mjs +2 -2
- package/es/components/popper/src/trigger.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/popper/src/trigger.vue_vue_type_template_id_4fb6e0af_lang.mjs.map +1 -1
- package/es/components/roving-focus-group/src/roving-focus-group-impl.vue.d.ts +1 -1
- package/es/components/roving-focus-group/src/roving-focus-item.vue.d.ts +1 -1
- package/es/components/select/index.d.ts +9 -1
- package/es/components/select/src/select.vue.d.ts +9 -1
- package/es/components/select/src/useSelect.d.ts +9 -1
- package/es/components/select-v2/index.d.ts +18 -2
- package/es/components/select-v2/src/select.vue.d.ts +9 -1
- package/es/components/select-v2/src/useSelect.d.ts +9 -1
- package/es/components/table/src/filter-panel.vue.d.ts +9 -1
- package/es/components/time-picker/src/common/picker.vue.d.ts +9 -1
- package/es/components/time-picker/src/common/picker.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/time-picker/src/common/picker.vue_vue_type_template_id_1d54be91_lang.mjs +4 -2
- package/es/components/time-picker/src/common/picker.vue_vue_type_template_id_1d54be91_lang.mjs.map +1 -1
- package/es/components/time-select/index.d.ts +14 -0
- package/es/components/time-select/src/time-select.vue.d.ts +7 -0
- package/es/components/time-select/src/time-select.vue_vue_type_script_lang.mjs +45 -7
- package/es/components/time-select/src/time-select.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/time-select/src/time-select.vue_vue_type_template_id_5beb6389_lang.mjs.map +1 -1
- package/es/components/tooltip/index.d.ts +5 -0
- package/es/components/tooltip/index.mjs +1 -0
- package/es/components/tooltip/index.mjs.map +1 -1
- package/es/components/tooltip/src/content.vue.d.ts +13 -6
- package/es/components/tooltip/src/content.vue_vue_type_script_lang.mjs +42 -67
- package/es/components/tooltip/src/content.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/tooltip/src/content.vue_vue_type_template_id_20254f8d_lang.mjs +53 -56
- package/es/components/tooltip/src/content.vue_vue_type_template_id_20254f8d_lang.mjs.map +1 -1
- package/es/components/tooltip/src/tokens.d.ts +1 -0
- package/es/components/tooltip/src/tokens.mjs.map +1 -1
- package/es/components/tooltip/src/tooltip.d.ts +2 -0
- package/es/components/tooltip/src/tooltip.mjs +8 -0
- package/es/components/tooltip/src/tooltip.mjs.map +1 -1
- package/es/components/tooltip/src/tooltip.vue.d.ts +4 -0
- package/es/components/tooltip/src/tooltip.vue_vue_type_script_lang.mjs +2 -1
- package/es/components/tooltip/src/tooltip.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/tooltip/src/tooltip.vue_vue_type_template_id_694d1617_lang.mjs +2 -1
- package/es/components/tooltip/src/tooltip.vue_vue_type_template_id_694d1617_lang.mjs.map +1 -1
- package/es/components/tooltip/src/trigger.vue.d.ts +1 -1
- package/es/components/tooltip/src/trigger.vue_vue_type_script_lang.mjs +2 -2
- package/es/components/tooltip/src/trigger.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/tooltip/src/trigger.vue_vue_type_template_id_0ec0b94c_lang.mjs +2 -2
- package/es/components/tooltip/src/trigger.vue_vue_type_template_id_0ec0b94c_lang.mjs.map +1 -1
- package/es/components/tree/src/model/useDragNode.mjs +1 -1
- package/es/components/tree/src/model/useDragNode.mjs.map +1 -1
- package/es/components/tree/src/tree-node.vue_vue_type_script_lang.mjs +1 -1
- package/es/components/tree/src/tree-node.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/tree/src/tree-node.vue_vue_type_template_id_62959aba_lang.mjs.map +1 -1
- package/es/components/tree-v2/src/tree-node.vue.d.ts +1 -1
- package/es/components/virtual-list/src/builders/build-grid.d.ts +2 -2
- package/es/components/virtual-list/src/builders/build-list.d.ts +2 -2
- package/es/components/virtual-list/src/components/dynamic-size-grid.d.ts +2 -2
- package/es/components/virtual-list/src/components/dynamic-size-list.d.ts +2 -2
- package/es/components/virtual-list/src/components/fixed-size-grid.d.ts +2 -2
- package/es/components/virtual-list/src/components/fixed-size-list.d.ts +2 -2
- package/es/index.mjs +1 -0
- package/es/index.mjs.map +1 -1
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/version.mjs.map +1 -1
- package/lib/components/calendar/src/calendar.vue_vue_type_script_lang.js +4 -4
- package/lib/components/calendar/src/calendar.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/calendar/src/calendar.vue_vue_type_template_id_76705c76_lang.js.map +1 -1
- package/lib/components/cascader/index.d.ts +18 -2
- package/lib/components/cascader/src/index.vue.d.ts +9 -1
- package/lib/components/cascader/src/index.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/cascader/src/index.vue_vue_type_template_id_0429c2db_lang.js +4 -2
- package/lib/components/cascader/src/index.vue_vue_type_template_id_0429c2db_lang.js.map +1 -1
- package/lib/components/date-picker/src/date-picker-com/panel-date-pick.vue_vue_type_script_lang.js +6 -0
- package/lib/components/date-picker/src/date-picker-com/panel-date-pick.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/date-picker/src/date-picker-com/panel-date-pick.vue_vue_type_template_id_78e07aa7_lang.js.map +1 -1
- package/lib/components/descriptions/index.d.ts +4 -4
- package/lib/components/descriptions/src/description-item.d.ts +2 -2
- package/lib/components/dropdown/index.d.ts +19 -7
- package/lib/components/dropdown/src/dropdown-item-impl.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/dropdown/src/dropdown-item-impl.vue_vue_type_template_id_6daab4f2_lang.js +31 -25
- package/lib/components/dropdown/src/dropdown-item-impl.vue_vue_type_template_id_6daab4f2_lang.js.map +1 -1
- package/lib/components/dropdown/src/dropdown-item.vue.d.ts +3 -2
- package/lib/components/dropdown/src/dropdown-item.vue_vue_type_script_lang.js +6 -3
- package/lib/components/dropdown/src/dropdown-item.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/dropdown/src/dropdown-item.vue_vue_type_template_id_396ed16b_lang.js.map +1 -1
- package/lib/components/dropdown/src/dropdown-menu.vue.d.ts +1 -0
- package/lib/components/dropdown/src/dropdown-menu.vue_vue_type_script_lang.js +7 -6
- package/lib/components/dropdown/src/dropdown-menu.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/dropdown/src/dropdown-menu.vue_vue_type_template_id_617b3492_lang.js +1 -1
- package/lib/components/dropdown/src/dropdown-menu.vue_vue_type_template_id_617b3492_lang.js.map +1 -1
- package/lib/components/dropdown/src/dropdown.vue.d.ts +11 -3
- package/lib/components/index.js +2 -0
- package/lib/components/index.js.map +1 -1
- package/lib/components/message-box/src/index.vue.d.ts +2 -2
- package/lib/components/pagination/index.d.ts +2 -2
- package/lib/components/pagination/src/pagination.d.ts +2 -2
- package/lib/components/popover/index.d.ts +18 -2
- package/lib/components/popover/src/index.vue.d.ts +9 -1
- package/lib/components/popper/src/content.vue_vue_type_script_lang.js +2 -1
- package/lib/components/popper/src/content.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/popper/src/content.vue_vue_type_template_id_611b76f0_lang.js.map +1 -1
- package/lib/components/popper/src/trigger.vue.d.ts +3 -3
- package/lib/components/popper/src/trigger.vue_vue_type_script_lang.js +2 -2
- package/lib/components/popper/src/trigger.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/popper/src/trigger.vue_vue_type_template_id_4fb6e0af_lang.js.map +1 -1
- package/lib/components/roving-focus-group/src/roving-focus-group-impl.vue.d.ts +1 -1
- package/lib/components/roving-focus-group/src/roving-focus-item.vue.d.ts +1 -1
- package/lib/components/select/index.d.ts +9 -1
- package/lib/components/select/src/select.vue.d.ts +9 -1
- package/lib/components/select/src/useSelect.d.ts +9 -1
- package/lib/components/select-v2/index.d.ts +18 -2
- package/lib/components/select-v2/src/select.vue.d.ts +9 -1
- package/lib/components/select-v2/src/useSelect.d.ts +9 -1
- package/lib/components/table/src/filter-panel.vue.d.ts +9 -1
- package/lib/components/time-picker/src/common/picker.vue.d.ts +9 -1
- package/lib/components/time-picker/src/common/picker.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/time-picker/src/common/picker.vue_vue_type_template_id_1d54be91_lang.js +4 -2
- package/lib/components/time-picker/src/common/picker.vue_vue_type_template_id_1d54be91_lang.js.map +1 -1
- package/lib/components/time-select/index.d.ts +14 -0
- package/lib/components/time-select/src/time-select.vue.d.ts +7 -0
- package/lib/components/time-select/src/time-select.vue_vue_type_script_lang.js +50 -7
- package/lib/components/time-select/src/time-select.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/time-select/src/time-select.vue_vue_type_template_id_5beb6389_lang.js.map +1 -1
- package/lib/components/tooltip/index.d.ts +5 -0
- package/lib/components/tooltip/index.js +2 -0
- package/lib/components/tooltip/index.js.map +1 -1
- package/lib/components/tooltip/src/content.vue.d.ts +13 -6
- package/lib/components/tooltip/src/content.vue_vue_type_script_lang.js +43 -68
- package/lib/components/tooltip/src/content.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/tooltip/src/content.vue_vue_type_template_id_20254f8d_lang.js +52 -55
- package/lib/components/tooltip/src/content.vue_vue_type_template_id_20254f8d_lang.js.map +1 -1
- package/lib/components/tooltip/src/tokens.d.ts +1 -0
- package/lib/components/tooltip/src/tokens.js.map +1 -1
- package/lib/components/tooltip/src/tooltip.d.ts +2 -0
- package/lib/components/tooltip/src/tooltip.js +8 -0
- package/lib/components/tooltip/src/tooltip.js.map +1 -1
- package/lib/components/tooltip/src/tooltip.vue.d.ts +4 -0
- package/lib/components/tooltip/src/tooltip.vue_vue_type_script_lang.js +2 -1
- package/lib/components/tooltip/src/tooltip.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/tooltip/src/tooltip.vue_vue_type_template_id_694d1617_lang.js +2 -1
- package/lib/components/tooltip/src/tooltip.vue_vue_type_template_id_694d1617_lang.js.map +1 -1
- package/lib/components/tooltip/src/trigger.vue.d.ts +1 -1
- package/lib/components/tooltip/src/trigger.vue_vue_type_script_lang.js +2 -2
- package/lib/components/tooltip/src/trigger.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/tooltip/src/trigger.vue_vue_type_template_id_0ec0b94c_lang.js +2 -2
- package/lib/components/tooltip/src/trigger.vue_vue_type_template_id_0ec0b94c_lang.js.map +1 -1
- package/lib/components/tree/src/model/useDragNode.js +1 -1
- package/lib/components/tree/src/model/useDragNode.js.map +1 -1
- package/lib/components/tree/src/tree-node.vue_vue_type_script_lang.js +1 -1
- package/lib/components/tree/src/tree-node.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/tree/src/tree-node.vue_vue_type_template_id_62959aba_lang.js.map +1 -1
- package/lib/components/tree-v2/src/tree-node.vue.d.ts +1 -1
- package/lib/components/virtual-list/src/builders/build-grid.d.ts +2 -2
- package/lib/components/virtual-list/src/builders/build-list.d.ts +2 -2
- package/lib/components/virtual-list/src/components/dynamic-size-grid.d.ts +2 -2
- package/lib/components/virtual-list/src/components/dynamic-size-list.d.ts +2 -2
- package/lib/components/virtual-list/src/components/fixed-size-grid.d.ts +2 -2
- package/lib/components/virtual-list/src/components/fixed-size-list.d.ts +2 -2
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +2 -2
- package/tags.json +1 -1
- package/theme-chalk/el-dropdown.css +1 -1
- package/theme-chalk/el-tabs.css +1 -1
- package/theme-chalk/el-tree.css +1 -1
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/src/dropdown.scss +13 -18
- package/theme-chalk/src/tabs.scss +8 -6
- package/theme-chalk/src/tree.scss +2 -1
- package/web-types.json +1 -1
package/lib/components/date-picker/src/date-picker-com/panel-date-pick.vue_vue_type_script_lang.js
CHANGED
|
@@ -13,6 +13,7 @@ var index$2 = require('../../../icon/index.js');
|
|
|
13
13
|
var aria = require('../../../../utils/aria.js');
|
|
14
14
|
var validators = require('../../../../utils/validators.js');
|
|
15
15
|
var iconsVue = require('@element-plus/icons-vue');
|
|
16
|
+
require('../../../tooltip/index.js');
|
|
16
17
|
require('./basic-date-table.js');
|
|
17
18
|
require('./basic-month-table.js');
|
|
18
19
|
require('./basic-year-table.js');
|
|
@@ -22,6 +23,7 @@ var basicMonthTable_vue_vue_type_script_lang = require('./basic-month-table.vue_
|
|
|
22
23
|
var basicYearTable_vue_vue_type_script_lang = require('./basic-year-table.vue_vue_type_script_lang.js');
|
|
23
24
|
var index$3 = require('../../../../directives/click-outside/index.js');
|
|
24
25
|
var index$4 = require('../../../../hooks/use-locale/index.js');
|
|
26
|
+
var tokens = require('../../../tooltip/src/tokens.js');
|
|
25
27
|
var dateUtils = require('../../../time-picker/src/common/date-utils.js');
|
|
26
28
|
|
|
27
29
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -66,6 +68,7 @@ var script = vue.defineComponent({
|
|
|
66
68
|
setup(props, ctx) {
|
|
67
69
|
const { t, lang } = index$4.useLocale();
|
|
68
70
|
const pickerBase = vue.inject("EP_PICKER_BASE");
|
|
71
|
+
const popper = vue.inject(tokens.TOOLTIP_INJECTION_KEY);
|
|
69
72
|
const {
|
|
70
73
|
shortcuts,
|
|
71
74
|
disabledDate,
|
|
@@ -179,6 +182,9 @@ var script = vue.defineComponent({
|
|
|
179
182
|
}
|
|
180
183
|
currentView.value = "date";
|
|
181
184
|
}, { immediate: true });
|
|
185
|
+
vue.watch(() => currentView.value, () => {
|
|
186
|
+
popper == null ? void 0 : popper.updatePopper();
|
|
187
|
+
});
|
|
182
188
|
const hasShortcuts = vue.computed(() => !!shortcuts.length);
|
|
183
189
|
const handleMonthPick = (month2) => {
|
|
184
190
|
innerDate.value = innerDate.value.startOf("month").month(month2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel-date-pick.vue_vue_type_script_lang.js","sources":["../../../../../../../packages/components/date-picker/src/date-picker-com/panel-date-pick.vue"],"sourcesContent":["<template>\n <div\n class=\"el-picker-panel el-date-picker\"\n :class=\"[\n {\n 'has-sidebar': $slots.sidebar || hasShortcuts,\n 'has-time': showTime,\n },\n ]\"\n >\n <div class=\"el-picker-panel__body-wrapper\">\n <slot name=\"sidebar\" class=\"el-picker-panel__sidebar\"></slot>\n <div v-if=\"hasShortcuts\" class=\"el-picker-panel__sidebar\">\n <button\n v-for=\"(shortcut, key) in shortcuts\"\n :key=\"key\"\n type=\"button\"\n class=\"el-picker-panel__shortcut\"\n @click=\"handleShortcutClick(shortcut)\"\n >\n {{ shortcut.text }}\n </button>\n </div>\n <div class=\"el-picker-panel__body\">\n <div v-if=\"showTime\" class=\"el-date-picker__time-header\">\n <span class=\"el-date-picker__editor-wrap\">\n <el-input\n :placeholder=\"t('el.datepicker.selectDate')\"\n :model-value=\"visibleDate\"\n size=\"small\"\n @input=\"(val) => (userInputDate = val)\"\n @change=\"handleVisibleDateChange\"\n />\n </span>\n <span\n v-clickoutside=\"handleTimePickClose\"\n class=\"el-date-picker__editor-wrap\"\n >\n <el-input\n :placeholder=\"t('el.datepicker.selectTime')\"\n :model-value=\"visibleTime\"\n size=\"small\"\n @focus=\"onTimePickerInputFocus\"\n @input=\"(val) => (userInputTime = val)\"\n @change=\"handleVisibleTimeChange\"\n />\n <time-pick-panel\n :visible=\"timePickerVisible\"\n :format=\"timeFormat\"\n :time-arrow-control=\"arrowControl\"\n :parsed-value=\"innerDate\"\n @pick=\"handleTimePick\"\n />\n </span>\n </div>\n <div\n v-show=\"currentView !== 'time'\"\n class=\"el-date-picker__header\"\n :class=\"{\n 'el-date-picker__header--bordered':\n currentView === 'year' || currentView === 'month',\n }\"\n >\n <button\n type=\"button\"\n :aria-label=\"t(`el.datepicker.prevYear`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__prev-btn d-arrow-left\"\n @click=\"prevYear_\"\n >\n <el-icon><d-arrow-left /></el-icon>\n </button>\n <button\n v-show=\"currentView === 'date'\"\n type=\"button\"\n :aria-label=\"t(`el.datepicker.prevMonth`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__prev-btn arrow-left\"\n @click=\"prevMonth_\"\n >\n <el-icon><arrow-left /></el-icon>\n </button>\n <span\n role=\"button\"\n class=\"el-date-picker__header-label\"\n @click=\"showYearPicker\"\n >{{ yearLabel }}</span\n >\n <span\n v-show=\"currentView === 'date'\"\n role=\"button\"\n class=\"el-date-picker__header-label\"\n :class=\"{ active: currentView === 'month' }\"\n @click=\"showMonthPicker\"\n >{{ t(`el.datepicker.month${month + 1}`) }}</span\n >\n <button\n type=\"button\"\n :aria-label=\"t(`el.datepicker.nextYear`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__next-btn d-arrow-right\"\n @click=\"nextYear_\"\n >\n <el-icon><d-arrow-right /></el-icon>\n </button>\n <button\n v-show=\"currentView === 'date'\"\n type=\"button\"\n :aria-label=\"t(`el.datepicker.nextMonth`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__next-btn arrow-right\"\n @click=\"nextMonth_\"\n >\n <el-icon><arrow-right /></el-icon>\n </button>\n </div>\n <div class=\"el-picker-panel__content\">\n <date-table\n v-if=\"currentView === 'date'\"\n :selection-mode=\"selectionMode\"\n :date=\"innerDate\"\n :parsed-value=\"parsedValue\"\n :disabled-date=\"disabledDate\"\n @pick=\"handleDatePick\"\n />\n <year-table\n v-if=\"currentView === 'year'\"\n :date=\"innerDate\"\n :disabled-date=\"disabledDate\"\n :parsed-value=\"parsedValue\"\n @pick=\"handleYearPick\"\n />\n <month-table\n v-if=\"currentView === 'month'\"\n :date=\"innerDate\"\n :parsed-value=\"parsedValue\"\n :disabled-date=\"disabledDate\"\n @pick=\"handleMonthPick\"\n />\n </div>\n </div>\n </div>\n <div\n v-show=\"footerVisible && currentView === 'date'\"\n class=\"el-picker-panel__footer\"\n >\n <el-button\n v-show=\"selectionMode !== 'dates'\"\n size=\"small\"\n type=\"text\"\n class=\"el-picker-panel__link-btn\"\n @click=\"changeToNow\"\n >\n {{ t('el.datepicker.now') }}\n </el-button>\n <el-button\n plain\n size=\"small\"\n class=\"el-picker-panel__link-btn\"\n @click=\"onConfirm\"\n >\n {{ t('el.datepicker.confirm') }}\n </el-button>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, inject, ref, watch } from 'vue'\nimport dayjs from 'dayjs'\nimport ElButton from '@element-plus/components/button'\nimport { ClickOutside } from '@element-plus/directives'\nimport { useLocale } from '@element-plus/hooks'\nimport ElInput from '@element-plus/components/input'\nimport {\n extractDateFormat,\n extractTimeFormat,\n TimePickPanel,\n} from '@element-plus/components/time-picker'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\nimport { isValidDatePickType } from '@element-plus/utils/validators'\nimport {\n DArrowLeft,\n ArrowLeft,\n DArrowRight,\n ArrowRight,\n} from '@element-plus/icons-vue'\nimport DateTable from './basic-date-table.vue'\nimport MonthTable from './basic-month-table.vue'\nimport YearTable from './basic-year-table.vue'\n\nimport type { PropType } from 'vue'\nimport type { ConfigType, Dayjs } from 'dayjs'\nimport type { IDatePickerType } from '../date-picker.type'\n\n// todo\n/* eslint-disable-next-line */\nconst timeWithinRange = (_: ConfigType, __: any, ___: string) => true\n\nexport default defineComponent({\n components: {\n DateTable,\n ElInput,\n ElButton,\n ElIcon,\n TimePickPanel,\n MonthTable,\n YearTable,\n DArrowLeft,\n ArrowLeft,\n DArrowRight,\n ArrowRight,\n },\n\n directives: { clickoutside: ClickOutside },\n props: {\n visible: {\n type: Boolean,\n default: false,\n },\n parsedValue: {\n type: [Object, Array] as PropType<Dayjs | Dayjs[]>,\n },\n format: {\n type: String,\n default: '',\n },\n type: {\n type: String as PropType<IDatePickerType>,\n required: true,\n validator: isValidDatePickType,\n },\n },\n emits: ['pick', 'set-picker-option'],\n setup(props, ctx) {\n const { t, lang } = useLocale()\n const pickerBase = inject('EP_PICKER_BASE') as any\n\n const {\n shortcuts,\n disabledDate,\n cellClassName,\n defaultTime,\n defaultValue,\n arrowControl,\n } = pickerBase.props\n\n const innerDate = ref(dayjs().locale(lang.value))\n\n const defaultTimeD = computed(() => {\n return dayjs(defaultTime).locale(lang.value)\n })\n\n const month = computed(() => {\n return innerDate.value.month()\n })\n\n const year = computed(() => {\n return innerDate.value.year()\n })\n\n const selectableRange = ref([])\n const userInputDate = ref(null)\n const userInputTime = ref(null)\n // todo update to disableHour\n const checkDateWithinRange = (date: ConfigType) => {\n return selectableRange.value.length > 0\n ? timeWithinRange(\n date,\n selectableRange.value,\n props.format || 'HH:mm:ss'\n )\n : true\n }\n const formatEmit = (emitDayjs: Dayjs) => {\n if (defaultTime && !visibleTime.value) {\n return defaultTimeD.value\n .year(emitDayjs.year())\n .month(emitDayjs.month())\n .date(emitDayjs.date())\n }\n if (showTime.value) return emitDayjs.millisecond(0)\n return emitDayjs.startOf('day')\n }\n const emit = (value, ...args) => {\n if (!value) {\n ctx.emit('pick', value, ...args)\n } else if (Array.isArray(value)) {\n const dates = value.map(formatEmit)\n ctx.emit('pick', dates, ...args)\n } else {\n ctx.emit('pick', formatEmit(value), ...args)\n }\n userInputDate.value = null\n userInputTime.value = null\n }\n const handleDatePick = (value: Dayjs) => {\n if (selectionMode.value === 'day') {\n let newDate = props.parsedValue\n ? (props.parsedValue as Dayjs)\n .year(value.year())\n .month(value.month())\n .date(value.date())\n : value\n // change default time while out of selectableRange\n if (!checkDateWithinRange(newDate)) {\n newDate = (selectableRange.value[0][0] as Dayjs)\n .year(value.year())\n .month(value.month())\n .date(value.date())\n }\n innerDate.value = newDate\n emit(newDate, showTime.value)\n } else if (selectionMode.value === 'week') {\n emit(value.date)\n } else if (selectionMode.value === 'dates') {\n emit(value, true) // set false to keep panel open\n }\n }\n const prevMonth_ = () => {\n innerDate.value = innerDate.value.subtract(1, 'month')\n }\n\n const nextMonth_ = () => {\n innerDate.value = innerDate.value.add(1, 'month')\n }\n\n const prevYear_ = () => {\n if (currentView.value === 'year') {\n innerDate.value = innerDate.value.subtract(10, 'year')\n } else {\n innerDate.value = innerDate.value.subtract(1, 'year')\n }\n }\n\n const nextYear_ = () => {\n if (currentView.value === 'year') {\n innerDate.value = innerDate.value.add(10, 'year')\n } else {\n innerDate.value = innerDate.value.add(1, 'year')\n }\n }\n\n const currentView = ref('date')\n\n const yearLabel = computed(() => {\n const yearTranslation = t('el.datepicker.year')\n if (currentView.value === 'year') {\n const startYear = Math.floor(year.value / 10) * 10\n if (yearTranslation) {\n return `${startYear} ${yearTranslation} - ${\n startYear + 9\n } ${yearTranslation}`\n }\n return `${startYear} - ${startYear + 9}`\n }\n return `${year.value} ${yearTranslation}`\n })\n\n const handleShortcutClick = (shortcut) => {\n const shortcutValue =\n typeof shortcut.value === 'function' ? shortcut.value() : shortcut.value\n if (shortcutValue) {\n emit(dayjs(shortcutValue).locale(lang.value))\n return\n }\n if (shortcut.onClick) {\n shortcut.onClick(ctx)\n }\n }\n\n const selectionMode = computed(() => {\n if (['week', 'month', 'year', 'dates'].includes(props.type)) {\n return props.type\n }\n return 'day'\n })\n\n watch(\n () => selectionMode.value,\n (val) => {\n if (['month', 'year'].includes(val)) {\n currentView.value = val\n return\n }\n currentView.value = 'date'\n },\n { immediate: true }\n )\n\n const hasShortcuts = computed(() => !!shortcuts.length)\n\n const handleMonthPick = (month) => {\n innerDate.value = innerDate.value.startOf('month').month(month)\n if (selectionMode.value === 'month') {\n emit(innerDate.value)\n } else {\n currentView.value = 'date'\n }\n }\n\n const handleYearPick = (year) => {\n if (selectionMode.value === 'year') {\n innerDate.value = innerDate.value.startOf('year').year(year)\n emit(innerDate.value)\n } else {\n innerDate.value = innerDate.value.year(year)\n currentView.value = 'month'\n }\n }\n\n const showMonthPicker = () => {\n currentView.value = 'month'\n }\n\n const showYearPicker = () => {\n currentView.value = 'year'\n }\n\n const showTime = computed(\n () => props.type === 'datetime' || props.type === 'datetimerange'\n )\n\n const footerVisible = computed(() => {\n return showTime.value || selectionMode.value === 'dates'\n })\n\n const onConfirm = () => {\n if (selectionMode.value === 'dates') {\n emit(props.parsedValue)\n } else {\n // deal with the scenario where: user opens the date time picker, then confirm without doing anything\n let result = props.parsedValue as Dayjs\n if (!result) {\n const defaultTimeD = dayjs(defaultTime).locale(lang.value)\n const defaultValueD = getDefaultValue()\n result = defaultTimeD\n .year(defaultValueD.year())\n .month(defaultValueD.month())\n .date(defaultValueD.date())\n }\n innerDate.value = result\n emit(result)\n }\n }\n\n const changeToNow = () => {\n // NOTE: not a permanent solution\n // consider disable \"now\" button in the future\n const now = dayjs().locale(lang.value)\n const nowDate = now.toDate()\n if (\n (!disabledDate || !disabledDate(nowDate)) &&\n checkDateWithinRange(nowDate)\n ) {\n innerDate.value = dayjs().locale(lang.value)\n emit(innerDate.value)\n }\n }\n\n const timeFormat = computed(() => {\n return extractTimeFormat(props.format)\n })\n\n const dateFormat = computed(() => {\n return extractDateFormat(props.format)\n })\n\n const visibleTime = computed(() => {\n if (userInputTime.value) return userInputTime.value\n if (!props.parsedValue && !defaultValue) return\n return ((props.parsedValue || innerDate.value) as Dayjs).format(\n timeFormat.value\n )\n })\n\n const visibleDate = computed(() => {\n if (userInputDate.value) return userInputDate.value\n if (!props.parsedValue && !defaultValue) return\n return ((props.parsedValue || innerDate.value) as Dayjs).format(\n dateFormat.value\n )\n })\n\n const timePickerVisible = ref(false)\n const onTimePickerInputFocus = () => {\n timePickerVisible.value = true\n }\n const handleTimePickClose = () => {\n timePickerVisible.value = false\n }\n\n const handleTimePick = (value, visible, first) => {\n const newDate = props.parsedValue\n ? (props.parsedValue as Dayjs)\n .hour(value.hour())\n .minute(value.minute())\n .second(value.second())\n : value\n innerDate.value = newDate\n emit(innerDate.value, true)\n if (!first) {\n timePickerVisible.value = visible\n }\n }\n\n const handleVisibleTimeChange = (value) => {\n const newDate = dayjs(value, timeFormat.value).locale(lang.value)\n if (newDate.isValid() && checkDateWithinRange(newDate)) {\n innerDate.value = newDate\n .year(innerDate.value.year())\n .month(innerDate.value.month())\n .date(innerDate.value.date())\n userInputTime.value = null\n timePickerVisible.value = false\n emit(innerDate.value, true)\n }\n }\n\n const handleVisibleDateChange = (value) => {\n const newDate = dayjs(value, dateFormat.value).locale(lang.value)\n if (newDate.isValid()) {\n if (disabledDate && disabledDate(newDate.toDate())) {\n return\n }\n innerDate.value = newDate\n .hour(innerDate.value.hour())\n .minute(innerDate.value.minute())\n .second(innerDate.value.second())\n userInputDate.value = null\n emit(innerDate.value, true)\n }\n }\n\n const isValidValue = (date: unknown) => {\n return (\n dayjs.isDayjs(date) &&\n date.isValid() &&\n (disabledDate ? !disabledDate(date.toDate()) : true)\n )\n }\n\n const formatToString = (value) => {\n if (selectionMode.value === 'dates') {\n return value.map((_) => _.format(props.format))\n }\n return value.format(props.format)\n }\n\n const parseUserInput = (value) => {\n return dayjs(value, props.format).locale(lang.value)\n }\n\n const getDefaultValue = () => {\n const parseDate = dayjs(defaultValue).locale(lang.value)\n if (!defaultValue) {\n const defaultTimeDValue = defaultTimeD.value\n return dayjs()\n .hour(defaultTimeDValue.hour())\n .minute(defaultTimeDValue.minute())\n .second(defaultTimeDValue.second())\n .locale(lang.value)\n }\n return parseDate\n }\n\n const handleKeydown = (event) => {\n const { code, keyCode } = event\n const list = [\n EVENT_CODE.up,\n EVENT_CODE.down,\n EVENT_CODE.left,\n EVENT_CODE.right,\n ]\n if (props.visible && !timePickerVisible.value) {\n if (list.includes(code)) {\n handleKeyControl(keyCode)\n event.stopPropagation()\n event.preventDefault()\n }\n if (\n code === EVENT_CODE.enter &&\n userInputDate.value === null &&\n userInputTime.value === null\n ) {\n // Enter\n emit(innerDate, false)\n }\n }\n }\n\n const handleKeyControl = (keyCode) => {\n const mapping = {\n year: {\n 38: -4,\n 40: 4,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setFullYear(date.getFullYear() + step),\n },\n month: {\n 38: -4,\n 40: 4,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setMonth(date.getMonth() + step),\n },\n week: {\n 38: -1,\n 40: 1,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setDate(date.getDate() + step * 7),\n },\n day: {\n 38: -7,\n 40: 7,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setDate(date.getDate() + step),\n },\n }\n\n const newDate = innerDate.value.toDate()\n while (Math.abs(innerDate.value.diff(newDate, 'year', true)) < 1) {\n const map = mapping[selectionMode.value]\n map.offset(newDate, map[keyCode])\n if (disabledDate && disabledDate(newDate)) {\n continue\n }\n const result = dayjs(newDate).locale(lang.value)\n innerDate.value = result\n ctx.emit('pick', result, true)\n break\n }\n }\n\n ctx.emit('set-picker-option', ['isValidValue', isValidValue])\n ctx.emit('set-picker-option', ['formatToString', formatToString])\n ctx.emit('set-picker-option', ['parseUserInput', parseUserInput])\n ctx.emit('set-picker-option', ['handleKeydown', handleKeydown])\n\n watch(\n () => props.parsedValue,\n (val) => {\n if (val) {\n if (selectionMode.value === 'dates') return\n if (Array.isArray(val)) return\n innerDate.value = val\n } else {\n innerDate.value = getDefaultValue()\n }\n },\n { immediate: true }\n )\n\n return {\n handleTimePick,\n handleTimePickClose,\n onTimePickerInputFocus,\n timePickerVisible,\n visibleTime,\n visibleDate,\n showTime,\n changeToNow,\n onConfirm,\n footerVisible,\n handleYearPick,\n showMonthPicker,\n showYearPicker,\n handleMonthPick,\n hasShortcuts,\n shortcuts,\n arrowControl,\n disabledDate,\n cellClassName,\n selectionMode,\n handleShortcutClick,\n prevYear_,\n nextYear_,\n prevMonth_,\n nextMonth_,\n innerDate,\n t,\n yearLabel,\n currentView,\n month,\n handleDatePick,\n handleVisibleTimeChange,\n handleVisibleDateChange,\n timeFormat,\n userInputTime,\n userInputDate,\n }\n },\n})\n</script>\n"],"names":["DateTable","ElInput","ElIcon","TimePickPanel","MonthTable","DArrowLeft","ArrowLeft","DArrowRight","ArrowRight","isValidDatePickType","ref","dayjs","computed","watch","extractDateFormat","EVENT_CODE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0LA,wBAAwB,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,IAAI,CAAC;;AAE7C,EAAE,UAAU,EAAE;AACd,eAAIA;AACJ,aAAIC;;AAEJ,YAAIC;AACJ,mBAAIC,iDAAa;AACjB,gBAAIC,mDAAU;;AAEd,gBAAIC;eACAC;iBACAC;gBACAC;;;OAGG,EAAE;IACL,OAAO,EAAE;MACP,IAAI,EAAE;MACN,OAAO;KACR;IACD,WAAW;MACT,IAAI,EAAE,CAAC;;;MAGP,IAAI,EAAE,MAAM;MACZ;KACD;QACG,EAAE;MACJ,IAAI,EAAE,MAAM;;MAEZ,SAAS,EAAEC;;;OAGV,EAAE,CAAC;OACH,CAAC,KAAK,EAAE,GAAG;UACR,EAAE,CAAC,EAAE;IACX;IACA,MAAM;MACJ,SAAS;MACT,YAAY;MACZ,aAAa;;;MAGb,YAAY;KACb,GAAG,UAAU;IACd,MAAM,YAAYC,OAAG,CAACC,yBAAK,E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C,IAAI,CAAC,KAAK,CAAC,CAAC;;QAEjD;QACA,MAAM;;;YAGF,CAAC,mBAAmB,EAAE,CAAC;QAC3B,IAAI,CAAC,mBAAmB;QACxB,IAAI,CAAC,mBAAmB,EAAE;;IAE9BE;;QAEI,IAAI,aAAa,CAAC,UAAU;UAC1B;QACF,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG;UACnB,OAAO;QACT,SAAS,CAAC,QAAQ,GAAG,CAAC;;;;KAIzB,EAAE,WAAW,EAAE,OAAO,CAAC;WACjB;oBACS;MACd;MACA,sBAAsB;;;MAGtB,WAAW;MACX,QAAQ;;;MAGR,aAAa;MACb,cAAc;MACd,eAAe;oBACD;qBACC;kBACH;eACH;kBACG;kBACA;MACZ;MACA,aAAa;;;MAGb,SAAS;MACT,UAAU;MACV;eACS;;eAEA;iBACE;MACX;MACA,cAAc;6BACS;6BACA;gBACb;mBACG;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"panel-date-pick.vue_vue_type_script_lang.js","sources":["../../../../../../../packages/components/date-picker/src/date-picker-com/panel-date-pick.vue"],"sourcesContent":["<template>\n <div\n class=\"el-picker-panel el-date-picker\"\n :class=\"[\n {\n 'has-sidebar': $slots.sidebar || hasShortcuts,\n 'has-time': showTime,\n },\n ]\"\n >\n <div class=\"el-picker-panel__body-wrapper\">\n <slot name=\"sidebar\" class=\"el-picker-panel__sidebar\"></slot>\n <div v-if=\"hasShortcuts\" class=\"el-picker-panel__sidebar\">\n <button\n v-for=\"(shortcut, key) in shortcuts\"\n :key=\"key\"\n type=\"button\"\n class=\"el-picker-panel__shortcut\"\n @click=\"handleShortcutClick(shortcut)\"\n >\n {{ shortcut.text }}\n </button>\n </div>\n <div class=\"el-picker-panel__body\">\n <div v-if=\"showTime\" class=\"el-date-picker__time-header\">\n <span class=\"el-date-picker__editor-wrap\">\n <el-input\n :placeholder=\"t('el.datepicker.selectDate')\"\n :model-value=\"visibleDate\"\n size=\"small\"\n @input=\"(val) => (userInputDate = val)\"\n @change=\"handleVisibleDateChange\"\n />\n </span>\n <span\n v-clickoutside=\"handleTimePickClose\"\n class=\"el-date-picker__editor-wrap\"\n >\n <el-input\n :placeholder=\"t('el.datepicker.selectTime')\"\n :model-value=\"visibleTime\"\n size=\"small\"\n @focus=\"onTimePickerInputFocus\"\n @input=\"(val) => (userInputTime = val)\"\n @change=\"handleVisibleTimeChange\"\n />\n <time-pick-panel\n :visible=\"timePickerVisible\"\n :format=\"timeFormat\"\n :time-arrow-control=\"arrowControl\"\n :parsed-value=\"innerDate\"\n @pick=\"handleTimePick\"\n />\n </span>\n </div>\n <div\n v-show=\"currentView !== 'time'\"\n class=\"el-date-picker__header\"\n :class=\"{\n 'el-date-picker__header--bordered':\n currentView === 'year' || currentView === 'month',\n }\"\n >\n <button\n type=\"button\"\n :aria-label=\"t(`el.datepicker.prevYear`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__prev-btn d-arrow-left\"\n @click=\"prevYear_\"\n >\n <el-icon><d-arrow-left /></el-icon>\n </button>\n <button\n v-show=\"currentView === 'date'\"\n type=\"button\"\n :aria-label=\"t(`el.datepicker.prevMonth`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__prev-btn arrow-left\"\n @click=\"prevMonth_\"\n >\n <el-icon><arrow-left /></el-icon>\n </button>\n <span\n role=\"button\"\n class=\"el-date-picker__header-label\"\n @click=\"showYearPicker\"\n >{{ yearLabel }}</span\n >\n <span\n v-show=\"currentView === 'date'\"\n role=\"button\"\n class=\"el-date-picker__header-label\"\n :class=\"{ active: currentView === 'month' }\"\n @click=\"showMonthPicker\"\n >{{ t(`el.datepicker.month${month + 1}`) }}</span\n >\n <button\n type=\"button\"\n :aria-label=\"t(`el.datepicker.nextYear`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__next-btn d-arrow-right\"\n @click=\"nextYear_\"\n >\n <el-icon><d-arrow-right /></el-icon>\n </button>\n <button\n v-show=\"currentView === 'date'\"\n type=\"button\"\n :aria-label=\"t(`el.datepicker.nextMonth`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__next-btn arrow-right\"\n @click=\"nextMonth_\"\n >\n <el-icon><arrow-right /></el-icon>\n </button>\n </div>\n <div class=\"el-picker-panel__content\">\n <date-table\n v-if=\"currentView === 'date'\"\n :selection-mode=\"selectionMode\"\n :date=\"innerDate\"\n :parsed-value=\"parsedValue\"\n :disabled-date=\"disabledDate\"\n @pick=\"handleDatePick\"\n />\n <year-table\n v-if=\"currentView === 'year'\"\n :date=\"innerDate\"\n :disabled-date=\"disabledDate\"\n :parsed-value=\"parsedValue\"\n @pick=\"handleYearPick\"\n />\n <month-table\n v-if=\"currentView === 'month'\"\n :date=\"innerDate\"\n :parsed-value=\"parsedValue\"\n :disabled-date=\"disabledDate\"\n @pick=\"handleMonthPick\"\n />\n </div>\n </div>\n </div>\n <div\n v-show=\"footerVisible && currentView === 'date'\"\n class=\"el-picker-panel__footer\"\n >\n <el-button\n v-show=\"selectionMode !== 'dates'\"\n size=\"small\"\n type=\"text\"\n class=\"el-picker-panel__link-btn\"\n @click=\"changeToNow\"\n >\n {{ t('el.datepicker.now') }}\n </el-button>\n <el-button\n plain\n size=\"small\"\n class=\"el-picker-panel__link-btn\"\n @click=\"onConfirm\"\n >\n {{ t('el.datepicker.confirm') }}\n </el-button>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, inject, ref, watch } from 'vue'\nimport dayjs from 'dayjs'\nimport ElButton from '@element-plus/components/button'\nimport { ClickOutside } from '@element-plus/directives'\nimport { useLocale } from '@element-plus/hooks'\nimport ElInput from '@element-plus/components/input'\nimport {\n extractDateFormat,\n extractTimeFormat,\n TimePickPanel,\n} from '@element-plus/components/time-picker'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\nimport { isValidDatePickType } from '@element-plus/utils/validators'\nimport {\n DArrowLeft,\n ArrowLeft,\n DArrowRight,\n ArrowRight,\n} from '@element-plus/icons-vue'\nimport { TOOLTIP_INJECTION_KEY } from '@element-plus/components/tooltip'\nimport DateTable from './basic-date-table.vue'\nimport MonthTable from './basic-month-table.vue'\nimport YearTable from './basic-year-table.vue'\n\nimport type { PropType } from 'vue'\nimport type { ConfigType, Dayjs } from 'dayjs'\nimport type { IDatePickerType } from '../date-picker.type'\n\n// todo\n/* eslint-disable-next-line */\nconst timeWithinRange = (_: ConfigType, __: any, ___: string) => true\n\nexport default defineComponent({\n components: {\n DateTable,\n ElInput,\n ElButton,\n ElIcon,\n TimePickPanel,\n MonthTable,\n YearTable,\n DArrowLeft,\n ArrowLeft,\n DArrowRight,\n ArrowRight,\n },\n\n directives: { clickoutside: ClickOutside },\n props: {\n visible: {\n type: Boolean,\n default: false,\n },\n parsedValue: {\n type: [Object, Array] as PropType<Dayjs | Dayjs[]>,\n },\n format: {\n type: String,\n default: '',\n },\n type: {\n type: String as PropType<IDatePickerType>,\n required: true,\n validator: isValidDatePickType,\n },\n },\n emits: ['pick', 'set-picker-option'],\n setup(props, ctx) {\n const { t, lang } = useLocale()\n const pickerBase = inject('EP_PICKER_BASE') as any\n const popper = inject(TOOLTIP_INJECTION_KEY)\n const {\n shortcuts,\n disabledDate,\n cellClassName,\n defaultTime,\n defaultValue,\n arrowControl,\n } = pickerBase.props\n\n const innerDate = ref(dayjs().locale(lang.value))\n\n const defaultTimeD = computed(() => {\n return dayjs(defaultTime).locale(lang.value)\n })\n\n const month = computed(() => {\n return innerDate.value.month()\n })\n\n const year = computed(() => {\n return innerDate.value.year()\n })\n\n const selectableRange = ref([])\n const userInputDate = ref(null)\n const userInputTime = ref(null)\n // todo update to disableHour\n const checkDateWithinRange = (date: ConfigType) => {\n return selectableRange.value.length > 0\n ? timeWithinRange(\n date,\n selectableRange.value,\n props.format || 'HH:mm:ss'\n )\n : true\n }\n const formatEmit = (emitDayjs: Dayjs) => {\n if (defaultTime && !visibleTime.value) {\n return defaultTimeD.value\n .year(emitDayjs.year())\n .month(emitDayjs.month())\n .date(emitDayjs.date())\n }\n if (showTime.value) return emitDayjs.millisecond(0)\n return emitDayjs.startOf('day')\n }\n const emit = (value, ...args) => {\n if (!value) {\n ctx.emit('pick', value, ...args)\n } else if (Array.isArray(value)) {\n const dates = value.map(formatEmit)\n ctx.emit('pick', dates, ...args)\n } else {\n ctx.emit('pick', formatEmit(value), ...args)\n }\n userInputDate.value = null\n userInputTime.value = null\n }\n const handleDatePick = (value: Dayjs) => {\n if (selectionMode.value === 'day') {\n let newDate = props.parsedValue\n ? (props.parsedValue as Dayjs)\n .year(value.year())\n .month(value.month())\n .date(value.date())\n : value\n // change default time while out of selectableRange\n if (!checkDateWithinRange(newDate)) {\n newDate = (selectableRange.value[0][0] as Dayjs)\n .year(value.year())\n .month(value.month())\n .date(value.date())\n }\n innerDate.value = newDate\n emit(newDate, showTime.value)\n } else if (selectionMode.value === 'week') {\n emit(value.date)\n } else if (selectionMode.value === 'dates') {\n emit(value, true) // set false to keep panel open\n }\n }\n const prevMonth_ = () => {\n innerDate.value = innerDate.value.subtract(1, 'month')\n }\n\n const nextMonth_ = () => {\n innerDate.value = innerDate.value.add(1, 'month')\n }\n\n const prevYear_ = () => {\n if (currentView.value === 'year') {\n innerDate.value = innerDate.value.subtract(10, 'year')\n } else {\n innerDate.value = innerDate.value.subtract(1, 'year')\n }\n }\n\n const nextYear_ = () => {\n if (currentView.value === 'year') {\n innerDate.value = innerDate.value.add(10, 'year')\n } else {\n innerDate.value = innerDate.value.add(1, 'year')\n }\n }\n\n const currentView = ref('date')\n\n const yearLabel = computed(() => {\n const yearTranslation = t('el.datepicker.year')\n if (currentView.value === 'year') {\n const startYear = Math.floor(year.value / 10) * 10\n if (yearTranslation) {\n return `${startYear} ${yearTranslation} - ${\n startYear + 9\n } ${yearTranslation}`\n }\n return `${startYear} - ${startYear + 9}`\n }\n return `${year.value} ${yearTranslation}`\n })\n\n const handleShortcutClick = (shortcut) => {\n const shortcutValue =\n typeof shortcut.value === 'function' ? shortcut.value() : shortcut.value\n if (shortcutValue) {\n emit(dayjs(shortcutValue).locale(lang.value))\n return\n }\n if (shortcut.onClick) {\n shortcut.onClick(ctx)\n }\n }\n\n const selectionMode = computed(() => {\n if (['week', 'month', 'year', 'dates'].includes(props.type)) {\n return props.type\n }\n return 'day'\n })\n\n watch(\n () => selectionMode.value,\n (val) => {\n if (['month', 'year'].includes(val)) {\n currentView.value = val\n return\n }\n currentView.value = 'date'\n },\n { immediate: true }\n )\n\n watch(\n () => currentView.value,\n () => {\n popper?.updatePopper()\n }\n )\n\n const hasShortcuts = computed(() => !!shortcuts.length)\n\n const handleMonthPick = (month) => {\n innerDate.value = innerDate.value.startOf('month').month(month)\n if (selectionMode.value === 'month') {\n emit(innerDate.value)\n } else {\n currentView.value = 'date'\n }\n }\n\n const handleYearPick = (year) => {\n if (selectionMode.value === 'year') {\n innerDate.value = innerDate.value.startOf('year').year(year)\n emit(innerDate.value)\n } else {\n innerDate.value = innerDate.value.year(year)\n currentView.value = 'month'\n }\n }\n\n const showMonthPicker = () => {\n currentView.value = 'month'\n }\n\n const showYearPicker = () => {\n currentView.value = 'year'\n }\n\n const showTime = computed(\n () => props.type === 'datetime' || props.type === 'datetimerange'\n )\n\n const footerVisible = computed(() => {\n return showTime.value || selectionMode.value === 'dates'\n })\n\n const onConfirm = () => {\n if (selectionMode.value === 'dates') {\n emit(props.parsedValue)\n } else {\n // deal with the scenario where: user opens the date time picker, then confirm without doing anything\n let result = props.parsedValue as Dayjs\n if (!result) {\n const defaultTimeD = dayjs(defaultTime).locale(lang.value)\n const defaultValueD = getDefaultValue()\n result = defaultTimeD\n .year(defaultValueD.year())\n .month(defaultValueD.month())\n .date(defaultValueD.date())\n }\n innerDate.value = result\n emit(result)\n }\n }\n\n const changeToNow = () => {\n // NOTE: not a permanent solution\n // consider disable \"now\" button in the future\n const now = dayjs().locale(lang.value)\n const nowDate = now.toDate()\n if (\n (!disabledDate || !disabledDate(nowDate)) &&\n checkDateWithinRange(nowDate)\n ) {\n innerDate.value = dayjs().locale(lang.value)\n emit(innerDate.value)\n }\n }\n\n const timeFormat = computed(() => {\n return extractTimeFormat(props.format)\n })\n\n const dateFormat = computed(() => {\n return extractDateFormat(props.format)\n })\n\n const visibleTime = computed(() => {\n if (userInputTime.value) return userInputTime.value\n if (!props.parsedValue && !defaultValue) return\n return ((props.parsedValue || innerDate.value) as Dayjs).format(\n timeFormat.value\n )\n })\n\n const visibleDate = computed(() => {\n if (userInputDate.value) return userInputDate.value\n if (!props.parsedValue && !defaultValue) return\n return ((props.parsedValue || innerDate.value) as Dayjs).format(\n dateFormat.value\n )\n })\n\n const timePickerVisible = ref(false)\n const onTimePickerInputFocus = () => {\n timePickerVisible.value = true\n }\n const handleTimePickClose = () => {\n timePickerVisible.value = false\n }\n\n const handleTimePick = (value, visible, first) => {\n const newDate = props.parsedValue\n ? (props.parsedValue as Dayjs)\n .hour(value.hour())\n .minute(value.minute())\n .second(value.second())\n : value\n innerDate.value = newDate\n emit(innerDate.value, true)\n if (!first) {\n timePickerVisible.value = visible\n }\n }\n\n const handleVisibleTimeChange = (value) => {\n const newDate = dayjs(value, timeFormat.value).locale(lang.value)\n if (newDate.isValid() && checkDateWithinRange(newDate)) {\n innerDate.value = newDate\n .year(innerDate.value.year())\n .month(innerDate.value.month())\n .date(innerDate.value.date())\n userInputTime.value = null\n timePickerVisible.value = false\n emit(innerDate.value, true)\n }\n }\n\n const handleVisibleDateChange = (value) => {\n const newDate = dayjs(value, dateFormat.value).locale(lang.value)\n if (newDate.isValid()) {\n if (disabledDate && disabledDate(newDate.toDate())) {\n return\n }\n innerDate.value = newDate\n .hour(innerDate.value.hour())\n .minute(innerDate.value.minute())\n .second(innerDate.value.second())\n userInputDate.value = null\n emit(innerDate.value, true)\n }\n }\n\n const isValidValue = (date: unknown) => {\n return (\n dayjs.isDayjs(date) &&\n date.isValid() &&\n (disabledDate ? !disabledDate(date.toDate()) : true)\n )\n }\n\n const formatToString = (value) => {\n if (selectionMode.value === 'dates') {\n return value.map((_) => _.format(props.format))\n }\n return value.format(props.format)\n }\n\n const parseUserInput = (value) => {\n return dayjs(value, props.format).locale(lang.value)\n }\n\n const getDefaultValue = () => {\n const parseDate = dayjs(defaultValue).locale(lang.value)\n if (!defaultValue) {\n const defaultTimeDValue = defaultTimeD.value\n return dayjs()\n .hour(defaultTimeDValue.hour())\n .minute(defaultTimeDValue.minute())\n .second(defaultTimeDValue.second())\n .locale(lang.value)\n }\n return parseDate\n }\n\n const handleKeydown = (event) => {\n const { code, keyCode } = event\n const list = [\n EVENT_CODE.up,\n EVENT_CODE.down,\n EVENT_CODE.left,\n EVENT_CODE.right,\n ]\n if (props.visible && !timePickerVisible.value) {\n if (list.includes(code)) {\n handleKeyControl(keyCode)\n event.stopPropagation()\n event.preventDefault()\n }\n if (\n code === EVENT_CODE.enter &&\n userInputDate.value === null &&\n userInputTime.value === null\n ) {\n // Enter\n emit(innerDate, false)\n }\n }\n }\n\n const handleKeyControl = (keyCode) => {\n const mapping = {\n year: {\n 38: -4,\n 40: 4,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setFullYear(date.getFullYear() + step),\n },\n month: {\n 38: -4,\n 40: 4,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setMonth(date.getMonth() + step),\n },\n week: {\n 38: -1,\n 40: 1,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setDate(date.getDate() + step * 7),\n },\n day: {\n 38: -7,\n 40: 7,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setDate(date.getDate() + step),\n },\n }\n\n const newDate = innerDate.value.toDate()\n while (Math.abs(innerDate.value.diff(newDate, 'year', true)) < 1) {\n const map = mapping[selectionMode.value]\n map.offset(newDate, map[keyCode])\n if (disabledDate && disabledDate(newDate)) {\n continue\n }\n const result = dayjs(newDate).locale(lang.value)\n innerDate.value = result\n ctx.emit('pick', result, true)\n break\n }\n }\n\n ctx.emit('set-picker-option', ['isValidValue', isValidValue])\n ctx.emit('set-picker-option', ['formatToString', formatToString])\n ctx.emit('set-picker-option', ['parseUserInput', parseUserInput])\n ctx.emit('set-picker-option', ['handleKeydown', handleKeydown])\n\n watch(\n () => props.parsedValue,\n (val) => {\n if (val) {\n if (selectionMode.value === 'dates') return\n if (Array.isArray(val)) return\n innerDate.value = val\n } else {\n innerDate.value = getDefaultValue()\n }\n },\n { immediate: true }\n )\n\n return {\n handleTimePick,\n handleTimePickClose,\n onTimePickerInputFocus,\n timePickerVisible,\n visibleTime,\n visibleDate,\n showTime,\n changeToNow,\n onConfirm,\n footerVisible,\n handleYearPick,\n showMonthPicker,\n showYearPicker,\n handleMonthPick,\n hasShortcuts,\n shortcuts,\n arrowControl,\n disabledDate,\n cellClassName,\n selectionMode,\n handleShortcutClick,\n prevYear_,\n nextYear_,\n prevMonth_,\n nextMonth_,\n innerDate,\n t,\n yearLabel,\n currentView,\n month,\n handleDatePick,\n handleVisibleTimeChange,\n handleVisibleDateChange,\n timeFormat,\n userInputTime,\n userInputDate,\n }\n },\n})\n</script>\n"],"names":["DateTable","ElInput","ElIcon","TimePickPanel","MonthTable","DArrowLeft","ArrowLeft","DArrowRight","ArrowRight","isValidDatePickType","dayjs","computed","ref","watch","EVENT_CODE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2LA,wBAAwB,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,IAAI,CAAC;;AAE7C,EAAE,UAAU,EAAE;AACd,eAAIA;AACJ,aAAIC;;AAEJ,YAAIC;AACJ,mBAAIC,iDAAa;AACjB,gBAAIC,mDAAU;;AAEd,gBAAIC;eACAC;iBACAC;gBACAC;;;OAGG,EAAE;IACL,OAAO,EAAE;MACP,IAAI,EAAE;MACN,OAAO;KACR;IACD,WAAW;MACT,IAAI,EAAE,CAAC;;;MAGP,IAAI,EAAE,MAAM;MACZ;KACD;QACG,EAAE;MACJ,IAAI,EAAE,MAAM;;MAEZ,SAAS,EAAEC;;;OAGV,EAAE,CAAC;OACH,CAAC,KAAK,EAAE,GAAG;UACR,EAAE,CAAC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I,EAAE,IAAI,KAAK,IAAI,CAAC;;;;UAI7B,EAAE,EAAE,CAAC;UACL,EAAE,EAAE,CAAC,CAAC;UACN,EAAE,EAAE,CAAC;UACL,MAAM,EAAE,CAAC,UAAU;;;YAGjB,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC;aACzB,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;QACxB,MAAM,GAAG,GAAG,OAAO,CAAC;QACpB,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC;;;;QAIxB,MAAM,MAAM,GAAGJ,yBAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;QACrC,SAAS,CAAC,KAAK,GAAG,MAAM,CAAC;WACtB,CAAC,IAAI,CAAC,MAAM,EAAE;QACjB,MAAM;;;QAGN,IAAI,CAAC,mBAAmB;YACpB,CAAC,mBAAmB,EAAE,CAAC;YACvB,CAAC,mBAAmB,EAAE,CAAC;YACvB,CAAC,mBAAmB,EAAE,CAAC;aAC1B,CAAC,MAAM,KAAK,CAAC,WAAW;UACvB,GAAG,EAAE;;;;UAIL,OAAO;QACT;aACK;QACL,SAAS,CAAC,KAAK;;;IAGnB;;MAEE,mBAAmB;MACnB,sBAAsB;uBACL;MACjB;MACA,WAAW;;;MAGX,SAAS;MACT,aAAa;;;MAGb,cAAc;MACd;MACA,YAAY;eACH;kBACG;kBACA;mBACC;mBACA;yBACM;MACnB;MACA,SAAS;;;MAGT,SAAS;MACT,CAAC;MACD,SAAS;iBACE;WACN;oBACS;;MAEd;MACA,UAAU;mBACG;mBACA;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel-date-pick.vue_vue_type_template_id_78e07aa7_lang.js","sources":["../../../../../../../packages/components/date-picker/src/date-picker-com/panel-date-pick.vue?vue&type=template&id=78e07aa7&lang.js"],"sourcesContent":["<template>\n <div\n class=\"el-picker-panel el-date-picker\"\n :class=\"[\n {\n 'has-sidebar': $slots.sidebar || hasShortcuts,\n 'has-time': showTime,\n },\n ]\"\n >\n <div class=\"el-picker-panel__body-wrapper\">\n <slot name=\"sidebar\" class=\"el-picker-panel__sidebar\"></slot>\n <div v-if=\"hasShortcuts\" class=\"el-picker-panel__sidebar\">\n <button\n v-for=\"(shortcut, key) in shortcuts\"\n :key=\"key\"\n type=\"button\"\n class=\"el-picker-panel__shortcut\"\n @click=\"handleShortcutClick(shortcut)\"\n >\n {{ shortcut.text }}\n </button>\n </div>\n <div class=\"el-picker-panel__body\">\n <div v-if=\"showTime\" class=\"el-date-picker__time-header\">\n <span class=\"el-date-picker__editor-wrap\">\n <el-input\n :placeholder=\"t('el.datepicker.selectDate')\"\n :model-value=\"visibleDate\"\n size=\"small\"\n @input=\"(val) => (userInputDate = val)\"\n @change=\"handleVisibleDateChange\"\n />\n </span>\n <span\n v-clickoutside=\"handleTimePickClose\"\n class=\"el-date-picker__editor-wrap\"\n >\n <el-input\n :placeholder=\"t('el.datepicker.selectTime')\"\n :model-value=\"visibleTime\"\n size=\"small\"\n @focus=\"onTimePickerInputFocus\"\n @input=\"(val) => (userInputTime = val)\"\n @change=\"handleVisibleTimeChange\"\n />\n <time-pick-panel\n :visible=\"timePickerVisible\"\n :format=\"timeFormat\"\n :time-arrow-control=\"arrowControl\"\n :parsed-value=\"innerDate\"\n @pick=\"handleTimePick\"\n />\n </span>\n </div>\n <div\n v-show=\"currentView !== 'time'\"\n class=\"el-date-picker__header\"\n :class=\"{\n 'el-date-picker__header--bordered':\n currentView === 'year' || currentView === 'month',\n }\"\n >\n <button\n type=\"button\"\n :aria-label=\"t(`el.datepicker.prevYear`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__prev-btn d-arrow-left\"\n @click=\"prevYear_\"\n >\n <el-icon><d-arrow-left /></el-icon>\n </button>\n <button\n v-show=\"currentView === 'date'\"\n type=\"button\"\n :aria-label=\"t(`el.datepicker.prevMonth`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__prev-btn arrow-left\"\n @click=\"prevMonth_\"\n >\n <el-icon><arrow-left /></el-icon>\n </button>\n <span\n role=\"button\"\n class=\"el-date-picker__header-label\"\n @click=\"showYearPicker\"\n >{{ yearLabel }}</span\n >\n <span\n v-show=\"currentView === 'date'\"\n role=\"button\"\n class=\"el-date-picker__header-label\"\n :class=\"{ active: currentView === 'month' }\"\n @click=\"showMonthPicker\"\n >{{ t(`el.datepicker.month${month + 1}`) }}</span\n >\n <button\n type=\"button\"\n :aria-label=\"t(`el.datepicker.nextYear`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__next-btn d-arrow-right\"\n @click=\"nextYear_\"\n >\n <el-icon><d-arrow-right /></el-icon>\n </button>\n <button\n v-show=\"currentView === 'date'\"\n type=\"button\"\n :aria-label=\"t(`el.datepicker.nextMonth`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__next-btn arrow-right\"\n @click=\"nextMonth_\"\n >\n <el-icon><arrow-right /></el-icon>\n </button>\n </div>\n <div class=\"el-picker-panel__content\">\n <date-table\n v-if=\"currentView === 'date'\"\n :selection-mode=\"selectionMode\"\n :date=\"innerDate\"\n :parsed-value=\"parsedValue\"\n :disabled-date=\"disabledDate\"\n @pick=\"handleDatePick\"\n />\n <year-table\n v-if=\"currentView === 'year'\"\n :date=\"innerDate\"\n :disabled-date=\"disabledDate\"\n :parsed-value=\"parsedValue\"\n @pick=\"handleYearPick\"\n />\n <month-table\n v-if=\"currentView === 'month'\"\n :date=\"innerDate\"\n :parsed-value=\"parsedValue\"\n :disabled-date=\"disabledDate\"\n @pick=\"handleMonthPick\"\n />\n </div>\n </div>\n </div>\n <div\n v-show=\"footerVisible && currentView === 'date'\"\n class=\"el-picker-panel__footer\"\n >\n <el-button\n v-show=\"selectionMode !== 'dates'\"\n size=\"small\"\n type=\"text\"\n class=\"el-picker-panel__link-btn\"\n @click=\"changeToNow\"\n >\n {{ t('el.datepicker.now') }}\n </el-button>\n <el-button\n plain\n size=\"small\"\n class=\"el-picker-panel__link-btn\"\n @click=\"onConfirm\"\n >\n {{ t('el.datepicker.confirm') }}\n </el-button>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, inject, ref, watch } from 'vue'\nimport dayjs from 'dayjs'\nimport ElButton from '@element-plus/components/button'\nimport { ClickOutside } from '@element-plus/directives'\nimport { useLocale } from '@element-plus/hooks'\nimport ElInput from '@element-plus/components/input'\nimport {\n extractDateFormat,\n extractTimeFormat,\n TimePickPanel,\n} from '@element-plus/components/time-picker'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\nimport { isValidDatePickType } from '@element-plus/utils/validators'\nimport {\n DArrowLeft,\n ArrowLeft,\n DArrowRight,\n ArrowRight,\n} from '@element-plus/icons-vue'\nimport DateTable from './basic-date-table.vue'\nimport MonthTable from './basic-month-table.vue'\nimport YearTable from './basic-year-table.vue'\n\nimport type { PropType } from 'vue'\nimport type { ConfigType, Dayjs } from 'dayjs'\nimport type { IDatePickerType } from '../date-picker.type'\n\n// todo\n/* eslint-disable-next-line */\nconst timeWithinRange = (_: ConfigType, __: any, ___: string) => true\n\nexport default defineComponent({\n components: {\n DateTable,\n ElInput,\n ElButton,\n ElIcon,\n TimePickPanel,\n MonthTable,\n YearTable,\n DArrowLeft,\n ArrowLeft,\n DArrowRight,\n ArrowRight,\n },\n\n directives: { clickoutside: ClickOutside },\n props: {\n visible: {\n type: Boolean,\n default: false,\n },\n parsedValue: {\n type: [Object, Array] as PropType<Dayjs | Dayjs[]>,\n },\n format: {\n type: String,\n default: '',\n },\n type: {\n type: String as PropType<IDatePickerType>,\n required: true,\n validator: isValidDatePickType,\n },\n },\n emits: ['pick', 'set-picker-option'],\n setup(props, ctx) {\n const { t, lang } = useLocale()\n const pickerBase = inject('EP_PICKER_BASE') as any\n\n const {\n shortcuts,\n disabledDate,\n cellClassName,\n defaultTime,\n defaultValue,\n arrowControl,\n } = pickerBase.props\n\n const innerDate = ref(dayjs().locale(lang.value))\n\n const defaultTimeD = computed(() => {\n return dayjs(defaultTime).locale(lang.value)\n })\n\n const month = computed(() => {\n return innerDate.value.month()\n })\n\n const year = computed(() => {\n return innerDate.value.year()\n })\n\n const selectableRange = ref([])\n const userInputDate = ref(null)\n const userInputTime = ref(null)\n // todo update to disableHour\n const checkDateWithinRange = (date: ConfigType) => {\n return selectableRange.value.length > 0\n ? timeWithinRange(\n date,\n selectableRange.value,\n props.format || 'HH:mm:ss'\n )\n : true\n }\n const formatEmit = (emitDayjs: Dayjs) => {\n if (defaultTime && !visibleTime.value) {\n return defaultTimeD.value\n .year(emitDayjs.year())\n .month(emitDayjs.month())\n .date(emitDayjs.date())\n }\n if (showTime.value) return emitDayjs.millisecond(0)\n return emitDayjs.startOf('day')\n }\n const emit = (value, ...args) => {\n if (!value) {\n ctx.emit('pick', value, ...args)\n } else if (Array.isArray(value)) {\n const dates = value.map(formatEmit)\n ctx.emit('pick', dates, ...args)\n } else {\n ctx.emit('pick', formatEmit(value), ...args)\n }\n userInputDate.value = null\n userInputTime.value = null\n }\n const handleDatePick = (value: Dayjs) => {\n if (selectionMode.value === 'day') {\n let newDate = props.parsedValue\n ? (props.parsedValue as Dayjs)\n .year(value.year())\n .month(value.month())\n .date(value.date())\n : value\n // change default time while out of selectableRange\n if (!checkDateWithinRange(newDate)) {\n newDate = (selectableRange.value[0][0] as Dayjs)\n .year(value.year())\n .month(value.month())\n .date(value.date())\n }\n innerDate.value = newDate\n emit(newDate, showTime.value)\n } else if (selectionMode.value === 'week') {\n emit(value.date)\n } else if (selectionMode.value === 'dates') {\n emit(value, true) // set false to keep panel open\n }\n }\n const prevMonth_ = () => {\n innerDate.value = innerDate.value.subtract(1, 'month')\n }\n\n const nextMonth_ = () => {\n innerDate.value = innerDate.value.add(1, 'month')\n }\n\n const prevYear_ = () => {\n if (currentView.value === 'year') {\n innerDate.value = innerDate.value.subtract(10, 'year')\n } else {\n innerDate.value = innerDate.value.subtract(1, 'year')\n }\n }\n\n const nextYear_ = () => {\n if (currentView.value === 'year') {\n innerDate.value = innerDate.value.add(10, 'year')\n } else {\n innerDate.value = innerDate.value.add(1, 'year')\n }\n }\n\n const currentView = ref('date')\n\n const yearLabel = computed(() => {\n const yearTranslation = t('el.datepicker.year')\n if (currentView.value === 'year') {\n const startYear = Math.floor(year.value / 10) * 10\n if (yearTranslation) {\n return `${startYear} ${yearTranslation} - ${\n startYear + 9\n } ${yearTranslation}`\n }\n return `${startYear} - ${startYear + 9}`\n }\n return `${year.value} ${yearTranslation}`\n })\n\n const handleShortcutClick = (shortcut) => {\n const shortcutValue =\n typeof shortcut.value === 'function' ? shortcut.value() : shortcut.value\n if (shortcutValue) {\n emit(dayjs(shortcutValue).locale(lang.value))\n return\n }\n if (shortcut.onClick) {\n shortcut.onClick(ctx)\n }\n }\n\n const selectionMode = computed(() => {\n if (['week', 'month', 'year', 'dates'].includes(props.type)) {\n return props.type\n }\n return 'day'\n })\n\n watch(\n () => selectionMode.value,\n (val) => {\n if (['month', 'year'].includes(val)) {\n currentView.value = val\n return\n }\n currentView.value = 'date'\n },\n { immediate: true }\n )\n\n const hasShortcuts = computed(() => !!shortcuts.length)\n\n const handleMonthPick = (month) => {\n innerDate.value = innerDate.value.startOf('month').month(month)\n if (selectionMode.value === 'month') {\n emit(innerDate.value)\n } else {\n currentView.value = 'date'\n }\n }\n\n const handleYearPick = (year) => {\n if (selectionMode.value === 'year') {\n innerDate.value = innerDate.value.startOf('year').year(year)\n emit(innerDate.value)\n } else {\n innerDate.value = innerDate.value.year(year)\n currentView.value = 'month'\n }\n }\n\n const showMonthPicker = () => {\n currentView.value = 'month'\n }\n\n const showYearPicker = () => {\n currentView.value = 'year'\n }\n\n const showTime = computed(\n () => props.type === 'datetime' || props.type === 'datetimerange'\n )\n\n const footerVisible = computed(() => {\n return showTime.value || selectionMode.value === 'dates'\n })\n\n const onConfirm = () => {\n if (selectionMode.value === 'dates') {\n emit(props.parsedValue)\n } else {\n // deal with the scenario where: user opens the date time picker, then confirm without doing anything\n let result = props.parsedValue as Dayjs\n if (!result) {\n const defaultTimeD = dayjs(defaultTime).locale(lang.value)\n const defaultValueD = getDefaultValue()\n result = defaultTimeD\n .year(defaultValueD.year())\n .month(defaultValueD.month())\n .date(defaultValueD.date())\n }\n innerDate.value = result\n emit(result)\n }\n }\n\n const changeToNow = () => {\n // NOTE: not a permanent solution\n // consider disable \"now\" button in the future\n const now = dayjs().locale(lang.value)\n const nowDate = now.toDate()\n if (\n (!disabledDate || !disabledDate(nowDate)) &&\n checkDateWithinRange(nowDate)\n ) {\n innerDate.value = dayjs().locale(lang.value)\n emit(innerDate.value)\n }\n }\n\n const timeFormat = computed(() => {\n return extractTimeFormat(props.format)\n })\n\n const dateFormat = computed(() => {\n return extractDateFormat(props.format)\n })\n\n const visibleTime = computed(() => {\n if (userInputTime.value) return userInputTime.value\n if (!props.parsedValue && !defaultValue) return\n return ((props.parsedValue || innerDate.value) as Dayjs).format(\n timeFormat.value\n )\n })\n\n const visibleDate = computed(() => {\n if (userInputDate.value) return userInputDate.value\n if (!props.parsedValue && !defaultValue) return\n return ((props.parsedValue || innerDate.value) as Dayjs).format(\n dateFormat.value\n )\n })\n\n const timePickerVisible = ref(false)\n const onTimePickerInputFocus = () => {\n timePickerVisible.value = true\n }\n const handleTimePickClose = () => {\n timePickerVisible.value = false\n }\n\n const handleTimePick = (value, visible, first) => {\n const newDate = props.parsedValue\n ? (props.parsedValue as Dayjs)\n .hour(value.hour())\n .minute(value.minute())\n .second(value.second())\n : value\n innerDate.value = newDate\n emit(innerDate.value, true)\n if (!first) {\n timePickerVisible.value = visible\n }\n }\n\n const handleVisibleTimeChange = (value) => {\n const newDate = dayjs(value, timeFormat.value).locale(lang.value)\n if (newDate.isValid() && checkDateWithinRange(newDate)) {\n innerDate.value = newDate\n .year(innerDate.value.year())\n .month(innerDate.value.month())\n .date(innerDate.value.date())\n userInputTime.value = null\n timePickerVisible.value = false\n emit(innerDate.value, true)\n }\n }\n\n const handleVisibleDateChange = (value) => {\n const newDate = dayjs(value, dateFormat.value).locale(lang.value)\n if (newDate.isValid()) {\n if (disabledDate && disabledDate(newDate.toDate())) {\n return\n }\n innerDate.value = newDate\n .hour(innerDate.value.hour())\n .minute(innerDate.value.minute())\n .second(innerDate.value.second())\n userInputDate.value = null\n emit(innerDate.value, true)\n }\n }\n\n const isValidValue = (date: unknown) => {\n return (\n dayjs.isDayjs(date) &&\n date.isValid() &&\n (disabledDate ? !disabledDate(date.toDate()) : true)\n )\n }\n\n const formatToString = (value) => {\n if (selectionMode.value === 'dates') {\n return value.map((_) => _.format(props.format))\n }\n return value.format(props.format)\n }\n\n const parseUserInput = (value) => {\n return dayjs(value, props.format).locale(lang.value)\n }\n\n const getDefaultValue = () => {\n const parseDate = dayjs(defaultValue).locale(lang.value)\n if (!defaultValue) {\n const defaultTimeDValue = defaultTimeD.value\n return dayjs()\n .hour(defaultTimeDValue.hour())\n .minute(defaultTimeDValue.minute())\n .second(defaultTimeDValue.second())\n .locale(lang.value)\n }\n return parseDate\n }\n\n const handleKeydown = (event) => {\n const { code, keyCode } = event\n const list = [\n EVENT_CODE.up,\n EVENT_CODE.down,\n EVENT_CODE.left,\n EVENT_CODE.right,\n ]\n if (props.visible && !timePickerVisible.value) {\n if (list.includes(code)) {\n handleKeyControl(keyCode)\n event.stopPropagation()\n event.preventDefault()\n }\n if (\n code === EVENT_CODE.enter &&\n userInputDate.value === null &&\n userInputTime.value === null\n ) {\n // Enter\n emit(innerDate, false)\n }\n }\n }\n\n const handleKeyControl = (keyCode) => {\n const mapping = {\n year: {\n 38: -4,\n 40: 4,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setFullYear(date.getFullYear() + step),\n },\n month: {\n 38: -4,\n 40: 4,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setMonth(date.getMonth() + step),\n },\n week: {\n 38: -1,\n 40: 1,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setDate(date.getDate() + step * 7),\n },\n day: {\n 38: -7,\n 40: 7,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setDate(date.getDate() + step),\n },\n }\n\n const newDate = innerDate.value.toDate()\n while (Math.abs(innerDate.value.diff(newDate, 'year', true)) < 1) {\n const map = mapping[selectionMode.value]\n map.offset(newDate, map[keyCode])\n if (disabledDate && disabledDate(newDate)) {\n continue\n }\n const result = dayjs(newDate).locale(lang.value)\n innerDate.value = result\n ctx.emit('pick', result, true)\n break\n }\n }\n\n ctx.emit('set-picker-option', ['isValidValue', isValidValue])\n ctx.emit('set-picker-option', ['formatToString', formatToString])\n ctx.emit('set-picker-option', ['parseUserInput', parseUserInput])\n ctx.emit('set-picker-option', ['handleKeydown', handleKeydown])\n\n watch(\n () => props.parsedValue,\n (val) => {\n if (val) {\n if (selectionMode.value === 'dates') return\n if (Array.isArray(val)) return\n innerDate.value = val\n } else {\n innerDate.value = getDefaultValue()\n }\n },\n { immediate: true }\n )\n\n return {\n handleTimePick,\n handleTimePickClose,\n onTimePickerInputFocus,\n timePickerVisible,\n visibleTime,\n visibleDate,\n showTime,\n changeToNow,\n onConfirm,\n footerVisible,\n handleYearPick,\n showMonthPicker,\n showYearPicker,\n handleMonthPick,\n hasShortcuts,\n shortcuts,\n arrowControl,\n disabledDate,\n cellClassName,\n selectionMode,\n handleShortcutClick,\n prevYear_,\n nextYear_,\n prevMonth_,\n nextMonth_,\n innerDate,\n t,\n yearLabel,\n currentView,\n month,\n handleDatePick,\n handleVisibleTimeChange,\n handleVisibleDateChange,\n timeFormat,\n userInputTime,\n userInputDate,\n }\n },\n})\n</script>\n"],"names":["_createElementVNode"],"mappings":";;;;;;;;;;EAY+B;;;;;;EAYF;;qBACb,KAAK,EAAC,6BAA6B;;;;;;sBAuFtC,KAAK,EAAC;eA4Bb,KAAK,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;yDAjIqB;;;;;;gBAKvB;;;;;;;iCAOJ;;;cAEI;;;;2BAIS;yBACC;;;;6CAIV;;;;;2BAQY;;4BAEC;;;;;;qCAMM;2BACVA;;;;;;;wBAIX;;;;;;;gBASQ;;;;;YAKJ;gCAAS,CAAgB;;;;;;;gBAIrB;;;;;YAKJ;;gBAAS;;;;;;;;;YAIT,UAAM;YACL;iCACG;0BAEN;YAEE;YACA,KAAK;YAEJ,OAAK;;;;;gBAIF;;;;;YAKJ;gCAAS,CAAiB;;;;;;;gBAItB;;;;;YAKJ;;;;;;;;;;;;;;;;kCAMiB;;;+BAGH;;;;;6BAGhB;;oBAEO,EAAE;;;;;;;;;sBAOA;;;kDAGe;;;;;;;;QAW1B,IAAI,EAAC;QACL;QACA,OAAM;;;6BAGN;;;;;;;MAEF;;;;;"}
|
|
1
|
+
{"version":3,"file":"panel-date-pick.vue_vue_type_template_id_78e07aa7_lang.js","sources":["../../../../../../../packages/components/date-picker/src/date-picker-com/panel-date-pick.vue?vue&type=template&id=78e07aa7&lang.js"],"sourcesContent":["<template>\n <div\n class=\"el-picker-panel el-date-picker\"\n :class=\"[\n {\n 'has-sidebar': $slots.sidebar || hasShortcuts,\n 'has-time': showTime,\n },\n ]\"\n >\n <div class=\"el-picker-panel__body-wrapper\">\n <slot name=\"sidebar\" class=\"el-picker-panel__sidebar\"></slot>\n <div v-if=\"hasShortcuts\" class=\"el-picker-panel__sidebar\">\n <button\n v-for=\"(shortcut, key) in shortcuts\"\n :key=\"key\"\n type=\"button\"\n class=\"el-picker-panel__shortcut\"\n @click=\"handleShortcutClick(shortcut)\"\n >\n {{ shortcut.text }}\n </button>\n </div>\n <div class=\"el-picker-panel__body\">\n <div v-if=\"showTime\" class=\"el-date-picker__time-header\">\n <span class=\"el-date-picker__editor-wrap\">\n <el-input\n :placeholder=\"t('el.datepicker.selectDate')\"\n :model-value=\"visibleDate\"\n size=\"small\"\n @input=\"(val) => (userInputDate = val)\"\n @change=\"handleVisibleDateChange\"\n />\n </span>\n <span\n v-clickoutside=\"handleTimePickClose\"\n class=\"el-date-picker__editor-wrap\"\n >\n <el-input\n :placeholder=\"t('el.datepicker.selectTime')\"\n :model-value=\"visibleTime\"\n size=\"small\"\n @focus=\"onTimePickerInputFocus\"\n @input=\"(val) => (userInputTime = val)\"\n @change=\"handleVisibleTimeChange\"\n />\n <time-pick-panel\n :visible=\"timePickerVisible\"\n :format=\"timeFormat\"\n :time-arrow-control=\"arrowControl\"\n :parsed-value=\"innerDate\"\n @pick=\"handleTimePick\"\n />\n </span>\n </div>\n <div\n v-show=\"currentView !== 'time'\"\n class=\"el-date-picker__header\"\n :class=\"{\n 'el-date-picker__header--bordered':\n currentView === 'year' || currentView === 'month',\n }\"\n >\n <button\n type=\"button\"\n :aria-label=\"t(`el.datepicker.prevYear`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__prev-btn d-arrow-left\"\n @click=\"prevYear_\"\n >\n <el-icon><d-arrow-left /></el-icon>\n </button>\n <button\n v-show=\"currentView === 'date'\"\n type=\"button\"\n :aria-label=\"t(`el.datepicker.prevMonth`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__prev-btn arrow-left\"\n @click=\"prevMonth_\"\n >\n <el-icon><arrow-left /></el-icon>\n </button>\n <span\n role=\"button\"\n class=\"el-date-picker__header-label\"\n @click=\"showYearPicker\"\n >{{ yearLabel }}</span\n >\n <span\n v-show=\"currentView === 'date'\"\n role=\"button\"\n class=\"el-date-picker__header-label\"\n :class=\"{ active: currentView === 'month' }\"\n @click=\"showMonthPicker\"\n >{{ t(`el.datepicker.month${month + 1}`) }}</span\n >\n <button\n type=\"button\"\n :aria-label=\"t(`el.datepicker.nextYear`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__next-btn d-arrow-right\"\n @click=\"nextYear_\"\n >\n <el-icon><d-arrow-right /></el-icon>\n </button>\n <button\n v-show=\"currentView === 'date'\"\n type=\"button\"\n :aria-label=\"t(`el.datepicker.nextMonth`)\"\n class=\"el-picker-panel__icon-btn el-date-picker__next-btn arrow-right\"\n @click=\"nextMonth_\"\n >\n <el-icon><arrow-right /></el-icon>\n </button>\n </div>\n <div class=\"el-picker-panel__content\">\n <date-table\n v-if=\"currentView === 'date'\"\n :selection-mode=\"selectionMode\"\n :date=\"innerDate\"\n :parsed-value=\"parsedValue\"\n :disabled-date=\"disabledDate\"\n @pick=\"handleDatePick\"\n />\n <year-table\n v-if=\"currentView === 'year'\"\n :date=\"innerDate\"\n :disabled-date=\"disabledDate\"\n :parsed-value=\"parsedValue\"\n @pick=\"handleYearPick\"\n />\n <month-table\n v-if=\"currentView === 'month'\"\n :date=\"innerDate\"\n :parsed-value=\"parsedValue\"\n :disabled-date=\"disabledDate\"\n @pick=\"handleMonthPick\"\n />\n </div>\n </div>\n </div>\n <div\n v-show=\"footerVisible && currentView === 'date'\"\n class=\"el-picker-panel__footer\"\n >\n <el-button\n v-show=\"selectionMode !== 'dates'\"\n size=\"small\"\n type=\"text\"\n class=\"el-picker-panel__link-btn\"\n @click=\"changeToNow\"\n >\n {{ t('el.datepicker.now') }}\n </el-button>\n <el-button\n plain\n size=\"small\"\n class=\"el-picker-panel__link-btn\"\n @click=\"onConfirm\"\n >\n {{ t('el.datepicker.confirm') }}\n </el-button>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, inject, ref, watch } from 'vue'\nimport dayjs from 'dayjs'\nimport ElButton from '@element-plus/components/button'\nimport { ClickOutside } from '@element-plus/directives'\nimport { useLocale } from '@element-plus/hooks'\nimport ElInput from '@element-plus/components/input'\nimport {\n extractDateFormat,\n extractTimeFormat,\n TimePickPanel,\n} from '@element-plus/components/time-picker'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\nimport { isValidDatePickType } from '@element-plus/utils/validators'\nimport {\n DArrowLeft,\n ArrowLeft,\n DArrowRight,\n ArrowRight,\n} from '@element-plus/icons-vue'\nimport { TOOLTIP_INJECTION_KEY } from '@element-plus/components/tooltip'\nimport DateTable from './basic-date-table.vue'\nimport MonthTable from './basic-month-table.vue'\nimport YearTable from './basic-year-table.vue'\n\nimport type { PropType } from 'vue'\nimport type { ConfigType, Dayjs } from 'dayjs'\nimport type { IDatePickerType } from '../date-picker.type'\n\n// todo\n/* eslint-disable-next-line */\nconst timeWithinRange = (_: ConfigType, __: any, ___: string) => true\n\nexport default defineComponent({\n components: {\n DateTable,\n ElInput,\n ElButton,\n ElIcon,\n TimePickPanel,\n MonthTable,\n YearTable,\n DArrowLeft,\n ArrowLeft,\n DArrowRight,\n ArrowRight,\n },\n\n directives: { clickoutside: ClickOutside },\n props: {\n visible: {\n type: Boolean,\n default: false,\n },\n parsedValue: {\n type: [Object, Array] as PropType<Dayjs | Dayjs[]>,\n },\n format: {\n type: String,\n default: '',\n },\n type: {\n type: String as PropType<IDatePickerType>,\n required: true,\n validator: isValidDatePickType,\n },\n },\n emits: ['pick', 'set-picker-option'],\n setup(props, ctx) {\n const { t, lang } = useLocale()\n const pickerBase = inject('EP_PICKER_BASE') as any\n const popper = inject(TOOLTIP_INJECTION_KEY)\n const {\n shortcuts,\n disabledDate,\n cellClassName,\n defaultTime,\n defaultValue,\n arrowControl,\n } = pickerBase.props\n\n const innerDate = ref(dayjs().locale(lang.value))\n\n const defaultTimeD = computed(() => {\n return dayjs(defaultTime).locale(lang.value)\n })\n\n const month = computed(() => {\n return innerDate.value.month()\n })\n\n const year = computed(() => {\n return innerDate.value.year()\n })\n\n const selectableRange = ref([])\n const userInputDate = ref(null)\n const userInputTime = ref(null)\n // todo update to disableHour\n const checkDateWithinRange = (date: ConfigType) => {\n return selectableRange.value.length > 0\n ? timeWithinRange(\n date,\n selectableRange.value,\n props.format || 'HH:mm:ss'\n )\n : true\n }\n const formatEmit = (emitDayjs: Dayjs) => {\n if (defaultTime && !visibleTime.value) {\n return defaultTimeD.value\n .year(emitDayjs.year())\n .month(emitDayjs.month())\n .date(emitDayjs.date())\n }\n if (showTime.value) return emitDayjs.millisecond(0)\n return emitDayjs.startOf('day')\n }\n const emit = (value, ...args) => {\n if (!value) {\n ctx.emit('pick', value, ...args)\n } else if (Array.isArray(value)) {\n const dates = value.map(formatEmit)\n ctx.emit('pick', dates, ...args)\n } else {\n ctx.emit('pick', formatEmit(value), ...args)\n }\n userInputDate.value = null\n userInputTime.value = null\n }\n const handleDatePick = (value: Dayjs) => {\n if (selectionMode.value === 'day') {\n let newDate = props.parsedValue\n ? (props.parsedValue as Dayjs)\n .year(value.year())\n .month(value.month())\n .date(value.date())\n : value\n // change default time while out of selectableRange\n if (!checkDateWithinRange(newDate)) {\n newDate = (selectableRange.value[0][0] as Dayjs)\n .year(value.year())\n .month(value.month())\n .date(value.date())\n }\n innerDate.value = newDate\n emit(newDate, showTime.value)\n } else if (selectionMode.value === 'week') {\n emit(value.date)\n } else if (selectionMode.value === 'dates') {\n emit(value, true) // set false to keep panel open\n }\n }\n const prevMonth_ = () => {\n innerDate.value = innerDate.value.subtract(1, 'month')\n }\n\n const nextMonth_ = () => {\n innerDate.value = innerDate.value.add(1, 'month')\n }\n\n const prevYear_ = () => {\n if (currentView.value === 'year') {\n innerDate.value = innerDate.value.subtract(10, 'year')\n } else {\n innerDate.value = innerDate.value.subtract(1, 'year')\n }\n }\n\n const nextYear_ = () => {\n if (currentView.value === 'year') {\n innerDate.value = innerDate.value.add(10, 'year')\n } else {\n innerDate.value = innerDate.value.add(1, 'year')\n }\n }\n\n const currentView = ref('date')\n\n const yearLabel = computed(() => {\n const yearTranslation = t('el.datepicker.year')\n if (currentView.value === 'year') {\n const startYear = Math.floor(year.value / 10) * 10\n if (yearTranslation) {\n return `${startYear} ${yearTranslation} - ${\n startYear + 9\n } ${yearTranslation}`\n }\n return `${startYear} - ${startYear + 9}`\n }\n return `${year.value} ${yearTranslation}`\n })\n\n const handleShortcutClick = (shortcut) => {\n const shortcutValue =\n typeof shortcut.value === 'function' ? shortcut.value() : shortcut.value\n if (shortcutValue) {\n emit(dayjs(shortcutValue).locale(lang.value))\n return\n }\n if (shortcut.onClick) {\n shortcut.onClick(ctx)\n }\n }\n\n const selectionMode = computed(() => {\n if (['week', 'month', 'year', 'dates'].includes(props.type)) {\n return props.type\n }\n return 'day'\n })\n\n watch(\n () => selectionMode.value,\n (val) => {\n if (['month', 'year'].includes(val)) {\n currentView.value = val\n return\n }\n currentView.value = 'date'\n },\n { immediate: true }\n )\n\n watch(\n () => currentView.value,\n () => {\n popper?.updatePopper()\n }\n )\n\n const hasShortcuts = computed(() => !!shortcuts.length)\n\n const handleMonthPick = (month) => {\n innerDate.value = innerDate.value.startOf('month').month(month)\n if (selectionMode.value === 'month') {\n emit(innerDate.value)\n } else {\n currentView.value = 'date'\n }\n }\n\n const handleYearPick = (year) => {\n if (selectionMode.value === 'year') {\n innerDate.value = innerDate.value.startOf('year').year(year)\n emit(innerDate.value)\n } else {\n innerDate.value = innerDate.value.year(year)\n currentView.value = 'month'\n }\n }\n\n const showMonthPicker = () => {\n currentView.value = 'month'\n }\n\n const showYearPicker = () => {\n currentView.value = 'year'\n }\n\n const showTime = computed(\n () => props.type === 'datetime' || props.type === 'datetimerange'\n )\n\n const footerVisible = computed(() => {\n return showTime.value || selectionMode.value === 'dates'\n })\n\n const onConfirm = () => {\n if (selectionMode.value === 'dates') {\n emit(props.parsedValue)\n } else {\n // deal with the scenario where: user opens the date time picker, then confirm without doing anything\n let result = props.parsedValue as Dayjs\n if (!result) {\n const defaultTimeD = dayjs(defaultTime).locale(lang.value)\n const defaultValueD = getDefaultValue()\n result = defaultTimeD\n .year(defaultValueD.year())\n .month(defaultValueD.month())\n .date(defaultValueD.date())\n }\n innerDate.value = result\n emit(result)\n }\n }\n\n const changeToNow = () => {\n // NOTE: not a permanent solution\n // consider disable \"now\" button in the future\n const now = dayjs().locale(lang.value)\n const nowDate = now.toDate()\n if (\n (!disabledDate || !disabledDate(nowDate)) &&\n checkDateWithinRange(nowDate)\n ) {\n innerDate.value = dayjs().locale(lang.value)\n emit(innerDate.value)\n }\n }\n\n const timeFormat = computed(() => {\n return extractTimeFormat(props.format)\n })\n\n const dateFormat = computed(() => {\n return extractDateFormat(props.format)\n })\n\n const visibleTime = computed(() => {\n if (userInputTime.value) return userInputTime.value\n if (!props.parsedValue && !defaultValue) return\n return ((props.parsedValue || innerDate.value) as Dayjs).format(\n timeFormat.value\n )\n })\n\n const visibleDate = computed(() => {\n if (userInputDate.value) return userInputDate.value\n if (!props.parsedValue && !defaultValue) return\n return ((props.parsedValue || innerDate.value) as Dayjs).format(\n dateFormat.value\n )\n })\n\n const timePickerVisible = ref(false)\n const onTimePickerInputFocus = () => {\n timePickerVisible.value = true\n }\n const handleTimePickClose = () => {\n timePickerVisible.value = false\n }\n\n const handleTimePick = (value, visible, first) => {\n const newDate = props.parsedValue\n ? (props.parsedValue as Dayjs)\n .hour(value.hour())\n .minute(value.minute())\n .second(value.second())\n : value\n innerDate.value = newDate\n emit(innerDate.value, true)\n if (!first) {\n timePickerVisible.value = visible\n }\n }\n\n const handleVisibleTimeChange = (value) => {\n const newDate = dayjs(value, timeFormat.value).locale(lang.value)\n if (newDate.isValid() && checkDateWithinRange(newDate)) {\n innerDate.value = newDate\n .year(innerDate.value.year())\n .month(innerDate.value.month())\n .date(innerDate.value.date())\n userInputTime.value = null\n timePickerVisible.value = false\n emit(innerDate.value, true)\n }\n }\n\n const handleVisibleDateChange = (value) => {\n const newDate = dayjs(value, dateFormat.value).locale(lang.value)\n if (newDate.isValid()) {\n if (disabledDate && disabledDate(newDate.toDate())) {\n return\n }\n innerDate.value = newDate\n .hour(innerDate.value.hour())\n .minute(innerDate.value.minute())\n .second(innerDate.value.second())\n userInputDate.value = null\n emit(innerDate.value, true)\n }\n }\n\n const isValidValue = (date: unknown) => {\n return (\n dayjs.isDayjs(date) &&\n date.isValid() &&\n (disabledDate ? !disabledDate(date.toDate()) : true)\n )\n }\n\n const formatToString = (value) => {\n if (selectionMode.value === 'dates') {\n return value.map((_) => _.format(props.format))\n }\n return value.format(props.format)\n }\n\n const parseUserInput = (value) => {\n return dayjs(value, props.format).locale(lang.value)\n }\n\n const getDefaultValue = () => {\n const parseDate = dayjs(defaultValue).locale(lang.value)\n if (!defaultValue) {\n const defaultTimeDValue = defaultTimeD.value\n return dayjs()\n .hour(defaultTimeDValue.hour())\n .minute(defaultTimeDValue.minute())\n .second(defaultTimeDValue.second())\n .locale(lang.value)\n }\n return parseDate\n }\n\n const handleKeydown = (event) => {\n const { code, keyCode } = event\n const list = [\n EVENT_CODE.up,\n EVENT_CODE.down,\n EVENT_CODE.left,\n EVENT_CODE.right,\n ]\n if (props.visible && !timePickerVisible.value) {\n if (list.includes(code)) {\n handleKeyControl(keyCode)\n event.stopPropagation()\n event.preventDefault()\n }\n if (\n code === EVENT_CODE.enter &&\n userInputDate.value === null &&\n userInputTime.value === null\n ) {\n // Enter\n emit(innerDate, false)\n }\n }\n }\n\n const handleKeyControl = (keyCode) => {\n const mapping = {\n year: {\n 38: -4,\n 40: 4,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setFullYear(date.getFullYear() + step),\n },\n month: {\n 38: -4,\n 40: 4,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setMonth(date.getMonth() + step),\n },\n week: {\n 38: -1,\n 40: 1,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setDate(date.getDate() + step * 7),\n },\n day: {\n 38: -7,\n 40: 7,\n 37: -1,\n 39: 1,\n offset: (date, step) => date.setDate(date.getDate() + step),\n },\n }\n\n const newDate = innerDate.value.toDate()\n while (Math.abs(innerDate.value.diff(newDate, 'year', true)) < 1) {\n const map = mapping[selectionMode.value]\n map.offset(newDate, map[keyCode])\n if (disabledDate && disabledDate(newDate)) {\n continue\n }\n const result = dayjs(newDate).locale(lang.value)\n innerDate.value = result\n ctx.emit('pick', result, true)\n break\n }\n }\n\n ctx.emit('set-picker-option', ['isValidValue', isValidValue])\n ctx.emit('set-picker-option', ['formatToString', formatToString])\n ctx.emit('set-picker-option', ['parseUserInput', parseUserInput])\n ctx.emit('set-picker-option', ['handleKeydown', handleKeydown])\n\n watch(\n () => props.parsedValue,\n (val) => {\n if (val) {\n if (selectionMode.value === 'dates') return\n if (Array.isArray(val)) return\n innerDate.value = val\n } else {\n innerDate.value = getDefaultValue()\n }\n },\n { immediate: true }\n )\n\n return {\n handleTimePick,\n handleTimePickClose,\n onTimePickerInputFocus,\n timePickerVisible,\n visibleTime,\n visibleDate,\n showTime,\n changeToNow,\n onConfirm,\n footerVisible,\n handleYearPick,\n showMonthPicker,\n showYearPicker,\n handleMonthPick,\n hasShortcuts,\n shortcuts,\n arrowControl,\n disabledDate,\n cellClassName,\n selectionMode,\n handleShortcutClick,\n prevYear_,\n nextYear_,\n prevMonth_,\n nextMonth_,\n innerDate,\n t,\n yearLabel,\n currentView,\n month,\n handleDatePick,\n handleVisibleTimeChange,\n handleVisibleDateChange,\n timeFormat,\n userInputTime,\n userInputDate,\n }\n },\n})\n</script>\n"],"names":["_createElementVNode"],"mappings":";;;;;;;;;;EAY+B;;;;;;EAYF;;qBACb,KAAK,EAAC,6BAA6B;;;;;;sBAuFtC,KAAK,EAAC;eA4Bb,KAAK,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;yDAjIqB;;;;;;gBAKvB;;;;;;;iCAOJ;;;cAEI;;;;2BAIS;yBACC;;;;6CAIV;;;;;2BAQY;;4BAEC;;;;;;qCAMM;2BACVA;;;;;;;wBAIX;;;;;;;gBASQ;;;;;YAKJ;gCAAS,CAAgB;;;;;;;gBAIrB;;;;;YAKJ;;gBAAS;;;;;;;;;YAIT,UAAM;YACL;iCACG;0BAEN;YAEE;YACA,KAAK;YAEJ,OAAK;;;;;gBAIF;;;;;YAKJ;gCAAS,CAAiB;;;;;;;gBAItB;;;;;YAKJ;;;;;;;;;;;;;;;;kCAMiB;;;+BAGH;;;;;6BAGhB;;oBAEO,EAAE;;;;;;;;;sBAOA;;;kDAGe;;;;;;;;QAW1B,IAAI,EAAC;QACL;QACA,OAAM;;;6BAGN;;;;;;;MAEF;;;;;"}
|
|
@@ -95,8 +95,8 @@ export declare const ElDescriptions: import("../../utils/types").SFCWithInstall<
|
|
|
95
95
|
span: number;
|
|
96
96
|
width: string | number;
|
|
97
97
|
align: string;
|
|
98
|
-
minWidth: string | number;
|
|
99
98
|
className: string;
|
|
99
|
+
minWidth: string | number;
|
|
100
100
|
labelAlign: string;
|
|
101
101
|
labelClassName: string;
|
|
102
102
|
} & {}>, {
|
|
@@ -104,8 +104,8 @@ export declare const ElDescriptions: import("../../utils/types").SFCWithInstall<
|
|
|
104
104
|
span: number;
|
|
105
105
|
width: string | number;
|
|
106
106
|
align: string;
|
|
107
|
-
minWidth: string | number;
|
|
108
107
|
className: string;
|
|
108
|
+
minWidth: string | number;
|
|
109
109
|
labelAlign: string;
|
|
110
110
|
labelClassName: string;
|
|
111
111
|
}>;
|
|
@@ -158,8 +158,8 @@ export declare const ElDescriptionsItem: import("../../utils/types").SFCWithInst
|
|
|
158
158
|
span: number;
|
|
159
159
|
width: string | number;
|
|
160
160
|
align: string;
|
|
161
|
-
minWidth: string | number;
|
|
162
161
|
className: string;
|
|
162
|
+
minWidth: string | number;
|
|
163
163
|
labelAlign: string;
|
|
164
164
|
labelClassName: string;
|
|
165
165
|
} & {}>, {
|
|
@@ -167,8 +167,8 @@ export declare const ElDescriptionsItem: import("../../utils/types").SFCWithInst
|
|
|
167
167
|
span: number;
|
|
168
168
|
width: string | number;
|
|
169
169
|
align: string;
|
|
170
|
-
minWidth: string | number;
|
|
171
170
|
className: string;
|
|
171
|
+
minWidth: string | number;
|
|
172
172
|
labelAlign: string;
|
|
173
173
|
labelClassName: string;
|
|
174
174
|
}>>;
|
|
@@ -45,8 +45,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
45
45
|
span: number;
|
|
46
46
|
width: string | number;
|
|
47
47
|
align: string;
|
|
48
|
-
minWidth: string | number;
|
|
49
48
|
className: string;
|
|
49
|
+
minWidth: string | number;
|
|
50
50
|
labelAlign: string;
|
|
51
51
|
labelClassName: string;
|
|
52
52
|
} & {}>, {
|
|
@@ -54,8 +54,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
54
54
|
span: number;
|
|
55
55
|
width: string | number;
|
|
56
56
|
align: string;
|
|
57
|
-
minWidth: string | number;
|
|
58
57
|
className: string;
|
|
58
|
+
minWidth: string | number;
|
|
59
59
|
labelAlign: string;
|
|
60
60
|
labelClassName: string;
|
|
61
61
|
}>;
|
|
@@ -107,6 +107,7 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
107
107
|
stopPopperMouseEvent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
108
108
|
showAfter: number;
|
|
109
109
|
hideAfter: number;
|
|
110
|
+
appendTo: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | HTMLElement>, unknown, unknown>;
|
|
110
111
|
rawContent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
111
112
|
persistent: boolean;
|
|
112
113
|
teleported: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
@@ -126,6 +127,7 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
126
127
|
trigger?: unknown;
|
|
127
128
|
virtualRef?: unknown;
|
|
128
129
|
virtualTriggering?: unknown;
|
|
130
|
+
appendTo?: unknown;
|
|
129
131
|
content?: unknown;
|
|
130
132
|
rawContent?: unknown;
|
|
131
133
|
persistent?: unknown;
|
|
@@ -223,6 +225,7 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
223
225
|
stopPopperMouseEvent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
224
226
|
showAfter: number;
|
|
225
227
|
hideAfter: number;
|
|
228
|
+
appendTo: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | HTMLElement>, unknown, unknown>;
|
|
226
229
|
rawContent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
227
230
|
persistent: boolean;
|
|
228
231
|
teleported: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
@@ -237,7 +240,7 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
237
240
|
virtualTriggering?: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown> | undefined;
|
|
238
241
|
}> & {
|
|
239
242
|
[x: string & `on${string}`]: ((...args: any[]) => any) | undefined;
|
|
240
|
-
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "disabled" | "style" | "transition" | "offset" | "visible" | "content" | "effect" | "arrowOffset" | "boundariesPadding" | "fallbackPlacements" | "gpuAcceleration" | "placement" | "popperOptions" | "strategy" | "className" | "enterable" | "pure" | "popperClass" | "popperStyle" | "referenceEl" | "stopPopperMouseEvent" | "showAfter" | "hideAfter" | "rawContent" | "persistent" | "teleported" | "trigger" | "virtualRef" | "virtualTriggering" | "openDelay" | "visibleArrow" | "showArrow">;
|
|
243
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "disabled" | "style" | "transition" | "offset" | "visible" | "content" | "effect" | "arrowOffset" | "boundariesPadding" | "fallbackPlacements" | "gpuAcceleration" | "placement" | "popperOptions" | "strategy" | "className" | "enterable" | "pure" | "popperClass" | "popperStyle" | "referenceEl" | "stopPopperMouseEvent" | "showAfter" | "hideAfter" | "appendTo" | "rawContent" | "persistent" | "teleported" | "trigger" | "virtualRef" | "virtualTriggering" | "openDelay" | "visibleArrow" | "showArrow">;
|
|
241
244
|
$attrs: {
|
|
242
245
|
[x: string]: unknown;
|
|
243
246
|
};
|
|
@@ -261,6 +264,7 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
261
264
|
trigger?: unknown;
|
|
262
265
|
virtualRef?: unknown;
|
|
263
266
|
virtualTriggering?: unknown;
|
|
267
|
+
appendTo?: unknown;
|
|
264
268
|
content?: unknown;
|
|
265
269
|
rawContent?: unknown;
|
|
266
270
|
persistent?: unknown;
|
|
@@ -358,6 +362,7 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
358
362
|
stopPopperMouseEvent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
359
363
|
showAfter: number;
|
|
360
364
|
hideAfter: number;
|
|
365
|
+
appendTo: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | HTMLElement>, unknown, unknown>;
|
|
361
366
|
rawContent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
362
367
|
persistent: boolean;
|
|
363
368
|
teleported: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
@@ -489,6 +494,7 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
489
494
|
stopPopperMouseEvent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
490
495
|
showAfter: number;
|
|
491
496
|
hideAfter: number;
|
|
497
|
+
appendTo: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | HTMLElement>, unknown, unknown>;
|
|
492
498
|
rawContent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
493
499
|
persistent: boolean;
|
|
494
500
|
teleported: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
@@ -528,6 +534,7 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
528
534
|
trigger?: unknown;
|
|
529
535
|
virtualRef?: unknown;
|
|
530
536
|
virtualTriggering?: unknown;
|
|
537
|
+
appendTo?: unknown;
|
|
531
538
|
content?: unknown;
|
|
532
539
|
rawContent?: unknown;
|
|
533
540
|
persistent?: unknown;
|
|
@@ -625,6 +632,7 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
625
632
|
stopPopperMouseEvent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
626
633
|
showAfter: number;
|
|
627
634
|
hideAfter: number;
|
|
635
|
+
appendTo: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | HTMLElement>, unknown, unknown>;
|
|
628
636
|
rawContent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
629
637
|
persistent: boolean;
|
|
630
638
|
teleported: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
@@ -704,9 +712,9 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
704
712
|
} & {
|
|
705
713
|
size: string;
|
|
706
714
|
effect: string;
|
|
707
|
-
maxHeight: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | number>, unknown, unknown>;
|
|
708
715
|
placement: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<import("@popperjs/core").Placement>, unknown, unknown>;
|
|
709
716
|
popperClass: string;
|
|
717
|
+
maxHeight: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | number>, unknown, unknown>;
|
|
710
718
|
trigger: "click" | "contextmenu" | "focus" | "hover" | ("click" | "contextmenu" | "focus" | "hover")[];
|
|
711
719
|
tabindex: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | number>, unknown, unknown>;
|
|
712
720
|
hideOnClick: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
@@ -724,9 +732,9 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
724
732
|
type: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<import("../../utils/props").BuildPropType<StringConstructor, "" | "default" | "primary" | "success" | "warning" | "info" | "danger" | "text", unknown>>, unknown, unknown>;
|
|
725
733
|
size: string;
|
|
726
734
|
effect: string;
|
|
727
|
-
maxHeight: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | number>, unknown, unknown>;
|
|
728
735
|
placement: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<import("@popperjs/core").Placement>, unknown, unknown>;
|
|
729
736
|
popperClass: string;
|
|
737
|
+
maxHeight: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | number>, unknown, unknown>;
|
|
730
738
|
trigger: "click" | "contextmenu" | "focus" | "hover" | ("click" | "contextmenu" | "focus" | "hover")[];
|
|
731
739
|
tabindex: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | number>, unknown, unknown>;
|
|
732
740
|
loop: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
@@ -742,11 +750,11 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
742
750
|
readonly textValue: StringConstructor;
|
|
743
751
|
readonly icon: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<string | import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>>, unknown, unknown, unknown, unknown>;
|
|
744
752
|
}, {
|
|
745
|
-
handleClick: (
|
|
753
|
+
handleClick: (event: PointerEvent) => void;
|
|
746
754
|
handlePointerMove: (event: PointerEvent) => void;
|
|
747
755
|
handlePointerLeave: (event: PointerEvent) => void;
|
|
748
756
|
textContent: import("vue").ComputedRef<string>;
|
|
749
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("pointerleave" | "pointermove")[], "pointerleave" | "pointermove", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
757
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "pointerleave" | "pointermove")[], "click" | "pointerleave" | "pointermove", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
750
758
|
readonly command?: unknown;
|
|
751
759
|
readonly disabled?: unknown;
|
|
752
760
|
readonly divided?: unknown;
|
|
@@ -760,6 +768,7 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
760
768
|
icon?: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>>, unknown, unknown> | undefined;
|
|
761
769
|
textValue?: string | undefined;
|
|
762
770
|
}> & {
|
|
771
|
+
onClick?: ((...args: any[]) => any) | undefined;
|
|
763
772
|
onPointermove?: ((...args: any[]) => any) | undefined;
|
|
764
773
|
onPointerleave?: ((...args: any[]) => any) | undefined;
|
|
765
774
|
}, {
|
|
@@ -774,6 +783,7 @@ export declare const ElDropdown: import("../../utils/types").SFCWithInstall<impo
|
|
|
774
783
|
size: import("vue").ComputedRef<string> | undefined;
|
|
775
784
|
rovingFocusGroupRootStyle: import("vue").Ref<import("vue").StyleValue>;
|
|
776
785
|
tabIndex: import("vue").Ref<number>;
|
|
786
|
+
dropdownKls: import("vue").ComputedRef<string[]>;
|
|
777
787
|
dropdownListWrapperRef: (el: Element | import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null) => void;
|
|
778
788
|
handleKeydown: (e: KeyboardEvent) => void;
|
|
779
789
|
onBlur: (e: Event) => void;
|
|
@@ -795,11 +805,11 @@ export declare const ElDropdownItem: import("../../utils/types").SFCWithInstall<
|
|
|
795
805
|
readonly textValue: StringConstructor;
|
|
796
806
|
readonly icon: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<string | import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>>, unknown, unknown, unknown, unknown>;
|
|
797
807
|
}, {
|
|
798
|
-
handleClick: (
|
|
808
|
+
handleClick: (event: PointerEvent) => void;
|
|
799
809
|
handlePointerMove: (event: PointerEvent) => void;
|
|
800
810
|
handlePointerLeave: (event: PointerEvent) => void;
|
|
801
811
|
textContent: import("vue").ComputedRef<string>;
|
|
802
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("pointerleave" | "pointermove")[], "pointerleave" | "pointermove", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
812
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "pointerleave" | "pointermove")[], "click" | "pointerleave" | "pointermove", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
803
813
|
readonly command?: unknown;
|
|
804
814
|
readonly disabled?: unknown;
|
|
805
815
|
readonly divided?: unknown;
|
|
@@ -813,6 +823,7 @@ export declare const ElDropdownItem: import("../../utils/types").SFCWithInstall<
|
|
|
813
823
|
icon?: import("../../utils/props").BuildPropType<import("../../utils/props").PropWrapper<string | import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>>, unknown, unknown> | undefined;
|
|
814
824
|
textValue?: string | undefined;
|
|
815
825
|
}> & {
|
|
826
|
+
onClick?: ((...args: any[]) => any) | undefined;
|
|
816
827
|
onPointermove?: ((...args: any[]) => any) | undefined;
|
|
817
828
|
onPointerleave?: ((...args: any[]) => any) | undefined;
|
|
818
829
|
}, {
|
|
@@ -827,6 +838,7 @@ export declare const ElDropdownMenu: import("../../utils/types").SFCWithInstall<
|
|
|
827
838
|
size: import("vue").ComputedRef<string> | undefined;
|
|
828
839
|
rovingFocusGroupRootStyle: import("vue").Ref<import("vue").StyleValue>;
|
|
829
840
|
tabIndex: import("vue").Ref<number>;
|
|
841
|
+
dropdownKls: import("vue").ComputedRef<string[]>;
|
|
830
842
|
dropdownListWrapperRef: (el: Element | import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null) => void;
|
|
831
843
|
handleKeydown: (e: KeyboardEvent) => void;
|
|
832
844
|
onBlur: (e: Event) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-item-impl.vue_vue_type_script_lang.js","sources":["../../../../../../packages/components/dropdown/src/dropdown-item-impl.vue"],"sourcesContent":["<template>\n <div\n :ref=\"itemRef\"\n v-bind=\"dataset\"\n :aria-disabled=\"disabled\"\n :class=\"{\n 'el-dropdown-menu__item': true,\n 'is-disabled': disabled,\n
|
|
1
|
+
{"version":3,"file":"dropdown-item-impl.vue_vue_type_script_lang.js","sources":["../../../../../../packages/components/dropdown/src/dropdown-item-impl.vue"],"sourcesContent":["<template>\n <div v-if=\"divided\" class=\"el-dropdown-menu__item--divided\"></div>\n <div\n :ref=\"itemRef\"\n v-bind=\"dataset\"\n :aria-disabled=\"disabled\"\n :class=\"{\n 'el-dropdown-menu__item': true,\n 'is-disabled': disabled,\n }\"\n :tabindex=\"tabIndex\"\n role=\"menuitem\"\n @click=\"(e) => $emit('click', e)\"\n @focus=\"handleFocus\"\n @keydown=\"handleKeydown\"\n @mousedown=\"handleMousedown\"\n @pointermove=\"(e) => $emit('pointermove', e)\"\n @pointerleave=\"(e) => $emit('pointerleave', e)\"\n >\n <el-icon v-if=\"icon\"><component :is=\"icon\" /></el-icon>\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, inject } from 'vue'\nimport {\n ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY,\n ROVING_FOCUS_ITEM_COLLECTION_INJECTION_KEY,\n} from '@element-plus/components/roving-focus-group'\nimport { COLLECTION_ITEM_SIGN } from '@element-plus/components/collection'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\nimport { composeEventHandlers, composeRefs } from '@element-plus/utils/dom'\nimport {\n DROPDOWN_COLLECTION_ITEM_INJECTION_KEY,\n dropdownItemProps,\n} from './dropdown'\n\nexport default defineComponent({\n name: 'DropdownItemImpl',\n components: {\n ElIcon,\n },\n props: dropdownItemProps,\n emits: ['pointermove', 'pointerleave', 'click'],\n setup(_, { emit }) {\n const { collectionItemRef: dropdownCollectionItemRef } = inject(\n DROPDOWN_COLLECTION_ITEM_INJECTION_KEY,\n undefined\n )!\n\n const { collectionItemRef: rovingFocusCollectionItemRef } = inject(\n ROVING_FOCUS_ITEM_COLLECTION_INJECTION_KEY,\n undefined\n )!\n\n const {\n rovingFocusGroupItemRef,\n tabIndex,\n handleFocus,\n handleKeydown: handleItemKeydown,\n handleMousedown,\n } = inject(ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY, undefined)!\n\n const itemRef = composeRefs(\n dropdownCollectionItemRef,\n rovingFocusCollectionItemRef,\n rovingFocusGroupItemRef\n )\n\n const handleKeydown = composeEventHandlers((e: KeyboardEvent) => {\n const { code } = e\n if (code === EVENT_CODE.enter || code === EVENT_CODE.space) {\n e.preventDefault()\n e.stopImmediatePropagation()\n emit('click', e)\n return true\n }\n }, handleItemKeydown)\n\n return {\n itemRef,\n dataset: {\n [COLLECTION_ITEM_SIGN]: '',\n },\n tabIndex,\n handleFocus,\n handleKeydown,\n handleMousedown,\n }\n },\n})\n</script>\n"],"names":["defineComponent","ElIcon","dropdownItemProps","inject","ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY","COLLECTION_ITEM_SIGN"],"mappings":";;;;;;;;;;;;;;;AAqCA,aAAeA;;AAEf,EAAE,UAAU;YACRC,YAAM;GACP;OACI,EAAEC;EACP;EACA,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;IACjB,MAAM,EAAE,iBAAiB,EAAE;IAC3B;IACA,MAAM;MACJ,uBAAuB;MACvB,QAAQ;;;MAGR,eAAe;QACbC,UAAM,CAACC;UACL;IACN;;MAEE,IAAI;QACF,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,CAAC,CAAC;QACF,IAAI,CAAC;QACL,OAAO,IAAI;OACZ;wBACiB,CAAC,CAAC;;MAEpB,OAAO;MACP,OAAO,EAAE;QACP,CAACC,+BAAoB,GAAG,EAAE;OAC3B;;;MAGD,aAAa;MACb,eAAe;MACf;;;;;;"}
|
package/lib/components/dropdown/src/dropdown-item-impl.vue_vue_type_template_id_6daab4f2_lang.js
CHANGED
|
@@ -4,33 +4,39 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var vue = require('vue');
|
|
6
6
|
|
|
7
|
-
const _hoisted_1 =
|
|
7
|
+
const _hoisted_1 = {
|
|
8
|
+
key: 0,
|
|
9
|
+
class: "el-dropdown-menu__item--divided"
|
|
10
|
+
};
|
|
11
|
+
const _hoisted_2 = ["aria-disabled", "tabindex"];
|
|
8
12
|
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
9
13
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
10
|
-
return vue.openBlock(), vue.createElementBlock(
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
|
|
15
|
+
_ctx.divided ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1)) : vue.createCommentVNode("v-if", true),
|
|
16
|
+
vue.createElementVNode("div", vue.mergeProps({ ref: _ctx.itemRef }, _ctx.dataset, {
|
|
17
|
+
"aria-disabled": _ctx.disabled,
|
|
18
|
+
class: {
|
|
19
|
+
"el-dropdown-menu__item": true,
|
|
20
|
+
"is-disabled": _ctx.disabled
|
|
21
|
+
},
|
|
22
|
+
tabindex: _ctx.tabIndex,
|
|
23
|
+
role: "menuitem",
|
|
24
|
+
onClick: _cache[0] || (_cache[0] = (e) => _ctx.$emit("click", e)),
|
|
25
|
+
onFocus: _cache[1] || (_cache[1] = (...args) => _ctx.handleFocus && _ctx.handleFocus(...args)),
|
|
26
|
+
onKeydown: _cache[2] || (_cache[2] = (...args) => _ctx.handleKeydown && _ctx.handleKeydown(...args)),
|
|
27
|
+
onMousedown: _cache[3] || (_cache[3] = (...args) => _ctx.handleMousedown && _ctx.handleMousedown(...args)),
|
|
28
|
+
onPointermove: _cache[4] || (_cache[4] = (e) => _ctx.$emit("pointermove", e)),
|
|
29
|
+
onPointerleave: _cache[5] || (_cache[5] = (e) => _ctx.$emit("pointerleave", e))
|
|
30
|
+
}), [
|
|
31
|
+
_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
32
|
+
default: vue.withCtx(() => [
|
|
33
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.icon)))
|
|
34
|
+
]),
|
|
35
|
+
_: 1
|
|
36
|
+
})) : vue.createCommentVNode("v-if", true),
|
|
37
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
38
|
+
], 16, _hoisted_2)
|
|
39
|
+
], 64);
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
exports.render = render;
|