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