This commit is contained in:
gr
2026-11-11 14:22:02 +08:00
parent 245618dcdc
commit a62311a8da
64878 changed files with 3747172 additions and 66 deletions
@@ -0,0 +1,51 @@
import { EpPropFinalized, EpPropMergeType } from "../../../utils/vue/props/types.js";
import { ComponentSize } from "../../../constants/size.js";
import _default from "./text.vue.js";
import * as _$vue from "vue";
import { ExtractPublicPropTypes } from "vue";
//#region ../../packages/components/text/src/text.d.ts
interface TextProps {
/**
* @description text type
*/
type?: 'primary' | 'success' | 'info' | 'warning' | 'danger' | '';
/**
* @description text size
*/
size?: ComponentSize;
/**
* @description render ellipsis
*/
truncated?: boolean;
/**
* @description maximum lines
*/
lineClamp?: number | string;
/**
* @description custom element tag
*/
tag?: string;
}
/**
* @deprecated Removed after 3.0.0, Use `TextProps` instead.
*/
declare const textProps: {
readonly type: EpPropFinalized<StringConstructor, "" | "info" | "primary" | "success" | "warning" | "danger", unknown, "", boolean>;
readonly size: EpPropFinalized<StringConstructor, "" | "default" | "large" | "small", unknown, "", boolean>;
readonly truncated: BooleanConstructor;
readonly lineClamp: {
readonly type: _$vue.PropType<EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly tag: EpPropFinalized<StringConstructor, unknown, unknown, "span", boolean>;
};
/**
* @deprecated Removed after 3.0.0, Use `TextProps` instead.
*/
type TextPropsPublic = ExtractPublicPropTypes<typeof textProps>;
type TextInstance = InstanceType<typeof _default> & unknown;
//#endregion
export { TextInstance, TextProps, TextPropsPublic, textProps };
@@ -0,0 +1,50 @@
import { componentSizes } from "../../../constants/size.mjs";
import { buildProps } from "../../../utils/vue/props/runtime.mjs";
//#region ../../packages/components/text/src/text.ts
/**
* @deprecated Removed after 3.0.0, Use `TextProps` instead.
*/
const textProps = buildProps({
/**
* @description text type
*/
type: {
type: String,
values: [
"primary",
"success",
"info",
"warning",
"danger",
""
],
default: ""
},
/**
* @description text size
*/
size: {
type: String,
values: componentSizes,
default: ""
},
/**
* @description render ellipsis
*/
truncated: Boolean,
/**
* @description maximum lines
*/
lineClamp: { type: [String, Number] },
/**
* @description custom element tag
*/
tag: {
type: String,
default: "span"
}
});
//#endregion
export { textProps };
//# sourceMappingURL=text.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"text.mjs","names":[],"sources":["../../../../../../packages/components/text/src/text.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils'\nimport { componentSizes } from '@element-plus/constants'\n\nimport type { ExtractPublicPropTypes } from 'vue'\nimport type { ComponentSize } from '@element-plus/constants'\nimport type Text from './text.vue'\n\nexport interface TextProps {\n /**\n * @description text type\n */\n type?: 'primary' | 'success' | 'info' | 'warning' | 'danger' | ''\n /**\n * @description text size\n */\n size?: ComponentSize\n /**\n * @description render ellipsis\n */\n truncated?: boolean\n /**\n * @description maximum lines\n */\n lineClamp?: number | string\n /**\n * @description custom element tag\n */\n tag?: string\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `TextProps` instead.\n */\nexport const textProps = buildProps({\n /**\n * @description text type\n */\n type: {\n type: String,\n values: ['primary', 'success', 'info', 'warning', 'danger', ''],\n default: '',\n },\n /**\n * @description text size\n */\n size: {\n type: String,\n values: componentSizes,\n default: '',\n },\n /**\n * @description render ellipsis\n */\n truncated: Boolean,\n /**\n * @description maximum lines\n */\n lineClamp: {\n type: [String, Number],\n },\n /**\n * @description custom element tag\n */\n tag: {\n type: String,\n default: 'span',\n },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `TextProps` instead.\n */\nexport type TextPropsPublic = ExtractPublicPropTypes<typeof textProps>\n\nexport type TextInstance = InstanceType<typeof Text> & unknown\n"],"mappings":";;;;;;AAiCA,MAAa,YAAY,WAAW;;;;CAIlC,MAAM;EACJ,MAAM;EACN,QAAQ;GAAC;GAAW;GAAW;GAAQ;GAAW;GAAU;EAAE;EAC9D,SAAS;CACX;;;;CAIA,MAAM;EACJ,MAAM;EACN,QAAQ;EACR,SAAS;CACX;;;;CAIA,WAAW;;;;CAIX,WAAW,EACT,MAAM,CAAC,QAAQ,MAAM,EACvB;;;;CAIA,KAAK;EACH,MAAM;EACN,SAAS;CACX;AACF,CAAU"}
@@ -0,0 +1,25 @@
import { ComponentSize } from "../../../constants/size.js";
import { TextProps } from "./text.js";
import * as _$vue from "vue";
//#region ../../packages/components/text/src/text.vue.d.ts
declare var __VLS_9: {};
type __VLS_Slots = {} & {
default?: (props: typeof __VLS_9) => any;
};
declare const __VLS_base: _$vue.DefineComponent<TextProps, {
/** @description whether the text is truncated */isTruncated: _$vue.Ref<boolean, boolean>;
}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<TextProps> & Readonly<{}>, {
type: "primary" | "success" | "info" | "warning" | "danger" | "";
size: ComponentSize;
tag: string;
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
declare const _default: typeof __VLS_export;
type __VLS_WithSlots<T, S> = T & {
new (): {
$slots: S;
};
};
//#endregion
export { _default as default };
@@ -0,0 +1,85 @@
import { isUndefined } from "../../../utils/types.mjs";
import { cAF, rAF } from "../../../utils/raf.mjs";
import { useNamespace } from "../../../hooks/use-namespace/index.mjs";
import { useFormSize } from "../../form/src/hooks/use-form-common-props.mjs";
import { textProps } from "./text.mjs";
import { useElementSize, useMutationObserver } from "@vueuse/core";
import { computed, createBlock, defineComponent, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderSlot, resolveDynamicComponent, watch, withCtx } from "vue";
//#region ../../packages/components/text/src/text.vue?vue&type=script&setup=true&lang.ts
var text_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
name: "ElText",
__name: "text",
props: textProps,
setup(__props, { expose: __expose }) {
const props = __props;
const textRef = ref();
const textSize = useFormSize();
const ns = useNamespace("text");
const textKls = computed(() => [
ns.b(),
ns.m(props.type),
ns.m(textSize.value),
ns.is("truncated", props.truncated),
ns.is("line-clamp", !isUndefined(props.lineClamp))
]);
const { width, height } = useElementSize(textRef);
const isTruncated = ref(false);
let rafId;
const bindTitle = () => {
if (rafId) cAF(rafId);
rafId = rAF(() => {
rafId = void 0;
isTruncated.value = false;
if (props.truncated) {
const width = textRef.value?.offsetWidth;
const scrollWidth = textRef.value?.scrollWidth;
if (width && scrollWidth && scrollWidth > width) isTruncated.value = true;
} else if (!isUndefined(props.lineClamp)) {
const height = textRef.value?.offsetHeight;
const scrollHeight = textRef.value?.scrollHeight;
if (height && scrollHeight && scrollHeight > height) isTruncated.value = true;
}
});
};
watch(() => [
width.value,
height.value,
props.truncated,
props.lineClamp
], bindTitle, { flush: "post" });
useMutationObserver(textRef, bindTitle, {
attributes: true,
attributeFilter: ["class", "style"],
subtree: true,
childList: true,
characterData: true
});
onMounted(bindTitle);
onBeforeUnmount(() => {
if (rafId) cAF(rafId);
});
__expose({
/** @description whether the text is truncated */
isTruncated });
return (_ctx, _cache) => {
return openBlock(), createBlock(resolveDynamicComponent(__props.tag), {
ref_key: "textRef",
ref: textRef,
class: normalizeClass(textKls.value),
title: _ctx.$attrs.title ?? (isTruncated.value ? textRef.value?.textContent : void 0),
style: normalizeStyle({ "-webkit-line-clamp": __props.lineClamp })
}, {
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
_: 3
}, 8, [
"class",
"title",
"style"
]);
};
}
});
//#endregion
export { text_vue_vue_type_script_setup_true_lang_default as default };
//# sourceMappingURL=text.vue_vue_type_script_setup_true_lang.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"text.vue_vue_type_script_setup_true_lang.mjs","names":["$attrs"],"sources":["../../../../../../packages/components/text/src/text.vue"],"sourcesContent":["<template>\n <component\n :is=\"tag\"\n ref=\"textRef\"\n :class=\"textKls\"\n :title=\"$attrs.title ?? (isTruncated ? textRef?.textContent : undefined)\"\n :style=\"{ '-webkit-line-clamp': lineClamp }\"\n >\n <slot />\n </component>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useElementSize, useMutationObserver } from '@vueuse/core'\nimport { useNamespace } from '@element-plus/hooks'\nimport { useFormSize } from '@element-plus/components/form'\nimport { cAF, isUndefined, rAF } from '@element-plus/utils'\n\nimport type { TextProps } from './text'\n\ndefineOptions({\n name: 'ElText',\n})\n\nconst props = withDefaults(defineProps<TextProps>(), {\n type: '',\n size: '',\n tag: 'span',\n})\nconst textRef = ref<HTMLElement>()\n\nconst textSize = useFormSize()\nconst ns = useNamespace('text')\n\nconst textKls = computed(() => [\n ns.b(),\n ns.m(props.type),\n ns.m(textSize.value),\n ns.is('truncated', props.truncated),\n ns.is('line-clamp', !isUndefined(props.lineClamp)),\n])\n\nconst { width, height } = useElementSize(textRef)\nconst isTruncated = ref(false)\nlet rafId: number | undefined\n\nconst bindTitle = () => {\n if (rafId) {\n cAF(rafId)\n }\n\n rafId = rAF(() => {\n rafId = undefined\n isTruncated.value = false\n\n if (props.truncated) {\n const width = textRef.value?.offsetWidth\n const scrollWidth = textRef.value?.scrollWidth\n if (width && scrollWidth && scrollWidth > width) {\n isTruncated.value = true\n }\n } else if (!isUndefined(props.lineClamp)) {\n const height = textRef.value?.offsetHeight\n const scrollHeight = textRef.value?.scrollHeight\n if (height && scrollHeight && scrollHeight > height) {\n isTruncated.value = true\n }\n }\n })\n}\n\nwatch(\n () => [width.value, height.value, props.truncated, props.lineClamp],\n bindTitle,\n { flush: 'post' }\n)\n\nuseMutationObserver(textRef, bindTitle, {\n attributes: true,\n attributeFilter: ['class', 'style'],\n subtree: true,\n childList: true,\n characterData: true,\n})\n\nonMounted(bindTitle)\nonBeforeUnmount(() => {\n if (rafId) {\n cAF(rafId)\n }\n})\n\ndefineExpose({\n /** @description whether the text is truncated */\n isTruncated,\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;EAyBA,MAAM,QAAQ;EAKd,MAAM,UAAU,I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A,OAAO,UAAU,YAAA,QAAc,QAAA,OAAS,cAAc,KAAA;IAC7D,OAAK,eAAA,EAAA,sBAA0B,QAAA,UAAS,CAAA;;IAEzC,SAAA,cAAQ,CAAR,WAAQ,KAAA,QAAA,SAAA,CAAA,CAAA"}
@@ -0,0 +1,7 @@
import text_vue_vue_type_script_setup_true_lang_default from "./text.vue_vue_type_script_setup_true_lang.mjs";
//#region ../../packages/components/text/src/text.vue
var text_default = text_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { text_default as default };
//# sourceMappingURL=text2.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"text2.mjs","names":[],"sources":["../../../../../../packages/components/text/src/text.vue"],"sourcesContent":["<template>\n <component\n :is=\"tag\"\n ref=\"textRef\"\n :class=\"textKls\"\n :title=\"$attrs.title ?? (isTruncated ? textRef?.textContent : undefined)\"\n :style=\"{ '-webkit-line-clamp': lineClamp }\"\n >\n <slot />\n </component>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useElementSize, useMutationObserver } from '@vueuse/core'\nimport { useNamespace } from '@element-plus/hooks'\nimport { useFormSize } from '@element-plus/components/form'\nimport { cAF, isUndefined, rAF } from '@element-plus/utils'\n\nimport type { TextProps } from './text'\n\ndefineOptions({\n name: 'ElText',\n})\n\nconst props = withDefaults(defineProps<TextProps>(), {\n type: '',\n size: '',\n tag: 'span',\n})\nconst textRef = ref<HTMLElement>()\n\nconst textSize = useFormSize()\nconst ns = useNamespace('text')\n\nconst textKls = computed(() => [\n ns.b(),\n ns.m(props.type),\n ns.m(textSize.value),\n ns.is('truncated', props.truncated),\n ns.is('line-clamp', !isUndefined(props.lineClamp)),\n])\n\nconst { width, height } = useElementSize(textRef)\nconst isTruncated = ref(false)\nlet rafId: number | undefined\n\nconst bindTitle = () => {\n if (rafId) {\n cAF(rafId)\n }\n\n rafId = rAF(() => {\n rafId = undefined\n isTruncated.value = false\n\n if (props.truncated) {\n const width = textRef.value?.offsetWidth\n const scrollWidth = textRef.value?.scrollWidth\n if (width && scrollWidth && scrollWidth > width) {\n isTruncated.value = true\n }\n } else if (!isUndefined(props.lineClamp)) {\n const height = textRef.value?.offsetHeight\n const scrollHeight = textRef.value?.scrollHeight\n if (height && scrollHeight && scrollHeight > height) {\n isTruncated.value = true\n }\n }\n })\n}\n\nwatch(\n () => [width.value, height.value, props.truncated, props.lineClamp],\n bindTitle,\n { flush: 'post' }\n)\n\nuseMutationObserver(textRef, bindTitle, {\n attributes: true,\n attributeFilter: ['class', 'style'],\n subtree: true,\n childList: true,\n characterData: true,\n})\n\nonMounted(bindTitle)\nonBeforeUnmount(() => {\n if (rafId) {\n cAF(rafId)\n }\n})\n\ndefineExpose({\n /** @description whether the text is truncated */\n isTruncated,\n})\n</script>\n"],"mappings":""}