@vasakgroup/vue-libvasak 0.0.3 → 0.2.0
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/README.md +47 -0
- package/dist/vue-libvasak.css +0 -0
- package/dist/vue-libvasak.es.js +2477 -0
- package/dist/vue-libvasak.umd.js +1 -0
- package/package.json +27 -6
- package/src/.d.ts +0 -0
- package/src/cards/DeviceCard.vue +82 -0
- package/src/cards/ListCard.vue +40 -0
- package/src/controls/ActionButton.vue +85 -0
- package/src/controls/ToggleControl.vue +55 -0
- package/src/forms/FormGroup.vue +27 -0
- package/src/forms/SliderControl.vue +100 -0
- package/src/forms/SwitchToggle.vue +49 -0
- package/src/index.ts +47 -1
- package/src/layout/ConfigSection.vue +28 -0
- package/src/sidebar/SideBar.vue +0 -0
- package/src/sidebar/SideButton.vue +1 -3
- package/src/tray/TrayIconButton.vue +80 -0
- package/src/types/vue-libvasak.d.ts +155 -0
- package/src/window/TopBar.vue +30 -43
- package/src/window/WindowFrame.vue +3 -75
- package/COPYING +0 -674
- package/readme.md +0 -71
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="p-1 rounded-vsk relative hover:bg-vsk-primary/30 group transition-all duration-300"
|
|
4
|
+
:class="customClass"
|
|
5
|
+
:title="tooltip"
|
|
6
|
+
@click="handleClick"
|
|
7
|
+
@mouseenter="showTooltip = true"
|
|
8
|
+
@mouseleave="showTooltip = false"
|
|
9
|
+
>
|
|
10
|
+
<img
|
|
11
|
+
:src="icon"
|
|
12
|
+
:alt="alt"
|
|
13
|
+
class="m-auto h-5.5 w-auto transition-all duration-300"
|
|
14
|
+
:class="iconClass"
|
|
15
|
+
/>
|
|
16
|
+
|
|
17
|
+
<!-- Badge/Counter -->
|
|
18
|
+
<div
|
|
19
|
+
v-if="badge !== null && badge > 0"
|
|
20
|
+
class="absolute bottom-1 right-1 bg-vsk-primary text-white text-xs rounded-full w-4 h-4 flex items-center justify-center font-bold animate-bounce"
|
|
21
|
+
>
|
|
22
|
+
{{ badge }}
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<!-- Tooltip personalizado -->
|
|
26
|
+
<div
|
|
27
|
+
v-if="showCustomTooltip && customTooltipText"
|
|
28
|
+
class="absolute top-1 left-1/2 transform -translate-x-1/2 text-xs font-semibold p-1 rounded-vsk transition-all duration-300 pointer-events-none background"
|
|
29
|
+
:class="[
|
|
30
|
+
tooltipClass,
|
|
31
|
+
{
|
|
32
|
+
'opacity-0 -translate-y-2': !showTooltip,
|
|
33
|
+
'opacity-100 translate-y-0': showTooltip
|
|
34
|
+
}
|
|
35
|
+
]"
|
|
36
|
+
>
|
|
37
|
+
{{ customTooltipText }}
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<!-- Slot para contenido adicional personalizado -->
|
|
41
|
+
<slot></slot>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<script setup lang="ts">
|
|
46
|
+
import { ref } from 'vue';
|
|
47
|
+
|
|
48
|
+
interface Props {
|
|
49
|
+
icon: string;
|
|
50
|
+
alt?: string;
|
|
51
|
+
tooltip?: string;
|
|
52
|
+
badge?: number | null;
|
|
53
|
+
iconClass?: string | Record<string, boolean>;
|
|
54
|
+
customClass?: string | Record<string, boolean>;
|
|
55
|
+
tooltipClass?: string | Record<string, boolean>;
|
|
56
|
+
showCustomTooltip?: boolean;
|
|
57
|
+
customTooltipText?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
withDefaults(defineProps<Props>(), {
|
|
61
|
+
alt: '',
|
|
62
|
+
tooltip: '',
|
|
63
|
+
badge: null,
|
|
64
|
+
iconClass: () => ({}),
|
|
65
|
+
customClass: '',
|
|
66
|
+
tooltipClass: '',
|
|
67
|
+
showCustomTooltip: false,
|
|
68
|
+
customTooltipText: '',
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const emit = defineEmits<{
|
|
72
|
+
click: [];
|
|
73
|
+
}>();
|
|
74
|
+
|
|
75
|
+
const showTooltip = ref(false);
|
|
76
|
+
|
|
77
|
+
const handleClick = () => {
|
|
78
|
+
emit('click');
|
|
79
|
+
};
|
|
80
|
+
</script>
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
declare module "@vasakgroup/vue-libvasak" {
|
|
2
|
+
import { DefineComponent, App } from "vue";
|
|
3
|
+
|
|
4
|
+
/* Layout */
|
|
5
|
+
export interface WindowFrameProps {
|
|
6
|
+
title?: string;
|
|
7
|
+
image?: string;
|
|
8
|
+
class?: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* Sidebar */
|
|
13
|
+
export interface SideBarProps {
|
|
14
|
+
class?: string;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SideButtonProps {
|
|
19
|
+
title?: string;
|
|
20
|
+
image?: string;
|
|
21
|
+
class?: string;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Controls */
|
|
26
|
+
export interface ActionButtonProps {
|
|
27
|
+
label: string;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
variant?: "primary" | "secondary" | "danger";
|
|
30
|
+
loading?: boolean;
|
|
31
|
+
customClass?: string | Record<string, boolean>;
|
|
32
|
+
size?: "sm" | "md" | "lg";
|
|
33
|
+
fullWidth?: boolean;
|
|
34
|
+
iconSrc?: string;
|
|
35
|
+
iconAlt?: string;
|
|
36
|
+
iconRight?: boolean;
|
|
37
|
+
type?: "button" | "submit" | "reset";
|
|
38
|
+
stopPropagation?: boolean;
|
|
39
|
+
preventDefault?: boolean;
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ToggleControlProps {
|
|
44
|
+
icon: string;
|
|
45
|
+
alt?: string;
|
|
46
|
+
tooltip?: string;
|
|
47
|
+
isActive?: boolean;
|
|
48
|
+
isLoading?: boolean;
|
|
49
|
+
iconClass?: Record<string, boolean>;
|
|
50
|
+
customClass?: Record<string, boolean>;
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* Layout/Config */
|
|
55
|
+
export interface ConfigSectionProps {
|
|
56
|
+
title: string;
|
|
57
|
+
icon?: string;
|
|
58
|
+
customClass?: string | Record<string, boolean>;
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Cards */
|
|
63
|
+
export interface DeviceCardProps {
|
|
64
|
+
icon: string;
|
|
65
|
+
title: string;
|
|
66
|
+
subtitle?: string;
|
|
67
|
+
metadata?: string;
|
|
68
|
+
extraInfo?: string[];
|
|
69
|
+
isConnected?: boolean;
|
|
70
|
+
showActionButton?: boolean;
|
|
71
|
+
actionLabel?: string;
|
|
72
|
+
showStatusIndicator?: boolean;
|
|
73
|
+
customClass?: string;
|
|
74
|
+
clickable?: boolean;
|
|
75
|
+
[key: string]: any;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ListCardProps {
|
|
79
|
+
clickable?: boolean;
|
|
80
|
+
customClass?: string | Record<string, boolean>;
|
|
81
|
+
[key: string]: any;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Forms */
|
|
85
|
+
export interface FormGroupProps {
|
|
86
|
+
label: string;
|
|
87
|
+
htmlFor?: string;
|
|
88
|
+
customClass?: string | Record<string, boolean>;
|
|
89
|
+
labelClass?: string | Record<string, boolean>;
|
|
90
|
+
[key: string]: any;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface SliderControlProps {
|
|
94
|
+
icon: string;
|
|
95
|
+
alt?: string;
|
|
96
|
+
tooltip?: string;
|
|
97
|
+
modelValue: number;
|
|
98
|
+
min?: number;
|
|
99
|
+
max?: number;
|
|
100
|
+
showButton?: boolean;
|
|
101
|
+
iconClass?: string | Record<string, boolean>;
|
|
102
|
+
getPercentageClass?: (percentage: number) => string;
|
|
103
|
+
[key: string]: any;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface SwitchToggleProps {
|
|
107
|
+
isOn: boolean;
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
size?: "small" | "medium";
|
|
110
|
+
activeClass?: string;
|
|
111
|
+
inactiveClass?: string;
|
|
112
|
+
customClass?: string;
|
|
113
|
+
[key: string]: any;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* Tray */
|
|
117
|
+
export interface TrayIconButtonProps {
|
|
118
|
+
icon: string;
|
|
119
|
+
alt?: string;
|
|
120
|
+
tooltip?: string;
|
|
121
|
+
badge?: number | null;
|
|
122
|
+
iconClass?: string | Record<string, boolean>;
|
|
123
|
+
customClass?: string | Record<string, boolean>;
|
|
124
|
+
tooltipClass?: string | Record<string, boolean>;
|
|
125
|
+
showCustomTooltip?: boolean;
|
|
126
|
+
customTooltipText?: string;
|
|
127
|
+
[key: string]: any;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* Component exports */
|
|
131
|
+
export const WindowFrame: DefineComponent<WindowFrameProps, any, any, {}, {}, {}, {}, {}, string>;
|
|
132
|
+
export const SideBar: DefineComponent<SideBarProps, any, any, {}, {}, {}, {}, {}, string>;
|
|
133
|
+
export const SideButton: DefineComponent<SideButtonProps, any, any, {}, {}, {}, {}, {}, string>;
|
|
134
|
+
|
|
135
|
+
export const ActionButton: DefineComponent<ActionButtonProps, any, any, {}, {}, {}, {}, { click: () => void }, string>;
|
|
136
|
+
export const ToggleControl: DefineComponent<ToggleControlProps, any, any, {}, {}, {}, {}, { click: () => void }, string>;
|
|
137
|
+
export const ConfigSection: DefineComponent<ConfigSectionProps, any, any, {}, {}, {}, {}, {}, string>;
|
|
138
|
+
|
|
139
|
+
export const DeviceCard: DefineComponent<DeviceCardProps, any, any, {}, {}, {}, {}, { action: () => void; click: () => void }, string>;
|
|
140
|
+
export const ListCard: DefineComponent<ListCardProps, any, any, {}, {}, {}, {}, { click: () => void }, string>;
|
|
141
|
+
|
|
142
|
+
export const FormGroup: DefineComponent<FormGroupProps, any, any, {}, {}, {}, {}, {}, string>;
|
|
143
|
+
export const SliderControl: DefineComponent<SliderControlProps, any, any, {}, {}, {}, {}, { 'update:modelValue': (value: number) => void; buttonClick: () => void }, string>;
|
|
144
|
+
export const SwitchToggle: DefineComponent<SwitchToggleProps, any, any, {}, {}, {}, {}, { toggle: (value: boolean) => void }, string>;
|
|
145
|
+
|
|
146
|
+
export const TrayIconButton: DefineComponent<TrayIconButtonProps, any, any, {}, {}, {}, {}, { click: () => void }, string>;
|
|
147
|
+
|
|
148
|
+
// Plugin de Vue
|
|
149
|
+
export interface VueLibVasakPlugin {
|
|
150
|
+
install(app: App): void;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare const plugin: VueLibVasakPlugin;
|
|
154
|
+
export default plugin;
|
|
155
|
+
}
|
package/src/window/TopBar.vue
CHANGED
|
@@ -1,59 +1,46 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { defineProps,
|
|
2
|
+
import { defineProps, ref, Ref, onMounted } from "vue";
|
|
3
|
+
import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
4
|
+
import { getIconSource } from "@vasakgroup/plugin-vicons";
|
|
3
5
|
|
|
4
|
-
const $vsk: any = inject("vsk");
|
|
5
6
|
const bar = ref(null);
|
|
7
|
+
const appWindow = getCurrentWindow();
|
|
8
|
+
const closeIcon: Ref<string> = ref("");
|
|
9
|
+
const minimizeIcon: Ref<string> = ref("");
|
|
10
|
+
const maximizeIcon: Ref<string> = ref("");
|
|
6
11
|
|
|
7
12
|
const props = defineProps({
|
|
8
13
|
title: String,
|
|
9
14
|
image: String,
|
|
10
|
-
customColor: String,
|
|
11
15
|
});
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const close = () => {
|
|
18
|
-
$vsk.exit();
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const minimize = () => {
|
|
22
|
-
$vsk.minimize();
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const toggleMaximize = () => {
|
|
26
|
-
$vsk.toggleMaximize();
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const isCustom = computed(() => {
|
|
30
|
-
console.log('customColor', props.customColor);
|
|
31
|
-
return props.customColor ? `custom`: '';
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
onMounted(() => {
|
|
35
|
-
if (bar.value) {
|
|
36
|
-
(bar.value as HTMLElement).addEventListener("mousedown", (e: any) => {
|
|
37
|
-
move();
|
|
38
|
-
});
|
|
39
|
-
}
|
|
17
|
+
onMounted(async () => {
|
|
18
|
+
closeIcon.value = await getIconSource("window-close");
|
|
19
|
+
minimizeIcon.value = await getIconSource("window-minimize");
|
|
20
|
+
maximizeIcon.value = await getIconSource("window-maximize");
|
|
40
21
|
});
|
|
41
22
|
</script>
|
|
42
23
|
|
|
43
24
|
<template>
|
|
44
|
-
<div
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<
|
|
25
|
+
<div
|
|
26
|
+
data-tauri-drag-region
|
|
27
|
+
class="flex h-8 px-4 py-1 bg-vsk-primary rounded-t-window justify-between align-center"
|
|
28
|
+
ref="bar"
|
|
29
|
+
>
|
|
30
|
+
<div data-tauri-drag-region>
|
|
31
|
+
<img :src="props.image" data-tauri-drag-region class="h-6 w-auto" />
|
|
32
|
+
</div>
|
|
33
|
+
<div data-tauri-drag-region>{{ props.title }}</div>
|
|
34
|
+
<div data-tauri-drag-region>
|
|
35
|
+
<span class="win-button" @click="appWindow.minimize()">
|
|
36
|
+
<img :src="minimizeIcon" class="h-6 w-6 inline-block" alt="Minimize">
|
|
37
|
+
</span>
|
|
38
|
+
<span class="win-button" @click="appWindow.toggleMaximize()">
|
|
39
|
+
<img :src="maximizeIcon" class="h-6 w-6 inline-block" alt="Maximize">
|
|
40
|
+
</span>
|
|
41
|
+
<span class="win-button" @click="appWindow.close()">
|
|
42
|
+
<img :src="closeIcon" class="h-6 w-6 inline-block" alt="Close">
|
|
43
|
+
</span>
|
|
51
44
|
</div>
|
|
52
45
|
</div>
|
|
53
46
|
</template>
|
|
54
|
-
|
|
55
|
-
<style scoped>
|
|
56
|
-
.custom{
|
|
57
|
-
background-color: v-bind(props.customColor);
|
|
58
|
-
}
|
|
59
|
-
</style>
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import TopBar from "./TopBar.vue";
|
|
3
|
-
import { defineProps
|
|
4
|
-
|
|
5
|
-
const $vsk: any = inject("vsk");
|
|
6
|
-
|
|
7
|
-
const top = ref(null);
|
|
8
|
-
const left = ref(null);
|
|
9
|
-
const right = ref(null);
|
|
10
|
-
const bottom = ref(null);
|
|
11
|
-
const topleft = ref(null);
|
|
12
|
-
const bottomleft = ref(null);
|
|
13
|
-
const topright = ref(null);
|
|
14
|
-
const bottomright = ref(null);
|
|
3
|
+
import { defineProps } from "vue";
|
|
15
4
|
|
|
16
5
|
const props = defineProps({
|
|
17
6
|
title: {
|
|
@@ -22,71 +11,10 @@ const props = defineProps({
|
|
|
22
11
|
type: String,
|
|
23
12
|
default: "",
|
|
24
13
|
},
|
|
25
|
-
customColor: {
|
|
26
|
-
type: String,
|
|
27
|
-
default: null,
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const resize = (dir: string) => {
|
|
32
|
-
$vsk.startResize(dir);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
onMounted(() => {
|
|
36
|
-
if (top.value) {
|
|
37
|
-
(top.value as HTMLElement).addEventListener("mousedown", (e: any) => {
|
|
38
|
-
resize("top");
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (bottom.value) {
|
|
42
|
-
(bottom.value as HTMLElement).addEventListener("mousedown", (e: any) => {
|
|
43
|
-
resize("bottom");
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
if (left.value) {
|
|
47
|
-
(left.value as HTMLElement).addEventListener("mousedown", (e: any) => {
|
|
48
|
-
resize("left");
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (right.value) {
|
|
52
|
-
(right.value as HTMLElement).addEventListener("mousedown", (e: any) => {
|
|
53
|
-
resize("right");
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
if (topleft.value) {
|
|
57
|
-
(topleft.value as HTMLElement).addEventListener("mousedown", (e: any) => {
|
|
58
|
-
resize("topleft");
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
if (bottomleft.value) {
|
|
62
|
-
(bottomleft.value as HTMLElement).addEventListener("mousedown", (e: any) => {
|
|
63
|
-
resize("bottomleft");
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
if (topright.value) {
|
|
67
|
-
(topright.value as HTMLElement).addEventListener("mousedown", (e: any) => {
|
|
68
|
-
resize("topright");
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (bottomright.value) {
|
|
72
|
-
(bottomright.value as HTMLElement).addEventListener("mousedown", (e: any) => {
|
|
73
|
-
resize("bottomright");
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
14
|
});
|
|
77
15
|
</script>
|
|
78
16
|
|
|
79
17
|
<template>
|
|
80
|
-
<TopBar :title :image
|
|
81
|
-
<
|
|
82
|
-
<slot />
|
|
83
|
-
<div ref="top" class="win-edge win-edge-top"></div>
|
|
84
|
-
<div ref="left" class="win-edge win-edge-left"></div>
|
|
85
|
-
<div ref="right" class="win-edge win-edge-right"></div>
|
|
86
|
-
<div ref="bottom" class="win-edge win-edge-bottom"></div>
|
|
87
|
-
<div ref="topleft" class="win-edge win-edge-topleft"></div>
|
|
88
|
-
<div ref="bottomleft" class="win-edge win-edge-bottomleft"></div>
|
|
89
|
-
<div ref="topright" class="win-edge win-edge-topright"></div>
|
|
90
|
-
<div ref="bottomright" class="win-edge win-edge-bottomright"></div>
|
|
91
|
-
</div>
|
|
18
|
+
<TopBar :title="props.title" :image="props.image" />
|
|
19
|
+
<slot />
|
|
92
20
|
</template>
|