@tanstack/react-form 0.25.2 → 0.26.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.
- package/README.md +1 -1
- package/dist/cjs/start/getFormData.cjs +2 -3
- package/dist/cjs/start/getFormData.cjs.map +1 -1
- package/dist/cjs/start/getFormData.d.cts +4 -1
- package/dist/esm/start/getFormData.d.ts +4 -1
- package/dist/esm/start/getFormData.js +2 -3
- package/dist/esm/start/getFormData.js.map +1 -1
- package/package.json +12 -12
- package/src/start/getFormData.tsx +5 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<img src="https://static.scarf.sh/a.png?x-pxid=be2d8a11-9712-4c1d-9963-580b2d4fb133" />
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
Hooks for managing form state in React
|
|
6
6
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const start = require("@tanstack/start");
|
|
4
3
|
const utils = require("./utils.cjs");
|
|
5
4
|
const initialFormState = {
|
|
6
5
|
errorMap: {
|
|
@@ -8,7 +7,7 @@ const initialFormState = {
|
|
|
8
7
|
},
|
|
9
8
|
errors: []
|
|
10
9
|
};
|
|
11
|
-
const getFormData =
|
|
10
|
+
const getFormData = async (ctx) => {
|
|
12
11
|
const data = await utils._tanstackInternalsCookie.parse(
|
|
13
12
|
ctx.request.headers.get("Cookie")
|
|
14
13
|
);
|
|
@@ -16,7 +15,7 @@ const getFormData = start.createServerFn("GET", async (_, ctx) => {
|
|
|
16
15
|
if (!data)
|
|
17
16
|
return initialFormState;
|
|
18
17
|
return data;
|
|
19
|
-
}
|
|
18
|
+
};
|
|
20
19
|
exports.getFormData = getFormData;
|
|
21
20
|
exports.initialFormState = initialFormState;
|
|
22
21
|
//# sourceMappingURL=getFormData.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFormData.cjs","sources":["../../../src/start/getFormData.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getFormData.cjs","sources":["../../../src/start/getFormData.tsx"],"sourcesContent":["import { type FetchFn } from '@tanstack/start'\nimport { _tanstackInternalsCookie } from './utils'\nimport type { ServerFormState } from './types'\n\ntype FetchFnCtx = Parameters<FetchFn<never, never>>[1]\n\nexport const initialFormState = {\n errorMap: {\n onServer: undefined,\n },\n errors: [],\n}\n\nexport const getFormData = async (ctx: FetchFnCtx) => {\n const data = (await _tanstackInternalsCookie.parse(\n ctx.request.headers.get('Cookie'),\n )) as undefined | ServerFormState<any>\n // Delete the cookie before it hits the client again¸\n ctx.request.headers.delete('Cookie')\n if (!data) return initialFormState\n return data\n}\n"],"names":["_tanstackInternalsCookie"],"mappings":";;;AAMO,MAAM,mBAAmB;AAAA,EAC9B,UAAU;AAAA,IACR,UAAU;AAAA,EACZ;AAAA,EACA,QAAQ,CAAC;AACX;AAEa,MAAA,cAAc,OAAO,QAAoB;AAC9C,QAAA,OAAQ,MAAMA,MAAAA,yBAAyB;AAAA,IAC3C,IAAI,QAAQ,QAAQ,IAAI,QAAQ;AAAA,EAAA;AAG9B,MAAA,QAAQ,QAAQ,OAAO,QAAQ;AACnC,MAAI,CAAC;AAAa,WAAA;AACX,SAAA;AACT;;;"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { FetchFn } from '@tanstack/start';
|
|
1
2
|
import { ServerFormState } from './types.cjs';
|
|
2
3
|
|
|
4
|
+
type FetchFnCtx = Parameters<FetchFn<never, never>>[1];
|
|
3
5
|
export declare const initialFormState: {
|
|
4
6
|
errorMap: {
|
|
5
7
|
onServer: undefined;
|
|
6
8
|
};
|
|
7
9
|
errors: never[];
|
|
8
10
|
};
|
|
9
|
-
export declare const getFormData:
|
|
11
|
+
export declare const getFormData: (ctx: FetchFnCtx) => Promise<{
|
|
10
12
|
errorMap: {
|
|
11
13
|
onServer: undefined;
|
|
12
14
|
};
|
|
13
15
|
errors: never[];
|
|
14
16
|
} | ServerFormState<any>>;
|
|
17
|
+
export {};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { FetchFn } from '@tanstack/start';
|
|
1
2
|
import { ServerFormState } from './types.js';
|
|
2
3
|
|
|
4
|
+
type FetchFnCtx = Parameters<FetchFn<never, never>>[1];
|
|
3
5
|
export declare const initialFormState: {
|
|
4
6
|
errorMap: {
|
|
5
7
|
onServer: undefined;
|
|
6
8
|
};
|
|
7
9
|
errors: never[];
|
|
8
10
|
};
|
|
9
|
-
export declare const getFormData:
|
|
11
|
+
export declare const getFormData: (ctx: FetchFnCtx) => Promise<{
|
|
10
12
|
errorMap: {
|
|
11
13
|
onServer: undefined;
|
|
12
14
|
};
|
|
13
15
|
errors: never[];
|
|
14
16
|
} | ServerFormState<any>>;
|
|
17
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createServerFn } from "@tanstack/start";
|
|
2
1
|
import { _tanstackInternalsCookie } from "./utils.js";
|
|
3
2
|
const initialFormState = {
|
|
4
3
|
errorMap: {
|
|
@@ -6,7 +5,7 @@ const initialFormState = {
|
|
|
6
5
|
},
|
|
7
6
|
errors: []
|
|
8
7
|
};
|
|
9
|
-
const getFormData =
|
|
8
|
+
const getFormData = async (ctx) => {
|
|
10
9
|
const data = await _tanstackInternalsCookie.parse(
|
|
11
10
|
ctx.request.headers.get("Cookie")
|
|
12
11
|
);
|
|
@@ -14,7 +13,7 @@ const getFormData = createServerFn("GET", async (_, ctx) => {
|
|
|
14
13
|
if (!data)
|
|
15
14
|
return initialFormState;
|
|
16
15
|
return data;
|
|
17
|
-
}
|
|
16
|
+
};
|
|
18
17
|
export {
|
|
19
18
|
getFormData,
|
|
20
19
|
initialFormState
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFormData.js","sources":["../../../src/start/getFormData.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getFormData.js","sources":["../../../src/start/getFormData.tsx"],"sourcesContent":["import { type FetchFn } from '@tanstack/start'\nimport { _tanstackInternalsCookie } from './utils'\nimport type { ServerFormState } from './types'\n\ntype FetchFnCtx = Parameters<FetchFn<never, never>>[1]\n\nexport const initialFormState = {\n errorMap: {\n onServer: undefined,\n },\n errors: [],\n}\n\nexport const getFormData = async (ctx: FetchFnCtx) => {\n const data = (await _tanstackInternalsCookie.parse(\n ctx.request.headers.get('Cookie'),\n )) as undefined | ServerFormState<any>\n // Delete the cookie before it hits the client again¸\n ctx.request.headers.delete('Cookie')\n if (!data) return initialFormState\n return data\n}\n"],"names":[],"mappings":";AAMO,MAAM,mBAAmB;AAAA,EAC9B,UAAU;AAAA,IACR,UAAU;AAAA,EACZ;AAAA,EACA,QAAQ,CAAC;AACX;AAEa,MAAA,cAAc,OAAO,QAAoB;AAC9C,QAAA,OAAQ,MAAM,yBAAyB;AAAA,IAC3C,IAAI,QAAQ,QAAQ,IAAI,QAAQ;AAAA,EAAA;AAG9B,MAAA,QAAQ,QAAQ,OAAO,QAAQ;AACnC,MAAI,CAAC;AAAa,WAAA;AACX,SAAA;AACT;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Powerful, type-safe forms for React.",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,11 +14,6 @@
|
|
|
14
14
|
"type": "github",
|
|
15
15
|
"url": "https://github.com/sponsors/tannerlinsley"
|
|
16
16
|
},
|
|
17
|
-
"sideEffects": false,
|
|
18
|
-
"files": [
|
|
19
|
-
"dist",
|
|
20
|
-
"src"
|
|
21
|
-
],
|
|
22
17
|
"type": "module",
|
|
23
18
|
"types": "dist/esm/index.d.ts",
|
|
24
19
|
"main": "dist/cjs/index.cjs",
|
|
@@ -56,6 +51,17 @@
|
|
|
56
51
|
},
|
|
57
52
|
"./package.json": "./package.json"
|
|
58
53
|
},
|
|
54
|
+
"sideEffects": false,
|
|
55
|
+
"files": [
|
|
56
|
+
"dist",
|
|
57
|
+
"src"
|
|
58
|
+
],
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@remix-run/node": "^2.9.2",
|
|
61
|
+
"@tanstack/react-store": "^0.5.0",
|
|
62
|
+
"decode-formdata": "^0.7.5",
|
|
63
|
+
"@tanstack/form-core": "0.25.3"
|
|
64
|
+
},
|
|
59
65
|
"devDependencies": {
|
|
60
66
|
"@tanstack/start": "^1.42.1",
|
|
61
67
|
"@types/react": "^18.3.3",
|
|
@@ -65,12 +71,6 @@
|
|
|
65
71
|
"react-dom": "^18.3.1",
|
|
66
72
|
"vite": "^5.1.4"
|
|
67
73
|
},
|
|
68
|
-
"dependencies": {
|
|
69
|
-
"@tanstack/react-store": "^0.5.0",
|
|
70
|
-
"decode-formdata": "^0.7.5",
|
|
71
|
-
"@remix-run/node": "^2.9.2",
|
|
72
|
-
"@tanstack/form-core": "0.25.2"
|
|
73
|
-
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@tanstack/start": "^1.40.1",
|
|
76
76
|
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type FetchFn } from '@tanstack/start'
|
|
2
2
|
import { _tanstackInternalsCookie } from './utils'
|
|
3
3
|
import type { ServerFormState } from './types'
|
|
4
4
|
|
|
5
|
+
type FetchFnCtx = Parameters<FetchFn<never, never>>[1]
|
|
6
|
+
|
|
5
7
|
export const initialFormState = {
|
|
6
8
|
errorMap: {
|
|
7
9
|
onServer: undefined,
|
|
@@ -9,7 +11,7 @@ export const initialFormState = {
|
|
|
9
11
|
errors: [],
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
export const getFormData =
|
|
14
|
+
export const getFormData = async (ctx: FetchFnCtx) => {
|
|
13
15
|
const data = (await _tanstackInternalsCookie.parse(
|
|
14
16
|
ctx.request.headers.get('Cookie'),
|
|
15
17
|
)) as undefined | ServerFormState<any>
|
|
@@ -17,4 +19,4 @@ export const getFormData = createServerFn('GET', async (_, ctx) => {
|
|
|
17
19
|
ctx.request.headers.delete('Cookie')
|
|
18
20
|
if (!data) return initialFormState
|
|
19
21
|
return data
|
|
20
|
-
}
|
|
22
|
+
}
|