tdesign-mobile-vue
Version:
tdesign-mobile-vue
148 lines (144 loc) • 5.89 kB
JavaScript
/**
* tdesign v1.7.0
* (c) 2024 TDesign Group
* @license MIT
*/
import { _ as _defineProperty } from '../_chunks/dep-219bb5a7.mjs';
import { defineComponent, computed, createVNode, resolveComponent } from 'vue';
import { ChevronLeftIcon } from 'tdesign-icons-vue-next';
import config from '../config.mjs';
import props from './props.mjs';
import { usePrefixClass } from '../hooks/useClass.mjs';
import { useTNodeJSX } from '../hooks/tnode.mjs';
import '../_chunks/dep-620d73f7.mjs';
import '../_chunks/dep-b9b8ead5.mjs';
import '../_chunks/dep-91d696ea.mjs';
import '../_chunks/dep-8bf3054e.mjs';
import '../_chunks/dep-3d249f65.mjs';
import '../_chunks/dep-e6c129ab.mjs';
import '../_chunks/dep-6c53a3e4.mjs';
import '../_chunks/dep-d2161895.mjs';
import '../_chunks/dep-89951f45.mjs';
import '../_chunks/dep-08bc7a4c.mjs';
import '../_chunks/dep-6bc862af.mjs';
import '../_chunks/dep-4931819d.mjs';
import '../_chunks/dep-10f4d030.mjs';
import '../_chunks/dep-8ee6f5cd.mjs';
import '../_chunks/dep-e57d46f3.mjs';
import '../_chunks/dep-9b2de386.mjs';
import '../_chunks/dep-4f44985d.mjs';
import '../_chunks/dep-b84be35c.mjs';
import '../_chunks/dep-019e292f.mjs';
import '../_chunks/dep-32364550.mjs';
import '../_chunks/dep-933f3a85.mjs';
import '../_chunks/dep-2bce42ea.mjs';
import '../_chunks/dep-6303c50c.mjs';
import '../_chunks/dep-ac139980.mjs';
import '../_chunks/dep-154c1925.mjs';
import '../_chunks/dep-ba131d9c.mjs';
import '../_chunks/dep-007f294e.mjs';
import '../_common/js/global-config/mobile/default-config.mjs';
import '../_common/js/global-config/mobile/locale/zh_CN.mjs';
import '../_chunks/dep-161f0c44.mjs';
import '../_chunks/dep-5fd0eaa4.mjs';
import '../_chunks/dep-3c59bf72.mjs';
import '../config-provider/type.mjs';
import '../_chunks/dep-60cadef8.mjs';
import '../_chunks/dep-8140c29b.mjs';
import '../_chunks/dep-0d52e58f.mjs';
import '../_chunks/dep-a836a38c.mjs';
import '../_chunks/dep-0ea7bbde.mjs';
import '../_chunks/dep-b437ef0b.mjs';
import '../_chunks/dep-6917b9bc.mjs';
import '../hooks/render-tnode.mjs';
import '../_chunks/dep-40507aac.mjs';
var prefix = config.prefix;
var _Navbar = defineComponent({
name: "".concat(prefix, "-navbar"),
components: {
TChevronLeftIcon: ChevronLeftIcon
},
props: props,
emits: ["left-click", "right-click"],
setup: function setup(props2, _ref) {
var slots = _ref.slots;
var navbarClass = usePrefixClass("navbar");
var renderTNodeJSX = useTNodeJSX();
var animationSuffix = computed(function () {
return props2.animation ? "-animation" : "";
});
var navClass = computed(function () {
return [navbarClass.value, _defineProperty({}, "".concat(navbarClass.value, "--fixed"), props2.fixed), props2.visible ? "".concat(navbarClass.value, "--visible").concat(animationSuffix.value) : "".concat(navbarClass.value, "--hide").concat(animationSuffix.value)];
});
var navStyle = computed(function () {
return "position: ".concat(props2.fixed ? "fixed" : "relative", ";");
});
var handleLeftClick = function handleLeftClick() {
var _props2$onLeftClick;
(_props2$onLeftClick = props2.onLeftClick) === null || _props2$onLeftClick === void 0 || _props2$onLeftClick.call(props2);
};
var handleRightClick = function handleRightClick() {
var _props2$onRightClick;
(_props2$onRightClick = props2.onRightClick) === null || _props2$onRightClick === void 0 || _props2$onRightClick.call(props2);
};
return function () {
var fixed = props2.fixed,
titleMaxLength = props2.titleMaxLength,
title = props2.title,
leftArrow = props2.leftArrow;
var renderRightContent = function renderRightContent() {
var rightContent = renderTNodeJSX("right");
if (!rightContent) {
return null;
}
return createVNode("div", {
"class": "".concat(navbarClass.value, "__right"),
"onClick": handleRightClick
}, [rightContent]);
};
var renderCapsuleContent = function renderCapsuleContent() {
var capsuleContent = renderTNodeJSX("capsule");
if (!capsuleContent) {
return null;
}
return createVNode("div", {
"class": "".concat(navbarClass.value, "__capsule")
}, [capsuleContent]);
};
var renderTitleContent = function renderTitleContent() {
var isStringTitle = typeof title === "string" && !slots.title;
var titleContent = renderTNodeJSX("title");
if (!titleContent) {
return null;
}
if (titleMaxLength != null && title) {
if (titleMaxLength <= 0) {
console.warn("titleMaxLength must be greater than 0");
} else {
titleContent = title.length <= titleMaxLength ? title : "".concat(title.slice(0, titleMaxLength), "...");
}
}
return isStringTitle ? createVNode("span", {
"class": "".concat(navbarClass.value, "__center-title")
}, [titleContent]) : titleContent;
};
return createVNode("div", {
"class": navClass.value,
"style": navStyle.value
}, [fixed && createVNode("div", {
"class": "".concat(navbarClass.value, "____placeholder")
}, null), createVNode("div", {
"class": "".concat(navbarClass.value, "__content")
}, [createVNode("div", {
"class": "".concat(navbarClass.value, "__left"),
"onClick": handleLeftClick
}, [leftArrow && createVNode(resolveComponent("t-chevron-left-icon"), {
"class": "".concat(navbarClass.value, "__left-arrow")
}, null), renderTNodeJSX("left"), renderCapsuleContent()]), createVNode("div", {
"class": "".concat(navbarClass.value, "__center")
}, [renderTitleContent()]), renderRightContent()])]);
};
}
});
export { _Navbar as default };
//# sourceMappingURL=navbar.mjs.map