sprintify-ui 0.0.64 → 0.0.66

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.
@@ -9,6 +9,10 @@ declare const _default: import("vue").DefineComponent<{
9
9
  default: boolean;
10
10
  type: BooleanConstructor;
11
11
  };
12
+ actionsVisible: {
13
+ default: string;
14
+ type: PropType<"toggle" | "always">;
15
+ };
12
16
  }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "click"[], "click", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
13
17
  item: {
14
18
  required: true;
@@ -18,9 +22,14 @@ declare const _default: import("vue").DefineComponent<{
18
22
  default: boolean;
19
23
  type: BooleanConstructor;
20
24
  };
25
+ actionsVisible: {
26
+ default: string;
27
+ type: PropType<"toggle" | "always">;
28
+ };
21
29
  }>> & {
22
30
  onClick?: ((...args: any[]) => any) | undefined;
23
31
  }, {
24
32
  dark: boolean;
33
+ actionsVisible: "toggle" | "always";
25
34
  }>;
26
35
  export default _default;
@@ -69,6 +69,7 @@ export interface ActionItem {
69
69
  icon?: string;
70
70
  count?: number;
71
71
  meta?: Record<string, any>;
72
+ actions?: ActionItem[];
72
73
  }
73
74
  export interface ActionSection {
74
75
  title: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.0.64",
3
+ "version": "0.0.66",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -39,8 +39,6 @@
39
39
  </template>
40
40
 
41
41
  <script lang="ts" setup>
42
- import { defineProps } from 'vue';
43
-
44
42
  const tooltipShown = ref(false);
45
43
  const showCopied = ref(false);
46
44
 
@@ -29,7 +29,26 @@ export default {
29
29
  label: 'Articles',
30
30
  to: '/articles',
31
31
  icon: 'heroicons:document-text',
32
+ actions: [
33
+ {
34
+ label: 'Articles',
35
+ to: '/articles/1',
36
+ },
37
+ {
38
+ label: 'Videos',
39
+ to: '/articles/2',
40
+ },
41
+ {
42
+ label: 'Training',
43
+ to: '/articles/3',
44
+ },
45
+ {
46
+ label: 'Archived',
47
+ to: '/articles/4',
48
+ },
49
+ ],
32
50
  },
51
+
33
52
  {
34
53
  label: 'Users',
35
54
  to: '/users',
@@ -1,20 +1,42 @@
1
1
  <template>
2
- <BaseActionItem
3
- :item="item"
4
- :dark="dark"
5
- item-class="flex w-full"
6
- @click="onClick"
7
- >
8
- <template #default="{ active }">
9
- <BaseNavbarSideItemContent
10
- :label="item.label"
11
- :icon="item.icon"
12
- :active="active"
13
- :count="item.count"
14
- :dark="dark"
15
- />
16
- </template>
17
- </BaseActionItem>
2
+ <div>
3
+ <BaseActionItem
4
+ :item="item"
5
+ :dark="dark"
6
+ item-class="flex w-full"
7
+ @click="onClick"
8
+ >
9
+ <template #default="{ active }">
10
+ <BaseNavbarSideItemContent
11
+ :label="item.label"
12
+ :icon="item.icon"
13
+ :active="active"
14
+ :count="item.count"
15
+ :dark="dark"
16
+ />
17
+ </template>
18
+ </BaseActionItem>
19
+
20
+ <div
21
+ v-if="showSubActions && item.actions && item.actions.length"
22
+ class="ml-10 mt-1.5 mb-3"
23
+ >
24
+ <div v-for="subItem in item.actions" :key="subItem.label" class="mb-1">
25
+ <BaseActionItem
26
+ :item="subItem"
27
+ :dark="dark"
28
+ :item-class="[
29
+ 'flex w-full',
30
+ dark
31
+ ? 'text-slate-300 hover:text-white'
32
+ : 'text-slate-900 hover:text-slate-600',
33
+ ]"
34
+ >
35
+ {{ subItem.label }}
36
+ </BaseActionItem>
37
+ </div>
38
+ </div>
39
+ </div>
18
40
  </template>
19
41
 
20
42
  <script setup lang="ts">
@@ -23,7 +45,7 @@ import { ActionItem } from '@/types';
23
45
  import BaseActionItem from './BaseActionItem.vue';
24
46
  import BaseNavbarSideItemContent from './BaseNavbarSideItemContent.vue';
25
47
 
26
- defineProps({
48
+ const props = defineProps({
27
49
  item: {
28
50
  required: true,
29
51
  type: Object as PropType<ActionItem>,
@@ -32,11 +54,39 @@ defineProps({
32
54
  default: false,
33
55
  type: Boolean,
34
56
  },
57
+ actionsVisible: {
58
+ default: 'toggle',
59
+ type: String as PropType<'toggle' | 'always'>,
60
+ },
35
61
  });
36
62
 
37
63
  const emit = defineEmits(['click']);
38
64
 
65
+ const router = useRouter();
66
+
39
67
  async function onClick() {
40
68
  emit('click');
41
69
  }
70
+
71
+ const routeActive = computed((): boolean => {
72
+ if (!props.item.to) {
73
+ return false;
74
+ }
75
+
76
+ const itemRoute = router.resolve(props.item.to);
77
+
78
+ return router.currentRoute.value.matched.some((route) => {
79
+ return itemRoute.path == route.path;
80
+ });
81
+ });
82
+
83
+ const showSubActions = computed((): boolean => {
84
+ if (props.actionsVisible == 'always') {
85
+ return true;
86
+ }
87
+ if (!props.item.to) {
88
+ return true;
89
+ }
90
+ return routeActive.value;
91
+ });
42
92
  </script>
@@ -85,6 +85,7 @@ export interface ActionItem {
85
85
  icon?: string;
86
86
  count?: number;
87
87
  meta?: Record<string, any>;
88
+ actions?: ActionItem[];
88
89
  }
89
90
 
90
91
  export interface ActionSection {