itube-specs 0.0.230 → 0.0.232

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.
@@ -6,7 +6,7 @@
6
6
  </template>
7
7
 
8
8
  <script setup lang="ts">
9
- import type { IChipsItem, IModelFilter } from '../../types';
9
+ import type { IChipsItem, IModelFilter, IModelFilterOptions } from '../../types';
10
10
  import type { LocationQueryValue } from '#vue-router';
11
11
  import { useRoute, useRouter } from '#vue-router';
12
12
  import { getMonth } from '../../runtime';
@@ -42,28 +42,33 @@ const chipsItems = computed(() => {
42
42
  }, {})
43
43
  )
44
44
 
45
- const title = (item: string, index: number) => {
45
+ const getValue = (item: string, index: number) => {
46
46
  const filter = props.filters.find(filter => {
47
47
  return filter.name === `${item.replace(/ /g, '_')
48
48
  .replace('_from', '')
49
49
  .replace('_to', '')
50
50
  }`
51
51
  });
52
- const defaultValue = index === 0 ? filter?.options[ 0 ] : filter?.options[ filter.options.length - 1 ]
52
+ const defaultValue = index === 0 ? filter?.options[ 0 ] : filter?.options[ filter.options.length - 1 ];
53
53
  const value: LocationQueryValue | LocationQueryValue[] = route.query[ `filter_${item.replace(/ /g, '_')}` ];
54
- if (item.split(' ').some(item => item === 'month')) {
55
- return getMonth(t, Number(value) - 1 || Number(defaultValue) - 1)
54
+ const result = () => {
55
+ if (item.split(' ').some(item => item === 'month')) {
56
+ return getMonth(t, Number(value) - 1 || Number(defaultValue) - 1);
57
+ } else {
58
+ return filter?.options.find((option: IModelFilterOptions) => option.name === value)?.title;
59
+ }
56
60
  }
57
- return value || Number(defaultValue) - 1;
61
+ return result() || Number(defaultValue) - 1;
58
62
  }
59
63
 
60
- const text = (item: string[]) => [...new Set(item.map((subItem, index) => title(subItem, index)))].join(' - ');
64
+ const getValueText = (item: string[]) => [...new Set(item.map((subItem, index) => getValue(subItem, index)))].join(' - ');
61
65
 
62
66
  const chipsTitle = ((item: string[]) => {
63
67
  const key = Array.isArray(item) ? item[0].replace(' from', '') : item;
64
- const convertedKey = props.filters.find(item => item.name.replace(/_/g, ' ') === key)?.title;
65
- const textValue = `${convertedKey}: ${text(item)}`;
66
- return textValue.length > 30 ? text(item) : textValue;
68
+ const convertedKey = props.filters.find(item => item.name.replace(/_/g, ' ') === key)?.name;
69
+ const filter = props.filters.find(item => item.name === convertedKey);
70
+ const textValue = `${filter?.title}: ${getValueText(item)}`;
71
+ return textValue.length > 30 ? getValueText(item) : textValue;
67
72
  })
68
73
 
69
74
  return groups.map((item) => ({
@@ -31,7 +31,7 @@
31
31
  v-for="(item, index) in scheme"
32
32
  :name="item.title"
33
33
  :key="`scheme-${index}`"
34
- v-model="filterValue[item.title.toLowerCase()]"
34
+ v-model="filterValue[item.name.toLowerCase()]"
35
35
  :items="item.items"
36
36
  :label="item?.label"
37
37
  :placeholder="item.placeholder"
@@ -6,7 +6,8 @@
6
6
  </template>
7
7
 
8
8
  <script setup lang="ts">
9
- import type { IChipsItem, ISelectItem } from '../../types';
9
+ import type { IChipsItem, ISelectItem, IFilterScheme } from '../../types';
10
+ import { convertString } from '../../runtime';
10
11
 
11
12
  const route = useRoute();
12
13
  const router = useRouter();
@@ -14,6 +15,7 @@ const router = useRouter();
14
15
  const props = defineProps<{
15
16
  addedItems: ISelectItem[]
16
17
  durationItems: ISelectItem[]
18
+ scheme: IFilterScheme[]
17
19
  }>()
18
20
 
19
21
  const chipsItems = computed(() => {
@@ -26,9 +28,14 @@ const chipsItems = computed(() => {
26
28
  ? categoriesParam.flatMap(c => c.split(','))
27
29
  : categoriesParam.split(',');
28
30
  categories.forEach(cat => {
29
- const title = cat.split('_')[1] ?? cat;
31
+ const value = cat.split('_')[1] ?? cat;
32
+ const groupCategory = cat.split('_')[0];
33
+ const title = props.scheme.find(item => {
34
+ return item.name === convertString().toCapitalize(groupCategory)
35
+ })?.items.find((item: ISelectItem) => item.value === value)?.title;
36
+
30
37
  items.push({
31
- title,
38
+ title: title || '',
32
39
  value: cat,
33
40
  key: 'categories'
34
41
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.230",
4
+ "version": "0.0.232",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {
@@ -2,10 +2,8 @@ import type { ISelectItem } from '../types';
2
2
 
3
3
  export interface IFilterScheme {
4
4
  title: string
5
- className?: string
6
5
  label?: string
7
- wide?: boolean
8
- fixed?: boolean
9
6
  items: ISelectItem[]
10
7
  placeholder: string
8
+ name: string
11
9
  }