@element-plus/nightly 0.0.20220721 → 0.0.20220722
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/dist/index.css +1 -1
- package/dist/index.full.js +2 -46
- package/dist/index.full.min.js +9 -9
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +9 -9
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +3 -46
- package/dist/locale/af.js +1 -1
- package/dist/locale/af.min.js +1 -1
- package/dist/locale/af.min.mjs +1 -1
- package/dist/locale/af.mjs +1 -1
- package/dist/locale/ar.js +1 -1
- package/dist/locale/ar.min.js +1 -1
- package/dist/locale/ar.min.mjs +1 -1
- package/dist/locale/ar.mjs +1 -1
- package/dist/locale/az.js +1 -1
- package/dist/locale/az.min.js +1 -1
- package/dist/locale/az.min.mjs +1 -1
- package/dist/locale/az.mjs +1 -1
- package/dist/locale/bg.js +1 -1
- package/dist/locale/bg.min.js +1 -1
- package/dist/locale/bg.min.mjs +1 -1
- package/dist/locale/bg.mjs +1 -1
- package/dist/locale/bn.js +1 -1
- package/dist/locale/bn.min.js +1 -1
- package/dist/locale/bn.min.mjs +1 -1
- package/dist/locale/bn.mjs +1 -1
- package/dist/locale/ca.js +1 -1
- package/dist/locale/ca.min.js +1 -1
- package/dist/locale/ca.min.mjs +1 -1
- package/dist/locale/ca.mjs +1 -1
- package/dist/locale/cs.js +1 -1
- package/dist/locale/cs.min.js +1 -1
- package/dist/locale/cs.min.mjs +1 -1
- package/dist/locale/cs.mjs +1 -1
- package/dist/locale/da.js +1 -1
- package/dist/locale/da.min.js +1 -1
- package/dist/locale/da.min.mjs +1 -1
- package/dist/locale/da.mjs +1 -1
- package/dist/locale/de.js +1 -1
- package/dist/locale/de.min.js +1 -1
- package/dist/locale/de.min.mjs +1 -1
- package/dist/locale/de.mjs +1 -1
- package/dist/locale/el.js +1 -1
- package/dist/locale/el.min.js +1 -1
- package/dist/locale/el.min.mjs +1 -1
- package/dist/locale/el.mjs +1 -1
- package/dist/locale/en.js +1 -1
- package/dist/locale/en.min.js +1 -1
- package/dist/locale/en.min.mjs +1 -1
- package/dist/locale/en.mjs +1 -1
- package/dist/locale/eo.js +1 -1
- package/dist/locale/eo.min.js +1 -1
- package/dist/locale/eo.min.mjs +1 -1
- package/dist/locale/eo.mjs +1 -1
- package/dist/locale/es.js +1 -1
- package/dist/locale/es.min.js +1 -1
- package/dist/locale/es.min.mjs +1 -1
- package/dist/locale/es.mjs +1 -1
- package/dist/locale/et.js +1 -1
- package/dist/locale/et.min.js +1 -1
- package/dist/locale/et.min.mjs +1 -1
- package/dist/locale/et.mjs +1 -1
- package/dist/locale/eu.js +1 -1
- package/dist/locale/eu.min.js +1 -1
- package/dist/locale/eu.min.mjs +1 -1
- package/dist/locale/eu.mjs +1 -1
- package/dist/locale/fa.js +1 -1
- package/dist/locale/fa.min.js +1 -1
- package/dist/locale/fa.min.mjs +1 -1
- package/dist/locale/fa.mjs +1 -1
- package/dist/locale/fi.js +1 -1
- package/dist/locale/fi.min.js +1 -1
- package/dist/locale/fi.min.mjs +1 -1
- package/dist/locale/fi.mjs +1 -1
- package/dist/locale/fr.js +1 -1
- package/dist/locale/fr.min.js +1 -1
- package/dist/locale/fr.min.mjs +1 -1
- package/dist/locale/fr.mjs +1 -1
- package/dist/locale/he.js +1 -1
- package/dist/locale/he.min.js +1 -1
- package/dist/locale/he.min.mjs +1 -1
- package/dist/locale/he.mjs +1 -1
- package/dist/locale/hr.js +1 -1
- package/dist/locale/hr.min.js +1 -1
- package/dist/locale/hr.min.mjs +1 -1
- package/dist/locale/hr.mjs +1 -1
- package/dist/locale/hu.js +1 -1
- package/dist/locale/hu.min.js +1 -1
- package/dist/locale/hu.min.mjs +1 -1
- package/dist/locale/hu.mjs +1 -1
- package/dist/locale/hy-am.js +1 -1
- package/dist/locale/hy-am.min.js +1 -1
- package/dist/locale/hy-am.min.mjs +1 -1
- package/dist/locale/hy-am.mjs +1 -1
- package/dist/locale/id.js +1 -1
- package/dist/locale/id.min.js +1 -1
- package/dist/locale/id.min.mjs +1 -1
- package/dist/locale/id.mjs +1 -1
- package/dist/locale/it.js +1 -1
- package/dist/locale/it.min.js +1 -1
- package/dist/locale/it.min.mjs +1 -1
- package/dist/locale/it.mjs +1 -1
- package/dist/locale/ja.js +1 -1
- package/dist/locale/ja.min.js +1 -1
- package/dist/locale/ja.min.mjs +1 -1
- package/dist/locale/ja.mjs +1 -1
- package/dist/locale/kk.js +1 -1
- package/dist/locale/kk.min.js +1 -1
- package/dist/locale/kk.min.mjs +1 -1
- package/dist/locale/kk.mjs +1 -1
- package/dist/locale/km.js +1 -1
- package/dist/locale/km.min.js +1 -1
- package/dist/locale/km.min.mjs +1 -1
- package/dist/locale/km.mjs +1 -1
- package/dist/locale/ko.js +1 -1
- package/dist/locale/ko.min.js +1 -1
- package/dist/locale/ko.min.mjs +1 -1
- package/dist/locale/ko.mjs +1 -1
- package/dist/locale/ku.js +1 -1
- package/dist/locale/ku.min.js +1 -1
- package/dist/locale/ku.min.mjs +1 -1
- package/dist/locale/ku.mjs +1 -1
- package/dist/locale/ky.js +1 -1
- package/dist/locale/ky.min.js +1 -1
- package/dist/locale/ky.min.mjs +1 -1
- package/dist/locale/ky.mjs +1 -1
- package/dist/locale/lt.js +1 -1
- package/dist/locale/lt.min.js +1 -1
- package/dist/locale/lt.min.mjs +1 -1
- package/dist/locale/lt.mjs +1 -1
- package/dist/locale/lv.js +1 -1
- package/dist/locale/lv.min.js +1 -1
- package/dist/locale/lv.min.mjs +1 -1
- package/dist/locale/lv.mjs +1 -1
- package/dist/locale/mg.js +1 -1
- package/dist/locale/mg.min.js +1 -1
- package/dist/locale/mg.min.mjs +1 -1
- package/dist/locale/mg.mjs +1 -1
- package/dist/locale/mn.js +1 -1
- package/dist/locale/mn.min.js +1 -1
- package/dist/locale/mn.min.mjs +1 -1
- package/dist/locale/mn.mjs +1 -1
- package/dist/locale/nb-no.js +1 -1
- package/dist/locale/nb-no.min.js +1 -1
- package/dist/locale/nb-no.min.mjs +1 -1
- package/dist/locale/nb-no.mjs +1 -1
- package/dist/locale/nl.js +1 -1
- package/dist/locale/nl.min.js +1 -1
- package/dist/locale/nl.min.mjs +1 -1
- package/dist/locale/nl.mjs +1 -1
- package/dist/locale/pa.js +1 -1
- package/dist/locale/pa.min.js +1 -1
- package/dist/locale/pa.min.mjs +1 -1
- package/dist/locale/pa.mjs +1 -1
- package/dist/locale/pl.js +1 -1
- package/dist/locale/pl.min.js +1 -1
- package/dist/locale/pl.min.mjs +1 -1
- package/dist/locale/pl.mjs +1 -1
- package/dist/locale/pt-br.js +1 -1
- package/dist/locale/pt-br.min.js +1 -1
- package/dist/locale/pt-br.min.mjs +1 -1
- package/dist/locale/pt-br.mjs +1 -1
- package/dist/locale/pt.js +1 -1
- package/dist/locale/pt.min.js +1 -1
- package/dist/locale/pt.min.mjs +1 -1
- package/dist/locale/pt.mjs +1 -1
- package/dist/locale/ro.js +1 -1
- package/dist/locale/ro.min.js +1 -1
- package/dist/locale/ro.min.mjs +1 -1
- package/dist/locale/ro.mjs +1 -1
- package/dist/locale/ru.js +1 -1
- package/dist/locale/ru.min.js +1 -1
- package/dist/locale/ru.min.mjs +1 -1
- package/dist/locale/ru.mjs +1 -1
- package/dist/locale/sk.js +1 -1
- package/dist/locale/sk.min.js +1 -1
- package/dist/locale/sk.min.mjs +1 -1
- package/dist/locale/sk.mjs +1 -1
- package/dist/locale/sl.js +1 -1
- package/dist/locale/sl.min.js +1 -1
- package/dist/locale/sl.min.mjs +1 -1
- package/dist/locale/sl.mjs +1 -1
- package/dist/locale/sr.js +1 -1
- package/dist/locale/sr.min.js +1 -1
- package/dist/locale/sr.min.mjs +1 -1
- package/dist/locale/sr.mjs +1 -1
- package/dist/locale/sv.js +1 -1
- package/dist/locale/sv.min.js +1 -1
- package/dist/locale/sv.min.mjs +1 -1
- package/dist/locale/sv.mjs +1 -1
- package/dist/locale/ta.js +1 -1
- package/dist/locale/ta.min.js +1 -1
- package/dist/locale/ta.min.mjs +1 -1
- package/dist/locale/ta.mjs +1 -1
- package/dist/locale/th.js +1 -1
- package/dist/locale/th.min.js +1 -1
- package/dist/locale/th.min.mjs +1 -1
- package/dist/locale/th.mjs +1 -1
- package/dist/locale/tk.js +1 -1
- package/dist/locale/tk.min.js +1 -1
- package/dist/locale/tk.min.mjs +1 -1
- package/dist/locale/tk.mjs +1 -1
- package/dist/locale/tr.js +1 -1
- package/dist/locale/tr.min.js +1 -1
- package/dist/locale/tr.min.mjs +1 -1
- package/dist/locale/tr.mjs +1 -1
- package/dist/locale/ug-cn.js +1 -1
- package/dist/locale/ug-cn.min.js +1 -1
- package/dist/locale/ug-cn.min.mjs +1 -1
- package/dist/locale/ug-cn.mjs +1 -1
- package/dist/locale/uk.js +1 -1
- package/dist/locale/uk.min.js +1 -1
- package/dist/locale/uk.min.mjs +1 -1
- package/dist/locale/uk.mjs +1 -1
- package/dist/locale/uz-uz.js +1 -1
- package/dist/locale/uz-uz.min.js +1 -1
- package/dist/locale/uz-uz.min.mjs +1 -1
- package/dist/locale/uz-uz.mjs +1 -1
- package/dist/locale/vi.js +1 -1
- package/dist/locale/vi.min.js +1 -1
- package/dist/locale/vi.min.mjs +1 -1
- package/dist/locale/vi.mjs +1 -1
- package/dist/locale/zh-cn.js +1 -1
- package/dist/locale/zh-cn.min.js +1 -1
- package/dist/locale/zh-cn.min.mjs +1 -1
- package/dist/locale/zh-cn.mjs +1 -1
- package/dist/locale/zh-tw.js +1 -1
- package/dist/locale/zh-tw.min.js +1 -1
- package/dist/locale/zh-tw.min.mjs +1 -1
- package/dist/locale/zh-tw.mjs +1 -1
- package/es/components/avatar/index.mjs +2 -2
- package/es/components/avatar/src/avatar.mjs +32 -67
- package/es/components/avatar/src/avatar.mjs.map +1 -1
- package/es/components/avatar/src/avatar2.mjs +67 -32
- package/es/components/avatar/src/avatar2.mjs.map +1 -1
- package/es/components/calendar/index.mjs +2 -2
- package/es/components/calendar/src/calendar.mjs +230 -16
- package/es/components/calendar/src/calendar.mjs.map +1 -1
- package/es/components/calendar/src/calendar2.mjs +16 -230
- package/es/components/calendar/src/calendar2.mjs.map +1 -1
- package/es/components/index.mjs +4 -4
- package/es/components/popper/index.mjs +2 -2
- package/es/components/popper/src/content.mjs +207 -87
- package/es/components/popper/src/content.mjs.map +1 -1
- package/es/components/popper/src/content2.mjs +87 -207
- package/es/components/popper/src/content2.mjs.map +1 -1
- package/es/components/tooltip/src/content.mjs +1 -1
- package/es/components/tooltip/src/tooltip.mjs +1 -1
- package/es/directives/index.d.ts +0 -1
- package/es/directives/index.mjs +0 -1
- package/es/directives/index.mjs.map +1 -1
- package/es/index.mjs +4 -5
- 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/avatar/index.js +2 -2
- package/lib/components/avatar/src/avatar.js +33 -67
- package/lib/components/avatar/src/avatar.js.map +1 -1
- package/lib/components/avatar/src/avatar2.js +67 -33
- package/lib/components/avatar/src/avatar2.js.map +1 -1
- package/lib/components/calendar/index.js +2 -2
- package/lib/components/calendar/src/calendar.js +233 -16
- package/lib/components/calendar/src/calendar.js.map +1 -1
- package/lib/components/calendar/src/calendar2.js +16 -233
- package/lib/components/calendar/src/calendar2.js.map +1 -1
- package/lib/components/index.js +4 -4
- package/lib/components/popper/index.js +2 -2
- package/lib/components/popper/src/content.js +206 -88
- package/lib/components/popper/src/content.js.map +1 -1
- package/lib/components/popper/src/content2.js +88 -206
- package/lib/components/popper/src/content2.js.map +1 -1
- package/lib/components/tooltip/src/content.js +1 -1
- package/lib/components/tooltip/src/tooltip.js +1 -1
- package/lib/directives/index.d.ts +0 -1
- package/lib/directives/index.js +0 -2
- package/lib/directives/index.js.map +1 -1
- package/lib/index.js +83 -85
- 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/theme-chalk/el-message.css +1 -1
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/src/common/var.scss +1 -1
- package/theme-chalk/src/message.scss +2 -1
- package/web-types.json +1 -1
- package/es/directives/resize/index.d.ts +0 -3
- package/es/directives/resize/index.mjs +0 -18
- package/es/directives/resize/index.mjs.map +0 -1
- package/lib/directives/resize/index.d.ts +0 -3
- package/lib/directives/resize/index.js +0 -22
- package/lib/directives/resize/index.js.map +0 -1
|
@@ -1,237 +1,23 @@
|
|
|
1
|
-
import { defineComponent, ref, computed, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, renderSlot, toDisplayString, createVNode, withCtx, createTextVNode, createCommentVNode, createSlots, normalizeProps, guardReactiveProps, Fragment, renderList, createBlock } from 'vue';
|
|
2
|
-
import dayjs from 'dayjs';
|
|
3
|
-
import { ElButtonGroup, ElButton } from '../../button/index.mjs';
|
|
4
|
-
import '../../../hooks/index.mjs';
|
|
5
1
|
import '../../../utils/index.mjs';
|
|
6
2
|
import '../../../constants/index.mjs';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
11
|
-
import { useLocale } from '../../../hooks/use-locale/index.mjs';
|
|
12
|
-
import { INPUT_EVENT, UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';
|
|
13
|
-
import { debugWarn } from '../../../utils/error.mjs';
|
|
3
|
+
import { isArray, isDate } from '@vue/shared';
|
|
4
|
+
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
|
|
5
|
+
import { UPDATE_MODEL_EVENT, INPUT_EVENT } from '../../../constants/event.mjs';
|
|
14
6
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const props = __props;
|
|
24
|
-
const COMPONENT_NAME = "ElCalendar";
|
|
25
|
-
const ns = useNamespace("calendar");
|
|
26
|
-
const { t, lang } = useLocale();
|
|
27
|
-
const selectedDay = ref();
|
|
28
|
-
const now = dayjs().locale(lang.value);
|
|
29
|
-
const realSelectedDay = computed({
|
|
30
|
-
get() {
|
|
31
|
-
if (!props.modelValue)
|
|
32
|
-
return selectedDay.value;
|
|
33
|
-
return date.value;
|
|
34
|
-
},
|
|
35
|
-
set(val) {
|
|
36
|
-
if (!val)
|
|
37
|
-
return;
|
|
38
|
-
selectedDay.value = val;
|
|
39
|
-
const result = val.toDate();
|
|
40
|
-
emit(INPUT_EVENT, result);
|
|
41
|
-
emit(UPDATE_MODEL_EVENT, result);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const validatedRange = computed(() => {
|
|
45
|
-
if (!props.range)
|
|
46
|
-
return [];
|
|
47
|
-
const rangeArrDayjs = props.range.map((_) => dayjs(_).locale(lang.value));
|
|
48
|
-
const [startDayjs, endDayjs] = rangeArrDayjs;
|
|
49
|
-
if (startDayjs.isAfter(endDayjs)) {
|
|
50
|
-
debugWarn(COMPONENT_NAME, "end time should be greater than start time");
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
if (startDayjs.isSame(endDayjs, "month")) {
|
|
54
|
-
return calculateValidatedDateRange(startDayjs, endDayjs);
|
|
55
|
-
} else {
|
|
56
|
-
if (startDayjs.add(1, "month").month() !== endDayjs.month()) {
|
|
57
|
-
debugWarn(COMPONENT_NAME, "start time and end time interval must not exceed two months");
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
return calculateValidatedDateRange(startDayjs, endDayjs);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
const date = computed(() => {
|
|
64
|
-
if (!props.modelValue) {
|
|
65
|
-
if (realSelectedDay.value) {
|
|
66
|
-
return realSelectedDay.value;
|
|
67
|
-
} else if (validatedRange.value.length) {
|
|
68
|
-
return validatedRange.value[0][0];
|
|
69
|
-
}
|
|
70
|
-
return now;
|
|
71
|
-
} else {
|
|
72
|
-
return dayjs(props.modelValue).locale(lang.value);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
const prevMonthDayjs = computed(() => date.value.subtract(1, "month").date(1));
|
|
76
|
-
const nextMonthDayjs = computed(() => date.value.add(1, "month").date(1));
|
|
77
|
-
const prevYearDayjs = computed(() => date.value.subtract(1, "year").date(1));
|
|
78
|
-
const nextYearDayjs = computed(() => date.value.add(1, "year").date(1));
|
|
79
|
-
const i18nDate = computed(() => {
|
|
80
|
-
const pickedMonth = `el.datepicker.month${date.value.format("M")}`;
|
|
81
|
-
return `${date.value.year()} ${t("el.datepicker.year")} ${t(pickedMonth)}`;
|
|
82
|
-
});
|
|
83
|
-
const calculateValidatedDateRange = (startDayjs, endDayjs) => {
|
|
84
|
-
const firstDay = startDayjs.startOf("week");
|
|
85
|
-
const lastDay = endDayjs.endOf("week");
|
|
86
|
-
const firstMonth = firstDay.get("month");
|
|
87
|
-
const lastMonth = lastDay.get("month");
|
|
88
|
-
if (firstMonth === lastMonth) {
|
|
89
|
-
return [[firstDay, lastDay]];
|
|
90
|
-
} else if (firstMonth + 1 === lastMonth) {
|
|
91
|
-
const firstMonthLastDay = firstDay.endOf("month");
|
|
92
|
-
const lastMonthFirstDay = lastDay.startOf("month");
|
|
93
|
-
const isSameWeek = firstMonthLastDay.isSame(lastMonthFirstDay, "week");
|
|
94
|
-
const lastMonthStartDay = isSameWeek ? lastMonthFirstDay.add(1, "week") : lastMonthFirstDay;
|
|
95
|
-
return [
|
|
96
|
-
[firstDay, firstMonthLastDay],
|
|
97
|
-
[lastMonthStartDay.startOf("week"), lastDay]
|
|
98
|
-
];
|
|
99
|
-
} else if (firstMonth + 2 === lastMonth || (firstMonth + 1) % 11 === lastMonth) {
|
|
100
|
-
const firstMonthLastDay = firstDay.endOf("month");
|
|
101
|
-
const secondMonthFirstDay = firstDay.add(1, "month").startOf("month");
|
|
102
|
-
const secondMonthStartDay = firstMonthLastDay.isSame(secondMonthFirstDay, "week") ? secondMonthFirstDay.add(1, "week") : secondMonthFirstDay;
|
|
103
|
-
const secondMonthLastDay = secondMonthStartDay.endOf("month");
|
|
104
|
-
const lastMonthFirstDay = lastDay.startOf("month");
|
|
105
|
-
const lastMonthStartDay = secondMonthLastDay.isSame(lastMonthFirstDay, "week") ? lastMonthFirstDay.add(1, "week") : lastMonthFirstDay;
|
|
106
|
-
return [
|
|
107
|
-
[firstDay, firstMonthLastDay],
|
|
108
|
-
[secondMonthStartDay.startOf("week"), secondMonthLastDay],
|
|
109
|
-
[lastMonthStartDay.startOf("week"), lastDay]
|
|
110
|
-
];
|
|
111
|
-
} else {
|
|
112
|
-
debugWarn(COMPONENT_NAME, "start time and end time interval must not exceed two months");
|
|
113
|
-
return [];
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const pickDay = (day) => {
|
|
117
|
-
realSelectedDay.value = day;
|
|
118
|
-
};
|
|
119
|
-
const selectDate = (type) => {
|
|
120
|
-
let day;
|
|
121
|
-
if (type === "prev-month") {
|
|
122
|
-
day = prevMonthDayjs.value;
|
|
123
|
-
} else if (type === "next-month") {
|
|
124
|
-
day = nextMonthDayjs.value;
|
|
125
|
-
} else if (type === "prev-year") {
|
|
126
|
-
day = prevYearDayjs.value;
|
|
127
|
-
} else if (type === "next-year") {
|
|
128
|
-
day = nextYearDayjs.value;
|
|
129
|
-
} else {
|
|
130
|
-
day = now;
|
|
131
|
-
}
|
|
132
|
-
if (day.isSame(date.value, "day"))
|
|
133
|
-
return;
|
|
134
|
-
pickDay(day);
|
|
135
|
-
};
|
|
136
|
-
expose({
|
|
137
|
-
selectedDay: realSelectedDay,
|
|
138
|
-
pickDay,
|
|
139
|
-
selectDate,
|
|
140
|
-
calculateValidatedDateRange
|
|
141
|
-
});
|
|
142
|
-
return (_ctx, _cache) => {
|
|
143
|
-
return openBlock(), createElementBlock("div", {
|
|
144
|
-
class: normalizeClass(unref(ns).b())
|
|
145
|
-
}, [
|
|
146
|
-
createElementVNode("div", {
|
|
147
|
-
class: normalizeClass(unref(ns).e("header"))
|
|
148
|
-
}, [
|
|
149
|
-
renderSlot(_ctx.$slots, "header", { date: unref(i18nDate) }, () => [
|
|
150
|
-
createElementVNode("div", {
|
|
151
|
-
class: normalizeClass(unref(ns).e("title"))
|
|
152
|
-
}, toDisplayString(unref(i18nDate)), 3),
|
|
153
|
-
unref(validatedRange).length === 0 ? (openBlock(), createElementBlock("div", {
|
|
154
|
-
key: 0,
|
|
155
|
-
class: normalizeClass(unref(ns).e("button-group"))
|
|
156
|
-
}, [
|
|
157
|
-
createVNode(unref(ElButtonGroup), null, {
|
|
158
|
-
default: withCtx(() => [
|
|
159
|
-
createVNode(unref(ElButton), {
|
|
160
|
-
size: "small",
|
|
161
|
-
onClick: _cache[0] || (_cache[0] = ($event) => selectDate("prev-month"))
|
|
162
|
-
}, {
|
|
163
|
-
default: withCtx(() => [
|
|
164
|
-
createTextVNode(toDisplayString(unref(t)("el.datepicker.prevMonth")), 1)
|
|
165
|
-
]),
|
|
166
|
-
_: 1
|
|
167
|
-
}),
|
|
168
|
-
createVNode(unref(ElButton), {
|
|
169
|
-
size: "small",
|
|
170
|
-
onClick: _cache[1] || (_cache[1] = ($event) => selectDate("today"))
|
|
171
|
-
}, {
|
|
172
|
-
default: withCtx(() => [
|
|
173
|
-
createTextVNode(toDisplayString(unref(t)("el.datepicker.today")), 1)
|
|
174
|
-
]),
|
|
175
|
-
_: 1
|
|
176
|
-
}),
|
|
177
|
-
createVNode(unref(ElButton), {
|
|
178
|
-
size: "small",
|
|
179
|
-
onClick: _cache[2] || (_cache[2] = ($event) => selectDate("next-month"))
|
|
180
|
-
}, {
|
|
181
|
-
default: withCtx(() => [
|
|
182
|
-
createTextVNode(toDisplayString(unref(t)("el.datepicker.nextMonth")), 1)
|
|
183
|
-
]),
|
|
184
|
-
_: 1
|
|
185
|
-
})
|
|
186
|
-
]),
|
|
187
|
-
_: 1
|
|
188
|
-
})
|
|
189
|
-
], 2)) : createCommentVNode("v-if", true)
|
|
190
|
-
])
|
|
191
|
-
], 2),
|
|
192
|
-
unref(validatedRange).length === 0 ? (openBlock(), createElementBlock("div", {
|
|
193
|
-
key: 0,
|
|
194
|
-
class: normalizeClass(unref(ns).e("body"))
|
|
195
|
-
}, [
|
|
196
|
-
createVNode(DateTable, {
|
|
197
|
-
date: unref(date),
|
|
198
|
-
"selected-day": unref(realSelectedDay),
|
|
199
|
-
onPick: pickDay
|
|
200
|
-
}, createSlots({ _: 2 }, [
|
|
201
|
-
_ctx.$slots.dateCell ? {
|
|
202
|
-
name: "dateCell",
|
|
203
|
-
fn: withCtx((data) => [
|
|
204
|
-
renderSlot(_ctx.$slots, "dateCell", normalizeProps(guardReactiveProps(data)))
|
|
205
|
-
])
|
|
206
|
-
} : void 0
|
|
207
|
-
]), 1032, ["date", "selected-day"])
|
|
208
|
-
], 2)) : (openBlock(), createElementBlock("div", {
|
|
209
|
-
key: 1,
|
|
210
|
-
class: normalizeClass(unref(ns).e("body"))
|
|
211
|
-
}, [
|
|
212
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(validatedRange), (range_, index) => {
|
|
213
|
-
return openBlock(), createBlock(DateTable, {
|
|
214
|
-
key: index,
|
|
215
|
-
date: range_[0],
|
|
216
|
-
"selected-day": unref(realSelectedDay),
|
|
217
|
-
range: range_,
|
|
218
|
-
"hide-header": index !== 0,
|
|
219
|
-
onPick: pickDay
|
|
220
|
-
}, createSlots({ _: 2 }, [
|
|
221
|
-
_ctx.$slots.dateCell ? {
|
|
222
|
-
name: "dateCell",
|
|
223
|
-
fn: withCtx((data) => [
|
|
224
|
-
renderSlot(_ctx.$slots, "dateCell", normalizeProps(guardReactiveProps(data)))
|
|
225
|
-
])
|
|
226
|
-
} : void 0
|
|
227
|
-
]), 1032, ["date", "selected-day", "range", "hide-header"]);
|
|
228
|
-
}), 128))
|
|
229
|
-
], 2))
|
|
230
|
-
], 2);
|
|
231
|
-
};
|
|
7
|
+
const isValidRange = (range) => isArray(range) && range.length === 2 && range.every((item) => isDate(item));
|
|
8
|
+
const calendarProps = buildProps({
|
|
9
|
+
modelValue: {
|
|
10
|
+
type: Date
|
|
11
|
+
},
|
|
12
|
+
range: {
|
|
13
|
+
type: definePropType(Array),
|
|
14
|
+
validator: isValidRange
|
|
232
15
|
}
|
|
233
16
|
});
|
|
234
|
-
|
|
17
|
+
const calendarEmits = {
|
|
18
|
+
[UPDATE_MODEL_EVENT]: (value) => isDate(value),
|
|
19
|
+
[INPUT_EVENT]: (value) => isDate(value)
|
|
20
|
+
};
|
|
235
21
|
|
|
236
|
-
export {
|
|
22
|
+
export { calendarEmits, calendarProps };
|
|
237
23
|
//# sourceMappingURL=calendar2.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar2.mjs","sources":["../../../../../../packages/components/calendar/src/calendar.vue"],"sourcesContent":["<template>\n <div :class=\"ns.b()\">\n <div :class=\"ns.e('header')\">\n <slot name=\"header\" :date=\"i18nDate\">\n <div :class=\"ns.e('title')\">{{ i18nDate }}</div>\n <div v-if=\"validatedRange.length === 0\" :class=\"ns.e('button-group')\">\n <el-button-group>\n <el-button size=\"small\" @click=\"selectDate('prev-month')\">\n {{ t('el.datepicker.prevMonth') }}\n </el-button>\n <el-button size=\"small\" @click=\"selectDate('today')\">\n {{ t('el.datepicker.today') }}\n </el-button>\n <el-button size=\"small\" @click=\"selectDate('next-month')\">\n {{ t('el.datepicker.nextMonth') }}\n </el-button>\n </el-button-group>\n </div>\n </slot>\n </div>\n <div v-if=\"validatedRange.length === 0\" :class=\"ns.e('body')\">\n <date-table :date=\"date\" :selected-day=\"realSelectedDay\" @pick=\"pickDay\">\n <template v-if=\"$slots.dateCell\" #dateCell=\"data\">\n <slot name=\"dateCell\" v-bind=\"data\" />\n </template>\n </date-table>\n </div>\n <div v-else :class=\"ns.e('body')\">\n <date-table\n v-for=\"(range_, index) in validatedRange\"\n :key=\"index\"\n :date=\"range_[0]\"\n :selected-day=\"realSelectedDay\"\n :range=\"range_\"\n :hide-header=\"index !== 0\"\n @pick=\"pickDay\"\n >\n <template v-if=\"$slots.dateCell\" #dateCell=\"data\">\n <slot name=\"dateCell\" v-bind=\"data\" />\n </template>\n </date-table>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, ref } from 'vue'\nimport dayjs from 'dayjs'\nimport { ElButton, ElButtonGroup } from '@element-plus/components/button'\nimport { useLocale, useNamespace } from '@element-plus/hooks'\nimport { debugWarn } from '@element-plus/utils'\nimport { INPUT_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport DateTable from './date-table.vue'\nimport { calendarEmits, calendarProps } from './calendar'\n\nimport type { CalendarDateType } from './calendar'\nimport type { ComputedRef } from 'vue'\nimport type { Dayjs } from 'dayjs'\n\nconst COMPONENT_NAME = 'ElCalendar'\n\ndefineOptions({\n name: 'ElCalendar',\n})\n\nconst props = defineProps(calendarProps)\nconst emit = defineEmits(calendarEmits)\n\nconst ns = useNamespace('calendar')\nconst { t, lang } = useLocale()\n\nconst selectedDay = ref<Dayjs>()\nconst now = dayjs().locale(lang.value)\n\nconst realSelectedDay = computed<Dayjs | undefined>({\n get() {\n if (!props.modelValue) return selectedDay.value\n return date.value\n },\n set(val) {\n if (!val) return\n selectedDay.value = val\n const result = val.toDate()\n\n emit(INPUT_EVENT, result)\n emit(UPDATE_MODEL_EVENT, result)\n },\n})\n\n// if range is valid, we get a two-digit array\nconst validatedRange = computed(() => {\n if (!props.range) return []\n const rangeArrDayjs = props.range.map((_) => dayjs(_).locale(lang.value))\n const [startDayjs, endDayjs] = rangeArrDayjs\n if (startDayjs.isAfter(endDayjs)) {\n debugWarn(COMPONENT_NAME, 'end time should be greater than start time')\n return []\n }\n if (startDayjs.isSame(endDayjs, 'month')) {\n // same month\n return calculateValidatedDateRange(startDayjs, endDayjs)\n } else {\n // two months\n if (startDayjs.add(1, 'month').month() !== endDayjs.month()) {\n debugWarn(\n COMPONENT_NAME,\n 'start time and end time interval must not exceed two months'\n )\n return []\n }\n return calculateValidatedDateRange(startDayjs, endDayjs)\n }\n})\n\nconst date: ComputedRef<Dayjs> = computed(() => {\n if (!props.modelValue) {\n if (realSelectedDay.value) {\n return realSelectedDay.value\n } else if (validatedRange.value.length) {\n return validatedRange.value[0][0]\n }\n return now\n } else {\n return dayjs(props.modelValue).locale(lang.value)\n }\n})\nconst prevMonthDayjs = computed(() => date.value.subtract(1, 'month').date(1))\nconst nextMonthDayjs = computed(() => date.value.add(1, 'month').date(1))\nconst prevYearDayjs = computed(() => date.value.subtract(1, 'year').date(1))\nconst nextYearDayjs = computed(() => date.value.add(1, 'year').date(1))\n\nconst i18nDate = computed(() => {\n const pickedMonth = `el.datepicker.month${date.value.format('M')}`\n return `${date.value.year()} ${t('el.datepicker.year')} ${t(pickedMonth)}`\n})\n\n// https://github.com/element-plus/element-plus/issues/3155\n// Calculate the validate date range according to the start and end dates\nconst calculateValidatedDateRange = (\n startDayjs: Dayjs,\n endDayjs: Dayjs\n): [Dayjs, Dayjs][] => {\n const firstDay = startDayjs.startOf('week')\n const lastDay = endDayjs.endOf('week')\n const firstMonth = firstDay.get('month')\n const lastMonth = lastDay.get('month')\n\n // Current mouth\n if (firstMonth === lastMonth) {\n return [[firstDay, lastDay]]\n }\n // Two adjacent months\n else if (firstMonth + 1 === lastMonth) {\n const firstMonthLastDay = firstDay.endOf('month')\n const lastMonthFirstDay = lastDay.startOf('month')\n\n // Whether the last day of the first month and the first day of the last month is in the same week\n const isSameWeek = firstMonthLastDay.isSame(lastMonthFirstDay, 'week')\n const lastMonthStartDay = isSameWeek\n ? lastMonthFirstDay.add(1, 'week')\n : lastMonthFirstDay\n\n return [\n [firstDay, firstMonthLastDay],\n [lastMonthStartDay.startOf('week'), lastDay],\n ]\n }\n // Three consecutive months (compatible: 2021-01-30 to 2021-02-28)\n else if (\n firstMonth + 2 === lastMonth ||\n (firstMonth + 1) % 11 === lastMonth\n ) {\n const firstMonthLastDay = firstDay.endOf('month')\n const secondMonthFirstDay = firstDay.add(1, 'month').startOf('month')\n\n // Whether the last day of the first month and the second month is in the same week\n const secondMonthStartDay = firstMonthLastDay.isSame(\n secondMonthFirstDay,\n 'week'\n )\n ? secondMonthFirstDay.add(1, 'week')\n : secondMonthFirstDay\n\n const secondMonthLastDay = secondMonthStartDay.endOf('month')\n const lastMonthFirstDay = lastDay.startOf('month')\n\n // Whether the last day of the second month and the last day of the last month is in the same week\n const lastMonthStartDay = secondMonthLastDay.isSame(\n lastMonthFirstDay,\n 'week'\n )\n ? lastMonthFirstDay.add(1, 'week')\n : lastMonthFirstDay\n\n return [\n [firstDay, firstMonthLastDay],\n [secondMonthStartDay.startOf('week'), secondMonthLastDay],\n [lastMonthStartDay.startOf('week'), lastDay],\n ]\n }\n // Other cases\n else {\n debugWarn(\n COMPONENT_NAME,\n 'start time and end time interval must not exceed two months'\n )\n return []\n }\n}\n\nconst pickDay = (day: Dayjs) => {\n realSelectedDay.value = day\n}\n\nconst selectDate = (type: CalendarDateType) => {\n let day: Dayjs\n if (type === 'prev-month') {\n day = prevMonthDayjs.value\n } else if (type === 'next-month') {\n day = nextMonthDayjs.value\n } else if (type === 'prev-year') {\n day = prevYearDayjs.value\n } else if (type === 'next-year') {\n day = nextYearDayjs.value\n } else {\n day = now\n }\n\n if (day.isSame(date.value, 'day')) return\n pickDay(day)\n}\n\ndefineExpose({\n /** @description currently selected date */\n selectedDay: realSelectedDay,\n /** @description select a specific date */\n pickDay,\n /** @description select date */\n selectDate,\n /** @description Calculate the validate date range according to the start and end dates */\n calculateValidatedDateRange,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2DA,IAAA,MAAA,cAAA,GAAA,YAAA,CAAA;AASA,IAAA,MAAA,EAAA,GAAA,aAAA,UAAA,CAAA,CAAA;AACA,IAAA,MAAA,EAAA,CAAA,EAAA,IAAA,EAAA,GAAA,SAAA,EAAA,CAAA;AAEA,IAAA,MAAA,cAAA,GAAA,EAAA,CAAA;AACA,IAAA,MAAA,GAA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AA,CAAA;AAAA,KACA,CAAA;AAEA,IAAA,MAAA,UAAA,GAAA,CAAA,IAAA,KAAA;AACA,MAAA,IAAA,GAAA,CAAA;AACA,MAAA,IAAA,SAAA,YAAA,EAAA;AACA,QAAA,GAAA,GAAA,cAAA,CAAA,KAAA,CAAA;AAAA,OACA,MAAA,IAAA,SAAA,YAAA,EAAA;AACA,QAAA,GAAA,GAAA,cAAA,CAAA,KAAA,CAAA;AAAA,OACA,MAAA,IAAA,SAAA,WAAA,EAAA;AACA,QAAA,GAAA,GAAA,aAAA,CAAA,KAAA,CAAA;AAAA,OACA,MAAA,IAAA,SAAA,WAAA,EAAA;AACA,QAAA,GAAA,GAAA,aAAA,CAAA,KAAA,CAAA;AAAA,OACA,MAAA;AACA,QAAA,GAAA,GAAA,GAAA,CAAA;AAAA,OACA;AAEA,MAAA,IAAA,GAAA,CAAA,MAAA,CAAA,IAAA,CAAA,KAAA,EAAA,KAAA,CAAA;AAAA,QAAA,OAAA;AACA,MAAA,OAAA,CAAA,GAAA,CAAA,CAAA;AAAA,KACA,CAAA;AAEA,IAAA,MAAA,CAAA;AAAA,MAEA,WAAA,EAAA,eAAA;AAAA,MAEA,OAAA;AAAA,MAEA,UAAA;AAAA,MAEA,2BAAA;AAAA,KACA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"calendar2.mjs","sources":["../../../../../../packages/components/calendar/src/calendar.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n isArray,\n isDate,\n} from '@element-plus/utils'\nimport { INPUT_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport type { ExtractPropTypes } from 'vue'\nimport type Calendar from './calendar.vue'\n\nexport type CalendarDateType =\n | 'prev-month'\n | 'next-month'\n | 'prev-year'\n | 'next-year'\n | 'today'\n\nconst isValidRange = (range: unknown): range is [Date, Date] =>\n isArray(range) && range.length === 2 && range.every((item) => isDate(item))\n\nexport const calendarProps = buildProps({\n modelValue: {\n type: Date,\n },\n range: {\n type: definePropType<[Date, Date]>(Array),\n validator: isValidRange,\n },\n} as const)\nexport type CalendarProps = ExtractPropTypes<typeof calendarProps>\n\nexport const calendarEmits = {\n [UPDATE_MODEL_EVENT]: (value: Date) => isDate(value),\n [INPUT_EVENT]: (value: Date) => isDate(value),\n}\nexport type CalendarEmits = typeof calendarEmits\n\nexport type CalendarInstance = InstanceType<typeof Calendar>\n"],"names":[],"mappings":";;;;;;AAOA,MAAM,YAAY,GAAG,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAChG,MAAC,aAAa,GAAG,UAAU,CAAC;AACxC,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,IAAI;AACd,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,SAAS,EAAE,YAAY;AAC3B,GAAG;AACH,CAAC,EAAE;AACS,MAAC,aAAa,GAAG;AAC7B,EAAE,CAAC,kBAAkB,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC;AAChD,EAAE,CAAC,WAAW,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC;AACzC;;;;"}
|
package/es/components/index.mjs
CHANGED
|
@@ -75,13 +75,13 @@ export { ElPopover, ElPopoverDirective } from './popover/index.mjs';
|
|
|
75
75
|
export { affixEmits, affixProps } from './affix/src/affix.mjs';
|
|
76
76
|
export { alertEffects, alertEmits, alertProps } from './alert/src/alert.mjs';
|
|
77
77
|
export { autocompleteEmits, autocompleteProps } from './autocomplete/src/autocomplete.mjs';
|
|
78
|
-
export { avatarEmits, avatarProps } from './avatar/src/
|
|
78
|
+
export { avatarEmits, avatarProps } from './avatar/src/avatar.mjs';
|
|
79
79
|
export { backtopEmits, backtopProps } from './backtop/src/backtop.mjs';
|
|
80
80
|
export { badgeProps } from './badge/src/badge.mjs';
|
|
81
81
|
export { breadcrumbProps } from './breadcrumb/src/breadcrumb.mjs';
|
|
82
82
|
export { breadcrumbItemProps } from './breadcrumb/src/breadcrumb-item.mjs';
|
|
83
83
|
export { buttonEmits, buttonNativeTypes, buttonProps, buttonTypes } from './button/src/button.mjs';
|
|
84
|
-
export { calendarEmits, calendarProps } from './calendar/src/
|
|
84
|
+
export { calendarEmits, calendarProps } from './calendar/src/calendar2.mjs';
|
|
85
85
|
export { cardProps } from './card/src/card.mjs';
|
|
86
86
|
export { carouselEmits, carouselProps } from './carousel/src/carousel.mjs';
|
|
87
87
|
export { carouselItemProps } from './carousel/src/carousel-item.mjs';
|
|
@@ -119,11 +119,11 @@ export { paginationEmits, paginationProps } from './pagination/src/pagination.mj
|
|
|
119
119
|
export { popconfirmProps } from './popconfirm/src/popconfirm.mjs';
|
|
120
120
|
export { Effect, usePopperProps } from './popper/src/popper.mjs';
|
|
121
121
|
export { usePopperTriggerProps } from './popper/src/trigger.mjs';
|
|
122
|
-
export { usePopperContentEmits, usePopperContentProps, usePopperCoreConfigProps } from './popper/src/
|
|
122
|
+
export { usePopperContentEmits, usePopperContentProps, usePopperCoreConfigProps } from './popper/src/content2.mjs';
|
|
123
123
|
export { usePopperArrowProps } from './popper/src/arrow.mjs';
|
|
124
124
|
export { default as ElPopperArrow } from './popper/src/arrow2.mjs';
|
|
125
125
|
export { default as ElPopperTrigger } from './popper/src/trigger2.mjs';
|
|
126
|
-
export { default as ElPopperContent } from './popper/src/
|
|
126
|
+
export { default as ElPopperContent } from './popper/src/content.mjs';
|
|
127
127
|
export { progressProps } from './progress/src/progress.mjs';
|
|
128
128
|
export { radioEmits, radioProps, radioPropsBase } from './radio/src/radio.mjs';
|
|
129
129
|
export { radioGroupEmits, radioGroupProps } from './radio/src/radio-group.mjs';
|
|
@@ -2,10 +2,10 @@ import '../../utils/index.mjs';
|
|
|
2
2
|
import Popper from './src/popper2.mjs';
|
|
3
3
|
export { default as ElPopperArrow } from './src/arrow2.mjs';
|
|
4
4
|
export { default as ElPopperTrigger } from './src/trigger2.mjs';
|
|
5
|
-
export { default as ElPopperContent } from './src/
|
|
5
|
+
export { default as ElPopperContent } from './src/content.mjs';
|
|
6
6
|
export { Effect, usePopperProps } from './src/popper.mjs';
|
|
7
7
|
export { usePopperTriggerProps } from './src/trigger.mjs';
|
|
8
|
-
export { usePopperContentEmits, usePopperContentProps, usePopperCoreConfigProps } from './src/
|
|
8
|
+
export { usePopperContentEmits, usePopperContentProps, usePopperCoreConfigProps } from './src/content2.mjs';
|
|
9
9
|
export { usePopperArrowProps } from './src/arrow.mjs';
|
|
10
10
|
import { withInstall } from '../../utils/vue/install.mjs';
|
|
11
11
|
|
|
@@ -1,93 +1,213 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineComponent, inject, ref, provide, computed, unref, onMounted, watch, toRefs, onBeforeUnmount, openBlock, createElementBlock, normalizeStyle, normalizeClass, createVNode, withCtx, renderSlot } from 'vue';
|
|
2
|
+
import { NOOP } from '@vue/shared';
|
|
3
|
+
import { isNil } from 'lodash-unified';
|
|
4
|
+
import { createPopper } from '@popperjs/core';
|
|
5
|
+
import '../../focus-trap/index.mjs';
|
|
6
|
+
import '../../../hooks/index.mjs';
|
|
7
|
+
import '../../../tokens/index.mjs';
|
|
2
8
|
import '../../../utils/index.mjs';
|
|
3
|
-
import {
|
|
9
|
+
import { usePopperContentProps, usePopperContentEmits } from './content2.mjs';
|
|
10
|
+
import { unwrapMeasurableEl, buildPopperOptions } from './utils.mjs';
|
|
11
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
12
|
+
import { POPPER_INJECTION_KEY, POPPER_CONTENT_INJECTION_KEY } from '../../../tokens/popper.mjs';
|
|
13
|
+
import { formItemContextKey } from '../../../tokens/form.mjs';
|
|
14
|
+
import { useZIndex } from '../../../hooks/use-z-index/index.mjs';
|
|
15
|
+
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
16
|
+
import { isElement } from '../../../utils/types.mjs';
|
|
17
|
+
import ElFocusTrap from '../../focus-trap/src/focus-trap.mjs';
|
|
4
18
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
const __default__ = {
|
|
20
|
+
name: "ElPopperContent"
|
|
21
|
+
};
|
|
22
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
23
|
+
...__default__,
|
|
24
|
+
props: usePopperContentProps,
|
|
25
|
+
emits: usePopperContentEmits,
|
|
26
|
+
setup(__props, { expose, emit }) {
|
|
27
|
+
const props = __props;
|
|
28
|
+
const { popperInstanceRef, contentRef, triggerRef, role } = inject(POPPER_INJECTION_KEY, void 0);
|
|
29
|
+
const formItemContext = inject(formItemContextKey, void 0);
|
|
30
|
+
const { nextZIndex } = useZIndex();
|
|
31
|
+
const ns = useNamespace("popper");
|
|
32
|
+
const popperContentRef = ref();
|
|
33
|
+
const focusStartRef = ref("first");
|
|
34
|
+
const arrowRef = ref();
|
|
35
|
+
const arrowOffset = ref();
|
|
36
|
+
provide(POPPER_CONTENT_INJECTION_KEY, {
|
|
37
|
+
arrowRef,
|
|
38
|
+
arrowOffset
|
|
39
|
+
});
|
|
40
|
+
if (formItemContext && (formItemContext.addInputId || formItemContext.removeInputId)) {
|
|
41
|
+
provide(formItemContextKey, {
|
|
42
|
+
...formItemContext,
|
|
43
|
+
addInputId: NOOP,
|
|
44
|
+
removeInputId: NOOP
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const contentZIndex = ref(props.zIndex || nextZIndex());
|
|
48
|
+
const trapped = ref(false);
|
|
49
|
+
let triggerTargetAriaStopWatch = void 0;
|
|
50
|
+
const computedReference = computed(() => unwrapMeasurableEl(props.referenceEl) || unref(triggerRef));
|
|
51
|
+
const contentStyle = computed(() => [{ zIndex: unref(contentZIndex) }, props.popperStyle]);
|
|
52
|
+
const contentClass = computed(() => [
|
|
53
|
+
ns.b(),
|
|
54
|
+
ns.is("pure", props.pure),
|
|
55
|
+
ns.is(props.effect),
|
|
56
|
+
props.popperClass
|
|
57
|
+
]);
|
|
58
|
+
const ariaModal = computed(() => {
|
|
59
|
+
return role && role.value === "dialog" ? "false" : void 0;
|
|
60
|
+
});
|
|
61
|
+
const createPopperInstance = ({ referenceEl, popperContentEl, arrowEl }) => {
|
|
62
|
+
const options = buildPopperOptions(props, {
|
|
63
|
+
arrowEl,
|
|
64
|
+
arrowOffset: unref(arrowOffset)
|
|
65
|
+
});
|
|
66
|
+
return createPopper(referenceEl, popperContentEl, options);
|
|
67
|
+
};
|
|
68
|
+
const updatePopper = (shouldUpdateZIndex = true) => {
|
|
69
|
+
var _a;
|
|
70
|
+
(_a = unref(popperInstanceRef)) == null ? void 0 : _a.update();
|
|
71
|
+
shouldUpdateZIndex && (contentZIndex.value = props.zIndex || nextZIndex());
|
|
72
|
+
};
|
|
73
|
+
const togglePopperAlive = () => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
const monitorable = { name: "eventListeners", enabled: props.visible };
|
|
76
|
+
(_b = (_a = unref(popperInstanceRef)) == null ? void 0 : _a.setOptions) == null ? void 0 : _b.call(_a, (options) => ({
|
|
77
|
+
...options,
|
|
78
|
+
modifiers: [...options.modifiers || [], monitorable]
|
|
79
|
+
}));
|
|
80
|
+
updatePopper(false);
|
|
81
|
+
if (props.visible && props.focusOnShow) {
|
|
82
|
+
trapped.value = true;
|
|
83
|
+
} else if (props.visible === false) {
|
|
84
|
+
trapped.value = false;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const onFocusAfterTrapped = () => {
|
|
88
|
+
emit("focus");
|
|
89
|
+
};
|
|
90
|
+
const onFocusAfterReleased = () => {
|
|
91
|
+
focusStartRef.value = "first";
|
|
92
|
+
emit("blur");
|
|
93
|
+
};
|
|
94
|
+
const onFocusInTrap = (event) => {
|
|
95
|
+
var _a;
|
|
96
|
+
if (props.visible && !trapped.value) {
|
|
97
|
+
if (event.target) {
|
|
98
|
+
focusStartRef.value = event.target;
|
|
99
|
+
}
|
|
100
|
+
trapped.value = true;
|
|
101
|
+
if (event.relatedTarget) {
|
|
102
|
+
;
|
|
103
|
+
(_a = event.relatedTarget) == null ? void 0 : _a.focus();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const onFocusoutPrevented = () => {
|
|
108
|
+
if (!props.trapping) {
|
|
109
|
+
trapped.value = false;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const onReleaseRequested = () => {
|
|
113
|
+
trapped.value = false;
|
|
114
|
+
emit("close");
|
|
115
|
+
};
|
|
116
|
+
onMounted(() => {
|
|
117
|
+
let updateHandle;
|
|
118
|
+
watch(computedReference, (referenceEl) => {
|
|
119
|
+
var _a;
|
|
120
|
+
updateHandle == null ? void 0 : updateHandle();
|
|
121
|
+
const popperInstance = unref(popperInstanceRef);
|
|
122
|
+
(_a = popperInstance == null ? void 0 : popperInstance.destroy) == null ? void 0 : _a.call(popperInstance);
|
|
123
|
+
if (referenceEl) {
|
|
124
|
+
const popperContentEl = unref(popperContentRef);
|
|
125
|
+
contentRef.value = popperContentEl;
|
|
126
|
+
popperInstanceRef.value = createPopperInstance({
|
|
127
|
+
referenceEl,
|
|
128
|
+
popperContentEl,
|
|
129
|
+
arrowEl: unref(arrowRef)
|
|
130
|
+
});
|
|
131
|
+
updateHandle = watch(() => referenceEl.getBoundingClientRect(), () => updatePopper(), {
|
|
132
|
+
immediate: true
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
popperInstanceRef.value = void 0;
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
immediate: true
|
|
139
|
+
});
|
|
140
|
+
watch(() => props.triggerTargetEl, (triggerTargetEl, prevTriggerTargetEl) => {
|
|
141
|
+
triggerTargetAriaStopWatch == null ? void 0 : triggerTargetAriaStopWatch();
|
|
142
|
+
triggerTargetAriaStopWatch = void 0;
|
|
143
|
+
const el = unref(triggerTargetEl || popperContentRef.value);
|
|
144
|
+
const prevEl = unref(prevTriggerTargetEl || popperContentRef.value);
|
|
145
|
+
if (isElement(el)) {
|
|
146
|
+
const { ariaLabel, id } = toRefs(props);
|
|
147
|
+
triggerTargetAriaStopWatch = watch([role, ariaLabel, ariaModal, id], (watches) => {
|
|
148
|
+
;
|
|
149
|
+
["role", "aria-label", "aria-modal", "id"].forEach((key, idx) => {
|
|
150
|
+
isNil(watches[idx]) ? el.removeAttribute(key) : el.setAttribute(key, watches[idx]);
|
|
151
|
+
});
|
|
152
|
+
}, { immediate: true });
|
|
153
|
+
}
|
|
154
|
+
if (isElement(prevEl)) {
|
|
155
|
+
;
|
|
156
|
+
["role", "aria-label", "aria-modal", "id"].forEach((key) => {
|
|
157
|
+
prevEl.removeAttribute(key);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}, { immediate: true });
|
|
161
|
+
watch(() => props.visible, togglePopperAlive, { immediate: true });
|
|
162
|
+
watch(() => buildPopperOptions(props, {
|
|
163
|
+
arrowEl: unref(arrowRef),
|
|
164
|
+
arrowOffset: unref(arrowOffset)
|
|
165
|
+
}), (option) => {
|
|
166
|
+
var _a;
|
|
167
|
+
return (_a = popperInstanceRef.value) == null ? void 0 : _a.setOptions(option);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
onBeforeUnmount(() => {
|
|
171
|
+
triggerTargetAriaStopWatch == null ? void 0 : triggerTargetAriaStopWatch();
|
|
172
|
+
triggerTargetAriaStopWatch = void 0;
|
|
173
|
+
});
|
|
174
|
+
expose({
|
|
175
|
+
popperContentRef,
|
|
176
|
+
popperInstanceRef,
|
|
177
|
+
updatePopper,
|
|
178
|
+
contentStyle
|
|
179
|
+
});
|
|
180
|
+
return (_ctx, _cache) => {
|
|
181
|
+
return openBlock(), createElementBlock("div", {
|
|
182
|
+
ref_key: "popperContentRef",
|
|
183
|
+
ref: popperContentRef,
|
|
184
|
+
style: normalizeStyle(unref(contentStyle)),
|
|
185
|
+
class: normalizeClass(unref(contentClass)),
|
|
186
|
+
tabindex: "-1",
|
|
187
|
+
onMouseenter: _cache[0] || (_cache[0] = (e) => _ctx.$emit("mouseenter", e)),
|
|
188
|
+
onMouseleave: _cache[1] || (_cache[1] = (e) => _ctx.$emit("mouseleave", e))
|
|
189
|
+
}, [
|
|
190
|
+
createVNode(unref(ElFocusTrap), {
|
|
191
|
+
trapped: trapped.value,
|
|
192
|
+
"trap-on-focus-in": true,
|
|
193
|
+
"focus-trap-el": popperContentRef.value,
|
|
194
|
+
"focus-start-el": focusStartRef.value,
|
|
195
|
+
onFocusAfterTrapped,
|
|
196
|
+
onFocusAfterReleased,
|
|
197
|
+
onFocusin: onFocusInTrap,
|
|
198
|
+
onFocusoutPrevented,
|
|
199
|
+
onReleaseRequested
|
|
200
|
+
}, {
|
|
201
|
+
default: withCtx(() => [
|
|
202
|
+
renderSlot(_ctx.$slots, "default")
|
|
203
|
+
]),
|
|
204
|
+
_: 3
|
|
205
|
+
}, 8, ["trapped", "focus-trap-el", "focus-start-el"])
|
|
206
|
+
], 38);
|
|
207
|
+
};
|
|
36
208
|
}
|
|
37
209
|
});
|
|
38
|
-
|
|
39
|
-
...usePopperCoreConfigProps,
|
|
40
|
-
id: String,
|
|
41
|
-
style: { type: definePropType([String, Array, Object]) },
|
|
42
|
-
className: { type: definePropType([String, Array, Object]) },
|
|
43
|
-
effect: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: "dark"
|
|
46
|
-
},
|
|
47
|
-
visible: Boolean,
|
|
48
|
-
enterable: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
default: true
|
|
51
|
-
},
|
|
52
|
-
pure: Boolean,
|
|
53
|
-
focusOnShow: {
|
|
54
|
-
type: Boolean,
|
|
55
|
-
default: false
|
|
56
|
-
},
|
|
57
|
-
trapping: {
|
|
58
|
-
type: Boolean,
|
|
59
|
-
default: false
|
|
60
|
-
},
|
|
61
|
-
popperClass: {
|
|
62
|
-
type: definePropType([String, Array, Object])
|
|
63
|
-
},
|
|
64
|
-
popperStyle: {
|
|
65
|
-
type: definePropType([String, Array, Object])
|
|
66
|
-
},
|
|
67
|
-
referenceEl: {
|
|
68
|
-
type: definePropType(Object)
|
|
69
|
-
},
|
|
70
|
-
triggerTargetEl: {
|
|
71
|
-
type: definePropType(Object)
|
|
72
|
-
},
|
|
73
|
-
stopPopperMouseEvent: {
|
|
74
|
-
type: Boolean,
|
|
75
|
-
default: true
|
|
76
|
-
},
|
|
77
|
-
ariaLabel: {
|
|
78
|
-
type: String,
|
|
79
|
-
default: void 0
|
|
80
|
-
},
|
|
81
|
-
virtualTriggering: Boolean,
|
|
82
|
-
zIndex: Number
|
|
83
|
-
});
|
|
84
|
-
const usePopperContentEmits = [
|
|
85
|
-
"mouseenter",
|
|
86
|
-
"mouseleave",
|
|
87
|
-
"focus",
|
|
88
|
-
"blur",
|
|
89
|
-
"close"
|
|
90
|
-
];
|
|
210
|
+
var ElPopperContent = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/popper/src/content.vue"]]);
|
|
91
211
|
|
|
92
|
-
export {
|
|
212
|
+
export { ElPopperContent as default };
|
|
93
213
|
//# sourceMappingURL=content.mjs.map
|