@teammodlr/ui-kit 2.1.75 → 2.1.76
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
|
@@ -13,12 +13,16 @@
|
|
|
13
13
|
import type { Size } from '../../types/props';
|
|
14
14
|
import { computed, defineComponent, provide, reactive, ref, watchEffect, type PropType } from 'vue';
|
|
15
15
|
import { tabs, tabContent, tabsEvenly } from './style';
|
|
16
|
+
|
|
16
17
|
export default defineComponent({
|
|
17
18
|
name: "TabGroup",
|
|
18
19
|
props: {
|
|
19
20
|
modelValue: {
|
|
20
21
|
type: [String, Number],
|
|
21
22
|
},
|
|
23
|
+
selected: {
|
|
24
|
+
type: [String, Number],
|
|
25
|
+
},
|
|
22
26
|
size: {
|
|
23
27
|
type: String as PropType<Size>,
|
|
24
28
|
default: 'md'
|
|
@@ -38,20 +42,32 @@ export default defineComponent({
|
|
|
38
42
|
}
|
|
39
43
|
},
|
|
40
44
|
emit: [
|
|
41
|
-
'update:modelValue'
|
|
45
|
+
'update:modelValue',
|
|
46
|
+
'update:selected'
|
|
42
47
|
],
|
|
43
48
|
setup(props, { emit }) {
|
|
44
49
|
const wrapperRef = ref<HTMLElement>();
|
|
45
50
|
const tabsContentRef = ref<HTMLElement>();
|
|
46
51
|
const contentRef = ref<HTMLElement>();
|
|
47
52
|
const active = ref();
|
|
53
|
+
const selectedActive = ref();
|
|
54
|
+
|
|
55
|
+
// Watch for changes in modelValue
|
|
56
|
+
watchEffect(() => {
|
|
57
|
+
if (props.modelValue !== undefined) {
|
|
58
|
+
active.value = props.modelValue;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
48
61
|
|
|
62
|
+
// Watch for changes in selected
|
|
49
63
|
watchEffect(() => {
|
|
50
|
-
|
|
64
|
+
if (props.selected !== undefined) {
|
|
65
|
+
selectedActive.value = props.selected;
|
|
66
|
+
}
|
|
51
67
|
});
|
|
52
68
|
|
|
53
69
|
const state = reactive({
|
|
54
|
-
active: computed(() => active.value),
|
|
70
|
+
active: computed(() => active.value ?? selectedActive.value),
|
|
55
71
|
type: computed(() => props.type)
|
|
56
72
|
});
|
|
57
73
|
|
|
@@ -66,7 +82,6 @@ export default defineComponent({
|
|
|
66
82
|
return {
|
|
67
83
|
[tabs[props.type as keyof typeof tabs]]: true,
|
|
68
84
|
[tabsEvenly]: props.evenly
|
|
69
|
-
|
|
70
85
|
}
|
|
71
86
|
});
|
|
72
87
|
|
|
@@ -74,18 +89,26 @@ export default defineComponent({
|
|
|
74
89
|
return {
|
|
75
90
|
[tabContent]: true
|
|
76
91
|
}
|
|
77
|
-
})
|
|
92
|
+
});
|
|
78
93
|
|
|
79
94
|
function selectTab(tab: string | number) {
|
|
80
|
-
|
|
81
|
-
|
|
95
|
+
// Update both modelValue and selected if they exist
|
|
96
|
+
if (props.modelValue !== undefined) {
|
|
97
|
+
active.value = tab;
|
|
98
|
+
emit('update:modelValue', tab);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (props.selected !== undefined) {
|
|
102
|
+
selectedActive.value = tab;
|
|
103
|
+
emit('update:selected', tab);
|
|
104
|
+
}
|
|
82
105
|
}
|
|
83
106
|
|
|
84
107
|
provide("tabs", {
|
|
85
108
|
tabsContentRef,
|
|
86
109
|
selectTab,
|
|
87
110
|
state
|
|
88
|
-
})
|
|
111
|
+
});
|
|
89
112
|
|
|
90
113
|
return {
|
|
91
114
|
wrapperRef,
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<MTabGroup v-model="active">
|
|
3
|
-
<MTab value="one" label="OneOneOneOneOneOneOneOneOneOneOneOneOneOneOneOne" closable @on-close="close">
|
|
4
|
-
Hello Worlddsd
|
|
5
|
-
</MTab>
|
|
6
|
-
<MTab value="two" label="Two" disabled>
|
|
7
|
-
Hello World Two
|
|
8
|
-
</MTab>
|
|
9
|
-
<MTab value="three" label="Third">
|
|
10
|
-
Hello World Two dfndjfn
|
|
11
|
-
</MTab>
|
|
12
|
-
</MTabGroup>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script lang="ts" setup>
|
|
16
|
-
import { ref } from "vue";
|
|
17
|
-
|
|
18
|
-
const active = ref("one");
|
|
19
|
-
|
|
20
|
-
function close(tab: any) {
|
|
21
|
-
console.log('hi', tab);
|
|
22
|
-
}
|
|
23
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<MTabGroup v-model="active">
|
|
3
|
+
<MTab value="one" label="OneOneOneOneOneOneOneOneOneOneOneOneOneOneOneOne" closable @on-close="close">
|
|
4
|
+
Hello Worlddsd
|
|
5
|
+
</MTab>
|
|
6
|
+
<MTab value="two" label="Two" disabled>
|
|
7
|
+
Hello World Two
|
|
8
|
+
</MTab>
|
|
9
|
+
<MTab value="three" label="Third">
|
|
10
|
+
Hello World Two dfndjfn
|
|
11
|
+
</MTab>
|
|
12
|
+
</MTabGroup>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import { ref } from "vue";
|
|
17
|
+
|
|
18
|
+
const active = ref("one");
|
|
19
|
+
|
|
20
|
+
function close(tab: any) {
|
|
21
|
+
console.log('hi', tab);
|
|
22
|
+
}
|
|
23
|
+
</script>
|