UNPKG

tdesign-vue-next

Version:
143 lines (139 loc) 6.2 kB
/** * tdesign v1.15.2 * (c) 2025 tdesign * @license MIT */ import { defineComponent, computed, ref, createVNode, mergeProps, isVNode } from 'vue'; import _typeof from '@babel/runtime/helpers/typeof'; import _defineProperty from '@babel/runtime/helpers/defineProperty'; import 'lodash-es'; import '@babel/runtime/helpers/toConsumableArray'; import '../../_chunks/dep-e604a5ce.js'; import { u as usePrefixClass } from '../../_chunks/dep-79c44a11.js'; import '@babel/runtime/helpers/slicedToArray'; import '../../_chunks/dep-7324137b.js'; import props from '../paragraph-props.js'; import { Tooltip } from '../../tooltip/index.js'; import { useConfig } from '../../config-provider/hooks/useConfig.js'; import '../../_chunks/dep-7fac49fa.js'; import '../../config-provider/utils/context.js'; import '../../_chunks/dep-3b49fbbe.js'; import 'dayjs'; import '@babel/runtime/helpers/createClass'; import '@babel/runtime/helpers/classCallCheck'; import '../../tooltip/tooltip.js'; import '../../tooltip/props.js'; import '../../popup/props.js'; import '../../popup/index.js'; import '../../popup/popup.js'; import '@popperjs/core'; import '../../_chunks/dep-1f7ad104.js'; import '../../_chunks/dep-1d44782f.js'; import '../../_chunks/dep-6c13cc0e.js'; import '../../_chunks/dep-b9ab7399.js'; import '../../_chunks/dep-3ba91e12.js'; import '../../_chunks/dep-34e44a4e.js'; import '../../popup/container.js'; import '../../_chunks/dep-82e44120.js'; import '../../_chunks/dep-37a2e7c8.js'; import '../../tooltip/utils/index.js'; 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: 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.js.map