This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
export declare const backtopProps: {
/**
* @description the button will not show until the scroll height reaches this value.
*/
readonly visibilityHeight: {
readonly type: NumberConstructor;
readonly default: 200;
};
/**
* @description the target to trigger scroll.
*/
readonly target: {
readonly type: StringConstructor;
readonly default: "";
};
/**
* @description right distance.
*/
readonly right: {
readonly type: NumberConstructor;
readonly default: 40;
};
/**
* @description bottom distance.
*/
readonly bottom: {
readonly type: NumberConstructor;
readonly default: 40;
};
};
export type BacktopProps = ExtractPropTypes<typeof backtopProps>;
export type BacktopPropsPublic = __ExtractPublicPropTypes<typeof backtopProps>;
export declare const backtopEmits: {
click: (evt: MouseEvent) => boolean;
};
export type BacktopEmits = typeof backtopEmits;

View File

@@ -0,0 +1,29 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const backtopProps = {
visibilityHeight: {
type: Number,
default: 200
},
target: {
type: String,
default: ""
},
right: {
type: Number,
default: 40
},
bottom: {
type: Number,
default: 40
}
};
const backtopEmits = {
click: (evt) => evt instanceof MouseEvent
};
exports.backtopEmits = backtopEmits;
exports.backtopProps = backtopProps;
//# sourceMappingURL=backtop.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"backtop.js","sources":["../../../../../../packages/components/backtop/src/backtop.ts"],"sourcesContent":["import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\n\nexport const backtopProps = {\n /**\n * @description the button will not show until the scroll height reaches this value.\n */\n visibilityHeight: {\n type: Number,\n default: 200,\n },\n /**\n * @description the target to trigger scroll.\n */\n target: {\n type: String,\n default: '',\n },\n /**\n * @description right distance.\n */\n right: {\n type: Number,\n default: 40,\n },\n /**\n * @description bottom distance.\n */\n bottom: {\n type: Number,\n default: 40,\n },\n} as const\nexport type BacktopProps = ExtractPropTypes<typeof backtopProps>\nexport type BacktopPropsPublic = __ExtractPublicPropTypes<typeof backtopProps>\n\nexport const backtopEmits = {\n click: (evt: MouseEvent) => evt instanceof MouseEvent,\n}\nexport type BacktopEmits = typeof backtopEmits\n"],"names":[],"mappings":";;;;AAAY,MAAC,YAAY,GAAG;AAC5B,EAAE,gBAAgB,EAAE;AACpB,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,GAAG;AAChB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE;AACU,MAAC,YAAY,GAAG;AAC5B,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,GAAG,YAAY,UAAU;AAC3C;;;;;"}

View File

@@ -0,0 +1,54 @@
declare function __VLS_template(): {
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly visibilityHeight: {
readonly type: NumberConstructor;
readonly default: 200;
};
readonly target: {
readonly type: StringConstructor;
readonly default: "";
};
readonly right: {
readonly type: NumberConstructor;
readonly default: 40;
};
readonly bottom: {
readonly type: NumberConstructor;
readonly default: 40;
};
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
click: (evt: MouseEvent) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly visibilityHeight: {
readonly type: NumberConstructor;
readonly default: 200;
};
readonly target: {
readonly type: StringConstructor;
readonly default: "";
};
readonly right: {
readonly type: NumberConstructor;
readonly default: 40;
};
readonly bottom: {
readonly type: NumberConstructor;
readonly default: 40;
};
}>> & {
onClick?: ((evt: MouseEvent) => any) | undefined;
}, {
readonly bottom: number;
readonly right: number;
readonly target: string;
readonly visibilityHeight: number;
}>;
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
export default _default;
type __VLS_WithTemplateSlots<T, S> = T & {
new (): {
$slots: S;
};
};

View File

@@ -0,0 +1,60 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var index$1 = require('../../icon/index.js');
var iconsVue = require('@element-plus/icons-vue');
var backtop = require('./backtop.js');
var useBacktop = require('./use-backtop.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
const COMPONENT_NAME = "ElBacktop";
const __default__ = vue.defineComponent({
name: COMPONENT_NAME
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: backtop.backtopProps,
emits: backtop.backtopEmits,
setup(__props, { emit }) {
const props = __props;
const ns = index.useNamespace("backtop");
const { handleClick, visible } = useBacktop.useBackTop(props, emit, COMPONENT_NAME);
const backTopStyle = vue.computed(() => ({
right: `${props.right}px`,
bottom: `${props.bottom}px`
}));
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.Transition, {
name: `${vue.unref(ns).namespace.value}-fade-in`
}, {
default: vue.withCtx(() => [
vue.unref(visible) ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
style: vue.normalizeStyle(vue.unref(backTopStyle)),
class: vue.normalizeClass(vue.unref(ns).b()),
onClick: vue.withModifiers(vue.unref(handleClick), ["stop"])
}, [
vue.renderSlot(_ctx.$slots, "default", {}, () => [
vue.createVNode(vue.unref(index$1.ElIcon), {
class: vue.normalizeClass(vue.unref(ns).e("icon"))
}, {
default: vue.withCtx(() => [
vue.createVNode(vue.unref(iconsVue.CaretTop))
]),
_: 1
}, 8, ["class"])
])
], 14, ["onClick"])) : vue.createCommentVNode("v-if", true)
]),
_: 3
}, 8, ["name"]);
};
}
});
var Backtop = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "backtop.vue"]]);
exports["default"] = Backtop;
//# sourceMappingURL=backtop2.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"backtop2.js","sources":["../../../../../../packages/components/backtop/src/backtop.vue"],"sourcesContent":["<template>\n <transition :name=\"`${ns.namespace.value}-fade-in`\">\n <div\n v-if=\"visible\"\n :style=\"backTopStyle\"\n :class=\"ns.b()\"\n @click.stop=\"handleClick\"\n >\n <slot>\n <el-icon :class=\"ns.e('icon')\"><caret-top /></el-icon>\n </slot>\n </div>\n </transition>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { CaretTop } from '@element-plus/icons-vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { backtopEmits, backtopProps } from './backtop'\nimport { useBackTop } from './use-backtop'\n\nconst COMPONENT_NAME = 'ElBacktop'\n\ndefineOptions({\n name: COMPONENT_NAME,\n})\n\nconst props = defineProps(backtopProps)\nconst emit = defineEmits(backtopEmits)\n\nconst ns = useNamespace('backtop')\n\nconst { handleClick, visible } = useBackTop(props, emit, COMPONENT_NAME)\n\nconst backTopStyle = computed(() => ({\n right: `${props.right}px`,\n bottom: `${props.bottom}px`,\n}))\n</script>\n"],"names":["useNamespace","useBackTop","computed"],"mappings":";;;;;;;;;;;;;uCAyBc,CAAA;AAAA,EACZ,IAAM,EAAA,cAAA;AACR;;;;;;;AAKA,IAAM,MAAA,EAAA,GAAKA,mBAAa,SAAS,CAAA,CAAA;AAEjC,IAAA,MAAM,EAAE,WAAa,EAAA,OAAA,KAAYC,qBAAW,CAAA,KAAA,EAAO,MAAM,cAAc,CAAA,CAAA;AAEvE,IAAM,MAAA,YAAA,GAAeC,aAAS,OAAO;AAAA,MACnC,KAAA,EAAO,CAAG,EAAA,KAAA,CAAM,KAAK,CAAA,EAAA,CAAA;AAAA,MACrB,MAAA,EAAQ,CAAG,EAAA,KAAA,CAAM,MAAM,CAAA,EAAA,CAAA;AAAA,KACvB,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,2 @@
import type Backtop from './backtop.vue';
export type BacktopInstance = InstanceType<typeof Backtop> & unknown;

View File

@@ -0,0 +1,3 @@
'use strict';
//# sourceMappingURL=instance.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"instance.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}

View File

@@ -0,0 +1,6 @@
import type { SetupContext } from 'vue';
import type { BacktopEmits, BacktopProps } from './backtop';
export declare const useBackTop: (props: BacktopProps, emit: SetupContext<BacktopEmits>["emit"], componentName: string) => {
visible: import("vue").Ref<boolean>;
handleClick: (event: MouseEvent) => void;
};

View File

@@ -0,0 +1,44 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var core = require('@vueuse/core');
var error = require('../../../utils/error.js');
const useBackTop = (props, emit, componentName) => {
const el = vue.shallowRef();
const container = vue.shallowRef();
const visible = vue.ref(false);
const handleScroll = () => {
if (el.value)
visible.value = el.value.scrollTop >= props.visibilityHeight;
};
const handleClick = (event) => {
var _a;
(_a = el.value) == null ? void 0 : _a.scrollTo({ top: 0, behavior: "smooth" });
emit("click", event);
};
const handleScrollThrottled = core.useThrottleFn(handleScroll, 300, true);
core.useEventListener(container, "scroll", handleScrollThrottled);
vue.onMounted(() => {
var _a;
container.value = document;
el.value = document.documentElement;
if (props.target) {
el.value = (_a = document.querySelector(props.target)) != null ? _a : void 0;
if (!el.value) {
error.throwError(componentName, `target does not exist: ${props.target}`);
}
container.value = el.value;
}
handleScroll();
});
return {
visible,
handleClick
};
};
exports.useBackTop = useBackTop;
//# sourceMappingURL=use-backtop.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"use-backtop.js","sources":["../../../../../../packages/components/backtop/src/use-backtop.ts"],"sourcesContent":["import { onMounted, ref, shallowRef } from 'vue'\nimport { useEventListener, useThrottleFn } from '@vueuse/core'\nimport { throwError } from '@element-plus/utils'\n\nimport type { SetupContext } from 'vue'\nimport type { BacktopEmits, BacktopProps } from './backtop'\n\nexport const useBackTop = (\n props: BacktopProps,\n emit: SetupContext<BacktopEmits>['emit'],\n componentName: string\n) => {\n const el = shallowRef<HTMLElement>()\n const container = shallowRef<Document | HTMLElement>()\n const visible = ref(false)\n\n const handleScroll = () => {\n if (el.value) visible.value = el.value.scrollTop >= props.visibilityHeight\n }\n\n const handleClick = (event: MouseEvent) => {\n el.value?.scrollTo({ top: 0, behavior: 'smooth' })\n emit('click', event)\n }\n\n const handleScrollThrottled = useThrottleFn(handleScroll, 300, true)\n\n useEventListener(container, 'scroll', handleScrollThrottled)\n onMounted(() => {\n container.value = document\n el.value = document.documentElement\n\n if (props.target) {\n el.value = document.querySelector<HTMLElement>(props.target) ?? undefined\n if (!el.value) {\n throwError(componentName, `target does not exist: ${props.target}`)\n }\n container.value = el.value\n }\n // Give visible an initial value, fix #13066\n handleScroll()\n })\n\n return {\n visible,\n handleClick,\n }\n}\n"],"names":["shallowRef","ref","useThrottleFn","useEventListener","onMounted","throwError"],"mappings":";;;;;;;;AAGY,MAAC,UAAU,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,aAAa,KAAK;AAC1D,EAAE,MAAM,EAAE,GAAGA,cAAU,EAAE,CAAC;AAC1B,EAAE,MAAM,SAAS,GAAGA,cAAU,EAAE,CAAC;AACjC,EAAE,MAAM,OAAO,GAAGC,OAAG,CAAC,KAAK,CAAC,CAAC;AAC7B,EAAE,MAAM,YAAY,GAAG,MAAM;AAC7B,IAAI,IAAI,EAAE,CAAC,KAAK;AAChB,MAAM,OAAO,CAAC,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,gBAAgB,CAAC;AACnE,GAAG,CAAC;AACJ,EAAE,MAAM,WAAW,GAAG,CAAC,KAAK,KAAK;AACjC,IAAI,IAAI,EAAE,CAAC;A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