@data-fair/lib-vuetify 1.0.1 → 1.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,11 @@
1
+ // made for https://github.com/unplugin/unplugin-auto-import
2
+ import vueAutoImports from '@data-fair/lib-vue/auto-imports.js'
3
+ export default [
4
+ ...vueAutoImports,
5
+ {
6
+ '@data-fair/lib-vuetify/personal-menu.vue': [['default', 'dfPersonalMenu']],
7
+ '@data-fair/lib-vuetify/tutorial-alert.vue': [['default', 'dfTutorialAlert']],
8
+ '@data-fair/lib-vuetify/user-avatar.vue': [['default', 'dfUserAvatar']]
9
+ }
10
+ ]
11
+ // # sourceMappingURL=auto-imports.js.map
package/default.scss ADDED
@@ -0,0 +1,10 @@
1
+ @use 'vuetify' with (
2
+ $color-pack: false,
3
+ $body-font-family: 'Nunito'
4
+ );
5
+
6
+ // v-icon has an opacity when it is prepended in a list of items.
7
+ // ref: https://github.com/vuetifyjs/vuetify/issues/18760
8
+ .v-icon {
9
+ --v-medium-emphasis-opacity: 1 !important;
10
+ }
package/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import { VuetifyOptions } from 'vuetify';
2
- export declare function defaultOptions(searchParams: Record<string, string>, darkCookie?: boolean): VuetifyOptions;
2
+ export declare function defaultOptions(searchParams: Record<string, string>, darkCookie?: boolean, locale?: 'fr' | 'en'): VuetifyOptions;
package/index.js CHANGED
@@ -13,7 +13,7 @@ const baseDarkColors = {
13
13
  primary: '#2196F3', // blue.base
14
14
  success: '#00E676' // green.accent3
15
15
  }
16
- export function defaultOptions (searchParams, darkCookie = false) {
16
+ export function defaultOptions (searchParams, darkCookie = false, locale = 'fr') {
17
17
  const dark = searchParams?.dark ? searchParams.dark === 'true' : darkCookie
18
18
  const searchParamsColors = {}
19
19
  for (const colorCode of ['primary', 'secondary']) {
@@ -25,9 +25,9 @@ export function defaultOptions (searchParams, darkCookie = false) {
25
25
  return {
26
26
  ssr: false,
27
27
  locale: {
28
- locale: 'fr',
28
+ locale,
29
29
  messages: { fr, en }
30
- }, // TODO: sync this with the i18n locale
30
+ },
31
31
  theme: {
32
32
  defaultTheme,
33
33
  themes: {
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@data-fair/lib-vuetify",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Components based on the Vuetify 3 UI lib for the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "files": [
7
7
  "**/*.js",
8
8
  "**/*.d.ts",
9
- "**/*.vue"
9
+ "**/*.vue",
10
+ "**/*.scss"
10
11
  ],
11
12
  "author": "",
12
13
  "license": "MIT",
@@ -15,13 +16,14 @@
15
16
  "build": "cd .. && npm run build"
16
17
  },
17
18
  "peerDependencies": {
18
- "@data-fair/lib-vue": "^1.0.1",
19
+ "@data-fair/lib-vue": "^1.1.0",
19
20
  "ofetch": "1",
20
21
  "vue-i18n": "10",
21
22
  "vuetify": "3"
22
23
  },
23
24
  "type": "module",
24
25
  "dependencies": {
25
- "@data-fair/lib-common-types": "^1.1.0"
26
+ "@data-fair/lib-common-types": "^1.1.0",
27
+ "@mdi/js": "^7.4.47"
26
28
  }
27
29
  }
@@ -62,7 +62,7 @@ en:
62
62
  </i18n>
63
63
 
64
64
  <script lang="ts">
65
- import { useTheme } from 'vuetify';
65
+ import { useTheme } from 'vuetify'
66
66
 
67
67
  export default {
68
68
  props: {
@@ -73,9 +73,9 @@ export default {
73
73
  initial: { type: Boolean, default: true },
74
74
  persistent: { type: Boolean, default: false }
75
75
  },
76
- setup() {
76
+ setup () {
77
77
  const theme = useTheme()
78
- return {theme}
78
+ return { theme }
79
79
  },
80
80
  data: () => ({
81
81
  show: false
package/ui-notif.vue ADDED
@@ -0,0 +1,66 @@
1
+ <template>
2
+ <v-snackbar
3
+ v-if="notification"
4
+ ref="notificationSnackbar"
5
+ v-model="showNotification"
6
+ class="ui-notification"
7
+ v-bind="fullSnackbarProps"
8
+ >
9
+ <p>{{ notification.msg }}</p>
10
+ <p
11
+ v-if="notification.type === 'error'"
12
+ class="ml-3"
13
+ v-html="notification.errorMsg"
14
+ />
15
+
16
+ <template #actions>
17
+ <v-btn
18
+ icon
19
+ @click.native="showNotification = false"
20
+ >
21
+ <v-icon :icon="mdiClose" />
22
+ </v-btn>
23
+ </template>
24
+ </v-snackbar>
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { computed, ref, watch } from 'vue'
29
+ import { useUiNotif } from '@data-fair/lib-vue/ui-notif.js'
30
+ import inIframe from '@data-fair/lib-utils/in-iframe.js'
31
+ import { mdiClose } from '@mdi/js'
32
+
33
+ const uiNotif = useUiNotif()
34
+
35
+ const notification = computed(() => uiNotif.notification.value)
36
+ const showNotification = ref(false)
37
+
38
+ watch(() => notification.value, async () => {
39
+ showNotification.value = false
40
+ if (!inIframe && notification.value) {
41
+ await new Promise(resolve => setTimeout(resolve, 300))
42
+ showNotification.value = true
43
+ }
44
+ }, {immediate: true})
45
+
46
+ const { snackbarProps } = defineProps({
47
+ snackbarProps: {
48
+ type: Object,
49
+ default () {
50
+ return { tile: true, right: true, bottom: true, timeout: 30000 }
51
+ }
52
+ }
53
+ })
54
+
55
+ const fullSnackbarProps = computed(() => {
56
+ const props = { ...snackbarProps }
57
+ if (!notification.value) return props
58
+ if (notification.value.type === 'error') props.timeout = -1
59
+ props.color = notification.value.type
60
+ return props
61
+ })
62
+
63
+ </script>
64
+
65
+ <style>
66
+ </style>
@@ -0,0 +1,24 @@
1
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ snackbarProps: {
3
+ type: ObjectConstructor;
4
+ default(): {
5
+ tile: boolean;
6
+ right: boolean;
7
+ bottom: boolean;
8
+ timeout: number;
9
+ };
10
+ };
11
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
12
+ snackbarProps: {
13
+ type: ObjectConstructor;
14
+ default(): {
15
+ tile: boolean;
16
+ right: boolean;
17
+ bottom: boolean;
18
+ timeout: number;
19
+ };
20
+ };
21
+ }>> & Readonly<{}>, {
22
+ snackbarProps: Record<string, any>;
23
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
24
+ export default _default;
@@ -0,0 +1,154 @@
1
+ /// <reference types=".vue-global-types/vue_3.5_false.d.ts" />
2
+ import { computed, ref, watch } from 'vue';
3
+ import { useUiNotif } from '@data-fair/lib-vue/ui-notif.js';
4
+ import inIframe from '@data-fair/lib-utils/in-iframe.js';
5
+ import { mdiClose } from '@mdi/js';
6
+ const { defineProps, defineSlots, defineEmits, defineExpose, defineModel, defineOptions, withDefaults, } = await import('vue');
7
+ const uiNotif = useUiNotif();
8
+ const notification = computed(() => uiNotif.notification.value);
9
+ const showNotification = ref(false);
10
+ watch(() => notification.value, async () => {
11
+ showNotification.value = false;
12
+ if (!inIframe && notification.value) {
13
+ await new Promise(resolve => setTimeout(resolve, 300));
14
+ showNotification.value = true;
15
+ }
16
+ }, { immediate: true });
17
+ const __VLS_props = defineProps({
18
+ snackbarProps: {
19
+ type: Object,
20
+ default() {
21
+ return { tile: true, right: true, bottom: true, timeout: 30000 };
22
+ }
23
+ }
24
+ });
25
+ const { snackbarProps } = __VLS_props;
26
+ const fullSnackbarProps = computed(() => {
27
+ const props = { ...snackbarProps };
28
+ if (!notification.value)
29
+ return props;
30
+ if (notification.value.type === 'error')
31
+ props.timeout = -1;
32
+ props.color = notification.value.type;
33
+ return props;
34
+ });
35
+ const __VLS_fnComponent = (await import('vue')).defineComponent({
36
+ props: {
37
+ snackbarProps: {
38
+ type: Object,
39
+ default() {
40
+ return { tile: true, right: true, bottom: true, timeout: 30000 };
41
+ }
42
+ }
43
+ },
44
+ });
45
+ ;
46
+ let __VLS_functionalComponentProps;
47
+ function __VLS_template() {
48
+ const __VLS_ctx = {};
49
+ const __VLS_localComponents = {
50
+ ...{},
51
+ ...{},
52
+ ...__VLS_ctx,
53
+ };
54
+ let __VLS_components;
55
+ const __VLS_localDirectives = {
56
+ ...{},
57
+ ...__VLS_ctx,
58
+ };
59
+ let __VLS_directives;
60
+ let __VLS_styleScopedClasses;
61
+ // CSS variable injection
62
+ // CSS variable injection end
63
+ let __VLS_resolvedLocalAndGlobalComponents;
64
+ if (__VLS_ctx.notification) {
65
+ const __VLS_0 = __VLS_resolvedLocalAndGlobalComponents.VSnackbar;
66
+ /** @type { [typeof __VLS_components.VSnackbar, typeof __VLS_components.vSnackbar, typeof __VLS_components.VSnackbar, typeof __VLS_components.vSnackbar, ] } */
67
+ // @ts-ignore
68
+ const __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0({ ref: ("notificationSnackbar"), modelValue: ((__VLS_ctx.showNotification)), ...{ class: ("ui-notification") }, ...(__VLS_ctx.fullSnackbarProps), }));
69
+ const __VLS_2 = __VLS_1({ ref: ("notificationSnackbar"), modelValue: ((__VLS_ctx.showNotification)), ...{ class: ("ui-notification") }, ...(__VLS_ctx.fullSnackbarProps), }, ...__VLS_functionalComponentArgsRest(__VLS_1));
70
+ // @ts-ignore navigation for `const notificationSnackbar = ref()`
71
+ __VLS_ctx.notificationSnackbar;
72
+ var __VLS_6 = {};
73
+ __VLS_elementAsFunction(__VLS_intrinsicElements.p, __VLS_intrinsicElements.p)({});
74
+ (__VLS_ctx.notification.msg);
75
+ if (__VLS_ctx.notification.type === 'error') {
76
+ __VLS_elementAsFunction(__VLS_intrinsicElements.p)({ ...{ class: ("ml-3") }, });
77
+ __VLS_directiveAsFunction(__VLS_directives.vHtml)(null, { ...__VLS_directiveBindingRestFields, value: (__VLS_ctx.notification.errorMsg) }, null, null);
78
+ }
79
+ __VLS_elementAsFunction(__VLS_intrinsicElements.template, __VLS_intrinsicElements.template)({});
80
+ {
81
+ const { actions: __VLS_thisSlot } = __VLS_nonNullable(__VLS_5.slots);
82
+ const __VLS_7 = __VLS_resolvedLocalAndGlobalComponents.VBtn;
83
+ /** @type { [typeof __VLS_components.VBtn, typeof __VLS_components.vBtn, typeof __VLS_components.VBtn, typeof __VLS_components.vBtn, ] } */
84
+ // @ts-ignore
85
+ const __VLS_8 = __VLS_asFunctionalComponent(__VLS_7, new __VLS_7({ ...{ 'onClick': {} }, icon: (true), }));
86
+ const __VLS_9 = __VLS_8({ ...{ 'onClick': {} }, icon: (true), }, ...__VLS_functionalComponentArgsRest(__VLS_8));
87
+ let __VLS_13;
88
+ const __VLS_14 = {
89
+ onClick: (...[$event]) => {
90
+ if (!((__VLS_ctx.notification)))
91
+ return;
92
+ __VLS_ctx.showNotification = false;
93
+ }
94
+ };
95
+ let __VLS_10;
96
+ let __VLS_11;
97
+ const __VLS_15 = __VLS_resolvedLocalAndGlobalComponents.VIcon;
98
+ /** @type { [typeof __VLS_components.VIcon, typeof __VLS_components.vIcon, ] } */
99
+ // @ts-ignore
100
+ const __VLS_16 = __VLS_asFunctionalComponent(__VLS_15, new __VLS_15({ icon: ((__VLS_ctx.mdiClose)), }));
101
+ const __VLS_17 = __VLS_16({ icon: ((__VLS_ctx.mdiClose)), }, ...__VLS_functionalComponentArgsRest(__VLS_16));
102
+ __VLS_nonNullable(__VLS_12.slots).default;
103
+ const __VLS_12 = __VLS_pickFunctionalComponentCtx(__VLS_7, __VLS_9);
104
+ }
105
+ const __VLS_5 = __VLS_pickFunctionalComponentCtx(__VLS_0, __VLS_2);
106
+ }
107
+ __VLS_styleScopedClasses['ui-notification'];
108
+ __VLS_styleScopedClasses['ml-3'];
109
+ var __VLS_slots;
110
+ var __VLS_inheritedAttrs;
111
+ const __VLS_refs = {
112
+ "notificationSnackbar": __VLS_6,
113
+ };
114
+ var $refs;
115
+ return {
116
+ slots: __VLS_slots,
117
+ refs: $refs,
118
+ attrs: {},
119
+ };
120
+ }
121
+ ;
122
+ const __VLS_self = (await import('vue')).defineComponent({
123
+ setup() {
124
+ return {
125
+ mdiClose: mdiClose,
126
+ notification: notification,
127
+ showNotification: showNotification,
128
+ fullSnackbarProps: fullSnackbarProps,
129
+ };
130
+ },
131
+ props: {
132
+ snackbarProps: {
133
+ type: Object,
134
+ default() {
135
+ return { tile: true, right: true, bottom: true, timeout: 30000 };
136
+ }
137
+ }
138
+ },
139
+ });
140
+ export default (await import('vue')).defineComponent({
141
+ setup() {
142
+ return {};
143
+ },
144
+ props: {
145
+ snackbarProps: {
146
+ type: Object,
147
+ default() {
148
+ return { tile: true, right: true, bottom: true, timeout: 30000 };
149
+ }
150
+ }
151
+ },
152
+ });
153
+ ;
154
+ //# sourceMappingURL=ui-notif.vue.js.map
package/user-avatar.vue CHANGED
@@ -48,10 +48,10 @@ const props = defineProps({
48
48
  })
49
49
 
50
50
  const session = useSession()
51
- const userAvatarUrl = computed(() => session.state.user && `/simple-directory/api/avatars/user/${session.state.user.id}/avatar.png`)
51
+ const userAvatarUrl = computed(() => session.state.user && `${session.options.directoryUrl}/api/avatars/user/${session.state.user.id}/avatar.png`)
52
52
  const accountAvatarUrl = computed(() => {
53
53
  if (!session.state.account) return
54
- let url = `/simple-directory/api/avatars/${session.state.account.type}/${session.state.account.id}`
54
+ let url = `${session.options.directoryUrl}/api/avatars/${session.state.account.type}/${session.state.account.id}`
55
55
  if (session.state.account.department) url += `/${session.state.account.department}`
56
56
  url += '/avatar.png'
57
57
  return url
@@ -6,11 +6,11 @@ const props = defineProps({
6
6
  showAccount: { type: Boolean, default: false }
7
7
  });
8
8
  const session = useSession();
9
- const userAvatarUrl = computed(() => session.state.user && `/simple-directory/api/avatars/user/${session.state.user.id}/avatar.png`);
9
+ const userAvatarUrl = computed(() => session.state.user && `${session.options.directoryUrl}/api/avatars/user/${session.state.user.id}/avatar.png`);
10
10
  const accountAvatarUrl = computed(() => {
11
11
  if (!session.state.account)
12
12
  return;
13
- let url = `/simple-directory/api/avatars/${session.state.account.type}/${session.state.account.id}`;
13
+ let url = `${session.options.directoryUrl}/api/avatars/${session.state.account.type}/${session.state.account.id}`;
14
14
  if (session.state.account.department)
15
15
  url += `/${session.state.account.department}`;
16
16
  url += '/avatar.png';
package/vite.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export declare const autoImports: (string | {
2
+ '@data-fair/lib-vue/session.js': string[];
3
+ '@data-fair/lib-vue/reactive-search-params.js': string[];
4
+ '@data-fair/lib-vue/locale-dayjs.js': string[];
5
+ '@data-fair/lib-vue/concept-filters.js': string[];
6
+ '@data-fair/lib-vue/ui-notif.js': string[];
7
+ } | {
8
+ '@data-fair/lib-vuetify/personal-menu.vue': string[][];
9
+ '@data-fair/lib-vuetify/tutorial-alert.vue': string[][];
10
+ '@data-fair/lib-vuetify/user-avatar.vue': string[][];
11
+ })[];
package/vite.js ADDED
@@ -0,0 +1,11 @@
1
+ // made for https://github.com/unplugin/unplugin-auto-import
2
+ import { autoImports as vueAutoImports } from '@data-fair/lib-vue/vite.js'
3
+ export const autoImports = [
4
+ ...vueAutoImports,
5
+ {
6
+ '@data-fair/lib-vuetify/personal-menu.vue': [['default', 'dfPersonalMenu']],
7
+ '@data-fair/lib-vuetify/tutorial-alert.vue': [['default', 'dfTutorialAlert']],
8
+ '@data-fair/lib-vuetify/user-avatar.vue': [['default', 'dfUserAvatar']]
9
+ }
10
+ ]
11
+ // # sourceMappingURL=vite.js.map