itube-specs 0.0.324 → 0.0.325
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.
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
/>
|
|
22
22
|
{{ name }}
|
|
23
23
|
<SIcon
|
|
24
|
-
v-if="(isActive && !
|
|
24
|
+
v-if="(isActive && !mini && item.resetPath) || withClose"
|
|
25
25
|
class="s-chips__close"
|
|
26
26
|
name="close"
|
|
27
27
|
size="16"
|
|
@@ -34,83 +34,90 @@ import type { IChipsItem } from '../../types';
|
|
|
34
34
|
import { convertString } from '../../runtime';
|
|
35
35
|
|
|
36
36
|
const props = defineProps<{
|
|
37
|
-
item: IChipsItem
|
|
38
|
-
allLink?: boolean
|
|
39
|
-
alphabet?: boolean
|
|
40
|
-
active?: boolean
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}>()
|
|
37
|
+
item: IChipsItem;
|
|
38
|
+
allLink?: boolean;
|
|
39
|
+
alphabet?: boolean;
|
|
40
|
+
active?: boolean;
|
|
41
|
+
withClose?: boolean;
|
|
42
|
+
isLink?: boolean;
|
|
43
|
+
mini?: boolean;
|
|
44
|
+
bright?: boolean;
|
|
45
|
+
notCapitalize?: boolean;
|
|
46
|
+
}>();
|
|
48
47
|
|
|
49
48
|
const emit = defineEmits<{
|
|
50
|
-
(eventName: 'click'): void
|
|
51
|
-
}>()
|
|
49
|
+
(eventName: 'click'): void;
|
|
50
|
+
}>();
|
|
52
51
|
|
|
53
|
-
const route = useRoute()
|
|
52
|
+
const route = useRoute();
|
|
54
53
|
|
|
55
|
-
const { generateLink } = useGenerateLink();
|
|
56
|
-
|
|
57
|
-
const isActive = computed(() => {
|
|
58
|
-
if (props.active || props.item.value === 'reset' && !route.params.slug) {
|
|
59
|
-
return true
|
|
60
|
-
}
|
|
61
|
-
return ((convertString().fromSlug(String(route.params.slug))).toLowerCase() === props.item.title.toLowerCase()) && route.path.includes(props.item.prefix || '');
|
|
62
|
-
})
|
|
63
54
|
const component = computed(() => {
|
|
64
55
|
if (props.isLink) {
|
|
65
|
-
return resolveComponent('NuxtLink')
|
|
56
|
+
return resolveComponent('NuxtLink');
|
|
66
57
|
}
|
|
67
|
-
return 'button'
|
|
68
|
-
})
|
|
58
|
+
return 'button';
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const { generateLink } = useGenerateLink();
|
|
69
62
|
|
|
70
|
-
const
|
|
63
|
+
const targetPath = computed(() => {
|
|
71
64
|
if (props.item.value === 'reset') {
|
|
72
|
-
|
|
73
|
-
return `/${props.item.prefix}`
|
|
65
|
+
return props.item.resetPath ? `/${props.item.resetPath}` : '/';
|
|
74
66
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return `/${props.item.value}
|
|
67
|
+
|
|
68
|
+
if (props.allLink && props.item.value) {
|
|
69
|
+
return `/${props.item.value}`;
|
|
78
70
|
}
|
|
71
|
+
|
|
79
72
|
if (props.item.value && props.item.prefix) {
|
|
80
|
-
|
|
81
|
-
// возврат, при активном состоянии
|
|
82
|
-
return props.alphabet ? `/${props.item.prefix}` : '/';
|
|
83
|
-
}
|
|
84
|
-
if (props.alphabet) {
|
|
85
|
-
return `/${props.item.prefix}/letter/${convertString().toSlug(props.item.title)}`;
|
|
86
|
-
}
|
|
87
|
-
return `/${props.item.prefix}/${convertString().toSlug(String(props.item.value))}`;
|
|
73
|
+
return `${props.item.prefix}/${convertString().toSlug(String(props.item.value))}`;
|
|
88
74
|
}
|
|
89
|
-
return ''
|
|
90
|
-
})
|
|
91
75
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
76
|
+
if (props.item.value === '' && props.item.prefix) {
|
|
77
|
+
return `${props.item.prefix}`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return '';
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const isActive = computed(() => {
|
|
84
|
+
if (props.active) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
if (!props.isLink || !targetPath.value) {
|
|
88
|
+
return false;
|
|
100
89
|
}
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
|
|
91
|
+
const current = route.path.replace(/^\/|\/$/g, '');
|
|
92
|
+
const target = targetPath.value.replace(/^\/|\/$/g, '');
|
|
93
|
+
|
|
94
|
+
return current === target;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const href = computed<string | undefined>(() => {
|
|
98
|
+
if (!props.isLink) return undefined;
|
|
99
|
+
|
|
100
|
+
if (isActive.value && props.item.resetPath) {
|
|
101
|
+
return generateLink(props.item.resetPath ? `/${props.item.resetPath}` : '/');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (targetPath.value) {
|
|
105
|
+
return generateLink(targetPath.value);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return undefined;
|
|
109
|
+
});
|
|
103
110
|
|
|
104
111
|
function onButtonClick() {
|
|
105
112
|
if (!props.isLink) {
|
|
106
|
-
emit('click')
|
|
113
|
+
emit('click');
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
const name = computed(() => {
|
|
111
118
|
if (props.item?.title.toLowerCase() === 'post') {
|
|
112
|
-
return '#'
|
|
119
|
+
return '#';
|
|
113
120
|
}
|
|
114
|
-
return props.item.title
|
|
115
|
-
})
|
|
121
|
+
return props.item.title;
|
|
122
|
+
});
|
|
116
123
|
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IChipsItem } from '../types';
|
|
2
|
+
|
|
3
|
+
export function useConvertStringArrayToChips(array: string[], prefix: string, resetPath: string) {
|
|
4
|
+
const alphabetItems = computed<IChipsItem[]>(() => {
|
|
5
|
+
return array.map((item) => ({
|
|
6
|
+
title: item,
|
|
7
|
+
value: item,
|
|
8
|
+
prefix: prefix,
|
|
9
|
+
resetPath: resetPath,
|
|
10
|
+
}));
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return { alphabetItems };
|
|
14
|
+
}
|