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 && !withoutClose && item.value !== 'reset' && !mini) || withClose"
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
- withoutClose?: boolean
42
- withClose?: boolean
43
- isLink?: boolean
44
- mini?: boolean
45
- bright?: boolean
46
- notCapitalize?: boolean
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 link = computed(() => {
63
+ const targetPath = computed(() => {
71
64
  if (props.item.value === 'reset') {
72
- // клик по popular
73
- return `/${props.item.prefix}`
65
+ return props.item.resetPath ? `/${props.item.resetPath}` : '/';
74
66
  }
75
- if (props.allLink) {
76
- // временно пока не перешли на value
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
- if (route.params.slug === props.item.title) {
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
- const href = computed(() => {
93
- if (props.isLink) {
94
- if (convertString().fromSlug(String(route.params.slug)).toLowerCase() === props.item.title.toLowerCase() && route.path.includes(props.item?.prefix || '')) {
95
- return generateLink(props.item?.prefix || '')
96
- } else if ((props.item.value && props.item.prefix) || props.allLink) {
97
- return generateLink(link.value)
98
- }
99
- return generateLink(`/${props.item?.prefix}/${link.value}`)
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
- return null
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
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.324",
4
+ "version": "0.0.325",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {