@tanstack/react-form 0.0.11 → 0.0.13
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/build/lib/_virtual/_rollupPluginBabelHelpers.cjs +19 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.cjs.map +1 -0
- package/build/{cjs → lib}/_virtual/_rollupPluginBabelHelpers.js +1 -17
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.cjs +19 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.cjs.map +1 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.js +17 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.js.map +1 -0
- package/build/lib/createFormFactory.cjs +20 -0
- package/build/lib/createFormFactory.cjs.map +1 -0
- package/build/{types/react-form/src → lib}/createFormFactory.d.ts +1 -0
- package/build/lib/createFormFactory.d.ts.map +1 -0
- package/build/lib/createFormFactory.js +18 -0
- package/build/{cjs → lib}/createFormFactory.js.map +1 -1
- package/build/lib/createFormFactory.legacy.cjs +20 -0
- package/build/lib/createFormFactory.legacy.cjs.map +1 -0
- package/build/lib/createFormFactory.legacy.js +18 -0
- package/build/lib/createFormFactory.legacy.js.map +1 -0
- package/build/{cjs/formContext.js → lib/formContext.cjs} +4 -19
- package/build/lib/formContext.cjs.map +1 -0
- package/build/{types/react-form/src → lib}/formContext.d.ts +1 -0
- package/build/lib/formContext.d.ts.map +1 -0
- package/build/lib/formContext.js +13 -0
- package/build/{cjs → lib}/formContext.js.map +1 -1
- package/build/lib/formContext.legacy.cjs +35 -0
- package/build/lib/formContext.legacy.cjs.map +1 -0
- package/build/lib/formContext.legacy.js +13 -0
- package/build/lib/formContext.legacy.js.map +1 -0
- package/build/{cjs/index.js → lib/index.cjs} +4 -16
- package/build/lib/index.cjs.map +1 -0
- package/build/{types/react-form/src → lib}/index.d.ts +1 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +5 -0
- package/build/{cjs → lib}/index.js.map +1 -1
- package/build/lib/index.legacy.cjs +26 -0
- package/build/lib/index.legacy.cjs.map +1 -0
- package/build/lib/index.legacy.js +5 -0
- package/build/lib/index.legacy.js.map +1 -0
- package/build/lib/tests/createFormFactory.test.d.ts +2 -0
- package/build/lib/tests/createFormFactory.test.d.ts.map +1 -0
- package/build/lib/tests/useForm.test.d.ts +2 -0
- package/build/lib/tests/useForm.test.d.ts.map +1 -0
- package/build/{cjs/useField.js → lib/useField.cjs} +22 -24
- package/build/lib/useField.cjs.map +1 -0
- package/build/{types/react-form/src → lib}/useField.d.ts +1 -1
- package/build/lib/useField.d.ts.map +1 -0
- package/build/lib/useField.js +74 -0
- package/build/lib/useField.js.map +1 -0
- package/build/lib/useField.legacy.cjs +96 -0
- package/build/lib/useField.legacy.cjs.map +1 -0
- package/build/lib/useField.legacy.js +74 -0
- package/build/lib/useField.legacy.js.map +1 -0
- package/build/lib/useForm.cjs +52 -0
- package/build/lib/useForm.cjs.map +1 -0
- package/build/{types/react-form/src → lib}/useForm.d.ts +1 -0
- package/build/lib/useForm.d.ts.map +1 -0
- package/build/lib/useForm.js +50 -0
- package/build/lib/useForm.js.map +1 -0
- package/build/lib/useForm.legacy.cjs +52 -0
- package/build/lib/useForm.legacy.cjs.map +1 -0
- package/build/lib/useForm.legacy.js +50 -0
- package/build/lib/useForm.legacy.js.map +1 -0
- package/package.json +29 -11
- package/src/tests/createFormFactory.test.tsx +39 -0
- package/src/tests/useForm.test.tsx +75 -0
- package/src/useField.tsx +1 -1
- package/src/useForm.tsx +5 -1
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/cjs/createFormFactory.js +0 -31
- package/build/cjs/useField.js.map +0 -1
- package/build/cjs/useForm.js +0 -67
- package/build/cjs/useForm.js.map +0 -1
- package/build/esm/index.js +0 -154
- package/build/esm/index.js.map +0 -1
- package/build/stats-html.html +0 -2689
- package/build/stats-react.json +0 -362
- package/build/types/form-core/src/FieldApi.d.ts +0 -85
- package/build/types/form-core/src/FormApi.d.ts +0 -82
- package/build/types/form-core/src/index.d.ts +0 -3
- package/build/types/form-core/src/utils.d.ts +0 -22
- package/build/types/index.d.ts +0 -74
- package/build/types/react-form/src/tests/test.test.d.ts +0 -0
- package/build/umd/index.development.js +0 -985
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -43
- package/build/umd/index.production.js.map +0 -1
- package/src/tests/test.test.tsx +0 -5
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _extends() {
|
|
4
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
5
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
6
|
+
var source = arguments[i];
|
|
7
|
+
for (var key in source) {
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
9
|
+
target[key] = source[key];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return target;
|
|
14
|
+
};
|
|
15
|
+
return _extends.apply(this, arguments);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.extends = _extends;
|
|
19
|
+
//# sourceMappingURL=_rollupPluginBabelHelpers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_rollupPluginBabelHelpers.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,33 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-form
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
1
|
function _extends() {
|
|
16
2
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
3
|
for (var i = 1; i < arguments.length; i++) {
|
|
18
4
|
var source = arguments[i];
|
|
19
|
-
|
|
20
5
|
for (var key in source) {
|
|
21
6
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
7
|
target[key] = source[key];
|
|
23
8
|
}
|
|
24
9
|
}
|
|
25
10
|
}
|
|
26
|
-
|
|
27
11
|
return target;
|
|
28
12
|
};
|
|
29
13
|
return _extends.apply(this, arguments);
|
|
30
14
|
}
|
|
31
15
|
|
|
32
|
-
|
|
16
|
+
export { _extends as extends };
|
|
33
17
|
//# sourceMappingURL=_rollupPluginBabelHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _extends() {
|
|
4
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
5
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
6
|
+
var source = arguments[i];
|
|
7
|
+
for (var key in source) {
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
9
|
+
target[key] = source[key];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return target;
|
|
14
|
+
};
|
|
15
|
+
return _extends.apply(this, arguments);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.extends = _extends;
|
|
19
|
+
//# sourceMappingURL=_rollupPluginBabelHelpers.legacy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_rollupPluginBabelHelpers.legacy.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
3
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
4
|
+
var source = arguments[i];
|
|
5
|
+
for (var key in source) {
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
+
target[key] = source[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
return _extends.apply(this, arguments);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { _extends as extends };
|
|
17
|
+
//# sourceMappingURL=_rollupPluginBabelHelpers.legacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_rollupPluginBabelHelpers.legacy.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var useField = require('./useField.cjs');
|
|
4
|
+
var useForm = require('./useForm.cjs');
|
|
5
|
+
|
|
6
|
+
function createFormFactory(defaultOpts) {
|
|
7
|
+
return {
|
|
8
|
+
useForm: opts => {
|
|
9
|
+
return useForm.useForm({
|
|
10
|
+
...defaultOpts,
|
|
11
|
+
...opts
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
useField: useField.useField,
|
|
15
|
+
Field: useField.Field
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.createFormFactory = createFormFactory;
|
|
20
|
+
//# sourceMappingURL=createFormFactory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFormFactory.cjs","sources":["../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, FormOptions } from '@tanstack/form-core'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { useForm } from './useForm'\n\nexport type FormFactory<TFormData> = {\n useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>\n useField: UseField<TFormData>\n Field: FieldComponent<TFormData, TFormData>\n}\n\nexport function createFormFactory<TFormData>(\n defaultOpts?: FormOptions<TFormData>,\n): FormFactory<TFormData> {\n return {\n useForm: (opts) => {\n return useForm<TFormData>({ ...defaultOpts, ...opts } as any) as any\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"names":["createFormFactory","defaultOpts","useForm","opts","useField","Field"],"mappings":";;;;;AAUO,SAASA,iBAAiBA,CAC/BC,WAAoC,EACZ;EACxB,OAAO;IACLC,OAAO,EAAGC,IAAI,IAAK;AACjB,MAAA,OAAOD,eAAO,CAAY;AAAE,QAAA,GAAGD,WAAW;QAAE,GAAGE,IAAAA;AAAK,OAAQ,CAAC,CAAA;KAC9D;AACDC,IAAAA,QAAQ,EAAEA,iBAAe;AACzBC,IAAAA,KAAK,EAAEA,cAAAA;GACR,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFormFactory.d.ts","sourceRoot":"","sources":["../../src/createFormFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAmB,MAAM,YAAY,CAAA;AAGhF,MAAM,MAAM,WAAW,CAAC,SAAS,IAAI;IACnC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,KAAK,OAAO,CAAC,SAAS,CAAC,CAAA;IAC9D,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAA;IAC7B,KAAK,EAAE,cAAc,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;CAC5C,CAAA;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EACzC,WAAW,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,GACnC,WAAW,CAAC,SAAS,CAAC,CAQxB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useField, Field } from './useField.js';
|
|
2
|
+
import { useForm } from './useForm.js';
|
|
3
|
+
|
|
4
|
+
function createFormFactory(defaultOpts) {
|
|
5
|
+
return {
|
|
6
|
+
useForm: opts => {
|
|
7
|
+
return useForm({
|
|
8
|
+
...defaultOpts,
|
|
9
|
+
...opts
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
useField: useField,
|
|
13
|
+
Field: Field
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { createFormFactory };
|
|
18
|
+
//# sourceMappingURL=createFormFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFormFactory.js","sources":["../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, FormOptions } from '@tanstack/form-core'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { useForm } from './useForm'\n\nexport type FormFactory<TFormData> = {\n useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>\n useField: UseField<TFormData>\n Field: FieldComponent<TFormData, TFormData>\n}\n\nexport function createFormFactory<TFormData>(\n defaultOpts?: FormOptions<TFormData>,\n): FormFactory<TFormData> {\n return {\n useForm: (opts) => {\n return useForm<TFormData>({ ...defaultOpts, ...opts } as any) as any\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"names":["createFormFactory","defaultOpts","useForm","opts","useField","Field"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createFormFactory.js","sources":["../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, FormOptions } from '@tanstack/form-core'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { useForm } from './useForm'\n\nexport type FormFactory<TFormData> = {\n useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>\n useField: UseField<TFormData>\n Field: FieldComponent<TFormData, TFormData>\n}\n\nexport function createFormFactory<TFormData>(\n defaultOpts?: FormOptions<TFormData>,\n): FormFactory<TFormData> {\n return {\n useForm: (opts) => {\n return useForm<TFormData>({ ...defaultOpts, ...opts } as any) as any\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"names":["createFormFactory","defaultOpts","useForm","opts","useField","Field"],"mappings":";;;AAUO,SAASA,iBAAiBA,CAC/BC,WAAoC,EACZ;EACxB,OAAO;IACLC,OAAO,EAAGC,IAAI,IAAK;AACjB,MAAA,OAAOD,OAAO,CAAY;AAAE,QAAA,GAAGD,WAAW;QAAE,GAAGE,IAAAA;AAAK,OAAQ,CAAC,CAAA;KAC9D;AACDC,IAAAA,QAAQ,EAAEA,QAAe;AACzBC,IAAAA,KAAK,EAAEA,KAAAA;GACR,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var useField = require('./useField.legacy.cjs');
|
|
4
|
+
var useForm = require('./useForm.legacy.cjs');
|
|
5
|
+
|
|
6
|
+
function createFormFactory(defaultOpts) {
|
|
7
|
+
return {
|
|
8
|
+
useForm: opts => {
|
|
9
|
+
return useForm.useForm({
|
|
10
|
+
...defaultOpts,
|
|
11
|
+
...opts
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
useField: useField.useField,
|
|
15
|
+
Field: useField.Field
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.createFormFactory = createFormFactory;
|
|
20
|
+
//# sourceMappingURL=createFormFactory.legacy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFormFactory.legacy.cjs","sources":["../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, FormOptions } from '@tanstack/form-core'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { useForm } from './useForm'\n\nexport type FormFactory<TFormData> = {\n useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>\n useField: UseField<TFormData>\n Field: FieldComponent<TFormData, TFormData>\n}\n\nexport function createFormFactory<TFormData>(\n defaultOpts?: FormOptions<TFormData>,\n): FormFactory<TFormData> {\n return {\n useForm: (opts) => {\n return useForm<TFormData>({ ...defaultOpts, ...opts } as any) as any\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"names":["createFormFactory","defaultOpts","useForm","opts","useField","Field"],"mappings":";;;;;AAUO,SAASA,iBAAiBA,CAC/BC,WAAoC,EACZ;EACxB,OAAO;IACLC,OAAO,EAAGC,IAAI,IAAK;AACjB,MAAA,OAAOD,eAAO,CAAY;AAAE,QAAA,GAAGD,WAAW;QAAE,GAAGE,IAAAA;AAAK,OAAQ,CAAC,CAAA;KAC9D;AACDC,IAAAA,QAAQ,EAAEA,iBAAe;AACzBC,IAAAA,KAAK,EAAEA,cAAAA;GACR,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useField, Field } from './useField.legacy.js';
|
|
2
|
+
import { useForm } from './useForm.legacy.js';
|
|
3
|
+
|
|
4
|
+
function createFormFactory(defaultOpts) {
|
|
5
|
+
return {
|
|
6
|
+
useForm: opts => {
|
|
7
|
+
return useForm({
|
|
8
|
+
...defaultOpts,
|
|
9
|
+
...opts
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
useField: useField,
|
|
13
|
+
Field: Field
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { createFormFactory };
|
|
18
|
+
//# sourceMappingURL=createFormFactory.legacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFormFactory.legacy.js","sources":["../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, FormOptions } from '@tanstack/form-core'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { useForm } from './useForm'\n\nexport type FormFactory<TFormData> = {\n useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>\n useField: UseField<TFormData>\n Field: FieldComponent<TFormData, TFormData>\n}\n\nexport function createFormFactory<TFormData>(\n defaultOpts?: FormOptions<TFormData>,\n): FormFactory<TFormData> {\n return {\n useForm: (opts) => {\n return useForm<TFormData>({ ...defaultOpts, ...opts } as any) as any\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"names":["createFormFactory","defaultOpts","useForm","opts","useField","Field"],"mappings":";;;AAUO,SAASA,iBAAiBA,CAC/BC,WAAoC,EACZ;EACxB,OAAO;IACLC,OAAO,EAAGC,IAAI,IAAK;AACjB,MAAA,OAAOD,OAAO,CAAY;AAAE,QAAA,GAAGD,WAAW;QAAE,GAAGE,IAAAA;AAAK,OAAQ,CAAC,CAAA;KAC9D;AACDC,IAAAA,QAAQ,EAAEA,QAAe;AACzBC,IAAAA,KAAK,EAAEA,KAAAA;GACR,CAAA;AACH;;;;"}
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-form
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
1
|
'use strict';
|
|
12
2
|
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
3
|
var React = require('react');
|
|
16
4
|
|
|
17
|
-
function
|
|
18
|
-
if (e && e.__esModule) return e;
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
19
6
|
var n = Object.create(null);
|
|
20
7
|
if (e) {
|
|
21
8
|
Object.keys(e).forEach(function (k) {
|
|
@@ -28,23 +15,21 @@ function _interopNamespace(e) {
|
|
|
28
15
|
}
|
|
29
16
|
});
|
|
30
17
|
}
|
|
31
|
-
n
|
|
18
|
+
n.default = e;
|
|
32
19
|
return Object.freeze(n);
|
|
33
20
|
}
|
|
34
21
|
|
|
35
|
-
var React__namespace = /*#__PURE__*/
|
|
22
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
36
23
|
|
|
37
24
|
const formContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
38
25
|
function useFormContext() {
|
|
39
26
|
const formApi = React__namespace.useContext(formContext);
|
|
40
|
-
|
|
41
27
|
if (!formApi) {
|
|
42
28
|
throw new Error("You are trying to use the form API outside of a form!");
|
|
43
29
|
}
|
|
44
|
-
|
|
45
30
|
return formApi;
|
|
46
31
|
}
|
|
47
32
|
|
|
48
33
|
exports.formContext = formContext;
|
|
49
34
|
exports.useFormContext = useFormContext;
|
|
50
|
-
//# sourceMappingURL=formContext.
|
|
35
|
+
//# sourceMappingURL=formContext.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formContext.cjs","sources":["../../src/formContext.ts"],"sourcesContent":["import type { FormApi } from '@tanstack/form-core'\nimport * as React from 'react'\n\nexport const formContext = React.createContext<{\n formApi: FormApi<any>\n parentFieldName?: string\n} | null>(null!)\n\nexport function useFormContext() {\n const formApi = React.useContext(formContext)\n\n if (!formApi) {\n throw new Error(`You are trying to use the form API outside of a form!`)\n }\n\n return formApi\n}\n"],"names":["formContext","React","createContext","useFormContext","formApi","useContext","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,WAAW,gBAAGC,gBAAK,CAACC,aAAa,CAGpC,IAAK,EAAC;AAET,SAASC,cAAcA,GAAG;AAC/B,EAAA,MAAMC,OAAO,GAAGH,gBAAK,CAACI,UAAU,CAACL,WAAW,CAAC,CAAA;EAE7C,IAAI,CAACI,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAA,uDAAwD,CAAC,CAAA;AAC1E,GAAA;AAEA,EAAA,OAAOF,OAAO,CAAA;AAChB;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formContext.d.ts","sourceRoot":"","sources":["../../src/formContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,eAAO,MAAM,WAAW;aACb,QAAQ,GAAG,CAAC;;SAEP,CAAA;AAEhB,wBAAgB,cAAc;;;EAQ7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
const formContext = /*#__PURE__*/React.createContext(null);
|
|
4
|
+
function useFormContext() {
|
|
5
|
+
const formApi = React.useContext(formContext);
|
|
6
|
+
if (!formApi) {
|
|
7
|
+
throw new Error("You are trying to use the form API outside of a form!");
|
|
8
|
+
}
|
|
9
|
+
return formApi;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { formContext, useFormContext };
|
|
13
|
+
//# sourceMappingURL=formContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formContext.js","sources":["../../src/formContext.ts"],"sourcesContent":["import type { FormApi } from '@tanstack/form-core'\nimport * as React from 'react'\n\nexport const formContext = React.createContext<{\n formApi: FormApi<any>\n parentFieldName?: string\n} | null>(null!)\n\nexport function useFormContext() {\n const formApi = React.useContext(formContext)\n\n if (!formApi) {\n throw new Error(`You are trying to use the form API outside of a form!`)\n }\n\n return formApi\n}\n"],"names":["formContext","React","createContext","useFormContext","formApi","useContext","Error"],"mappings":"
|
|
1
|
+
{"version":3,"file":"formContext.js","sources":["../../src/formContext.ts"],"sourcesContent":["import type { FormApi } from '@tanstack/form-core'\nimport * as React from 'react'\n\nexport const formContext = React.createContext<{\n formApi: FormApi<any>\n parentFieldName?: string\n} | null>(null!)\n\nexport function useFormContext() {\n const formApi = React.useContext(formContext)\n\n if (!formApi) {\n throw new Error(`You are trying to use the form API outside of a form!`)\n }\n\n return formApi\n}\n"],"names":["formContext","React","createContext","useFormContext","formApi","useContext","Error"],"mappings":";;AAGO,MAAMA,WAAW,gBAAGC,KAAK,CAACC,aAAa,CAGpC,IAAK,EAAC;AAET,SAASC,cAAcA,GAAG;AAC/B,EAAA,MAAMC,OAAO,GAAGH,KAAK,CAACI,UAAU,CAACL,WAAW,CAAC,CAAA;EAE7C,IAAI,CAACI,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAA,uDAAwD,CAAC,CAAA;AAC1E,GAAA;AAEA,EAAA,OAAOF,OAAO,CAAA;AAChB;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
var n = Object.create(null);
|
|
7
|
+
if (e) {
|
|
8
|
+
Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default') {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
23
|
+
|
|
24
|
+
const formContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
25
|
+
function useFormContext() {
|
|
26
|
+
const formApi = React__namespace.useContext(formContext);
|
|
27
|
+
if (!formApi) {
|
|
28
|
+
throw new Error("You are trying to use the form API outside of a form!");
|
|
29
|
+
}
|
|
30
|
+
return formApi;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.formContext = formContext;
|
|
34
|
+
exports.useFormContext = useFormContext;
|
|
35
|
+
//# sourceMappingURL=formContext.legacy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formContext.legacy.cjs","sources":["../../src/formContext.ts"],"sourcesContent":["import type { FormApi } from '@tanstack/form-core'\nimport * as React from 'react'\n\nexport const formContext = React.createContext<{\n formApi: FormApi<any>\n parentFieldName?: string\n} | null>(null!)\n\nexport function useFormContext() {\n const formApi = React.useContext(formContext)\n\n if (!formApi) {\n throw new Error(`You are trying to use the form API outside of a form!`)\n }\n\n return formApi\n}\n"],"names":["formContext","React","createContext","useFormContext","formApi","useContext","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,WAAW,gBAAGC,gBAAK,CAACC,aAAa,CAGpC,IAAK,EAAC;AAET,SAASC,cAAcA,GAAG;AAC/B,EAAA,MAAMC,OAAO,GAAGH,gBAAK,CAACI,UAAU,CAACL,WAAW,CAAC,CAAA;EAE7C,IAAI,CAACI,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAA,uDAAwD,CAAC,CAAA;AAC1E,GAAA;AAEA,EAAA,OAAOF,OAAO,CAAA;AAChB;;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
const formContext = /*#__PURE__*/React.createContext(null);
|
|
4
|
+
function useFormContext() {
|
|
5
|
+
const formApi = React.useContext(formContext);
|
|
6
|
+
if (!formApi) {
|
|
7
|
+
throw new Error("You are trying to use the form API outside of a form!");
|
|
8
|
+
}
|
|
9
|
+
return formApi;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { formContext, useFormContext };
|
|
13
|
+
//# sourceMappingURL=formContext.legacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formContext.legacy.js","sources":["../../src/formContext.ts"],"sourcesContent":["import type { FormApi } from '@tanstack/form-core'\nimport * as React from 'react'\n\nexport const formContext = React.createContext<{\n formApi: FormApi<any>\n parentFieldName?: string\n} | null>(null!)\n\nexport function useFormContext() {\n const formApi = React.useContext(formContext)\n\n if (!formApi) {\n throw new Error(`You are trying to use the form API outside of a form!`)\n }\n\n return formApi\n}\n"],"names":["formContext","React","createContext","useFormContext","formApi","useContext","Error"],"mappings":";;AAGO,MAAMA,WAAW,gBAAGC,KAAK,CAACC,aAAa,CAGpC,IAAK,EAAC;AAET,SAASC,cAAcA,GAAG;AAC/B,EAAA,MAAMC,OAAO,GAAGH,KAAK,CAACI,UAAU,CAACL,WAAW,CAAC,CAAA;EAE7C,IAAI,CAACI,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAA,uDAAwD,CAAC,CAAA;AAC1E,GAAA;AAEA,EAAA,OAAOF,OAAO,CAAA;AAChB;;;;"}
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-form
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
1
|
'use strict';
|
|
12
2
|
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
3
|
var formCore = require('@tanstack/form-core');
|
|
16
|
-
var useForm = require('./useForm.
|
|
17
|
-
var useField = require('./useField.
|
|
18
|
-
var createFormFactory = require('./createFormFactory.
|
|
4
|
+
var useForm = require('./useForm.cjs');
|
|
5
|
+
var useField = require('./useField.cjs');
|
|
6
|
+
var createFormFactory = require('./createFormFactory.cjs');
|
|
19
7
|
|
|
20
8
|
|
|
21
9
|
|
|
@@ -35,4 +23,4 @@ exports.useForm = useForm.useForm;
|
|
|
35
23
|
exports.Field = useField.Field;
|
|
36
24
|
exports.useField = useField.useField;
|
|
37
25
|
exports.createFormFactory = createFormFactory.createFormFactory;
|
|
38
|
-
//# sourceMappingURL=index.
|
|
26
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,QAAQ,EACR,SAAS,EACT,eAAe,EACf,SAAS,EACT,SAAS,EACT,YAAY,EACZ,UAAU,EACV,WAAW,EACX,SAAS,EACT,UAAU,EACV,aAAa,EACb,OAAO,EACP,SAAS,EACT,eAAe,EACf,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,GACf,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEzE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE5C,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var formCore = require('@tanstack/form-core');
|
|
4
|
+
var useForm = require('./useForm.legacy.cjs');
|
|
5
|
+
var useField = require('./useField.legacy.cjs');
|
|
6
|
+
var createFormFactory = require('./createFormFactory.legacy.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, 'FieldApi', {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return formCore.FieldApi; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, 'FormApi', {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return formCore.FormApi; }
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, 'functionalUpdate', {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return formCore.functionalUpdate; }
|
|
21
|
+
});
|
|
22
|
+
exports.useForm = useForm.useForm;
|
|
23
|
+
exports.Field = useField.Field;
|
|
24
|
+
exports.useField = useField.useField;
|
|
25
|
+
exports.createFormFactory = createFormFactory.createFormFactory;
|
|
26
|
+
//# sourceMappingURL=index.legacy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.legacy.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FieldApi, FormApi, functionalUpdate } from '@tanstack/form-core';
|
|
2
|
+
export { useForm } from './useForm.legacy.js';
|
|
3
|
+
export { Field, useField } from './useField.legacy.js';
|
|
4
|
+
export { createFormFactory } from './createFormFactory.legacy.js';
|
|
5
|
+
//# sourceMappingURL=index.legacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.legacy.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFormFactory.test.d.ts","sourceRoot":"","sources":["../../../src/tests/createFormFactory.test.tsx"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForm.test.d.ts","sourceRoot":"","sources":["../../../src/tests/useForm.test.tsx"],"names":[],"mappings":"AAEA,OAAO,2BAA2B,CAAA"}
|
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-form
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
1
|
'use strict';
|
|
12
2
|
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
3
|
var React = require('react');
|
|
16
4
|
var reactStore = require('@tanstack/react-store');
|
|
17
5
|
var formCore = require('@tanstack/form-core');
|
|
18
|
-
var formContext = require('./formContext.
|
|
6
|
+
var formContext = require('./formContext.cjs');
|
|
19
7
|
|
|
20
|
-
function
|
|
21
|
-
if (e && e.__esModule) return e;
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
22
9
|
var n = Object.create(null);
|
|
23
10
|
if (e) {
|
|
24
11
|
Object.keys(e).forEach(function (k) {
|
|
@@ -31,11 +18,11 @@ function _interopNamespace(e) {
|
|
|
31
18
|
}
|
|
32
19
|
});
|
|
33
20
|
}
|
|
34
|
-
n
|
|
21
|
+
n.default = e;
|
|
35
22
|
return Object.freeze(n);
|
|
36
23
|
}
|
|
37
24
|
|
|
38
|
-
var React__namespace = /*#__PURE__*/
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
39
26
|
|
|
40
27
|
function useField(opts) {
|
|
41
28
|
// Get the form API either manually or from context
|
|
@@ -45,24 +32,30 @@ function useField(opts) {
|
|
|
45
32
|
} = formContext.useFormContext();
|
|
46
33
|
const [fieldApi] = React__namespace.useState(() => {
|
|
47
34
|
const name = (typeof opts.index === 'number' ? [parentFieldName, opts.index, opts.name] : [parentFieldName, opts.name]).filter(d => d !== undefined).join('.');
|
|
48
|
-
const api = new formCore.FieldApi({
|
|
35
|
+
const api = new formCore.FieldApi({
|
|
36
|
+
...opts,
|
|
49
37
|
form: formApi,
|
|
50
38
|
name: name
|
|
51
39
|
});
|
|
52
40
|
api.Field = Field;
|
|
53
41
|
return api;
|
|
54
|
-
});
|
|
42
|
+
});
|
|
55
43
|
|
|
56
|
-
|
|
44
|
+
// Keep options up to date as they are rendered
|
|
45
|
+
fieldApi.update({
|
|
46
|
+
...opts,
|
|
57
47
|
form: formApi
|
|
58
48
|
});
|
|
59
49
|
reactStore.useStore(fieldApi.store, opts.mode === 'array' ? state => {
|
|
60
50
|
return [state.meta, Object.keys(state.value || []).length];
|
|
61
|
-
} : undefined);
|
|
51
|
+
} : undefined);
|
|
62
52
|
|
|
53
|
+
// Instantiates field meta and removes it when unrendered
|
|
63
54
|
React__namespace.useEffect(() => fieldApi.mount(), [fieldApi]);
|
|
64
55
|
return fieldApi;
|
|
65
|
-
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// export type FieldValue<TFormData, TField> = TFormData extends any[]
|
|
66
59
|
// ? TField extends `[${infer TIndex extends number | 'i'}].${infer TRest}`
|
|
67
60
|
// ? DeepValue<TFormData[TIndex extends 'i' ? number : TIndex], TRest>
|
|
68
61
|
// : TField extends `[${infer TIndex extends number | 'i'}]`
|
|
@@ -78,7 +71,12 @@ function useField(opts) {
|
|
|
78
71
|
// : TField extends `${infer TPrefix}[${infer TIndex extends number | 'i'}]`
|
|
79
72
|
// ? DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex]
|
|
80
73
|
// : DeepValue<TFormData, TField>
|
|
81
|
-
|
|
74
|
+
// type Test1 = FieldValue<{ foo: { bar: string }[] }, 'foo'>
|
|
75
|
+
// // ^?
|
|
76
|
+
// type Test2 = FieldValue<{ foo: { bar: string }[] }, 'foo[i]'>
|
|
77
|
+
// // ^?
|
|
78
|
+
// type Test3 = FieldValue<{ foo: { bar: string }[] }, 'foo[2].bar'>
|
|
79
|
+
// // ^?
|
|
82
80
|
function Field({
|
|
83
81
|
children,
|
|
84
82
|
...fieldOptions
|
|
@@ -95,4 +93,4 @@ function Field({
|
|
|
95
93
|
|
|
96
94
|
exports.Field = Field;
|
|
97
95
|
exports.useField = useField;
|
|
98
|
-
//# sourceMappingURL=useField.
|
|
96
|
+
//# sourceMappingURL=useField.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useField.cjs","sources":["../../src/useField.tsx"],"sourcesContent":["import * as React from 'react'\n//\nimport { useStore } from '@tanstack/react-store'\nimport type {\n DeepKeys,\n DeepValue,\n FieldOptions,\n Narrow,\n} from '@tanstack/form-core'\nimport { FieldApi, functionalUpdate } from '@tanstack/form-core'\nimport { useFormContext, formContext } from './formContext'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<TData, TFormData> {\n Field: FieldComponent<TData, TFormData>\n }\n}\n\nexport type UseFieldOptions<TData, TFormData> = FieldOptions<\n TData,\n TFormData\n> & {\n mode?: 'value' | 'array'\n}\n\nexport type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(\n opts?: { name: Narrow<TField> } & UseFieldOptions<\n DeepValue<TFormData, TField>,\n TFormData\n >,\n) => FieldApi<DeepValue<TFormData, TField>, TFormData>\n\nexport function useField<TData, TFormData>(\n opts: UseFieldOptions<TData, TFormData>,\n): FieldApi<TData, TFormData> {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const [fieldApi] = React.useState<FieldApi<TData, TFormData>>(() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({ ...opts, form: formApi, name: name as any })\n\n api.Field = Field as any\n\n return api\n })\n\n // Keep options up to date as they are rendered\n fieldApi.update({ ...opts, form: formApi } as never)\n\n useStore(\n fieldApi.store as any,\n opts.mode === 'array'\n ? (state: any) => {\n return [state.meta, Object.keys(state.value || []).length]\n }\n : undefined,\n )\n\n // Instantiates field meta and removes it when unrendered\n React.useEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi\n}\n\n// export type FieldValue<TFormData, TField> = TFormData extends any[]\n// ? TField extends `[${infer TIndex extends number | 'i'}].${infer TRest}`\n// ? DeepValue<TFormData[TIndex extends 'i' ? number : TIndex], TRest>\n// : TField extends `[${infer TIndex extends number | 'i'}]`\n// ? TFormData[TIndex extends 'i' ? number : TIndex]\n// : never\n// : TField extends `${infer TPrefix}[${infer TIndex extends\n// | number\n// | 'i'}].${infer TRest}`\n// ? DeepValue<\n// DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex],\n// TRest\n// >\n// : TField extends `${infer TPrefix}[${infer TIndex extends number | 'i'}]`\n// ? DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex]\n// : DeepValue<TFormData, TField>\n\nexport type FieldValue<TFormData, TField> = TFormData extends any[]\n ? unknown extends TField\n ? TFormData[number]\n : DeepValue<TFormData[number], TField>\n : DeepValue<TFormData, TField>\n\n// type Test1 = FieldValue<{ foo: { bar: string }[] }, 'foo'>\n// // ^?\n// type Test2 = FieldValue<{ foo: { bar: string }[] }, 'foo[i]'>\n// // ^?\n// type Test3 = FieldValue<{ foo: { bar: string }[] }, 'foo[2].bar'>\n// // ^?\n\nexport type FieldComponent<TParentData, TFormData> = <TField>({\n children,\n ...fieldOptions\n}: {\n children: (\n fieldApi: FieldApi<FieldValue<TParentData, TField>, TFormData>,\n ) => any\n} & Omit<\n UseFieldOptions<FieldValue<TParentData, TField>, TFormData>,\n 'name' | 'index'\n> &\n (TParentData extends any[]\n ? {\n name?: TField extends undefined ? TField : DeepKeys<TParentData>\n index: number\n }\n : {\n name: TField extends undefined ? TField : DeepKeys<TParentData>\n index?: never\n })) => any\n\nexport function Field<TData, TFormData>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TData, TFormData>) => any\n} & UseFieldOptions<TData, TFormData>) {\n const fieldApi = useField(fieldOptions as any)\n\n return (\n <formContext.Provider\n value={{ formApi: fieldApi.form, parentFieldName: fieldApi.name }}\n children={functionalUpdate(children, fieldApi as any)}\n />\n )\n}\n"],"names":["useField","opts","formApi","parentFieldName","useFormContext","fieldApi","React","useState","name","index","filter","d","undefined","join","api","FieldApi","form","Field","update","useStore","store","mode","state","meta","Object","keys","value","length","useEffect","mount","children","fieldOptions","createElement","formContext","Provider","functionalUpdate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiCO,SAASA,QAAQA,CACtBC,IAAuC,EACX;AAC5B;EACA,MAAM;IAAEC,OAAO;AAAEC,IAAAA,eAAAA;GAAiB,GAAGC,0BAAc,EAAE,CAAA;EAErD,MAAM,CAACC,QAAQ,CAAC,GAAGC,gBAAK,CAACC,QAAQ,CAA6B,MAAM;AAClE,IAAA,MAAMC,IAAI,GAAG,CACX,OAAOP,IAAI,CAACQ,KAAK,KAAK,QAAQ,GAC1B,CAACN,eAAe,EAAEF,IAAI,CAACQ,KAAK,EAAER,IAAI,CAACO,IAAI,CAAC,GACxC,CAACL,eAAe,EAAEF,IAAI,CAACO,IAAI,CAAC,EAE/BE,MAAM,CAAEC,CAAC,IAAKA,CAAC,KAAKC,SAAS,CAAC,CAC9BC,IAAI,CAAC,GAAG,CAAC,CAAA;AAEZ,IAAA,MAAMC,GAAG,GAAG,IAAIC,iBAAQ,CAAC;AAAE,MAAA,GAAGd,IAAI;AAAEe,MAAAA,IAAI,EAAEd,OAAO;AAAEM,MAAAA,IAAI,EAAEA,IAAAA;AAAY,KAAC,CAAC,CAAA;IAEvEM,GAAG,CAACG,KAAK,GAAGA,KAAY,CAAA;AAExB,IAAA,OAAOH,GAAG,CAAA;AACZ,GAAC,CAAC,CAAA;;AAEF;EACAT,QAAQ,CAACa,MAAM,CAAC;AAAE,IAAA,GAAGjB,IAAI;AAAEe,IAAAA,IAAI,EAAEd,OAAAA;AAAQ,GAAU,CAAC,CAAA;AAEpDiB,EAAAA,mBAAQ,CACNd,QAAQ,CAACe,KAAK,EACdnB,IAAI,CAACoB,IAAI,KAAK,OAAO,GAChBC,KAAU,IAAK;AACd,IAAA,OAAO,CAACA,KAAK,CAACC,IAAI,EAAEC,MAAM,CAACC,IAAI,CAACH,KAAK,CAACI,KAAK,IAAI,EAAE,CAAC,CAACC,MAAM,CAAC,CAAA;GAC3D,GACDf,SACN,CAAC,CAAA;;AAED;AACAN,EAAAA,gBAAK,CAACsB,SAAS,CAAC,MAAMvB,QAAQ,CAACwB,KAAK,EAAE,EAAE,CAACxB,QAAQ,CAAC,CAAC,CAAA;AAEnD,EAAA,OAAOA,QAAQ,CAAA;AACjB,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAuBO,SAASY,KAAKA,CAAmB;EACtCa,QAAQ;EACR,GAAGC,YAAAA;AAG+B,CAAC,EAAE;AACrC,EAAA,MAAM1B,QAAQ,GAAGL,QAAQ,CAAC+B,YAAmB,CAAC,CAAA;AAE9C,EAAA,oBACEzB,gBAAA,CAAA0B,aAAA,CAACC,uBAAW,CAACC,QAAQ,EAAA;AACnBR,IAAAA,KAAK,EAAE;MAAExB,OAAO,EAAEG,QAAQ,CAACW,IAAI;MAAEb,eAAe,EAAEE,QAAQ,CAACG,IAAAA;KAAO;AAClEsB,IAAAA,QAAQ,EAAEK,yBAAgB,CAACL,QAAQ,EAAEzB,QAAe,CAAA;AAAE,GACvD,CAAC,CAAA;AAEN;;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { DeepKeys, DeepValue, FieldOptions, Narrow } from '@tanstack/form-core';
|
|
3
2
|
import { FieldApi } from '@tanstack/form-core';
|
|
4
3
|
declare module '@tanstack/form-core' {
|
|
@@ -26,3 +25,4 @@ export type FieldComponent<TParentData, TFormData> = <TField>({ children, ...fie
|
|
|
26
25
|
export declare function Field<TData, TFormData>({ children, ...fieldOptions }: {
|
|
27
26
|
children: (fieldApi: FieldApi<TData, TFormData>) => any;
|
|
28
27
|
} & UseFieldOptions<TData, TFormData>): JSX.Element;
|
|
28
|
+
//# sourceMappingURL=useField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useField.d.ts","sourceRoot":"","sources":["../../src/useField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,MAAM,EACP,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,QAAQ,EAAoB,MAAM,qBAAqB,CAAA;AAGhE,OAAO,QAAQ,qBAAqB,CAAC;IAEnC,UAAU,QAAQ,CAAC,KAAK,EAAE,SAAS;QACjC,KAAK,EAAE,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;KACxC;CACF;AAED,MAAM,MAAM,eAAe,CAAC,KAAK,EAAE,SAAS,IAAI,YAAY,CAC1D,KAAK,EACL,SAAS,CACV,GAAG;IACF,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,QAAQ,CAAC,SAAS,IAAI,CAAC,MAAM,SAAS,QAAQ,CAAC,SAAS,CAAC,EACnE,IAAI,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;CAAE,GAAG,eAAe,CAC/C,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,EAC5B,SAAS,CACV,KACE,QAAQ,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAA;AAEtD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,EACvC,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,GACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAoC5B;AAmBD,MAAM,MAAM,UAAU,CAAC,SAAS,EAAE,MAAM,IAAI,SAAS,SAAS,GAAG,EAAE,GAC/D,OAAO,SAAS,MAAM,GACpB,SAAS,CAAC,MAAM,CAAC,GACjB,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GACtC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAShC,MAAM,MAAM,cAAc,CAAC,WAAW,EAAE,SAAS,IAAI,CAAC,MAAM,EAAE,EAC5D,QAAQ,EACR,GAAG,YAAY,EAChB,EAAE;IACD,QAAQ,EAAE,CACR,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,KAC3D,GAAG,CAAA;CACT,GAAG,IAAI,CACN,eAAe,CAAC,UAAU,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,EAC3D,MAAM,GAAG,OAAO,CACjB,GACC,CAAC,WAAW,SAAS,GAAG,EAAE,GACtB;IACE,IAAI,CAAC,EAAE,MAAM,SAAS,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAA;IAChE,KAAK,EAAE,MAAM,CAAA;CACd,GACD;IACE,IAAI,EAAE,MAAM,SAAS,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAA;IAC/D,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAC,KAAK,GAAG,CAAA;AAEhB,wBAAgB,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,EACtC,QAAQ,EACR,GAAG,YAAY,EAChB,EAAE;IACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,GAAG,CAAA;CACxD,GAAG,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,eASpC"}
|