@oiij/chrome-tabs 0.0.1
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/LICENSE +21 -0
- package/README.md +58 -0
- package/dist/TabItem.vue.d.ts +36 -0
- package/dist/Tabs.vue.d.ts +41 -0
- package/dist/index.css +15 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +551 -0
- package/dist/index.umd.cjs +554 -0
- package/package.json +98 -0
package/dist/index.js
ADDED
@@ -0,0 +1,551 @@
|
|
1
|
+
import { onMounted, nextTick, getCurrentScope, onScopeDispose, getCurrentInstance, toValue, computed, ref, watch, onBeforeUnmount, defineComponent, h as h$1, inject, createElementBlock, openBlock, normalizeClass, createElementVNode, createBlock, createCommentVNode, resolveDynamicComponent, renderSlot, withModifiers, createStaticVNode, mergeModels, useModel, provide, normalizeStyle, createVNode, TransitionGroup, withCtx } from "vue";
|
2
|
+
function tryOnScopeDispose(fn) {
|
3
|
+
if (getCurrentScope()) {
|
4
|
+
onScopeDispose(fn);
|
5
|
+
return true;
|
6
|
+
}
|
7
|
+
return false;
|
8
|
+
}
|
9
|
+
const isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
10
|
+
typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
|
11
|
+
const noop = () => {
|
12
|
+
};
|
13
|
+
function createFilterWrapper(filter, fn) {
|
14
|
+
function wrapper(...args) {
|
15
|
+
return new Promise((resolve, reject) => {
|
16
|
+
Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
|
17
|
+
});
|
18
|
+
}
|
19
|
+
return wrapper;
|
20
|
+
}
|
21
|
+
function debounceFilter(ms, options = {}) {
|
22
|
+
let timer;
|
23
|
+
let maxTimer;
|
24
|
+
let lastRejector = noop;
|
25
|
+
const _clearTimeout = (timer2) => {
|
26
|
+
clearTimeout(timer2);
|
27
|
+
lastRejector();
|
28
|
+
lastRejector = noop;
|
29
|
+
};
|
30
|
+
let lastInvoker;
|
31
|
+
const filter = (invoke) => {
|
32
|
+
const duration = toValue(ms);
|
33
|
+
const maxDuration = toValue(options.maxWait);
|
34
|
+
if (timer)
|
35
|
+
_clearTimeout(timer);
|
36
|
+
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
37
|
+
if (maxTimer) {
|
38
|
+
_clearTimeout(maxTimer);
|
39
|
+
maxTimer = null;
|
40
|
+
}
|
41
|
+
return Promise.resolve(invoke());
|
42
|
+
}
|
43
|
+
return new Promise((resolve, reject) => {
|
44
|
+
lastRejector = options.rejectOnCancel ? reject : resolve;
|
45
|
+
lastInvoker = invoke;
|
46
|
+
if (maxDuration && !maxTimer) {
|
47
|
+
maxTimer = setTimeout(() => {
|
48
|
+
if (timer)
|
49
|
+
_clearTimeout(timer);
|
50
|
+
maxTimer = null;
|
51
|
+
resolve(lastInvoker());
|
52
|
+
}, maxDuration);
|
53
|
+
}
|
54
|
+
timer = setTimeout(() => {
|
55
|
+
if (maxTimer)
|
56
|
+
_clearTimeout(maxTimer);
|
57
|
+
maxTimer = null;
|
58
|
+
resolve(invoke());
|
59
|
+
}, duration);
|
60
|
+
});
|
61
|
+
};
|
62
|
+
return filter;
|
63
|
+
}
|
64
|
+
function getLifeCycleTarget(target) {
|
65
|
+
return getCurrentInstance();
|
66
|
+
}
|
67
|
+
function toArray(value) {
|
68
|
+
return Array.isArray(value) ? value : [value];
|
69
|
+
}
|
70
|
+
function useDebounceFn(fn, ms = 200, options = {}) {
|
71
|
+
return createFilterWrapper(
|
72
|
+
debounceFilter(ms, options),
|
73
|
+
fn
|
74
|
+
);
|
75
|
+
}
|
76
|
+
function tryOnMounted(fn, sync = true, target) {
|
77
|
+
const instance = getLifeCycleTarget();
|
78
|
+
if (instance)
|
79
|
+
onMounted(fn, target);
|
80
|
+
else if (sync)
|
81
|
+
fn();
|
82
|
+
else
|
83
|
+
nextTick(fn);
|
84
|
+
}
|
85
|
+
const defaultWindow = isClient ? window : void 0;
|
86
|
+
function unrefElement(elRef) {
|
87
|
+
var _a;
|
88
|
+
const plain = toValue(elRef);
|
89
|
+
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
90
|
+
}
|
91
|
+
function useMounted() {
|
92
|
+
const isMounted = ref(false);
|
93
|
+
const instance = getCurrentInstance();
|
94
|
+
if (instance) {
|
95
|
+
onMounted(() => {
|
96
|
+
isMounted.value = true;
|
97
|
+
}, instance);
|
98
|
+
}
|
99
|
+
return isMounted;
|
100
|
+
}
|
101
|
+
function useSupported(callback) {
|
102
|
+
const isMounted = useMounted();
|
103
|
+
return computed(() => {
|
104
|
+
isMounted.value;
|
105
|
+
return Boolean(callback());
|
106
|
+
});
|
107
|
+
}
|
108
|
+
function useResizeObserver(target, callback, options = {}) {
|
109
|
+
const { window: window2 = defaultWindow, ...observerOptions } = options;
|
110
|
+
let observer;
|
111
|
+
const isSupported = useSupported(() => window2 && "ResizeObserver" in window2);
|
112
|
+
const cleanup = () => {
|
113
|
+
if (observer) {
|
114
|
+
observer.disconnect();
|
115
|
+
observer = void 0;
|
116
|
+
}
|
117
|
+
};
|
118
|
+
const targets = computed(() => {
|
119
|
+
const _targets = toValue(target);
|
120
|
+
return Array.isArray(_targets) ? _targets.map((el) => unrefElement(el)) : [unrefElement(_targets)];
|
121
|
+
});
|
122
|
+
const stopWatch = watch(
|
123
|
+
targets,
|
124
|
+
(els) => {
|
125
|
+
cleanup();
|
126
|
+
if (isSupported.value && window2) {
|
127
|
+
observer = new ResizeObserver(callback);
|
128
|
+
for (const _el of els) {
|
129
|
+
if (_el)
|
130
|
+
observer.observe(_el, observerOptions);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
},
|
134
|
+
{ immediate: true, flush: "post" }
|
135
|
+
);
|
136
|
+
const stop = () => {
|
137
|
+
cleanup();
|
138
|
+
stopWatch();
|
139
|
+
};
|
140
|
+
tryOnScopeDispose(stop);
|
141
|
+
return {
|
142
|
+
isSupported,
|
143
|
+
stop
|
144
|
+
};
|
145
|
+
}
|
146
|
+
function useElementSize(target, initialSize = { width: 0, height: 0 }, options = {}) {
|
147
|
+
const { window: window2 = defaultWindow, box = "content-box" } = options;
|
148
|
+
const isSVG = computed(() => {
|
149
|
+
var _a, _b;
|
150
|
+
return (_b = (_a = unrefElement(target)) == null ? void 0 : _a.namespaceURI) == null ? void 0 : _b.includes("svg");
|
151
|
+
});
|
152
|
+
const width = ref(initialSize.width);
|
153
|
+
const height = ref(initialSize.height);
|
154
|
+
const { stop: stop1 } = useResizeObserver(
|
155
|
+
target,
|
156
|
+
([entry]) => {
|
157
|
+
const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
|
158
|
+
if (window2 && isSVG.value) {
|
159
|
+
const $elem = unrefElement(target);
|
160
|
+
if ($elem) {
|
161
|
+
const rect = $elem.getBoundingClientRect();
|
162
|
+
width.value = rect.width;
|
163
|
+
height.value = rect.height;
|
164
|
+
}
|
165
|
+
} else {
|
166
|
+
if (boxSize) {
|
167
|
+
const formatBoxSize = toArray(boxSize);
|
168
|
+
width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
|
169
|
+
height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
|
170
|
+
} else {
|
171
|
+
width.value = entry.contentRect.width;
|
172
|
+
height.value = entry.contentRect.height;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
},
|
176
|
+
options
|
177
|
+
);
|
178
|
+
tryOnMounted(() => {
|
179
|
+
const ele = unrefElement(target);
|
180
|
+
if (ele) {
|
181
|
+
width.value = "offsetWidth" in ele ? ele.offsetWidth : initialSize.width;
|
182
|
+
height.value = "offsetHeight" in ele ? ele.offsetHeight : initialSize.height;
|
183
|
+
}
|
184
|
+
});
|
185
|
+
const stop2 = watch(
|
186
|
+
() => unrefElement(target),
|
187
|
+
(ele) => {
|
188
|
+
width.value = ele ? initialSize.width : 0;
|
189
|
+
height.value = ele ? initialSize.height : 0;
|
190
|
+
}
|
191
|
+
);
|
192
|
+
function stop() {
|
193
|
+
stop1();
|
194
|
+
stop2();
|
195
|
+
}
|
196
|
+
return {
|
197
|
+
width,
|
198
|
+
height,
|
199
|
+
stop
|
200
|
+
};
|
201
|
+
}
|
202
|
+
function useInjectionKey(key) {
|
203
|
+
return Symbol(key);
|
204
|
+
}
|
205
|
+
function useScrollView(options) {
|
206
|
+
const { activeClassName = ".active", enableWheel = true } = options || {};
|
207
|
+
const scrollRef = ref();
|
208
|
+
const { width } = useElementSize(scrollRef);
|
209
|
+
async function scrollToView() {
|
210
|
+
var _a;
|
211
|
+
if (!scrollRef.value)
|
212
|
+
return;
|
213
|
+
await nextTick();
|
214
|
+
const activeEl = (_a = scrollRef.value) == null ? void 0 : _a.children[0].querySelector(activeClassName);
|
215
|
+
if (!activeEl)
|
216
|
+
return;
|
217
|
+
activeEl.scrollIntoView({
|
218
|
+
behavior: "smooth",
|
219
|
+
block: "nearest",
|
220
|
+
inline: "nearest"
|
221
|
+
});
|
222
|
+
}
|
223
|
+
function wheelEvent(e2) {
|
224
|
+
var _a, _b;
|
225
|
+
const { deltaY } = e2;
|
226
|
+
if (deltaY > 0) {
|
227
|
+
(_a = scrollRef.value) == null ? void 0 : _a.scrollBy({
|
228
|
+
top: 0,
|
229
|
+
left: width.value,
|
230
|
+
behavior: "smooth"
|
231
|
+
});
|
232
|
+
} else {
|
233
|
+
(_b = scrollRef.value) == null ? void 0 : _b.scrollBy({
|
234
|
+
top: 0,
|
235
|
+
left: -width.value,
|
236
|
+
behavior: "smooth"
|
237
|
+
});
|
238
|
+
}
|
239
|
+
}
|
240
|
+
function init() {
|
241
|
+
if (!scrollRef.value || !enableWheel)
|
242
|
+
return;
|
243
|
+
scrollRef.value.addEventListener("wheel", wheelEvent);
|
244
|
+
}
|
245
|
+
function destroy() {
|
246
|
+
var _a;
|
247
|
+
(_a = scrollRef.value) == null ? void 0 : _a.removeEventListener("wheel", wheelEvent);
|
248
|
+
}
|
249
|
+
const debouncedScrollToView = useDebounceFn(scrollToView, 500);
|
250
|
+
watch(width, () => {
|
251
|
+
debouncedScrollToView();
|
252
|
+
});
|
253
|
+
onBeforeUnmount(() => {
|
254
|
+
destroy();
|
255
|
+
});
|
256
|
+
onMounted(() => {
|
257
|
+
scrollToView();
|
258
|
+
init();
|
259
|
+
});
|
260
|
+
return {
|
261
|
+
scrollRef,
|
262
|
+
scrollToView
|
263
|
+
};
|
264
|
+
}
|
265
|
+
const _hoisted_1$1 = { class: "uno-iyw1ix" };
|
266
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
267
|
+
__name: "TabItem",
|
268
|
+
props: {
|
269
|
+
name: {},
|
270
|
+
disabled: { type: Boolean },
|
271
|
+
closeable: { type: Boolean },
|
272
|
+
showLine: { type: Boolean },
|
273
|
+
icon: { type: [Function, String] },
|
274
|
+
loading: { type: Boolean },
|
275
|
+
loadingRender: { type: Function, default: () => h$1("i", { class: "i-line-md-loading-twotone-loop", style: { width: `16px`, height: `16px` } }) }
|
276
|
+
},
|
277
|
+
emits: ["close", "click", "contextmenu"],
|
278
|
+
setup(__props, { emit: __emit }) {
|
279
|
+
const emit = __emit;
|
280
|
+
const { activeName, list, pushItem, removeItem, itemClick } = inject(tabsBarInjectionKey) || {};
|
281
|
+
const active = computed(() => (activeName == null ? void 0 : activeName.value) === __props.name);
|
282
|
+
const activeIndex = computed(() => list == null ? void 0 : list.value.findIndex((f2) => f2 === (activeName == null ? void 0 : activeName.value)));
|
283
|
+
const currentIndex = computed(() => list == null ? void 0 : list.value.findIndex((f2) => f2 === __props.name));
|
284
|
+
const showLine = computed(() => (activeIndex == null ? void 0 : activeIndex.value) !== (currentIndex == null ? void 0 : currentIndex.value) && ((activeIndex == null ? void 0 : activeIndex.value) ?? 0) - 1 !== (currentIndex == null ? void 0 : currentIndex.value));
|
285
|
+
function onClose() {
|
286
|
+
removeItem == null ? void 0 : removeItem(__props.name);
|
287
|
+
emit("close");
|
288
|
+
}
|
289
|
+
function onClick(ev) {
|
290
|
+
itemClick == null ? void 0 : itemClick(__props.name);
|
291
|
+
emit("click", ev);
|
292
|
+
}
|
293
|
+
function onContextMenu(ev) {
|
294
|
+
emit("contextmenu", ev);
|
295
|
+
}
|
296
|
+
onMounted(() => {
|
297
|
+
pushItem == null ? void 0 : pushItem(__props.name);
|
298
|
+
});
|
299
|
+
return (_ctx, _cache) => {
|
300
|
+
return openBlock(), createElementBlock("div", {
|
301
|
+
class: normalizeClass(["uno-ubq14l group", [active.value ? "tab-active" : "", _ctx.disabled ? "uno-4y9yog" : ""]]),
|
302
|
+
onClick,
|
303
|
+
onContextmenu: onContextMenu
|
304
|
+
}, [
|
305
|
+
createElementVNode("div", {
|
306
|
+
class: normalizeClass(["uno-qjxywp", active.value ? "" : "uno-epu25o"])
|
307
|
+
}, [
|
308
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.loading ? _ctx.loadingRender : _ctx.icon))),
|
309
|
+
createElementVNode("div", _hoisted_1$1, [
|
310
|
+
renderSlot(_ctx.$slots, "default")
|
311
|
+
]),
|
312
|
+
_ctx.closeable ? (openBlock(), createElementBlock("div", {
|
313
|
+
key: 0,
|
314
|
+
class: "uno-r1pbch",
|
315
|
+
onClick: withModifiers(onClose, ["stop"])
|
316
|
+
}, _cache[0] || (_cache[0] = [
|
317
|
+
createElementVNode("i", { class: "uno-sjjwmq" }, null, -1)
|
318
|
+
]))) : createCommentVNode("", true)
|
319
|
+
], 2),
|
320
|
+
createElementVNode("div", {
|
321
|
+
class: normalizeClass(["uno-mzsdgg", active.value ? "uno-h6cmdc" : "uno-m6t4oj"])
|
322
|
+
}, _cache[1] || (_cache[1] = [
|
323
|
+
createStaticVNode('<svg width="10" height="10" class="uno-3sky1m"><path d="M 0 10 A 10 10 0 0 0 10 0 L 10 10 Z"></path></svg><div class="uno-nylnxp"></div><svg width="10" height="10" class="uno-3sky1m"><path d="M 0 0 A 10 10 0 0 0 10 10 L 0 10 Z"></path></svg>', 3)
|
324
|
+
]), 2),
|
325
|
+
createElementVNode("div", {
|
326
|
+
class: normalizeClass([showLine.value ? "uno-h6cmdc" : "uno-m6t4oj", "uno-wqscdb"])
|
327
|
+
}, null, 2)
|
328
|
+
], 34);
|
329
|
+
};
|
330
|
+
}
|
331
|
+
});
|
332
|
+
var r = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, t = function(r2) {
|
333
|
+
return "string" == typeof r2 ? r2.length > 0 : "number" == typeof r2;
|
334
|
+
}, n = function(r2, t2, n2) {
|
335
|
+
return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r2) / n2 + 0;
|
336
|
+
}, e = function(r2, t2, n2) {
|
337
|
+
return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r2 > n2 ? n2 : r2 > t2 ? r2 : t2;
|
338
|
+
}, u = function(r2) {
|
339
|
+
return (r2 = isFinite(r2) ? r2 % 360 : 0) > 0 ? r2 : r2 + 360;
|
340
|
+
}, a = function(r2) {
|
341
|
+
return { r: e(r2.r, 0, 255), g: e(r2.g, 0, 255), b: e(r2.b, 0, 255), a: e(r2.a) };
|
342
|
+
}, o = function(r2) {
|
343
|
+
return { r: n(r2.r), g: n(r2.g), b: n(r2.b), a: n(r2.a, 3) };
|
344
|
+
}, i = /^#([0-9a-f]{3,8})$/i, s = function(r2) {
|
345
|
+
var t2 = r2.toString(16);
|
346
|
+
return t2.length < 2 ? "0" + t2 : t2;
|
347
|
+
}, h = function(r2) {
|
348
|
+
var t2 = r2.r, n2 = r2.g, e2 = r2.b, u2 = r2.a, a2 = Math.max(t2, n2, e2), o2 = a2 - Math.min(t2, n2, e2), i2 = o2 ? a2 === t2 ? (n2 - e2) / o2 : a2 === n2 ? 2 + (e2 - t2) / o2 : 4 + (t2 - n2) / o2 : 0;
|
349
|
+
return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
|
350
|
+
}, b = function(r2) {
|
351
|
+
var t2 = r2.h, n2 = r2.s, e2 = r2.v, u2 = r2.a;
|
352
|
+
t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
|
353
|
+
var a2 = Math.floor(t2), o2 = e2 * (1 - n2), i2 = e2 * (1 - (t2 - a2) * n2), s2 = e2 * (1 - (1 - t2 + a2) * n2), h2 = a2 % 6;
|
354
|
+
return { r: 255 * [e2, i2, o2, o2, s2, e2][h2], g: 255 * [s2, e2, e2, i2, o2, o2][h2], b: 255 * [o2, o2, s2, e2, e2, i2][h2], a: u2 };
|
355
|
+
}, g = function(r2) {
|
356
|
+
return { h: u(r2.h), s: e(r2.s, 0, 100), l: e(r2.l, 0, 100), a: e(r2.a) };
|
357
|
+
}, d = function(r2) {
|
358
|
+
return { h: n(r2.h), s: n(r2.s), l: n(r2.l), a: n(r2.a, 3) };
|
359
|
+
}, f = function(r2) {
|
360
|
+
return b((n2 = (t2 = r2).s, { h: t2.h, s: (n2 *= ((e2 = t2.l) < 50 ? e2 : 100 - e2) / 100) > 0 ? 2 * n2 / (e2 + n2) * 100 : 0, v: e2 + n2, a: t2.a }));
|
361
|
+
var t2, n2, e2;
|
362
|
+
}, c = function(r2) {
|
363
|
+
return { h: (t2 = h(r2)).h, s: (u2 = (200 - (n2 = t2.s)) * (e2 = t2.v) / 100) > 0 && u2 < 200 ? n2 * e2 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t2.a };
|
364
|
+
var t2, n2, e2, u2;
|
365
|
+
}, l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, y = { string: [[function(r2) {
|
366
|
+
var t2 = i.exec(r2);
|
367
|
+
return t2 ? (r2 = t2[1]).length <= 4 ? { r: parseInt(r2[0] + r2[0], 16), g: parseInt(r2[1] + r2[1], 16), b: parseInt(r2[2] + r2[2], 16), a: 4 === r2.length ? n(parseInt(r2[3] + r2[3], 16) / 255, 2) : 1 } : 6 === r2.length || 8 === r2.length ? { r: parseInt(r2.substr(0, 2), 16), g: parseInt(r2.substr(2, 2), 16), b: parseInt(r2.substr(4, 2), 16), a: 8 === r2.length ? n(parseInt(r2.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
368
|
+
}, "hex"], [function(r2) {
|
369
|
+
var t2 = v.exec(r2) || m.exec(r2);
|
370
|
+
return t2 ? t2[2] !== t2[4] || t2[4] !== t2[6] ? null : a({ r: Number(t2[1]) / (t2[2] ? 100 / 255 : 1), g: Number(t2[3]) / (t2[4] ? 100 / 255 : 1), b: Number(t2[5]) / (t2[6] ? 100 / 255 : 1), a: void 0 === t2[7] ? 1 : Number(t2[7]) / (t2[8] ? 100 : 1) }) : null;
|
371
|
+
}, "rgb"], [function(t2) {
|
372
|
+
var n2 = l.exec(t2) || p.exec(t2);
|
373
|
+
if (!n2) return null;
|
374
|
+
var e2, u2, a2 = g({ h: (e2 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e2) * (r[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) });
|
375
|
+
return f(a2);
|
376
|
+
}, "hsl"]], object: [[function(r2) {
|
377
|
+
var n2 = r2.r, e2 = r2.g, u2 = r2.b, o2 = r2.a, i2 = void 0 === o2 ? 1 : o2;
|
378
|
+
return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
|
379
|
+
}, "rgb"], [function(r2) {
|
380
|
+
var n2 = r2.h, e2 = r2.s, u2 = r2.l, a2 = r2.a, o2 = void 0 === a2 ? 1 : a2;
|
381
|
+
if (!t(n2) || !t(e2) || !t(u2)) return null;
|
382
|
+
var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
|
383
|
+
return f(i2);
|
384
|
+
}, "hsl"], [function(r2) {
|
385
|
+
var n2 = r2.h, a2 = r2.s, o2 = r2.v, i2 = r2.a, s2 = void 0 === i2 ? 1 : i2;
|
386
|
+
if (!t(n2) || !t(a2) || !t(o2)) return null;
|
387
|
+
var h2 = function(r3) {
|
388
|
+
return { h: u(r3.h), s: e(r3.s, 0, 100), v: e(r3.v, 0, 100), a: e(r3.a) };
|
389
|
+
}({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
|
390
|
+
return b(h2);
|
391
|
+
}, "hsv"]] }, N = function(r2, t2) {
|
392
|
+
for (var n2 = 0; n2 < t2.length; n2++) {
|
393
|
+
var e2 = t2[n2][0](r2);
|
394
|
+
if (e2) return [e2, t2[n2][1]];
|
395
|
+
}
|
396
|
+
return [null, void 0];
|
397
|
+
}, x = function(r2) {
|
398
|
+
return "string" == typeof r2 ? N(r2.trim(), y.string) : "object" == typeof r2 && null !== r2 ? N(r2, y.object) : [null, void 0];
|
399
|
+
}, M = function(r2, t2) {
|
400
|
+
var n2 = c(r2);
|
401
|
+
return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
|
402
|
+
}, H = function(r2) {
|
403
|
+
return (299 * r2.r + 587 * r2.g + 114 * r2.b) / 1e3 / 255;
|
404
|
+
}, $ = function(r2, t2) {
|
405
|
+
var n2 = c(r2);
|
406
|
+
return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
|
407
|
+
}, j = function() {
|
408
|
+
function r2(r3) {
|
409
|
+
this.parsed = x(r3)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
410
|
+
}
|
411
|
+
return r2.prototype.isValid = function() {
|
412
|
+
return null !== this.parsed;
|
413
|
+
}, r2.prototype.brightness = function() {
|
414
|
+
return n(H(this.rgba), 2);
|
415
|
+
}, r2.prototype.isDark = function() {
|
416
|
+
return H(this.rgba) < 0.5;
|
417
|
+
}, r2.prototype.isLight = function() {
|
418
|
+
return H(this.rgba) >= 0.5;
|
419
|
+
}, r2.prototype.toHex = function() {
|
420
|
+
return r3 = o(this.rgba), t2 = r3.r, e2 = r3.g, u2 = r3.b, i2 = (a2 = r3.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t2) + s(e2) + s(u2) + i2;
|
421
|
+
var r3, t2, e2, u2, a2, i2;
|
422
|
+
}, r2.prototype.toRgb = function() {
|
423
|
+
return o(this.rgba);
|
424
|
+
}, r2.prototype.toRgbString = function() {
|
425
|
+
return r3 = o(this.rgba), t2 = r3.r, n2 = r3.g, e2 = r3.b, (u2 = r3.a) < 1 ? "rgba(" + t2 + ", " + n2 + ", " + e2 + ", " + u2 + ")" : "rgb(" + t2 + ", " + n2 + ", " + e2 + ")";
|
426
|
+
var r3, t2, n2, e2, u2;
|
427
|
+
}, r2.prototype.toHsl = function() {
|
428
|
+
return d(c(this.rgba));
|
429
|
+
}, r2.prototype.toHslString = function() {
|
430
|
+
return r3 = d(c(this.rgba)), t2 = r3.h, n2 = r3.s, e2 = r3.l, (u2 = r3.a) < 1 ? "hsla(" + t2 + ", " + n2 + "%, " + e2 + "%, " + u2 + ")" : "hsl(" + t2 + ", " + n2 + "%, " + e2 + "%)";
|
431
|
+
var r3, t2, n2, e2, u2;
|
432
|
+
}, r2.prototype.toHsv = function() {
|
433
|
+
return r3 = h(this.rgba), { h: n(r3.h), s: n(r3.s), v: n(r3.v), a: n(r3.a, 3) };
|
434
|
+
var r3;
|
435
|
+
}, r2.prototype.invert = function() {
|
436
|
+
return w({ r: 255 - (r3 = this.rgba).r, g: 255 - r3.g, b: 255 - r3.b, a: r3.a });
|
437
|
+
var r3;
|
438
|
+
}, r2.prototype.saturate = function(r3) {
|
439
|
+
return void 0 === r3 && (r3 = 0.1), w(M(this.rgba, r3));
|
440
|
+
}, r2.prototype.desaturate = function(r3) {
|
441
|
+
return void 0 === r3 && (r3 = 0.1), w(M(this.rgba, -r3));
|
442
|
+
}, r2.prototype.grayscale = function() {
|
443
|
+
return w(M(this.rgba, -1));
|
444
|
+
}, r2.prototype.lighten = function(r3) {
|
445
|
+
return void 0 === r3 && (r3 = 0.1), w($(this.rgba, r3));
|
446
|
+
}, r2.prototype.darken = function(r3) {
|
447
|
+
return void 0 === r3 && (r3 = 0.1), w($(this.rgba, -r3));
|
448
|
+
}, r2.prototype.rotate = function(r3) {
|
449
|
+
return void 0 === r3 && (r3 = 15), this.hue(this.hue() + r3);
|
450
|
+
}, r2.prototype.alpha = function(r3) {
|
451
|
+
return "number" == typeof r3 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r3 }) : n(this.rgba.a, 3);
|
452
|
+
var t2;
|
453
|
+
}, r2.prototype.hue = function(r3) {
|
454
|
+
var t2 = c(this.rgba);
|
455
|
+
return "number" == typeof r3 ? w({ h: r3, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
|
456
|
+
}, r2.prototype.isEqual = function(r3) {
|
457
|
+
return this.toHex() === w(r3).toHex();
|
458
|
+
}, r2;
|
459
|
+
}(), w = function(r2) {
|
460
|
+
return r2 instanceof j ? r2 : new j(r2);
|
461
|
+
};
|
462
|
+
const _hoisted_1 = { class: "uno-5zyl8j" };
|
463
|
+
const _hoisted_2 = { class: "uno-ov60i3" };
|
464
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
465
|
+
__name: "Tabs",
|
466
|
+
props: /* @__PURE__ */ mergeModels({
|
467
|
+
backgroundColor: { default: "#E5E7EB" },
|
468
|
+
activeBackgroundColor: { default: "#fff" },
|
469
|
+
primaryColor: { default: "rgba(251,191,36,1)" }
|
470
|
+
}, {
|
471
|
+
"value": {},
|
472
|
+
"valueModifiers": {}
|
473
|
+
}),
|
474
|
+
emits: /* @__PURE__ */ mergeModels(["close"], ["update:value"]),
|
475
|
+
setup(__props, { emit: __emit }) {
|
476
|
+
const emit = __emit;
|
477
|
+
const value = useModel(__props, "value");
|
478
|
+
const { scrollRef, scrollToView } = useScrollView({ activeClassName: ".tab-active" });
|
479
|
+
watch(value, () => {
|
480
|
+
scrollToView();
|
481
|
+
});
|
482
|
+
const list = ref([]);
|
483
|
+
const activeName = computed(() => list.value.find((f2) => f2 === value.value));
|
484
|
+
provide(tabsBarInjectionKey, {
|
485
|
+
list,
|
486
|
+
activeName,
|
487
|
+
pushItem(name) {
|
488
|
+
list.value.push(name);
|
489
|
+
},
|
490
|
+
removeItem(name) {
|
491
|
+
emit("close", name);
|
492
|
+
nextTick(() => {
|
493
|
+
scrollToView();
|
494
|
+
});
|
495
|
+
},
|
496
|
+
itemClick(name) {
|
497
|
+
value.value = name;
|
498
|
+
}
|
499
|
+
});
|
500
|
+
const backgroundColorDark = computed(() => w(__props.backgroundColor).darken(0.8).toHex());
|
501
|
+
const activeBackgroundColorDark = computed(() => w(__props.activeBackgroundColor).darken(0.8).toHex());
|
502
|
+
const primaryColorDark = computed(() => w(__props.primaryColor).darken(0.3).toHex());
|
503
|
+
return (_ctx, _cache) => {
|
504
|
+
return openBlock(), createElementBlock("div", {
|
505
|
+
class: "uno-f9asjx",
|
506
|
+
style: normalizeStyle({
|
507
|
+
"--tabs-bar-background-color": `${_ctx.backgroundColor}`,
|
508
|
+
"--tabs-bar-background-color-dark": `${backgroundColorDark.value}`,
|
509
|
+
"--tabs-bar-active-background-color": `${_ctx.activeBackgroundColor}`,
|
510
|
+
"--tabs-bar-active-background-color-dark": `${activeBackgroundColorDark.value}`,
|
511
|
+
"--tabs-bar-primary-color": `${_ctx.primaryColor}`,
|
512
|
+
"--tabs-bar-primary-color-dark": `${primaryColorDark.value}`
|
513
|
+
})
|
514
|
+
}, [
|
515
|
+
createElementVNode("div", _hoisted_1, [
|
516
|
+
createElementVNode("div", _hoisted_2, [
|
517
|
+
renderSlot(_ctx.$slots, "prefix", {}, () => [
|
518
|
+
_cache[0] || (_cache[0] = createElementVNode("div", { class: "uno-kq7run" }, [
|
519
|
+
createElementVNode("i", { class: "i-ri-arrow-down-s-line" })
|
520
|
+
], -1))
|
521
|
+
])
|
522
|
+
]),
|
523
|
+
createElementVNode("div", {
|
524
|
+
ref_key: "scrollRef",
|
525
|
+
ref: scrollRef,
|
526
|
+
class: "uno-23n4xq"
|
527
|
+
}, [
|
528
|
+
createVNode(TransitionGroup, {
|
529
|
+
name: "group",
|
530
|
+
tag: "div",
|
531
|
+
class: "uno-r0jwks"
|
532
|
+
}, {
|
533
|
+
default: withCtx(() => [
|
534
|
+
renderSlot(_ctx.$slots, "default")
|
535
|
+
]),
|
536
|
+
_: 3
|
537
|
+
})
|
538
|
+
], 512),
|
539
|
+
renderSlot(_ctx.$slots, "suffix")
|
540
|
+
]),
|
541
|
+
_cache[1] || (_cache[1] = createElementVNode("div", { class: "uno-kfa0e9" }, null, -1))
|
542
|
+
], 4);
|
543
|
+
};
|
544
|
+
}
|
545
|
+
});
|
546
|
+
const tabsBarInjectionKey = useInjectionKey("tabs-bar-injection-key");
|
547
|
+
export {
|
548
|
+
_sfc_main$1 as CTabItem,
|
549
|
+
_sfc_main as CTabs,
|
550
|
+
tabsBarInjectionKey
|
551
|
+
};
|