@luizleon/sf.prefeiturasp.vuecomponents 0.0.47 → 0.0.48

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.47",
3
+ "version": "0.0.48",
4
4
  "type": "module",
5
5
  "main": "dist/sf.prefeiturasp.vuecomponents.umd.js",
6
6
  "module": "dist/sf.prefeiturasp.vuecomponents.es.js",
@@ -32,6 +32,8 @@
32
32
  "vue-tsc": "2.0.4"
33
33
  },
34
34
  "peerDependencies": {
35
- "vue": "3.*"
35
+ "vue": "3.*",
36
+ "primevue": "3.*",
37
+ "vue-router": "4.*"
36
38
  }
37
39
  }
@@ -0,0 +1,26 @@
1
+ import { VNode } from "vue";
2
+ import { StyleValue } from "vue";
3
+ import {
4
+ ClassComponent,
5
+ GlobalComponentConstructor,
6
+ HintedString,
7
+ } from "../../ts-helpers";
8
+ import { SfPanelMenuProps } from "./PanelMenu.vue";
9
+
10
+ export interface SfPanelMenuSlots {}
11
+
12
+ export declare type SfPanelMenuEmits = {};
13
+
14
+ declare class SfPanelMenu extends ClassComponent<
15
+ SfPanelMenuProps,
16
+ SfPanelMenuSlots,
17
+ SfPanelMenuEmits
18
+ > {}
19
+
20
+ declare module "@vue/runtime-core" {
21
+ interface GlobalComponents {
22
+ SfPanelMenu: GlobalComponentConstructor<SfPanelMenu>;
23
+ }
24
+ }
25
+
26
+ export default SfPanelMenu;
@@ -0,0 +1,101 @@
1
+ <script setup lang="ts">
2
+ import { RouteRecordName, useRoute } from "vue-router";
3
+ import PanelMenu, { PanelMenuExpandedKeys } from "primevue/panelmenu";
4
+ import Icon from "./../icon/Icon.vue";
5
+ import { ref, watch } from "vue";
6
+
7
+ export interface SfPanelMenuItem {
8
+ [x: string]: any;
9
+ label: string;
10
+ route?: RouteRecordName;
11
+ url?: string;
12
+ icon?: string;
13
+ items?: SfPanelMenuItem[];
14
+ }
15
+
16
+ const props = defineProps<{
17
+ items: SfPanelMenuItem[];
18
+ }>();
19
+
20
+ const route = useRoute();
21
+
22
+ AdicionarSourceKeys(props.items);
23
+
24
+ function AdicionarSourceKeys(
25
+ items: SfPanelMenuItem[],
26
+ key: string | undefined = undefined
27
+ ) {
28
+ items.forEach((item) => {
29
+ if (!!key) {
30
+ item.sourceKey = key;
31
+ }
32
+ if (item.items) {
33
+ AdicionarSourceKeys(item.items, item.key);
34
+ }
35
+ });
36
+ }
37
+
38
+ const expandedKeys = ref<PanelMenuExpandedKeys>({});
39
+
40
+ function MudancaDeRota(
41
+ items: SfPanelMenuItem[],
42
+ route: string,
43
+ key: string | undefined = undefined
44
+ ) {
45
+ items.forEach((item) => {
46
+ if (item.route && item.route === route && !!key) {
47
+ expandedKeys.value[key] = key === item.sourceKey;
48
+ }
49
+ if (item.items) {
50
+ MudancaDeRota(item.items, route, item.key);
51
+ }
52
+ });
53
+ }
54
+
55
+ watch(
56
+ () => route.name,
57
+ (v) => {
58
+ if (!v) return;
59
+ MudancaDeRota(props.items, v.toString());
60
+ }
61
+ );
62
+ </script>
63
+
64
+ <template>
65
+ <PanelMenu
66
+ :model="props.items"
67
+ v-model:expandedKeys="expandedKeys"
68
+ :multiple="true"
69
+ :class="'sf-p-2'"
70
+ >
71
+ <template #item="{ item, active }">
72
+ <router-link
73
+ v-if="item.route"
74
+ v-slot="{ href, navigate, isActive }"
75
+ :to="{ name: item.route }"
76
+ custom
77
+ >
78
+ <a
79
+ class="sf-flex sf-align-items-center sf-px-3 sf-py-2 sf-ripple"
80
+ :data-active="isActive"
81
+ :href="href"
82
+ @click="navigate"
83
+ >
84
+ <Icon :icon="item.icon ?? 'chevron_right'" />
85
+ <span class="sf-ml-2">{{ item.label }}</span>
86
+ </a>
87
+ </router-link>
88
+ <a
89
+ v-else
90
+ class="sf-flex sf-align-items-center sf-pl-3 sf-py-2"
91
+ :href="item.url"
92
+ :target="item.target"
93
+ >
94
+ <Icon v-if="item.icon" :icon="item.icon" />
95
+ <span class="sf-ml-2">{{ item.label }}</span>
96
+ <div class="sf-flex-grow-1"></div>
97
+ <Icon :icon="active ? 'expand_less' : 'expand_more'" />
98
+ </a>
99
+ </template>
100
+ </PanelMenu>
101
+ </template>
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ import SfButton from "./components/button/Button.vue";
7
7
  import SfDrawer from "./components/drawer/Drawer.vue";
8
8
  import SfMessage from "./components/message/Message.vue";
9
9
  import SfTooltip from "./components/tooltip/Tooltip.vue";
10
+ import SfPanelMenu from "./components/panelmenu/PanelMenu.vue";
10
11
  import { ThemeToggleBase } from "./components/internal/ThemeToggle";
11
12
 
12
13
  import { UseNavMenuService } from "./services/navMenuService";
@@ -30,6 +31,7 @@ export {
30
31
  SfDrawer,
31
32
  SfMessage,
32
33
  SfTooltip,
34
+ SfPanelMenu,
33
35
  UseAuthService,
34
36
  UseNavMenuService,
35
37
  UseConfirmService,