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,6 @@
import Badge from './src/badge.vue';
import type { SFCWithInstall } from 'element-plus/es/utils';
export declare const ElBadge: SFCWithInstall<typeof Badge>;
export default ElBadge;
export * from './src/badge';
export type { BadgeInstance } from './src/instance';

View File

@@ -0,0 +1,8 @@
import Badge from './src/badge2.mjs';
export { badgeProps } from './src/badge.mjs';
import { withInstall } from '../../utils/vue/install.mjs';
const ElBadge = withInstall(Badge);
export { ElBadge, ElBadge as default };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/badge/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport Badge from './src/badge.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElBadge: SFCWithInstall<typeof Badge> = withInstall(Badge)\nexport default ElBadge\n\nexport * from './src/badge'\nexport type { BadgeInstance } from './src/instance'\n"],"names":[],"mappings":";;;;AAEY,MAAC,OAAO,GAAG,WAAW,CAAC,KAAK;;;;"}

View File

@@ -0,0 +1,25 @@
import type { ExtractPropTypes, StyleValue, __ExtractPublicPropTypes } from 'vue';
export declare const badgeProps: {
readonly value: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
readonly max: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 99, boolean>;
readonly isDot: BooleanConstructor;
readonly hidden: BooleanConstructor;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "primary" | "success" | "warning" | "info" | "danger", unknown, "danger", boolean>;
readonly showZero: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly color: StringConstructor;
readonly badgeStyle: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => string | import("vue").CSSProperties | StyleValue[]) | (() => StyleValue) | ((new (...args: any[]) => string | import("vue").CSSProperties | StyleValue[]) | (() => StyleValue))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly offset: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => [number, number]) | (() => [number, number]) | ((new (...args: any[]) => [number, number]) | (() => [number, number]))[], unknown, unknown, readonly [0, 0], boolean>;
readonly badgeClass: {
readonly type: import("vue").PropType<string>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
};
export type BadgeProps = ExtractPropTypes<typeof badgeProps>;
export type BadgePropsPublic = __ExtractPublicPropTypes<typeof badgeProps>;

View File

@@ -0,0 +1,37 @@
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
const badgeProps = buildProps({
value: {
type: [String, Number],
default: ""
},
max: {
type: Number,
default: 99
},
isDot: Boolean,
hidden: Boolean,
type: {
type: String,
values: ["primary", "success", "warning", "info", "danger"],
default: "danger"
},
showZero: {
type: Boolean,
default: true
},
color: String,
badgeStyle: {
type: definePropType([String, Object, Array])
},
offset: {
type: definePropType(Array),
default: [0, 0]
},
badgeClass: {
type: String
}
});
export { badgeProps };
//# sourceMappingURL=badge.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"badge.mjs","sources":["../../../../../../packages/components/badge/src/badge.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils'\n\nimport type {\n ExtractPropTypes,\n StyleValue,\n __ExtractPublicPropTypes,\n} from 'vue'\n\nexport const badgeProps = buildProps({\n /**\n * @description display value.\n */\n value: {\n type: [String, Number],\n default: '',\n },\n /**\n * @description maximum value, shows `{max}+` when exceeded. Only works if value is a number.\n */\n max: {\n type: Number,\n default: 99,\n },\n /**\n * @description if a little dot is displayed.\n */\n isDot: Boolean,\n /**\n * @description hidden badge.\n */\n hidden: Boolean,\n /**\n * @description badge type.\n */\n type: {\n type: String,\n values: ['primary', 'success', 'warning', 'info', 'danger'],\n default: 'danger',\n },\n /**\n * @description whether to show badge when value is zero.\n */\n showZero: {\n type: Boolean,\n default: true,\n },\n /**\n * @description customize dot background color\n */\n color: String,\n /**\n * @description CSS style of badge\n */\n badgeStyle: {\n type: definePropType<StyleValue>([String, Object, Array]),\n },\n /**\n * @description set offset of the badge\n */\n offset: {\n type: definePropType<[number, number]>(Array),\n default: [0, 0],\n },\n /**\n * @description custom class name of badge\n */\n badgeClass: {\n type: String,\n },\n} as const)\nexport type BadgeProps = ExtractPropTypes<typeof badgeProps>\nexport type BadgePropsPublic = __ExtractPublicPropTypes<typeof badgeProps>\n"],"names":[],"mappings":";;AACY,MAAC,UAAU,GAAG,UAAU,CAAC;AACrC,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,GAAG,EAAE;AACP,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,KAAK,EAAE,OAAO;AAChB,EAAE,MAAM,EAAE,OAAO;AACjB,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC;AAC/D,IAAI,OAAO,EAAE,QAAQ;AACrB,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,KAAK,EAAE,MAAM;AACf,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACjD,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACnB,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,MAAM;AAChB,GAAG;AACH,CAAC;;;;"}

View File

@@ -0,0 +1,68 @@
import type { StyleValue } from 'vue';
declare function __VLS_template(): {
default?(_: {}): any;
content?(_: {
value: string;
}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly value: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
readonly max: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 99, boolean>;
readonly isDot: BooleanConstructor;
readonly hidden: BooleanConstructor;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "primary" | "success" | "warning" | "info" | "danger", unknown, "danger", boolean>;
readonly showZero: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly color: StringConstructor;
readonly badgeStyle: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => string | import("vue").CSSProperties | StyleValue[]) | (() => StyleValue) | ((new (...args: any[]) => string | import("vue").CSSProperties | StyleValue[]) | (() => StyleValue))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly offset: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => [number, number]) | (() => [number, number]) | ((new (...args: any[]) => [number, number]) | (() => [number, number]))[], unknown, unknown, readonly [0, 0], boolean>;
readonly badgeClass: {
readonly type: import("vue").PropType<string>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
}, {
/** @description badge content */
content: import("vue").ComputedRef<string>;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly value: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
readonly max: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 99, boolean>;
readonly isDot: BooleanConstructor;
readonly hidden: BooleanConstructor;
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "primary" | "success" | "warning" | "info" | "danger", unknown, "danger", boolean>;
readonly showZero: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly color: StringConstructor;
readonly badgeStyle: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => string | import("vue").CSSProperties | StyleValue[]) | (() => StyleValue) | ((new (...args: any[]) => string | import("vue").CSSProperties | StyleValue[]) | (() => StyleValue))[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly offset: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => [number, number]) | (() => [number, number]) | ((new (...args: any[]) => [number, number]) | (() => [number, number]))[], unknown, unknown, readonly [0, 0], boolean>;
readonly badgeClass: {
readonly type: import("vue").PropType<string>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
}>>, {
readonly hidden: boolean;
readonly offset: [number, number];
readonly value: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>;
readonly type: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "primary" | "success" | "warning" | "info" | "danger", unknown>;
readonly max: number;
readonly showZero: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;
readonly isDot: 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,76 @@
import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, unref, renderSlot, createVNode, Transition, withCtx, withDirectives, createElementVNode, normalizeStyle, createTextVNode, toDisplayString, vShow } from 'vue';
import { badgeProps } from './badge.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { isNumber } from '../../../utils/types.mjs';
import { addUnit } from '../../../utils/dom/style.mjs';
const __default__ = defineComponent({
name: "ElBadge"
});
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: badgeProps,
setup(__props, { expose }) {
const props = __props;
const ns = useNamespace("badge");
const content = computed(() => {
if (props.isDot)
return "";
if (isNumber(props.value) && isNumber(props.max)) {
return props.max < props.value ? `${props.max}+` : `${props.value}`;
}
return `${props.value}`;
});
const style = computed(() => {
var _a, _b, _c, _d, _e;
return [
{
backgroundColor: props.color,
marginRight: addUnit(-((_b = (_a = props.offset) == null ? void 0 : _a[0]) != null ? _b : 0)),
marginTop: addUnit((_d = (_c = props.offset) == null ? void 0 : _c[1]) != null ? _d : 0)
},
(_e = props.badgeStyle) != null ? _e : {}
];
});
expose({
content
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
class: normalizeClass(unref(ns).b())
}, [
renderSlot(_ctx.$slots, "default"),
createVNode(Transition, {
name: `${unref(ns).namespace.value}-zoom-in-center`,
persisted: ""
}, {
default: withCtx(() => [
withDirectives(createElementVNode("sup", {
class: normalizeClass([
unref(ns).e("content"),
unref(ns).em("content", _ctx.type),
unref(ns).is("fixed", !!_ctx.$slots.default),
unref(ns).is("dot", _ctx.isDot),
unref(ns).is("hide-zero", !_ctx.showZero && props.value === 0),
_ctx.badgeClass
]),
style: normalizeStyle(unref(style))
}, [
renderSlot(_ctx.$slots, "content", { value: unref(content) }, () => [
createTextVNode(toDisplayString(unref(content)), 1)
])
], 6), [
[vShow, !_ctx.hidden && (unref(content) || _ctx.isDot || _ctx.$slots.content)]
])
]),
_: 3
}, 8, ["name"])
], 2);
};
}
});
var Badge = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "badge.vue"]]);
export { Badge as default };
//# sourceMappingURL=badge2.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"badge2.mjs","sources":["../../../../../../packages/components/badge/src/badge.vue"],"sourcesContent":["<template>\n <div :class=\"ns.b()\">\n <slot />\n <transition :name=\"`${ns.namespace.value}-zoom-in-center`\">\n <sup\n v-show=\"!hidden && (content || isDot || $slots.content)\"\n :class=\"[\n ns.e('content'),\n ns.em('content', type),\n ns.is('fixed', !!$slots.default),\n ns.is('dot', isDot),\n ns.is('hide-zero', !showZero && props.value === 0),\n badgeClass,\n ]\"\n :style=\"style\"\n >\n <slot name=\"content\" :value=\"content\">\n {{ content }}\n </slot>\n </sup>\n </transition>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { addUnit, isNumber } from '@element-plus/utils'\nimport { badgeProps } from './badge'\n\nimport type { StyleValue } from 'vue'\n\ndefineOptions({\n name: 'ElBadge',\n})\n\nconst props = defineProps(badgeProps)\n\nconst ns = useNamespace('badge')\n\nconst content = computed<string>(() => {\n if (props.isDot) return ''\n if (isNumber(props.value) && isNumber(props.max)) {\n return props.max < props.value ? `${props.max}+` : `${props.value}`\n }\n return `${props.value}`\n})\n\nconst style = computed<StyleValue>(() => {\n return [\n {\n backgroundColor: props.color,\n marginRight: addUnit(-(props.offset?.[0] ?? 0)),\n marginTop: addUnit(props.offset?.[1] ?? 0),\n },\n props.badgeStyle ?? {},\n ]\n})\n\ndefineExpose({\n /** @description badge content */\n content,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;mCAgCc,CAAA;AAAA,EACZ,IAAM,EAAA,SAAA;AACR,CAAA,CAAA,CAAA;;;;;;AAIA,IAAM,MAAA,EAAA,GAAK,aAAa,OAAO,CAAA,CAAA;AAE/B,IAAM,MAAA,OAAA,GAAU,SAAiB,MAAM;AACrC,MAAI,IAAA,KAAA,CAAM;AACV,QAAA;AACE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Badge> & unknown;

View File

@@ -0,0 +1,2 @@
//# sourceMappingURL=instance.mjs.map

View File

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

View File

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

View File

@@ -0,0 +1,3 @@
import '../../base/style/css.mjs';
import 'element-plus/theme-chalk/el-badge.css';
//# sourceMappingURL=css.mjs.map

View File

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

View File

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

View File

@@ -0,0 +1,3 @@
import '../../base/style/index.mjs';
import 'element-plus/theme-chalk/src/badge.scss';
//# sourceMappingURL=index.mjs.map

View File

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