@element-plus/nightly 0.0.20240118 → 0.0.20240120
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.full.js +29 -17
- package/dist/index.full.min.js +3 -3
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +7 -7
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +29 -17
- 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-eg.js +1 -1
- package/dist/locale/ar-eg.min.js +1 -1
- package/dist/locale/ar-eg.min.mjs +1 -1
- package/dist/locale/ar-eg.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/ckb.js +1 -1
- package/dist/locale/ckb.min.js +1 -1
- package/dist/locale/ckb.min.mjs +1 -1
- package/dist/locale/ckb.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/sw.js +1 -1
- package/dist/locale/sw.min.js +1 -1
- package/dist/locale/sw.min.mjs +1 -1
- package/dist/locale/sw.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/alert/index.mjs +2 -2
- package/es/components/alert/src/alert.mjs +96 -36
- package/es/components/alert/src/alert.mjs.map +1 -1
- package/es/components/alert/src/alert2.mjs +36 -96
- package/es/components/alert/src/alert2.mjs.map +1 -1
- package/es/components/breadcrumb/index.mjs +4 -4
- package/es/components/breadcrumb/src/breadcrumb-item.mjs +56 -11
- package/es/components/breadcrumb/src/breadcrumb-item.mjs.map +1 -1
- package/es/components/breadcrumb/src/breadcrumb-item2.mjs +11 -56
- package/es/components/breadcrumb/src/breadcrumb-item2.mjs.map +1 -1
- package/es/components/breadcrumb/src/breadcrumb.mjs +36 -11
- package/es/components/breadcrumb/src/breadcrumb.mjs.map +1 -1
- package/es/components/breadcrumb/src/breadcrumb2.mjs +11 -36
- package/es/components/breadcrumb/src/breadcrumb2.mjs.map +1 -1
- package/es/components/index.mjs +4 -4
- package/es/components/pagination/src/components/pager.mjs +17 -216
- package/es/components/pagination/src/components/pager.mjs.map +1 -1
- package/es/components/pagination/src/components/pager2.mjs +216 -17
- package/es/components/pagination/src/components/pager2.mjs.map +1 -1
- package/es/components/pagination/src/pagination.mjs +1 -1
- package/es/components/scrollbar/index.mjs +1 -1
- package/es/components/scrollbar/src/bar2.mjs +1 -1
- package/es/components/scrollbar/src/thumb.mjs +11 -130
- package/es/components/scrollbar/src/thumb.mjs.map +1 -1
- package/es/components/scrollbar/src/thumb2.mjs +130 -11
- package/es/components/scrollbar/src/thumb2.mjs.map +1 -1
- package/es/components/space/src/use-space.mjs +7 -8
- package/es/components/space/src/use-space.mjs.map +1 -1
- package/es/components/tour/index.d.ts +9 -9
- package/es/components/tour/src/helper.d.ts +1 -1
- package/es/components/tour/src/helper.mjs +20 -7
- package/es/components/tour/src/helper.mjs.map +1 -1
- package/es/components/tour/src/step.d.ts +1 -1
- package/es/components/tour/src/step.mjs +1 -1
- package/es/components/tour/src/step.mjs.map +1 -1
- package/es/components/tour/src/step.vue.d.ts +3 -3
- package/es/components/tour/src/tour.vue.d.ts +3 -3
- package/es/components/tour/src/types.d.ts +1 -1
- package/es/index.mjs +4 -4
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/version.mjs.map +1 -1
- package/lib/components/alert/index.js +2 -2
- package/lib/components/alert/src/alert.js +95 -37
- package/lib/components/alert/src/alert.js.map +1 -1
- package/lib/components/alert/src/alert2.js +37 -95
- package/lib/components/alert/src/alert2.js.map +1 -1
- package/lib/components/breadcrumb/index.js +4 -4
- package/lib/components/breadcrumb/src/breadcrumb-item.js +56 -11
- package/lib/components/breadcrumb/src/breadcrumb-item.js.map +1 -1
- package/lib/components/breadcrumb/src/breadcrumb-item2.js +11 -56
- package/lib/components/breadcrumb/src/breadcrumb-item2.js.map +1 -1
- package/lib/components/breadcrumb/src/breadcrumb.js +36 -11
- package/lib/components/breadcrumb/src/breadcrumb.js.map +1 -1
- package/lib/components/breadcrumb/src/breadcrumb2.js +11 -36
- package/lib/components/breadcrumb/src/breadcrumb2.js.map +1 -1
- package/lib/components/index.js +4 -4
- package/lib/components/pagination/src/components/pager.js +17 -216
- package/lib/components/pagination/src/components/pager.js.map +1 -1
- package/lib/components/pagination/src/components/pager2.js +216 -17
- package/lib/components/pagination/src/components/pager2.js.map +1 -1
- package/lib/components/pagination/src/pagination.js +1 -1
- package/lib/components/scrollbar/index.js +1 -1
- package/lib/components/scrollbar/src/bar2.js +1 -1
- package/lib/components/scrollbar/src/thumb.js +11 -130
- package/lib/components/scrollbar/src/thumb.js.map +1 -1
- package/lib/components/scrollbar/src/thumb2.js +130 -11
- package/lib/components/scrollbar/src/thumb2.js.map +1 -1
- package/lib/components/space/src/use-space.js +7 -8
- package/lib/components/space/src/use-space.js.map +1 -1
- package/lib/components/tour/index.d.ts +9 -9
- package/lib/components/tour/src/helper.d.ts +1 -1
- package/lib/components/tour/src/helper.js +19 -6
- package/lib/components/tour/src/helper.js.map +1 -1
- package/lib/components/tour/src/step.d.ts +1 -1
- package/lib/components/tour/src/step.js +1 -1
- package/lib/components/tour/src/step.js.map +1 -1
- package/lib/components/tour/src/step.vue.d.ts +3 -3
- package/lib/components/tour/src/tour.vue.d.ts +3 -3
- package/lib/components/tour/src/types.d.ts +1 -1
- package/lib/index.js +4 -4
- 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/web-types.json +1 -1
|
@@ -1,135 +1,16 @@
|
|
|
1
|
-
import { defineComponent, inject, ref, computed, onBeforeUnmount, toRef, openBlock, createBlock, Transition, unref, withCtx, withDirectives, createElementVNode, normalizeClass, normalizeStyle, vShow } from 'vue';
|
|
2
|
-
import { isClient, useEventListener } from '@vueuse/core';
|
|
3
1
|
import '../../../utils/index.mjs';
|
|
4
|
-
import '../../../
|
|
5
|
-
import { scrollbarContextKey } from './constants.mjs';
|
|
6
|
-
import { BAR_MAP, renderThumbStyle } from './util.mjs';
|
|
7
|
-
import { thumbProps } from './thumb2.mjs';
|
|
8
|
-
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
9
|
-
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
10
|
-
import { throwError } from '../../../utils/error.mjs';
|
|
2
|
+
import { buildProps } from '../../../utils/vue/props/runtime.mjs';
|
|
11
3
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
throwError(COMPONENT_NAME, "can not inject scrollbar context");
|
|
22
|
-
const instance = ref();
|
|
23
|
-
const thumb = ref();
|
|
24
|
-
const thumbState = ref({});
|
|
25
|
-
const visible = ref(false);
|
|
26
|
-
let cursorDown = false;
|
|
27
|
-
let cursorLeave = false;
|
|
28
|
-
let originalOnSelectStart = isClient ? document.onselectstart : null;
|
|
29
|
-
const bar = computed(() => BAR_MAP[props.vertical ? "vertical" : "horizontal"]);
|
|
30
|
-
const thumbStyle = computed(() => renderThumbStyle({
|
|
31
|
-
size: props.size,
|
|
32
|
-
move: props.move,
|
|
33
|
-
bar: bar.value
|
|
34
|
-
}));
|
|
35
|
-
const offsetRatio = computed(() => instance.value[bar.value.offset] ** 2 / scrollbar.wrapElement[bar.value.scrollSize] / props.ratio / thumb.value[bar.value.offset]);
|
|
36
|
-
const clickThumbHandler = (e) => {
|
|
37
|
-
var _a;
|
|
38
|
-
e.stopPropagation();
|
|
39
|
-
if (e.ctrlKey || [1, 2].includes(e.button))
|
|
40
|
-
return;
|
|
41
|
-
(_a = window.getSelection()) == null ? void 0 : _a.removeAllRanges();
|
|
42
|
-
startDrag(e);
|
|
43
|
-
const el = e.currentTarget;
|
|
44
|
-
if (!el)
|
|
45
|
-
return;
|
|
46
|
-
thumbState.value[bar.value.axis] = el[bar.value.offset] - (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction]);
|
|
47
|
-
};
|
|
48
|
-
const clickTrackHandler = (e) => {
|
|
49
|
-
if (!thumb.value || !instance.value || !scrollbar.wrapElement)
|
|
50
|
-
return;
|
|
51
|
-
const offset = Math.abs(e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]);
|
|
52
|
-
const thumbHalf = thumb.value[bar.value.offset] / 2;
|
|
53
|
-
const thumbPositionPercentage = (offset - thumbHalf) * 100 * offsetRatio.value / instance.value[bar.value.offset];
|
|
54
|
-
scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
|
|
55
|
-
};
|
|
56
|
-
const startDrag = (e) => {
|
|
57
|
-
e.stopImmediatePropagation();
|
|
58
|
-
cursorDown = true;
|
|
59
|
-
document.addEventListener("mousemove", mouseMoveDocumentHandler);
|
|
60
|
-
document.addEventListener("mouseup", mouseUpDocumentHandler);
|
|
61
|
-
originalOnSelectStart = document.onselectstart;
|
|
62
|
-
document.onselectstart = () => false;
|
|
63
|
-
};
|
|
64
|
-
const mouseMoveDocumentHandler = (e) => {
|
|
65
|
-
if (!instance.value || !thumb.value)
|
|
66
|
-
return;
|
|
67
|
-
if (cursorDown === false)
|
|
68
|
-
return;
|
|
69
|
-
const prevPage = thumbState.value[bar.value.axis];
|
|
70
|
-
if (!prevPage)
|
|
71
|
-
return;
|
|
72
|
-
const offset = (instance.value.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) * -1;
|
|
73
|
-
const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
|
|
74
|
-
const thumbPositionPercentage = (offset - thumbClickPosition) * 100 * offsetRatio.value / instance.value[bar.value.offset];
|
|
75
|
-
scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
|
|
76
|
-
};
|
|
77
|
-
const mouseUpDocumentHandler = () => {
|
|
78
|
-
cursorDown = false;
|
|
79
|
-
thumbState.value[bar.value.axis] = 0;
|
|
80
|
-
document.removeEventListener("mousemove", mouseMoveDocumentHandler);
|
|
81
|
-
document.removeEventListener("mouseup", mouseUpDocumentHandler);
|
|
82
|
-
restoreOnselectstart();
|
|
83
|
-
if (cursorLeave)
|
|
84
|
-
visible.value = false;
|
|
85
|
-
};
|
|
86
|
-
const mouseMoveScrollbarHandler = () => {
|
|
87
|
-
cursorLeave = false;
|
|
88
|
-
visible.value = !!props.size;
|
|
89
|
-
};
|
|
90
|
-
const mouseLeaveScrollbarHandler = () => {
|
|
91
|
-
cursorLeave = true;
|
|
92
|
-
visible.value = cursorDown;
|
|
93
|
-
};
|
|
94
|
-
onBeforeUnmount(() => {
|
|
95
|
-
restoreOnselectstart();
|
|
96
|
-
document.removeEventListener("mouseup", mouseUpDocumentHandler);
|
|
97
|
-
});
|
|
98
|
-
const restoreOnselectstart = () => {
|
|
99
|
-
if (document.onselectstart !== originalOnSelectStart)
|
|
100
|
-
document.onselectstart = originalOnSelectStart;
|
|
101
|
-
};
|
|
102
|
-
useEventListener(toRef(scrollbar, "scrollbarElement"), "mousemove", mouseMoveScrollbarHandler);
|
|
103
|
-
useEventListener(toRef(scrollbar, "scrollbarElement"), "mouseleave", mouseLeaveScrollbarHandler);
|
|
104
|
-
return (_ctx, _cache) => {
|
|
105
|
-
return openBlock(), createBlock(Transition, {
|
|
106
|
-
name: unref(ns).b("fade"),
|
|
107
|
-
persisted: ""
|
|
108
|
-
}, {
|
|
109
|
-
default: withCtx(() => [
|
|
110
|
-
withDirectives(createElementVNode("div", {
|
|
111
|
-
ref_key: "instance",
|
|
112
|
-
ref: instance,
|
|
113
|
-
class: normalizeClass([unref(ns).e("bar"), unref(ns).is(unref(bar).key)]),
|
|
114
|
-
onMousedown: clickTrackHandler
|
|
115
|
-
}, [
|
|
116
|
-
createElementVNode("div", {
|
|
117
|
-
ref_key: "thumb",
|
|
118
|
-
ref: thumb,
|
|
119
|
-
class: normalizeClass(unref(ns).e("thumb")),
|
|
120
|
-
style: normalizeStyle(unref(thumbStyle)),
|
|
121
|
-
onMousedown: clickThumbHandler
|
|
122
|
-
}, null, 38)
|
|
123
|
-
], 34), [
|
|
124
|
-
[vShow, _ctx.always || visible.value]
|
|
125
|
-
])
|
|
126
|
-
]),
|
|
127
|
-
_: 1
|
|
128
|
-
}, 8, ["name"]);
|
|
129
|
-
};
|
|
130
|
-
}
|
|
4
|
+
const thumbProps = buildProps({
|
|
5
|
+
vertical: Boolean,
|
|
6
|
+
size: String,
|
|
7
|
+
move: Number,
|
|
8
|
+
ratio: {
|
|
9
|
+
type: Number,
|
|
10
|
+
required: true
|
|
11
|
+
},
|
|
12
|
+
always: Boolean
|
|
131
13
|
});
|
|
132
|
-
var Thumb = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "thumb.vue"]]);
|
|
133
14
|
|
|
134
|
-
export {
|
|
15
|
+
export { thumbProps };
|
|
135
16
|
//# sourceMappingURL=thumb.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thumb.mjs","sources":["../../../../../../packages/components/scrollbar/src/thumb.
|
|
1
|
+
{"version":3,"file":"thumb.mjs","sources":["../../../../../../packages/components/scrollbar/src/thumb.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils'\nimport type { ExtractPropTypes } from 'vue'\nimport type Thumb from './thumb.vue'\n\nexport const thumbProps = buildProps({\n vertical: Boolean,\n size: String,\n move: Number,\n ratio: {\n type: Number,\n required: true,\n },\n always: Boolean,\n} as const)\nexport type ThumbProps = ExtractPropTypes<typeof thumbProps>\n\nexport type ThumbInstance = InstanceType<typeof Thumb>\n"],"names":[],"mappings":";;;AACY,MAAC,UAAU,GAAG,UAAU,CAAC;AACrC,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,IAAI,EAAE,MAAM;AACd,EAAE,IAAI,EAAE,MAAM;AACd,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,QAAQ,EAAE,IAAI;AAClB,GAAG;AACH,EAAE,MAAM,EAAE,OAAO;AACjB,CAAC;;;;"}
|
|
@@ -1,16 +1,135 @@
|
|
|
1
|
+
import { defineComponent, inject, ref, computed, onBeforeUnmount, toRef, openBlock, createBlock, Transition, unref, withCtx, withDirectives, createElementVNode, normalizeClass, normalizeStyle, vShow } from 'vue';
|
|
2
|
+
import { isClient, useEventListener } from '@vueuse/core';
|
|
1
3
|
import '../../../utils/index.mjs';
|
|
2
|
-
import
|
|
4
|
+
import '../../../hooks/index.mjs';
|
|
5
|
+
import { scrollbarContextKey } from './constants.mjs';
|
|
6
|
+
import { BAR_MAP, renderThumbStyle } from './util.mjs';
|
|
7
|
+
import { thumbProps } from './thumb.mjs';
|
|
8
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
9
|
+
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
10
|
+
import { throwError } from '../../../utils/error.mjs';
|
|
3
11
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const COMPONENT_NAME = "Thumb";
|
|
13
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
14
|
+
__name: "thumb",
|
|
15
|
+
props: thumbProps,
|
|
16
|
+
setup(__props) {
|
|
17
|
+
const props = __props;
|
|
18
|
+
const scrollbar = inject(scrollbarContextKey);
|
|
19
|
+
const ns = useNamespace("scrollbar");
|
|
20
|
+
if (!scrollbar)
|
|
21
|
+
throwError(COMPONENT_NAME, "can not inject scrollbar context");
|
|
22
|
+
const instance = ref();
|
|
23
|
+
const thumb = ref();
|
|
24
|
+
const thumbState = ref({});
|
|
25
|
+
const visible = ref(false);
|
|
26
|
+
let cursorDown = false;
|
|
27
|
+
let cursorLeave = false;
|
|
28
|
+
let originalOnSelectStart = isClient ? document.onselectstart : null;
|
|
29
|
+
const bar = computed(() => BAR_MAP[props.vertical ? "vertical" : "horizontal"]);
|
|
30
|
+
const thumbStyle = computed(() => renderThumbStyle({
|
|
31
|
+
size: props.size,
|
|
32
|
+
move: props.move,
|
|
33
|
+
bar: bar.value
|
|
34
|
+
}));
|
|
35
|
+
const offsetRatio = computed(() => instance.value[bar.value.offset] ** 2 / scrollbar.wrapElement[bar.value.scrollSize] / props.ratio / thumb.value[bar.value.offset]);
|
|
36
|
+
const clickThumbHandler = (e) => {
|
|
37
|
+
var _a;
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
if (e.ctrlKey || [1, 2].includes(e.button))
|
|
40
|
+
return;
|
|
41
|
+
(_a = window.getSelection()) == null ? void 0 : _a.removeAllRanges();
|
|
42
|
+
startDrag(e);
|
|
43
|
+
const el = e.currentTarget;
|
|
44
|
+
if (!el)
|
|
45
|
+
return;
|
|
46
|
+
thumbState.value[bar.value.axis] = el[bar.value.offset] - (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction]);
|
|
47
|
+
};
|
|
48
|
+
const clickTrackHandler = (e) => {
|
|
49
|
+
if (!thumb.value || !instance.value || !scrollbar.wrapElement)
|
|
50
|
+
return;
|
|
51
|
+
const offset = Math.abs(e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]);
|
|
52
|
+
const thumbHalf = thumb.value[bar.value.offset] / 2;
|
|
53
|
+
const thumbPositionPercentage = (offset - thumbHalf) * 100 * offsetRatio.value / instance.value[bar.value.offset];
|
|
54
|
+
scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
|
|
55
|
+
};
|
|
56
|
+
const startDrag = (e) => {
|
|
57
|
+
e.stopImmediatePropagation();
|
|
58
|
+
cursorDown = true;
|
|
59
|
+
document.addEventListener("mousemove", mouseMoveDocumentHandler);
|
|
60
|
+
document.addEventListener("mouseup", mouseUpDocumentHandler);
|
|
61
|
+
originalOnSelectStart = document.onselectstart;
|
|
62
|
+
document.onselectstart = () => false;
|
|
63
|
+
};
|
|
64
|
+
const mouseMoveDocumentHandler = (e) => {
|
|
65
|
+
if (!instance.value || !thumb.value)
|
|
66
|
+
return;
|
|
67
|
+
if (cursorDown === false)
|
|
68
|
+
return;
|
|
69
|
+
const prevPage = thumbState.value[bar.value.axis];
|
|
70
|
+
if (!prevPage)
|
|
71
|
+
return;
|
|
72
|
+
const offset = (instance.value.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) * -1;
|
|
73
|
+
const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
|
|
74
|
+
const thumbPositionPercentage = (offset - thumbClickPosition) * 100 * offsetRatio.value / instance.value[bar.value.offset];
|
|
75
|
+
scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
|
|
76
|
+
};
|
|
77
|
+
const mouseUpDocumentHandler = () => {
|
|
78
|
+
cursorDown = false;
|
|
79
|
+
thumbState.value[bar.value.axis] = 0;
|
|
80
|
+
document.removeEventListener("mousemove", mouseMoveDocumentHandler);
|
|
81
|
+
document.removeEventListener("mouseup", mouseUpDocumentHandler);
|
|
82
|
+
restoreOnselectstart();
|
|
83
|
+
if (cursorLeave)
|
|
84
|
+
visible.value = false;
|
|
85
|
+
};
|
|
86
|
+
const mouseMoveScrollbarHandler = () => {
|
|
87
|
+
cursorLeave = false;
|
|
88
|
+
visible.value = !!props.size;
|
|
89
|
+
};
|
|
90
|
+
const mouseLeaveScrollbarHandler = () => {
|
|
91
|
+
cursorLeave = true;
|
|
92
|
+
visible.value = cursorDown;
|
|
93
|
+
};
|
|
94
|
+
onBeforeUnmount(() => {
|
|
95
|
+
restoreOnselectstart();
|
|
96
|
+
document.removeEventListener("mouseup", mouseUpDocumentHandler);
|
|
97
|
+
});
|
|
98
|
+
const restoreOnselectstart = () => {
|
|
99
|
+
if (document.onselectstart !== originalOnSelectStart)
|
|
100
|
+
document.onselectstart = originalOnSelectStart;
|
|
101
|
+
};
|
|
102
|
+
useEventListener(toRef(scrollbar, "scrollbarElement"), "mousemove", mouseMoveScrollbarHandler);
|
|
103
|
+
useEventListener(toRef(scrollbar, "scrollbarElement"), "mouseleave", mouseLeaveScrollbarHandler);
|
|
104
|
+
return (_ctx, _cache) => {
|
|
105
|
+
return openBlock(), createBlock(Transition, {
|
|
106
|
+
name: unref(ns).b("fade"),
|
|
107
|
+
persisted: ""
|
|
108
|
+
}, {
|
|
109
|
+
default: withCtx(() => [
|
|
110
|
+
withDirectives(createElementVNode("div", {
|
|
111
|
+
ref_key: "instance",
|
|
112
|
+
ref: instance,
|
|
113
|
+
class: normalizeClass([unref(ns).e("bar"), unref(ns).is(unref(bar).key)]),
|
|
114
|
+
onMousedown: clickTrackHandler
|
|
115
|
+
}, [
|
|
116
|
+
createElementVNode("div", {
|
|
117
|
+
ref_key: "thumb",
|
|
118
|
+
ref: thumb,
|
|
119
|
+
class: normalizeClass(unref(ns).e("thumb")),
|
|
120
|
+
style: normalizeStyle(unref(thumbStyle)),
|
|
121
|
+
onMousedown: clickThumbHandler
|
|
122
|
+
}, null, 38)
|
|
123
|
+
], 34), [
|
|
124
|
+
[vShow, _ctx.always || visible.value]
|
|
125
|
+
])
|
|
126
|
+
]),
|
|
127
|
+
_: 1
|
|
128
|
+
}, 8, ["name"]);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
13
131
|
});
|
|
132
|
+
var Thumb = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "thumb.vue"]]);
|
|
14
133
|
|
|
15
|
-
export {
|
|
134
|
+
export { Thumb as default };
|
|
16
135
|
//# sourceMappingURL=thumb2.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thumb2.mjs","sources":["../../../../../../packages/components/scrollbar/src/thumb.
|
|
1
|
+
{"version":3,"file":"thumb2.mjs","sources":["../../../../../../packages/components/scrollbar/src/thumb.vue"],"sourcesContent":["<template>\n <transition :name=\"ns.b('fade')\">\n <div\n v-show=\"always || visible\"\n ref=\"instance\"\n :class=\"[ns.e('bar'), ns.is(bar.key)]\"\n @mousedown=\"clickTrackHandler\"\n >\n <div\n ref=\"thumb\"\n :class=\"ns.e('thumb')\"\n :style=\"thumbStyle\"\n @mousedown=\"clickThumbHandler\"\n />\n </div>\n </transition>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, inject, onBeforeUnmount, ref, toRef } from 'vue'\nimport { useEventListener } from '@vueuse/core'\nimport { isClient, throwError } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { scrollbarContextKey } from './constants'\nimport { BAR_MAP, renderThumbStyle } from './util'\nimport { thumbProps } from './thumb'\n\nconst COMPONENT_NAME = 'Thumb'\nconst props = defineProps(thumbProps)\n\nconst scrollbar = inject(scrollbarContextKey)\nconst ns = useNamespace('scrollbar')\n\nif (!scrollbar) throwError(COMPONENT_NAME, 'can not inject scrollbar context')\n\nconst instance = ref<HTMLDivElement>()\nconst thumb = ref<HTMLDivElement>()\n\nconst thumbState = ref<Partial<Record<'X' | 'Y', number>>>({})\nconst visible = ref(false)\n\nlet cursorDown = false\nlet cursorLeave = false\nlet originalOnSelectStart:\n | ((this: GlobalEventHandlers, ev: Event) => any)\n | null = isClient ? document.onselectstart : null\n\nconst bar = computed(() => BAR_MAP[props.vertical ? 'vertical' : 'horizontal'])\n\nconst thumbStyle = computed(() =>\n renderThumbStyle({\n size: props.size,\n move: props.move,\n bar: bar.value,\n })\n)\n\nconst offsetRatio = computed(\n () =>\n // offsetRatioX = original width of thumb / current width of thumb / ratioX\n // offsetRatioY = original height of thumb / current height of thumb / ratioY\n // instance height = wrap height - GAP\n instance.value![bar.value.offset] ** 2 /\n scrollbar.wrapElement![bar.value.scrollSize] /\n props.ratio /\n thumb.value![bar.value.offset]\n)\n\nconst clickThumbHandler = (e: MouseEvent) => {\n // prevent click event of middle and right button\n e.stopPropagation()\n if (e.ctrlKey || [1, 2].includes(e.button)) return\n\n window.getSelection()?.removeAllRanges()\n startDrag(e)\n\n const el = e.currentTarget as HTMLDivElement\n if (!el) return\n thumbState.value[bar.value.axis] =\n el[bar.value.offset] -\n (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction])\n}\n\nconst clickTrackHandler = (e: MouseEvent) => {\n if (!thumb.value || !instance.value || !scrollbar.wrapElement) return\n\n const offset = Math.abs(\n (e.target as HTMLElement).getBoundingClientRect()[bar.value.direction] -\n e[bar.value.client]\n )\n const thumbHalf = thumb.value[bar.value.offset] / 2\n const thumbPositionPercentage =\n ((offset - thumbHalf) * 100 * offsetRatio.value) /\n instance.value[bar.value.offset]\n\n scrollbar.wrapElement[bar.value.scroll] =\n (thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize]) /\n 100\n}\n\nconst startDrag = (e: MouseEvent) => {\n e.stopImmediatePropagation()\n cursorDown = true\n document.addEventListener('mousemove', mouseMoveDocumentHandler)\n document.addEventListener('mouseup', mouseUpDocumentHandler)\n originalOnSelectStart = document.onselectstart\n document.onselectstart = () => false\n}\n\nconst mouseMoveDocumentHandler = (e: MouseEvent) => {\n if (!instance.value || !thumb.value) return\n if (cursorDown === false) return\n\n const prevPage = thumbState.value[bar.value.axis]\n if (!prevPage) return\n\n const offset =\n (instance.value.getBoundingClientRect()[bar.value.direction] -\n e[bar.value.client]) *\n -1\n const thumbClickPosition = thumb.value[bar.value.offset] - prevPage\n const thumbPositionPercentage =\n ((offset - thumbClickPosition) * 100 * offsetRatio.value) /\n instance.value[bar.value.offset]\n scrollbar.wrapElement[bar.value.scroll] =\n (thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize]) /\n 100\n}\n\nconst mouseUpDocumentHandler = () => {\n cursorDown = false\n thumbState.value[bar.value.axis] = 0\n document.removeEventListener('mousemove', mouseMoveDocumentHandler)\n document.removeEventListener('mouseup', mouseUpDocumentHandler)\n restoreOnselectstart()\n if (cursorLeave) visible.value = false\n}\n\nconst mouseMoveScrollbarHandler = () => {\n cursorLeave = false\n visible.value = !!props.size\n}\n\nconst mouseLeaveScrollbarHandler = () => {\n cursorLeave = true\n visible.value = cursorDown\n}\n\nonBeforeUnmount(() => {\n restoreOnselectstart()\n document.removeEventListener('mouseup', mouseUpDocumentHandler)\n})\n\nconst restoreOnselectstart = () => {\n if (document.onselectstart !== originalOnSelectStart)\n document.onselectstart = originalOnSelectStart\n}\n\nuseEventListener(\n toRef(scrollbar, 'scrollbarElement'),\n 'mousemove',\n mouseMoveScrollbarHandler\n)\nuseEventListener(\n toRef(scrollbar, 'scrollbarElement'),\n 'mouseleave',\n mouseLeaveScrollbarHandler\n)\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA8BA,IAAM,MAAA,SAAA,GAAY,OAAO,mBAAmB,CAAA,CAAA;AAC5C,IAAM,MAAA,EAAA,GAAK,aAAa,WAAW,CAAA,CAAA;AAEnC,IAAA,IAAI,CAAC,SAAA;AAAW,MAAA,UAAA,CAAW,gBAAgB,kCAAkC,CAAA,CAAA;AAE7E,IAAA,MAAM,WAAW,GAAoB,EAAA,CAAA;AACrC,IAAA,MAAM,QA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|
|
@@ -16,19 +16,18 @@ function useSpace(props) {
|
|
|
16
16
|
const horizontalSize = ref(0);
|
|
17
17
|
const verticalSize = ref(0);
|
|
18
18
|
const containerStyle = computed(() => {
|
|
19
|
-
const wrapKls = props.wrap || props.fill ? { flexWrap: "wrap"
|
|
19
|
+
const wrapKls = props.wrap || props.fill ? { flexWrap: "wrap" } : {};
|
|
20
20
|
const alignment = {
|
|
21
21
|
alignItems: props.alignment
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
const gap = {
|
|
24
|
+
rowGap: `${verticalSize.value}px`,
|
|
25
|
+
columnGap: `${horizontalSize.value}px`
|
|
26
|
+
};
|
|
27
|
+
return [wrapKls, alignment, gap, props.style];
|
|
24
28
|
});
|
|
25
29
|
const itemStyle = computed(() => {
|
|
26
|
-
|
|
27
|
-
paddingBottom: `${verticalSize.value}px`,
|
|
28
|
-
marginRight: `${horizontalSize.value}px`
|
|
29
|
-
};
|
|
30
|
-
const fillStyle = props.fill ? { flexGrow: 1, minWidth: `${props.fillRatio}%` } : {};
|
|
31
|
-
return [itemBaseStyle, fillStyle];
|
|
30
|
+
return props.fill ? { flexGrow: 1, minWidth: `${props.fillRatio}%` } : {};
|
|
32
31
|
});
|
|
33
32
|
watchEffect(() => {
|
|
34
33
|
const { size = "small", wrap, direction: dir, fill } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-space.mjs","sources":["../../../../../../packages/components/space/src/use-space.ts"],"sourcesContent":["import { computed, ref, watchEffect } from 'vue'\nimport { isArray, isNumber } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\n\nimport type { SpaceProps } from './space'\nimport type { CSSProperties, StyleValue } from 'vue'\n\nconst SIZE_MAP = {\n small: 8,\n default: 12,\n large: 16,\n} as const\n\nexport function useSpace(props: SpaceProps) {\n const ns = useNamespace('space')\n\n const classes = computed(() => [ns.b(), ns.m(props.direction), props.class])\n\n const horizontalSize = ref(0)\n const verticalSize = ref(0)\n\n const containerStyle = computed<StyleValue>(() => {\n const wrapKls: CSSProperties =\n props.wrap || props.fill
|
|
1
|
+
{"version":3,"file":"use-space.mjs","sources":["../../../../../../packages/components/space/src/use-space.ts"],"sourcesContent":["import { computed, ref, watchEffect } from 'vue'\nimport { isArray, isNumber } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\n\nimport type { SpaceProps } from './space'\nimport type { CSSProperties, StyleValue } from 'vue'\n\nconst SIZE_MAP = {\n small: 8,\n default: 12,\n large: 16,\n} as const\n\nexport function useSpace(props: SpaceProps) {\n const ns = useNamespace('space')\n\n const classes = computed(() => [ns.b(), ns.m(props.direction), props.class])\n\n const horizontalSize = ref(0)\n const verticalSize = ref(0)\n\n const containerStyle = computed<StyleValue>(() => {\n const wrapKls: CSSProperties =\n props.wrap || props.fill ? { flexWrap: 'wrap' } : {}\n const alignment: CSSProperties = {\n alignItems: props.alignment,\n }\n const gap: CSSProperties = {\n rowGap: `${verticalSize.value}px`,\n columnGap: `${horizontalSize.value}px`,\n }\n return [wrapKls, alignment, gap, props.style]\n })\n\n const itemStyle = computed<StyleValue>(() => {\n return props.fill ? { flexGrow: 1, minWidth: `${props.fillRatio}%` } : {}\n })\n\n watchEffect(() => {\n const { size = 'small', wrap, direction: dir, fill } = props\n\n // when the specified size have been given\n if (isArray(size)) {\n const [h = 0, v = 0] = size\n horizontalSize.value = h\n verticalSize.value = v\n } else {\n let val: number\n if (isNumber(size)) {\n val = size\n } else {\n val = SIZE_MAP[size || 'small'] || SIZE_MAP.small\n }\n\n if ((wrap || fill) && dir === 'horizontal') {\n horizontalSize.value = verticalSize.value = val\n } else {\n if (dir === 'horizontal') {\n horizontalSize.value = val\n verticalSize.value = 0\n } else {\n verticalSize.value = val\n horizontalSize.value = 0\n }\n }\n }\n })\n\n return {\n classes,\n containerStyle,\n itemStyle,\n }\n}\n"],"names":[],"mappings":";;;;;;;AAGA,MAAM,QAAQ,GAAG;AACjB,EAAE,KAAK,EAAE,CAAC;AACV,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ACJ;;;;"}
|
|
@@ -108,7 +108,7 @@ export declare const ElTour: import("@element-plus/nightly/es/utils").SFCWithIns
|
|
|
108
108
|
cssVarBlockName: (name: string) => string;
|
|
109
109
|
};
|
|
110
110
|
steps: import("vue").Ref<{
|
|
111
|
-
target?: HTMLElement | null | undefined;
|
|
111
|
+
target?: string | HTMLElement | (() => HTMLElement | null) | null | undefined;
|
|
112
112
|
showArrow?: boolean | undefined;
|
|
113
113
|
placement?: import("@floating-ui/core").Placement | undefined;
|
|
114
114
|
contentStyle?: {
|
|
@@ -3184,7 +3184,7 @@ export declare const ElTour: import("@element-plus/nightly/es/utils").SFCWithIns
|
|
|
3184
3184
|
current: import("vue").Ref<number> | import("vue").WritableComputedRef<number>;
|
|
3185
3185
|
total: import("vue").ComputedRef<number>;
|
|
3186
3186
|
currentStep: import("vue").ComputedRef<{
|
|
3187
|
-
target?: HTMLElement | null | undefined;
|
|
3187
|
+
target?: string | HTMLElement | (() => HTMLElement | null) | null | undefined;
|
|
3188
3188
|
showArrow?: boolean | undefined;
|
|
3189
3189
|
placement?: import("@floating-ui/core").Placement | undefined;
|
|
3190
3190
|
contentStyle?: {
|
|
@@ -6257,7 +6257,7 @@ export declare const ElTour: import("@element-plus/nightly/es/utils").SFCWithIns
|
|
|
6257
6257
|
behavior?: ScrollBehavior | undefined;
|
|
6258
6258
|
} | undefined;
|
|
6259
6259
|
}>;
|
|
6260
|
-
currentTarget: import("vue").ComputedRef<HTMLElement | null | undefined>;
|
|
6260
|
+
currentTarget: import("vue").ComputedRef<string | HTMLElement | (() => HTMLElement | null) | null | undefined>;
|
|
6261
6261
|
kls: import("vue").ComputedRef<string[]>;
|
|
6262
6262
|
mergedPlacement: import("vue").ComputedRef<"top" | "bottom" | "right" | "left" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end">;
|
|
6263
6263
|
mergedContentStyle: import("vue").ComputedRef<import("vue").CSSProperties | undefined>;
|
|
@@ -6537,7 +6537,7 @@ export declare const ElTour: import("@element-plus/nightly/es/utils").SFCWithIns
|
|
|
6537
6537
|
}>> & {
|
|
6538
6538
|
TourStep: import("vue").DefineComponent<{
|
|
6539
6539
|
target: {
|
|
6540
|
-
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => HTMLElement) | (() => HTMLElement | null) | ((new (...args: any[]) => HTMLElement) | (() => HTMLElement | null))[], unknown, unknown>>;
|
|
6540
|
+
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null) | ((new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null))[], unknown, unknown>>;
|
|
6541
6541
|
readonly required: false;
|
|
6542
6542
|
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
6543
6543
|
__epPropKey: true;
|
|
@@ -6592,7 +6592,7 @@ export declare const ElTour: import("@element-plus/nightly/es/utils").SFCWithIns
|
|
|
6592
6592
|
}, {
|
|
6593
6593
|
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
6594
6594
|
target: {
|
|
6595
|
-
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => HTMLElement) | (() => HTMLElement | null) | ((new (...args: any[]) => HTMLElement) | (() => HTMLElement | null))[], unknown, unknown>>;
|
|
6595
|
+
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null) | ((new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null))[], unknown, unknown>>;
|
|
6596
6596
|
readonly required: false;
|
|
6597
6597
|
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
6598
6598
|
__epPropKey: true;
|
|
@@ -7020,7 +7020,7 @@ export declare const ElTour: import("@element-plus/nightly/es/utils").SFCWithIns
|
|
|
7020
7020
|
close: () => boolean;
|
|
7021
7021
|
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
7022
7022
|
target: {
|
|
7023
|
-
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => HTMLElement) | (() => HTMLElement | null) | ((new (...args: any[]) => HTMLElement) | (() => HTMLElement | null))[], unknown, unknown>>;
|
|
7023
|
+
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null) | ((new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null))[], unknown, unknown>>;
|
|
7024
7024
|
readonly required: false;
|
|
7025
7025
|
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
7026
7026
|
__epPropKey: true;
|
|
@@ -7082,7 +7082,7 @@ export declare const ElTour: import("@element-plus/nightly/es/utils").SFCWithIns
|
|
|
7082
7082
|
};
|
|
7083
7083
|
export declare const ElTourStep: import("@element-plus/nightly/es/utils").SFCWithInstall<import("vue").DefineComponent<{
|
|
7084
7084
|
target: {
|
|
7085
|
-
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => HTMLElement) | (() => HTMLElement | null) | ((new (...args: any[]) => HTMLElement) | (() => HTMLElement | null))[], unknown, unknown>>;
|
|
7085
|
+
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null) | ((new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null))[], unknown, unknown>>;
|
|
7086
7086
|
readonly required: false;
|
|
7087
7087
|
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
7088
7088
|
__epPropKey: true;
|
|
@@ -7137,7 +7137,7 @@ export declare const ElTourStep: import("@element-plus/nightly/es/utils").SFCWit
|
|
|
7137
7137
|
}, {
|
|
7138
7138
|
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
7139
7139
|
target: {
|
|
7140
|
-
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => HTMLElement) | (() => HTMLElement | null) | ((new (...args: any[]) => HTMLElement) | (() => HTMLElement | null))[], unknown, unknown>>;
|
|
7140
|
+
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null) | ((new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null))[], unknown, unknown>>;
|
|
7141
7141
|
readonly required: false;
|
|
7142
7142
|
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
7143
7143
|
__epPropKey: true;
|
|
@@ -7565,7 +7565,7 @@ export declare const ElTourStep: import("@element-plus/nightly/es/utils").SFCWit
|
|
|
7565
7565
|
close: () => boolean;
|
|
7566
7566
|
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
7567
7567
|
target: {
|
|
7568
|
-
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => HTMLElement) | (() => HTMLElement | null) | ((new (...args: any[]) => HTMLElement) | (() => HTMLElement | null))[], unknown, unknown>>;
|
|
7568
|
+
readonly type: import("vue").PropType<import("@element-plus/nightly/es/utils").EpPropMergeType<(new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null) | ((new (...args: any[]) => (string | HTMLElement | (() => HTMLElement | null) | null) & {}) | (() => string | HTMLElement | (() => HTMLElement | null) | null))[], unknown, unknown>>;
|
|
7569
7569
|
readonly required: false;
|
|
7570
7570
|
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
7571
7571
|
__epPropKey: true;
|
|
@@ -2,7 +2,7 @@ import type { CSSProperties, Component, ComputedRef, InjectionKey, Ref, SetupCon
|
|
|
2
2
|
import type { UseNamespaceReturn } from '@element-plus/nightly/es/hooks';
|
|
3
3
|
import type { TourGap, TourMask } from './types';
|
|
4
4
|
import type { Placement, Strategy, VirtualElement } from '@floating-ui/dom';
|
|
5
|
-
export declare const useTarget: (target: Ref<HTMLElement | null | undefined>, open: Ref<boolean>, gap: Ref<TourGap>, mergedMask: Ref<TourMask>, scrollIntoViewOptions: Ref<boolean | ScrollIntoViewOptions>) => {
|
|
5
|
+
export declare const useTarget: (target: Ref<string | HTMLElement | (() => HTMLElement | null) | null | undefined>, open: Ref<boolean>, gap: Ref<TourGap>, mergedMask: Ref<TourMask>, scrollIntoViewOptions: Ref<boolean | ScrollIntoViewOptions>) => {
|
|
6
6
|
mergedPosInfo: ComputedRef<{
|
|
7
7
|
left: number;
|
|
8
8
|
top: number;
|
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import { ref, onMounted, watch, onBeforeUnmount, computed, isVNode, camelize, unref, watchEffect } from 'vue';
|
|
2
2
|
import { offset, flip, shift, arrow, computePosition, autoUpdate, detectOverflow } from '@floating-ui/dom';
|
|
3
3
|
import '../../../utils/index.mjs';
|
|
4
|
-
import { isArray, hasOwn } from '@vue/shared';
|
|
4
|
+
import { isString, isFunction, isArray, hasOwn } from '@vue/shared';
|
|
5
5
|
import { isClient } from '@vueuse/core';
|
|
6
6
|
import { keysOf } from '../../../utils/objects.mjs';
|
|
7
7
|
|
|
8
8
|
const useTarget = (target, open, gap, mergedMask, scrollIntoViewOptions) => {
|
|
9
9
|
const posInfo = ref(null);
|
|
10
|
+
const getTargetEl = () => {
|
|
11
|
+
let targetEl;
|
|
12
|
+
if (isString(target.value)) {
|
|
13
|
+
targetEl = document.querySelector(target.value);
|
|
14
|
+
} else if (isFunction(target.value)) {
|
|
15
|
+
targetEl = target.value();
|
|
16
|
+
} else {
|
|
17
|
+
targetEl = target.value;
|
|
18
|
+
}
|
|
19
|
+
return targetEl;
|
|
20
|
+
};
|
|
10
21
|
const updatePosInfo = () => {
|
|
11
|
-
|
|
22
|
+
const targetEl = getTargetEl();
|
|
23
|
+
if (!targetEl || !open.value) {
|
|
12
24
|
posInfo.value = null;
|
|
13
25
|
return;
|
|
14
26
|
}
|
|
15
|
-
if (!isInViewPort(
|
|
16
|
-
|
|
27
|
+
if (!isInViewPort(targetEl) && open.value) {
|
|
28
|
+
targetEl.scrollIntoView(scrollIntoViewOptions.value);
|
|
17
29
|
}
|
|
18
|
-
const { left, top, width, height } =
|
|
30
|
+
const { left, top, width, height } = targetEl.getBoundingClientRect();
|
|
19
31
|
posInfo.value = {
|
|
20
32
|
left,
|
|
21
33
|
top,
|
|
@@ -55,8 +67,9 @@ const useTarget = (target, open, gap, mergedMask, scrollIntoViewOptions) => {
|
|
|
55
67
|
};
|
|
56
68
|
});
|
|
57
69
|
const triggerTarget = computed(() => {
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
const targetEl = getTargetEl();
|
|
71
|
+
if (!mergedMask.value || !targetEl || !window.DOMRect) {
|
|
72
|
+
return targetEl || void 0;
|
|
60
73
|
}
|
|
61
74
|
return {
|
|
62
75
|
getBoundingClientRect() {
|