@touchvue/ui 1.0.0-beta.51 → 1.0.0-beta.53
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/es/components/form/src/form.vue.d.ts +0 -3
- package/es/components/index.d.ts +3 -1
- package/es/components/input/src/input.vue.d.ts +1 -10
- package/es/components/rate/index.d.ts +4 -0
- package/es/components/rate/src/instance.d.ts +2 -0
- package/es/components/rate/src/rate.vue.d.ts +77 -0
- package/es/components/select/src/select.d.ts +0 -8
- package/es/components/select/src/select.vue.d.ts +0 -9
- package/es/components/slide/src/slide.vue.d.ts +4 -0
- package/es/components/switch/src/switch.vue.d.ts +3 -3
- package/es/components/tab/src/tab.d.ts +1 -1
- package/es/components/tab/src/tab.vue.d.ts +17 -4
- package/es/index.d.mjs +1 -0
- package/es/index.d.mjs.map +1 -1
- package/es/index.mjs +1 -0
- package/es/index.mjs.map +1 -1
- package/es/packages/components/cascader/src/cascader.vue2.mjs +1 -1
- package/es/packages/components/cascader/src/cascader.vue2.mjs.map +1 -1
- package/es/packages/components/checkbox/src/Checkbox.vue2.mjs +1 -1
- package/es/packages/components/checkbox/src/Checkbox.vue2.mjs.map +1 -1
- package/es/packages/components/checkboxes/src/Checkboxes.vue2.mjs.map +1 -1
- package/es/packages/components/datepicker/src/DatePicker.vue2.mjs +2 -3
- package/es/packages/components/datepicker/src/DatePicker.vue2.mjs.map +1 -1
- package/es/packages/components/daterange/src/date-range.vue2.mjs +18 -6
- package/es/packages/components/daterange/src/date-range.vue2.mjs.map +1 -1
- package/es/packages/components/form/src/form.vue2.mjs +1 -2
- package/es/packages/components/form/src/form.vue2.mjs.map +1 -1
- package/es/packages/components/index.d.mjs +1 -0
- package/es/packages/components/index.d.mjs.map +1 -1
- package/es/packages/components/index.mjs +1 -0
- package/es/packages/components/index.mjs.map +1 -1
- package/es/packages/components/input/src/input.vue2.mjs +63 -62
- package/es/packages/components/input/src/input.vue2.mjs.map +1 -1
- package/es/packages/components/page/src/page.vue2.mjs +6 -3
- package/es/packages/components/page/src/page.vue2.mjs.map +1 -1
- package/es/packages/components/rate/index.d.mjs +2 -0
- package/es/packages/components/rate/index.d.mjs.map +1 -0
- package/es/packages/components/rate/index.mjs +7 -0
- package/es/packages/components/rate/index.mjs.map +1 -0
- package/es/packages/components/rate/src/instance.d.mjs +2 -0
- package/es/packages/components/rate/src/instance.d.mjs.map +1 -0
- package/es/packages/components/rate/src/instance.mjs +2 -0
- package/es/packages/components/rate/src/instance.mjs.map +1 -0
- package/es/packages/components/rate/src/rate.vue.mjs +7 -0
- package/es/packages/components/rate/src/rate.vue.mjs.map +1 -0
- package/es/packages/components/rate/src/rate.vue2.mjs +153 -0
- package/es/packages/components/rate/src/rate.vue2.mjs.map +1 -0
- package/es/packages/components/segment/src/segment.vue.mjs +1 -4
- package/es/packages/components/segment/src/segment.vue.mjs.map +1 -1
- package/es/packages/components/select/src/hooks/use-select-class-style.mjs +1 -1
- package/es/packages/components/select/src/hooks/use-select-class-style.mjs.map +1 -1
- package/es/packages/components/select/src/select.mjs +0 -8
- package/es/packages/components/select/src/select.mjs.map +1 -1
- package/es/packages/components/select/src/select.vue2.mjs +2 -2
- package/es/packages/components/select/src/select.vue2.mjs.map +1 -1
- package/es/packages/components/slide/src/slide.vue2.mjs +3 -1
- package/es/packages/components/slide/src/slide.vue2.mjs.map +1 -1
- package/es/packages/components/switch/src/switch.vue2.mjs +4 -4
- package/es/packages/components/switch/src/switch.vue2.mjs.map +1 -1
- package/es/packages/components/tab/src/tab.vue2.mjs +401 -47
- package/es/packages/components/tab/src/tab.vue2.mjs.map +1 -1
- package/es/packages/components/transfer/src/transfer.vue2.mjs.map +1 -1
- package/es/packages/components/tree/src/tree.vue2.mjs +2 -0
- package/es/packages/components/tree/src/tree.vue2.mjs.map +1 -1
- package/es/packages/components/upload/src/upload.vue2.mjs +2 -2
- package/es/packages/components/upload/src/upload.vue2.mjs.map +1 -1
- package/es/packages/utils/disabledArea.mjs +2 -2
- package/es/packages/utils/disabledArea.mjs.map +1 -1
- package/es/packages/utils/validate.mjs +18 -11
- package/es/packages/utils/validate.mjs.map +1 -1
- package/global.d.ts +1 -0
- package/lib/components/form/src/form.vue.d.ts +0 -3
- package/lib/components/index.d.ts +3 -1
- package/lib/components/input/src/input.vue.d.ts +1 -10
- package/lib/components/rate/index.d.ts +4 -0
- package/lib/components/rate/src/instance.d.ts +2 -0
- package/lib/components/rate/src/rate.vue.d.ts +77 -0
- package/lib/components/select/src/select.d.ts +0 -8
- package/lib/components/select/src/select.vue.d.ts +0 -9
- package/lib/components/slide/src/slide.vue.d.ts +4 -0
- package/lib/components/switch/src/switch.vue.d.ts +3 -3
- package/lib/components/tab/src/tab.d.ts +1 -1
- package/lib/components/tab/src/tab.vue.d.ts +17 -4
- package/lib/index.d.js +8 -6
- package/lib/index.d.js.map +1 -1
- package/lib/index.js +13 -11
- package/lib/index.js.map +1 -1
- package/lib/packages/components/cascader/src/cascader.vue2.js +1 -1
- package/lib/packages/components/cascader/src/cascader.vue2.js.map +1 -1
- package/lib/packages/components/checkbox/src/Checkbox.vue2.js +1 -1
- package/lib/packages/components/checkbox/src/Checkbox.vue2.js.map +1 -1
- package/lib/packages/components/checkboxes/src/Checkboxes.vue2.js.map +1 -1
- package/lib/packages/components/datepicker/src/DatePicker.vue2.js +2 -3
- package/lib/packages/components/datepicker/src/DatePicker.vue2.js.map +1 -1
- package/lib/packages/components/daterange/src/date-range.vue2.js +18 -6
- package/lib/packages/components/daterange/src/date-range.vue2.js.map +1 -1
- package/lib/packages/components/form/src/form.vue2.js +1 -2
- package/lib/packages/components/form/src/form.vue2.js.map +1 -1
- package/lib/packages/components/index.d.js +2 -0
- package/lib/packages/components/index.d.js.map +1 -1
- package/lib/packages/components/index.js +2 -0
- package/lib/packages/components/index.js.map +1 -1
- package/lib/packages/components/input/src/input.vue2.js +63 -62
- package/lib/packages/components/input/src/input.vue2.js.map +1 -1
- package/lib/packages/components/page/src/page.vue2.js +6 -3
- package/lib/packages/components/page/src/page.vue2.js.map +1 -1
- package/lib/packages/components/rate/index.d.js +3 -0
- package/lib/packages/components/rate/index.d.js.map +1 -0
- package/lib/packages/components/rate/index.js +9 -0
- package/lib/packages/components/rate/index.js.map +1 -0
- package/lib/packages/components/rate/src/instance.d.js +3 -0
- package/lib/packages/components/rate/src/instance.d.js.map +1 -0
- package/lib/packages/components/rate/src/instance.js +3 -0
- package/lib/packages/components/rate/src/instance.js.map +1 -0
- package/lib/packages/components/rate/src/rate.vue.js +11 -0
- package/lib/packages/components/rate/src/rate.vue.js.map +1 -0
- package/lib/packages/components/rate/src/rate.vue2.js +157 -0
- package/lib/packages/components/rate/src/rate.vue2.js.map +1 -0
- package/lib/packages/components/segment/src/segment.vue.js +1 -4
- package/lib/packages/components/segment/src/segment.vue.js.map +1 -1
- package/lib/packages/components/select/src/hooks/use-select-class-style.js +1 -1
- package/lib/packages/components/select/src/hooks/use-select-class-style.js.map +1 -1
- package/lib/packages/components/select/src/select.js +0 -8
- package/lib/packages/components/select/src/select.js.map +1 -1
- package/lib/packages/components/select/src/select.vue2.js +2 -2
- package/lib/packages/components/select/src/select.vue2.js.map +1 -1
- package/lib/packages/components/slide/src/slide.vue2.js +3 -1
- package/lib/packages/components/slide/src/slide.vue2.js.map +1 -1
- package/lib/packages/components/switch/src/switch.vue2.js +4 -4
- package/lib/packages/components/switch/src/switch.vue2.js.map +1 -1
- package/lib/packages/components/tab/src/tab.vue2.js +400 -46
- package/lib/packages/components/tab/src/tab.vue2.js.map +1 -1
- package/lib/packages/components/transfer/src/transfer.vue2.js.map +1 -1
- package/lib/packages/components/tree/src/tree.vue2.js +2 -0
- package/lib/packages/components/tree/src/tree.vue2.js.map +1 -1
- package/lib/packages/components/upload/src/upload.vue2.js +2 -2
- package/lib/packages/components/upload/src/upload.vue2.js.map +1 -1
- package/lib/packages/utils/disabledArea.js +2 -2
- package/lib/packages/utils/disabledArea.js.map +1 -1
- package/lib/packages/utils/validate.js +24 -17
- package/lib/packages/utils/validate.js.map +1 -1
- package/package.json +1 -1
- package/theme/components/index.css +313 -122
- package/theme/index.css +313 -122
- package/theme/skin/default.css +313 -122
- package/types/global.d.ts +1 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { defineComponent, ref, useSlots, watch, onMounted,
|
|
1
|
+
import { defineComponent, ref, computed, useSlots, watch, onMounted, onBeforeUnmount, nextTick, provide, resolveComponent, openBlock, createElementBlock, unref, normalizeClass, normalizeStyle, createElementVNode, renderSlot, createTextVNode, toDisplayString, createCommentVNode, Fragment, renderList, createBlock, mergeProps, withModifiers, Teleport, createVNode, withCtx } from 'vue';
|
|
2
2
|
import { ToIcon } from '../../icon/index.mjs';
|
|
3
3
|
import { ToFloat } from '../../float/index.mjs';
|
|
4
4
|
import { langKey } from '../../../locale/index.mjs';
|
|
5
|
+
import { useDevice } from '../../../hooks/useDevice.mjs';
|
|
5
6
|
|
|
6
7
|
const __default__ = defineComponent({
|
|
7
8
|
name: "ToTab"
|
|
@@ -17,7 +18,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17
18
|
removable: { type: Boolean, default: false },
|
|
18
19
|
position: { default: "" },
|
|
19
20
|
itemDir: { default: "" },
|
|
20
|
-
over: { default: "
|
|
21
|
+
over: { default: "" },
|
|
21
22
|
event: { default: "click" },
|
|
22
23
|
contentType: { default: "" },
|
|
23
24
|
title: { default: "" },
|
|
@@ -34,17 +35,37 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
34
35
|
const selectValue = ref("");
|
|
35
36
|
const _data = ref([]);
|
|
36
37
|
const floatRef = ref(null);
|
|
38
|
+
const overflowFloatRef = ref(null);
|
|
39
|
+
const overflowIconRef = ref(null);
|
|
40
|
+
const overflowTabs = ref([]);
|
|
41
|
+
const overflowFloatShow = computed(() => props.over === "float" && overflowTabs.value.length > 0);
|
|
37
42
|
const ul = ref(null);
|
|
38
43
|
const list = ref(null);
|
|
44
|
+
const tabScrollRef = ref(null);
|
|
45
|
+
const tabScrollWidth = ref(0);
|
|
46
|
+
const tabScrollLeft = ref(0);
|
|
47
|
+
const tabScrollable = ref(false);
|
|
48
|
+
const tabScrollDragging = ref(false);
|
|
49
|
+
const activeOver = ref("");
|
|
39
50
|
let scrollTimer = null;
|
|
40
51
|
const controlShow = ref(false);
|
|
41
52
|
let stopChange = false;
|
|
53
|
+
let activeOverVersion = 0;
|
|
42
54
|
const slot = useSlots();
|
|
55
|
+
const { isPc } = useDevice();
|
|
56
|
+
const tabScrollShow = computed(() => isPc.value && tabScrollable.value);
|
|
57
|
+
const tabScrollStyle = computed(() => {
|
|
58
|
+
return {
|
|
59
|
+
width: `${tabScrollWidth.value}px`,
|
|
60
|
+
left: `${tabScrollLeft.value}px`
|
|
61
|
+
};
|
|
62
|
+
});
|
|
43
63
|
watch(
|
|
44
64
|
() => props.modelValue,
|
|
45
65
|
(val, old) => {
|
|
46
66
|
if (val || val === 0) {
|
|
47
67
|
selectValue.value = val;
|
|
68
|
+
scrollSelectTabIntoView();
|
|
48
69
|
} else {
|
|
49
70
|
emit("update:modelValue", old);
|
|
50
71
|
}
|
|
@@ -60,8 +81,26 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
60
81
|
},
|
|
61
82
|
{ deep: true }
|
|
62
83
|
);
|
|
84
|
+
watch(
|
|
85
|
+
() => isPc.value,
|
|
86
|
+
() => {
|
|
87
|
+
updateTabLayout();
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
watch(
|
|
91
|
+
() => props.over,
|
|
92
|
+
() => {
|
|
93
|
+
updateTabLayout();
|
|
94
|
+
}
|
|
95
|
+
);
|
|
63
96
|
onMounted(() => {
|
|
64
97
|
initData();
|
|
98
|
+
window.addEventListener("resize", updateTabLayout);
|
|
99
|
+
});
|
|
100
|
+
onBeforeUnmount(() => {
|
|
101
|
+
window.removeEventListener("resize", updateTabLayout);
|
|
102
|
+
stopTabScrollDrag();
|
|
103
|
+
scrollStop();
|
|
65
104
|
});
|
|
66
105
|
function initData() {
|
|
67
106
|
if (props.data && props.data.length) {
|
|
@@ -82,6 +121,11 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
82
121
|
setLayout();
|
|
83
122
|
});
|
|
84
123
|
}
|
|
124
|
+
if (props.over === "float") {
|
|
125
|
+
updateOverflowTabs();
|
|
126
|
+
}
|
|
127
|
+
updateTabScroll();
|
|
128
|
+
updateActiveOver();
|
|
85
129
|
}
|
|
86
130
|
const setTabStyle = computed(() => {
|
|
87
131
|
let obj = {};
|
|
@@ -118,12 +162,8 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
118
162
|
if (props.align) {
|
|
119
163
|
arr.push(`align-${props.align}`);
|
|
120
164
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const setUlClass = computed(() => {
|
|
124
|
-
let arr = [];
|
|
125
|
-
if (props.over) {
|
|
126
|
-
arr.push(`over-${props.over}`);
|
|
165
|
+
if (activeOver.value) {
|
|
166
|
+
arr.push(`over-${activeOver.value}`);
|
|
127
167
|
}
|
|
128
168
|
return arr;
|
|
129
169
|
});
|
|
@@ -138,8 +178,8 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
138
178
|
}
|
|
139
179
|
return obj;
|
|
140
180
|
});
|
|
141
|
-
async function changeTab(item, index, event) {
|
|
142
|
-
if (props.event !== event)
|
|
181
|
+
async function changeTab(item, index, event, force = false) {
|
|
182
|
+
if (!force && props.event !== event)
|
|
143
183
|
return false;
|
|
144
184
|
if (item.disabled)
|
|
145
185
|
return false;
|
|
@@ -163,9 +203,11 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
163
203
|
selectValue.value = item.value;
|
|
164
204
|
emit("update:modelValue", item.value);
|
|
165
205
|
emit("change", item.value, item, index);
|
|
206
|
+
scrollTabIntoView(index);
|
|
166
207
|
setTimeout(() => {
|
|
167
208
|
stopChange = false;
|
|
168
209
|
}, 10);
|
|
210
|
+
return true;
|
|
169
211
|
}
|
|
170
212
|
async function removePTab(item, idx) {
|
|
171
213
|
let flag = true;
|
|
@@ -194,6 +236,11 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
194
236
|
if (props.over === "control") {
|
|
195
237
|
setLayout();
|
|
196
238
|
}
|
|
239
|
+
if (props.over === "float") {
|
|
240
|
+
updateOverflowTabs();
|
|
241
|
+
}
|
|
242
|
+
updateTabScroll();
|
|
243
|
+
updateActiveOver();
|
|
197
244
|
emit("remove", item.value, item, idx);
|
|
198
245
|
setTimeout(() => {
|
|
199
246
|
stopChange = false;
|
|
@@ -217,6 +264,11 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
217
264
|
setLayout();
|
|
218
265
|
});
|
|
219
266
|
}
|
|
267
|
+
if (props.over === "float") {
|
|
268
|
+
updateOverflowTabs();
|
|
269
|
+
}
|
|
270
|
+
updateTabScroll();
|
|
271
|
+
updateActiveOver();
|
|
220
272
|
}
|
|
221
273
|
setTimeout(() => {
|
|
222
274
|
stopChange = false;
|
|
@@ -226,6 +278,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
226
278
|
let idx = _data.value.findIndex((item) => item.label === oldLabel);
|
|
227
279
|
if (idx !== -1) {
|
|
228
280
|
_data.value[idx].label = label;
|
|
281
|
+
updateTabLayout();
|
|
229
282
|
}
|
|
230
283
|
}
|
|
231
284
|
function getPicOn(pic) {
|
|
@@ -251,31 +304,229 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
251
304
|
function contextmenu(item, idx) {
|
|
252
305
|
emit("contextmenu", item.value, item, idx);
|
|
253
306
|
}
|
|
307
|
+
function updateTabLayout() {
|
|
308
|
+
if (props.over === "control") {
|
|
309
|
+
setLayout();
|
|
310
|
+
}
|
|
311
|
+
updateActiveOver();
|
|
312
|
+
updateOverflowTabs();
|
|
313
|
+
updateTabScroll();
|
|
314
|
+
}
|
|
315
|
+
function handleListScroll() {
|
|
316
|
+
setOverflowTabs();
|
|
317
|
+
setTabScroll();
|
|
318
|
+
}
|
|
319
|
+
function updateOverflowTabs() {
|
|
320
|
+
nextTick(() => {
|
|
321
|
+
setOverflowTabs();
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
function setOverflowTabs() {
|
|
325
|
+
if (props.over !== "float" || !list.value || !ul.value) {
|
|
326
|
+
overflowTabs.value = [];
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const listRect = list.value.getBoundingClientRect();
|
|
330
|
+
if (!listRect.width || !listRect.height) {
|
|
331
|
+
overflowTabs.value = [];
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const hiddenIndexes = /* @__PURE__ */ new Set();
|
|
335
|
+
const itemNodes = Array.from(ul.value.querySelectorAll(".to-tab-item"));
|
|
336
|
+
itemNodes.forEach((node) => {
|
|
337
|
+
const index = Number(node.dataset.tabIndex);
|
|
338
|
+
if (Number.isNaN(index))
|
|
339
|
+
return;
|
|
340
|
+
const rect = node.getBoundingClientRect();
|
|
341
|
+
const isHidden = rect.left < listRect.left - 1 || rect.right > listRect.right + 1 || rect.top < listRect.top - 1 || rect.bottom > listRect.bottom + 1;
|
|
342
|
+
if (isHidden) {
|
|
343
|
+
hiddenIndexes.add(index);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
const oldShow = overflowTabs.value.length > 0;
|
|
347
|
+
overflowTabs.value = _data.value.map((item, index) => ({ item, index })).filter((tab) => hiddenIndexes.has(tab.index));
|
|
348
|
+
if (oldShow !== overflowTabs.value.length > 0) {
|
|
349
|
+
updateOverflowTabs();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function updateTabScroll() {
|
|
353
|
+
nextTick(() => {
|
|
354
|
+
setTabScroll();
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
function setTabScroll() {
|
|
358
|
+
if (!isPc.value || !list.value || !ul.value) {
|
|
359
|
+
tabScrollable.value = false;
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const listWidth = list.value.clientWidth;
|
|
363
|
+
const scrollWidth = ul.value.scrollWidth;
|
|
364
|
+
const scrollRange = scrollWidth - listWidth;
|
|
365
|
+
if (listWidth <= 0 || scrollRange <= 1) {
|
|
366
|
+
tabScrollable.value = false;
|
|
367
|
+
tabScrollWidth.value = 0;
|
|
368
|
+
tabScrollLeft.value = 0;
|
|
369
|
+
list.value.scrollLeft = 0;
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
const scrollLeft = Math.max(0, Math.min(scrollRange, list.value.scrollLeft));
|
|
373
|
+
if (scrollLeft !== list.value.scrollLeft) {
|
|
374
|
+
list.value.scrollLeft = scrollLeft;
|
|
375
|
+
}
|
|
376
|
+
tabScrollable.value = true;
|
|
377
|
+
tabScrollWidth.value = Math.max(listWidth * listWidth / scrollWidth, 16);
|
|
378
|
+
const trackRange = Math.max(listWidth - tabScrollWidth.value, 0);
|
|
379
|
+
const scrollRatio = scrollLeft / scrollRange;
|
|
380
|
+
tabScrollLeft.value = scrollLeft + scrollRatio * trackRange;
|
|
381
|
+
}
|
|
382
|
+
function getTabScrollRange() {
|
|
383
|
+
if (!list.value || !ul.value)
|
|
384
|
+
return 0;
|
|
385
|
+
return Math.max(ul.value.scrollWidth - list.value.clientWidth, 0);
|
|
386
|
+
}
|
|
387
|
+
async function updateActiveOver() {
|
|
388
|
+
const version = ++activeOverVersion;
|
|
389
|
+
const over = props.over;
|
|
390
|
+
if (over !== "avg" && over !== "wrap") {
|
|
391
|
+
activeOver.value = over;
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
activeOver.value = "";
|
|
395
|
+
await nextTick();
|
|
396
|
+
if (version !== activeOverVersion || props.over !== over || !list.value || !ul.value)
|
|
397
|
+
return;
|
|
398
|
+
activeOver.value = getTabScrollRange() > 1 ? over : "";
|
|
399
|
+
await nextTick();
|
|
400
|
+
if (version !== activeOverVersion)
|
|
401
|
+
return;
|
|
402
|
+
setTabScroll();
|
|
403
|
+
}
|
|
404
|
+
function setTabScrollLeft(scrollLeft) {
|
|
405
|
+
if (!list.value)
|
|
406
|
+
return;
|
|
407
|
+
const scrollRange = getTabScrollRange();
|
|
408
|
+
list.value.scrollLeft = Math.max(0, Math.min(scrollRange, scrollLeft));
|
|
409
|
+
setTabScroll();
|
|
410
|
+
setOverflowTabs();
|
|
411
|
+
}
|
|
412
|
+
function startTabScrollDrag(event) {
|
|
413
|
+
if (!tabScrollShow.value || !list.value || !ul.value)
|
|
414
|
+
return;
|
|
415
|
+
event.preventDefault();
|
|
416
|
+
tabScrollDragging.value = true;
|
|
417
|
+
const startX = event.clientX;
|
|
418
|
+
const startScrollLeft = list.value.scrollLeft;
|
|
419
|
+
const listWidth = list.value.clientWidth;
|
|
420
|
+
const scrollRange = getTabScrollRange();
|
|
421
|
+
const trackRange = Math.max(listWidth - tabScrollWidth.value, 1);
|
|
422
|
+
const move = (moveEvent) => {
|
|
423
|
+
moveEvent.preventDefault();
|
|
424
|
+
const nextScrollLeft = startScrollLeft + (moveEvent.clientX - startX) / trackRange * scrollRange;
|
|
425
|
+
setTabScrollLeft(nextScrollLeft);
|
|
426
|
+
};
|
|
427
|
+
const up = () => {
|
|
428
|
+
stopTabScrollDrag();
|
|
429
|
+
};
|
|
430
|
+
window.addEventListener("mousemove", move);
|
|
431
|
+
window.addEventListener("mouseup", up, { once: true });
|
|
432
|
+
tabScrollMove = move;
|
|
433
|
+
tabScrollUp = up;
|
|
434
|
+
}
|
|
435
|
+
let tabScrollMove = null;
|
|
436
|
+
let tabScrollUp = null;
|
|
437
|
+
function stopTabScrollDrag() {
|
|
438
|
+
tabScrollDragging.value = false;
|
|
439
|
+
if (tabScrollMove) {
|
|
440
|
+
window.removeEventListener("mousemove", tabScrollMove);
|
|
441
|
+
tabScrollMove = null;
|
|
442
|
+
}
|
|
443
|
+
if (tabScrollUp) {
|
|
444
|
+
window.removeEventListener("mouseup", tabScrollUp);
|
|
445
|
+
tabScrollUp = null;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
async function toggleOverflowFloat() {
|
|
449
|
+
var _a, _b, _c, _d;
|
|
450
|
+
updateOverflowTabs();
|
|
451
|
+
await nextTick();
|
|
452
|
+
if (overflowTabs.value.length) {
|
|
453
|
+
(_b = (_a = overflowFloatRef.value) == null ? void 0 : _a.toggle) == null ? void 0 : _b.call(_a, overflowIconRef.value);
|
|
454
|
+
} else {
|
|
455
|
+
(_d = (_c = overflowFloatRef.value) == null ? void 0 : _c.close) == null ? void 0 : _d.call(_c);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
async function changeOverflowTab(tab) {
|
|
459
|
+
var _a, _b;
|
|
460
|
+
const changed = await changeTab(tab.item, tab.index, "click", true);
|
|
461
|
+
if (changed !== false) {
|
|
462
|
+
(_b = (_a = overflowFloatRef.value) == null ? void 0 : _a.close) == null ? void 0 : _b.call(_a);
|
|
463
|
+
scrollTabIntoView(tab.index);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
async function removeOverflowTab(tab) {
|
|
467
|
+
var _a, _b;
|
|
468
|
+
await removePTab(tab.item, tab.index);
|
|
469
|
+
updateOverflowTabs();
|
|
470
|
+
await nextTick();
|
|
471
|
+
if (!overflowTabs.value.length) {
|
|
472
|
+
(_b = (_a = overflowFloatRef.value) == null ? void 0 : _a.close) == null ? void 0 : _b.call(_a);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
function scrollTabIntoView(index) {
|
|
476
|
+
nextTick(() => {
|
|
477
|
+
if (!list.value || !ul.value)
|
|
478
|
+
return;
|
|
479
|
+
const node = ul.value.querySelector(`.to-tab-item[data-tab-index="${index}"]`);
|
|
480
|
+
if (!node)
|
|
481
|
+
return;
|
|
482
|
+
const listRect = list.value.getBoundingClientRect();
|
|
483
|
+
const nodeRect = node.getBoundingClientRect();
|
|
484
|
+
if (nodeRect.right > listRect.right) {
|
|
485
|
+
setTabScrollLeft(list.value.scrollLeft + nodeRect.right - listRect.right);
|
|
486
|
+
} else if (nodeRect.left < listRect.left) {
|
|
487
|
+
setTabScrollLeft(list.value.scrollLeft + nodeRect.left - listRect.left);
|
|
488
|
+
} else {
|
|
489
|
+
updateOverflowTabs();
|
|
490
|
+
updateTabScroll();
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
function scrollSelectTabIntoView() {
|
|
495
|
+
const index = _data.value.findIndex((item) => item.value === selectValue.value);
|
|
496
|
+
if (index !== -1) {
|
|
497
|
+
scrollTabIntoView(index);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
254
500
|
function controlLeftScroll() {
|
|
255
501
|
scrollTimer = setInterval(() => {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
// behavior: 'smooth' // 平滑滚动效果
|
|
259
|
-
});
|
|
502
|
+
var _a;
|
|
503
|
+
setTabScrollLeft((((_a = list.value) == null ? void 0 : _a.scrollLeft) || 0) - 3);
|
|
260
504
|
}, 1);
|
|
261
505
|
}
|
|
262
506
|
function controlRightScroll() {
|
|
263
507
|
scrollTimer = setInterval(() => {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
// behavior: 'smooth' // 平滑滚动效果
|
|
267
|
-
});
|
|
508
|
+
var _a;
|
|
509
|
+
setTabScrollLeft((((_a = list.value) == null ? void 0 : _a.scrollLeft) || 0) + 3);
|
|
268
510
|
}, 1);
|
|
269
511
|
}
|
|
270
512
|
function scrollStop() {
|
|
271
|
-
|
|
513
|
+
if (scrollTimer) {
|
|
514
|
+
clearInterval(scrollTimer);
|
|
515
|
+
scrollTimer = null;
|
|
516
|
+
}
|
|
272
517
|
}
|
|
273
518
|
function setLayout() {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
519
|
+
nextTick(() => {
|
|
520
|
+
if (!list.value || !ul.value) {
|
|
521
|
+
controlShow.value = false;
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
controlShow.value = getTabScrollRange() > 1;
|
|
525
|
+
if (!controlShow.value) {
|
|
526
|
+
list.value.scrollLeft = 0;
|
|
527
|
+
}
|
|
528
|
+
setTabScroll();
|
|
529
|
+
});
|
|
279
530
|
}
|
|
280
531
|
provide("TabProvide", {
|
|
281
532
|
addTab,
|
|
@@ -285,6 +536,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
285
536
|
});
|
|
286
537
|
return (_ctx, _cache) => {
|
|
287
538
|
const _component_to_pic = resolveComponent("to-pic");
|
|
539
|
+
const _component_to_scroll = resolveComponent("to-scroll");
|
|
288
540
|
return openBlock(), createElementBlock("div", {
|
|
289
541
|
key: unref(langKey),
|
|
290
542
|
class: normalizeClass(["to-tab", setClass.value]),
|
|
@@ -311,7 +563,8 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
311
563
|
{
|
|
312
564
|
ref_key: "list",
|
|
313
565
|
ref: list,
|
|
314
|
-
class: "to-tab-list"
|
|
566
|
+
class: "to-tab-list",
|
|
567
|
+
onScroll: handleListScroll
|
|
315
568
|
},
|
|
316
569
|
[
|
|
317
570
|
createElementVNode(
|
|
@@ -319,7 +572,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
319
572
|
{
|
|
320
573
|
ref_key: "ul",
|
|
321
574
|
ref: ul,
|
|
322
|
-
class:
|
|
575
|
+
class: "to-tab-wrapper"
|
|
323
576
|
},
|
|
324
577
|
[
|
|
325
578
|
(openBlock(true), createElementBlock(
|
|
@@ -335,6 +588,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
335
588
|
])) : (openBlock(), createElementBlock("div", {
|
|
336
589
|
key: 1,
|
|
337
590
|
class: normalizeClass(["to-tab-item", { "is-on": item.value === selectValue.value, "is-disabled": item.disabled }]),
|
|
591
|
+
"data-tab-index": index,
|
|
338
592
|
style: normalizeStyle(setTabStyle.value),
|
|
339
593
|
onClick: ($event) => changeTab(item, index, "click"),
|
|
340
594
|
onMouseover: ($event) => changeTab(item, index, "hover"),
|
|
@@ -352,16 +606,13 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
352
606
|
class: "to-tab-item-pic",
|
|
353
607
|
src: item.value === selectValue.value ? getPicOn(item.pic) : item.pic
|
|
354
608
|
}, null, 8, ["src"])) : createCommentVNode("v-if", true),
|
|
355
|
-
item.icon ? (openBlock(),
|
|
609
|
+
item.icon ? (openBlock(), createBlock(unref(ToIcon), {
|
|
356
610
|
key: 1,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
mode: "tab-icon"
|
|
363
|
-
}, null, 8, ["value", "type"])
|
|
364
|
-
])) : createCommentVNode("v-if", true),
|
|
611
|
+
value: item.icon,
|
|
612
|
+
class: "to-tab-item-icon",
|
|
613
|
+
type: item.value === selectValue.value ? "fill" : "",
|
|
614
|
+
mode: "tab-icon"
|
|
615
|
+
}, null, 8, ["value", "type"])) : createCommentVNode("v-if", true),
|
|
365
616
|
createElementVNode("div", { class: "to-tab-item-label" }, [
|
|
366
617
|
renderSlot(_ctx.$slots, "label", mergeProps({ ref_for: true }, item), () => [
|
|
367
618
|
createTextVNode(
|
|
@@ -383,7 +634,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
383
634
|
]),
|
|
384
635
|
createElementVNode("div", { class: "to-tab-indicator" })
|
|
385
636
|
])
|
|
386
|
-
], 46, ["onClick", "onMouseover", "onContextmenu"]))
|
|
637
|
+
], 46, ["data-tab-index", "onClick", "onMouseover", "onContextmenu"]))
|
|
387
638
|
],
|
|
388
639
|
64
|
|
389
640
|
/* STABLE_FRAGMENT */
|
|
@@ -393,14 +644,30 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
393
644
|
/* KEYED_FRAGMENT */
|
|
394
645
|
))
|
|
395
646
|
],
|
|
396
|
-
|
|
397
|
-
/*
|
|
398
|
-
)
|
|
647
|
+
512
|
|
648
|
+
/* NEED_PATCH */
|
|
649
|
+
),
|
|
650
|
+
tabScrollShow.value ? (openBlock(), createElementBlock(
|
|
651
|
+
"div",
|
|
652
|
+
{
|
|
653
|
+
key: 0,
|
|
654
|
+
ref_key: "tabScrollRef",
|
|
655
|
+
ref: tabScrollRef,
|
|
656
|
+
class: normalizeClass(["to-tab-list-scroll", { "is-dragging": tabScrollDragging.value }]),
|
|
657
|
+
style: normalizeStyle(tabScrollStyle.value),
|
|
658
|
+
onMousedown: startTabScrollDrag
|
|
659
|
+
},
|
|
660
|
+
[
|
|
661
|
+
createElementVNode("div", { class: "to-tab-list-scroll-bar" })
|
|
662
|
+
],
|
|
663
|
+
38
|
|
664
|
+
/* CLASS, STYLE, NEED_HYDRATION */
|
|
665
|
+
)) : createCommentVNode("v-if", true)
|
|
399
666
|
],
|
|
400
|
-
|
|
401
|
-
/* NEED_PATCH */
|
|
667
|
+
544
|
|
668
|
+
/* NEED_HYDRATION, NEED_PATCH */
|
|
402
669
|
),
|
|
403
|
-
controlShow.value ||
|
|
670
|
+
controlShow.value || overflowFloatShow.value || unref(slot).fn ? (openBlock(), createElementBlock("div", {
|
|
404
671
|
key: 1,
|
|
405
672
|
class: "to-tab-fn"
|
|
406
673
|
}, [
|
|
@@ -423,11 +690,98 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
423
690
|
onMouseleave: scrollStop
|
|
424
691
|
})) : createCommentVNode("v-if", true),
|
|
425
692
|
renderSlot(_ctx.$slots, "fn"),
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
693
|
+
overflowFloatShow.value ? (openBlock(), createBlock(
|
|
694
|
+
unref(ToIcon),
|
|
695
|
+
{
|
|
696
|
+
key: 2,
|
|
697
|
+
ref_key: "overflowIconRef",
|
|
698
|
+
ref: overflowIconRef,
|
|
699
|
+
value: "more",
|
|
700
|
+
link: "",
|
|
701
|
+
onClick: toggleOverflowFloat
|
|
702
|
+
},
|
|
703
|
+
null,
|
|
704
|
+
512
|
|
705
|
+
/* NEED_PATCH */
|
|
706
|
+
)) : createCommentVNode("v-if", true),
|
|
707
|
+
overflowFloatShow.value ? (openBlock(), createBlock(Teleport, {
|
|
708
|
+
key: 3,
|
|
709
|
+
to: "body"
|
|
710
|
+
}, [
|
|
711
|
+
createElementVNode("div", { class: "to-tab" }, [
|
|
712
|
+
createVNode(
|
|
713
|
+
unref(ToFloat),
|
|
714
|
+
{
|
|
715
|
+
ref_key: "overflowFloatRef",
|
|
716
|
+
ref: overflowFloatRef,
|
|
717
|
+
align: "right",
|
|
718
|
+
global: false,
|
|
719
|
+
class: "to-tab-over-float",
|
|
720
|
+
lazy: false,
|
|
721
|
+
width: "12"
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
default: withCtx(() => [
|
|
725
|
+
createVNode(_component_to_scroll, { class: "to-tab-over-scroll" }, {
|
|
726
|
+
default: withCtx(() => [
|
|
727
|
+
createElementVNode("div", { class: "to-tab-over-list" }, [
|
|
728
|
+
(openBlock(true), createElementBlock(
|
|
729
|
+
Fragment,
|
|
730
|
+
null,
|
|
731
|
+
renderList(overflowTabs.value, (tab) => {
|
|
732
|
+
return openBlock(), createElementBlock("div", {
|
|
733
|
+
key: tab.index,
|
|
734
|
+
class: normalizeClass(["to-tab-over-item", { "is-on": tab.item.value === selectValue.value, "is-disabled": tab.item.disabled }]),
|
|
735
|
+
onClick: ($event) => changeOverflowTab(tab),
|
|
736
|
+
onContextmenu: ($event) => contextmenu(tab.item, tab.index)
|
|
737
|
+
}, [
|
|
738
|
+
tab.item.pic ? (openBlock(), createBlock(_component_to_pic, {
|
|
739
|
+
key: 0,
|
|
740
|
+
class: "to-tab-over-item-pic",
|
|
741
|
+
src: tab.item.value === selectValue.value ? getPicOn(tab.item.pic) : tab.item.pic
|
|
742
|
+
}, null, 8, ["src"])) : createCommentVNode("v-if", true),
|
|
743
|
+
tab.item.icon ? (openBlock(), createBlock(unref(ToIcon), {
|
|
744
|
+
key: 1,
|
|
745
|
+
value: tab.item.icon,
|
|
746
|
+
class: "to-tab-over-item-icon",
|
|
747
|
+
type: tab.item.value === selectValue.value ? "fill" : "",
|
|
748
|
+
mode: "tab-icon"
|
|
749
|
+
}, null, 8, ["value", "type"])) : createCommentVNode("v-if", true),
|
|
750
|
+
createElementVNode("div", { class: "to-tab-over-item-label" }, [
|
|
751
|
+
renderSlot(_ctx.$slots, "label", mergeProps({ ref_for: true }, tab.item), () => [
|
|
752
|
+
createTextVNode(
|
|
753
|
+
toDisplayString(tab.item.label),
|
|
754
|
+
1
|
|
755
|
+
/* TEXT */
|
|
756
|
+
)
|
|
757
|
+
])
|
|
758
|
+
]),
|
|
759
|
+
__props.removable ? (openBlock(), createBlock(unref(ToIcon), {
|
|
760
|
+
key: 2,
|
|
761
|
+
value: "close",
|
|
762
|
+
link: "",
|
|
763
|
+
class: "to-tab-over-item-remove",
|
|
764
|
+
onClick: withModifiers(($event) => removeOverflowTab(tab), ["stop"])
|
|
765
|
+
}, null, 8, ["onClick"])) : createCommentVNode("v-if", true)
|
|
766
|
+
], 42, ["onClick", "onContextmenu"]);
|
|
767
|
+
}),
|
|
768
|
+
128
|
|
769
|
+
/* KEYED_FRAGMENT */
|
|
770
|
+
))
|
|
771
|
+
])
|
|
772
|
+
]),
|
|
773
|
+
_: 3
|
|
774
|
+
/* FORWARDED */
|
|
775
|
+
})
|
|
776
|
+
]),
|
|
777
|
+
_: 3
|
|
778
|
+
/* FORWARDED */
|
|
779
|
+
},
|
|
780
|
+
512
|
|
781
|
+
/* NEED_PATCH */
|
|
782
|
+
)
|
|
783
|
+
])
|
|
784
|
+
])) : createCommentVNode("v-if", true)
|
|
431
785
|
])) : createCommentVNode("v-if", true),
|
|
432
786
|
createElementVNode("div", { class: "to-tab-divider" })
|
|
433
787
|
]),
|