UNPKG

tdesign-vue-next

Version:
152 lines (148 loc) 6.52 kB
/** * tdesign v1.19.2 * (c) 2026 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-c68ea098.js'; import { u as usePrefixClass } from '../../_chunks/dep-e8dd47a9.js'; import '@babel/runtime/helpers/slicedToArray'; import '../../_chunks/dep-91fc762d.js'; import props from '../paragraph-props.js'; import { Tooltip } from '../../tooltip/index.js'; import { useConfig } from '../../config-provider/hooks/useConfig.js'; import '../../_chunks/dep-f0f392fb.js'; import '../../config-provider/utils/context.js'; import '../../_chunks/dep-509ddbe3.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-d518fdfb.js'; import '../../_chunks/dep-7bdccf65.js'; import '../../_chunks/dep-8d4d971b.js'; import '../../_chunks/dep-98d89c71.js'; import '../../_chunks/dep-ef7a41ce.js'; import '../../_chunks/dep-e332908e.js'; import '../../popup/container.js'; import '../../_chunks/dep-d5fc4caa.js'; import '../../_chunks/dep-ae3e94b6.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: _objectSpread(_objectSpread({}, props), {}, { renderCopy: Function }), 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 symbolStyle = { textDecoration: "none", whiteSpace: "nowrap", flex: 1, marginRight: props2.renderCopy ? "8px" : 0 }; var moreNode = createVNode("span", { "class": "".concat(COMPONENT_NAME.value, "-ellipsis-symbol"), "onClick": onExpand, "style": symbolStyle }, [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": symbolStyle }, [globalConfig.value.collapseText]); } }; return function () { var _props2$renderCopy; 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(), (_props2$renderCopy = props2.renderCopy) === null || _props2$renderCopy === void 0 ? void 0 : _props2$renderCopy.call(props2)]); }; } }); export { Ellipsis as default }; //# sourceMappingURL=ellipsis.js.map