nuxt-outfit 1.2.7 → 1.2.9
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/dist/module.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { useRuntimeConfig, useNuxtApp
|
|
1
|
+
import { useRuntimeConfig, useNuxtApp } from "#imports";
|
|
2
2
|
import { ref, reactive } from "vue";
|
|
3
3
|
import { klona as deepClone } from "klona/full";
|
|
4
4
|
import { has, unset } from "lodash-es";
|
|
5
5
|
import flat from "flat";
|
|
6
6
|
export const useForm = (opts = {}) => {
|
|
7
|
+
const { schema } = opts;
|
|
7
8
|
const httpInstance = useRuntimeConfig().public.outfit.httpInstance;
|
|
8
9
|
const http = useNuxtApp()?.[httpInstance] ?? $fetch;
|
|
9
|
-
const snackMessage = useState("snackMessage");
|
|
10
10
|
const fields = reactive(deepClone(opts?.initialValues));
|
|
11
11
|
const isPending = ref(false);
|
|
12
12
|
const errors = ref({});
|
|
@@ -66,8 +66,6 @@ export const useForm = (opts = {}) => {
|
|
|
66
66
|
} else if (fail.name === "FetchError") {
|
|
67
67
|
if (fail.data?.errors !== void 0) {
|
|
68
68
|
messages = fail.data.errors;
|
|
69
|
-
} else if (fail.data?.message !== void 0) {
|
|
70
|
-
snackMessage.value = { message: fail.data?.message, type: "error" };
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
71
|
setErrors(unflatten(messages));
|
|
@@ -100,6 +98,7 @@ export const useForm = (opts = {}) => {
|
|
|
100
98
|
clearError,
|
|
101
99
|
reset,
|
|
102
100
|
onSuccess,
|
|
103
|
-
onFail
|
|
101
|
+
onFail,
|
|
102
|
+
schema
|
|
104
103
|
};
|
|
105
104
|
};
|