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 Text from './src/text.vue';
import type { SFCWithInstall } from 'element-plus/es/utils';
export declare const ElText: SFCWithInstall<typeof Text>;
export default ElText;
export * from './src/text';

View File

@@ -0,0 +1,8 @@
import Text from './src/text.mjs';
export { textProps } from './src/text2.mjs';
import { withInstall } from '../../utils/vue/install.mjs';
const ElText = withInstall(Text);
export { ElText, ElText as default };
//# sourceMappingURL=index.mjs.map

View File

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

View File

@@ -0,0 +1,15 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
export declare const textProps: {
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "primary" | "success" | "warning" | "info" | "danger", unknown, "", boolean>;
readonly size: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "small" | "default" | "large", unknown, "", boolean>;
readonly truncated: BooleanConstructor;
readonly lineClamp: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly tag: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "span", boolean>;
};
export type TextProps = ExtractPropTypes<typeof textProps>;
export type TextPropsPublic = __ExtractPublicPropTypes<typeof textProps>;

View File

@@ -0,0 +1,72 @@
import { defineComponent, ref, computed, onMounted, onUpdated, openBlock, createBlock, resolveDynamicComponent, normalizeClass, unref, normalizeStyle, withCtx, renderSlot, useAttrs } from 'vue';
import { textProps } from './text2.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useFormSize } from '../../form/src/hooks/use-form-common-props.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { isUndefined } from '../../../utils/types.mjs';
const __default__ = defineComponent({
name: "ElText"
});
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: textProps,
setup(__props) {
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 bindTitle = () => {
var _a, _b, _c, _d, _e, _f, _g;
const inheritTitle = useAttrs().title;
if (inheritTitle)
return;
let shouldAddTitle = false;
const text = ((_a = textRef.value) == null ? void 0 : _a.textContent) || "";
if (props.truncated) {
const width = (_b = textRef.value) == null ? void 0 : _b.offsetWidth;
const scrollWidth = (_c = textRef.value) == null ? void 0 : _c.scrollWidth;
if (width && scrollWidth && scrollWidth > width) {
shouldAddTitle = true;
}
} else if (!isUndefined(props.lineClamp)) {
const height = (_d = textRef.value) == null ? void 0 : _d.offsetHeight;
const scrollHeight = (_e = textRef.value) == null ? void 0 : _e.scrollHeight;
if (height && scrollHeight && scrollHeight > height) {
shouldAddTitle = true;
}
}
if (shouldAddTitle) {
(_f = textRef.value) == null ? void 0 : _f.setAttribute("title", text);
} else {
(_g = textRef.value) == null ? void 0 : _g.removeAttribute("title");
}
};
onMounted(bindTitle);
onUpdated(bindTitle);
return (_ctx, _cache) => {
return openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), {
ref_key: "textRef",
ref: textRef,
class: normalizeClass(unref(textKls)),
style: normalizeStyle({ "-webkit-line-clamp": _ctx.lineClamp })
}, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 8, ["class", "style"]);
};
}
});
var Text = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "text.vue"]]);
export { Text as default };
//# sourceMappingURL=text.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"text.mjs","sources":["../../../../../../packages/components/text/src/text.vue"],"sourcesContent":["<template>\n <component\n :is=\"tag\"\n ref=\"textRef\"\n :class=\"textKls\"\n :style=\"{ '-webkit-line-clamp': lineClamp }\"\n >\n <slot />\n </component>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, onMounted, onUpdated, ref, useAttrs } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { useFormSize } from '@element-plus/components/form'\nimport { isUndefined } from '@element-plus/utils'\nimport { textProps } from './text'\n\ndefineOptions({\n name: 'ElText',\n})\n\nconst props = defineProps(textProps)\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 bindTitle = () => {\n const inheritTitle = useAttrs().title\n\n if (inheritTitle) return\n let shouldAddTitle = false\n const text = textRef.value?.textContent || ''\n\n if (props.truncated) {\n const width = textRef.value?.offsetWidth\n const scrollWidth = textRef.value?.scrollWidth\n if (width && scrollWidth && scrollWidth > width) {\n shouldAddTitle = 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 shouldAddTitle = true\n }\n }\n\n if (shouldAddTitle) {\n textRef.value?.setAttribute('title', text)\n } else {\n textRef.value?.removeAttribute('title')\n }\n}\n\nonMounted(bindTitle)\nonUpdated(bindTitle)\n</script>\n"],"names":[],"mappings":";;;;;;;mCAkBc,CAAA;AAAA,EACZ,IAAM,EAAA,QAAA;AACR,CAAA,CAAA,CAAA;;;;;;AAGA,I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,WAAA,IAAA,WAAA,GAAA,KAAA,EAAA;AAAA,UACS,cAAa,GAAA,IAAA,CAAA;AACtB,SAAM;AACN,OAAM,MAAA,IAAA,CAAA,WAAe,gBAAe,CAAA,EAAA;AACpC,QAAI,MAAA,MAAA,GAA0B,CAAA,EAAA,GAAA,OAAA,CAAA,KAAA,KAAA,IAAA,GAAuB,KAAA,CAAA,GAAA,EAAA,CAAA,YAAA,CAAA;AACnD,QAAiB,MAAA,YAAA,GAAA,CAAA,EAAA,GAAA,OAAA,CAAA,KAAA,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,YAAA,CAAA;AAAA,QACnB,IAAA,MAAA,IAAA,YAAA,IAAA,YAAA,GAAA,MAAA,EAAA;AAAA,UACF,cAAA,GAAA,IAAA,CAAA;AAEA,SAAA;AACE,OAAQ;AAAiC,MAC3C,IAAO,cAAA,EAAA;AACL,QAAQ,CAAA,EAAA,GAAA,OAAA,CAAA,iBAAuB,KAAO,CAAA,GAAA,EAAA,CAAA,YAAA,CAAA,OAAA,EAAA,IAAA,CAAA,CAAA;AAAA,OACxC,MAAA;AAAA,QACF,CAAA,EAAA,GAAA,OAAA,CAAA,KAAA,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,eAAA,CAAA,OAAA,CAAA,CAAA;AAEA,OAAA;AACA,KAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,38 @@
declare function __VLS_template(): {
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "primary" | "success" | "warning" | "info" | "danger", unknown, "", boolean>;
readonly size: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "small" | "default" | "large", unknown, "", boolean>;
readonly truncated: BooleanConstructor;
readonly lineClamp: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly tag: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "span", boolean>;
}, {}, 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 type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "primary" | "success" | "warning" | "info" | "danger", unknown, "", boolean>;
readonly size: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "" | "small" | "default" | "large", unknown, "", boolean>;
readonly truncated: BooleanConstructor;
readonly lineClamp: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly tag: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "span", boolean>;
}>>, {
readonly size: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", unknown>;
readonly type: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "" | "primary" | "success" | "warning" | "info" | "danger", unknown>;
readonly tag: string;
readonly truncated: 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,26 @@
import { buildProps } from '../../../utils/vue/props/runtime.mjs';
import { componentSizes } from '../../../constants/size.mjs';
const textProps = buildProps({
type: {
type: String,
values: ["primary", "success", "info", "warning", "danger", ""],
default: ""
},
size: {
type: String,
values: componentSizes,
default: ""
},
truncated: Boolean,
lineClamp: {
type: [String, Number]
},
tag: {
type: String,
default: "span"
}
});
export { textProps };
//# sourceMappingURL=text2.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"text2.mjs","sources":["../../../../../../packages/components/text/src/text.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils'\nimport { componentSizes } from '@element-plus/constants'\n\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\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\nexport type TextProps = ExtractPropTypes<typeof textProps>\nexport type TextPropsPublic = __ExtractPublicPropTypes<typeof textProps>\n"],"names":[],"mappings":";;;AAEY,MAAC,SAAS,GAAG,UAAU,CAAC;AACpC,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC;AACnE,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,cAAc;AAC1B,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,SAAS,EAAE,OAAO;AACpB,EAAE,SAAS,EAAE;AACb,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,GAAG;AACH,EAAE,GAAG,EAAE;AACP,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,MAAM;AACnB,GAAG;AACH,CAAC;;;;"}

View File

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

View File

@@ -0,0 +1,3 @@
import '../../base/style/css.mjs';
import 'element-plus/theme-chalk/el-text.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/text.scss';

View File

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

View File

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