@element-plus/nightly 0.0.20220901 → 0.0.20220902
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 +341 -5764
- package/dist/index.full.min.js +37 -63
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +37 -63
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +342 -5764
- 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/affix/index.mjs +2 -2
- package/es/components/affix/src/affix.mjs +26 -115
- package/es/components/affix/src/affix.mjs.map +1 -1
- package/es/components/affix/src/affix2.mjs +115 -26
- package/es/components/affix/src/affix2.mjs.map +1 -1
- package/es/components/button/index.mjs +2 -2
- package/es/components/button/src/button-group.mjs +1 -1
- package/es/components/button/src/button.mjs +118 -53
- package/es/components/button/src/button.mjs.map +1 -1
- package/es/components/button/src/button2.mjs +53 -118
- package/es/components/button/src/button2.mjs.map +1 -1
- package/es/components/cascader/index.d.ts +68 -68
- package/es/components/cascader/src/index.vue.d.ts +34 -34
- package/es/components/cascader-panel/index.mjs +1 -1
- package/es/components/cascader-panel/src/config.d.ts +1 -2
- package/es/components/cascader-panel/src/config.mjs +1 -2
- package/es/components/cascader-panel/src/config.mjs.map +1 -1
- package/es/components/cascader-panel/src/index.mjs +2 -2
- package/es/components/cascader-panel/src/index.mjs.map +1 -1
- package/es/components/cascader-panel/src/index.vue.d.ts +3 -3
- package/es/components/cascader-panel/src/node.d.ts +1 -4
- package/es/components/cascader-panel/src/node.mjs +1 -6
- package/es/components/cascader-panel/src/node.mjs.map +1 -1
- package/es/components/cascader-panel/src/types.d.ts +2 -27
- package/es/components/cascader-panel/src/types.mjs +1 -6
- package/es/components/cascader-panel/src/types.mjs.map +1 -1
- package/es/components/date-picker/src/date-picker-com/basic-date-table.mjs +1 -1
- package/es/components/date-picker/src/date-picker-com/basic-date-table.mjs.map +1 -1
- package/es/components/index.mjs +3 -3
- package/es/components/popconfirm/src/popconfirm.mjs +1 -1
- package/es/components/tree-v2/src/composables/useTree.mjs +2 -2
- package/es/components/tree-v2/src/composables/useTree.mjs.map +1 -1
- package/es/index.mjs +3 -3
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/version.mjs.map +1 -1
- package/lib/components/affix/index.js +2 -2
- package/lib/components/affix/src/affix.js +27 -115
- package/lib/components/affix/src/affix.js.map +1 -1
- package/lib/components/affix/src/affix2.js +115 -27
- package/lib/components/affix/src/affix2.js.map +1 -1
- package/lib/components/button/index.js +2 -2
- package/lib/components/button/src/button-group.js +1 -1
- package/lib/components/button/src/button.js +118 -56
- package/lib/components/button/src/button.js.map +1 -1
- package/lib/components/button/src/button2.js +56 -118
- package/lib/components/button/src/button2.js.map +1 -1
- package/lib/components/cascader/index.d.ts +68 -68
- package/lib/components/cascader/src/index.vue.d.ts +34 -34
- package/lib/components/cascader-panel/index.js +0 -1
- package/lib/components/cascader-panel/index.js.map +1 -1
- package/lib/components/cascader-panel/src/config.d.ts +1 -2
- package/lib/components/cascader-panel/src/config.js +1 -2
- package/lib/components/cascader-panel/src/config.js.map +1 -1
- package/lib/components/cascader-panel/src/index.js +1 -1
- package/lib/components/cascader-panel/src/index.js.map +1 -1
- package/lib/components/cascader-panel/src/index.vue.d.ts +3 -3
- package/lib/components/cascader-panel/src/node.d.ts +1 -4
- package/lib/components/cascader-panel/src/node.js +0 -6
- package/lib/components/cascader-panel/src/node.js.map +1 -1
- package/lib/components/cascader-panel/src/types.d.ts +2 -27
- package/lib/components/cascader-panel/src/types.js +0 -6
- package/lib/components/cascader-panel/src/types.js.map +1 -1
- package/lib/components/date-picker/src/date-picker-com/basic-date-table.js +2 -2
- package/lib/components/date-picker/src/date-picker-com/basic-date-table.js.map +1 -1
- package/lib/components/index.js +2 -3
- package/lib/components/index.js.map +1 -1
- package/lib/components/popconfirm/src/popconfirm.js +1 -1
- package/lib/components/tree-v2/src/composables/useTree.js +2 -2
- package/lib/components/tree-v2/src/composables/useTree.js.map +1 -1
- package/lib/index.js +2 -3
- 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/web-types.json +1 -1
|
@@ -1,121 +1,32 @@
|
|
|
1
|
-
import { defineComponent, shallowRef, ref, computed, watch, onMounted, watchEffect, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createElementVNode, renderSlot } from 'vue';
|
|
2
|
-
import { useWindowSize, useElementBounding, useEventListener } from '@vueuse/core';
|
|
3
1
|
import '../../../utils/index.mjs';
|
|
4
|
-
import '../../../
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import { throwError } from '../../../utils/error.mjs';
|
|
9
|
-
import { getScrollContainer } from '../../../utils/dom/scroll.mjs';
|
|
2
|
+
import '../../../constants/index.mjs';
|
|
3
|
+
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
|
|
4
|
+
import { isNumber, isBoolean } from '@vueuse/core';
|
|
5
|
+
import { CHANGE_EVENT } from '../../../constants/event.mjs';
|
|
10
6
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
width: rootWidth,
|
|
29
|
-
top: rootTop,
|
|
30
|
-
bottom: rootBottom,
|
|
31
|
-
update: updateRoot
|
|
32
|
-
} = useElementBounding(root);
|
|
33
|
-
const targetRect = useElementBounding(target);
|
|
34
|
-
const fixed = ref(false);
|
|
35
|
-
const scrollTop = ref(0);
|
|
36
|
-
const transform = ref(0);
|
|
37
|
-
const rootStyle = computed(() => {
|
|
38
|
-
return {
|
|
39
|
-
height: fixed.value ? `${rootHeight.value}px` : "",
|
|
40
|
-
width: fixed.value ? `${rootWidth.value}px` : ""
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
const affixStyle = computed(() => {
|
|
44
|
-
if (!fixed.value)
|
|
45
|
-
return {};
|
|
46
|
-
const offset = props.offset ? `${props.offset}px` : 0;
|
|
47
|
-
return {
|
|
48
|
-
height: `${rootHeight.value}px`,
|
|
49
|
-
width: `${rootWidth.value}px`,
|
|
50
|
-
top: props.position === "top" ? offset : "",
|
|
51
|
-
bottom: props.position === "bottom" ? offset : "",
|
|
52
|
-
transform: transform.value ? `translateY(${transform.value}px)` : "",
|
|
53
|
-
zIndex: props.zIndex
|
|
54
|
-
};
|
|
55
|
-
});
|
|
56
|
-
const update = () => {
|
|
57
|
-
if (!scrollContainer.value)
|
|
58
|
-
return;
|
|
59
|
-
scrollTop.value = scrollContainer.value instanceof Window ? document.documentElement.scrollTop : scrollContainer.value.scrollTop || 0;
|
|
60
|
-
if (props.position === "top") {
|
|
61
|
-
if (props.target) {
|
|
62
|
-
const difference = targetRect.bottom.value - props.offset - rootHeight.value;
|
|
63
|
-
fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0;
|
|
64
|
-
transform.value = difference < 0 ? difference : 0;
|
|
65
|
-
} else {
|
|
66
|
-
fixed.value = props.offset > rootTop.value;
|
|
67
|
-
}
|
|
68
|
-
} else if (props.target) {
|
|
69
|
-
const difference = windowHeight.value - targetRect.top.value - props.offset - rootHeight.value;
|
|
70
|
-
fixed.value = windowHeight.value - props.offset < rootBottom.value && windowHeight.value > targetRect.top.value;
|
|
71
|
-
transform.value = difference < 0 ? -difference : 0;
|
|
72
|
-
} else {
|
|
73
|
-
fixed.value = windowHeight.value - props.offset < rootBottom.value;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const handleScroll = () => {
|
|
77
|
-
emit("scroll", {
|
|
78
|
-
scrollTop: scrollTop.value,
|
|
79
|
-
fixed: fixed.value
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
watch(fixed, (val) => emit("change", val));
|
|
83
|
-
onMounted(() => {
|
|
84
|
-
var _a;
|
|
85
|
-
if (props.target) {
|
|
86
|
-
target.value = (_a = document.querySelector(props.target)) != null ? _a : void 0;
|
|
87
|
-
if (!target.value)
|
|
88
|
-
throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`);
|
|
89
|
-
} else {
|
|
90
|
-
target.value = document.documentElement;
|
|
91
|
-
}
|
|
92
|
-
scrollContainer.value = getScrollContainer(root.value, true);
|
|
93
|
-
updateRoot();
|
|
94
|
-
});
|
|
95
|
-
useEventListener(scrollContainer, "scroll", handleScroll);
|
|
96
|
-
watchEffect(update);
|
|
97
|
-
expose({
|
|
98
|
-
update,
|
|
99
|
-
updateRoot
|
|
100
|
-
});
|
|
101
|
-
return (_ctx, _cache) => {
|
|
102
|
-
return openBlock(), createElementBlock("div", {
|
|
103
|
-
ref_key: "root",
|
|
104
|
-
ref: root,
|
|
105
|
-
class: normalizeClass(unref(ns).b()),
|
|
106
|
-
style: normalizeStyle(unref(rootStyle))
|
|
107
|
-
}, [
|
|
108
|
-
createElementVNode("div", {
|
|
109
|
-
class: normalizeClass({ [unref(ns).m("fixed")]: fixed.value }),
|
|
110
|
-
style: normalizeStyle(unref(affixStyle))
|
|
111
|
-
}, [
|
|
112
|
-
renderSlot(_ctx.$slots, "default")
|
|
113
|
-
], 6)
|
|
114
|
-
], 6);
|
|
115
|
-
};
|
|
7
|
+
const affixProps = buildProps({
|
|
8
|
+
zIndex: {
|
|
9
|
+
type: definePropType([Number, String]),
|
|
10
|
+
default: 100
|
|
11
|
+
},
|
|
12
|
+
target: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: ""
|
|
15
|
+
},
|
|
16
|
+
offset: {
|
|
17
|
+
type: Number,
|
|
18
|
+
default: 0
|
|
19
|
+
},
|
|
20
|
+
position: {
|
|
21
|
+
type: String,
|
|
22
|
+
values: ["top", "bottom"],
|
|
23
|
+
default: "top"
|
|
116
24
|
}
|
|
117
25
|
});
|
|
118
|
-
|
|
26
|
+
const affixEmits = {
|
|
27
|
+
scroll: ({ scrollTop, fixed }) => isNumber(scrollTop) && isBoolean(fixed),
|
|
28
|
+
[CHANGE_EVENT]: (fixed) => isBoolean(fixed)
|
|
29
|
+
};
|
|
119
30
|
|
|
120
|
-
export {
|
|
31
|
+
export { affixEmits, affixProps };
|
|
121
32
|
//# sourceMappingURL=affix.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affix.mjs","sources":["../../../../../../packages/components/affix/src/affix.
|
|
1
|
+
{"version":3,"file":"affix.mjs","sources":["../../../../../../packages/components/affix/src/affix.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n isBoolean,\n isNumber,\n} from '@element-plus/utils'\nimport { CHANGE_EVENT } from '@element-plus/constants'\nimport type { ExtractPropTypes } from 'vue'\nimport type { ZIndexProperty } from 'csstype'\nimport type Affix from './affix.vue'\n\nexport const affixProps = buildProps({\n zIndex: {\n type: definePropType<ZIndexProperty>([Number, String]),\n default: 100,\n },\n target: {\n type: String,\n default: '',\n },\n offset: {\n type: Number,\n default: 0,\n },\n position: {\n type: String,\n values: ['top', 'bottom'],\n default: 'top',\n },\n} as const)\nexport type AffixProps = ExtractPropTypes<typeof affixProps>\n\nexport const affixEmits = {\n scroll: ({ scrollTop, fixed }: { scrollTop: number; fixed: boolean }) =>\n isNumber(scrollTop) && isBoolean(fixed),\n [CHANGE_EVENT]: (fixed: boolean) => isBoolean(fixed),\n}\nexport type AffixEmits = typeof affixEmits\n\nexport type AffixInstance = InstanceType<typeof Affix>\n"],"names":[],"mappings":";;;;;;AAOY,MAAC,UAAU,GAAG,UAAU,CAAC;AACrC,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1C,IAAI,OAAO,EAAE,GAAG;AAChB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,CAAC;AACd,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC;AAC7B,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,UAAU,GAAG;AAC1B,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC;AAC3E,EAAE,CAAC,YAAY,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK,CAAC;AAC7C;;;;"}
|
|
@@ -1,32 +1,121 @@
|
|
|
1
|
+
import { defineComponent, shallowRef, ref, computed, watch, onMounted, watchEffect, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createElementVNode, renderSlot } from 'vue';
|
|
2
|
+
import { useWindowSize, useElementBounding, useEventListener } from '@vueuse/core';
|
|
1
3
|
import '../../../utils/index.mjs';
|
|
2
|
-
import '../../../
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import '../../../hooks/index.mjs';
|
|
5
|
+
import { affixProps, affixEmits } from './affix.mjs';
|
|
6
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
7
|
+
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
8
|
+
import { throwError } from '../../../utils/error.mjs';
|
|
9
|
+
import { getScrollContainer } from '../../../utils/dom/scroll.mjs';
|
|
6
10
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
const __default__ = {
|
|
12
|
+
name: "ElAffix"
|
|
13
|
+
};
|
|
14
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
15
|
+
...__default__,
|
|
16
|
+
props: affixProps,
|
|
17
|
+
emits: affixEmits,
|
|
18
|
+
setup(__props, { expose, emit }) {
|
|
19
|
+
const props = __props;
|
|
20
|
+
const COMPONENT_NAME = "ElAffix";
|
|
21
|
+
const ns = useNamespace("affix");
|
|
22
|
+
const target = shallowRef();
|
|
23
|
+
const root = shallowRef();
|
|
24
|
+
const scrollContainer = shallowRef();
|
|
25
|
+
const { height: windowHeight } = useWindowSize();
|
|
26
|
+
const {
|
|
27
|
+
height: rootHeight,
|
|
28
|
+
width: rootWidth,
|
|
29
|
+
top: rootTop,
|
|
30
|
+
bottom: rootBottom,
|
|
31
|
+
update: updateRoot
|
|
32
|
+
} = useElementBounding(root);
|
|
33
|
+
const targetRect = useElementBounding(target);
|
|
34
|
+
const fixed = ref(false);
|
|
35
|
+
const scrollTop = ref(0);
|
|
36
|
+
const transform = ref(0);
|
|
37
|
+
const rootStyle = computed(() => {
|
|
38
|
+
return {
|
|
39
|
+
height: fixed.value ? `${rootHeight.value}px` : "",
|
|
40
|
+
width: fixed.value ? `${rootWidth.value}px` : ""
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const affixStyle = computed(() => {
|
|
44
|
+
if (!fixed.value)
|
|
45
|
+
return {};
|
|
46
|
+
const offset = props.offset ? `${props.offset}px` : 0;
|
|
47
|
+
return {
|
|
48
|
+
height: `${rootHeight.value}px`,
|
|
49
|
+
width: `${rootWidth.value}px`,
|
|
50
|
+
top: props.position === "top" ? offset : "",
|
|
51
|
+
bottom: props.position === "bottom" ? offset : "",
|
|
52
|
+
transform: transform.value ? `translateY(${transform.value}px)` : "",
|
|
53
|
+
zIndex: props.zIndex
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
const update = () => {
|
|
57
|
+
if (!scrollContainer.value)
|
|
58
|
+
return;
|
|
59
|
+
scrollTop.value = scrollContainer.value instanceof Window ? document.documentElement.scrollTop : scrollContainer.value.scrollTop || 0;
|
|
60
|
+
if (props.position === "top") {
|
|
61
|
+
if (props.target) {
|
|
62
|
+
const difference = targetRect.bottom.value - props.offset - rootHeight.value;
|
|
63
|
+
fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0;
|
|
64
|
+
transform.value = difference < 0 ? difference : 0;
|
|
65
|
+
} else {
|
|
66
|
+
fixed.value = props.offset > rootTop.value;
|
|
67
|
+
}
|
|
68
|
+
} else if (props.target) {
|
|
69
|
+
const difference = windowHeight.value - targetRect.top.value - props.offset - rootHeight.value;
|
|
70
|
+
fixed.value = windowHeight.value - props.offset < rootBottom.value && windowHeight.value > targetRect.top.value;
|
|
71
|
+
transform.value = difference < 0 ? -difference : 0;
|
|
72
|
+
} else {
|
|
73
|
+
fixed.value = windowHeight.value - props.offset < rootBottom.value;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const handleScroll = () => {
|
|
77
|
+
emit("scroll", {
|
|
78
|
+
scrollTop: scrollTop.value,
|
|
79
|
+
fixed: fixed.value
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
watch(fixed, (val) => emit("change", val));
|
|
83
|
+
onMounted(() => {
|
|
84
|
+
var _a;
|
|
85
|
+
if (props.target) {
|
|
86
|
+
target.value = (_a = document.querySelector(props.target)) != null ? _a : void 0;
|
|
87
|
+
if (!target.value)
|
|
88
|
+
throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`);
|
|
89
|
+
} else {
|
|
90
|
+
target.value = document.documentElement;
|
|
91
|
+
}
|
|
92
|
+
scrollContainer.value = getScrollContainer(root.value, true);
|
|
93
|
+
updateRoot();
|
|
94
|
+
});
|
|
95
|
+
useEventListener(scrollContainer, "scroll", handleScroll);
|
|
96
|
+
watchEffect(update);
|
|
97
|
+
expose({
|
|
98
|
+
update,
|
|
99
|
+
updateRoot
|
|
100
|
+
});
|
|
101
|
+
return (_ctx, _cache) => {
|
|
102
|
+
return openBlock(), createElementBlock("div", {
|
|
103
|
+
ref_key: "root",
|
|
104
|
+
ref: root,
|
|
105
|
+
class: normalizeClass(unref(ns).b()),
|
|
106
|
+
style: normalizeStyle(unref(rootStyle))
|
|
107
|
+
}, [
|
|
108
|
+
createElementVNode("div", {
|
|
109
|
+
class: normalizeClass({ [unref(ns).m("fixed")]: fixed.value }),
|
|
110
|
+
style: normalizeStyle(unref(affixStyle))
|
|
111
|
+
}, [
|
|
112
|
+
renderSlot(_ctx.$slots, "default")
|
|
113
|
+
], 6)
|
|
114
|
+
], 6);
|
|
115
|
+
};
|
|
24
116
|
}
|
|
25
117
|
});
|
|
26
|
-
|
|
27
|
-
scroll: ({ scrollTop, fixed }) => isNumber(scrollTop) && isBoolean(fixed),
|
|
28
|
-
[CHANGE_EVENT]: (fixed) => isBoolean(fixed)
|
|
29
|
-
};
|
|
118
|
+
var Affix = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/affix/src/affix.vue"]]);
|
|
30
119
|
|
|
31
|
-
export {
|
|
120
|
+
export { Affix as default };
|
|
32
121
|
//# sourceMappingURL=affix2.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affix2.mjs","sources":["../../../../../../packages/components/affix/src/affix.
|
|
1
|
+
{"version":3,"file":"affix2.mjs","sources":["../../../../../../packages/components/affix/src/affix.vue"],"sourcesContent":["<template>\n <div ref=\"root\" :class=\"ns.b()\" :style=\"rootStyle\">\n <div :class=\"{ [ns.m('fixed')]: fixed }\" :style=\"affixStyle\">\n <slot />\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'\nimport {\n useElementBounding,\n useEventListener,\n useWindowSize,\n} from '@vueuse/core'\nimport { getScrollContainer, throwError } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { affixEmits, affixProps } from './affix'\nimport type { CSSProperties } from 'vue'\n\nconst COMPONENT_NAME = 'ElAffix'\ndefineOptions({\n name: 'ElAffix',\n})\n\nconst props = defineProps(affixProps)\nconst emit = defineEmits(affixEmits)\n\nconst ns = useNamespace('affix')\n\nconst target = shallowRef<HTMLElement>()\nconst root = shallowRef<HTMLDivElement>()\nconst scrollContainer = shallowRef<HTMLElement | Window>()\nconst { height: windowHeight } = useWindowSize()\nconst {\n height: rootHeight,\n width: rootWidth,\n top: rootTop,\n bottom: rootBottom,\n update: updateRoot,\n} = useElementBounding(root)\nconst targetRect = useElementBounding(target)\n\nconst fixed = ref(false)\nconst scrollTop = ref(0)\nconst transform = ref(0)\n\nconst rootStyle = computed<CSSProperties>(() => {\n return {\n height: fixed.value ? `${rootHeight.value}px` : '',\n width: fixed.value ? `${rootWidth.value}px` : '',\n }\n})\n\nconst affixStyle = computed<CSSProperties>(() => {\n if (!fixed.value) return {}\n\n const offset = props.offset ? `${props.offset}px` : 0\n return {\n height: `${rootHeight.value}px`,\n width: `${rootWidth.value}px`,\n top: props.position === 'top' ? offset : '',\n bottom: props.position === 'bottom' ? offset : '',\n transform: transform.value ? `translateY(${transform.value}px)` : '',\n zIndex: props.zIndex,\n }\n})\n\nconst update = () => {\n if (!scrollContainer.value) return\n\n scrollTop.value =\n scrollContainer.value instanceof Window\n ? document.documentElement.scrollTop\n : scrollContainer.value.scrollTop || 0\n\n if (props.position === 'top') {\n if (props.target) {\n const difference =\n targetRect.bottom.value - props.offset - rootHeight.value\n fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0\n transform.value = difference < 0 ? difference : 0\n } else {\n fixed.value = props.offset > rootTop.value\n }\n } else if (props.target) {\n const difference =\n windowHeight.value -\n targetRect.top.value -\n props.offset -\n rootHeight.value\n fixed.value =\n windowHeight.value - props.offset < rootBottom.value &&\n windowHeight.value > targetRect.top.value\n transform.value = difference < 0 ? -difference : 0\n } else {\n fixed.value = windowHeight.value - props.offset < rootBottom.value\n }\n}\n\nconst handleScroll = () => {\n emit('scroll', {\n scrollTop: scrollTop.value,\n fixed: fixed.value,\n })\n}\n\nwatch(fixed, (val) => emit('change', val))\n\nonMounted(() => {\n if (props.target) {\n target.value =\n document.querySelector<HTMLElement>(props.target) ?? undefined\n if (!target.value)\n throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`)\n } else {\n target.value = document.documentElement\n }\n scrollContainer.value = getScrollContainer(root.value!, true)\n updateRoot()\n})\n\nuseEventListener(scrollContainer, 'scroll', handleScroll)\nwatchEffect(update)\n\ndefineExpose({\n /** @description update affix status */\n update,\n /** @description update rootRect info */\n updateRoot,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAo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AAA,CAAA;AACA,OAAA;AACA,MAAA,eAAA,CAAA,KAAA,GAAA,kBAAA,CAAA,IAAA,CAAA,KAAA,EAAA,IAAA,CAAA,CAAA;AAAA,MACA,UAAA,EAAA,CAAA;AAEA,KAAA,CAAA,CAAA;AACA,IAAA,gBAAA,CAAA,eAAA,EAAA,QAAA,EAAA,YAAA,CAAA,CAAA;AAEA,IAAA,WAAA,CAAA,MAAA,CAAA,CAAA;AAAA,IAEA,MAAA,CAAA;AAAA,MAEA,MAAA;AAAA,MACA,UAAA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../../utils/index.mjs';
|
|
2
|
-
import Button from './src/
|
|
2
|
+
import Button from './src/button.mjs';
|
|
3
3
|
import ButtonGroup from './src/button-group2.mjs';
|
|
4
|
-
export { buttonEmits, buttonNativeTypes, buttonProps, buttonTypes } from './src/
|
|
4
|
+
export { buttonEmits, buttonNativeTypes, buttonProps, buttonTypes } from './src/button2.mjs';
|
|
5
5
|
import { withInstall, withNoopInstall } from '../../utils/vue/install.mjs';
|
|
6
6
|
|
|
7
7
|
const ElButton = withInstall(Button, {
|
|
@@ -1,59 +1,124 @@
|
|
|
1
|
+
import { defineComponent, useSlots, computed, inject, ref, Text, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, Fragment, renderSlot, createBlock, withCtx, resolveDynamicComponent, createCommentVNode } from 'vue';
|
|
2
|
+
import { ElIcon } from '../../icon/index.mjs';
|
|
1
3
|
import '../../../hooks/index.mjs';
|
|
2
|
-
import '../../../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
4
|
+
import '../../../tokens/index.mjs';
|
|
5
|
+
import { buttonProps, buttonEmits } from './button2.mjs';
|
|
6
|
+
import { useButtonCustomStyle } from './button-custom.mjs';
|
|
7
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
8
|
+
import { useDeprecated } from '../../../hooks/use-deprecated/index.mjs';
|
|
9
|
+
import { buttonGroupContextKey } from '../../../tokens/button.mjs';
|
|
10
|
+
import { useGlobalConfig } from '../../../hooks/use-global-config/index.mjs';
|
|
11
|
+
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
12
|
+
import { useFormItem } from '../../../hooks/use-form-item/index.mjs';
|
|
13
|
+
import { useSize, useDisabled } from '../../../hooks/use-common-props/index.mjs';
|
|
7
14
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
15
|
+
const _hoisted_1 = ["aria-disabled", "disabled", "autofocus", "type"];
|
|
16
|
+
const __default__ = {
|
|
17
|
+
name: "ElButton"
|
|
18
|
+
};
|
|
19
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
20
|
+
...__default__,
|
|
21
|
+
props: buttonProps,
|
|
22
|
+
emits: buttonEmits,
|
|
23
|
+
setup(__props, { expose, emit }) {
|
|
24
|
+
const props = __props;
|
|
25
|
+
const slots = useSlots();
|
|
26
|
+
useDeprecated({
|
|
27
|
+
from: "type.text",
|
|
28
|
+
replacement: "type.link",
|
|
29
|
+
version: "3.0.0",
|
|
30
|
+
scope: "props",
|
|
31
|
+
ref: "https://element-plus.org/en-US/component/button.html#button-attributes"
|
|
32
|
+
}, computed(() => props.type === "text"));
|
|
33
|
+
const buttonGroupContext = inject(buttonGroupContextKey, void 0);
|
|
34
|
+
const globalConfig = useGlobalConfig("button");
|
|
35
|
+
const ns = useNamespace("button");
|
|
36
|
+
const { form } = useFormItem();
|
|
37
|
+
const _size = useSize(computed(() => buttonGroupContext == null ? void 0 : buttonGroupContext.size));
|
|
38
|
+
const _disabled = useDisabled();
|
|
39
|
+
const _ref = ref();
|
|
40
|
+
const _type = computed(() => props.type || (buttonGroupContext == null ? void 0 : buttonGroupContext.type) || "");
|
|
41
|
+
const autoInsertSpace = computed(() => {
|
|
42
|
+
var _a, _b, _c;
|
|
43
|
+
return (_c = (_b = props.autoInsertSpace) != null ? _b : (_a = globalConfig.value) == null ? void 0 : _a.autoInsertSpace) != null ? _c : false;
|
|
44
|
+
});
|
|
45
|
+
const shouldAddSpace = computed(() => {
|
|
46
|
+
var _a;
|
|
47
|
+
const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots);
|
|
48
|
+
if (autoInsertSpace.value && (defaultSlot == null ? void 0 : defaultSlot.length) === 1) {
|
|
49
|
+
const slot = defaultSlot[0];
|
|
50
|
+
if ((slot == null ? void 0 : slot.type) === Text) {
|
|
51
|
+
const text = slot.children;
|
|
52
|
+
return /^\p{Unified_Ideograph}{2}$/u.test(text.trim());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
});
|
|
57
|
+
const buttonStyle = useButtonCustomStyle(props);
|
|
58
|
+
const handleClick = (evt) => {
|
|
59
|
+
if (props.nativeType === "reset") {
|
|
60
|
+
form == null ? void 0 : form.resetFields();
|
|
61
|
+
}
|
|
62
|
+
emit("click", evt);
|
|
63
|
+
};
|
|
64
|
+
expose({
|
|
65
|
+
ref: _ref,
|
|
66
|
+
size: _size,
|
|
67
|
+
type: _type,
|
|
68
|
+
disabled: _disabled,
|
|
69
|
+
shouldAddSpace
|
|
70
|
+
});
|
|
71
|
+
return (_ctx, _cache) => {
|
|
72
|
+
return openBlock(), createElementBlock("button", {
|
|
73
|
+
ref_key: "_ref",
|
|
74
|
+
ref: _ref,
|
|
75
|
+
class: normalizeClass([
|
|
76
|
+
unref(ns).b(),
|
|
77
|
+
unref(ns).m(unref(_type)),
|
|
78
|
+
unref(ns).m(unref(_size)),
|
|
79
|
+
unref(ns).is("disabled", unref(_disabled)),
|
|
80
|
+
unref(ns).is("loading", _ctx.loading),
|
|
81
|
+
unref(ns).is("plain", _ctx.plain),
|
|
82
|
+
unref(ns).is("round", _ctx.round),
|
|
83
|
+
unref(ns).is("circle", _ctx.circle),
|
|
84
|
+
unref(ns).is("text", _ctx.text),
|
|
85
|
+
unref(ns).is("link", _ctx.link),
|
|
86
|
+
unref(ns).is("has-bg", _ctx.bg)
|
|
87
|
+
]),
|
|
88
|
+
"aria-disabled": unref(_disabled) || _ctx.loading,
|
|
89
|
+
disabled: unref(_disabled) || _ctx.loading,
|
|
90
|
+
autofocus: _ctx.autofocus,
|
|
91
|
+
type: _ctx.nativeType,
|
|
92
|
+
style: normalizeStyle(unref(buttonStyle)),
|
|
93
|
+
onClick: handleClick
|
|
94
|
+
}, [
|
|
95
|
+
_ctx.loading ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
96
|
+
_ctx.$slots.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }) : (openBlock(), createBlock(unref(ElIcon), {
|
|
97
|
+
key: 1,
|
|
98
|
+
class: normalizeClass(unref(ns).is("loading"))
|
|
99
|
+
}, {
|
|
100
|
+
default: withCtx(() => [
|
|
101
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.loadingIcon)))
|
|
102
|
+
]),
|
|
103
|
+
_: 1
|
|
104
|
+
}, 8, ["class"]))
|
|
105
|
+
], 64)) : _ctx.icon || _ctx.$slots.icon ? (openBlock(), createBlock(unref(ElIcon), { key: 1 }, {
|
|
106
|
+
default: withCtx(() => [
|
|
107
|
+
_ctx.icon ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon), { key: 0 })) : renderSlot(_ctx.$slots, "icon", { key: 1 })
|
|
108
|
+
]),
|
|
109
|
+
_: 3
|
|
110
|
+
})) : createCommentVNode("v-if", true),
|
|
111
|
+
_ctx.$slots.default ? (openBlock(), createElementBlock("span", {
|
|
112
|
+
key: 2,
|
|
113
|
+
class: normalizeClass({ [unref(ns).em("text", "expand")]: unref(shouldAddSpace) })
|
|
114
|
+
}, [
|
|
115
|
+
renderSlot(_ctx.$slots, "default")
|
|
116
|
+
], 2)) : createCommentVNode("v-if", true)
|
|
117
|
+
], 14, _hoisted_1);
|
|
118
|
+
};
|
|
52
119
|
}
|
|
53
120
|
});
|
|
54
|
-
|
|
55
|
-
click: (evt) => evt instanceof MouseEvent
|
|
56
|
-
};
|
|
121
|
+
var Button = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/button/src/button.vue"]]);
|
|
57
122
|
|
|
58
|
-
export {
|
|
123
|
+
export { Button as default };
|
|
59
124
|
//# sourceMappingURL=button.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.mjs","sources":["../../../../../../packages/components/button/src/button.
|
|
1
|
+
{"version":3,"file":"button.mjs","sources":["../../../../../../packages/components/button/src/button.vue"],"sourcesContent":["<template>\n <button\n ref=\"_ref\"\n :class=\"[\n ns.b(),\n ns.m(_type),\n ns.m(_size),\n ns.is('disabled', _disabled),\n ns.is('loading', loading),\n ns.is('plain', plain),\n ns.is('round', round),\n ns.is('circle', circle),\n ns.is('text', text),\n ns.is('link', link),\n ns.is('has-bg', bg),\n ]\"\n :aria-disabled=\"_disabled || loading\"\n :disabled=\"_disabled || loading\"\n :autofocus=\"autofocus\"\n :type=\"nativeType\"\n :style=\"buttonStyle\"\n @click=\"handleClick\"\n >\n <template v-if=\"loading\">\n <slot v-if=\"$slots.loading\" name=\"loading\" />\n <el-icon v-else :class=\"ns.is('loading')\">\n <component :is=\"loadingIcon\" />\n </el-icon>\n </template>\n <el-icon v-else-if=\"icon || $slots.icon\">\n <component :is=\"icon\" v-if=\"icon\" />\n <slot v-else name=\"icon\" />\n </el-icon>\n <span\n v-if=\"$slots.default\"\n :class=\"{ [ns.em('text', 'expand')]: shouldAddSpace }\"\n >\n <slot />\n </span>\n </button>\n</template>\n\n<script lang=\"ts\" setup>\nimport { Text, computed, inject, ref, useSlots } from 'vue'\nimport { ElIcon } from '@element-plus/components/icon'\nimport {\n useDeprecated,\n useDisabled,\n useFormItem,\n useGlobalConfig,\n useNamespace,\n useSize,\n} from '@element-plus/hooks'\nimport { buttonGroupContextKey } from '@element-plus/tokens'\nimport { buttonEmits, buttonProps } from './button'\nimport { useButtonCustomStyle } from './button-custom'\n\ndefineOptions({\n name: 'ElButton',\n})\n\nconst props = defineProps(buttonProps)\nconst emit = defineEmits(buttonEmits)\nconst slots = useSlots()\n\nuseDeprecated(\n {\n from: 'type.text',\n replacement: 'type.link',\n version: '3.0.0',\n scope: 'props',\n ref: 'https://element-plus.org/en-US/component/button.html#button-attributes',\n },\n computed(() => props.type === 'text')\n)\n\nconst buttonGroupContext = inject(buttonGroupContextKey, undefined)\nconst globalConfig = useGlobalConfig('button')\nconst ns = useNamespace('button')\nconst { form } = useFormItem()\nconst _size = useSize(computed(() => buttonGroupContext?.size))\nconst _disabled = useDisabled()\nconst _ref = ref<HTMLButtonElement>()\n\nconst _type = computed(() => props.type || buttonGroupContext?.type || '')\nconst autoInsertSpace = computed(\n () => props.autoInsertSpace ?? globalConfig.value?.autoInsertSpace ?? false\n)\n\n// add space between two characters in Chinese\nconst shouldAddSpace = computed(() => {\n const defaultSlot = slots.default?.()\n if (autoInsertSpace.value && defaultSlot?.length === 1) {\n const slot = defaultSlot[0]\n if (slot?.type === Text) {\n const text = slot.children as string\n return /^\\p{Unified_Ideograph}{2}$/u.test(text.trim())\n }\n }\n return false\n})\n\nconst buttonStyle = useButtonCustomStyle(props)\n\nconst handleClick = (evt: MouseEvent) => {\n if (props.nativeType === 'reset') {\n form?.resetFields()\n }\n emit('click', evt)\n}\n\ndefineExpose({\n /** @description button html element */\n ref: _ref,\n /** @description button size */\n size: _size,\n /** @description button type */\n type: _type,\n /** @description button disabled */\n disabled: _disabled,\n /** @description whether adding space */\n shouldAddSpace,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+DA,IAAA,MAAA,QAAA,QAAA,EAAA,CAAA;AAEA,IACA,aAAA,CAAA;AAAA,MACA,IAAA,EAAA,WAAA;AAAA,MACA,WAAA,EAAA,WAAA;AAAA,MACA,OAAA,EAAA,OAAA;AAAA,MACA,KAAA,EAAA,OAAA;AAAA,MACA,GAAA,EAAA,wEAAA;AAAA,OAEA,QAAA,CAAA,MAAA,KAAA,CAAA,IAAA,KAAA,MAAA,CACA,CAAA,CAAA;AAEA,IAAA,MAAA,kBAAA,GAAA,MAAA,CAAA,qBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AACA,IAAA,MAAA,YAAA,GAAA,gBAAA,QAAA,CAAA,CAAA;AACA,IAAA,MAAA,EAAA,GAAA,aAAA,QAAA,CAAA,CAAA;AACA,IAAA,MAAA,EAAA,SAAA,WAAA,EAAA,CAAA;AACA,IAAA,MAAA,QAAA,OAAA,CAAA,QAAA,CAAA,MAAA,kBAAA,QAAA,GAAA,KAAA,CAAA,GAAA,kBAAA,CAAA,IAAA,CAAA,CAAA,CAAA;AACA,IAAA,MAAA,YAAA,WAAA,EAAA,CAAA;AACA,IAAA,MAAA,OAAA,GAAA,EAAA,CAAA;AAEA,IAAA,MAAA,QAAA,QAAA,CAAA,MAAA,MAAA,IAAA,KAAA,kBAAA,WAAA,KAAA,CAAA,GAAA,kBAAA,CAAA,IAAA,CAAA,IAAA,EAAA,CAAA,CAAA;AACA,IAAA,MAAA,eAAA,GAAA,SACA,MAAA;AAIA,MAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAA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