UNPKG

tdesign-vue-next

Version:
153 lines (149 loc) 6.49 kB
/** * tdesign v1.11.5 * (c) 2025 tdesign * @license MIT */ import { _ as _typeof } from '../_chunks/dep-4ed7019e.mjs'; import { _ as _defineProperty } from '../_chunks/dep-da95471f.mjs'; import { isVNode, defineComponent, computed, ref, createVNode, mergeProps } from 'vue'; import { usePrefixClass } from '../hooks/useConfig.mjs'; import props from './paragraph-props.mjs'; import { Tooltip } from '../tooltip/index.mjs'; import { useConfig } from '../config-provider/hooks/useConfig.mjs'; import 'lodash-es'; import '../config-provider/utils/context.mjs'; import '../_chunks/dep-a5ae2f3f.mjs'; import '../_chunks/dep-82d2a14f.mjs'; import '../_chunks/dep-37fa6ccb.mjs'; import '../_chunks/dep-7fb24b17.mjs'; import '../tooltip/tooltip.mjs'; import '../_chunks/dep-6d9c1bfc.mjs'; import '../_chunks/dep-9f375e51.mjs'; import '../tooltip/props.mjs'; import '../popup/props.mjs'; import '../popup/index.mjs'; import '../popup/popup.mjs'; import '@popperjs/core'; import '../hooks/index.mjs'; import '../hooks/icon.mjs'; import '../hooks/slot.mjs'; import '../utils/render-tnode.mjs'; import '../_chunks/dep-46ec3e86.mjs'; import '../hooks/useCommonClassName.mjs'; import '../hooks/useDefaultValue.mjs'; import '../hooks/useDestroyOnClose.mjs'; import '../hooks/useKeepAnimation.mjs'; import '../hooks/useRipple.mjs'; import '../_chunks/dep-6cfc5734.mjs'; import '../hooks/useVirtualScroll.mjs'; import '../hooks/useVModel.mjs'; import '../hooks/useImagePreviewUrl.mjs'; import '../_chunks/dep-dda40c90.mjs'; import '../_chunks/dep-88187fb2.mjs'; import '../utils/dom.mjs'; import '../popup/container.mjs'; import '../_chunks/dep-03e058e5.mjs'; import '../hooks/useResizeObserver.mjs'; import '../utils/withInstall.mjs'; import './style/css.mjs'; import '../tooltip/utils/index.mjs'; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _isSlot(s) { return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s); } var Ellipsis = defineComponent({ name: "TEllipsis", components: { TTooltip: Tooltip }, props: _objectSpread({}, props), setup: function setup(props2, _ref) { var slots = _ref.slots; var COMPONENT_NAME = usePrefixClass("typography"); var _useConfig = useConfig("typography"), globalConfig = _useConfig.globalConfig; var content = computed(function () { return props2.content || (slots === null || slots === void 0 ? void 0 : slots["default"]()); }); var ellipsisState = computed(function () { var ellipsis = props2.ellipsis; return _objectSpread({ row: 1, expandable: false }, _typeof(ellipsis) === "object" ? ellipsis : null); }); var ellipsisStyles = computed(function () { var ellipsis = ellipsisState.value; var def = { overflow: props2.ellipsis ? "hidden" : "visible", textOverflow: props2.ellipsis ? "ellipsis" : "initial", whiteSpace: props2.ellipsis ? "normal" : "nowrap", display: "-webkit-box", WebkitLineClamp: ellipsis.row, WebkitBoxOrient: "vertical" }; if (isExpand.value) { def.overflow = "visible"; def.whiteSpace = "normal"; def.display = "initial"; } return def; }); var isExpand = ref(false); var onExpand = function onExpand() { var _props2$ellipsis$onEx, _props2$ellipsis; isExpand.value = true; if (_typeof(props2.ellipsis) === "object") (_props2$ellipsis$onEx = (_props2$ellipsis = props2.ellipsis).onExpand) === null || _props2$ellipsis$onEx === void 0 || _props2$ellipsis$onEx.call(_props2$ellipsis, true); }; var onCollapse = function onCollapse() { var _props2$ellipsis$onEx2, _props2$ellipsis2; isExpand.value = false; if (_typeof(props2.ellipsis) === "object") (_props2$ellipsis$onEx2 = (_props2$ellipsis2 = props2.ellipsis).onExpand) === null || _props2$ellipsis$onEx2 === void 0 || _props2$ellipsis$onEx2.call(_props2$ellipsis2, false); }; var renderEllipsisExpand = function renderEllipsisExpand() { var suffix = ellipsisState.value.suffix; var moreNode = createVNode("span", { "class": "".concat(COMPONENT_NAME.value, "-ellipsis-symbol"), "onClick": onExpand, "style": "text-decoration:none;white-space:nowrap;flex: 1;" }, [suffix || globalConfig.value.expandText]); var _ellipsisState$value = ellipsisState.value, tooltipProps = _ellipsisState$value.tooltipProps, expandable = _ellipsisState$value.expandable, collapsible = _ellipsisState$value.collapsible; if (!isExpand.value && expandable) { return tooltipProps && tooltipProps.content ? createVNode(Tooltip, mergeProps(tooltipProps, { "content": tooltipProps.content }), _isSlot(moreNode) ? moreNode : { "default": function _default() { return [moreNode]; } }) : moreNode; } if (expandable && isExpand.value && collapsible) { return createVNode("span", { "class": "".concat(COMPONENT_NAME.value, "-ellipsis-symbol"), "onClick": onCollapse, "style": "text-decoration:none;white-space:nowrap;flex: 1;" }, [globalConfig.value.collapseText]); } }; return function () { var tooltipProps = ellipsisState.value.tooltipProps; return createVNode("div", { "style": { display: "flex", alignItems: "flex-end" } }, [tooltipProps && createVNode(Tooltip, { "content": tooltipProps.content, "placement": "top-right" }, null), createVNode("p", { "style": props2.ellipsis ? ellipsisStyles.value : {} }, [content.value]), renderEllipsisExpand()]); }; } }); export { Ellipsis as default }; //# sourceMappingURL=ellipsis.mjs.map