@ramathibodi/nuxt-commons 0.1.0 → 0.1.2

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/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.1.0"
7
+ "version": "0.1.2"
8
8
  }
@@ -1,19 +0,0 @@
1
- import { type InjectionKey, type ComputedRef, type Ref } from 'vue';
2
- import { type RouteRecordNormalized, type RouteRecordRaw } from 'vue-router';
3
- export interface MenuItem {
4
- title: string;
5
- icon: string;
6
- role: string;
7
- link: any;
8
- menuItems: Array<MenuItem>;
9
- active: boolean;
10
- name: string;
11
- }
12
- export interface MenuProvide {
13
- menuAll: Ref<MenuItem[]>;
14
- menuByRoute: ComputedRef<MenuItem[]>;
15
- }
16
- export declare const MenuKey: InjectionKey<MenuProvide>;
17
- export declare function routeToMenuItem(route: RouteRecordRaw | RouteRecordNormalized): MenuItem | undefined;
18
- export declare function createMenu(): void;
19
- export declare function useMenu(): MenuProvide | null;
@@ -1,4 +1,4 @@
1
- import { inject, provide, ref, computed } from "vue";
1
+ import { inject, provide, ref } from "vue";
2
2
  import { useRoute, useRouter } from "vue-router";
3
3
  import { isUndefined } from "lodash-es";
4
4
  export const MenuKey = Symbol.for("ramacare:menu");
@@ -43,7 +43,7 @@ export function createMenu() {
43
43
  }
44
44
  }
45
45
  provide(MenuKey, {
46
- menuByRoute: computed(() => {
46
+ menuByRoute: () => {
47
47
  const route = useRoute();
48
48
  for (const menuItem of menuAll.value) {
49
49
  if (menuItem.name == route.path.split("/")[1]) {
@@ -51,7 +51,7 @@ export function createMenu() {
51
51
  }
52
52
  }
53
53
  return [];
54
- }),
54
+ },
55
55
  menuAll
56
56
  });
57
57
  }
@@ -10,6 +10,16 @@ declare global {
10
10
  icon: string
11
11
  role: string
12
12
  }
13
+
14
+ interface MenuItem {
15
+ title: string
16
+ icon: string
17
+ role: string
18
+ link: any
19
+ menuItems: Array<MenuItem>
20
+ active: boolean
21
+ name: string
22
+ }
13
23
  }
14
24
 
15
25
  export {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramathibodi/nuxt-commons",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Ramathibodi Nuxt modules for common components",
5
5
  "repository": {
6
6
  "type": "git",