@falcondev-oss/nuxt-layers-base 0.20.3 → 0.21.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,18 @@
|
|
|
1
|
+
<script setup lang="ts" generic="T">
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
input: T
|
|
4
|
+
}>()
|
|
5
|
+
|
|
6
|
+
const output = defineModel<T>('output', { required: true })
|
|
7
|
+
|
|
8
|
+
watch(
|
|
9
|
+
() => props.input,
|
|
10
|
+
() => {
|
|
11
|
+
output.value = props.input
|
|
12
|
+
},
|
|
13
|
+
{ immediate: true },
|
|
14
|
+
)
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<!-- eslint-disable-next-line vue/valid-template-root -->
|
|
18
|
+
<template></template>
|
|
@@ -2,7 +2,7 @@ import type { FormFieldTranslator } from '@falcondev-oss/form-core'
|
|
|
2
2
|
import type { DateValue } from 'reka-ui'
|
|
3
3
|
import { parseDate } from '@internationalized/date'
|
|
4
4
|
|
|
5
|
-
export function
|
|
5
|
+
export function undefinedNullTranslator<T>() {
|
|
6
6
|
return {
|
|
7
7
|
get(v: T | null) {
|
|
8
8
|
return v ?? undefined
|
|
@@ -12,12 +12,12 @@ export function nullUndefinedTranslator<T>() {
|
|
|
12
12
|
},
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
export function
|
|
15
|
+
export function indeterminateNullTranslator(): FormFieldTranslator<
|
|
16
16
|
boolean | null,
|
|
17
17
|
boolean | 'indeterminate'
|
|
18
18
|
> {
|
|
19
19
|
return {
|
|
20
|
-
get: (v) => v ??
|
|
20
|
+
get: (v) => v ?? 'indeterminate',
|
|
21
21
|
set: (v) => (v === 'indeterminate' ? null : v),
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -26,7 +26,7 @@ export function indeterminateFalseTranslator(): FormFieldTranslator<
|
|
|
26
26
|
boolean | 'indeterminate'
|
|
27
27
|
> {
|
|
28
28
|
return {
|
|
29
|
-
get: (v) =>
|
|
29
|
+
get: (v) => v || 'indeterminate',
|
|
30
30
|
set: (v) => (v === 'indeterminate' ? false : v),
|
|
31
31
|
}
|
|
32
32
|
}
|
package/app/utils/plugins.ts
CHANGED
|
@@ -22,6 +22,25 @@ interface VueQueryNuxtPluginOptions {
|
|
|
22
22
|
queryClientOptions?: QueryClientConfig
|
|
23
23
|
vuePluginOptions?: VueQueryPluginOptions
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
interface ToastOpts {
|
|
27
|
+
title?: string
|
|
28
|
+
description?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface CustomMeta {
|
|
32
|
+
mutationMeta: {
|
|
33
|
+
toast?: {
|
|
34
|
+
success?: ToastOpts
|
|
35
|
+
error?: ToastOpts
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare module '@tanstack/vue-query' {
|
|
41
|
+
interface Register extends CustomMeta {}
|
|
42
|
+
}
|
|
43
|
+
|
|
25
44
|
export function vueQueryPlugin(opts?: VueQueryNuxtPluginOptions) {
|
|
26
45
|
return {
|
|
27
46
|
name: 'vue-query',
|
|
@@ -49,23 +68,37 @@ export function vueQueryPlugin(opts?: VueQueryNuxtPluginOptions) {
|
|
|
49
68
|
},
|
|
50
69
|
},
|
|
51
70
|
mutationCache: new MutationCache({
|
|
52
|
-
|
|
71
|
+
onSuccess(_res, _input, _onMutateRes, mutation) {
|
|
72
|
+
if (mutation.meta?.toast?.success) {
|
|
73
|
+
toast.add({
|
|
74
|
+
preset: 'success',
|
|
75
|
+
duration: 5000,
|
|
76
|
+
...mutation.meta.toast.success,
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
onError(err, _input, __onMutateRes, mutation) {
|
|
53
81
|
console.error(err)
|
|
54
82
|
|
|
55
|
-
if (
|
|
83
|
+
if (mutation.meta?.toast?.error) {
|
|
84
|
+
toast.add({
|
|
85
|
+
preset: 'error',
|
|
86
|
+
duration: 5000,
|
|
87
|
+
...mutation.meta.toast.error,
|
|
88
|
+
})
|
|
89
|
+
} else if (err instanceof TRPCClientError)
|
|
56
90
|
toast.add({
|
|
57
91
|
preset: 'error',
|
|
58
92
|
title: 'Request Error',
|
|
59
93
|
description: err.message,
|
|
60
94
|
duration: 5000,
|
|
61
95
|
})
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
})
|
|
96
|
+
else
|
|
97
|
+
toast.add({
|
|
98
|
+
preset: 'error',
|
|
99
|
+
title: 'An unknown error occurred',
|
|
100
|
+
duration: 5000,
|
|
101
|
+
})
|
|
69
102
|
},
|
|
70
103
|
}),
|
|
71
104
|
}),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@falcondev-oss/nuxt-layers-base",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.0",
|
|
5
5
|
"description": "Nuxt layer with lots of useful helpers and @nuxt/ui components",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "github:falcondev-oss/nuxt-layers",
|