@luizleon/sf.prefeiturasp.vuecomponents 0.0.48 → 0.0.50

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luizleon/sf.prefeiturasp.vuecomponents",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "type": "module",
5
5
  "main": "dist/sf.prefeiturasp.vuecomponents.umd.js",
6
6
  "module": "dist/sf.prefeiturasp.vuecomponents.es.js",
@@ -1,16 +1,20 @@
1
1
  <script setup lang="ts">
2
- import { RouteRecordName, useRoute } from "vue-router";
2
+ import { useRoute } from "vue-router";
3
3
  import PanelMenu, { PanelMenuExpandedKeys } from "primevue/panelmenu";
4
4
  import Icon from "./../icon/Icon.vue";
5
- import { ref, watch } from "vue";
5
+ import { Ref, computed, ref, watch } from "vue";
6
6
 
7
7
  export interface SfPanelMenuItem {
8
- [x: string]: any;
9
8
  label: string;
10
- route?: RouteRecordName;
9
+ routeName?: string;
11
10
  url?: string;
12
11
  icon?: string;
13
12
  items?: SfPanelMenuItem[];
13
+ key?: string;
14
+ }
15
+
16
+ interface Menu extends SfPanelMenuItem {
17
+ parentKey?: string;
14
18
  }
15
19
 
16
20
  const props = defineProps<{
@@ -19,15 +23,19 @@ const props = defineProps<{
19
23
 
20
24
  const route = useRoute();
21
25
 
22
- AdicionarSourceKeys(props.items);
26
+ const menu: Ref<Menu[]> = computed(() => {
27
+ return props.items;
28
+ });
29
+
30
+ AdicionarSourceKeys(menu.value);
23
31
 
24
32
  function AdicionarSourceKeys(
25
- items: SfPanelMenuItem[],
33
+ items: Menu[],
26
34
  key: string | undefined = undefined
27
35
  ) {
28
36
  items.forEach((item) => {
29
37
  if (!!key) {
30
- item.sourceKey = key;
38
+ item.parentKey = key;
31
39
  }
32
40
  if (item.items) {
33
41
  AdicionarSourceKeys(item.items, item.key);
@@ -38,13 +46,13 @@ function AdicionarSourceKeys(
38
46
  const expandedKeys = ref<PanelMenuExpandedKeys>({});
39
47
 
40
48
  function MudancaDeRota(
41
- items: SfPanelMenuItem[],
49
+ items: Menu[],
42
50
  route: string,
43
51
  key: string | undefined = undefined
44
52
  ) {
45
53
  items.forEach((item) => {
46
- if (item.route && item.route === route && !!key) {
47
- expandedKeys.value[key] = key === item.sourceKey;
54
+ if (!!item.routeName && item.routeName === route && !!key) {
55
+ expandedKeys.value[key] = key === item.parentKey;
48
56
  }
49
57
  if (item.items) {
50
58
  MudancaDeRota(item.items, route, item.key);
@@ -56,14 +64,14 @@ watch(
56
64
  () => route.name,
57
65
  (v) => {
58
66
  if (!v) return;
59
- MudancaDeRota(props.items, v.toString());
67
+ MudancaDeRota(menu.value, v.toString());
60
68
  }
61
69
  );
62
70
  </script>
63
71
 
64
72
  <template>
65
73
  <PanelMenu
66
- :model="props.items"
74
+ :model="menu"
67
75
  v-model:expandedKeys="expandedKeys"
68
76
  :multiple="true"
69
77
  :class="'sf-p-2'"