UNPKG

tdesign-vue

Version:
181 lines (173 loc) 6.86 kB
/** * tdesign v1.12.1 * (c) 2025 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _defineProperty = require('@babel/runtime/helpers/defineProperty'); var Vue = require('vue'); var anchor_utils = require('./utils.js'); var anchor_anchorItemProps = require('./anchor-item-props.js'); var configProvider_configReceiver = require('../config-provider/config-receiver.js'); var utils_mixins = require('../utils/mixins.js'); var isEmpty = require('../_chunks/dep-f6069bb1.js'); require('../_chunks/dep-6247fdbf.js'); require('../_common/js/global-config/default-config.js'); require('../_common/js/global-config/locale/zh_CN.js'); require('../_chunks/dep-3ed0c42e.js'); require('@babel/runtime/helpers/typeof'); require('../_chunks/dep-53935099.js'); require('dayjs'); require('../_chunks/dep-403352a7.js'); require('../_chunks/dep-cca66fee.js'); require('../_chunks/dep-4361b357.js'); require('../_chunks/dep-887c649b.js'); require('../_chunks/dep-411a10dd.js'); require('../_chunks/dep-5ea2b00f.js'); require('../_chunks/dep-51fe98f1.js'); require('../_chunks/dep-3d682642.js'); require('../_chunks/dep-dea23841.js'); require('../_chunks/dep-d7270eaf.js'); require('../_chunks/dep-9b72cbc5.js'); require('../_chunks/dep-4aa08166.js'); require('../_chunks/dep-ddc1429e.js'); require('../_chunks/dep-65896ff9.js'); require('../_chunks/dep-b65b2f55.js'); require('../_chunks/dep-6e7b8cda.js'); require('../_chunks/dep-98f48ff2.js'); require('../_chunks/dep-80e3757f.js'); require('../_chunks/dep-08d7842c.js'); require('../_chunks/dep-1ca3138c.js'); require('../_chunks/dep-e6ed4b1f.js'); require('../_chunks/dep-c44b2462.js'); require('../_common/js/global-config/t.js'); require('@babel/runtime/helpers/slicedToArray'); require('../_chunks/dep-6b60413b.js'); require('../_chunks/dep-ed8c3176.js'); require('../_chunks/dep-28836b00.js'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty); var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); 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__default["default"](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 classPrefixMixins = configProvider_configReceiver.getClassPrefixMixins("anchor"); var _AnchorItem = utils_mixins["default"](Vue__default["default"], classPrefixMixins).extend({ name: "TAnchorItem", props: _objectSpread(_objectSpread({}, anchor_anchorItemProps["default"]), {}, { _level: { type: Number, "default": 0 }, href: { type: String, required: true, validator: function validator(v) { return anchor_utils.ANCHOR_SHARP_REGEXP.test(v); } } }), inject: { tAnchor: { "default": void 0 } }, watch: { href: { immediate: true, handler: function handler() { this.unregister(); this.register(); } } }, destroyed: function destroyed() { this.unregister(); }, methods: { register: function register() { this.tAnchor.registerLink(this.href); }, unregister: function unregister() { var href = this.href; if (!href) return; this.tAnchor.unregisterLink(href); }, handleClick: function handleClick(e) { var href = this.href, tAnchor = this.tAnchor, title = this.title; tAnchor.handleLinkClick({ href: href, title: typeof title === "string" ? title : void 0, e: e }); }, renderTitle: function renderTitle() { var title = this.title, $scopedSlots = this.$scopedSlots; var titleSlot = $scopedSlots.title; var titleVal; if (typeof title === "string") { titleVal = title; } else if (typeof title === "function") { titleVal = title(this.$createElement); } else if (titleSlot) { titleVal = titleSlot(null); } return titleVal; } }, render: function render(h) { var href = this.href, target = this.target, $scopedSlots = this.$scopedSlots, tAnchor = this.tAnchor; var children = $scopedSlots["default"], titleSlot = $scopedSlots.title; var title = this.renderTitle(); var titleAttr = typeof title === "string" ? title : null; var isActive = tAnchor.active === href; var wrapperClass = _defineProperty__default["default"](_defineProperty__default["default"]({}, "".concat(this.componentName, "__item"), true), this.commonStatusClassName.active, isActive); var titleClass = _defineProperty__default["default"]({}, "".concat(this.componentName, "__item-link"), true); var newLevel = this.$props._level + 1; var h5Tags = []; var anchorItems = []; if (children) { children(null).forEach(function (child) { if (isEmpty.isEmpty(child.componentOptions)) { h5Tags.push(h(child.tag, child.data, child.children)); } else { var _child$componentOptio, _child$componentOptio2, _child$componentOptio3; anchorItems.push(h((_child$componentOptio = child.componentOptions) === null || _child$componentOptio === void 0 ? void 0 : _child$componentOptio.Ctor, { props: _objectSpread(_objectSpread({}, (_child$componentOptio2 = child.componentOptions) === null || _child$componentOptio2 === void 0 ? void 0 : _child$componentOptio2.propsData), {}, { _level: newLevel }) }, child === null || child === void 0 || (_child$componentOptio3 = child.componentOptions) === null || _child$componentOptio3 === void 0 ? void 0 : _child$componentOptio3.children)); } }); } return h("div", { "style": { display: "contents" } }, [h("div", { "class": wrapperClass, "style": { "--level": newLevel } }, [h("a", { "attrs": { "href": href, "title": titleAttr, "target": target }, "class": titleClass, "on": { "click": this.handleClick } }, [titleSlot ? titleSlot(null) : title]), h5Tags]), anchorItems]); } }); exports["default"] = _AnchorItem; //# sourceMappingURL=anchor-item.js.map