@element-plus/nightly 0.0.20240123 → 0.0.20240124
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 +2 -2
- package/dist/index.full.min.js +2 -2
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +2 -2
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +2 -2
- 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/divider/index.mjs +2 -2
- package/es/components/divider/src/divider.mjs +35 -17
- package/es/components/divider/src/divider.mjs.map +1 -1
- package/es/components/divider/src/divider2.mjs +17 -35
- package/es/components/divider/src/divider2.mjs.map +1 -1
- package/es/components/form/index.mjs +2 -2
- package/es/components/form/src/form.mjs +54 -152
- package/es/components/form/src/form.mjs.map +1 -1
- package/es/components/form/src/form2.mjs +152 -54
- package/es/components/form/src/form2.mjs.map +1 -1
- package/es/components/index.mjs +4 -4
- package/es/components/menu/index.mjs +2 -2
- package/es/components/menu/src/menu-item.mjs +97 -14
- package/es/components/menu/src/menu-item.mjs.map +1 -1
- package/es/components/menu/src/menu-item2.mjs +14 -97
- package/es/components/menu/src/menu-item2.mjs.map +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/time-select/index.mjs +1 -1
- package/es/components/time-select/src/time-select.mjs +48 -120
- package/es/components/time-select/src/time-select.mjs.map +1 -1
- package/es/components/time-select/src/time-select2.mjs +120 -48
- package/es/components/time-select/src/time-select2.mjs.map +1 -1
- package/es/components/tour/src/content.mjs +44 -63
- package/es/components/tour/src/content.mjs.map +1 -1
- package/es/components/tour/src/content2.mjs +63 -44
- package/es/components/tour/src/content2.mjs.map +1 -1
- package/es/components/tour/src/step.mjs +1 -1
- package/es/components/tour/src/tour.mjs +1 -1
- package/es/components/tour/src/tour2.mjs +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/divider/index.js +2 -2
- package/lib/components/divider/src/divider.js +35 -17
- package/lib/components/divider/src/divider.js.map +1 -1
- package/lib/components/divider/src/divider2.js +17 -35
- package/lib/components/divider/src/divider2.js.map +1 -1
- package/lib/components/form/index.js +2 -2
- package/lib/components/form/src/form.js +54 -151
- package/lib/components/form/src/form.js.map +1 -1
- package/lib/components/form/src/form2.js +151 -54
- package/lib/components/form/src/form2.js.map +1 -1
- package/lib/components/index.js +4 -4
- package/lib/components/menu/index.js +2 -2
- package/lib/components/menu/src/menu-item.js +97 -15
- package/lib/components/menu/src/menu-item.js.map +1 -1
- package/lib/components/menu/src/menu-item2.js +15 -97
- package/lib/components/menu/src/menu-item2.js.map +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/time-select/index.js +1 -1
- package/lib/components/time-select/src/time-select.js +48 -125
- package/lib/components/time-select/src/time-select.js.map +1 -1
- package/lib/components/time-select/src/time-select2.js +125 -48
- package/lib/components/time-select/src/time-select2.js.map +1 -1
- package/lib/components/tour/src/content.js +45 -63
- package/lib/components/tour/src/content.js.map +1 -1
- package/lib/components/tour/src/content2.js +63 -45
- package/lib/components/tour/src/content2.js.map +1 -1
- package/lib/components/tour/src/step.js +1 -1
- package/lib/components/tour/src/tour.js +1 -1
- package/lib/components/tour/src/tour2.js +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 +1 -1
- package/web-types.json +1 -1
|
@@ -1,20 +1,103 @@
|
|
|
1
|
+
import { defineComponent, getCurrentInstance, inject, toRef, computed, reactive, onMounted, onBeforeUnmount, resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, withCtx, renderSlot, createElementVNode, Fragment } from 'vue';
|
|
2
|
+
import { ElTooltip } from '../../tooltip/index.mjs';
|
|
1
3
|
import '../../../utils/index.mjs';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
+
import '../../../hooks/index.mjs';
|
|
5
|
+
import useMenu from './use-menu.mjs';
|
|
6
|
+
import { menuItemProps, menuItemEmits } from './menu-item2.mjs';
|
|
7
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
8
|
+
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
9
|
+
import { throwError } from '../../../utils/error.mjs';
|
|
4
10
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
const COMPONENT_NAME = "ElMenuItem";
|
|
12
|
+
const _sfc_main = defineComponent({
|
|
13
|
+
name: COMPONENT_NAME,
|
|
14
|
+
components: {
|
|
15
|
+
ElTooltip
|
|
9
16
|
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
17
|
+
props: menuItemProps,
|
|
18
|
+
emits: menuItemEmits,
|
|
19
|
+
setup(props, { emit }) {
|
|
20
|
+
const instance = getCurrentInstance();
|
|
21
|
+
const rootMenu = inject("rootMenu");
|
|
22
|
+
const nsMenu = useNamespace("menu");
|
|
23
|
+
const nsMenuItem = useNamespace("menu-item");
|
|
24
|
+
if (!rootMenu)
|
|
25
|
+
throwError(COMPONENT_NAME, "can not inject root menu");
|
|
26
|
+
const { parentMenu, indexPath } = useMenu(instance, toRef(props, "index"));
|
|
27
|
+
const subMenu = inject(`subMenu:${parentMenu.value.uid}`);
|
|
28
|
+
if (!subMenu)
|
|
29
|
+
throwError(COMPONENT_NAME, "can not inject sub menu");
|
|
30
|
+
const active = computed(() => props.index === rootMenu.activeIndex);
|
|
31
|
+
const item = reactive({
|
|
32
|
+
index: props.index,
|
|
33
|
+
indexPath,
|
|
34
|
+
active
|
|
35
|
+
});
|
|
36
|
+
const handleClick = () => {
|
|
37
|
+
if (!props.disabled) {
|
|
38
|
+
rootMenu.handleMenuItemClick({
|
|
39
|
+
index: props.index,
|
|
40
|
+
indexPath: indexPath.value,
|
|
41
|
+
route: props.route
|
|
42
|
+
});
|
|
43
|
+
emit("click", item);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
onMounted(() => {
|
|
47
|
+
subMenu.addSubMenu(item);
|
|
48
|
+
rootMenu.addMenuItem(item);
|
|
49
|
+
});
|
|
50
|
+
onBeforeUnmount(() => {
|
|
51
|
+
subMenu.removeSubMenu(item);
|
|
52
|
+
rootMenu.removeMenuItem(item);
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
parentMenu,
|
|
56
|
+
rootMenu,
|
|
57
|
+
active,
|
|
58
|
+
nsMenu,
|
|
59
|
+
nsMenuItem,
|
|
60
|
+
handleClick
|
|
61
|
+
};
|
|
62
|
+
}
|
|
14
63
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
64
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
65
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
66
|
+
return openBlock(), createElementBlock("li", {
|
|
67
|
+
class: normalizeClass([
|
|
68
|
+
_ctx.nsMenuItem.b(),
|
|
69
|
+
_ctx.nsMenuItem.is("active", _ctx.active),
|
|
70
|
+
_ctx.nsMenuItem.is("disabled", _ctx.disabled)
|
|
71
|
+
]),
|
|
72
|
+
role: "menuitem",
|
|
73
|
+
tabindex: "-1",
|
|
74
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
|
|
75
|
+
}, [
|
|
76
|
+
_ctx.parentMenu.type.name === "ElMenu" && _ctx.rootMenu.props.collapse && _ctx.$slots.title ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
77
|
+
key: 0,
|
|
78
|
+
effect: _ctx.rootMenu.props.popperEffect,
|
|
79
|
+
placement: "right",
|
|
80
|
+
"fallback-placements": ["left"],
|
|
81
|
+
persistent: ""
|
|
82
|
+
}, {
|
|
83
|
+
content: withCtx(() => [
|
|
84
|
+
renderSlot(_ctx.$slots, "title")
|
|
85
|
+
]),
|
|
86
|
+
default: withCtx(() => [
|
|
87
|
+
createElementVNode("div", {
|
|
88
|
+
class: normalizeClass(_ctx.nsMenu.be("tooltip", "trigger"))
|
|
89
|
+
}, [
|
|
90
|
+
renderSlot(_ctx.$slots, "default")
|
|
91
|
+
], 2)
|
|
92
|
+
]),
|
|
93
|
+
_: 3
|
|
94
|
+
}, 8, ["effect"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
95
|
+
renderSlot(_ctx.$slots, "default"),
|
|
96
|
+
renderSlot(_ctx.$slots, "title")
|
|
97
|
+
], 64))
|
|
98
|
+
], 2);
|
|
99
|
+
}
|
|
100
|
+
var MenuItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "menu-item.vue"]]);
|
|
18
101
|
|
|
19
|
-
export {
|
|
102
|
+
export { MenuItem as default };
|
|
20
103
|
//# sourceMappingURL=menu-item.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item.mjs","sources":["../../../../../../packages/components/menu/src/menu-item.
|
|
1
|
+
{"version":3,"file":"menu-item.mjs","sources":["../../../../../../packages/components/menu/src/menu-item.vue"],"sourcesContent":["<template>\n <li\n :class=\"[\n nsMenuItem.b(),\n nsMenuItem.is('active', active),\n nsMenuItem.is('disabled', disabled),\n ]\"\n role=\"menuitem\"\n tabindex=\"-1\"\n @click=\"handleClick\"\n >\n <el-tooltip\n v-if=\"\n parentMenu.type.name === 'ElMenu' &&\n rootMenu.props.collapse &&\n $slots.title\n \"\n :effect=\"rootMenu.props.popperEffect\"\n placement=\"right\"\n :fallback-placements=\"['left']\"\n persistent\n >\n <template #content>\n <slot name=\"title\" />\n </template>\n <div :class=\"nsMenu.be('tooltip', 'trigger')\">\n <slot />\n </div>\n </el-tooltip>\n <template v-else>\n <slot />\n <slot name=\"title\" />\n </template>\n </li>\n</template>\n\n<script lang=\"ts\">\n// @ts-nocheck\nimport {\n computed,\n defineComponent,\n getCurrentInstance,\n inject,\n onBeforeUnmount,\n onMounted,\n reactive,\n toRef,\n} from 'vue'\nimport ElTooltip from '@element-plus/components/tooltip'\nimport { throwError } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport useMenu from './use-menu'\nimport { menuItemEmits, menuItemProps } from './menu-item'\n\nimport type { MenuItemRegistered, MenuProvider, SubMenuProvider } from './types'\n\nconst COMPONENT_NAME = 'ElMenuItem'\nexport default defineComponent({\n name: COMPONENT_NAME,\n components: {\n ElTooltip,\n },\n\n props: menuItemProps,\n emits: menuItemEmits,\n\n setup(props, { emit }) {\n const instance = getCurrentInstance()!\n const rootMenu = inject<MenuProvider>('rootMenu')\n const nsMenu = useNamespace('menu')\n const nsMenuItem = useNamespace('menu-item')\n if (!rootMenu) throwError(COMPONENT_NAME, 'can not inject root menu')\n\n const { parentMenu, indexPath } = useMenu(instance, toRef(props, 'index'))\n\n const subMenu = inject<SubMenuProvider>(`subMenu:${parentMenu.value.uid}`)\n if (!subMenu) throwError(COMPONENT_NAME, 'can not inject sub menu')\n\n const active = computed(() => props.index === rootMenu.activeIndex)\n const item: MenuItemRegistered = reactive({\n index: props.index,\n indexPath,\n active,\n })\n\n const handleClick = () => {\n if (!props.disabled) {\n rootMenu.handleMenuItemClick({\n index: props.index,\n indexPath: indexPath.value,\n route: props.route,\n })\n emit('click', item)\n }\n }\n\n onMounted(() => {\n subMenu.addSubMenu(item)\n rootMenu.addMenuItem(item)\n })\n\n onBeforeUnmount(() => {\n subMenu.removeSubMenu(item)\n rootMenu.removeMenuItem(item)\n })\n\n return {\n parentMenu,\n rootMenu,\n active,\n nsMenu,\n nsMenuItem,\n handleClick,\n }\n },\n})\n</script>\n"],"names":["_createElementBlock","_normalizeClass","_createBlock","_withCtx","_renderSlot","_createElementVNode","_Fragment"],"mappings":"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"}
|
|
@@ -1,103 +1,20 @@
|
|
|
1
|
-
import { defineComponent, getCurrentInstance, inject, toRef, computed, reactive, onMounted, onBeforeUnmount, resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, withCtx, renderSlot, createElementVNode, Fragment } from 'vue';
|
|
2
|
-
import { ElTooltip } from '../../tooltip/index.mjs';
|
|
3
1
|
import '../../../utils/index.mjs';
|
|
4
|
-
import '../../../
|
|
5
|
-
import
|
|
6
|
-
import { menuItemProps, menuItemEmits } from './menu-item.mjs';
|
|
7
|
-
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
8
|
-
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
9
|
-
import { throwError } from '../../../utils/error.mjs';
|
|
2
|
+
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
|
|
3
|
+
import { isString } from '@vue/shared';
|
|
10
4
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
ElTooltip
|
|
5
|
+
const menuItemProps = buildProps({
|
|
6
|
+
index: {
|
|
7
|
+
type: definePropType([String, null]),
|
|
8
|
+
default: null
|
|
16
9
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const rootMenu = inject("rootMenu");
|
|
22
|
-
const nsMenu = useNamespace("menu");
|
|
23
|
-
const nsMenuItem = useNamespace("menu-item");
|
|
24
|
-
if (!rootMenu)
|
|
25
|
-
throwError(COMPONENT_NAME, "can not inject root menu");
|
|
26
|
-
const { parentMenu, indexPath } = useMenu(instance, toRef(props, "index"));
|
|
27
|
-
const subMenu = inject(`subMenu:${parentMenu.value.uid}`);
|
|
28
|
-
if (!subMenu)
|
|
29
|
-
throwError(COMPONENT_NAME, "can not inject sub menu");
|
|
30
|
-
const active = computed(() => props.index === rootMenu.activeIndex);
|
|
31
|
-
const item = reactive({
|
|
32
|
-
index: props.index,
|
|
33
|
-
indexPath,
|
|
34
|
-
active
|
|
35
|
-
});
|
|
36
|
-
const handleClick = () => {
|
|
37
|
-
if (!props.disabled) {
|
|
38
|
-
rootMenu.handleMenuItemClick({
|
|
39
|
-
index: props.index,
|
|
40
|
-
indexPath: indexPath.value,
|
|
41
|
-
route: props.route
|
|
42
|
-
});
|
|
43
|
-
emit("click", item);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
onMounted(() => {
|
|
47
|
-
subMenu.addSubMenu(item);
|
|
48
|
-
rootMenu.addMenuItem(item);
|
|
49
|
-
});
|
|
50
|
-
onBeforeUnmount(() => {
|
|
51
|
-
subMenu.removeSubMenu(item);
|
|
52
|
-
rootMenu.removeMenuItem(item);
|
|
53
|
-
});
|
|
54
|
-
return {
|
|
55
|
-
parentMenu,
|
|
56
|
-
rootMenu,
|
|
57
|
-
active,
|
|
58
|
-
nsMenu,
|
|
59
|
-
nsMenuItem,
|
|
60
|
-
handleClick
|
|
61
|
-
};
|
|
62
|
-
}
|
|
10
|
+
route: {
|
|
11
|
+
type: definePropType([String, Object])
|
|
12
|
+
},
|
|
13
|
+
disabled: Boolean
|
|
63
14
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
class: normalizeClass([
|
|
68
|
-
_ctx.nsMenuItem.b(),
|
|
69
|
-
_ctx.nsMenuItem.is("active", _ctx.active),
|
|
70
|
-
_ctx.nsMenuItem.is("disabled", _ctx.disabled)
|
|
71
|
-
]),
|
|
72
|
-
role: "menuitem",
|
|
73
|
-
tabindex: "-1",
|
|
74
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
|
|
75
|
-
}, [
|
|
76
|
-
_ctx.parentMenu.type.name === "ElMenu" && _ctx.rootMenu.props.collapse && _ctx.$slots.title ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
77
|
-
key: 0,
|
|
78
|
-
effect: _ctx.rootMenu.props.popperEffect,
|
|
79
|
-
placement: "right",
|
|
80
|
-
"fallback-placements": ["left"],
|
|
81
|
-
persistent: ""
|
|
82
|
-
}, {
|
|
83
|
-
content: withCtx(() => [
|
|
84
|
-
renderSlot(_ctx.$slots, "title")
|
|
85
|
-
]),
|
|
86
|
-
default: withCtx(() => [
|
|
87
|
-
createElementVNode("div", {
|
|
88
|
-
class: normalizeClass(_ctx.nsMenu.be("tooltip", "trigger"))
|
|
89
|
-
}, [
|
|
90
|
-
renderSlot(_ctx.$slots, "default")
|
|
91
|
-
], 2)
|
|
92
|
-
]),
|
|
93
|
-
_: 3
|
|
94
|
-
}, 8, ["effect"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
95
|
-
renderSlot(_ctx.$slots, "default"),
|
|
96
|
-
renderSlot(_ctx.$slots, "title")
|
|
97
|
-
], 64))
|
|
98
|
-
], 2);
|
|
99
|
-
}
|
|
100
|
-
var MenuItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "menu-item.vue"]]);
|
|
15
|
+
const menuItemEmits = {
|
|
16
|
+
click: (item) => isString(item.index) && Array.isArray(item.indexPath)
|
|
17
|
+
};
|
|
101
18
|
|
|
102
|
-
export {
|
|
19
|
+
export { menuItemEmits, menuItemProps };
|
|
103
20
|
//# sourceMappingURL=menu-item2.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item2.mjs","sources":["../../../../../../packages/components/menu/src/menu-item.
|
|
1
|
+
{"version":3,"file":"menu-item2.mjs","sources":["../../../../../../packages/components/menu/src/menu-item.ts"],"sourcesContent":["import { buildProps, definePropType, isString } from '@element-plus/utils'\n\nimport type { ExtractPropTypes } from 'vue'\nimport type { RouteLocationRaw } from 'vue-router'\nimport type { MenuItemRegistered } from './types'\n\nexport const menuItemProps = buildProps({\n index: {\n type: definePropType<string | null>([String, null]),\n default: null,\n },\n route: {\n type: definePropType<RouteLocationRaw>([String, Object]),\n },\n disabled: Boolean,\n} as const)\nexport type MenuItemProps = ExtractPropTypes<typeof menuItemProps>\n\nexport const menuItemEmits = {\n click: (item: MenuItemRegistered) =>\n isString(item.index) && Array.isArray(item.indexPath),\n}\nexport type MenuItemEmits = typeof menuItemEmits\n"],"names":[],"mappings":";;;;AACY,MAAC,aAAa,GAAG,UAAU,CAAC;AACxC,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACxC,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1C,GAAG;AACH,EAAE,QAAQ,EAAE,OAAO;AACnB,CAAC,EAAE;AACS,MAAC,aAAa,GAAG;AAC7B,EAAE,KAAK,EAAE,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;AACxE;;;;"}
|
|
@@ -2,7 +2,7 @@ import '../../utils/index.mjs';
|
|
|
2
2
|
import Scrollbar from './src/scrollbar2.mjs';
|
|
3
3
|
export { BAR_MAP, GAP, renderThumbStyle } from './src/util.mjs';
|
|
4
4
|
export { scrollbarEmits, scrollbarProps } from './src/scrollbar.mjs';
|
|
5
|
-
export { thumbProps } from './src/
|
|
5
|
+
export { thumbProps } from './src/thumb.mjs';
|
|
6
6
|
export { scrollbarContextKey } from './src/constants.mjs';
|
|
7
7
|
import { withInstall } from '../../utils/vue/install.mjs';
|
|
8
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, ref, openBlock, createElementBlock, Fragment, createVNode } from 'vue';
|
|
2
2
|
import { GAP } from './util.mjs';
|
|
3
|
-
import Thumb from './
|
|
3
|
+
import Thumb from './thumb2.mjs';
|
|
4
4
|
import { barProps } from './bar.mjs';
|
|
5
5
|
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
6
6
|
|
|
@@ -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
|