@webitel/ui-datalist 1.1.75 → 1.1.76
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 +1 -1
- package/src/modules/card/composables/useCardListNavigation.ts +30 -0
- package/src/modules/card/composables/useCardTabs.ts +38 -0
- package/src/modules/card/index.ts +2 -0
- package/types/.tsbuildinfo +1 -1
- package/types/modules/card/composables/useCardListNavigation.d.ts +10 -0
- package/types/modules/card/composables/useCardTabs.d.ts +9 -0
- package/types/modules/card/index.d.ts +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Opens a nested-card popup on the same route by setting/replacing its
|
|
5
|
+
* optional route param (e.g. `phones/:commId?`). `open()` or `open('new')`
|
|
6
|
+
* opens the "add" card, `open(id)` opens an existing one.
|
|
7
|
+
*/
|
|
8
|
+
export const useCardListNavigation = ({
|
|
9
|
+
routeParamName,
|
|
10
|
+
}: {
|
|
11
|
+
routeParamName: string;
|
|
12
|
+
}) => {
|
|
13
|
+
const route = useRoute();
|
|
14
|
+
const router = useRouter();
|
|
15
|
+
|
|
16
|
+
const open = (id: string = 'new') => {
|
|
17
|
+
return router.push({
|
|
18
|
+
name: route.name,
|
|
19
|
+
params: {
|
|
20
|
+
...route.params,
|
|
21
|
+
[routeParamName]: id,
|
|
22
|
+
},
|
|
23
|
+
query: route.query,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
open,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ComputedRef, computed, type Ref } from 'vue';
|
|
2
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
3
|
+
|
|
4
|
+
export interface CardTab {
|
|
5
|
+
pathName: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useCardTabs = <T extends CardTab>(
|
|
10
|
+
tabs: Ref<T[]> | ComputedRef<T[]>,
|
|
11
|
+
) => {
|
|
12
|
+
const router = useRouter();
|
|
13
|
+
const route = useRoute();
|
|
14
|
+
|
|
15
|
+
const currentTab = computed<T | undefined>(() => {
|
|
16
|
+
return (
|
|
17
|
+
tabs.value.find(({ pathName }) =>
|
|
18
|
+
route.matched.some(({ name }) => name === pathName),
|
|
19
|
+
) || tabs.value[0]
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function changeTab(tab: T) {
|
|
24
|
+
const { params, query, hash } = route;
|
|
25
|
+
|
|
26
|
+
return router.push({
|
|
27
|
+
name: tab.pathName,
|
|
28
|
+
params,
|
|
29
|
+
query,
|
|
30
|
+
hash,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
currentTab,
|
|
36
|
+
changeTab,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from './composables/useCardComponent';
|
|
2
|
+
export * from './composables/useCardListNavigation';
|
|
3
|
+
export * from './composables/useCardTabs';
|
|
2
4
|
export * from './composables/useNestedCardComponent';
|
|
3
5
|
export * from './stores/createCardStore';
|
|
4
6
|
export * from './types/CardValidationFields.types';
|