UNPKG

tdesign-vue

Version:
178 lines (174 loc) 7.06 kB
/** * tdesign v1.15.0 * (c) 2026 tdesign * @license MIT */ import { h as helper } from '../../_chunks/dep-23f4ec37.js'; import _typeof from '@babel/runtime/helpers/typeof'; import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { defineComponent, computed, ref } from '@vue/composition-api'; import { usePrefixClass, useConfig } from '../../config-provider/useConfig.js'; import { useContent } from '../../hooks/tnode.js'; import props from '../paragraph-props.js'; import { Tooltip } from '../../tooltip/index.js'; import '../../config-provider/context.js'; import 'lodash-es'; import '../../_common/js/global-config/default-config.js'; import '../../_common/js/global-config/locale/zh_CN.js'; import '../../_chunks/dep-f96e5597.js'; import '../../_chunks/dep-b7176ef3.js'; import 'dayjs'; import '../../_chunks/dep-77bb0823.js'; import '../../config-provider/type.js'; import '../../_common/js/global-config/t.js'; import '@babel/runtime/helpers/slicedToArray'; import '../../hooks/render-tnode.js'; import '../../tooltip/tooltip.js'; import '../../tooltip/props.js'; import '../../popup/props.js'; import '../../popup/popup.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@popperjs/core'; import '../../utils/dom.js'; import 'vue'; import 'raf'; import '../../utils/easing.js'; import '../../utils/render-tnode.js'; import '@babel/runtime/helpers/readOnlyError'; import '../../utils/helper.js'; import '@babel/runtime/helpers/objectWithoutProperties'; import '../../_common/js/utils/setStyle.js'; import '../../popup/container.js'; import '../../config-provider/config-receiver.js'; import '../../utils/mixins.js'; import '../../utils/event.js'; import '../../popup/utils.js'; import '../../utils/map-props.js'; import '../../utils/withInstall.js'; import './style/index.js'; import '../../tooltip/type.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; } var Ellipsis = defineComponent({ name: "TEllipsis", components: { TTooltip: Tooltip }, props: _objectSpread(_objectSpread({}, props), {}, { renderCopy: Function }), setup: function setup(props2) { var COMPONENT_NAME = usePrefixClass("typography"); var _useConfig = useConfig("typography"), globalConfig = _useConfig.globalConfig; var renderContent = useContent(); var ellipsisState = computed(function () { var ellipsis = props2.ellipsis; return _objectSpread({ row: 1, expandable: false }, _typeof(ellipsis) === "object" ? ellipsis : {}); }); var isExpand = ref(false); 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 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); }; return { COMPONENT_NAME: COMPONENT_NAME, globalConfig: globalConfig, ellipsisState: ellipsisState, isExpand: isExpand, ellipsisStyles: ellipsisStyles, renderContent: renderContent, onExpand: onExpand, onCollapse: onCollapse }; }, methods: { renderEllipsisExpand: function renderEllipsisExpand() { var h = this.$createElement; var _this$ellipsisState = this.ellipsisState, suffix = _this$ellipsisState.suffix, expandable = _this$ellipsisState.expandable, collapsible = _this$ellipsisState.collapsible; var symbolStyle = { textDecoration: "none", whiteSpace: "nowrap", flex: 1, marginRight: this.renderCopy ? "8px" : 0 }; var renderSuffix = function renderSuffix(expanded) { if (typeof suffix === "function") return suffix({ expanded: expanded }); return suffix; }; if (!this.isExpand && expandable) { return h("span", { "class": "".concat(this.COMPONENT_NAME, "-ellipsis-symbol"), "on": { "click": this.onExpand }, "style": symbolStyle }, [renderSuffix(false) || this.globalConfig.expandText]); } if (expandable && this.isExpand && collapsible) { return h("span", { "class": "".concat(this.COMPONENT_NAME, "-ellipsis-symbol"), "on": { "click": this.onCollapse }, "style": symbolStyle }, [renderSuffix(true) || this.globalConfig.collapseText]); } } }, render: function render() { var _this$renderCopy; var h = arguments[0]; var tooltipProps = this.ellipsisState.tooltipProps; var content = this.renderContent("default", "content"); var ellipsisNode = h("p", { "style": this.ellipsis ? this.ellipsisStyles : {} }, [content]); var shouldShowTooltip = !!tooltipProps && !!this.ellipsis && !this.isExpand; var wrappedEllipsisNode = shouldShowTooltip ? h(Tooltip, helper([{}, { "props": _objectSpread({ placement: "top-right", content: content }, tooltipProps) }]), [ellipsisNode]) : ellipsisNode; return h("div", { "style": { display: "flex", alignItems: "flex-end" } }, [wrappedEllipsisNode, this.renderEllipsisExpand(), (_this$renderCopy = this.renderCopy) === null || _this$renderCopy === void 0 ? void 0 : _this$renderCopy.call(this)]); } }); export { Ellipsis as default }; //# sourceMappingURL=ellipsis.js.map