nuxt-outfit 1.2.2 → 1.2.4
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 +1 -1
- package/dist/runtime/composables/useEcho.d.ts +4 -0
- package/dist/runtime/composables/useEcho.mjs +6 -0
- package/dist/runtime/composables/useForm.d.ts +1 -1
- package/dist/runtime/composables/useForm.mjs +4 -4
- package/dist/runtime/composables/useSpaHeaders.d.ts +4 -0
- package/dist/runtime/composables/useSpaHeaders.mjs +8 -2
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -4,7 +4,7 @@ export declare const useForm: (opts?: {}) => {
|
|
|
4
4
|
repeatArray: (property: any) => void;
|
|
5
5
|
removeArray: (property: any, index: any) => void;
|
|
6
6
|
isPending: import("vue").Ref<boolean>;
|
|
7
|
-
handleSubmit: () => Promise<void>;
|
|
7
|
+
handleSubmit: (action?: null) => Promise<void>;
|
|
8
8
|
clearError: (field: any) => void;
|
|
9
9
|
reset: () => void;
|
|
10
10
|
onSuccess: (callback: any) => void;
|
|
@@ -81,12 +81,12 @@ export const useForm = (opts = {}) => {
|
|
|
81
81
|
_onSuccess(hit);
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
const validate = () => {
|
|
85
|
-
return opts?.schema.validate(deepClone(fields), { abortEarly: false }).then((validated) => http(opts?.action, { method: "POST", body: validated })).then((hit) => handleSuccess(hit)).catch((fail) => handleFail(fail));
|
|
84
|
+
const validate = (action) => {
|
|
85
|
+
return opts?.schema.validate(deepClone(fields), { abortEarly: false }).then((validated) => http(action ?? opts?.action, { method: "POST", body: validated })).then((hit) => handleSuccess(hit)).catch((fail) => handleFail(fail));
|
|
86
86
|
};
|
|
87
|
-
const handleSubmit = async () => {
|
|
87
|
+
const handleSubmit = async (action = null) => {
|
|
88
88
|
processing();
|
|
89
|
-
await validate();
|
|
89
|
+
await validate(action);
|
|
90
90
|
processed();
|
|
91
91
|
};
|
|
92
92
|
return {
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { useRuntimeConfig, useRequestEvent, useRequestHeaders } from "#imports";
|
|
1
|
+
import { useRuntimeConfig, useRequestEvent, useRequestHeaders, useEcho } from "#imports";
|
|
2
2
|
import { appendHeader } from "h3";
|
|
3
3
|
import { parse, splitCookiesString as split } from "set-cookie-parser";
|
|
4
4
|
import { serialize } from "cookie";
|
|
5
5
|
export const useSpaHeaders = (additionalHeaders = {}) => {
|
|
6
6
|
if (process.client) {
|
|
7
|
+
const { getSocketId } = useEcho();
|
|
7
8
|
return {
|
|
8
|
-
headers: additionalHeaders
|
|
9
|
+
headers: additionalHeaders,
|
|
10
|
+
async onRequest({ request, options }) {
|
|
11
|
+
if (getSocketId() !== void 0) {
|
|
12
|
+
options.headers["X-Socket-ID"] = getSocketId();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
9
15
|
};
|
|
10
16
|
}
|
|
11
17
|
const serverUrl = useRuntimeConfig().outfit.serverUrl;
|