@veltra/desktop 1.15.5 → 1.15.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/nav/style2.css +1 -1
- package/dist/components/tabs/style2.css +12 -12
- package/dist/components/tabs/tabs-horizontal.js +24 -21
- package/dist/components/tabs/tabs-horizontal.js.map +1 -1
- package/dist/components/tabs/use-tabs-bar.js +4 -38
- package/dist/components/tabs/use-tabs-bar.js.map +1 -1
- package/package.json +1 -1
- package/src/components/nav/style.scss +3 -1
- package/src/components/tabs/style.scss +20 -21
- package/src/components/tabs/tabs-horizontal.vue +2 -2
- package/src/components/tabs/use-tabs-bar.ts +3 -54
- package/src/components/tabs/__test__/use-tabs-bar.test.ts +0 -143
|
@@ -81,7 +81,6 @@
|
|
|
81
81
|
display: inline-flex;
|
|
82
82
|
flex-wrap: nowrap;
|
|
83
83
|
flex-shrink: 0;
|
|
84
|
-
position: relative;
|
|
85
84
|
width: max-content;
|
|
86
85
|
margin: 0;
|
|
87
86
|
padding: 0;
|
|
@@ -234,26 +233,27 @@
|
|
|
234
233
|
.u-tabs-bar.is-rounded .u-tabs-bar__nav {
|
|
235
234
|
border-radius: 9999px;
|
|
236
235
|
}
|
|
237
|
-
.u-tabs-bar.is-rounded .u-tabs-bar__indicator {
|
|
238
|
-
border-radius: 9999px;
|
|
239
|
-
}
|
|
240
236
|
.u-tabs-bar--horizontal.is-rounded {
|
|
241
237
|
border-radius: 9999px;
|
|
242
238
|
}
|
|
243
|
-
.u-tabs-bar--horizontal .u-tabs-
|
|
239
|
+
.u-tabs-bar--horizontal .u-tabs-bar__item {
|
|
240
|
+
isolation: isolate;
|
|
241
|
+
}
|
|
242
|
+
.u-tabs-bar--horizontal .u-tabs-bar__item .u-tabs-bar__indicator {
|
|
244
243
|
position: absolute;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
z-index: 0;
|
|
244
|
+
inset: 0;
|
|
245
|
+
z-index: -1;
|
|
248
246
|
pointer-events: none;
|
|
249
|
-
border-radius:
|
|
247
|
+
border-radius: inherit;
|
|
250
248
|
background-color: var(--u-tabs-active-bg, var(--u-bg-color-top));
|
|
251
249
|
box-shadow: var(--u-shadow-sm);
|
|
252
|
-
|
|
253
|
-
.
|
|
254
|
-
z-index: 1;
|
|
250
|
+
opacity: 0;
|
|
251
|
+
transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1);
|
|
255
252
|
}
|
|
256
253
|
.u-tabs-bar--horizontal .u-tabs-bar__item.is-active {
|
|
257
254
|
background-color: transparent;
|
|
258
255
|
box-shadow: none;
|
|
259
256
|
}
|
|
257
|
+
.u-tabs-bar--horizontal .u-tabs-bar__item.is-active .u-tabs-bar__indicator {
|
|
258
|
+
opacity: 1;
|
|
259
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icon/icon.js";
|
|
2
2
|
import { useTabsBar } from "./use-tabs-bar.js";
|
|
3
|
-
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, mergeModels, mergeProps, normalizeClass,
|
|
3
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, mergeModels, mergeProps, normalizeClass, openBlock, renderList, renderSlot, shallowRef, toDisplayString, unref, useModel, vShow, withCtx, withDirectives, withModifiers } from "vue";
|
|
4
4
|
import { useFallbackProps } from "@veltra/compositions";
|
|
5
5
|
import { bem } from "@veltra/utils";
|
|
6
6
|
import { ArrowLeft, ArrowRight, Close } from "@veltra/icons/normal";
|
|
@@ -47,7 +47,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
47
47
|
const viewportRef = shallowRef();
|
|
48
48
|
const listRef = shallowRef();
|
|
49
49
|
const itemsRef = computed(() => props.items);
|
|
50
|
-
const { showNav, canPrev, canNext, scrollByStep
|
|
50
|
+
const { showNav, canPrev, canNext, scrollByStep } = useTabsBar({
|
|
51
51
|
viewportRef,
|
|
52
52
|
listRef,
|
|
53
53
|
items: itemsRef,
|
|
@@ -92,11 +92,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
92
92
|
ref_key: "listRef",
|
|
93
93
|
ref: listRef,
|
|
94
94
|
class: normalizeClass(unref(cls).e("list"))
|
|
95
|
-
}, [
|
|
96
|
-
class: normalizeClass(unref(cls).e("indicator")),
|
|
97
|
-
style: normalizeStyle(unref(indicatorStyle)),
|
|
98
|
-
"aria-hidden": "true"
|
|
99
|
-
}, null, 6), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, index) => {
|
|
95
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, index) => {
|
|
100
96
|
return openBlock(), createElementBlock("button", {
|
|
101
97
|
type: "button",
|
|
102
98
|
role: "tab",
|
|
@@ -107,20 +103,27 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
107
103
|
unref(bem).is("disabled", item.disabled === true)
|
|
108
104
|
]),
|
|
109
105
|
onClick: withModifiers(($event) => handleClick(item, index), ["stop"])
|
|
110
|
-
}, [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
106
|
+
}, [
|
|
107
|
+
createElementVNode("span", {
|
|
108
|
+
class: normalizeClass(unref(cls).e("indicator")),
|
|
109
|
+
"aria-hidden": "true"
|
|
110
|
+
}, null, 2),
|
|
111
|
+
renderSlot(_ctx.$slots, "default", mergeProps({ ref_for: true }, {
|
|
112
|
+
item,
|
|
113
|
+
index
|
|
114
|
+
}), () => [createElementVNode("span", { class: normalizeClass(unref(cls).e("item-label")) }, toDisplayString(item.name ?? item.key), 3)]),
|
|
115
|
+
isItemClosable(item) ? (openBlock(), createElementBlock("span", {
|
|
116
|
+
key: 0,
|
|
117
|
+
role: "button",
|
|
118
|
+
tabindex: "0",
|
|
119
|
+
class: normalizeClass(unref(cls).e("close")),
|
|
120
|
+
"aria-label": `close ${item.name ?? item.key}`,
|
|
121
|
+
onClick: withModifiers(($event) => handleClose(item, index), ["stop"])
|
|
122
|
+
}, [createVNode(unref(_sfc_main$1), null, {
|
|
123
|
+
default: withCtx(() => [createVNode(unref(Close))]),
|
|
124
|
+
_: 1
|
|
125
|
+
})], 10, _hoisted_3)) : createCommentVNode("v-if", true)
|
|
126
|
+
], 10, _hoisted_2);
|
|
124
127
|
}), 128))], 2)], 2),
|
|
125
128
|
withDirectives(createElementVNode("button", {
|
|
126
129
|
type: "button",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs-horizontal.js","names":["_useModel","_openBlock","_createElementBlock","_normalizeClass","_unref","_withDirectives","_createElementVNode","_createVNode","UIcon","_withCtx","_vShow","
|
|
1
|
+
{"version":3,"file":"tabs-horizontal.js","names":["_useModel","_openBlock","_createElementBlock","_normalizeClass","_unref","_withDirectives","_createElementVNode","_createVNode","UIcon","_withCtx","_vShow","_Fragment","_renderList","_withModifiers","_renderSlot","_mergeProps","_toDisplayString","_createCommentVNode"],"sources":["../../../src/components/tabs/tabs-horizontal.vue"],"sourcesContent":["<template>\n <div\n :class=\"[\n cls.b,\n cls.m('horizontal'),\n cls.m(position),\n cls.m(size),\n bem.is('block', block),\n bem.is('rounded', rounded)\n ]\"\n >\n <button\n v-show=\"showNav\"\n type=\"button\"\n :class=\"[cls.e('nav'), cls.em('nav', 'prev')]\"\n :disabled=\"!canPrev\"\n @click=\"scrollByStep(-1)\"\n >\n <u-icon> <ArrowLeft /> </u-icon>\n </button>\n\n <div ref=\"viewportRef\" :class=\"cls.e('viewport')\">\n <div ref=\"listRef\" :class=\"cls.e('list')\">\n <button\n type=\"button\"\n role=\"tab\"\n v-for=\"(item, index) in items\"\n :key=\"item.key\"\n :class=\"[\n cls.e('item'),\n bem.is('active', model === item.key),\n bem.is('disabled', item.disabled === true)\n ]\"\n @click.stop=\"handleClick(item, index)\"\n >\n <span :class=\"cls.e('indicator')\" aria-hidden=\"true\" />\n <slot v-bind=\"{ item, index }\">\n <span :class=\"cls.e('item-label')\">{{ item.name ?? item.key }}</span>\n </slot>\n\n <span\n v-if=\"isItemClosable(item)\"\n role=\"button\"\n tabindex=\"0\"\n :class=\"cls.e('close')\"\n :aria-label=\"`close ${item.name ?? item.key}`\"\n @click.stop=\"handleClose(item, index)\"\n >\n <u-icon>\n <Close />\n </u-icon>\n </span>\n </button>\n </div>\n </div>\n\n <button\n v-show=\"showNav\"\n type=\"button\"\n :class=\"[cls.e('nav'), cls.em('nav', 'next')]\"\n :disabled=\"!canNext\"\n @click=\"scrollByStep(1)\"\n >\n <u-icon> <ArrowRight /> </u-icon>\n </button>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { useFallbackProps } from '@veltra/compositions'\nimport { ArrowLeft, ArrowRight, Close } from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { computed, shallowRef } from 'vue'\n\nimport type { ComponentSize, TabItem, TabsHorizontalEmits, TabsHorizontalProps } from '../../types'\nimport { UIcon } from '../icon'\nimport { useTabsBar } from './use-tabs-bar'\n\ndefineOptions({ name: 'UTabsHorizontal' })\n\nconst props = withDefaults(defineProps<TabsHorizontalProps>(), {\n position: 'top',\n closable: false,\n block: false,\n rounded: false\n})\n\nconst emit = defineEmits<TabsHorizontalEmits>()\n\ndefineSlots<{ default: (props: { item: TabItem; index: number }) => any }>()\n\nconst { size } = useFallbackProps([props], { size: 'default' as ComponentSize })\n\nconst cls = bem('tabs-bar')\n\nconst model = defineModel<string>()\n\nconst viewportRef = shallowRef<HTMLElement>()\nconst listRef = shallowRef<HTMLElement>()\n\nconst itemsRef = computed(() => props.items)\n\nconst { showNav, canPrev, canNext, scrollByStep } = useTabsBar({\n viewportRef,\n listRef,\n items: itemsRef,\n model\n})\n\nconst isItemClosable = (item: TabItem) => {\n if (item.disabled) return false\n return item.closable ?? props.closable\n}\n\nconst handleClick = (item: TabItem, index: number) => {\n if (item.disabled) return\n model.value = item.key\n emit('click', item, index)\n}\n\nconst handleClose = (item: TabItem, index: number) => {\n if (item.disabled) return\n emit('close', item, index)\n}\n</script>\n"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nextTick, onBeforeUnmount, onMounted, shallowRef, watch } from "vue";
|
|
2
2
|
import { useResizeObserver } from "@veltra/compositions";
|
|
3
3
|
import { applyWheelHorizontalScroll, computeOverflowNavState, scrollElementIntoView, scrollViewportByStep } from "@veltra/utils";
|
|
4
4
|
// src/components/tabs/use-tabs-bar.ts
|
|
@@ -38,31 +38,6 @@ function useTabsBar(options) {
|
|
|
38
38
|
if (!el) return;
|
|
39
39
|
scrollElementIntoView(vp, el);
|
|
40
40
|
};
|
|
41
|
-
const indicatorX = shallowRef(0);
|
|
42
|
-
const indicatorY = shallowRef(0);
|
|
43
|
-
const indicatorW = shallowRef(0);
|
|
44
|
-
const indicatorH = shallowRef(0);
|
|
45
|
-
const indicatorOn = shallowRef(false);
|
|
46
|
-
const indicatorStyle = computed(() => ({
|
|
47
|
-
width: `${indicatorW.value}px`,
|
|
48
|
-
height: `${indicatorH.value}px`,
|
|
49
|
-
transform: `translate(${indicatorX.value}px, ${indicatorY.value}px)`,
|
|
50
|
-
opacity: indicatorOn.value ? "1" : "0"
|
|
51
|
-
}));
|
|
52
|
-
function measureIndicator() {
|
|
53
|
-
const list = listRef.value;
|
|
54
|
-
if (!list) return;
|
|
55
|
-
const el = list.querySelector("[role=\"tab\"].is-active");
|
|
56
|
-
if (!el) {
|
|
57
|
-
indicatorOn.value = false;
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
indicatorX.value = el.offsetLeft;
|
|
61
|
-
indicatorY.value = el.offsetTop;
|
|
62
|
-
indicatorW.value = el.offsetWidth;
|
|
63
|
-
indicatorH.value = el.offsetHeight;
|
|
64
|
-
indicatorOn.value = true;
|
|
65
|
-
}
|
|
66
41
|
/** 鼠标滚轮(纵向)驱动水平滚动;触控板横滑(已有 deltaX)不拦截 */
|
|
67
42
|
const handleWheel = (e) => {
|
|
68
43
|
const vp = viewportRef.value;
|
|
@@ -71,21 +46,16 @@ function useTabsBar(options) {
|
|
|
71
46
|
};
|
|
72
47
|
useResizeObserver({
|
|
73
48
|
targets: [viewportRef, listRef],
|
|
74
|
-
onResize: () =>
|
|
75
|
-
updateNavState();
|
|
76
|
-
measureIndicator();
|
|
77
|
-
}
|
|
49
|
+
onResize: () => updateNavState()
|
|
78
50
|
});
|
|
79
51
|
watch(model, async () => {
|
|
80
52
|
await nextTick();
|
|
81
53
|
ensureActiveVisible();
|
|
82
|
-
measureIndicator();
|
|
83
54
|
});
|
|
84
55
|
watch(items, async () => {
|
|
85
56
|
await nextTick();
|
|
86
57
|
updateNavState();
|
|
87
58
|
ensureActiveVisible();
|
|
88
|
-
measureIndicator();
|
|
89
59
|
}, { deep: false });
|
|
90
60
|
onMounted(() => {
|
|
91
61
|
const vp = viewportRef.value;
|
|
@@ -93,10 +63,7 @@ function useTabsBar(options) {
|
|
|
93
63
|
vp.addEventListener("wheel", handleWheel, { passive: false });
|
|
94
64
|
vp.addEventListener("scroll", updateNavState, { passive: true });
|
|
95
65
|
updateNavState();
|
|
96
|
-
nextTick(
|
|
97
|
-
ensureActiveVisible();
|
|
98
|
-
measureIndicator();
|
|
99
|
-
});
|
|
66
|
+
nextTick(ensureActiveVisible);
|
|
100
67
|
});
|
|
101
68
|
onBeforeUnmount(() => {
|
|
102
69
|
const vp = viewportRef.value;
|
|
@@ -110,8 +77,7 @@ function useTabsBar(options) {
|
|
|
110
77
|
canNext,
|
|
111
78
|
updateNavState,
|
|
112
79
|
scrollByStep,
|
|
113
|
-
ensureActiveVisible
|
|
114
|
-
indicatorStyle
|
|
80
|
+
ensureActiveVisible
|
|
115
81
|
};
|
|
116
82
|
}
|
|
117
83
|
export { useTabsBar };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tabs-bar.js","names":[],"sources":["../../../src/components/tabs/use-tabs-bar.ts"],"sourcesContent":["import { useResizeObserver } from '@veltra/compositions'\nimport {\n applyWheelHorizontalScroll,\n computeOverflowNavState,\n scrollElementIntoView,\n scrollViewportByStep\n} from '@veltra/utils'\nimport {\n type
|
|
1
|
+
{"version":3,"file":"use-tabs-bar.js","names":[],"sources":["../../../src/components/tabs/use-tabs-bar.ts"],"sourcesContent":["import { useResizeObserver } from '@veltra/compositions'\nimport {\n applyWheelHorizontalScroll,\n computeOverflowNavState,\n scrollElementIntoView,\n scrollViewportByStep\n} from '@veltra/utils'\nimport {\n type ModelRef,\n type Ref,\n type ShallowRef,\n nextTick,\n onBeforeUnmount,\n onMounted,\n shallowRef,\n watch\n} from 'vue'\n\nimport type { TabItem } from '../../types'\n\ninterface UseTabsBarOptions {\n viewportRef: ShallowRef<HTMLElement | undefined>\n listRef: ShallowRef<HTMLElement | undefined>\n items: Ref<TabItem[]>\n model: ModelRef<string | undefined>\n}\n\n/**\n * 水平标签栏的溢出滚动逻辑(滚动几何/滚轮转横滚/元素滚入视野共享\n * @veltra/utils overflow-nav,见 #17;此处保留 useResizeObserver 与 watch 差异):\n * - 计算 nav 按钮显隐与可用状态\n * - 提供按步滚动与活动标签自动滚入视野的方法\n * - 绑定 wheel / scroll / resize 事件\n */\nexport function useTabsBar(options: UseTabsBarOptions) {\n const { viewportRef, listRef, items, model } = options\n\n const showNav = shallowRef(false)\n const canPrev = shallowRef(false)\n const canNext = shallowRef(false)\n\n /** 依据 viewport 与内容尺寸推导滚动按钮可用状态 */\n const updateNavState = () => {\n const vp = viewportRef.value\n if (!vp) return\n const state = computeOverflowNavState(vp)\n showNav.value = state.overflowing\n canPrev.value = state.canPrev\n canNext.value = state.canNext\n }\n\n /** 箭头按钮:按视口宽度 80% 的步长平滑滚动 */\n const scrollByStep = (dir: 1 | -1) => {\n const vp = viewportRef.value\n if (!vp) return\n scrollViewportByStep(vp, dir)\n }\n\n /** 活动标签自动滚入视野 */\n const ensureActiveVisible = () => {\n const vp = viewportRef.value\n const list = listRef.value\n if (!vp || !list) return\n const el = list.querySelector<HTMLElement>('[role=\"tab\"].is-active')\n if (!el) return\n scrollElementIntoView(vp, el)\n }\n\n /** 鼠标滚轮(纵向)驱动水平滚动;触控板横滑(已有 deltaX)不拦截 */\n const handleWheel = (e: WheelEvent) => {\n const vp = viewportRef.value\n if (!vp) return\n applyWheelHorizontalScroll(e, vp, showNav.value)\n }\n\n useResizeObserver({ targets: [viewportRef, listRef], onResize: () => updateNavState() })\n\n watch(model, async () => {\n await nextTick()\n ensureActiveVisible()\n })\n\n watch(\n items,\n async () => {\n await nextTick()\n updateNavState()\n ensureActiveVisible()\n },\n { deep: false }\n )\n\n onMounted(() => {\n const vp = viewportRef.value\n if (!vp) return\n vp.addEventListener('wheel', handleWheel, { passive: false })\n vp.addEventListener('scroll', updateNavState, { passive: true })\n updateNavState()\n nextTick(ensureActiveVisible)\n })\n\n onBeforeUnmount(() => {\n const vp = viewportRef.value\n if (!vp) return\n vp.removeEventListener('wheel', handleWheel)\n vp.removeEventListener('scroll', updateNavState)\n })\n\n return { showNav, canPrev, canNext, updateNavState, scrollByStep, ensureActiveVisible }\n}\n"],"mappings":";;;;;;;;;;;AAkCA,SAAgB,WAAW,SAA4B;CACrD,MAAM,EAAE,aAAa,SAAS,OAAO,UAAU;CAE/C,MAAM,UAAU,WAAW,KAAK;CAChC,MAAM,UAAU,WAAW,KAAK;CAChC,MAAM,UAAU,WAAW,KAAK;;CAGhC,MAAM,uBAAuB;EAC3B,MAAM,KAAK,YAAY;EACvB,IAAI,CAAC,IAAI;EACT,MAAM,QAAQ,wBAAwB,EAAE;EACxC,QAAQ,QAAQ,MAAM;EACtB,QAAQ,QAAQ,MAAM;EACtB,QAAQ,QAAQ,MAAM;CACxB;;CAGA,MAAM,gBAAgB,QAAgB;EACpC,MAAM,KAAK,YAAY;EACvB,IAAI,CAAC,IAAI;EACT,qBAAqB,IAAI,GAAG;CAC9B;;CAGA,MAAM,4BAA4B;EAChC,MAAM,KAAK,YAAY;EACvB,MAAM,OAAO,QAAQ;EACrB,IAAI,CAAC,MAAM,CAAC,MAAM;EAClB,MAAM,KAAK,KAAK,cAA2B,0BAAwB;EACnE,IAAI,CAAC,IAAI;EACT,sBAAsB,IAAI,EAAE;CAC9B;;CAGA,MAAM,eAAe,MAAkB;EACrC,MAAM,KAAK,YAAY;EACvB,IAAI,CAAC,IAAI;EACT,2BAA2B,GAAG,IAAI,QAAQ,KAAK;CACjD;CAEA,kBAAkB;EAAE,SAAS,CAAC,aAAa,OAAO;EAAG,gBAAgB,eAAe;CAAE,CAAC;CAEvF,MAAM,OAAO,YAAY;EACvB,MAAM,SAAS;EACf,oBAAoB;CACtB,CAAC;CAED,MACE,OACA,YAAY;EACV,MAAM,SAAS;EACf,eAAe;EACf,oBAAoB;CACtB,GACA,EAAE,MAAM,MAAM,CAChB;CAEA,gBAAgB;EACd,MAAM,KAAK,YAAY;EACvB,IAAI,CAAC,IAAI;EACT,GAAG,iBAAiB,SAAS,aAAa,EAAE,SAAS,MAAM,CAAC;EAC5D,GAAG,iBAAiB,UAAU,gBAAgB,EAAE,SAAS,KAAK,CAAC;EAC/D,eAAe;EACf,SAAS,mBAAmB;CAC9B,CAAC;CAED,sBAAsB;EACpB,MAAM,KAAK,YAAY;EACvB,IAAI,CAAC,IAAI;EACT,GAAG,oBAAoB,SAAS,WAAW;EAC3C,GAAG,oBAAoB,UAAU,cAAc;CACjD,CAAC;CAED,OAAO;EAAE;EAAS;EAAS;EAAS;EAAgB;EAAc;CAAoB;AACxF"}
|
package/package.json
CHANGED
|
@@ -184,7 +184,9 @@ $collapsed-nav: collapsed-nav;
|
|
|
184
184
|
|
|
185
185
|
@include m.is(expanded) {
|
|
186
186
|
transform: rotate(90deg);
|
|
187
|
-
|
|
187
|
+
// 强调色取 nav 变体 token:深侧栏(浅色主题)底色近黑,全局 text-color/title
|
|
188
|
+
// 会让图标变黑失去对比度;--u-nav-strong-color 各变体下均与展开行强调色一致
|
|
189
|
+
color: var(--u-nav-strong-color);
|
|
188
190
|
transition:
|
|
189
191
|
transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
|
|
190
192
|
color 0.18s ease;
|
|
@@ -90,9 +90,6 @@ $active-shadow: fn.use-var(shadow, sm);
|
|
|
90
90
|
display: inline-flex;
|
|
91
91
|
flex-wrap: nowrap;
|
|
92
92
|
flex-shrink: 0;
|
|
93
|
-
// 定位是测量基准:__item 的 offsetLeft/offsetWidth 以 __list 为 offsetParent
|
|
94
|
-
// (useTabsBar 的指示器几何测量依赖这一约束)
|
|
95
|
-
position: relative;
|
|
96
93
|
width: max-content;
|
|
97
94
|
margin: 0;
|
|
98
95
|
padding: 0;
|
|
@@ -286,10 +283,6 @@ $active-shadow: fn.use-var(shadow, sm);
|
|
|
286
283
|
@include m.bem(tabs-bar, nav) {
|
|
287
284
|
border-radius: 9999px;
|
|
288
285
|
}
|
|
289
|
-
|
|
290
|
-
@include m.bem(tabs-bar, indicator) {
|
|
291
|
-
border-radius: 9999px;
|
|
292
|
-
}
|
|
293
286
|
}
|
|
294
287
|
|
|
295
288
|
@include m.m(horizontal) {
|
|
@@ -298,26 +291,32 @@ $active-shadow: fn.use-var(shadow, sm);
|
|
|
298
291
|
}
|
|
299
292
|
}
|
|
300
293
|
|
|
294
|
+
// 指示器内嵌在 __item 中:宽度随 item(含 hover 关闭按钮展开)由布局天然同步,
|
|
295
|
+
// 无需 JS 测量重摆;激活切换用 opacity 交叉淡入淡出,节奏与 __item 色彩过渡一致
|
|
301
296
|
@include m.m(horizontal) {
|
|
302
|
-
@include m.bem(tabs-bar, indicator) {
|
|
303
|
-
position: absolute;
|
|
304
|
-
left: 0;
|
|
305
|
-
top: 0;
|
|
306
|
-
z-index: 0;
|
|
307
|
-
pointer-events: none;
|
|
308
|
-
border-radius: $item-radius;
|
|
309
|
-
background-color: $active-bg;
|
|
310
|
-
box-shadow: $active-shadow;
|
|
311
|
-
// 不做滑动过渡:hover 时关闭按钮展开(width/margin 布局动画)会与固定时长的
|
|
312
|
-
// 位移过渡互相打断,观感生硬;切换时测量后直接就位
|
|
313
|
-
}
|
|
314
|
-
|
|
315
297
|
@include m.bem(tabs-bar, item) {
|
|
316
|
-
z-index: 1
|
|
298
|
+
// 建立 stacking context:z-index: -1 的指示器衬在文字之下、容器底色之上
|
|
299
|
+
isolation: isolate;
|
|
300
|
+
|
|
301
|
+
@include m.bem(tabs-bar, indicator) {
|
|
302
|
+
position: absolute;
|
|
303
|
+
inset: 0;
|
|
304
|
+
z-index: -1;
|
|
305
|
+
pointer-events: none;
|
|
306
|
+
border-radius: inherit;
|
|
307
|
+
background-color: $active-bg;
|
|
308
|
+
box-shadow: $active-shadow;
|
|
309
|
+
opacity: 0;
|
|
310
|
+
transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1);
|
|
311
|
+
}
|
|
317
312
|
|
|
318
313
|
@include m.is(active) {
|
|
319
314
|
background-color: transparent;
|
|
320
315
|
box-shadow: none;
|
|
316
|
+
|
|
317
|
+
@include m.bem(tabs-bar, indicator) {
|
|
318
|
+
opacity: 1;
|
|
319
|
+
}
|
|
321
320
|
}
|
|
322
321
|
}
|
|
323
322
|
}
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
|
|
22
22
|
<div ref="viewportRef" :class="cls.e('viewport')">
|
|
23
23
|
<div ref="listRef" :class="cls.e('list')">
|
|
24
|
-
<div :class="cls.e('indicator')" :style="indicatorStyle" aria-hidden="true" />
|
|
25
24
|
<button
|
|
26
25
|
type="button"
|
|
27
26
|
role="tab"
|
|
@@ -34,6 +33,7 @@
|
|
|
34
33
|
]"
|
|
35
34
|
@click.stop="handleClick(item, index)"
|
|
36
35
|
>
|
|
36
|
+
<span :class="cls.e('indicator')" aria-hidden="true" />
|
|
37
37
|
<slot v-bind="{ item, index }">
|
|
38
38
|
<span :class="cls.e('item-label')">{{ item.name ?? item.key }}</span>
|
|
39
39
|
</slot>
|
|
@@ -100,7 +100,7 @@ const listRef = shallowRef<HTMLElement>()
|
|
|
100
100
|
|
|
101
101
|
const itemsRef = computed(() => props.items)
|
|
102
102
|
|
|
103
|
-
const { showNav, canPrev, canNext, scrollByStep
|
|
103
|
+
const { showNav, canPrev, canNext, scrollByStep } = useTabsBar({
|
|
104
104
|
viewportRef,
|
|
105
105
|
listRef,
|
|
106
106
|
items: itemsRef,
|
|
@@ -6,11 +6,9 @@ import {
|
|
|
6
6
|
scrollViewportByStep
|
|
7
7
|
} from '@veltra/utils'
|
|
8
8
|
import {
|
|
9
|
-
type CSSProperties,
|
|
10
9
|
type ModelRef,
|
|
11
10
|
type Ref,
|
|
12
11
|
type ShallowRef,
|
|
13
|
-
computed,
|
|
14
12
|
nextTick,
|
|
15
13
|
onBeforeUnmount,
|
|
16
14
|
onMounted,
|
|
@@ -68,36 +66,6 @@ export function useTabsBar(options: UseTabsBarOptions) {
|
|
|
68
66
|
scrollElementIntoView(vp, el)
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
const indicatorX = shallowRef(0)
|
|
72
|
-
const indicatorY = shallowRef(0)
|
|
73
|
-
const indicatorW = shallowRef(0)
|
|
74
|
-
const indicatorH = shallowRef(0)
|
|
75
|
-
const indicatorOn = shallowRef(false)
|
|
76
|
-
|
|
77
|
-
const indicatorStyle = computed<CSSProperties>(() => ({
|
|
78
|
-
width: `${indicatorW.value}px`,
|
|
79
|
-
height: `${indicatorH.value}px`,
|
|
80
|
-
transform: `translate(${indicatorX.value}px, ${indicatorY.value}px)`,
|
|
81
|
-
opacity: indicatorOn.value ? '1' : '0'
|
|
82
|
-
}))
|
|
83
|
-
|
|
84
|
-
function measureIndicator() {
|
|
85
|
-
const list = listRef.value
|
|
86
|
-
if (!list) return
|
|
87
|
-
const el = list.querySelector<HTMLElement>('[role="tab"].is-active')
|
|
88
|
-
if (!el) {
|
|
89
|
-
indicatorOn.value = false
|
|
90
|
-
return
|
|
91
|
-
}
|
|
92
|
-
// offset 几何不含 transform:点击瞬间的 :active 按压缩放(scale 0.97)
|
|
93
|
-
// 不会混进测量值;指示器不带过渡、测量后直接就位
|
|
94
|
-
indicatorX.value = el.offsetLeft
|
|
95
|
-
indicatorY.value = el.offsetTop
|
|
96
|
-
indicatorW.value = el.offsetWidth
|
|
97
|
-
indicatorH.value = el.offsetHeight
|
|
98
|
-
indicatorOn.value = true
|
|
99
|
-
}
|
|
100
|
-
|
|
101
69
|
/** 鼠标滚轮(纵向)驱动水平滚动;触控板横滑(已有 deltaX)不拦截 */
|
|
102
70
|
const handleWheel = (e: WheelEvent) => {
|
|
103
71
|
const vp = viewportRef.value
|
|
@@ -105,18 +73,11 @@ export function useTabsBar(options: UseTabsBarOptions) {
|
|
|
105
73
|
applyWheelHorizontalScroll(e, vp, showNav.value)
|
|
106
74
|
}
|
|
107
75
|
|
|
108
|
-
useResizeObserver({
|
|
109
|
-
targets: [viewportRef, listRef],
|
|
110
|
-
onResize: () => {
|
|
111
|
-
updateNavState()
|
|
112
|
-
measureIndicator()
|
|
113
|
-
}
|
|
114
|
-
})
|
|
76
|
+
useResizeObserver({ targets: [viewportRef, listRef], onResize: () => updateNavState() })
|
|
115
77
|
|
|
116
78
|
watch(model, async () => {
|
|
117
79
|
await nextTick()
|
|
118
80
|
ensureActiveVisible()
|
|
119
|
-
measureIndicator()
|
|
120
81
|
})
|
|
121
82
|
|
|
122
83
|
watch(
|
|
@@ -125,7 +86,6 @@ export function useTabsBar(options: UseTabsBarOptions) {
|
|
|
125
86
|
await nextTick()
|
|
126
87
|
updateNavState()
|
|
127
88
|
ensureActiveVisible()
|
|
128
|
-
measureIndicator()
|
|
129
89
|
},
|
|
130
90
|
{ deep: false }
|
|
131
91
|
)
|
|
@@ -136,10 +96,7 @@ export function useTabsBar(options: UseTabsBarOptions) {
|
|
|
136
96
|
vp.addEventListener('wheel', handleWheel, { passive: false })
|
|
137
97
|
vp.addEventListener('scroll', updateNavState, { passive: true })
|
|
138
98
|
updateNavState()
|
|
139
|
-
nextTick(
|
|
140
|
-
ensureActiveVisible()
|
|
141
|
-
measureIndicator()
|
|
142
|
-
})
|
|
99
|
+
nextTick(ensureActiveVisible)
|
|
143
100
|
})
|
|
144
101
|
|
|
145
102
|
onBeforeUnmount(() => {
|
|
@@ -149,13 +106,5 @@ export function useTabsBar(options: UseTabsBarOptions) {
|
|
|
149
106
|
vp.removeEventListener('scroll', updateNavState)
|
|
150
107
|
})
|
|
151
108
|
|
|
152
|
-
return {
|
|
153
|
-
showNav,
|
|
154
|
-
canPrev,
|
|
155
|
-
canNext,
|
|
156
|
-
updateNavState,
|
|
157
|
-
scrollByStep,
|
|
158
|
-
ensureActiveVisible,
|
|
159
|
-
indicatorStyle
|
|
160
|
-
}
|
|
109
|
+
return { showNav, canPrev, canNext, updateNavState, scrollByStep, ensureActiveVisible }
|
|
161
110
|
}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// @vitest-environment happy-dom
|
|
2
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'
|
|
3
|
-
import { createApp, defineComponent, h, nextTick, shallowRef } from 'vue'
|
|
4
|
-
|
|
5
|
-
import { useTabsBar } from '../use-tabs-bar'
|
|
6
|
-
|
|
7
|
-
/** 激活项几何注入容器:offset 几何是测量输入,getBoundingClientRect 模拟按压缩放中的视觉矩形 */
|
|
8
|
-
function createFakeDom() {
|
|
9
|
-
const state: {
|
|
10
|
-
active:
|
|
11
|
-
| (Pick<HTMLElement, 'offsetLeft' | 'offsetTop' | 'offsetWidth' | 'offsetHeight'> & {
|
|
12
|
-
getBoundingClientRect: () => DOMRect
|
|
13
|
-
})
|
|
14
|
-
| null
|
|
15
|
-
} = { active: null }
|
|
16
|
-
|
|
17
|
-
const activeRect = () => {
|
|
18
|
-
const { offsetWidth: w, offsetHeight: hgt, offsetLeft: l, offsetTop: t } = state.active!
|
|
19
|
-
// 视觉矩形带 scale(0.97):按压中的 getBoundingClientRect 比布局几何小
|
|
20
|
-
return {
|
|
21
|
-
left: l,
|
|
22
|
-
top: t,
|
|
23
|
-
width: w * 0.97,
|
|
24
|
-
height: hgt * 0.97,
|
|
25
|
-
right: l + w * 0.97,
|
|
26
|
-
toJSON: () => ({})
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const setActive = (
|
|
31
|
-
geo: Pick<HTMLElement, 'offsetLeft' | 'offsetTop' | 'offsetWidth' | 'offsetHeight'> | null
|
|
32
|
-
) => {
|
|
33
|
-
state.active = geo ? { ...geo, getBoundingClientRect: activeRect } : null
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const list = {
|
|
37
|
-
querySelector: (selector: string) => (selector.includes('is-active') ? state.active : null)
|
|
38
|
-
}
|
|
39
|
-
const viewport = {
|
|
40
|
-
addEventListener: vi.fn(),
|
|
41
|
-
removeEventListener: vi.fn(),
|
|
42
|
-
getBoundingClientRect: () => ({ left: 0, right: 100, top: 0, bottom: 28 }),
|
|
43
|
-
scrollTo: vi.fn(),
|
|
44
|
-
scrollWidth: 0,
|
|
45
|
-
clientWidth: 0,
|
|
46
|
-
scrollLeft: 0
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
setActive,
|
|
51
|
-
viewportRef: shallowRef(viewport as unknown as HTMLElement),
|
|
52
|
-
listRef: shallowRef(list as unknown as HTMLElement)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** 挂载宿主组件拿到 useTabsBar 返回值(需要 onMounted 等生命周期上下文) */
|
|
57
|
-
function setupTabsBar(dom: ReturnType<typeof createFakeDom>) {
|
|
58
|
-
const items = shallowRef([{ key: 'a' }, { key: 'b' }])
|
|
59
|
-
const model = shallowRef<string | undefined>('a')
|
|
60
|
-
let api!: ReturnType<typeof useTabsBar>
|
|
61
|
-
|
|
62
|
-
const host = defineComponent({
|
|
63
|
-
setup() {
|
|
64
|
-
api = useTabsBar({ viewportRef: dom.viewportRef, listRef: dom.listRef, items, model })
|
|
65
|
-
return () => h('div')
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
createApp(host).mount(document.createElement('div'))
|
|
69
|
-
|
|
70
|
-
return { api, model }
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
describe('useTabsBar 指示器', () => {
|
|
74
|
-
beforeEach(() => {
|
|
75
|
-
vi.stubGlobal(
|
|
76
|
-
'ResizeObserver',
|
|
77
|
-
class {
|
|
78
|
-
observe() {}
|
|
79
|
-
unobserve() {}
|
|
80
|
-
disconnect() {}
|
|
81
|
-
}
|
|
82
|
-
)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
afterEach(() => {
|
|
86
|
-
vi.unstubAllGlobals()
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
it('按 offset 几何落位,不被 :active 按压缩放污染', async () => {
|
|
90
|
-
const dom = createFakeDom()
|
|
91
|
-
dom.setActive({ offsetLeft: 40, offsetTop: 0, offsetWidth: 100, offsetHeight: 28 })
|
|
92
|
-
const { api } = setupTabsBar(dom)
|
|
93
|
-
await nextTick()
|
|
94
|
-
await nextTick()
|
|
95
|
-
|
|
96
|
-
expect(api.indicatorStyle.value).toMatchObject({
|
|
97
|
-
width: '100px',
|
|
98
|
-
height: '28px',
|
|
99
|
-
transform: 'translate(40px, 0px)',
|
|
100
|
-
opacity: '1'
|
|
101
|
-
})
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
it('model 切换后即时重测到新几何,不附带过渡', async () => {
|
|
105
|
-
const dom = createFakeDom()
|
|
106
|
-
dom.setActive({ offsetLeft: 40, offsetTop: 0, offsetWidth: 100, offsetHeight: 28 })
|
|
107
|
-
const { api, model } = setupTabsBar(dom)
|
|
108
|
-
await nextTick()
|
|
109
|
-
await nextTick()
|
|
110
|
-
|
|
111
|
-
dom.setActive({ offsetLeft: 160, offsetTop: 0, offsetWidth: 80, offsetHeight: 28 })
|
|
112
|
-
model.value = 'b'
|
|
113
|
-
await nextTick()
|
|
114
|
-
await nextTick()
|
|
115
|
-
|
|
116
|
-
expect(api.indicatorStyle.value).toMatchObject({
|
|
117
|
-
width: '80px',
|
|
118
|
-
transform: 'translate(160px, 0px)',
|
|
119
|
-
opacity: '1'
|
|
120
|
-
})
|
|
121
|
-
expect(api.indicatorStyle.value.transition).toBeUndefined()
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
it('无激活项时隐藏,恢复显示时直接落到新位置', async () => {
|
|
125
|
-
const dom = createFakeDom()
|
|
126
|
-
dom.setActive(null)
|
|
127
|
-
const { api, model } = setupTabsBar(dom)
|
|
128
|
-
await nextTick()
|
|
129
|
-
await nextTick()
|
|
130
|
-
expect(api.indicatorStyle.value.opacity).toBe('0')
|
|
131
|
-
|
|
132
|
-
dom.setActive({ offsetLeft: 40, offsetTop: 0, offsetWidth: 100, offsetHeight: 28 })
|
|
133
|
-
model.value = 'b'
|
|
134
|
-
await nextTick()
|
|
135
|
-
await nextTick()
|
|
136
|
-
|
|
137
|
-
expect(api.indicatorStyle.value).toMatchObject({
|
|
138
|
-
opacity: '1',
|
|
139
|
-
transform: 'translate(40px, 0px)'
|
|
140
|
-
})
|
|
141
|
-
expect(api.indicatorStyle.value.transition).toBeUndefined()
|
|
142
|
-
})
|
|
143
|
-
})
|