@data-fair/lib-vuetify 0.1.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.
@@ -0,0 +1,104 @@
1
+ <!-- produces a string compatible with the _c_date_match filter of data-fair -->
2
+
3
+ <template>
4
+ <v-menu
5
+ v-model="menu"
6
+ :close-on-content-click="false"
7
+ offset-y
8
+ min-width="auto"
9
+ >
10
+ <template #activator="{ props }">
11
+ <v-btn
12
+ v-model="date"
13
+ icon
14
+ color="white"
15
+ density="comfortable"
16
+ class="mx-1 mt-1"
17
+ v-bind="props"
18
+ >
19
+ <v-icon color="primary">
20
+ mdi-calendar
21
+ </v-icon>
22
+ </v-btn>
23
+ </template>
24
+ <v-sheet>
25
+ <h3
26
+ v-if="rangeMode"
27
+ class="text-h6 px-2"
28
+ >
29
+ Sélectionnez un interval entre 2 dates
30
+ </h3>
31
+ <h3
32
+ v-else
33
+ class="text-h6 px-2"
34
+ >
35
+ Sélectionnez une date
36
+ </h3>
37
+ <v-date-picker
38
+ v-model="date"
39
+ :multiple="rangeMode"
40
+ hide-header
41
+ show-adjacent-months
42
+ flat
43
+ />
44
+ </v-sheet>
45
+ </v-menu>
46
+ </template>
47
+
48
+ <script lang="ts">
49
+ // 1 => 01, 12 => 12
50
+ const padTimeComponent = (val: number) => {
51
+ const s = '' + val
52
+ return s.length === 1 ? '0' + s : s
53
+ }
54
+
55
+ // get the the date and short time components expected by date-time picker from a full date
56
+ // 2020-04-03T21:07:43+02:00 => ['2020-04-03', '19:07']
57
+ const getDateTimeParts = (date: Date) => {
58
+ return [`${date.getFullYear()}-${padTimeComponent(date.getMonth() + 1)}-${padTimeComponent(date.getDate())}`, `${padTimeComponent(date.getHours())}:${padTimeComponent(date.getMinutes())}`]
59
+ }
60
+
61
+ export default {
62
+ props: {
63
+ modelValue: {
64
+ type: String,
65
+ default: null
66
+ },
67
+ rangeMode: {
68
+ type: Boolean,
69
+ default: false
70
+ }
71
+ },
72
+ emits: ['update:modelValue'],
73
+ data: () => ({
74
+ menu: false
75
+ }),
76
+ computed: {
77
+ date: {
78
+ get (): Date | Date[] | null {
79
+ if (!this.modelValue) return null
80
+ if (this.rangeMode) return this.modelValue.split(',').map(v => new Date(v))
81
+ return this.modelValue ? new Date(this.modelValue) : null
82
+ },
83
+ set (value: Date | Date[]) {
84
+ if (Array.isArray(value)) {
85
+ const dates = value.map(v => getDateTimeParts(v)[0])
86
+ dates.sort()
87
+ const newValue = dates[0] + ',' + dates[dates.length - 1]
88
+ if (newValue !== this.modelValue) {
89
+ this.$emit('update:modelValue', dates[0] + ',' + dates[dates.length - 1])
90
+ if (dates.length >= 2) this.menu = false
91
+ }
92
+ } else {
93
+ const newValue = getDateTimeParts(value)[0] === this.modelValue ? undefined : getDateTimeParts(value)[0]
94
+ this.$emit('update:modelValue', newValue)
95
+ this.menu = false
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ </script>
102
+
103
+ <style lang="css">
104
+ </style>
@@ -0,0 +1,32 @@
1
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ modelValue: {
3
+ type: StringConstructor;
4
+ default: null;
5
+ };
6
+ rangeMode: {
7
+ type: BooleanConstructor;
8
+ default: boolean;
9
+ };
10
+ }>, {}, {
11
+ menu: boolean;
12
+ }, {
13
+ date: {
14
+ get(): Date | Date[] | null;
15
+ set(value: Date | Date[]): void;
16
+ };
17
+ }, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
18
+ modelValue: {
19
+ type: StringConstructor;
20
+ default: null;
21
+ };
22
+ rangeMode: {
23
+ type: BooleanConstructor;
24
+ default: boolean;
25
+ };
26
+ }>> & Readonly<{
27
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
28
+ }>, {
29
+ modelValue: string;
30
+ rangeMode: boolean;
31
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
32
+ export default _default;
@@ -0,0 +1,133 @@
1
+ /// <reference types=".vue-global-types/vue_3.5_false.d.ts" />
2
+ // 1 => 01, 12 => 12
3
+ const padTimeComponent = (val) => {
4
+ const s = '' + val;
5
+ return s.length === 1 ? '0' + s : s;
6
+ };
7
+ // get the the date and short time components expected by date-time picker from a full date
8
+ // 2020-04-03T21:07:43+02:00 => ['2020-04-03', '19:07']
9
+ const getDateTimeParts = (date) => {
10
+ return [`${date.getFullYear()}-${padTimeComponent(date.getMonth() + 1)}-${padTimeComponent(date.getDate())}`, `${padTimeComponent(date.getHours())}:${padTimeComponent(date.getMinutes())}`];
11
+ };
12
+ export default (await import('vue')).defineComponent({
13
+ props: {
14
+ modelValue: {
15
+ type: String,
16
+ default: null
17
+ },
18
+ rangeMode: {
19
+ type: Boolean,
20
+ default: false
21
+ }
22
+ },
23
+ emits: ['update:modelValue'],
24
+ data: () => ({
25
+ menu: false
26
+ }),
27
+ computed: {
28
+ date: {
29
+ get() {
30
+ if (!this.modelValue)
31
+ return null;
32
+ if (this.rangeMode)
33
+ return this.modelValue.split(',').map(v => new Date(v));
34
+ return this.modelValue ? new Date(this.modelValue) : null;
35
+ },
36
+ set(value) {
37
+ if (Array.isArray(value)) {
38
+ const dates = value.map(v => getDateTimeParts(v)[0]);
39
+ dates.sort();
40
+ const newValue = dates[0] + ',' + dates[dates.length - 1];
41
+ if (newValue !== this.modelValue) {
42
+ this.$emit('update:modelValue', dates[0] + ',' + dates[dates.length - 1]);
43
+ if (dates.length >= 2)
44
+ this.menu = false;
45
+ }
46
+ }
47
+ else {
48
+ const newValue = getDateTimeParts(value)[0] === this.modelValue ? undefined : getDateTimeParts(value)[0];
49
+ this.$emit('update:modelValue', newValue);
50
+ this.menu = false;
51
+ }
52
+ }
53
+ }
54
+ }
55
+ });
56
+ function __VLS_template() {
57
+ const __VLS_ctx = {};
58
+ const __VLS_localComponents = {
59
+ ...{},
60
+ ...__VLS_ctx,
61
+ };
62
+ let __VLS_components;
63
+ const __VLS_localDirectives = {
64
+ ...{},
65
+ ...__VLS_ctx,
66
+ };
67
+ let __VLS_directives;
68
+ let __VLS_styleScopedClasses;
69
+ // CSS variable injection
70
+ // CSS variable injection end
71
+ let __VLS_resolvedLocalAndGlobalComponents;
72
+ const __VLS_0 = __VLS_resolvedLocalAndGlobalComponents.VMenu;
73
+ /** @type { [typeof __VLS_components.VMenu, typeof __VLS_components.vMenu, typeof __VLS_components.VMenu, typeof __VLS_components.vMenu, ] } */
74
+ // @ts-ignore
75
+ const __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0({ modelValue: ((__VLS_ctx.menu)), closeOnContentClick: ((false)), offsetY: (true), minWidth: ("auto"), }));
76
+ const __VLS_2 = __VLS_1({ modelValue: ((__VLS_ctx.menu)), closeOnContentClick: ((false)), offsetY: (true), minWidth: ("auto"), }, ...__VLS_functionalComponentArgsRest(__VLS_1));
77
+ __VLS_elementAsFunction(__VLS_intrinsicElements.template, __VLS_intrinsicElements.template)({});
78
+ {
79
+ const { activator: __VLS_thisSlot } = __VLS_nonNullable(__VLS_5.slots);
80
+ const [{ props }] = __VLS_getSlotParams(__VLS_thisSlot);
81
+ const __VLS_6 = __VLS_resolvedLocalAndGlobalComponents.VBtn;
82
+ /** @type { [typeof __VLS_components.VBtn, typeof __VLS_components.vBtn, typeof __VLS_components.VBtn, typeof __VLS_components.vBtn, ] } */
83
+ // @ts-ignore
84
+ const __VLS_7 = __VLS_asFunctionalComponent(__VLS_6, new __VLS_6({ modelValue: ((__VLS_ctx.date)), icon: (true), color: ("white"), density: ("comfortable"), ...{ class: ("mx-1 mt-1") }, ...(props), }));
85
+ const __VLS_8 = __VLS_7({ modelValue: ((__VLS_ctx.date)), icon: (true), color: ("white"), density: ("comfortable"), ...{ class: ("mx-1 mt-1") }, ...(props), }, ...__VLS_functionalComponentArgsRest(__VLS_7));
86
+ const __VLS_12 = __VLS_resolvedLocalAndGlobalComponents.VIcon;
87
+ /** @type { [typeof __VLS_components.VIcon, typeof __VLS_components.vIcon, typeof __VLS_components.VIcon, typeof __VLS_components.vIcon, ] } */
88
+ // @ts-ignore
89
+ const __VLS_13 = __VLS_asFunctionalComponent(__VLS_12, new __VLS_12({ color: ("primary"), }));
90
+ const __VLS_14 = __VLS_13({ color: ("primary"), }, ...__VLS_functionalComponentArgsRest(__VLS_13));
91
+ __VLS_nonNullable(__VLS_17.slots).default;
92
+ const __VLS_17 = __VLS_pickFunctionalComponentCtx(__VLS_12, __VLS_14);
93
+ __VLS_nonNullable(__VLS_11.slots).default;
94
+ const __VLS_11 = __VLS_pickFunctionalComponentCtx(__VLS_6, __VLS_8);
95
+ }
96
+ const __VLS_18 = __VLS_resolvedLocalAndGlobalComponents.VSheet;
97
+ /** @type { [typeof __VLS_components.VSheet, typeof __VLS_components.vSheet, typeof __VLS_components.VSheet, typeof __VLS_components.vSheet, ] } */
98
+ // @ts-ignore
99
+ const __VLS_19 = __VLS_asFunctionalComponent(__VLS_18, new __VLS_18({}));
100
+ const __VLS_20 = __VLS_19({}, ...__VLS_functionalComponentArgsRest(__VLS_19));
101
+ if (__VLS_ctx.rangeMode) {
102
+ __VLS_elementAsFunction(__VLS_intrinsicElements.h3, __VLS_intrinsicElements.h3)({ ...{ class: ("text-h6 px-2") }, });
103
+ }
104
+ else {
105
+ __VLS_elementAsFunction(__VLS_intrinsicElements.h3, __VLS_intrinsicElements.h3)({ ...{ class: ("text-h6 px-2") }, });
106
+ }
107
+ const __VLS_24 = __VLS_resolvedLocalAndGlobalComponents.VDatePicker;
108
+ /** @type { [typeof __VLS_components.VDatePicker, typeof __VLS_components.vDatePicker, ] } */
109
+ // @ts-ignore
110
+ const __VLS_25 = __VLS_asFunctionalComponent(__VLS_24, new __VLS_24({ modelValue: ((__VLS_ctx.date)), multiple: ((__VLS_ctx.rangeMode)), hideHeader: (true), showAdjacentMonths: (true), flat: (true), }));
111
+ const __VLS_26 = __VLS_25({ modelValue: ((__VLS_ctx.date)), multiple: ((__VLS_ctx.rangeMode)), hideHeader: (true), showAdjacentMonths: (true), flat: (true), }, ...__VLS_functionalComponentArgsRest(__VLS_25));
112
+ __VLS_nonNullable(__VLS_23.slots).default;
113
+ const __VLS_23 = __VLS_pickFunctionalComponentCtx(__VLS_18, __VLS_20);
114
+ const __VLS_5 = __VLS_pickFunctionalComponentCtx(__VLS_0, __VLS_2);
115
+ __VLS_styleScopedClasses['mx-1'];
116
+ __VLS_styleScopedClasses['mt-1'];
117
+ __VLS_styleScopedClasses['text-h6'];
118
+ __VLS_styleScopedClasses['px-2'];
119
+ __VLS_styleScopedClasses['text-h6'];
120
+ __VLS_styleScopedClasses['px-2'];
121
+ var __VLS_slots;
122
+ var __VLS_inheritedAttrs;
123
+ const __VLS_refs = {};
124
+ var $refs;
125
+ return {
126
+ slots: __VLS_slots,
127
+ refs: $refs,
128
+ attrs: {},
129
+ };
130
+ }
131
+ ;
132
+ let __VLS_self;
133
+ //# sourceMappingURL=date-match-filter.vue.js.map
@@ -0,0 +1,76 @@
1
+ <script setup>
2
+ import { ref, watch } from 'vue'
3
+
4
+ const props = defineProps({
5
+ min: { type: String, default: undefined },
6
+ max: { type: String, default: undefined },
7
+ label: { type: String, default: undefined }
8
+ })
9
+
10
+ const model = defineModel({ type: String })
11
+ const initialValue = (model.value || '').split(',')
12
+ const start = ref((initialValue.length && initialValue[0]) || props.min)
13
+ const end = ref((initialValue.length && initialValue[initialValue.length - 1]) || props.max)
14
+
15
+ watch(model, (val) => {
16
+ const value = (val || '').split(',')
17
+ start.value = value.length ? value[0] : undefined
18
+ end.value = value.length ? value[value.length - 1] : undefined
19
+ })
20
+
21
+ watch(start, (val) => {
22
+ const value = [end.value]
23
+ if (val !== end.value) value.unshift(val)
24
+ model.value = value.join(',')
25
+ })
26
+
27
+ watch(end, (val) => {
28
+ const value = [start.value]
29
+ if (val !== start.value) value.push(val)
30
+ model.value = value.join(',')
31
+ })
32
+ </script>
33
+
34
+ <template>
35
+ <label
36
+ v-if="props.label"
37
+ class="text-body-2 text-medium-emphasis ml-2"
38
+ >{{ label }}</label>
39
+ <v-row
40
+ v-if="model && model.length"
41
+ class="date-range-picker"
42
+ align="center"
43
+ >
44
+ <v-col class="pr-0">
45
+ <v-text-field
46
+ v-model="start"
47
+ :min="min"
48
+ :max="max"
49
+ type="date"
50
+ density="compact"
51
+ />
52
+ </v-col>
53
+ <span class="pb-6">~</span>
54
+ <v-col class="pl-0">
55
+ <v-text-field
56
+ v-model="end"
57
+ :min="min"
58
+ :max="max"
59
+ type="date"
60
+ density="compact"
61
+ />
62
+ </v-col>
63
+ </v-row>
64
+ </template>
65
+
66
+ <style>
67
+ .date-range-picker .v-input__control input{
68
+ padding-left: 8px;
69
+ padding-right: 8px;
70
+ }
71
+
72
+ .date-range-picker .v-input__control label{
73
+ left: -8px;
74
+ right: -8px;
75
+ }
76
+ </style>
@@ -0,0 +1,11 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {
2
+ label?: string | undefined;
3
+ max?: string | undefined;
4
+ min?: string | undefined;
5
+ $props: {
6
+ readonly label?: string | undefined;
7
+ readonly max?: string | undefined;
8
+ readonly min?: string | undefined;
9
+ };
10
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
11
+ export default _default;
@@ -0,0 +1,134 @@
1
+ /// <reference types=".vue-global-types/vue_3.5_false.d.ts" />
2
+ import { ref, watch } from 'vue';
3
+ const { defineProps, defineSlots, defineEmits, defineExpose, defineModel, defineOptions, withDefaults, } = await import('vue');
4
+ const props = defineProps({
5
+ min: { type: String, default: undefined },
6
+ max: { type: String, default: undefined },
7
+ label: { type: String, default: undefined }
8
+ });
9
+ const model = defineModel({ type: String });
10
+ const initialValue = (model.value || '').split(',');
11
+ const start = ref((initialValue.length && initialValue[0]) || props.min);
12
+ const end = ref((initialValue.length && initialValue[initialValue.length - 1]) || props.max);
13
+ watch(model, (val) => {
14
+ const value = (val || '').split(',');
15
+ start.value = value.length ? value[0] : undefined;
16
+ end.value = value.length ? value[value.length - 1] : undefined;
17
+ });
18
+ watch(start, (val) => {
19
+ const value = [end.value];
20
+ if (val !== end.value)
21
+ value.unshift(val);
22
+ model.value = value.join(',');
23
+ });
24
+ watch(end, (val) => {
25
+ const value = [start.value];
26
+ if (val !== start.value)
27
+ value.push(val);
28
+ model.value = value.join(',');
29
+ });
30
+ const __VLS_fnComponent = (await import('vue')).defineComponent({
31
+ props: {
32
+ min: { type: String, default: undefined },
33
+ max: { type: String, default: undefined },
34
+ label: { type: String, default: undefined }
35
+ },
36
+ __typeEmits: {},
37
+ });
38
+ ;
39
+ let __VLS_functionalComponentProps;
40
+ const __VLS_defaults = {};
41
+ function __VLS_template() {
42
+ const __VLS_ctx = {};
43
+ const __VLS_localComponents = {
44
+ ...{},
45
+ ...{},
46
+ ...__VLS_ctx,
47
+ };
48
+ let __VLS_components;
49
+ const __VLS_localDirectives = {
50
+ ...{},
51
+ ...__VLS_ctx,
52
+ };
53
+ let __VLS_directives;
54
+ let __VLS_styleScopedClasses;
55
+ // CSS variable injection
56
+ // CSS variable injection end
57
+ let __VLS_resolvedLocalAndGlobalComponents;
58
+ if (props.label) {
59
+ __VLS_elementAsFunction(__VLS_intrinsicElements.label, __VLS_intrinsicElements.label)({ ...{ class: ("text-body-2 text-medium-emphasis ml-2") }, });
60
+ (__VLS_ctx.label);
61
+ }
62
+ if (__VLS_ctx.model && __VLS_ctx.model.length) {
63
+ const __VLS_0 = __VLS_resolvedLocalAndGlobalComponents.VRow;
64
+ /** @type { [typeof __VLS_components.VRow, typeof __VLS_components.vRow, typeof __VLS_components.VRow, typeof __VLS_components.vRow, ] } */
65
+ // @ts-ignore
66
+ const __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0({ ...{ class: ("date-range-picker") }, align: ("center"), }));
67
+ const __VLS_2 = __VLS_1({ ...{ class: ("date-range-picker") }, align: ("center"), }, ...__VLS_functionalComponentArgsRest(__VLS_1));
68
+ const __VLS_6 = __VLS_resolvedLocalAndGlobalComponents.VCol;
69
+ /** @type { [typeof __VLS_components.VCol, typeof __VLS_components.vCol, typeof __VLS_components.VCol, typeof __VLS_components.vCol, ] } */
70
+ // @ts-ignore
71
+ const __VLS_7 = __VLS_asFunctionalComponent(__VLS_6, new __VLS_6({ ...{ class: ("pr-0") }, }));
72
+ const __VLS_8 = __VLS_7({ ...{ class: ("pr-0") }, }, ...__VLS_functionalComponentArgsRest(__VLS_7));
73
+ const __VLS_12 = __VLS_resolvedLocalAndGlobalComponents.VTextField;
74
+ /** @type { [typeof __VLS_components.VTextField, typeof __VLS_components.vTextField, ] } */
75
+ // @ts-ignore
76
+ const __VLS_13 = __VLS_asFunctionalComponent(__VLS_12, new __VLS_12({ modelValue: ((__VLS_ctx.start)), min: ((__VLS_ctx.min)), max: ((__VLS_ctx.max)), type: ("date"), density: ("compact"), }));
77
+ const __VLS_14 = __VLS_13({ modelValue: ((__VLS_ctx.start)), min: ((__VLS_ctx.min)), max: ((__VLS_ctx.max)), type: ("date"), density: ("compact"), }, ...__VLS_functionalComponentArgsRest(__VLS_13));
78
+ __VLS_nonNullable(__VLS_11.slots).default;
79
+ const __VLS_11 = __VLS_pickFunctionalComponentCtx(__VLS_6, __VLS_8);
80
+ __VLS_elementAsFunction(__VLS_intrinsicElements.span, __VLS_intrinsicElements.span)({ ...{ class: ("pb-6") }, });
81
+ const __VLS_18 = __VLS_resolvedLocalAndGlobalComponents.VCol;
82
+ /** @type { [typeof __VLS_components.VCol, typeof __VLS_components.vCol, typeof __VLS_components.VCol, typeof __VLS_components.vCol, ] } */
83
+ // @ts-ignore
84
+ const __VLS_19 = __VLS_asFunctionalComponent(__VLS_18, new __VLS_18({ ...{ class: ("pl-0") }, }));
85
+ const __VLS_20 = __VLS_19({ ...{ class: ("pl-0") }, }, ...__VLS_functionalComponentArgsRest(__VLS_19));
86
+ const __VLS_24 = __VLS_resolvedLocalAndGlobalComponents.VTextField;
87
+ /** @type { [typeof __VLS_components.VTextField, typeof __VLS_components.vTextField, ] } */
88
+ // @ts-ignore
89
+ const __VLS_25 = __VLS_asFunctionalComponent(__VLS_24, new __VLS_24({ modelValue: ((__VLS_ctx.end)), min: ((__VLS_ctx.min)), max: ((__VLS_ctx.max)), type: ("date"), density: ("compact"), }));
90
+ const __VLS_26 = __VLS_25({ modelValue: ((__VLS_ctx.end)), min: ((__VLS_ctx.min)), max: ((__VLS_ctx.max)), type: ("date"), density: ("compact"), }, ...__VLS_functionalComponentArgsRest(__VLS_25));
91
+ __VLS_nonNullable(__VLS_23.slots).default;
92
+ const __VLS_23 = __VLS_pickFunctionalComponentCtx(__VLS_18, __VLS_20);
93
+ __VLS_nonNullable(__VLS_5.slots).default;
94
+ const __VLS_5 = __VLS_pickFunctionalComponentCtx(__VLS_0, __VLS_2);
95
+ }
96
+ __VLS_styleScopedClasses['text-body-2'];
97
+ __VLS_styleScopedClasses['text-medium-emphasis'];
98
+ __VLS_styleScopedClasses['ml-2'];
99
+ __VLS_styleScopedClasses['date-range-picker'];
100
+ __VLS_styleScopedClasses['pr-0'];
101
+ __VLS_styleScopedClasses['pb-6'];
102
+ __VLS_styleScopedClasses['pl-0'];
103
+ var __VLS_slots;
104
+ var __VLS_inheritedAttrs;
105
+ const __VLS_refs = {};
106
+ var $refs;
107
+ return {
108
+ slots: __VLS_slots,
109
+ refs: $refs,
110
+ attrs: {},
111
+ };
112
+ }
113
+ ;
114
+ const __VLS_self = (await import('vue')).defineComponent({
115
+ setup() {
116
+ return {
117
+ $props: __VLS_makeOptional(props),
118
+ ...props,
119
+ model: model,
120
+ start: start,
121
+ end: end,
122
+ };
123
+ },
124
+ });
125
+ export default (await import('vue')).defineComponent({
126
+ setup() {
127
+ return {
128
+ $props: __VLS_makeOptional(props),
129
+ ...props,
130
+ };
131
+ },
132
+ });
133
+ ;
134
+ //# sourceMappingURL=date-range-picker.vue.js.map
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { VuetifyOptions } from 'vuetify';
2
+ export declare function defaultOptions(searchParams: Record<string, string>, darkCookie?: boolean): VuetifyOptions;
package/index.js ADDED
@@ -0,0 +1,53 @@
1
+ import { fr, en } from 'vuetify/locale'
2
+ const baseColors = {
3
+ primary: '#1E88E5', // blue.darken1
4
+ secondary: '#42A5F5', // blue.lighten1,
5
+ accent: '#FF9800', // orange.base
6
+ error: '#FF5252', // red.accent2
7
+ info: '#2196F3', // blue.base
8
+ success: '#4CAF50', // green.base
9
+ warning: '#E91E63', // pink.base
10
+ admin: '#E53935' // red.darken1
11
+ }
12
+ const baseDarkColors = {
13
+ primary: '#2196F3', // blue.base
14
+ success: '#00E676' // green.accent3
15
+ }
16
+ export function defaultOptions (searchParams, darkCookie = false) {
17
+ const dark = searchParams?.dark ? searchParams.dark === 'true' : darkCookie
18
+ const searchParamsColors = {}
19
+ for (const colorCode of ['primary', 'secondary']) {
20
+ if (searchParams?.[colorCode]) { searchParamsColors[colorCode] = searchParams[colorCode] }
21
+ }
22
+ const lightColors = { ...baseColors, ...searchParamsColors }
23
+ const darkColors = { ...baseColors, ...baseDarkColors, ...searchParamsColors }
24
+ const defaultTheme = dark ? 'dark' : 'light'
25
+ return {
26
+ ssr: false,
27
+ locale: {
28
+ locale: 'fr',
29
+ messages: { fr, en }
30
+ }, // TODO: sync this with the i18n locale
31
+ theme: {
32
+ defaultTheme,
33
+ themes: {
34
+ light: {
35
+ dark: false,
36
+ colors: lightColors
37
+ },
38
+ dark: {
39
+ dark: true,
40
+ colors: darkColors
41
+ }
42
+ }
43
+ },
44
+ defaults: {
45
+ VCard: {
46
+ // grey outlined card by default
47
+ variant: 'outlined',
48
+ style: 'border-color: rgba(var(--v-theme-on-surface), var(--v-focus-opacity)) !important;'
49
+ }
50
+ }
51
+ }
52
+ }
53
+ // # sourceMappingURL=index.js.map
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <v-tooltip location="top">
3
+ <template #activator="{ props }">
4
+ <span
5
+ v-bind="props"
6
+ class="text-body-2"
7
+ >
8
+ <v-avatar :size="28">
9
+ <img
10
+ :src="avatarUrl"
11
+ style="object-fit: cover; width: 100%; height: 100%;"
12
+ >
13
+ </v-avatar>
14
+ </span>
15
+ </template>
16
+ {{ label }}
17
+ </v-tooltip>
18
+ </template>
19
+
20
+ <script setup>
21
+ import { computed } from 'vue'
22
+
23
+ const ownerProps = defineProps({
24
+ owner: {
25
+ type: Object,
26
+ default: null
27
+ }
28
+ })
29
+
30
+ const avatarUrl = computed(() => {
31
+ if (ownerProps.owner.department) return `/simple-directory/api/avatars/${ownerProps.owner.type}/${ownerProps.owner.id}/${ownerProps.owner.department}/avatar.png`
32
+ else return `/simple-directory/api/avatars/${ownerProps.owner.type}/${ownerProps.owner.id}/avatar.png`
33
+ })
34
+
35
+ const label = computed(() => {
36
+ let label = ownerProps.owner.name
37
+ if (ownerProps.owner.department) label += ' - ' + (ownerProps.owner.departmentName || ownerProps.owner.department)
38
+ if (ownerProps.owner.role) label += ` (${ownerProps.owner.role})`
39
+ return label
40
+ })
41
+ </script>
42
+
43
+ <style>
44
+ </style>
@@ -0,0 +1,7 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {
2
+ owner: Record<string, any>;
3
+ $props: {
4
+ readonly owner?: Record<string, any> | undefined;
5
+ };
6
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
7
+ export default _default;