sprintify-ui 0.8.5 → 0.8.6
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/package.json
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<li
|
|
2
|
+
<li
|
|
3
|
+
ref="baseTabItemRef"
|
|
4
|
+
class="[&:first-child_a]:pl-0 [&:last-child_a]:pr-0"
|
|
5
|
+
>
|
|
3
6
|
<RouterLink
|
|
4
7
|
v-slot="{ href, navigate, isActive, isExactActive }"
|
|
5
8
|
:to="to"
|
|
@@ -36,6 +39,7 @@
|
|
|
36
39
|
</template>
|
|
37
40
|
|
|
38
41
|
<script lang="ts" setup>
|
|
42
|
+
import { useElementBounding } from '@vueuse/core';
|
|
39
43
|
import { NavigationFailure, RouteLocationRaw } from 'vue-router';
|
|
40
44
|
|
|
41
45
|
const props = withDefaults(
|
|
@@ -51,6 +55,7 @@ const props = withDefaults(
|
|
|
51
55
|
);
|
|
52
56
|
|
|
53
57
|
const size = inject('tabs:size', ref<'xs' | 'sm' | 'md' | 'lg'>('md'));
|
|
58
|
+
const animate = inject('tabs:animate', () => { });
|
|
54
59
|
|
|
55
60
|
function onClick(navigate: () => Promise<void | NavigationFailure>) {
|
|
56
61
|
if (props.disabled) {
|
|
@@ -64,6 +69,18 @@ function isActiveInternal(isActive: boolean, isExactActive: boolean) {
|
|
|
64
69
|
return props.activeStrategy == 'default' ? isActive : isExactActive;
|
|
65
70
|
}
|
|
66
71
|
|
|
72
|
+
const baseTabItemRef = ref<HTMLElement | null>(null);
|
|
73
|
+
|
|
74
|
+
const { x, y, width } = useElementBounding(baseTabItemRef);
|
|
75
|
+
|
|
76
|
+
watch(
|
|
77
|
+
() => x.value + '-' + y.value + '-' + width.value,
|
|
78
|
+
() => {
|
|
79
|
+
animate();
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
|
|
67
84
|
const sizeClassOuter = computed(() => {
|
|
68
85
|
switch (size.value) {
|
|
69
86
|
case 'xs':
|
|
@@ -21,7 +21,14 @@ const Template = (args) => ({
|
|
|
21
21
|
BaseCounter,
|
|
22
22
|
},
|
|
23
23
|
setup() {
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
const label = ref('Home');
|
|
26
|
+
|
|
27
|
+
setInterval(() => {
|
|
28
|
+
label.value = Math.random().toString(36).substring(7);
|
|
29
|
+
}, 1000);
|
|
30
|
+
|
|
31
|
+
return { args, label };
|
|
25
32
|
},
|
|
26
33
|
template: `
|
|
27
34
|
<div class="bg-slate-100 py-10">
|
|
@@ -29,7 +36,7 @@ const Template = (args) => ({
|
|
|
29
36
|
<BaseTabs v-bind="args">
|
|
30
37
|
<BaseTabItem to="/" v-slot="{active}">
|
|
31
38
|
<div class="flex items-center">
|
|
32
|
-
<span class="mr-1">
|
|
39
|
+
<span class="mr-1">{{ label }}</span>
|
|
33
40
|
<BaseCounter
|
|
34
41
|
:size="['lg', 'md'].includes(args.size) ? 'sm' : 'xs'"
|
|
35
42
|
:color="active ? 'primary' : 'light'"
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
</template>
|
|
26
26
|
|
|
27
27
|
<script lang="ts" setup>
|
|
28
|
+
import { debounce } from 'lodash';
|
|
29
|
+
|
|
28
30
|
const props = withDefaults(
|
|
29
31
|
defineProps<{
|
|
30
32
|
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
@@ -52,6 +54,12 @@ provide(
|
|
|
52
54
|
computed(() => props.size)
|
|
53
55
|
);
|
|
54
56
|
|
|
57
|
+
provide(
|
|
58
|
+
'tabs:animate',
|
|
59
|
+
debounce(animateLine, 100)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
|
|
55
63
|
function getActiveTab(): HTMLElement | null {
|
|
56
64
|
|
|
57
65
|
if (!scrollable.value) {
|