feat: initial commit - Phase 1 & 2 core features

This commit is contained in:
hiderfong
2026-04-22 17:07:33 +08:00
commit 1773bda06b
25005 changed files with 6252106 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
import { SFCWithInstall } from "../../utils/vue/typescript.js";
import "../../utils/index.js";
import { BacktopEmits, BacktopProps, BacktopPropsPublic, backtopEmits, backtopProps } from "./src/backtop.js";
import { _default } from "./src/backtop.vue.js";
import { BacktopInstance } from "./src/instance.js";
//#region ../../packages/components/backtop/index.d.ts
declare const ElBacktop: SFCWithInstall<typeof _default>;
//#endregion
export { BacktopEmits, type BacktopInstance, BacktopProps, BacktopPropsPublic, ElBacktop, ElBacktop as default, backtopEmits, backtopProps };
+10
View File
@@ -0,0 +1,10 @@
import { withInstall } from "../../utils/vue/install.mjs";
import { backtopEmits, backtopProps } from "./src/backtop.mjs";
import backtop_default from "./src/backtop2.mjs";
//#region ../../packages/components/backtop/index.ts
const ElBacktop = withInstall(backtop_default);
//#endregion
export { ElBacktop, ElBacktop as default, backtopEmits, backtopProps };
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","names":["Backtop"],"sources":["../../../../../packages/components/backtop/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport Backtop from './src/backtop.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElBacktop: SFCWithInstall<typeof Backtop> = withInstall(Backtop)\nexport default ElBacktop\n\nexport * from './src/backtop'\nexport type { BacktopInstance } from './src/instance'\n"],"mappings":";;;;;AAKA,MAAa,YAA4C,YAAYA,gBAAQ"}
@@ -0,0 +1,64 @@
import { ExtractPublicPropTypes } from "vue";
//#region ../../packages/components/backtop/src/backtop.d.ts
interface BacktopProps {
/**
* @description the button will not show until the scroll height reaches this value.
*/
visibilityHeight?: number;
/**
* @description the target to trigger scroll.
*/
target?: string;
/**
* @description right distance.
*/
right?: number;
/**
* @description bottom distance.
*/
bottom?: number;
}
/**
* @deprecated Removed after 3.0.0, Use `BacktopProps` instead.
*/
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;
};
};
/**
* @deprecated Removed after 3.0.0, Use `BacktopProps` instead.
*/
type BacktopPropsPublic = ExtractPublicPropTypes<typeof backtopProps>;
declare const backtopEmits: {
click: (evt: MouseEvent) => boolean;
};
type BacktopEmits = typeof backtopEmits;
//#endregion
export { BacktopEmits, BacktopProps, BacktopPropsPublic, backtopEmits, backtopProps };
@@ -0,0 +1,27 @@
//#region ../../packages/components/backtop/src/backtop.ts
/**
* @deprecated Removed after 3.0.0, Use `BacktopProps` instead.
*/
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 };
//#endregion
export { backtopEmits, backtopProps };
//# sourceMappingURL=backtop.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"backtop.mjs","names":[],"sources":["../../../../../../packages/components/backtop/src/backtop.ts"],"sourcesContent":["import type { ExtractPublicPropTypes } from 'vue'\n\nexport interface BacktopProps {\n /**\n * @description the button will not show until the scroll height reaches this value.\n */\n visibilityHeight?: number\n /**\n * @description the target to trigger scroll.\n */\n target?: string\n /**\n * @description right distance.\n */\n right?: number\n /**\n * @description bottom distance.\n */\n bottom?: number\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `BacktopProps` instead.\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\n\n/**\n * @deprecated Removed after 3.0.0, Use `BacktopProps` instead.\n */\nexport type BacktopPropsPublic = ExtractPublicPropTypes<typeof backtopProps>\n\nexport const backtopEmits = {\n click: (evt: MouseEvent) => evt instanceof MouseEvent,\n}\nexport type BacktopEmits = typeof backtopEmits\n"],"mappings":";;;;AAwBA,MAAa,eAAe;CAI1B,kBAAkB;EAChB,MAAM;EACN,SAAS;EACV;CAID,QAAQ;EACN,MAAM;EACN,SAAS;EACV;CAID,OAAO;EACL,MAAM;EACN,SAAS;EACV;CAID,QAAQ;EACN,MAAM;EACN,SAAS;EACV;CACF;AAOD,MAAa,eAAe,EAC1B,QAAQ,QAAoB,eAAe,YAC5C"}
@@ -0,0 +1,27 @@
import { BacktopProps } from "./backtop.js";
import * as vue from "vue";
//#region ../../packages/components/backtop/src/backtop.vue.d.ts
declare var __VLS_7: {};
type __VLS_Slots = {} & {
default?: (props: typeof __VLS_7) => any;
};
declare const __VLS_base: vue.DefineComponent<BacktopProps, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
click: (evt: MouseEvent) => void;
}, string, vue.PublicProps, Readonly<BacktopProps> & Readonly<{
onClick?: ((evt: MouseEvent) => any) | undefined;
}>, {
target: string;
bottom: number;
right: number;
visibilityHeight: number;
}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
declare const _default: typeof __VLS_export;
type __VLS_WithSlots<T, S> = T & {
new (): {
$slots: S;
};
};
//#endregion
export { _default };
@@ -0,0 +1,43 @@
import { useNamespace } from "../../../hooks/use-namespace/index.mjs";
import { ElIcon } from "../../icon/index.mjs";
import { backtopEmits, backtopProps } from "./backtop.mjs";
import { useBackTop } from "./use-backtop.mjs";
import { CaretTop } from "@element-plus/icons-vue";
import { Transition, computed, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, renderSlot, unref, withCtx, withModifiers } from "vue";
//#region ../../packages/components/backtop/src/backtop.vue?vue&type=script&setup=true&lang.ts
const COMPONENT_NAME = "ElBacktop";
var backtop_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
name: COMPONENT_NAME,
__name: "backtop",
props: backtopProps,
emits: backtopEmits,
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const ns = useNamespace("backtop");
const { handleClick, visible } = useBackTop(props, emit, COMPONENT_NAME);
const backTopStyle = computed(() => ({
right: `${props.right}px`,
bottom: `${props.bottom}px`
}));
return (_ctx, _cache) => {
return openBlock(), createBlock(Transition, { name: `${unref(ns).namespace.value}-fade-in` }, {
default: withCtx(() => [unref(visible) ? (openBlock(), createElementBlock("div", {
key: 0,
style: normalizeStyle(backTopStyle.value),
class: normalizeClass(unref(ns).b()),
onClick: _cache[0] || (_cache[0] = withModifiers((...args) => unref(handleClick) && unref(handleClick)(...args), ["stop"]))
}, [renderSlot(_ctx.$slots, "default", {}, () => [createVNode(unref(ElIcon), { class: normalizeClass(unref(ns).e("icon")) }, {
default: withCtx(() => [createVNode(unref(CaretTop))]),
_: 1
}, 8, ["class"])])], 6)) : createCommentVNode("v-if", true)]),
_: 3
}, 8, ["name"]);
};
}
});
//#endregion
export { backtop_vue_vue_type_script_setup_true_lang_default as default };
//# sourceMappingURL=backtop.vue_vue_type_script_setup_true_lang.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"backtop.vue_vue_type_script_setup_true_lang.mjs","names":[],"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 } from './backtop'\nimport { useBackTop } from './use-backtop'\n\nimport type { BacktopProps } from './backtop'\n\nconst COMPONENT_NAME = 'ElBacktop'\n\ndefineOptions({\n name: COMPONENT_NAME,\n})\n\nconst props = withDefaults(defineProps<BacktopProps>(), {\n visibilityHeight: 200,\n target: '',\n right: 40,\n bottom: 40,\n})\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"],"mappings":";;;;;;;;AAyBA,MAAM,iBAAiB;;;;;;;EAMvB,MAAM,QAAQ;EAMd,MAAM,OAAO;EAEb,MAAM,KAAK,aAAa,UAAS;EAEjC,MAAM,EAAE,aAAa,YAAY,WAAW,OAAO,MAAM,eAAc;EAEvE,MAAM,eAAe,gBAAgB;GACnC,OAAO,GAAG,MAAM,MAAM;GACtB,QAAQ,GAAG,MAAM,OAAO;GACzB,EAAC;;uBA7CA,YAWa,YAAA,EAXA,MAAI,GAAK,MAAA,GAAE,CAAC,UAAU,MAAK;2BAUhC,CARE,MAAA,QAAO,iBADf,mBASM,OAAA;;KAPH,OAAK,eAAE,aAAA,MAAY;KACnB,OAAK,eAAE,MAAA,GAAE,CAAC,GAAC,CAAA;KACX,SAAK,OAAA,OAAA,OAAA,KAAA,2BAAO,MAAA,YAAA,IAAA,MAAA,YAAA,CAAA,GAAA,KAAW,EAAA,CAAA,OAAA,CAAA;QAExB,WAEO,KAAA,QAAA,WAAA,EAAA,QAAA,CADL,YAAsD,MAAA,OAAA,EAAA,EAA5C,OAAK,eAAE,MAAA,GAAE,CAAC,EAAC,OAAA,CAAA;4BAAuB,CAAb,YAAa,MAAA,SAAA,CAAA"}
@@ -0,0 +1,8 @@
import backtop_vue_vue_type_script_setup_true_lang_default from "./backtop.vue_vue_type_script_setup_true_lang.mjs";
//#region ../../packages/components/backtop/src/backtop.vue
var backtop_default = backtop_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { backtop_default as default };
//# sourceMappingURL=backtop2.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"backtop2.mjs","names":[],"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 } from './backtop'\nimport { useBackTop } from './use-backtop'\n\nimport type { BacktopProps } from './backtop'\n\nconst COMPONENT_NAME = 'ElBacktop'\n\ndefineOptions({\n name: COMPONENT_NAME,\n})\n\nconst props = withDefaults(defineProps<BacktopProps>(), {\n visibilityHeight: 200,\n target: '',\n right: 40,\n bottom: 40,\n})\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"],"mappings":""}
@@ -0,0 +1,6 @@
import { _default } from "./backtop.vue.js";
//#region ../../packages/components/backtop/src/instance.d.ts
type BacktopInstance = InstanceType<typeof _default> & unknown;
//#endregion
export { BacktopInstance };
@@ -0,0 +1,39 @@
import { throwError } from "../../../utils/error.mjs";
import { useEventListener, useThrottleFn } from "@vueuse/core";
import { onMounted, ref, shallowRef } from "vue";
//#region ../../packages/components/backtop/src/use-backtop.ts
const useBackTop = (props, emit, componentName) => {
const el = shallowRef();
const container = shallowRef();
const visible = ref(false);
const handleScroll = () => {
if (el.value) visible.value = el.value.scrollTop >= props.visibilityHeight;
};
const handleClick = (event) => {
el.value?.scrollTo({
top: 0,
behavior: "smooth"
});
emit("click", event);
};
useEventListener(container, "scroll", useThrottleFn(handleScroll, 300, true));
onMounted(() => {
container.value = document;
el.value = document.documentElement;
if (props.target) {
el.value = document.querySelector(props.target) ?? void 0;
if (!el.value) throwError(componentName, `target does not exist: ${props.target}`);
container.value = el.value;
}
handleScroll();
});
return {
visible,
handleClick
};
};
//#endregion
export { useBackTop };
//# sourceMappingURL=use-backtop.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"use-backtop.mjs","names":[],"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: Required<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"],"mappings":";;;;;AAOA,MAAa,cACX,OACA,MACA,kBACG;CACH,MAAM,KAAK,YAAyB;CACpC,MAAM,YAAY,YAAoC;CACtD,MAAM,UAAU,IAAI,MAAM;CAE1B,MAAM,qBAAqB;AACzB,MAAI,GAAG,MAAO,SAAQ,QAAQ,GAAG,MAAM,aAAa,MAAM;;CAG5D,MAAM,eAAe,UAAsB;AACzC,KAAG,OAAO,SAAS;GAAE,KAAK;GAAG,UAAU;GAAU,CAAC;AAClD,OAAK,SAAS,MAAM;;AAKtB,kBAAiB,WAAW,UAFE,cAAc,cAAc,KAAK,KAAK,CAER;AAC5D,iBAAgB;AACd,YAAU,QAAQ;AAClB,KAAG,QAAQ,SAAS;AAEpB,MAAI,MAAM,QAAQ;AAChB,MAAG,QAAQ,SAAS,cAA2B,MAAM,OAAO,IAAI;AAChE,OAAI,CAAC,GAAG,MACN,YAAW,eAAe,0BAA0B,MAAM,SAAS;AAErE,aAAU,QAAQ,GAAG;;AAGvB,gBAAc;GACd;AAEF,QAAO;EACL;EACA;EACD"}
@@ -0,0 +1,2 @@
import "../../base/style/css.mjs";
import "element-plus/theme-chalk/el-backtop.css";
@@ -0,0 +1,2 @@
import "../../base/style/index.mjs";
import "element-plus/theme-chalk/src/backtop.scss";