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
+13
View File
@@ -0,0 +1,13 @@
import { SFCWithInstall } from "../../utils/vue/typescript.js";
import "../../utils/index.js";
import { AnchorEmits, AnchorInstance, AnchorProps, AnchorPropsPublic, anchorEmits, anchorProps } from "./src/anchor.js";
import { _default } from "./src/anchor.vue.js";
import { _default as _default$1 } from "./src/anchor-link.vue.js";
//#region ../../packages/components/anchor/index.d.ts
declare const ElAnchor: SFCWithInstall<typeof _default> & {
AnchorLink: typeof _default$1;
};
declare const ElAnchorLink: SFCWithInstall<typeof _default$1>;
//#endregion
export { AnchorEmits, AnchorInstance, AnchorProps, AnchorPropsPublic, ElAnchor, ElAnchor as default, ElAnchorLink, anchorEmits, anchorProps };
+17
View File
@@ -0,0 +1,17 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_install = require('../../utils/vue/install.js');
const require_anchor = require('./src/anchor.js');
const require_anchor$1 = require('./src/anchor2.js');
const require_anchor_link = require('./src/anchor-link2.js');
//#region ../../packages/components/anchor/index.ts
const ElAnchor = require_install.withInstall(require_anchor$1.default, { AnchorLink: require_anchor_link.default });
const ElAnchorLink = require_install.withNoopInstall(require_anchor_link.default);
//#endregion
exports.ElAnchor = ElAnchor;
exports.default = ElAnchor;
exports.ElAnchorLink = ElAnchorLink;
exports.anchorEmits = require_anchor.anchorEmits;
exports.anchorProps = require_anchor.anchorProps;
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":["withInstall","Anchor","withNoopInstall","AnchorLink"],"sources":["../../../../../packages/components/anchor/index.ts"],"sourcesContent":["import { withInstall, withNoopInstall } from '@element-plus/utils'\nimport Anchor from './src/anchor.vue'\nimport AnchorLink from './src/anchor-link.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElAnchor: SFCWithInstall<typeof Anchor> & {\n AnchorLink: typeof AnchorLink\n} = withInstall(Anchor, {\n AnchorLink,\n})\nexport const ElAnchorLink: SFCWithInstall<typeof AnchorLink> =\n withNoopInstall(AnchorLink)\nexport default ElAnchor\n\nexport * from './src/anchor'\n"],"mappings":";;;;;;;AAMA,MAAa,WAETA,4BAAYC,0BAAQ,EACtB,yCACD,CAAC;AACF,MAAa,eACXC,gCAAgBC,4BAAW"}
@@ -0,0 +1,15 @@
import { ExtractPublicPropTypes } from "vue";
//#region ../../packages/components/anchor/src/anchor-link.d.ts
interface AnchorLinkProps {
/**
* @description the text content of the anchor link
*/
title?: string;
/**
* @description The address of the anchor link
*/
href?: string;
}
//#endregion
export { AnchorLinkProps };
@@ -0,0 +1,15 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../../../utils/vue/props/runtime.js');
//#region ../../packages/components/anchor/src/anchor-link.ts
/**
* @deprecated Removed after 3.0.0, Use `AnchorLinkProps` instead.
*/
const anchorLinkProps = require_runtime.buildProps({
title: String,
href: String
});
//#endregion
exports.anchorLinkProps = anchorLinkProps;
//# sourceMappingURL=anchor-link.js.map
@@ -0,0 +1 @@
{"version":3,"file":"anchor-link.js","names":["buildProps"],"sources":["../../../../../../packages/components/anchor/src/anchor-link.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils'\n\nimport type { ExtractPublicPropTypes } from 'vue'\n\nexport interface AnchorLinkProps {\n /**\n * @description the text content of the anchor link\n */\n title?: string\n /**\n * @description The address of the anchor link\n */\n href?: string\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `AnchorLinkProps` instead.\n */\nexport const anchorLinkProps = buildProps({\n /**\n * @description the text content of the anchor link\n */\n title: String,\n /**\n * @description The address of the anchor link\n */\n href: String,\n})\n\n/**\n * @deprecated Removed after 3.0.0, Use `AnchorLinkProps` instead.\n */\nexport type AnchorLinkPropsPublic = ExtractPublicPropTypes<\n typeof anchorLinkProps\n>\n"],"mappings":";;;;;;;AAkBA,MAAa,kBAAkBA,2BAAW;CAIxC,OAAO;CAIP,MAAM;CACP,CAAC"}
@@ -0,0 +1,20 @@
import { AnchorLinkProps } from "./anchor-link.js";
import * as vue from "vue";
//#region ../../packages/components/anchor/src/anchor-link.vue.d.ts
declare var __VLS_1: {}, __VLS_3: {};
type __VLS_Slots = {} & {
default?: (props: typeof __VLS_1) => any;
} & {
'sub-link'?: (props: typeof __VLS_3) => any;
};
declare const __VLS_base: vue.DefineComponent<AnchorLinkProps, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<AnchorLinkProps> & Readonly<{}>, {}, {}, {}, {}, 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,57 @@
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
const require_constants = require('./constants.js');
const require_anchor_link = require('./anchor-link.js');
let vue = require("vue");
//#region ../../packages/components/anchor/src/anchor-link.vue?vue&type=script&setup=true&lang.ts
const _hoisted_1 = ["href"];
var anchor_link_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
name: "ElAnchorLink",
__name: "anchor-link",
props: require_anchor_link.anchorLinkProps,
setup(__props) {
const props = __props;
const linkRef = (0, vue.ref)(null);
const { ns, direction, currentAnchor, addLink, removeLink, handleClick: contextHandleClick } = (0, vue.inject)(require_constants.anchorKey);
const cls = (0, vue.computed)(() => [ns.e("link"), ns.is("active", currentAnchor.value === props.href)]);
const handleClick = (e) => {
contextHandleClick(e, props.href);
};
(0, vue.watch)(() => props.href, (val, oldVal) => {
(0, vue.nextTick)(() => {
if (oldVal) removeLink(oldVal);
if (val) addLink({
href: val,
el: linkRef.value
});
});
});
(0, vue.onMounted)(() => {
const { href } = props;
if (href) addLink({
href,
el: linkRef.value
});
});
(0, vue.onBeforeUnmount)(() => {
const { href } = props;
if (href) removeLink(href);
});
return (_ctx, _cache) => {
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", { class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("item")) }, [(0, vue.createElementVNode)("a", {
ref_key: "linkRef",
ref: linkRef,
class: (0, vue.normalizeClass)(cls.value),
href: __props.href,
onClick: handleClick
}, [(0, vue.renderSlot)(_ctx.$slots, "default", {}, () => [(0, vue.createTextVNode)((0, vue.toDisplayString)(__props.title), 1)])], 10, _hoisted_1), _ctx.$slots["sub-link"] && (0, vue.unref)(direction) === "vertical" ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
key: 0,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("list"))
}, [(0, vue.renderSlot)(_ctx.$slots, "sub-link")], 2)) : (0, vue.createCommentVNode)("v-if", true)], 2);
};
}
});
//#endregion
exports.default = anchor_link_vue_vue_type_script_setup_true_lang_default;
//# sourceMappingURL=anchor-link.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
{"version":3,"file":"anchor-link.vue_vue_type_script_setup_true_lang.js","names":["$slots"],"sources":["../../../../../../packages/components/anchor/src/anchor-link.vue"],"sourcesContent":["<template>\n <div :class=\"ns.e('item')\">\n <a ref=\"linkRef\" :class=\"cls\" :href=\"href\" @click=\"handleClick\">\n <slot>{{ title }}</slot>\n </a>\n <div\n v-if=\"$slots['sub-link'] && direction === 'vertical'\"\n :class=\"ns.e('list')\"\n >\n <slot name=\"sub-link\" />\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport {\n computed,\n inject,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n} from 'vue'\nimport { anchorKey } from './constants'\n\nimport type { AnchorLinkProps } from './anchor-link'\n\ndefineOptions({\n name: 'ElAnchorLink',\n})\n\nconst props = defineProps<AnchorLinkProps>()\n\nconst linkRef = ref<HTMLElement | null>(null)\n\nconst {\n ns,\n direction,\n currentAnchor,\n addLink,\n removeLink,\n handleClick: contextHandleClick,\n} = inject(anchorKey)!\n\nconst cls = computed(() => [\n ns.e('link'),\n ns.is('active', currentAnchor.value === props.href),\n])\n\nconst handleClick = (e: MouseEvent) => {\n contextHandleClick(e, props.href)\n}\n\nwatch(\n () => props.href,\n (val, oldVal) => {\n nextTick(() => {\n if (oldVal) removeLink(oldVal)\n if (val) {\n addLink({\n href: val,\n el: linkRef.value!,\n })\n }\n })\n }\n)\n\nonMounted(() => {\n const { href } = props\n if (href) {\n addLink({\n href,\n el: linkRef.value!,\n })\n }\n})\n\nonBeforeUnmount(() => {\n const { href } = props\n if (href) {\n removeLink(href)\n }\n})\n</script>\n"],"mappings":";;;;;;;;;;;;EAgCA,MAAM,QAAQ;EAEd,MAAM,uBAAkC,KAAI;EAE5C,MAAM,EACJ,IACA,WACA,eACA,SACA,YACA,aAAa,uCACJ,4BAAU;EAErB,MAAM,8BAAqB,CACzB,GAAG,EAAE,OAAO,EACZ,GAAG,GAAG,UAAU,cAAc,UAAU,MAAM,KAAK,CACpD,CAAA;EAED,MAAM,eAAe,MAAkB;AACrC,sBAAmB,GAAG,MAAM,KAAI;;AAGlC,uBACQ,MAAM,OACX,KAAK,WAAW;AACf,2BAAe;AACb,QAAI,OAAQ,YAAW,OAAM;AAC7B,QAAI,IACF,SAAQ;KACN,MAAM;KACN,IAAI,QAAQ;KACb,CAAA;KAEJ;IAEL;AAEA,2BAAgB;GACd,MAAM,EAAE,SAAS;AACjB,OAAI,KACF,SAAQ;IACN;IACA,IAAI,QAAQ;IACb,CAAA;IAEJ;AAED,iCAAsB;GACpB,MAAM,EAAE,SAAS;AACjB,OAAI,KACF,YAAW,KAAI;IAElB;;4DAzEO,OAAA,EAVA,8CAAO,GAAE,CAAC,EAAC,OAAA,CAAA,iCAGX,KAAA;aAFG;IAAJ,KAAI;IAAW,+BAAO,IAAA,MAAG;IAAG,MAAM,QAAA;IAAO,SAAO;2BACzB,KAAA,QAAA,WAAA,EAAA,QAAA,mDAAf,QAAA,MAAK,EAAA,EAAA,sBAGRA,KAAAA,OAAM,8BAAgB,UAAS,KAAA,gEAIjC,OAAA;;IAHH,8CAAO,GAAE,CAAC,EAAC,OAAA,CAAA;2BAEY,KAAA,QAAA,WAAA"}
@@ -0,0 +1,9 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_anchor_link_vue_vue_type_script_setup_true_lang = require('./anchor-link.vue_vue_type_script_setup_true_lang.js');
//#region ../../packages/components/anchor/src/anchor-link.vue
var anchor_link_default = require_anchor_link_vue_vue_type_script_setup_true_lang.default;
//#endregion
exports.default = anchor_link_default;
//# sourceMappingURL=anchor-link2.js.map
@@ -0,0 +1 @@
{"version":3,"file":"anchor-link2.js","names":[],"sources":["../../../../../../packages/components/anchor/src/anchor-link.vue"],"sourcesContent":["<template>\n <div :class=\"ns.e('item')\">\n <a ref=\"linkRef\" :class=\"cls\" :href=\"href\" @click=\"handleClick\">\n <slot>{{ title }}</slot>\n </a>\n <div\n v-if=\"$slots['sub-link'] && direction === 'vertical'\"\n :class=\"ns.e('list')\"\n >\n <slot name=\"sub-link\" />\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport {\n computed,\n inject,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n} from 'vue'\nimport { anchorKey } from './constants'\n\nimport type { AnchorLinkProps } from './anchor-link'\n\ndefineOptions({\n name: 'ElAnchorLink',\n})\n\nconst props = defineProps<AnchorLinkProps>()\n\nconst linkRef = ref<HTMLElement | null>(null)\n\nconst {\n ns,\n direction,\n currentAnchor,\n addLink,\n removeLink,\n handleClick: contextHandleClick,\n} = inject(anchorKey)!\n\nconst cls = computed(() => [\n ns.e('link'),\n ns.is('active', currentAnchor.value === props.href),\n])\n\nconst handleClick = (e: MouseEvent) => {\n contextHandleClick(e, props.href)\n}\n\nwatch(\n () => props.href,\n (val, oldVal) => {\n nextTick(() => {\n if (oldVal) removeLink(oldVal)\n if (val) {\n addLink({\n href: val,\n el: linkRef.value!,\n })\n }\n })\n }\n)\n\nonMounted(() => {\n const { href } = props\n if (href) {\n addLink({\n href,\n el: linkRef.value!,\n })\n }\n})\n\nonBeforeUnmount(() => {\n const { href } = props\n if (href) {\n removeLink(href)\n }\n})\n</script>\n"],"mappings":""}
@@ -0,0 +1,71 @@
import { EpPropFinalized, EpPropMergeType } from "../../../utils/vue/props/types.js";
import "../../../utils/index.js";
import { _default } from "./anchor.vue.js";
import * as vue from "vue";
import { ExtractPublicPropTypes } from "vue";
//#region ../../packages/components/anchor/src/anchor.d.ts
interface AnchorProps {
/**
* @description scroll container
*/
container?: string | HTMLElement | Window | null;
/**
* @description Set the offset of the anchor scroll
*/
offset?: number;
/**
* @description The offset of the element starting to trigger the anchor
*/
bound?: number;
/**
* @description Set the scroll duration of the container when the anchor is clicked, in milliseconds
*/
duration?: number;
/**
* @description Whether to show the marker
*/
marker?: boolean;
/**
* @description Set Anchor type
*/
type?: 'default' | 'underline';
/**
* @description Set Anchor direction
*/
direction?: 'vertical' | 'horizontal';
/**
* @description Scroll whether link is selected at the top
*/
selectScrollTop?: boolean;
}
/**
* @deprecated Removed after 3.0.0, Use `AnchorProps` instead.
*/
declare const anchorProps: {
container: {
readonly type: vue.PropType<EpPropMergeType<(new (...args: any[]) => string | HTMLElement | Window) | (() => string | HTMLElement | Window | null) | (((new (...args: any[]) => string | HTMLElement | Window) | (() => string | HTMLElement | Window | null)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
offset: EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
bound: EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
duration: EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
marker: EpPropFinalized<BooleanConstructor, unknown, unknown, boolean, boolean>;
type: EpPropFinalized<(new (...args: any[]) => "default" | "underline") | (() => "default" | "underline") | (((new (...args: any[]) => "default" | "underline") | (() => "default" | "underline")) | null)[], unknown, unknown, string, boolean>;
direction: EpPropFinalized<(new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical") | (((new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical")) | null)[], unknown, unknown, string, boolean>;
selectScrollTop: BooleanConstructor;
};
/**
* @deprecated Removed after 3.0.0, Use `AnchorProps` instead.
*/
type AnchorPropsPublic = ExtractPublicPropTypes<typeof anchorProps>;
type AnchorInstance = InstanceType<typeof _default> & unknown;
declare const anchorEmits: {
change: (href: string) => boolean;
click: (e: MouseEvent, href?: string) => boolean;
};
type AnchorEmits = typeof anchorEmits;
//#endregion
export { AnchorEmits, AnchorInstance, AnchorProps, AnchorPropsPublic, anchorEmits, anchorProps };
+47
View File
@@ -0,0 +1,47 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
const require_types = require('../../../utils/types.js');
const require_runtime$1 = require('../../../utils/vue/props/runtime.js');
let _vue_shared = require("@vue/shared");
//#region ../../packages/components/anchor/src/anchor.ts
/**
* @deprecated Removed after 3.0.0, Use `AnchorProps` instead.
*/
const anchorProps = require_runtime$1.buildProps({
container: { type: require_runtime$1.definePropType([String, Object]) },
offset: {
type: Number,
default: 0
},
bound: {
type: Number,
default: 15
},
duration: {
type: Number,
default: 300
},
marker: {
type: Boolean,
default: true
},
type: {
type: require_runtime$1.definePropType(String),
default: "default"
},
direction: {
type: require_runtime$1.definePropType(String),
default: "vertical"
},
selectScrollTop: Boolean
});
const anchorEmits = {
change: (href) => (0, _vue_shared.isString)(href),
click: (e, href) => e instanceof MouseEvent && ((0, _vue_shared.isString)(href) || require_types.isUndefined(href))
};
//#endregion
exports.anchorEmits = anchorEmits;
exports.anchorProps = anchorProps;
//# sourceMappingURL=anchor.js.map
@@ -0,0 +1 @@
{"version":3,"file":"anchor.js","names":["buildProps","definePropType","isUndefined"],"sources":["../../../../../../packages/components/anchor/src/anchor.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n isString,\n isUndefined,\n} from '@element-plus/utils'\n\nimport type { ExtractPublicPropTypes } from 'vue'\nimport type Anchor from './anchor.vue'\n\nexport interface AnchorProps {\n /**\n * @description scroll container\n */\n container?: string | HTMLElement | Window | null\n /**\n * @description Set the offset of the anchor scroll\n */\n offset?: number\n /**\n * @description The offset of the element starting to trigger the anchor\n */\n bound?: number\n /**\n * @description Set the scroll duration of the container when the anchor is clicked, in milliseconds\n */\n duration?: number\n /**\n * @description Whether to show the marker\n */\n marker?: boolean\n /**\n * @description Set Anchor type\n */\n type?: 'default' | 'underline'\n /**\n * @description Set Anchor direction\n */\n direction?: 'vertical' | 'horizontal'\n /**\n * @description Scroll whether link is selected at the top\n */\n selectScrollTop?: boolean\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `AnchorProps` instead.\n */\nexport const anchorProps = buildProps({\n /**\n * @description scroll container\n */\n container: {\n type: definePropType<string | HTMLElement | Window | null>([\n String,\n Object,\n ]),\n },\n /**\n * @description Set the offset of the anchor scroll\n */\n offset: {\n type: Number,\n default: 0,\n },\n /**\n * @description The offset of the element starting to trigger the anchor\n */\n bound: {\n type: Number,\n default: 15,\n },\n /**\n * @description Set the scroll duration of the container when the anchor is clicked, in milliseconds\n */\n duration: {\n type: Number,\n default: 300,\n },\n /**\n * @description Whether to show the marker\n */\n marker: {\n type: Boolean,\n default: true,\n },\n /**\n * @description Set Anchor type\n */\n type: {\n type: definePropType<'default' | 'underline'>(String),\n default: 'default',\n },\n /**\n * @description Set Anchor direction\n */\n direction: {\n type: definePropType<'vertical' | 'horizontal'>(String),\n default: 'vertical',\n },\n /**\n * @description Scroll whether link is selected at the top\n */\n selectScrollTop: Boolean,\n})\n\n/**\n * @deprecated Removed after 3.0.0, Use `AnchorProps` instead.\n */\nexport type AnchorPropsPublic = ExtractPublicPropTypes<typeof anchorProps>\nexport type AnchorInstance = InstanceType<typeof Anchor> & unknown\n\nexport const anchorEmits = {\n change: (href: string) => isString(href),\n click: (e: MouseEvent, href?: string) =>\n e instanceof MouseEvent && (isString(href) || isUndefined(href)),\n}\nexport type AnchorEmits = typeof anchorEmits\n"],"mappings":";;;;;;;;;;AAgDA,MAAa,cAAcA,6BAAW;CAIpC,WAAW,EACT,MAAMC,iCAAqD,CACzD,QACA,OACD,CAAC,EACH;CAID,QAAQ;EACN,MAAM;EACN,SAAS;EACV;CAID,OAAO;EACL,MAAM;EACN,SAAS;EACV;CAID,UAAU;EACR,MAAM;EACN,SAAS;EACV;CAID,QAAQ;EACN,MAAM;EACN,SAAS;EACV;CAID,MAAM;EACJ,MAAMA,iCAAwC,OAAO;EACrD,SAAS;EACV;CAID,WAAW;EACT,MAAMA,iCAA0C,OAAO;EACvD,SAAS;EACV;CAID,iBAAiB;CAClB,CAAC;AAQF,MAAa,cAAc;CACzB,SAAS,mCAA0B,KAAK;CACxC,QAAQ,GAAe,SACrB,aAAa,yCAAwB,KAAK,IAAIC,0BAAY,KAAK;CAClE"}
@@ -0,0 +1,33 @@
import { AnchorProps } from "./anchor.js";
import * as vue from "vue";
//#region ../../packages/components/anchor/src/anchor.vue.d.ts
declare var __VLS_1: {};
type __VLS_Slots = {} & {
default?: (props: typeof __VLS_1) => any;
};
declare const __VLS_base: vue.DefineComponent<AnchorProps, {
scrollTo: (href?: string) => void;
}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
change: (href: string) => void;
click: (e: MouseEvent, href?: string | undefined) => void;
}, string, vue.PublicProps, Readonly<AnchorProps> & Readonly<{
onChange?: ((href: string) => any) | undefined;
onClick?: ((e: MouseEvent, href?: string | undefined) => any) | undefined;
}>, {
offset: number;
type: "default" | "underline";
direction: "vertical" | "horizontal";
marker: boolean;
duration: number;
bound: 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,179 @@
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
const require_event = require('../../../constants/event.js');
const require_position = require('../../../utils/dom/position.js');
const require_types = require('../../../utils/types.js');
const require_scroll = require('../../../utils/dom/scroll.js');
const require_element = require('../../../utils/dom/element.js');
const require_throttleByRaf = require('../../../utils/throttleByRaf.js');
const require_index = require('../../../hooks/use-namespace/index.js');
const require_anchor = require('./anchor.js');
const require_constants = require('./constants.js');
let _vueuse_core = require("@vueuse/core");
let vue = require("vue");
//#region ../../packages/components/anchor/src/anchor.vue?vue&type=script&setup=true&lang.ts
var anchor_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
name: "ElAnchor",
__name: "anchor",
props: require_anchor.anchorProps,
emits: require_anchor.anchorEmits,
setup(__props, { expose: __expose, emit: __emit }) {
const props = __props;
const emit = __emit;
const slots = (0, vue.useSlots)();
const currentAnchor = (0, vue.ref)("");
const markerStyle = (0, vue.ref)({});
const anchorRef = (0, vue.ref)(null);
const markerRef = (0, vue.ref)(null);
const containerEl = (0, vue.ref)();
const links = {};
let isScrolling = false;
let currentScrollTop = 0;
const ns = require_index.useNamespace("anchor");
const cls = (0, vue.computed)(() => [
ns.b(),
props.type === "underline" ? ns.m("underline") : "",
ns.m(props.direction)
]);
const addLink = (state) => {
links[state.href] = state.el;
};
const removeLink = (href) => {
delete links[href];
};
const setCurrentAnchor = (href) => {
if (currentAnchor.value !== href) {
currentAnchor.value = href;
emit(require_event.CHANGE_EVENT, href);
}
};
let clearAnimate = null;
let currentTargetHref = "";
const scrollToAnchor = (href) => {
if (!containerEl.value) return;
const target = require_element.getElement(href);
if (!target) return;
if (clearAnimate) {
if (currentTargetHref === href) return;
clearAnimate();
}
currentTargetHref = href;
isScrolling = true;
const scrollEle = require_scroll.getScrollElement(target, containerEl.value);
const distance = require_position.getOffsetTopDistance(target, scrollEle);
const max = scrollEle.scrollHeight - scrollEle.clientHeight;
const to = Math.min(distance - props.offset, max);
clearAnimate = require_scroll.animateScrollTo(containerEl.value, currentScrollTop, to, props.duration, () => {
setTimeout(() => {
isScrolling = false;
currentTargetHref = "";
}, 20);
});
};
const scrollTo = (href) => {
if (href) {
setCurrentAnchor(href);
scrollToAnchor(href);
}
};
const handleClick = (e, href) => {
emit("click", e, href);
scrollTo(href);
};
const handleScroll = require_throttleByRaf.throttleByRaf(() => {
if (containerEl.value) currentScrollTop = require_scroll.getScrollTop(containerEl.value);
const currentHref = getCurrentHref();
if (isScrolling || require_types.isUndefined(currentHref)) return;
setCurrentAnchor(currentHref);
});
const getCurrentHref = () => {
if (!containerEl.value) return;
const scrollTop = require_scroll.getScrollTop(containerEl.value);
const anchorTopList = [];
for (const href of Object.keys(links)) {
const target = require_element.getElement(href);
if (!target) continue;
const distance = require_position.getOffsetTopDistance(target, require_scroll.getScrollElement(target, containerEl.value));
anchorTopList.push({
top: distance - props.offset - props.bound,
href
});
}
anchorTopList.sort((prev, next) => prev.top - next.top);
for (let i = 0; i < anchorTopList.length; i++) {
const item = anchorTopList[i];
const next = anchorTopList[i + 1];
if (i === 0 && scrollTop === 0) return props.selectScrollTop ? item.href : "";
if (item.top <= scrollTop && (!next || next.top > scrollTop)) return item.href;
}
};
const getContainer = () => {
const el = require_element.getElement(props.container);
if (!el || require_types.isWindow(el)) containerEl.value = window;
else containerEl.value = el;
};
(0, _vueuse_core.useEventListener)(containerEl, "scroll", handleScroll);
const updateMarkerStyle = () => {
(0, vue.nextTick)(() => {
if (!anchorRef.value || !markerRef.value || !currentAnchor.value) {
markerStyle.value = {};
return;
}
const currentLinkEl = links[currentAnchor.value];
if (!currentLinkEl) {
markerStyle.value = {};
return;
}
const anchorRect = anchorRef.value.getBoundingClientRect();
const markerRect = markerRef.value.getBoundingClientRect();
const linkRect = currentLinkEl.getBoundingClientRect();
if (props.direction === "horizontal") markerStyle.value = {
left: `${linkRect.left - anchorRect.left}px`,
width: `${linkRect.width}px`,
opacity: 1
};
else markerStyle.value = {
top: `${linkRect.top - anchorRect.top + (linkRect.height - markerRect.height) / 2}px`,
opacity: 1
};
});
};
(0, vue.watch)(currentAnchor, updateMarkerStyle);
(0, vue.watch)(() => slots.default?.(), updateMarkerStyle);
(0, vue.onMounted)(() => {
getContainer();
const hash = decodeURIComponent(window.location.hash);
if (require_element.getElement(hash)) scrollTo(hash);
else handleScroll();
});
(0, vue.watch)(() => props.container, () => {
getContainer();
});
(0, vue.provide)(require_constants.anchorKey, {
ns,
direction: props.direction,
currentAnchor,
addLink,
removeLink,
handleClick
});
__expose({ scrollTo });
return (_ctx, _cache) => {
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
ref_key: "anchorRef",
ref: anchorRef,
class: (0, vue.normalizeClass)(cls.value)
}, [__props.marker ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
key: 0,
ref_key: "markerRef",
ref: markerRef,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("marker")),
style: (0, vue.normalizeStyle)(markerStyle.value)
}, null, 6)) : (0, vue.createCommentVNode)("v-if", true), (0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("list")) }, [(0, vue.renderSlot)(_ctx.$slots, "default")], 2)], 2);
};
}
});
//#endregion
exports.default = anchor_vue_vue_type_script_setup_true_lang_default;
//# sourceMappingURL=anchor.vue_vue_type_script_setup_true_lang.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_anchor_vue_vue_type_script_setup_true_lang = require('./anchor.vue_vue_type_script_setup_true_lang.js');
//#region ../../packages/components/anchor/src/anchor.vue
var anchor_default = require_anchor_vue_vue_type_script_setup_true_lang.default;
//#endregion
exports.default = anchor_default;
//# sourceMappingURL=anchor2.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
//#region ../../packages/components/anchor/src/constants.ts
const anchorKey = Symbol("anchor");
//#endregion
exports.anchorKey = anchorKey;
//# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
{"version":3,"file":"constants.js","names":[],"sources":["../../../../../../packages/components/anchor/src/constants.ts"],"sourcesContent":["import type { InjectionKey, Ref } from 'vue'\nimport type { UseNamespaceReturn } from '@element-plus/hooks'\n\nexport interface AnchorLinkState {\n el: HTMLElement\n href: string\n}\n\nexport interface AnchorContext {\n ns: UseNamespaceReturn\n direction: string\n currentAnchor: Ref<string>\n addLink(state: AnchorLinkState): void\n removeLink(href: string): void\n handleClick(e: MouseEvent, href?: string): void\n}\n\nexport const anchorKey: InjectionKey<AnchorContext> = Symbol('anchor')\n"],"mappings":";;;AAiBA,MAAa,YAAyC,OAAO,SAAS"}
@@ -0,0 +1,3 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
require('../../base/style/css.js');
require("element-plus/theme-chalk/el-anchor.css");
@@ -0,0 +1,3 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
require('../../base/style/index.js');
require("element-plus/theme-chalk/src/anchor.scss");