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,5 @@
import Affix from './src/affix.vue';
import type { SFCWithInstall } from 'element-plus/es/utils';
export declare const ElAffix: SFCWithInstall<typeof Affix>;
export default ElAffix;
export * from './src/affix';

View File

@@ -0,0 +1,15 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var affix$1 = require('./src/affix2.js');
var affix = require('./src/affix.js');
var install = require('../../utils/vue/install.js');
const ElAffix = install.withInstall(affix$1["default"]);
exports.affixEmits = affix.affixEmits;
exports.affixProps = affix.affixProps;
exports.ElAffix = ElAffix;
exports["default"] = ElAffix;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../../packages/components/affix/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport Affix from './src/affix.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElAffix: SFCWithInstall<typeof Affix> = withInstall(Affix)\nexport default ElAffix\n\nexport * from './src/affix'\n"],"names":["withInstall","Affix"],"mappings":";;;;;;;;AAEY,MAAC,OAAO,GAAGA,mBAAW,CAACC,kBAAK;;;;;;;"}

View File

@@ -0,0 +1,20 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
import type { ZIndexProperty } from 'csstype';
import type Affix from './affix.vue';
export declare const affixProps: {
readonly zIndex: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => number | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "auto") | (() => ZIndexProperty) | ((new (...args: any[]) => number | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "auto") | (() => ZIndexProperty))[], unknown, unknown, 100, boolean>;
readonly target: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly offset: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 0, boolean>;
readonly position: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "top" | "bottom", unknown, "top", boolean>;
};
export type AffixProps = ExtractPropTypes<typeof affixProps>;
export type AffixPropsPublic = __ExtractPublicPropTypes<typeof affixProps>;
export declare const affixEmits: {
scroll: ({ scrollTop, fixed }: {
scrollTop: number;
fixed: boolean;
}) => boolean;
change: (fixed: boolean) => boolean;
};
export type AffixEmits = typeof affixEmits;
export type AffixInstance = InstanceType<typeof Affix> & unknown;

View File

@@ -0,0 +1,35 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var event = require('../../../constants/event.js');
var runtime = require('../../../utils/vue/props/runtime.js');
var types = require('../../../utils/types.js');
const affixProps = runtime.buildProps({
zIndex: {
type: runtime.definePropType([Number, String]),
default: 100
},
target: {
type: String,
default: ""
},
offset: {
type: Number,
default: 0
},
position: {
type: String,
values: ["top", "bottom"],
default: "top"
}
});
const affixEmits = {
scroll: ({ scrollTop, fixed }) => types.isNumber(scrollTop) && types.isBoolean(fixed),
[event.CHANGE_EVENT]: (fixed) => types.isBoolean(fixed)
};
exports.affixEmits = affixEmits;
exports.affixProps = affixProps;
//# sourceMappingURL=affix.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"affix.js","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'\n\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\nimport type { ZIndexProperty } from 'csstype'\nimport type Affix from './affix.vue'\n\nexport const affixProps = buildProps({\n /**\n * @description affix element zIndex value\n * */\n zIndex: {\n type: definePropType<ZIndexProperty>([Number, String]),\n default: 100,\n },\n /**\n * @description target container. (CSS selector)\n */\n target: {\n type: String,\n default: '',\n },\n /**\n * @description offset distance\n * */\n offset: {\n type: Number,\n default: 0,\n },\n /**\n * @description position of affix\n * */\n position: {\n type: String,\n values: ['top', 'bottom'],\n default: 'top',\n },\n} as const)\nexport type AffixProps = ExtractPropTypes<typeof affixProps>\nexport type AffixPropsPublic = __ExtractPublicPropTypes<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> & unknown\n"],"names":["buildProps","definePropType","isNumber","isBoolean","CHANGE_EVENT"],"mappings":";;;;;;;;AAOY,MAAC,UAAU,GAAGA,kBAAU,CAAC;AACrC,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAEC,sBAAc,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,KAAKC,cAAQ,CAAC,SAAS,CAAC,IAAIC,eAAS,CAAC,KAAK,CAAC;AAC3E,EAAE,CAACC,kBAAY,GAAG,CAAC,KAAK,KAAKD,eAAS,CAAC,KAAK,CAAC;AAC7C;;;;;"}

View File

@@ -0,0 +1,44 @@
declare function __VLS_template(): {
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly zIndex: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => number | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "auto") | (() => import("csstype").ZIndexProperty) | ((new (...args: any[]) => number | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "auto") | (() => import("csstype").ZIndexProperty))[], unknown, unknown, 100, boolean>;
readonly target: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly offset: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 0, boolean>;
readonly position: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "top" | "bottom", unknown, "top", boolean>;
}, {
/** @description update affix status */
update: () => void;
/** @description update rootRect info */
updateRoot: () => Promise<void>;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
scroll: (args_0: {
scrollTop: number;
fixed: boolean;
}) => void;
change: (fixed: boolean) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly zIndex: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => number | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "auto") | (() => import("csstype").ZIndexProperty) | ((new (...args: any[]) => number | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "auto") | (() => import("csstype").ZIndexProperty))[], unknown, unknown, 100, boolean>;
readonly target: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly offset: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 0, boolean>;
readonly position: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "top" | "bottom", unknown, "top", boolean>;
}>> & {
onScroll?: ((args_0: {
scrollTop: number;
fixed: boolean;
}) => any) | undefined;
onChange?: ((fixed: boolean) => any) | undefined;
}, {
readonly position: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "top" | "bottom", unknown>;
readonly zIndex: import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => number | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "auto") | (() => import("csstype").ZIndexProperty) | ((new (...args: any[]) => number | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "auto") | (() => import("csstype").ZIndexProperty))[], unknown, unknown>;
readonly offset: number;
readonly target: string;
}>;
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,139 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var core = require('@vueuse/core');
var affix = require('./affix.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
var scroll = require('../../../utils/dom/scroll.js');
var style = require('../../../utils/dom/style.js');
var event = require('../../../constants/event.js');
var error = require('../../../utils/error.js');
const COMPONENT_NAME = "ElAffix";
const __default__ = vue.defineComponent({
name: COMPONENT_NAME
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: affix.affixProps,
emits: affix.affixEmits,
setup(__props, { expose, emit }) {
const props = __props;
const ns = index.useNamespace("affix");
const target = vue.shallowRef();
const root = vue.shallowRef();
const scrollContainer = vue.shallowRef();
const { height: windowHeight } = core.useWindowSize();
const {
height: rootHeight,
width: rootWidth,
top: rootTop,
bottom: rootBottom,
update: updateRoot
} = core.useElementBounding(root, { windowScroll: false });
const targetRect = core.useElementBounding(target);
const fixed = vue.ref(false);
const scrollTop = vue.ref(0);
const transform = vue.ref(0);
const rootStyle = vue.computed(() => {
return {
height: fixed.value ? `${rootHeight.value}px` : "",
width: fixed.value ? `${rootWidth.value}px` : ""
};
});
const affixStyle = vue.computed(() => {
if (!fixed.value)
return {};
const offset = props.offset ? style.addUnit(props.offset) : 0;
return {
height: `${rootHeight.value}px`,
width: `${rootWidth.value}px`,
top: props.position === "top" ? offset : "",
bottom: props.position === "bottom" ? offset : "",
transform: transform.value ? `translateY(${transform.value}px)` : "",
zIndex: props.zIndex
};
});
const update = () => {
if (!scrollContainer.value)
return;
scrollTop.value = scrollContainer.value instanceof Window ? document.documentElement.scrollTop : scrollContainer.value.scrollTop || 0;
const { position, target: target2, offset } = props;
const rootHeightOffset = offset + rootHeight.value;
if (position === "top") {
if (target2) {
const difference = targetRect.bottom.value - rootHeightOffset;
fixed.value = offset > rootTop.value && targetRect.bottom.value > 0;
transform.value = difference < 0 ? difference : 0;
} else {
fixed.value = offset > rootTop.value;
}
} else if (target2) {
const difference = windowHeight.value - targetRect.top.value - rootHeightOffset;
fixed.value = windowHeight.value - offset < rootBottom.value && windowHeight.value > targetRect.top.value;
transform.value = difference < 0 ? -difference : 0;
} else {
fixed.value = windowHeight.value - offset < rootBottom.value;
}
};
const updateRootRect = async () => {
if (!fixed.value) {
updateRoot();
return;
}
fixed.value = false;
await vue.nextTick();
updateRoot();
fixed.value = true;
};
const handleScroll = async () => {
updateRoot();
await vue.nextTick();
emit("scroll", {
scrollTop: scrollTop.value,
fixed: fixed.value
});
};
vue.watch(fixed, (val) => emit(event.CHANGE_EVENT, val));
vue.onMounted(() => {
var _a;
if (props.target) {
target.value = (_a = document.querySelector(props.target)) != null ? _a : void 0;
if (!target.value)
error.throwError(COMPONENT_NAME, `Target does not exist: ${props.target}`);
} else {
target.value = document.documentElement;
}
scrollContainer.value = scroll.getScrollContainer(root.value, true);
updateRoot();
});
core.useEventListener(scrollContainer, "scroll", handleScroll);
vue.watchEffect(update);
expose({
update,
updateRoot: updateRootRect
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
ref_key: "root",
ref: root,
class: vue.normalizeClass(vue.unref(ns).b()),
style: vue.normalizeStyle(vue.unref(rootStyle))
}, [
vue.createElementVNode("div", {
class: vue.normalizeClass({ [vue.unref(ns).m("fixed")]: fixed.value }),
style: vue.normalizeStyle(vue.unref(affixStyle))
}, [
vue.renderSlot(_ctx.$slots, "default")
], 6)
], 6);
};
}
});
var Affix = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "affix.vue"]]);
exports["default"] = Affix;
//# sourceMappingURL=affix2.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style/css';
import 'element-plus/theme-chalk/el-affix.css';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/css.js');
require('element-plus/theme-chalk/el-affix.css');
//# sourceMappingURL=css.js.map

View File

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

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style';
import 'element-plus/theme-chalk/src/affix.scss';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/index.js');
require('element-plus/theme-chalk/src/affix.scss');
//# sourceMappingURL=index.js.map

View File

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

View File

@@ -0,0 +1,6 @@
import Alert from './src/alert.vue';
import type { SFCWithInstall } from 'element-plus/es/utils';
export declare const ElAlert: SFCWithInstall<typeof Alert>;
export default ElAlert;
export * from './src/alert';
export type { AlertInstance } from './src/instance';

View File

@@ -0,0 +1,16 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var alert$1 = require('./src/alert.js');
var alert = require('./src/alert2.js');
var install = require('../../utils/vue/install.js');
const ElAlert = install.withInstall(alert$1["default"]);
exports.alertEffects = alert.alertEffects;
exports.alertEmits = alert.alertEmits;
exports.alertProps = alert.alertProps;
exports.ElAlert = ElAlert;
exports["default"] = ElAlert;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../../packages/components/alert/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport Alert from './src/alert.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElAlert: SFCWithInstall<typeof Alert> = withInstall(Alert)\nexport default ElAlert\n\nexport * from './src/alert'\nexport type { AlertInstance } from './src/instance'\n"],"names":["withInstall","Alert"],"mappings":";;;;;;;;AAEY,MAAC,OAAO,GAAGA,mBAAW,CAACC,kBAAK;;;;;;;;"}

View File

@@ -0,0 +1,22 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
export declare const alertEffects: readonly ["light", "dark"];
export declare const alertProps: {
readonly showAfter: NumberConstructor;
readonly hideAfter: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 200, boolean>;
readonly autoClose: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 0, boolean>;
readonly title: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly description: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "error" | "primary" | "success" | "warning" | "info", unknown, "info", boolean>;
readonly closable: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly closeText: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly showIcon: BooleanConstructor;
readonly center: BooleanConstructor;
readonly effect: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "dark" | "light", unknown, "light", boolean>;
};
export type AlertProps = ExtractPropTypes<typeof alertProps>;
export type AlertPropsPublic = __ExtractPublicPropTypes<typeof alertProps>;
export declare const alertEmits: {
open: () => boolean;
close: (evt?: Event) => boolean;
};
export type AlertEmits = typeof alertEmits;

View File

@@ -0,0 +1,117 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var index$2 = require('../../icon/index.js');
var alert = require('./alert2.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index$1 = require('../../../hooks/use-delayed-toggle/index.js');
var icon = require('../../../utils/vue/icon.js');
var index = require('../../../hooks/use-namespace/index.js');
var types = require('../../../utils/types.js');
var core = require('@vueuse/core');
const __default__ = vue.defineComponent({
name: "ElAlert"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: alert.alertProps,
emits: alert.alertEmits,
setup(__props, { emit }) {
const props = __props;
const { Close } = icon.TypeComponents;
const slots = vue.useSlots();
const ns = index.useNamespace("alert");
const visible = vue.ref(types.isUndefined(props.showAfter));
const iconComponent = vue.computed(() => icon.TypeComponentsMap[props.type]);
const hasDesc = vue.computed(() => !!(props.description || slots.default));
const open = () => {
visible.value = true;
emit("open");
};
const close = (event) => {
visible.value = false;
emit("close", event);
};
const { onOpen, onClose } = index$1.useDelayedToggle({
showAfter: vue.toRef(props, "showAfter", 0),
hideAfter: vue.toRef(props, "hideAfter"),
autoClose: vue.toRef(props, "autoClose"),
open,
close
});
if (core.isClient) {
onOpen();
}
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.Transition, {
name: vue.unref(ns).b("fade"),
persisted: ""
}, {
default: vue.withCtx(() => [
vue.withDirectives(vue.createElementVNode("div", {
class: vue.normalizeClass([vue.unref(ns).b(), vue.unref(ns).m(_ctx.type), vue.unref(ns).is("center", _ctx.center), vue.unref(ns).is(_ctx.effect)]),
role: "alert"
}, [
_ctx.showIcon && (_ctx.$slots.icon || vue.unref(iconComponent)) ? (vue.openBlock(), vue.createBlock(vue.unref(index$2.ElIcon), {
key: 0,
class: vue.normalizeClass([vue.unref(ns).e("icon"), { [vue.unref(ns).is("big")]: vue.unref(hasDesc) }])
}, {
default: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "icon", {}, () => [
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(iconComponent))))
])
]),
_: 3
}, 8, ["class"])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("div", {
class: vue.normalizeClass(vue.unref(ns).e("content"))
}, [
_ctx.title || _ctx.$slots.title ? (vue.openBlock(), vue.createElementBlock("span", {
key: 0,
class: vue.normalizeClass([vue.unref(ns).e("title"), { "with-description": vue.unref(hasDesc) }])
}, [
vue.renderSlot(_ctx.$slots, "title", {}, () => [
vue.createTextVNode(vue.toDisplayString(_ctx.title), 1)
])
], 2)) : vue.createCommentVNode("v-if", true),
vue.unref(hasDesc) ? (vue.openBlock(), vue.createElementBlock("p", {
key: 1,
class: vue.normalizeClass(vue.unref(ns).e("description"))
}, [
vue.renderSlot(_ctx.$slots, "default", {}, () => [
vue.createTextVNode(vue.toDisplayString(_ctx.description), 1)
])
], 2)) : vue.createCommentVNode("v-if", true),
_ctx.closable ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
_ctx.closeText ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: vue.normalizeClass([vue.unref(ns).e("close-btn"), vue.unref(ns).is("customed")]),
onClick: close
}, vue.toDisplayString(_ctx.closeText), 3)) : (vue.openBlock(), vue.createBlock(vue.unref(index$2.ElIcon), {
key: 1,
class: vue.normalizeClass(vue.unref(ns).e("close-btn")),
onClick: vue.unref(onClose)
}, {
default: vue.withCtx(() => [
vue.createVNode(vue.unref(Close))
]),
_: 1
}, 8, ["class", "onClick"]))
], 64)) : vue.createCommentVNode("v-if", true)
], 2)
], 2), [
[vue.vShow, visible.value]
])
]),
_: 3
}, 8, ["name"]);
};
}
});
var Alert = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "alert.vue"]]);
exports["default"] = Alert;
//# sourceMappingURL=alert.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"alert.js","sources":["../../../../../../packages/components/alert/src/alert.vue"],"sourcesContent":["<template>\n <transition :name=\"ns.b('fade')\">\n <div\n v-show=\"visible\"\n :class=\"[ns.b(), ns.m(type), ns.is('center', center), ns.is(effect)]\"\n role=\"alert\"\n >\n <el-icon\n v-if=\"showIcon && ($slots.icon || iconComponent)\"\n :class=\"[ns.e('icon'), { [ns.is('big')]: hasDesc }]\"\n >\n <slot name=\"icon\">\n <component :is=\"iconComponent\" />\n </slot>\n </el-icon>\n\n <div :class=\"ns.e('content')\">\n <span\n v-if=\"title || $slots.title\"\n :class=\"[ns.e('title'), { 'with-description': hasDesc }]\"\n >\n <slot name=\"title\">{{ title }}</slot>\n </span>\n <p v-if=\"hasDesc\" :class=\"ns.e('description')\">\n <slot>\n {{ description }}\n </slot>\n </p>\n <template v-if=\"closable\">\n <div\n v-if=\"closeText\"\n :class=\"[ns.e('close-btn'), ns.is('customed')]\"\n @click=\"close\"\n >\n {{ closeText }}\n </div>\n <el-icon v-else :class=\"ns.e('close-btn')\" @click=\"onClose\">\n <Close />\n </el-icon>\n </template>\n </div>\n </div>\n </transition>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, ref, toRef, useSlots } from 'vue'\nimport { ElIcon } from '@element-plus/components/icon'\nimport {\n TypeComponents,\n TypeComponentsMap,\n isClient,\n isUndefined,\n} from '@element-plus/utils'\nimport { useDelayedToggle, useNamespace } from '@element-plus/hooks'\nimport { alertEmits, alertProps } from './alert'\n\nconst { Close } = TypeComponents\n\ndefineOptions({\n name: 'ElAlert',\n})\n\nconst props = defineProps(alertProps)\nconst emit = defineEmits(alertEmits)\nconst slots = useSlots()\n\nconst ns = useNamespace('alert')\n\nconst visible = ref(isUndefined(props.showAfter))\n\nconst iconComponent = computed(() => TypeComponentsMap[props.type])\n\nconst hasDesc = computed(() => !!(props.description || slots.default))\n\nconst open = () => {\n visible.value = true\n emit('open')\n}\n\nconst close = (event?: Event) => {\n visible.value = false\n emit('close', event)\n}\n\nconst { onOpen, onClose } = useDelayedToggle({\n showAfter: toRef(props, 'showAfter', 0),\n hideAfter: toRef(props, 'hideAfter'),\n autoClose: toRef(props, 'autoClose'),\n open,\n close,\n})\n\nif (isClient) {\n onOpen()\n}\n</script>\n"],"names":["TypeComponents","useSlots","useNamespace","ref","isUndefined","computed","TypeComponentsMap","useDelayedToggle","toRef","isClient"],"mappings":";;;;;;;;;;;;;;uCA2Dc,CAAA;AAAA,EACZ,IAAM,EAAA,SAAA;AACR,CAAA,CAAA,CAAA;;;;;;;AAJA,IAAM,MAAA,EAAE,OAAU,GAAAA,mBAAA,CAAA;AAQlB,IAAA,MAAM,QAAQC,YAAS,EAAA,CAAA;AAEvB,IAAM,MAAA,EAAA,GAAKC,mBAAa,OAAO,CAAA,CAAA;AAE/B,IAAA,MAAM,OAAU,GAAAC,OAAA,CAAIC,iBAAY,CAAA,KAAA,CAAM,SAAS,CAAC,CAAA,CAAA;AAEhD,IAAA,MAAM,gBAAgBC,YAAS,CAAA,MAAMC,sBAAkB,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA,CAAA;AAElE,IAAM,MAAA,OAAA,GAAUD,aAAS,MAAM,CAAC,EAAE,KAAM,CAAA,WAAA,IAAe,MAAM,OAAQ,CAAA,CAAA,CAAA;AAErE,IAAA,MAAM,OAAO,MAAM;AACjB,MAAA,OAAA,CAAQ,KAAQ,GAAA,IAAA,CAAA;AAChB,MAAA,IAAA,CAAK,MAAM,CAAA,CAAA;AAAA,KACb,CAAA;AAEA,IAAM,MAAA,KAAA,GAAQ,CAAC,KAAkB,KAAA;AAC/B,MAAA,OAAA,CAAQ,KAAQ,GAAA,KAAA,CAAA;AAChB,MAAA,IAAA,CAAK,SAAS,KAAK,CAAA,CAAA;AAAA,KACrB,CAAA;AAEA,IAAA,MAAM,EAAE,MAAA,EAAQ,OAAQ,EAAA,GAAIE,wBAAiB,CAAA;AAAA,MAC3C,SAAW,EAAAC,SAAA,CAAM,KAAO,EAAA,WAAA,EAAa,CAAC,CAAA;AAAA,MACtC,SAAA,EAAWA,SAAM,CAAA,KAAA,EAAO,WAAW,CAAA;AAAA,MACnC,SAAA,EAAWA,SAAM,CAAA,KAAA,EAAO,WAAW,CAAA;AAAA,MACnC,IAAA;AAAA,MACA,KAAA;AAAA,KACD,CAAA,CAAA;AAED,IAAA,IAAIC,aAAU,EAAA;AACZ,MAAO,MAAA,EAAA,CAAA;AAAA,KACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,54 @@
declare function __VLS_template(): {
icon?(_: {}): any;
title?(_: {}): any;
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly showAfter: NumberConstructor;
readonly hideAfter: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 200, boolean>;
readonly autoClose: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 0, boolean>;
readonly title: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly description: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "error" | "primary" | "success" | "warning" | "info", unknown, "info", boolean>;
readonly closable: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly closeText: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly showIcon: BooleanConstructor;
readonly center: BooleanConstructor;
readonly effect: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "dark" | "light", unknown, "light", boolean>;
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
open: () => void;
close: (evt?: Event | undefined) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly showAfter: NumberConstructor;
readonly hideAfter: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 200, boolean>;
readonly autoClose: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 0, boolean>;
readonly title: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly description: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "error" | "primary" | "success" | "warning" | "info", unknown, "info", boolean>;
readonly closable: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly closeText: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly showIcon: BooleanConstructor;
readonly center: BooleanConstructor;
readonly effect: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "dark" | "light", unknown, "light", boolean>;
}>> & {
onOpen?: (() => any) | undefined;
onClose?: ((evt?: Event | undefined) => any) | undefined;
}, {
readonly title: string;
readonly center: boolean;
readonly type: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "error" | "primary" | "success" | "warning" | "info", unknown>;
readonly description: string;
readonly effect: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "dark" | "light", unknown>;
readonly hideAfter: number;
readonly autoClose: number;
readonly closable: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;
readonly closeText: string;
readonly showIcon: boolean;
}>;
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,52 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var index = require('../../../hooks/use-delayed-toggle/index.js');
var icon = require('../../../utils/vue/icon.js');
var runtime = require('../../../utils/vue/props/runtime.js');
var objects = require('../../../utils/objects.js');
var types = require('../../../utils/types.js');
const alertEffects = ["light", "dark"];
const alertProps = runtime.buildProps({
title: {
type: String,
default: ""
},
description: {
type: String,
default: ""
},
type: {
type: String,
values: objects.keysOf(icon.TypeComponentsMap),
default: "info"
},
closable: {
type: Boolean,
default: true
},
closeText: {
type: String,
default: ""
},
showIcon: Boolean,
center: Boolean,
effect: {
type: String,
values: alertEffects,
default: "light"
},
...index.useDelayedToggleProps,
showAfter: Number
});
const alertEmits = {
open: () => true,
close: (evt) => types.isUndefined(evt) || evt instanceof Event
};
exports.alertEffects = alertEffects;
exports.alertEmits = alertEmits;
exports.alertProps = alertProps;
//# sourceMappingURL=alert2.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"alert2.js","sources":["../../../../../../packages/components/alert/src/alert.ts"],"sourcesContent":["import { useDelayedToggleProps } from '@element-plus/hooks'\nimport {\n TypeComponentsMap,\n buildProps,\n isUndefined,\n keysOf,\n} from '@element-plus/utils'\n\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\n\nexport const alertEffects = ['light', 'dark'] as const\n\nexport const alertProps = buildProps({\n /**\n * @description alert title.\n */\n title: {\n type: String,\n default: '',\n },\n description: {\n type: String,\n default: '',\n },\n /**\n * @description alert type.\n */\n type: {\n type: String,\n values: keysOf(TypeComponentsMap),\n default: 'info',\n },\n /**\n * @description whether alert can be dismissed.\n */\n closable: {\n type: Boolean,\n default: true,\n },\n /**\n * @description text for replacing x button\n */\n closeText: {\n type: String,\n default: '',\n },\n /**\n * @description whether show icon\n */\n showIcon: Boolean,\n /**\n * @description should content be placed in center.\n */\n center: Boolean,\n effect: {\n type: String,\n values: alertEffects,\n default: 'light',\n },\n ...useDelayedToggleProps,\n /**\n * @description delay of appearance, in millisecond\n */\n showAfter: Number,\n} as const)\nexport type AlertProps = ExtractPropTypes<typeof alertProps>\nexport type AlertPropsPublic = __ExtractPublicPropTypes<typeof alertProps>\n\nexport const alertEmits = {\n open: () => true,\n close: (evt?: Event) => isUndefined(evt) || evt instanceof Event,\n}\nexport type AlertEmits = typeof alertEmits\n"],"names":["buildProps","keysOf","TypeComponentsMap","useDelayedToggleProps","isUndefined"],"mappings":";;;;;;;;;;AAOY,MAAC,YAAY,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE;AAClC,MAAC,UAAU,GAAGA,kBAAU,CAAC;AACrC,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAEC,cAAM,CAACC,sBAAiB,CAAC;AACrC,IAAI,OAAO,EAAE,MAAM;AACnB,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,SAAS,EAAE;AACb,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,MAAM,EAAE,OAAO;AACjB,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,YAAY;AACxB,IAAI,OAAO,EAAE,OAAO;AACpB,GAAG;AACH,EAAE,GAAGC,2BAAqB;AAC1B,EAAE,SAAS,EAAE,MAAM;AACnB,CAAC,EAAE;AACS,MAAC,UAAU,GAAG;AAC1B,EAAE,IAAI,EAAE,MAAM,IAAI;AAClB,EAAE,KAAK,EAAE,CAAC,GAAG,KAAKC,iBAAW,CAAC,GAAG,CAAC,IAAI,GAAG,YAAY,KAAK;AAC1D;;;;;;"}

View File

@@ -0,0 +1,2 @@
import type Alert from './alert.vue';
export type AlertInstance = InstanceType<typeof Alert> & 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,2 @@
import 'element-plus/es/components/base/style/css';
import 'element-plus/theme-chalk/el-alert.css';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/css.js');
require('element-plus/theme-chalk/el-alert.css');
//# sourceMappingURL=css.js.map

View File

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

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style';
import 'element-plus/theme-chalk/src/alert.scss';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/index.js');
require('element-plus/theme-chalk/src/alert.scss');
//# sourceMappingURL=index.js.map

View File

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

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style/css';
import 'element-plus/theme-chalk/el-anchor-link.css';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/css.js');
require('element-plus/theme-chalk/el-anchor-link.css');
//# sourceMappingURL=css.js.map

View File

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

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style';
import 'element-plus/theme-chalk/src/anchor-link.scss';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/index.js');
require('element-plus/theme-chalk/src/anchor-link.scss');
//# sourceMappingURL=index.js.map

View File

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

View File

@@ -0,0 +1,9 @@
import Anchor from './src/anchor.vue';
import AnchorLink from './src/anchor-link.vue';
import type { SFCWithInstall } from 'element-plus/es/utils';
export declare const ElAnchor: SFCWithInstall<typeof Anchor> & {
AnchorLink: typeof AnchorLink;
};
export declare const ElAnchorLink: SFCWithInstall<typeof AnchorLink>;
export default ElAnchor;
export * from './src/anchor';

View File

@@ -0,0 +1,20 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var anchor$1 = require('./src/anchor2.js');
var anchorLink = require('./src/anchor-link2.js');
var anchor = require('./src/anchor.js');
var install = require('../../utils/vue/install.js');
const ElAnchor = install.withInstall(anchor$1["default"], {
AnchorLink: anchorLink["default"]
});
const ElAnchorLink = install.withNoopInstall(anchorLink["default"]);
exports.anchorEmits = anchor.anchorEmits;
exports.anchorProps = anchor.anchorProps;
exports.ElAnchor = ElAnchor;
exports.ElAnchorLink = ElAnchorLink;
exports["default"] = ElAnchor;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","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"],"names":["withInstall","Anchor","AnchorLink","withNoopInstall"],"mappings":";;;;;;;;;AAGY,MAAC,QAAQ,GAAGA,mBAAW,CAACC,mBAAM,EAAE;AAC5C,cAAEC,qBAAU;AACZ,CAAC,EAAE;AACS,MAAC,YAAY,GAAGC,uBAAe,CAACD,qBAAU;;;;;;;;"}

View File

@@ -0,0 +1,7 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
export declare const anchorLinkProps: {
title: StringConstructor;
href: StringConstructor;
};
export type AnchorLinkProps = ExtractPropTypes<typeof anchorLinkProps>;
export type AnchorLinkPropsPublic = __ExtractPublicPropTypes<typeof anchorLinkProps>;

View File

@@ -0,0 +1,13 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var runtime = require('../../../utils/vue/props/runtime.js');
const anchorLinkProps = runtime.buildProps({
title: String,
href: String
});
exports.anchorLinkProps = anchorLinkProps;
//# sourceMappingURL=anchor-link.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"anchor-link.js","sources":["../../../../../../packages/components/anchor/src/anchor-link.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils'\n\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\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\nexport type AnchorLinkProps = ExtractPropTypes<typeof anchorLinkProps>\nexport type AnchorLinkPropsPublic = __ExtractPublicPropTypes<\n typeof anchorLinkProps\n>\n"],"names":["buildProps"],"mappings":";;;;;;AACY,MAAC,eAAe,GAAGA,kBAAU,CAAC;AAC1C,EAAE,KAAK,EAAE,MAAM;AACf,EAAE,IAAI,EAAE,MAAM;AACd,CAAC;;;;"}

View File

@@ -0,0 +1,18 @@
declare function __VLS_template(): {
default?(_: {}): any;
"sub-link"?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
title: StringConstructor;
href: StringConstructor;
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
title: StringConstructor;
href: StringConstructor;
}>>, {}>;
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,89 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var anchorLink = require('./anchor-link.js');
var constants = require('./constants.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
const __default__ = vue.defineComponent({
name: "ElAnchorLink"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: anchorLink.anchorLinkProps,
setup(__props) {
const props = __props;
const linkRef = vue.ref(null);
const {
ns,
direction,
currentAnchor,
addLink,
removeLink,
handleClick: contextHandleClick
} = vue.inject(constants.anchorKey);
const cls = vue.computed(() => [
ns.e("link"),
ns.is("active", currentAnchor.value === props.href)
]);
const handleClick = (e) => {
contextHandleClick(e, props.href);
};
vue.watch(() => props.href, (val, oldVal) => {
vue.nextTick(() => {
if (oldVal)
removeLink(oldVal);
if (val) {
addLink({
href: val,
el: linkRef.value
});
}
});
});
vue.onMounted(() => {
const { href } = props;
if (href) {
addLink({
href,
el: linkRef.value
});
}
});
vue.onBeforeUnmount(() => {
const { href } = props;
if (href) {
removeLink(href);
}
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass(vue.unref(ns).e("item"))
}, [
vue.createElementVNode("a", {
ref_key: "linkRef",
ref: linkRef,
class: vue.normalizeClass(vue.unref(cls)),
href: _ctx.href,
onClick: handleClick
}, [
vue.renderSlot(_ctx.$slots, "default", {}, () => [
vue.createTextVNode(vue.toDisplayString(_ctx.title), 1)
])
], 10, ["href"]),
_ctx.$slots["sub-link"] && vue.unref(direction) === "vertical" ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: vue.normalizeClass(vue.unref(ns).e("list"))
}, [
vue.renderSlot(_ctx.$slots, "sub-link")
], 2)) : vue.createCommentVNode("v-if", true)
], 2);
};
}
});
var AnchorLink = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "anchor-link.vue"]]);
exports["default"] = AnchorLink;
//# sourceMappingURL=anchor-link2.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"anchor-link2.js","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 { anchorLinkProps } from './anchor-link'\nimport { anchorKey } from './constants'\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"],"names":["ref","inject","anchorKey","computed","watch","nextTick","onMounted","onBeforeUnmount","_openBlock","_createElementBlock"],"mappings":";;;;;;;;;uCA2Bc,CAAA;AAAA,EACZ,IAAM,EAAA,cAAA;AACR,CAAA,CAAA,CAAA;;;;;;AAIA,IAAM,MAAA,OAAA,GAAUA,QAAwB,IAAI,CAAA,CAAA;AAE5C,IAAM,MAAA;AAAA,MACJ,EAAA;AAAA,MACA,SAAA;AAAA,MACA,aAAA;AAAA,MACA,OAAA;AAAA,MACA,UAAA;AAAA,MACA,WAAa,EAAA,kBAAA;AAAA,KACf,GAAIC,WAAOC,mBAAS,CAAA,CAAA;AAEpB,IAAM,MAAA,GAAA,GAAMC,aAAS,MAAM;AAAA,MACzB,EAAA,CAAG,EAAE,MAAM,CAAA;AAAA,MACX,GAAG,EAAG,CAAA,QAAA,EAAU,aAAc,CAAA,KAAA,KAAU,MAAM,IAAI,CAAA;AAAA,KACnD,CAAA,CAAA;AAED,IAAM,MAAA,WAAA,GAAc,CAAC,CAAkB,KAAA;AACrC,MAAmB,kBAAA,CAAA,CAAA,EAAG,MAAM,IAAI,CAAA,CAAA;AAAA,KAClC,CAAA;AAEA,IAAAC,SAAA,CAAA,MAAA,KAAA,CAAA,IAAA,EAAA,CAAA,GAAA,EAAA,MAAA,KAAA;AAAA,MACEC,YAAY,CAAA,MAAA;AAAA,YACN,MAAW;AACf,UAAA,UAAe,CAAA,MAAA,CAAA,CAAA;AACb,QAAI,IAAA,GAAA,EAAA;AACJ,UAAA,OAAS,CAAA;AACP,YAAQ,IAAA,EAAA,GAAA;AAAA,YAAA,EACN,EAAM,OAAA,CAAA,KAAA;AAAA,WAAA,CAAA,CAAA;AACM,SAAA;AACb,OACH,CAAA,CAAA;AAAA,KAAA,CAAA,CAAA;AACD,IACHC,aAAA,CAAA,MAAA;AAAA,MACF,MAAA,EAAA,IAAA,EAAA,GAAA,KAAA,CAAA;AAEA,MAAA,IAAA,IAAU,EAAM;AACd,QAAM;AACN,UAAI,IAAM;AACR,UAAQ,EAAA,EAAA,OAAA,CAAA,KAAA;AAAA,SACN,CAAA,CAAA;AAAA,OAAA;AACY,KAAA,CAAA,CAAA;AACb,IACHC,mBAAA,CAAA,MAAA;AAAA,MACD,MAAA,EAAA,IAAA,EAAA,GAAA,KAAA,CAAA;AAED,MAAA,IAAA,IAAA,EAAA;AACE,QAAM,WAAO,IAAI,CAAA,CAAA;AACjB,OAAA;AACE,KAAA,CAAA,CAAA;AAAe,IACjB,OAAA,CAAA,IAAA,EAAA,MAAA,KAAA;AAAA,MACD,OAAAC,aAAA,EAAA,EAAAC,sBAAA,CAAA,KAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,25 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
import type Anchor from './anchor.vue';
export declare const anchorProps: {
container: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => string | HTMLElement | Window) | (() => string | HTMLElement | Window | null) | ((new (...args: any[]) => string | HTMLElement | Window) | (() => string | HTMLElement | Window | null))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
offset: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
bound: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
duration: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
marker: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, boolean, boolean>;
type: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => "default" | "underline") | (() => "default" | "underline") | ((new (...args: any[]) => "default" | "underline") | (() => "default" | "underline"))[], unknown, unknown, string, boolean>;
direction: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical") | ((new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical"))[], unknown, unknown, string, boolean>;
selectScrollTop: BooleanConstructor;
};
export type AnchorProps = ExtractPropTypes<typeof anchorProps>;
export type AnchorPropsPublic = __ExtractPublicPropTypes<typeof anchorProps>;
export type AnchorInstance = InstanceType<typeof Anchor> & unknown;
export declare const anchorEmits: {
change: (href: string) => boolean;
click: (e: MouseEvent, href?: string) => boolean;
};
export type AnchorEmits = typeof anchorEmits;

View File

@@ -0,0 +1,49 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var runtime = require('../../../utils/vue/props/runtime.js');
var shared = require('@vue/shared');
var types = require('../../../utils/types.js');
const anchorProps = runtime.buildProps({
container: {
type: runtime.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: runtime.definePropType(String),
default: "default"
},
direction: {
type: runtime.definePropType(String),
default: "vertical"
},
selectScrollTop: Boolean
});
const anchorEmits = {
change: (href) => shared.isString(href),
click: (e, href) => e instanceof MouseEvent && (shared.isString(href) || types.isUndefined(href))
};
exports.anchorEmits = anchorEmits;
exports.anchorProps = anchorProps;
//# sourceMappingURL=anchor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"anchor.js","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 { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\nimport type Anchor from './anchor.vue'\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\nexport type AnchorProps = ExtractPropTypes<typeof anchorProps>\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"],"names":["buildProps","definePropType","isString","isUndefined"],"mappings":";;;;;;;;AAMY,MAAC,WAAW,GAAGA,kBAAU,CAAC;AACtC,EAAE,SAAS,EAAE;AACb,IAAI,IAAI,EAAEC,sBAAc,CAAC;AACzB,MAAM,MAAM;AACZ,MAAM,MAAM;AACZ,KAAK,CAAC;AACN,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,CAAC;AACd,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,GAAG;AAChB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAEA,sBAAc,CAAC,MAAM,CAAC;AAChC,IAAI,OAAO,EAAE,SAAS;AACtB,GAAG;AACH,EAAE,SAAS,EAAE;AACb,IAAI,IAAI,EAAEA,sBAAc,CAAC,MAAM,CAAC;AAChC,IAAI,OAAO,EAAE,UAAU;AACvB,GAAG;AACH,EAAE,eAAe,EAAE,OAAO;AAC1B,CAAC,EAAE;AACS,MAAC,WAAW,GAAG;AAC3B,EAAE,MAAM,EAAE,CAAC,IAAI,KAAKC,eAAQ,CAAC,IAAI,CAAC;AAClC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,YAAY,UAAU,KAAKA,eAAQ,CAAC,IAAI,CAAC,IAAIC,iBAAW,CAAC,IAAI,CAAC,CAAC;AACtF;;;;;"}

View File

@@ -0,0 +1,55 @@
declare function __VLS_template(): {
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
container: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => string | HTMLElement | Window) | (() => string | HTMLElement | Window | null) | ((new (...args: any[]) => string | HTMLElement | Window) | (() => string | HTMLElement | Window | null))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
offset: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
bound: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
duration: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
marker: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, boolean, boolean>;
type: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => "default" | "underline") | (() => "default" | "underline") | ((new (...args: any[]) => "default" | "underline") | (() => "default" | "underline"))[], unknown, unknown, string, boolean>;
direction: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical") | ((new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical"))[], unknown, unknown, string, boolean>;
selectScrollTop: BooleanConstructor;
}, {
scrollTo: (href?: string) => void;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
click: (e: MouseEvent, href?: string | undefined) => void;
change: (href: string) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
container: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => string | HTMLElement | Window) | (() => string | HTMLElement | Window | null) | ((new (...args: any[]) => string | HTMLElement | Window) | (() => string | HTMLElement | Window | null))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
offset: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
bound: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
duration: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, number, boolean>;
marker: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, boolean, boolean>;
type: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => "default" | "underline") | (() => "default" | "underline") | ((new (...args: any[]) => "default" | "underline") | (() => "default" | "underline"))[], unknown, unknown, string, boolean>;
direction: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical") | ((new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical"))[], unknown, unknown, string, boolean>;
selectScrollTop: BooleanConstructor;
}>> & {
onChange?: ((href: string) => any) | undefined;
onClick?: ((e: MouseEvent, href?: string | undefined) => any) | undefined;
}, {
marker: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;
direction: import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical") | ((new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical"))[], unknown, unknown>;
offset: number;
type: import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => "default" | "underline") | (() => "default" | "underline") | ((new (...args: any[]) => "default" | "underline") | (() => "default" | "underline"))[], unknown, unknown>;
duration: number;
bound: number;
selectScrollTop: boolean;
}>;
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,215 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var core = require('@vueuse/core');
var anchor = require('./anchor.js');
var constants = require('./constants.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var element = require('../../../utils/dom/element.js');
var throttleByRaf = require('../../../utils/throttleByRaf.js');
var scroll = require('../../../utils/dom/scroll.js');
var position = require('../../../utils/dom/position.js');
var index = require('../../../hooks/use-namespace/index.js');
var types = require('../../../utils/types.js');
var event = require('../../../constants/event.js');
const __default__ = vue.defineComponent({
name: "ElAnchor"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: anchor.anchorProps,
emits: anchor.anchorEmits,
setup(__props, { expose, emit }) {
const props = __props;
const slots = vue.useSlots();
const currentAnchor = vue.ref("");
const markerStyle = vue.ref({});
const anchorRef = vue.ref(null);
const markerRef = vue.ref(null);
const containerEl = vue.ref();
const links = {};
let isScrolling = false;
let currentScrollTop = 0;
const ns = index.useNamespace("anchor");
const cls = 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) => {
const activeHref = currentAnchor.value;
if (activeHref !== href) {
currentAnchor.value = href;
emit(event.CHANGE_EVENT, href);
}
};
let clearAnimate = null;
const scrollToAnchor = (href) => {
if (!containerEl.value)
return;
const target = element.getElement(href);
if (!target)
return;
if (clearAnimate)
clearAnimate();
isScrolling = true;
const scrollEle = scroll.getScrollElement(target, containerEl.value);
const distance = position.getOffsetTopDistance(target, scrollEle);
const max = scrollEle.scrollHeight - scrollEle.clientHeight;
const to = Math.min(distance - props.offset, max);
clearAnimate = scroll.animateScrollTo(containerEl.value, currentScrollTop, to, props.duration, () => {
setTimeout(() => {
isScrolling = false;
}, 20);
});
};
const scrollTo = (href) => {
if (href) {
setCurrentAnchor(href);
scrollToAnchor(href);
}
};
const handleClick = (e, href) => {
emit("click", e, href);
scrollTo(href);
};
const handleScroll = throttleByRaf.throttleByRaf(() => {
if (containerEl.value) {
currentScrollTop = scroll.getScrollTop(containerEl.value);
}
const currentHref = getCurrentHref();
if (isScrolling || types.isUndefined(currentHref))
return;
setCurrentAnchor(currentHref);
});
const getCurrentHref = () => {
if (!containerEl.value)
return;
const scrollTop = scroll.getScrollTop(containerEl.value);
const anchorTopList = [];
for (const href of Object.keys(links)) {
const target = element.getElement(href);
if (!target)
continue;
const scrollEle = scroll.getScrollElement(target, containerEl.value);
const distance = position.getOffsetTopDistance(target, scrollEle);
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 = element.getElement(props.container);
if (!el || types.isWindow(el)) {
containerEl.value = window;
} else {
containerEl.value = el;
}
};
core.useEventListener(containerEl, "scroll", handleScroll);
const updateMarkerStyle = () => {
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") {
const left = linkRect.left - anchorRect.left;
markerStyle.value = {
left: `${left}px`,
width: `${linkRect.width}px`,
opacity: 1
};
} else {
const top = linkRect.top - anchorRect.top + (linkRect.height - markerRect.height) / 2;
markerStyle.value = {
top: `${top}px`,
opacity: 1
};
}
});
};
vue.watch(currentAnchor, updateMarkerStyle);
vue.watch(() => {
var _a;
return (_a = slots.default) == null ? void 0 : _a.call(slots);
}, updateMarkerStyle);
vue.onMounted(() => {
getContainer();
const hash = decodeURIComponent(window.location.hash);
const target = element.getElement(hash);
if (target) {
scrollTo(hash);
} else {
handleScroll();
}
});
vue.watch(() => props.container, () => {
getContainer();
});
vue.provide(constants.anchorKey, {
ns,
direction: props.direction,
currentAnchor,
addLink,
removeLink,
handleClick
});
expose({
scrollTo
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
ref_key: "anchorRef",
ref: anchorRef,
class: vue.normalizeClass(vue.unref(cls))
}, [
_ctx.marker ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
ref_key: "markerRef",
ref: markerRef,
class: vue.normalizeClass(vue.unref(ns).e("marker")),
style: vue.normalizeStyle(markerStyle.value)
}, null, 6)) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("div", {
class: vue.normalizeClass(vue.unref(ns).e("list"))
}, [
vue.renderSlot(_ctx.$slots, "default")
], 2)
], 2);
};
}
});
var Anchor = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "anchor.vue"]]);
exports["default"] = Anchor;
//# sourceMappingURL=anchor2.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
import type { InjectionKey, Ref } from 'vue';
import type { UseNamespaceReturn } from 'element-plus/es/hooks';
export interface AnchorLinkState {
el: HTMLElement;
href: string;
}
export interface AnchorContext {
ns: UseNamespaceReturn;
direction: string;
currentAnchor: Ref<string>;
addLink(state: AnchorLinkState): void;
removeLink(href: string): void;
handleClick(e: MouseEvent, href?: string): void;
}
export declare const anchorKey: InjectionKey<AnchorContext>;

View File

@@ -0,0 +1,8 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const anchorKey = Symbol("anchor");
exports.anchorKey = anchorKey;
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","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"],"names":[],"mappings":";;;;AAAY,MAAC,SAAS,GAAG,MAAM,CAAC,QAAQ;;;;"}

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style/css';
import 'element-plus/theme-chalk/el-anchor.css';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/css.js');
require('element-plus/theme-chalk/el-anchor.css');
//# sourceMappingURL=css.js.map

View File

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

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style';
import 'element-plus/theme-chalk/src/anchor.scss';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/index.js');
require('element-plus/theme-chalk/src/anchor.scss');
//# sourceMappingURL=index.js.map

View File

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

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style/css';
import 'element-plus/theme-chalk/el-aside.css';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/css.js');
require('element-plus/theme-chalk/el-aside.css');
//# sourceMappingURL=css.js.map

View File

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

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style';
import 'element-plus/theme-chalk/src/aside.scss';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/index.js');
require('element-plus/theme-chalk/src/aside.scss');
//# sourceMappingURL=index.js.map

View File

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

View File

@@ -0,0 +1,5 @@
import Autocomplete from './src/autocomplete.vue';
import type { SFCWithInstall } from 'element-plus/es/utils';
export declare const ElAutocomplete: SFCWithInstall<typeof Autocomplete>;
export default ElAutocomplete;
export * from './src/autocomplete';

View File

@@ -0,0 +1,15 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var autocomplete$1 = require('./src/autocomplete2.js');
var autocomplete = require('./src/autocomplete.js');
var install = require('../../utils/vue/install.js');
const ElAutocomplete = install.withInstall(autocomplete$1["default"]);
exports.autocompleteEmits = autocomplete.autocompleteEmits;
exports.autocompleteProps = autocomplete.autocompleteProps;
exports.ElAutocomplete = ElAutocomplete;
exports["default"] = ElAutocomplete;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../../packages/components/autocomplete/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport Autocomplete from './src/autocomplete.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElAutocomplete: SFCWithInstall<typeof Autocomplete> =\n withInstall(Autocomplete)\n\nexport default ElAutocomplete\n\nexport * from './src/autocomplete'\n"],"names":["withInstall","Autocomplete"],"mappings":";;;;;;;;AAEY,MAAC,cAAc,GAAGA,mBAAW,CAACC,yBAAY;;;;;;;"}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,69 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var input = require('../../input/src/input.js');
var content = require('../../tooltip/src/content.js');
var runtime = require('../../../utils/vue/props/runtime.js');
var shared = require('@vue/shared');
var event = require('../../../constants/event.js');
var types = require('../../../utils/types.js');
const autocompleteProps = runtime.buildProps({
...input.inputProps,
valueKey: {
type: String,
default: "value"
},
modelValue: {
type: [String, Number],
default: ""
},
debounce: {
type: Number,
default: 300
},
placement: {
type: runtime.definePropType(String),
values: [
"top",
"top-start",
"top-end",
"bottom",
"bottom-start",
"bottom-end"
],
default: "bottom-start"
},
fetchSuggestions: {
type: runtime.definePropType([Function, Array]),
default: shared.NOOP
},
popperClass: {
type: String,
default: ""
},
triggerOnFocus: {
type: Boolean,
default: true
},
selectWhenUnmatched: Boolean,
hideLoading: Boolean,
teleported: content.useTooltipContentProps.teleported,
appendTo: content.useTooltipContentProps.appendTo,
highlightFirstItem: Boolean,
fitInputWidth: Boolean
});
const autocompleteEmits = {
[event.UPDATE_MODEL_EVENT]: (value) => shared.isString(value) || types.isNumber(value),
[event.INPUT_EVENT]: (value) => shared.isString(value) || types.isNumber(value),
[event.CHANGE_EVENT]: (value) => shared.isString(value) || types.isNumber(value),
focus: (evt) => evt instanceof FocusEvent,
blur: (evt) => evt instanceof FocusEvent,
clear: () => true,
select: (item) => shared.isObject(item)
};
exports.autocompleteEmits = autocompleteEmits;
exports.autocompleteProps = autocompleteProps;
//# sourceMappingURL=autocomplete.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,405 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var lodashUnified = require('lodash-unified');
var core = require('@vueuse/core');
var iconsVue = require('@element-plus/icons-vue');
var index$5 = require('../../input/index.js');
var index$3 = require('../../scrollbar/index.js');
var index$2 = require('../../tooltip/index.js');
var index$4 = require('../../icon/index.js');
var autocomplete = require('./autocomplete.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var input = require('../../input/src/input.js');
var useFormCommonProps = require('../../form/src/hooks/use-form-common-props.js');
var index = require('../../../hooks/use-namespace/index.js');
var index$1 = require('../../../hooks/use-id/index.js');
var shared = require('@vue/shared');
var event = require('../../../constants/event.js');
var error = require('../../../utils/error.js');
const COMPONENT_NAME = "ElAutocomplete";
const __default__ = vue.defineComponent({
name: COMPONENT_NAME,
inheritAttrs: false
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: autocomplete.autocompleteProps,
emits: autocomplete.autocompleteEmits,
setup(__props, { expose, emit }) {
const props = __props;
const passInputProps = vue.computed(() => lodashUnified.pick(props, Object.keys(input.inputProps)));
const rawAttrs = vue.useAttrs();
const disabled = useFormCommonProps.useFormDisabled();
const ns = index.useNamespace("autocomplete");
const inputRef = vue.ref();
const regionRef = vue.ref();
const popperRef = vue.ref();
const listboxRef = vue.ref();
let readonly = false;
let ignoreFocusEvent = false;
const suggestions = vue.ref([]);
const highlightedIndex = vue.ref(-1);
const dropdownWidth = vue.ref("");
const activated = vue.ref(false);
const suggestionDisabled = vue.ref(false);
const loading = vue.ref(false);
const listboxId = index$1.useId();
const styles = vue.computed(() => rawAttrs.style);
const suggestionVisible = vue.computed(() => {
const isValidData = suggestions.value.length > 0;
return (isValidData || loading.value) && activated.value;
});
const suggestionLoading = vue.computed(() => !props.hideLoading && loading.value);
const refInput = vue.computed(() => {
if (inputRef.value) {
return Array.from(inputRef.value.$el.querySelectorAll("input"));
}
return [];
});
const onSuggestionShow = () => {
if (suggestionVisible.value) {
dropdownWidth.value = `${inputRef.value.$el.offsetWidth}px`;
}
};
const onHide = () => {
highlightedIndex.value = -1;
};
const getData = async (queryString) => {
if (suggestionDisabled.value)
return;
const cb = (suggestionList) => {
loading.value = false;
if (suggestionDisabled.value)
return;
if (shared.isArray(suggestionList)) {
suggestions.value = suggestionList;
highlightedIndex.value = props.highlightFirstItem ? 0 : -1;
} else {
error.throwError(COMPONENT_NAME, "autocomplete suggestions must be an array");
}
};
loading.value = true;
if (shared.isArray(props.fetchSuggestions)) {
cb(props.fetchSuggestions);
} else {
const result = await props.fetchSuggestions(queryString, cb);
if (shared.isArray(result))
cb(result);
}
};
const debouncedGetData = lodashUnified.debounce(getData, props.debounce);
const handleInput = (value) => {
const valuePresented = !!value;
emit(event.INPUT_EVENT, value);
emit(event.UPDATE_MODEL_EVENT, value);
suggestionDisabled.value = false;
activated.value || (activated.value = valuePresented);
if (!props.triggerOnFocus && !value) {
suggestionDisabled.value = true;
suggestions.value = [];
return;
}
debouncedGetData(value);
};
const handleMouseDown = (event) => {
var _a;
if (disabled.value)
return;
if (((_a = event.target) == null ? void 0 : _a.tagName) !== "INPUT" || refInput.value.includes(document.activeElement)) {
activated.value = true;
}
};
const handleChange = (value) => {
emit(event.CHANGE_EVENT, value);
};
const handleFocus = (evt) => {
var _a;
if (!ignoreFocusEvent) {
activated.value = true;
emit("focus", evt);
const queryString = (_a = props.modelValue) != null ? _a : "";
if (props.triggerOnFocus && !readonly) {
debouncedGetData(String(queryString));
}
} else {
ignoreFocusEvent = false;
}
};
const handleBlur = (evt) => {
setTimeout(() => {
var _a;
if ((_a = popperRef.value) == null ? void 0 : _a.isFocusInsideContent()) {
ignoreFocusEvent = true;
return;
}
activated.value && close();
emit("blur", evt);
});
};
const handleClear = () => {
activated.value = false;
emit(event.UPDATE_MODEL_EVENT, "");
emit("clear");
};
const handleKeyEnter = async () => {
var _a;
if ((_a = inputRef.value) == null ? void 0 : _a.isComposing) {
return;
}
if (suggestionVisible.value && highlightedIndex.value >= 0 && highlightedIndex.value < suggestions.value.length) {
handleSelect(suggestions.value[highlightedIndex.value]);
} else if (props.selectWhenUnmatched) {
emit("select", { value: props.modelValue });
suggestions.value = [];
highlightedIndex.value = -1;
}
};
const handleKeyEscape = (evt) => {
if (suggestionVisible.value) {
evt.preventDefault();
evt.stopPropagation();
close();
}
};
const close = () => {
activated.value = false;
};
const focus = () => {
var _a;
(_a = inputRef.value) == null ? void 0 : _a.focus();
};
const blur = () => {
var _a;
(_a = inputRef.value) == null ? void 0 : _a.blur();
};
const handleSelect = async (item) => {
emit(event.INPUT_EVENT, item[props.valueKey]);
emit(event.UPDATE_MODEL_EVENT, item[props.valueKey]);
emit("select", item);
suggestions.value = [];
highlightedIndex.value = -1;
};
const highlight = (index) => {
var _a, _b;
if (!suggestionVisible.value || loading.value)
return;
if (index < 0) {
highlightedIndex.value = -1;
return;
}
if (index >= suggestions.value.length) {
index = suggestions.value.length - 1;
}
const suggestion = regionRef.value.querySelector(`.${ns.be("suggestion", "wrap")}`);
const suggestionList = suggestion.querySelectorAll(`.${ns.be("suggestion", "list")} li`);
const highlightItem = suggestionList[index];
const scrollTop = suggestion.scrollTop;
const { offsetTop, scrollHeight } = highlightItem;
if (offsetTop + scrollHeight > scrollTop + suggestion.clientHeight) {
suggestion.scrollTop += scrollHeight;
}
if (offsetTop < scrollTop) {
suggestion.scrollTop -= scrollHeight;
}
highlightedIndex.value = index;
(_b = (_a = inputRef.value) == null ? void 0 : _a.ref) == null ? void 0 : _b.setAttribute("aria-activedescendant", `${listboxId.value}-item-${highlightedIndex.value}`);
};
const stopHandle = core.onClickOutside(listboxRef, () => {
var _a;
if ((_a = popperRef.value) == null ? void 0 : _a.isFocusInsideContent())
return;
suggestionVisible.value && close();
});
vue.onBeforeUnmount(() => {
stopHandle == null ? void 0 : stopHandle();
});
vue.onMounted(() => {
var _a;
const inputElement = (_a = inputRef.value) == null ? void 0 : _a.ref;
if (!inputElement)
return;
[
{ key: "role", value: "textbox" },
{ key: "aria-autocomplete", value: "list" },
{ key: "aria-controls", value: "id" },
{
key: "aria-activedescendant",
value: `${listboxId.value}-item-${highlightedIndex.value}`
}
].forEach(({ key, value }) => inputElement.setAttribute(key, value));
readonly = inputElement.hasAttribute("readonly");
});
expose({
highlightedIndex,
activated,
loading,
inputRef,
popperRef,
suggestions,
handleSelect,
handleKeyEnter,
focus,
blur,
close,
highlight,
getData
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.unref(index$2.ElTooltip), {
ref_key: "popperRef",
ref: popperRef,
visible: vue.unref(suggestionVisible),
placement: _ctx.placement,
"fallback-placements": ["bottom-start", "top-start"],
"popper-class": [vue.unref(ns).e("popper"), _ctx.popperClass],
teleported: _ctx.teleported,
"append-to": _ctx.appendTo,
"gpu-acceleration": false,
pure: "",
"manual-mode": "",
effect: "light",
trigger: "click",
transition: `${vue.unref(ns).namespace.value}-zoom-in-top`,
persistent: "",
role: "listbox",
onBeforeShow: onSuggestionShow,
onHide
}, {
content: vue.withCtx(() => [
vue.createElementVNode("div", {
ref_key: "regionRef",
ref: regionRef,
class: vue.normalizeClass([vue.unref(ns).b("suggestion"), vue.unref(ns).is("loading", vue.unref(suggestionLoading))]),
style: vue.normalizeStyle({
[_ctx.fitInputWidth ? "width" : "minWidth"]: dropdownWidth.value,
outline: "none"
}),
role: "region"
}, [
_ctx.$slots.header ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: vue.normalizeClass(vue.unref(ns).be("suggestion", "header")),
onClick: vue.withModifiers(() => {
}, ["stop"])
}, [
vue.renderSlot(_ctx.$slots, "header")
], 10, ["onClick"])) : vue.createCommentVNode("v-if", true),
vue.createVNode(vue.unref(index$3.ElScrollbar), {
id: vue.unref(listboxId),
tag: "ul",
"wrap-class": vue.unref(ns).be("suggestion", "wrap"),
"view-class": vue.unref(ns).be("suggestion", "list"),
role: "listbox"
}, {
default: vue.withCtx(() => [
vue.unref(suggestionLoading) ? (vue.openBlock(), vue.createElementBlock("li", { key: 0 }, [
vue.renderSlot(_ctx.$slots, "loading", {}, () => [
vue.createVNode(vue.unref(index$4.ElIcon), {
class: vue.normalizeClass(vue.unref(ns).is("loading"))
}, {
default: vue.withCtx(() => [
vue.createVNode(vue.unref(iconsVue.Loading))
]),
_: 1
}, 8, ["class"])
])
])) : (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(suggestions.value, (item, index) => {
return vue.openBlock(), vue.createElementBlock("li", {
id: `${vue.unref(listboxId)}-item-${index}`,
key: index,
class: vue.normalizeClass({ highlighted: highlightedIndex.value === index }),
role: "option",
"aria-selected": highlightedIndex.value === index,
onClick: ($event) => handleSelect(item)
}, [
vue.renderSlot(_ctx.$slots, "default", { item }, () => [
vue.createTextVNode(vue.toDisplayString(item[_ctx.valueKey]), 1)
])
], 10, ["id", "aria-selected", "onClick"]);
}), 128))
]),
_: 3
}, 8, ["id", "wrap-class", "view-class"]),
_ctx.$slots.footer ? (vue.openBlock(), vue.createElementBlock("div", {
key: 1,
class: vue.normalizeClass(vue.unref(ns).be("suggestion", "footer")),
onClick: vue.withModifiers(() => {
}, ["stop"])
}, [
vue.renderSlot(_ctx.$slots, "footer")
], 10, ["onClick"])) : vue.createCommentVNode("v-if", true)
], 6)
]),
default: vue.withCtx(() => [
vue.createElementVNode("div", {
ref_key: "listboxRef",
ref: listboxRef,
class: vue.normalizeClass([vue.unref(ns).b(), _ctx.$attrs.class]),
style: vue.normalizeStyle(vue.unref(styles)),
role: "combobox",
"aria-haspopup": "listbox",
"aria-expanded": vue.unref(suggestionVisible),
"aria-owns": vue.unref(listboxId)
}, [
vue.createVNode(vue.unref(index$5.ElInput), vue.mergeProps({
ref_key: "inputRef",
ref: inputRef
}, vue.mergeProps(vue.unref(passInputProps), _ctx.$attrs), {
"model-value": _ctx.modelValue,
disabled: vue.unref(disabled),
onInput: handleInput,
onChange: handleChange,
onFocus: handleFocus,
onBlur: handleBlur,
onClear: handleClear,
onKeydown: [
vue.withKeys(vue.withModifiers(($event) => highlight(highlightedIndex.value - 1), ["prevent"]), ["up"]),
vue.withKeys(vue.withModifiers(($event) => highlight(highlightedIndex.value + 1), ["prevent"]), ["down"]),
vue.withKeys(handleKeyEnter, ["enter"]),
vue.withKeys(close, ["tab"]),
vue.withKeys(handleKeyEscape, ["esc"])
],
onMousedown: handleMouseDown
}), vue.createSlots({
_: 2
}, [
_ctx.$slots.prepend ? {
name: "prepend",
fn: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "prepend")
])
} : void 0,
_ctx.$slots.append ? {
name: "append",
fn: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "append")
])
} : void 0,
_ctx.$slots.prefix ? {
name: "prefix",
fn: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "prefix")
])
} : void 0,
_ctx.$slots.suffix ? {
name: "suffix",
fn: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "suffix")
])
} : void 0
]), 1040, ["model-value", "disabled", "onKeydown"])
], 14, ["aria-expanded", "aria-owns"])
]),
_: 3
}, 8, ["visible", "placement", "popper-class", "teleported", "append-to", "transition"]);
};
}
});
var Autocomplete = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "autocomplete.vue"]]);
exports["default"] = Autocomplete;
//# sourceMappingURL=autocomplete2.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
import 'element-plus/es/components/base/style/css';
import 'element-plus/theme-chalk/el-autocomplete.css';
import 'element-plus/es/components/input/style/css';
import 'element-plus/es/components/scrollbar/style/css';
import 'element-plus/es/components/popper/style/css';

View File

@@ -0,0 +1,9 @@
'use strict';
require('../../base/style/css.js');
require('element-plus/theme-chalk/el-autocomplete.css');
require('../../input/style/css.js');
require('../../scrollbar/style/css.js');
require('../../popper/style/css.js');
//# sourceMappingURL=css.js.map

View File

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

View File

@@ -0,0 +1,5 @@
import 'element-plus/es/components/base/style';
import 'element-plus/theme-chalk/src/autocomplete.scss';
import 'element-plus/es/components/input/style';
import 'element-plus/es/components/scrollbar/style';
import 'element-plus/es/components/popper/style';

View File

@@ -0,0 +1,9 @@
'use strict';
require('../../base/style/index.js');
require('element-plus/theme-chalk/src/autocomplete.scss');
require('../../input/style/index.js');
require('../../scrollbar/style/index.js');
require('../../popper/style/index.js');
//# sourceMappingURL=index.js.map

View File

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

View File

@@ -0,0 +1,6 @@
import Avatar from './src/avatar.vue';
import type { SFCWithInstall } from 'element-plus/es/utils';
export declare const ElAvatar: SFCWithInstall<typeof Avatar>;
export default ElAvatar;
export * from './src/avatar';
export type { AvatarInstance } from './src/instance';

View File

@@ -0,0 +1,15 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var avatar$1 = require('./src/avatar2.js');
var avatar = require('./src/avatar.js');
var install = require('../../utils/vue/install.js');
const ElAvatar = install.withInstall(avatar$1["default"]);
exports.avatarEmits = avatar.avatarEmits;
exports.avatarProps = avatar.avatarProps;
exports.ElAvatar = ElAvatar;
exports["default"] = ElAvatar;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../../packages/components/avatar/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport Avatar from './src/avatar.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElAvatar: SFCWithInstall<typeof Avatar> = withInstall(Avatar)\nexport default ElAvatar\n\nexport * from './src/avatar'\nexport type { AvatarInstance } from './src/instance'\n"],"names":["withInstall","Avatar"],"mappings":";;;;;;;;AAEY,MAAC,QAAQ,GAAGA,mBAAW,CAACC,mBAAM;;;;;;;"}

View File

@@ -0,0 +1,22 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
import type { ObjectFitProperty } from 'csstype';
export declare const avatarProps: {
readonly size: import("element-plus/es/utils").EpPropFinalized<readonly [NumberConstructor, StringConstructor], "" | "small" | "default" | "large", number, "", boolean>;
readonly shape: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "circle" | "square", unknown, "circle", boolean>;
readonly icon: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | ((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly src: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly alt: StringConstructor;
readonly srcSet: StringConstructor;
readonly fit: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => "fill" | "contain" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "none" | "cover" | "scale-down") | (() => ObjectFitProperty) | ((new (...args: any[]) => "fill" | "contain" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "none" | "cover" | "scale-down") | (() => ObjectFitProperty))[], unknown, unknown, "cover", boolean>;
};
export type AvatarProps = ExtractPropTypes<typeof avatarProps>;
export type AvatarPropsPublic = __ExtractPublicPropTypes<typeof avatarProps>;
export declare const avatarEmits: {
error: (evt: Event) => boolean;
};
export type AvatarEmits = typeof avatarEmits;

View File

@@ -0,0 +1,42 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var runtime = require('../../../utils/vue/props/runtime.js');
var size = require('../../../constants/size.js');
var types = require('../../../utils/types.js');
var icon = require('../../../utils/vue/icon.js');
const avatarProps = runtime.buildProps({
size: {
type: [Number, String],
values: size.componentSizes,
default: "",
validator: (val) => types.isNumber(val)
},
shape: {
type: String,
values: ["circle", "square"],
default: "circle"
},
icon: {
type: icon.iconPropType
},
src: {
type: String,
default: ""
},
alt: String,
srcSet: String,
fit: {
type: runtime.definePropType(String),
default: "cover"
}
});
const avatarEmits = {
error: (evt) => evt instanceof Event
};
exports.avatarEmits = avatarEmits;
exports.avatarProps = avatarProps;
//# sourceMappingURL=avatar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"avatar.js","sources":["../../../../../../packages/components/avatar/src/avatar.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n iconPropType,\n isNumber,\n} from '@element-plus/utils'\nimport { componentSizes } from '@element-plus/constants'\n\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\nimport type { ObjectFitProperty } from 'csstype'\n\nexport const avatarProps = buildProps({\n /**\n * @description avatar size.\n */\n size: {\n type: [Number, String],\n values: componentSizes,\n default: '',\n validator: (val: unknown): val is number => isNumber(val),\n },\n /**\n * @description avatar shape.\n */\n shape: {\n type: String,\n values: ['circle', 'square'],\n default: 'circle',\n },\n /**\n * @description representation type to icon, more info on icon component.\n */\n icon: {\n type: iconPropType,\n },\n /**\n * @description the source of the image for an image avatar.\n */\n src: {\n type: String,\n default: '',\n },\n /**\n * @description native attribute `alt` of image avatar.\n */\n alt: String,\n /**\n * @description native attribute srcset of image avatar.\n */\n srcSet: String,\n /**\n * @description set how the image fit its container for an image avatar.\n */\n fit: {\n type: definePropType<ObjectFitProperty>(String),\n default: 'cover',\n },\n} as const)\nexport type AvatarProps = ExtractPropTypes<typeof avatarProps>\nexport type AvatarPropsPublic = __ExtractPublicPropTypes<typeof avatarProps>\n\nexport const avatarEmits = {\n error: (evt: Event) => evt instanceof Event,\n}\nexport type AvatarEmits = typeof avatarEmits\n"],"names":["buildProps","componentSizes","isNumber","iconPropType","definePropType"],"mappings":";;;;;;;;;AAOY,MAAC,WAAW,GAAGA,kBAAU,CAAC;AACtC,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,IAAI,MAAM,EAAEC,mBAAc;AAC1B,IAAI,OAAO,EAAE,EAAE;AACf,IAAI,SAAS,EAAE,CAAC,GAAG,KAAKC,cAAQ,CAAC,GAAG,CAAC;AACrC,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;AAChC,IAAI,OAAO,EAAE,QAAQ;AACrB,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAEC,iBAAY;AACtB,GAAG;AACH,EAAE,GAAG,EAAE;AACP,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,GAAG,EAAE,MAAM;AACb,EAAE,MAAM,EAAE,MAAM;AAChB,EAAE,GAAG,EAAE;AACP,IAAI,IAAI,EAAEC,sBAAc,CAAC,MAAM,CAAC;AAChC,IAAI,OAAO,EAAE,OAAO;AACpB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,WAAW,GAAG;AAC3B,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,GAAG,YAAY,KAAK;AACtC;;;;;"}

View File

@@ -0,0 +1,46 @@
declare function __VLS_template(): {
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly size: import("element-plus/es/utils").EpPropFinalized<readonly [NumberConstructor, StringConstructor], "" | "small" | "default" | "large", number, "", boolean>;
readonly shape: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "circle" | "square", unknown, "circle", boolean>;
readonly icon: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | ((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly src: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly alt: StringConstructor;
readonly srcSet: StringConstructor;
readonly fit: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => "fill" | "contain" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "none" | "cover" | "scale-down") | (() => import("csstype").ObjectFitProperty) | ((new (...args: any[]) => "fill" | "contain" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "none" | "cover" | "scale-down") | (() => import("csstype").ObjectFitProperty))[], unknown, unknown, "cover", boolean>;
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
error: (evt: Event) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly size: import("element-plus/es/utils").EpPropFinalized<readonly [NumberConstructor, StringConstructor], "" | "small" | "default" | "large", number, "", boolean>;
readonly shape: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "circle" | "square", unknown, "circle", boolean>;
readonly icon: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | ((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly src: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
readonly alt: StringConstructor;
readonly srcSet: StringConstructor;
readonly fit: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => "fill" | "contain" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "none" | "cover" | "scale-down") | (() => import("csstype").ObjectFitProperty) | ((new (...args: any[]) => "fill" | "contain" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "none" | "cover" | "scale-down") | (() => import("csstype").ObjectFitProperty))[], unknown, unknown, "cover", boolean>;
}>> & {
onError?: ((evt: Event) => any) | undefined;
}, {
readonly size: import("element-plus/es/utils").EpPropMergeType<readonly [NumberConstructor, StringConstructor], "" | "small" | "default" | "large", number>;
readonly shape: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "circle" | "square", unknown>;
readonly src: string;
readonly fit: import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => "fill" | "contain" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "none" | "cover" | "scale-down") | (() => import("csstype").ObjectFitProperty) | ((new (...args: any[]) => "fill" | "contain" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "none" | "cover" | "scale-down") | (() => import("csstype").ObjectFitProperty))[], unknown, unknown>;
}>;
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,75 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var index$1 = require('../../icon/index.js');
var avatar = require('./avatar.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
var shared = require('@vue/shared');
var types = require('../../../utils/types.js');
var style = require('../../../utils/dom/style.js');
const __default__ = vue.defineComponent({
name: "ElAvatar"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: avatar.avatarProps,
emits: avatar.avatarEmits,
setup(__props, { emit }) {
const props = __props;
const ns = index.useNamespace("avatar");
const hasLoadError = vue.ref(false);
const avatarClass = vue.computed(() => {
const { size, icon, shape } = props;
const classList = [ns.b()];
if (shared.isString(size))
classList.push(ns.m(size));
if (icon)
classList.push(ns.m("icon"));
if (shape)
classList.push(ns.m(shape));
return classList;
});
const sizeStyle = vue.computed(() => {
const { size } = props;
return types.isNumber(size) ? ns.cssVarBlock({
size: style.addUnit(size) || ""
}) : void 0;
});
const fitStyle = vue.computed(() => ({
objectFit: props.fit
}));
vue.watch(() => props.src, () => hasLoadError.value = false);
function handleError(e) {
hasLoadError.value = true;
emit("error", e);
}
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("span", {
class: vue.normalizeClass(vue.unref(avatarClass)),
style: vue.normalizeStyle(vue.unref(sizeStyle))
}, [
(_ctx.src || _ctx.srcSet) && !hasLoadError.value ? (vue.openBlock(), vue.createElementBlock("img", {
key: 0,
src: _ctx.src,
alt: _ctx.alt,
srcset: _ctx.srcSet,
style: vue.normalizeStyle(vue.unref(fitStyle)),
onError: handleError
}, null, 44, ["src", "alt", "srcset"])) : _ctx.icon ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.ElIcon), { key: 1 }, {
default: vue.withCtx(() => [
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.icon)))
]),
_: 1
})) : vue.renderSlot(_ctx.$slots, "default", { key: 2 })
], 6);
};
}
});
var Avatar = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "avatar.vue"]]);
exports["default"] = Avatar;
//# sourceMappingURL=avatar2.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"avatar2.js","sources":["../../../../../../packages/components/avatar/src/avatar.vue"],"sourcesContent":["<template>\n <span :class=\"avatarClass\" :style=\"sizeStyle\">\n <img\n v-if=\"(src || srcSet) && !hasLoadError\"\n :src=\"src\"\n :alt=\"alt\"\n :srcset=\"srcSet\"\n :style=\"fitStyle\"\n @error=\"handleError\"\n />\n <el-icon v-else-if=\"icon\">\n <component :is=\"icon\" />\n </el-icon>\n <slot v-else />\n </span>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, ref, watch } from 'vue'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { useNamespace } from '@element-plus/hooks'\nimport { addUnit, isNumber, isString } from '@element-plus/utils'\nimport { avatarEmits, avatarProps } from './avatar'\n\nimport type { CSSProperties } from 'vue'\n\ndefineOptions({\n name: 'ElAvatar',\n})\n\nconst props = defineProps(avatarProps)\nconst emit = defineEmits(avatarEmits)\n\nconst ns = useNamespace('avatar')\n\nconst hasLoadError = ref(false)\n\nconst avatarClass = computed(() => {\n const { size, icon, shape } = props\n const classList = [ns.b()]\n if (isString(size)) classList.push(ns.m(size))\n if (icon) classList.push(ns.m('icon'))\n if (shape) classList.push(ns.m(shape))\n return classList\n})\n\nconst sizeStyle = computed(() => {\n const { size } = props\n return isNumber(size)\n ? (ns.cssVarBlock({\n size: addUnit(size) || '',\n }) as CSSProperties)\n : undefined\n})\n\nconst fitStyle = computed<CSSProperties>(() => ({\n objectFit: props.fit,\n}))\n\n// need reset hasLoadError to false if src changed\nwatch(\n () => props.src,\n () => (hasLoadError.value = false)\n)\n\nfunction handleError(e: Event) {\n hasLoadError.value = true\n emit('error', e)\n}\n</script>\n"],"names":["useNamespace","ref","computed","isString","isNumber","addUnit","watch"],"mappings":";;;;;;;;;;;;;uCA0Bc,CAAA;AAAA,EACZ,IAAM,EAAA,UAAA;AACR,CAAA,CAAA,CAAA;;;;;;;AAKA,IAAM,MAAA,EAAA,GAAKA,mBAAa,QAAQ,CAAA,CAAA;AAEhC,IAAM,MAAA,YAAA,GAAeC,QAAI,KAAK,CAAA,CAAA;AAE9B,IAAM,MAAA,WAAA,GAAcC,aAAS,MAAM;AACjC,MAAA,MAAM,EAAE,IAAA,EAAM,IAAM,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AAC9B,MAAA,MAAM,SAAY,GAAA,CAAC,EAAG,CAAA,CAAA,EAAG,CAAA,CAAA;AACzB,MAAI,IAAAC,eAAA,CAAS,IAAI,CAAG;AACpB,QAAA,SAAoB,CAAA,IAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAQ,CAAA,CAAA,CAAA;AAC5B,MAAA,IAAI;AACJ,QAAO,SAAA,CAAA,IAAA,CAAA,EAAA,CAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CAAA;AAAA,MACR,IAAA,KAAA;AAED,QAAM,SAAA,CAAA,IAAY,WAAe,CAAA,CAAA,CAAA;AAC/B,MAAM,OAAA,SAAW,CAAA;AACjB,KAAA,CAAA,CAAA;AACoB,IACd,MAAA,SAAc,GAAAD,YAAS,CAAA,MAAA;AAAA,MACzB,MACA,EAAA,IAAA,EAAA,GAAA,KAAA,CAAA;AAAA,MACL,OAAAE,cAAA,CAAA,IAAA,CAAA,GAAA,EAAA,CAAA,WAAA,CAAA;AAED,QAAM,IAAA,EAAAC,aAAW,UAA+B,EAAA;AAAA,iBACnC,CAAM;AAAA,KACjB,CAAA,CAAA;AAGF,IAAA,MAAA,QAAA,GAAAH,YAAA,CAAA,OAAA;AAAA,MACE,SAAY,EAAA,KAAA,CAAA,GAAA;AAAA,KACZ,CAAA,CAAA,CAAA;AAA4B,IAC9BI,SAAA,CAAA,MAAA,KAAA,CAAA,GAAA,EAAA,MAAA,YAAA,CAAA,KAAA,GAAA,KAAA,CAAA,CAAA;AAEA,IAAA,SAAS,YAAY,CAAU,EAAA;AAC7B,MAAA,YAAA,CAAa,KAAQ,GAAA,IAAA,CAAA;AACrB,MAAA,IAAA,CAAK,SAAS,CAAC,CAAA,CAAA;AAAA,KACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,2 @@
import type Avatar from './avatar.vue';
export type AvatarInstance = InstanceType<typeof Avatar> & 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,2 @@
import 'element-plus/es/components/base/style/css';
import 'element-plus/theme-chalk/el-avatar.css';

View File

@@ -0,0 +1,6 @@
'use strict';
require('../../base/style/css.js');
require('element-plus/theme-chalk/el-avatar.css');
//# sourceMappingURL=css.js.map

View File

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

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style';
import 'element-plus/theme-chalk/src/avatar.scss';

Some files were not shown because too many files have changed in this diff Show More