This commit is contained in:
2022-12-30 16:13:19 +08:00
parent 379a852aee
commit c5d893ba35
43 changed files with 1468 additions and 1107 deletions

View File

@@ -1,5 +1,5 @@
import { w as withInstall } from "../badge/index2.js";
import { defineComponent, useSlots, ref, reactive, computed, provide, shallowRef, watch, nextTick, onMounted, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, unref, createCommentVNode, Fragment, renderList, withModifiers, createBlock, createVNode, renderSlot, h, createTextVNode } from "vue";
import { b as isArrayChildren, w as withInstall } from "../badge/index2.js";
import { defineComponent, useSlots, reactive, ref, computed, provide, shallowRef, watch, nextTick, onMounted, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, unref, createCommentVNode, Fragment, renderList, withModifiers, createBlock, createVNode, renderSlot, h, createTextVNode } from "vue";
import { _ as _sfc_main$2E } from "../checkbox/index2.js";
import { T as TabInjectKey, _ as _sfc_main$1 } from "../tabItem/index2.js";
import { R as RenderFunction } from "../dropdown/index2.js";
@@ -26,15 +26,14 @@ const _sfc_main = defineComponent({
setup(__props, { emit }) {
const props = __props;
const slot = useSlots();
const childrens = ref([]);
const tabMap = reactive(/* @__PURE__ */ new Map());
const childrens = ref([]);
const setItemInstanceBySlot = function(nodes) {
nodes == null ? void 0 : nodes.map((item) => {
let component2 = item.type;
if (item.type.toString() == "Symbol(Fragment)") {
if (isArrayChildren(item, item.children)) {
setItemInstanceBySlot(item.children);
} else {
if (component2.name == _sfc_main$1.name) {
if (item.type.name == _sfc_main$1.name) {
childrens.value.push(item);
}
}
@@ -226,6 +225,20 @@ const _sfc_main = defineComponent({
}
}
};
const horizontalScroll = (e) => {
var _a, _b;
e.preventDefault();
const navSize = getNavSize();
const containerSize = navRef.value[`offset${sizeName.value}`];
const currentOffset = navOffset.value;
const scrollNextSize = (_b = (_a = scrollNextRef.value) == null ? void 0 : _a[`offset${sizeName.value}`]) != null ? _b : 0;
const direction = Math.abs(e.deltaX) >= Math.abs(e.deltaY) ? e.deltaX : e.deltaY;
const distance = 50 * (direction > 0 ? 1 : -1);
const newOffset = Math.max(currentOffset + distance, 0);
if (navSize - currentOffset <= containerSize - scrollNextSize && direction > 0)
return;
navOffset.value = newOffset;
};
const renderTabIcon = (attrs) => {
const tab = attrs.tabData;
if (typeof tab.icon === "function") {
@@ -250,7 +263,7 @@ const _sfc_main = defineComponent({
}
};
useResizeObserver(navRef, update);
watch(tabMap, function() {
watch(tabMap, () => {
childrens.value = [];
setItemInstanceBySlot(slot.default && slot.default());
}, { immediate: true });
@@ -283,6 +296,7 @@ const _sfc_main = defineComponent({
createElementVNode("ul", {
ref_key: "navRef",
ref: navRef,
onWheel: horizontalScroll,
class: normalizeClass([
"layui-tab-title",
props.tabPosition ? `is-${__props.tabPosition}` : ""
@@ -320,7 +334,7 @@ const _sfc_main = defineComponent({
}, null, 8, _hoisted_2)) : createCommentVNode("", true)
], 10, _hoisted_1);
}), 128))
], 6),
], 38),
scrollable.value ? (openBlock(), createElementBlock("span", {
key: 0,
ref_key: "scrollPrevRef",