@data-fair/lib-vuetify 1.2.0 → 1.3.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/lang-switcher.vue +48 -0
- package/lang-switcher.vue.d.ts +14 -0
- package/lang-switcher.vue.js +132 -0
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template lang="html">
|
|
2
|
+
<v-toolbar-items class="lang-switcher">
|
|
3
|
+
<v-speed-dial
|
|
4
|
+
v-if="locales.length > 1"
|
|
5
|
+
direction="bottom"
|
|
6
|
+
transition="fade-transition"
|
|
7
|
+
>
|
|
8
|
+
<template #activator="{props}">
|
|
9
|
+
<v-btn
|
|
10
|
+
v-bind="props"
|
|
11
|
+
>
|
|
12
|
+
{{ session.lang.value }}
|
|
13
|
+
</v-btn>
|
|
14
|
+
</template>
|
|
15
|
+
<v-btn
|
|
16
|
+
v-for="locale in locales.filter(l => l !== session.lang.value)"
|
|
17
|
+
:key="locale"
|
|
18
|
+
icon
|
|
19
|
+
@click="setLocale(locale)"
|
|
20
|
+
>
|
|
21
|
+
{{ locale }}
|
|
22
|
+
</v-btn>
|
|
23
|
+
</v-speed-dial>
|
|
24
|
+
</v-toolbar-items>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script lang="ts" setup>
|
|
28
|
+
import { useI18n } from 'vue-i18n'
|
|
29
|
+
import useSession from '@data-fair/lib-vue/session.js'
|
|
30
|
+
|
|
31
|
+
const i18n = useI18n()
|
|
32
|
+
const session = useSession()
|
|
33
|
+
|
|
34
|
+
const {locales} = defineProps({
|
|
35
|
+
locales: {
|
|
36
|
+
type: Array as () => string[],
|
|
37
|
+
default: ['fr', 'en']
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const setLocale = (locale: string) => {
|
|
42
|
+
session.switchLang(locale)
|
|
43
|
+
window.location.reload()
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<style lang="css">
|
|
48
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
locales: {
|
|
3
|
+
type: () => string[];
|
|
4
|
+
default: string[];
|
|
5
|
+
};
|
|
6
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
7
|
+
locales: {
|
|
8
|
+
type: () => string[];
|
|
9
|
+
default: string[];
|
|
10
|
+
};
|
|
11
|
+
}>> & Readonly<{}>, {
|
|
12
|
+
locales: string[];
|
|
13
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/// <reference types=".vue-global-types/vue_3.5_false.d.ts" />
|
|
2
|
+
import { useI18n } from 'vue-i18n';
|
|
3
|
+
import useSession from '@data-fair/lib-vue/session.js';
|
|
4
|
+
const { defineProps, defineSlots, defineEmits, defineExpose, defineModel, defineOptions, withDefaults, } = await import('vue');
|
|
5
|
+
const i18n = useI18n();
|
|
6
|
+
const session = useSession();
|
|
7
|
+
const __VLS_props = defineProps({
|
|
8
|
+
locales: {
|
|
9
|
+
type: Array,
|
|
10
|
+
default: ['fr', 'en']
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const { locales } = __VLS_props;
|
|
14
|
+
const setLocale = (locale) => {
|
|
15
|
+
session.switchLang(locale);
|
|
16
|
+
window.location.reload();
|
|
17
|
+
};
|
|
18
|
+
const __VLS_fnComponent = (await import('vue')).defineComponent({
|
|
19
|
+
props: {
|
|
20
|
+
locales: {
|
|
21
|
+
type: Array,
|
|
22
|
+
default: ['fr', 'en']
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
;
|
|
27
|
+
let __VLS_functionalComponentProps;
|
|
28
|
+
function __VLS_template() {
|
|
29
|
+
const __VLS_ctx = {};
|
|
30
|
+
const __VLS_localComponents = {
|
|
31
|
+
...{},
|
|
32
|
+
...{},
|
|
33
|
+
...__VLS_ctx,
|
|
34
|
+
};
|
|
35
|
+
let __VLS_components;
|
|
36
|
+
const __VLS_localDirectives = {
|
|
37
|
+
...{},
|
|
38
|
+
...__VLS_ctx,
|
|
39
|
+
};
|
|
40
|
+
let __VLS_directives;
|
|
41
|
+
let __VLS_styleScopedClasses;
|
|
42
|
+
// CSS variable injection
|
|
43
|
+
// CSS variable injection end
|
|
44
|
+
let __VLS_resolvedLocalAndGlobalComponents;
|
|
45
|
+
const __VLS_0 = __VLS_resolvedLocalAndGlobalComponents.VToolbarItems;
|
|
46
|
+
/** @type { [typeof __VLS_components.VToolbarItems, typeof __VLS_components.vToolbarItems, typeof __VLS_components.VToolbarItems, typeof __VLS_components.vToolbarItems, ] } */
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
const __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0({ ...{ class: ("lang-switcher") }, }));
|
|
49
|
+
const __VLS_2 = __VLS_1({ ...{ class: ("lang-switcher") }, }, ...__VLS_functionalComponentArgsRest(__VLS_1));
|
|
50
|
+
if (__VLS_ctx.locales.length > 1) {
|
|
51
|
+
const __VLS_6 = __VLS_resolvedLocalAndGlobalComponents.VSpeedDial;
|
|
52
|
+
/** @type { [typeof __VLS_components.VSpeedDial, typeof __VLS_components.vSpeedDial, typeof __VLS_components.VSpeedDial, typeof __VLS_components.vSpeedDial, ] } */
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
const __VLS_7 = __VLS_asFunctionalComponent(__VLS_6, new __VLS_6({ direction: ("bottom"), transition: ("fade-transition"), }));
|
|
55
|
+
const __VLS_8 = __VLS_7({ direction: ("bottom"), transition: ("fade-transition"), }, ...__VLS_functionalComponentArgsRest(__VLS_7));
|
|
56
|
+
__VLS_elementAsFunction(__VLS_intrinsicElements.template, __VLS_intrinsicElements.template)({});
|
|
57
|
+
{
|
|
58
|
+
const { activator: __VLS_thisSlot } = __VLS_nonNullable(__VLS_11.slots);
|
|
59
|
+
const [{ props }] = __VLS_getSlotParams(__VLS_thisSlot);
|
|
60
|
+
const __VLS_12 = __VLS_resolvedLocalAndGlobalComponents.VBtn;
|
|
61
|
+
/** @type { [typeof __VLS_components.VBtn, typeof __VLS_components.vBtn, typeof __VLS_components.VBtn, typeof __VLS_components.vBtn, ] } */
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
const __VLS_13 = __VLS_asFunctionalComponent(__VLS_12, new __VLS_12({ ...(props), }));
|
|
64
|
+
const __VLS_14 = __VLS_13({ ...(props), }, ...__VLS_functionalComponentArgsRest(__VLS_13));
|
|
65
|
+
(__VLS_ctx.session.lang.value);
|
|
66
|
+
__VLS_nonNullable(__VLS_17.slots).default;
|
|
67
|
+
const __VLS_17 = __VLS_pickFunctionalComponentCtx(__VLS_12, __VLS_14);
|
|
68
|
+
}
|
|
69
|
+
for (const [locale] of __VLS_getVForSourceType((__VLS_ctx.locales.filter(l => l !== __VLS_ctx.session.lang.value)))) {
|
|
70
|
+
const __VLS_18 = __VLS_resolvedLocalAndGlobalComponents.VBtn;
|
|
71
|
+
/** @type { [typeof __VLS_components.VBtn, typeof __VLS_components.vBtn, typeof __VLS_components.VBtn, typeof __VLS_components.vBtn, ] } */
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
const __VLS_19 = __VLS_asFunctionalComponent(__VLS_18, new __VLS_18({ ...{ 'onClick': {} }, key: ((locale)), icon: (true), }));
|
|
74
|
+
const __VLS_20 = __VLS_19({ ...{ 'onClick': {} }, key: ((locale)), icon: (true), }, ...__VLS_functionalComponentArgsRest(__VLS_19));
|
|
75
|
+
let __VLS_24;
|
|
76
|
+
const __VLS_25 = {
|
|
77
|
+
onClick: (...[$event]) => {
|
|
78
|
+
if (!((__VLS_ctx.locales.length > 1)))
|
|
79
|
+
return;
|
|
80
|
+
__VLS_ctx.setLocale(locale);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
let __VLS_21;
|
|
84
|
+
let __VLS_22;
|
|
85
|
+
(locale);
|
|
86
|
+
__VLS_nonNullable(__VLS_23.slots).default;
|
|
87
|
+
const __VLS_23 = __VLS_pickFunctionalComponentCtx(__VLS_18, __VLS_20);
|
|
88
|
+
}
|
|
89
|
+
const __VLS_11 = __VLS_pickFunctionalComponentCtx(__VLS_6, __VLS_8);
|
|
90
|
+
}
|
|
91
|
+
__VLS_nonNullable(__VLS_5.slots).default;
|
|
92
|
+
const __VLS_5 = __VLS_pickFunctionalComponentCtx(__VLS_0, __VLS_2);
|
|
93
|
+
__VLS_styleScopedClasses['lang-switcher'];
|
|
94
|
+
var __VLS_slots;
|
|
95
|
+
var __VLS_inheritedAttrs;
|
|
96
|
+
const __VLS_refs = {};
|
|
97
|
+
var $refs;
|
|
98
|
+
return {
|
|
99
|
+
slots: __VLS_slots,
|
|
100
|
+
refs: $refs,
|
|
101
|
+
attrs: {},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
;
|
|
105
|
+
const __VLS_self = (await import('vue')).defineComponent({
|
|
106
|
+
setup() {
|
|
107
|
+
return {
|
|
108
|
+
session: session,
|
|
109
|
+
locales: locales,
|
|
110
|
+
setLocale: setLocale,
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
props: {
|
|
114
|
+
locales: {
|
|
115
|
+
type: Array,
|
|
116
|
+
default: ['fr', 'en']
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
export default (await import('vue')).defineComponent({
|
|
121
|
+
setup() {
|
|
122
|
+
return {};
|
|
123
|
+
},
|
|
124
|
+
props: {
|
|
125
|
+
locales: {
|
|
126
|
+
type: Array,
|
|
127
|
+
default: ['fr', 'en']
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
;
|
|
132
|
+
//# sourceMappingURL=lang-switcher.vue.js.map
|