@tanstack/vue-form 0.2.0 → 0.3.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.
Files changed (83) hide show
  1. package/package.json +2 -2
  2. package/src/tests/useField.test.tsx +9 -9
  3. package/src/tests/useForm.test.tsx +9 -3
  4. package/src/types.ts +2 -0
  5. package/src/useField.tsx +24 -21
  6. package/src/useForm.tsx +15 -4
  7. package/build/legacy/createFormFactory-161e85f9.d.ts +0 -42
  8. package/build/legacy/createFormFactory.cjs +0 -42
  9. package/build/legacy/createFormFactory.cjs.map +0 -1
  10. package/build/legacy/createFormFactory.d.cts +0 -3
  11. package/build/legacy/createFormFactory.d.ts +0 -3
  12. package/build/legacy/createFormFactory.js +0 -17
  13. package/build/legacy/createFormFactory.js.map +0 -1
  14. package/build/legacy/formContext.cjs +0 -46
  15. package/build/legacy/formContext.cjs.map +0 -1
  16. package/build/legacy/formContext.d.cts +0 -14
  17. package/build/legacy/formContext.d.ts +0 -14
  18. package/build/legacy/formContext.js +0 -19
  19. package/build/legacy/formContext.js.map +0 -1
  20. package/build/legacy/index.cjs +0 -33
  21. package/build/legacy/index.cjs.map +0 -1
  22. package/build/legacy/index.d.cts +0 -23
  23. package/build/legacy/index.d.ts +0 -23
  24. package/build/legacy/index.js +0 -7
  25. package/build/legacy/index.js.map +0 -1
  26. package/build/legacy/types.cjs +0 -19
  27. package/build/legacy/types.cjs.map +0 -1
  28. package/build/legacy/types.d.cts +0 -3
  29. package/build/legacy/types.d.ts +0 -3
  30. package/build/legacy/types.js +0 -1
  31. package/build/legacy/types.js.map +0 -1
  32. package/build/lib/createFormFactory.d.ts +0 -9
  33. package/build/lib/createFormFactory.d.ts.map +0 -1
  34. package/build/lib/createFormFactory.js +0 -12
  35. package/build/lib/formContext.d.ts +0 -12
  36. package/build/lib/formContext.d.ts.map +0 -1
  37. package/build/lib/formContext.js +0 -12
  38. package/build/lib/index.d.ts +0 -6
  39. package/build/lib/index.d.ts.map +0 -1
  40. package/build/lib/index.js +0 -5
  41. package/build/lib/tests/useField.test.d.ts +0 -3
  42. package/build/lib/tests/useField.test.d.ts.map +0 -1
  43. package/build/lib/tests/useField.test.jsx +0 -109
  44. package/build/lib/tests/useForm.test.d.ts +0 -3
  45. package/build/lib/tests/useForm.test.d.ts.map +0 -1
  46. package/build/lib/tests/useForm.test.jsx +0 -71
  47. package/build/lib/tests/utils.d.ts +0 -2
  48. package/build/lib/tests/utils.d.ts.map +0 -1
  49. package/build/lib/tests/utils.js +0 -5
  50. package/build/lib/types.d.ts +0 -2
  51. package/build/lib/types.d.ts.map +0 -1
  52. package/build/lib/types.js +0 -1
  53. package/build/lib/useField.d.ts +0 -33
  54. package/build/lib/useField.d.ts.map +0 -1
  55. package/build/lib/useField.jsx +0 -39
  56. package/build/lib/useForm.d.ts +0 -17
  57. package/build/lib/useForm.d.ts.map +0 -1
  58. package/build/lib/useForm.jsx +0 -35
  59. package/build/modern/createFormFactory-161e85f9.d.ts +0 -42
  60. package/build/modern/createFormFactory.cjs +0 -42
  61. package/build/modern/createFormFactory.cjs.map +0 -1
  62. package/build/modern/createFormFactory.d.cts +0 -3
  63. package/build/modern/createFormFactory.d.ts +0 -3
  64. package/build/modern/createFormFactory.js +0 -17
  65. package/build/modern/createFormFactory.js.map +0 -1
  66. package/build/modern/formContext.cjs +0 -46
  67. package/build/modern/formContext.cjs.map +0 -1
  68. package/build/modern/formContext.d.cts +0 -14
  69. package/build/modern/formContext.d.ts +0 -14
  70. package/build/modern/formContext.js +0 -19
  71. package/build/modern/formContext.js.map +0 -1
  72. package/build/modern/index.cjs +0 -33
  73. package/build/modern/index.cjs.map +0 -1
  74. package/build/modern/index.d.cts +0 -23
  75. package/build/modern/index.d.ts +0 -23
  76. package/build/modern/index.js +0 -7
  77. package/build/modern/index.js.map +0 -1
  78. package/build/modern/types.cjs +0 -19
  79. package/build/modern/types.cjs.map +0 -1
  80. package/build/modern/types.d.cts +0 -3
  81. package/build/modern/types.d.ts +0 -3
  82. package/build/modern/types.js +0 -1
  83. package/build/modern/types.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/vue-form",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Powerful, type-safe forms for Vue.",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -45,7 +45,7 @@
45
45
  "@tanstack/store": "0.1.3",
46
46
  "@tanstack/vue-store": "0.1.3",
47
47
  "vue-demi": "^0.14.6",
48
- "@tanstack/form-core": "0.2.0"
48
+ "@tanstack/form-core": "0.3.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@vue/composition-api": "1.7.2",
@@ -30,7 +30,7 @@ describe('useField', () => {
30
30
 
31
31
  return () => (
32
32
  <form.Field name="firstName" defaultValue="FirstName">
33
- {(field: FieldApi<string, Person>) => (
33
+ {({ field }: { field: FieldApi<string, Person> }) => (
34
34
  <input
35
35
  data-testid={'fieldinput'}
36
36
  value={field.state.value}
@@ -68,7 +68,7 @@ describe('useField', () => {
68
68
  name="firstName"
69
69
  onChange={(value) => (value === 'other' ? error : undefined)}
70
70
  >
71
- {(field: FieldApi<string, Person>) => (
71
+ {({ field }: { field: FieldApi<string, Person> }) => (
72
72
  <div>
73
73
  <input
74
74
  data-testid="fieldinput"
@@ -79,7 +79,7 @@ describe('useField', () => {
79
79
  field.setValue((e.target as HTMLInputElement).value)
80
80
  }
81
81
  />
82
- <p>{field.getMeta().error}</p>
82
+ <p>{field.getMeta().errors}</p>
83
83
  </div>
84
84
  )}
85
85
  </form.Field>
@@ -111,7 +111,7 @@ describe('useField', () => {
111
111
  name="firstName"
112
112
  onChange={(value) => (value === 'other' ? error : undefined)}
113
113
  >
114
- {(field: FieldApi<string, Person>) => (
114
+ {({ field }: { field: FieldApi<string, Person> }) => (
115
115
  <div>
116
116
  <input
117
117
  data-testid="fieldinput"
@@ -122,7 +122,7 @@ describe('useField', () => {
122
122
  field.handleChange((e.target as HTMLInputElement).value)
123
123
  }
124
124
  />
125
- <p>{field.getMeta().error}</p>
125
+ <p>{field.getMeta().errors}</p>
126
126
  </div>
127
127
  )}
128
128
  </form.Field>
@@ -159,7 +159,7 @@ describe('useField', () => {
159
159
  return error
160
160
  }}
161
161
  >
162
- {(field: FieldApi<string, Person>) => (
162
+ {({ field }: { field: FieldApi<string, Person> }) => (
163
163
  <div>
164
164
  <input
165
165
  data-testid="fieldinput"
@@ -170,7 +170,7 @@ describe('useField', () => {
170
170
  field.handleChange((e.target as HTMLInputElement).value)
171
171
  }
172
172
  />
173
- <p>{field.getMeta().error}</p>
173
+ <p>{field.getMeta().errors}</p>
174
174
  </div>
175
175
  )}
176
176
  </form.Field>
@@ -211,7 +211,7 @@ describe('useField', () => {
211
211
  return error
212
212
  }}
213
213
  >
214
- {(field: FieldApi<string, Person>) => (
214
+ {({ field }: { field: FieldApi<string, Person> }) => (
215
215
  <div>
216
216
  <input
217
217
  data-testid="fieldinput"
@@ -222,7 +222,7 @@ describe('useField', () => {
222
222
  field.handleChange((e.target as HTMLInputElement).value)
223
223
  }
224
224
  />
225
- <p>{field.getMeta().error}</p>
225
+ <p>{field.getMeta().errors}</p>
226
226
  </div>
227
227
  )}
228
228
  </form.Field>
@@ -29,7 +29,7 @@ describe('useForm', () => {
29
29
 
30
30
  return () => (
31
31
  <form.Field name="firstName" defaultValue="">
32
- {(field: FieldApi<string, Person>) => (
32
+ {({ field }: { field: FieldApi<string, Person> }) => (
33
33
  <input
34
34
  data-testid={'fieldinput'}
35
35
  value={field.state.value}
@@ -69,7 +69,9 @@ describe('useForm', () => {
69
69
 
70
70
  return () => (
71
71
  <form.Field name="firstName" defaultValue="">
72
- {(field: FieldApi<string, Person>) => <p>{field.state.value}</p>}
72
+ {({ field }: { field: FieldApi<string, Person> }) => (
73
+ <p>{field.state.value}</p>
74
+ )}
73
75
  </form.Field>
74
76
  )
75
77
  })
@@ -96,7 +98,11 @@ describe('useForm', () => {
96
98
  return () => (
97
99
  <form.Provider>
98
100
  <form.Field name="firstName">
99
- {(field: FieldApi<string, { firstName: string }>) => {
101
+ {({
102
+ field,
103
+ }: {
104
+ field: FieldApi<string, { firstName: string }>
105
+ }) => {
100
106
  return (
101
107
  <input
102
108
  value={field.state.value}
package/src/types.ts CHANGED
@@ -1 +1,3 @@
1
1
  export type NoInfer<T> = [T][T extends any ? 0 : never]
2
+
3
+ export type ReleaseVersion = 2
package/src/useField.tsx CHANGED
@@ -1,19 +1,14 @@
1
- import {
2
- type DeepKeys,
3
- type DeepValue,
4
- FieldApi,
5
- type FieldOptions,
6
- type Narrow,
1
+ import { FieldApi } from '@tanstack/form-core'
2
+ import type {
3
+ FieldState,
4
+ DeepKeys,
5
+ DeepValue,
6
+ FieldOptions,
7
+ Narrow,
7
8
  } from '@tanstack/form-core'
8
9
  import { useStore } from '@tanstack/vue-store'
9
- import {
10
- type SetupContext,
11
- defineComponent,
12
- type Ref,
13
- onMounted,
14
- onUnmounted,
15
- watch,
16
- } from 'vue-demi'
10
+ import { defineComponent, onMounted, onUnmounted, watch } from 'vue-demi'
11
+ import type { SlotsType, SetupContext, Ref } from 'vue-demi'
17
12
  import { provideFormContext, useFormContext } from './formContext'
18
13
 
19
14
  declare module '@tanstack/form-core' {
@@ -113,11 +108,7 @@ export type FieldValue<TFormData, TField> = TFormData extends any[]
113
108
  // // ^?
114
109
 
115
110
  export type FieldComponent<TParentData, TFormData> = <TField>(
116
- fieldOptions: {
117
- children?: (
118
- fieldApi: FieldApi<FieldValue<TParentData, TField>, TFormData>,
119
- ) => any
120
- } & Omit<
111
+ fieldOptions: Omit<
121
112
  UseFieldOptions<FieldValue<TParentData, TField>, TFormData>,
122
113
  'name' | 'index'
123
114
  > &
@@ -130,7 +121,15 @@ export type FieldComponent<TParentData, TFormData> = <TField>(
130
121
  name: TField extends undefined ? TField : DeepKeys<TParentData>
131
122
  index?: never
132
123
  }),
133
- context: SetupContext,
124
+ context: SetupContext<
125
+ {},
126
+ SlotsType<{
127
+ default: {
128
+ field: FieldApi<FieldValue<TParentData, TField>, TFormData>
129
+ state: FieldState<any>
130
+ }
131
+ }>
132
+ >,
134
133
  ) => any
135
134
 
136
135
  export const Field = defineComponent(
@@ -145,7 +144,11 @@ export const Field = defineComponent(
145
144
  parentFieldName: fieldApi.api.name,
146
145
  } as never)
147
146
 
148
- return () => context.slots.default!(fieldApi.api, fieldApi.state.value)
147
+ return () =>
148
+ context.slots.default!({
149
+ field: fieldApi.api,
150
+ state: fieldApi.state.value,
151
+ })
149
152
  },
150
153
  { name: 'Field', inheritAttrs: false },
151
154
  )
package/src/useForm.tsx CHANGED
@@ -2,7 +2,12 @@ import { FormApi, type FormState, type FormOptions } from '@tanstack/form-core'
2
2
  import { useStore } from '@tanstack/vue-store'
3
3
  import { type UseField, type FieldComponent, Field, useField } from './useField'
4
4
  import { provideFormContext } from './formContext'
5
- import { defineComponent } from 'vue-demi'
5
+ import {
6
+ type EmitsOptions,
7
+ type SlotsType,
8
+ type SetupContext,
9
+ defineComponent,
10
+ } from 'vue-demi'
6
11
  import type { NoInfer } from './types'
7
12
 
8
13
  declare module '@tanstack/form-core' {
@@ -15,9 +20,15 @@ declare module '@tanstack/form-core' {
15
20
  useStore: <TSelected = NoInfer<FormState<TFormData>>>(
16
21
  selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,
17
22
  ) => TSelected
18
- Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
19
- selector?: (state: NoInfer<FormState<TFormData>>) => TSelected
20
- }) => any
23
+ Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(
24
+ props: {
25
+ selector?: (state: NoInfer<FormState<TFormData>>) => TSelected
26
+ },
27
+ context: SetupContext<
28
+ EmitsOptions,
29
+ SlotsType<{ default: NoInfer<FormState<TFormData>> }>
30
+ >,
31
+ ) => any
21
32
  }
22
33
  }
23
34
 
@@ -1,42 +0,0 @@
1
- import { FieldApi, DeepKeys, FieldOptions, Narrow, DeepValue, FormOptions, FormApi } from '@tanstack/form-core';
2
- import { SetupContext, Ref } from 'vue-demi';
3
-
4
- declare module '@tanstack/form-core' {
5
- interface FieldApi<TData, TFormData> {
6
- Field: FieldComponent<TData, TFormData>;
7
- }
8
- }
9
- interface UseFieldOptions<TData, TFormData> extends FieldOptions<TData, TFormData> {
10
- mode?: 'value' | 'array';
11
- }
12
- type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(opts?: {
13
- name: Narrow<TField>;
14
- } & UseFieldOptions<DeepValue<TFormData, TField>, TFormData>) => FieldApi<DeepValue<TFormData, TField>, TFormData>;
15
- declare function useField<TData, TFormData>(opts: UseFieldOptions<TData, TFormData>): {
16
- api: FieldApi<TData, TFormData>;
17
- state: Readonly<Ref<FieldApi<TData, TFormData>['state']>>;
18
- };
19
- type FieldValue<TFormData, TField> = TFormData extends any[] ? unknown extends TField ? TFormData[number] : DeepValue<TFormData[number], TField> : DeepValue<TFormData, TField>;
20
- type FieldComponent<TParentData, TFormData> = <TField>(fieldOptions: {
21
- children?: (fieldApi: FieldApi<FieldValue<TParentData, TField>, TFormData>) => any;
22
- } & Omit<UseFieldOptions<FieldValue<TParentData, TField>, TFormData>, 'name' | 'index'> & (TParentData extends any[] ? {
23
- name?: TField extends undefined ? TField : DeepKeys<TParentData>;
24
- index: number;
25
- } : {
26
- name: TField extends undefined ? TField : DeepKeys<TParentData>;
27
- index?: never;
28
- }), context: SetupContext) => any;
29
- declare const Field: <TData, TFormData>(props: UseFieldOptions<TData, TFormData> & ({
30
- [x: `on${Capitalize<string>}`]: ((...args: never) => any) | undefined;
31
- } | {
32
- [x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
33
- })) => any;
34
-
35
- type FormFactory<TFormData> = {
36
- useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>;
37
- useField: UseField<TFormData>;
38
- Field: FieldComponent<TFormData, TFormData>;
39
- };
40
- declare function createFormFactory<TFormData>(defaultOpts?: FormOptions<TFormData>): FormFactory<TFormData>;
41
-
42
- export { FieldComponent as F, UseField as U, FormFactory as a, UseFieldOptions as b, createFormFactory as c, FieldValue as d, Field as e, useField as u };
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/createFormFactory.ts
21
- var createFormFactory_exports = {};
22
- __export(createFormFactory_exports, {
23
- createFormFactory: () => createFormFactory
24
- });
25
- module.exports = __toCommonJS(createFormFactory_exports);
26
- var import_useField = require("./useField.cjs");
27
- var import_useForm = require("./useForm.cjs");
28
- function createFormFactory(defaultOpts) {
29
- return {
30
- useForm: (opts) => {
31
- const formOptions = Object.assign({}, defaultOpts, opts);
32
- return (0, import_useForm.useForm)(formOptions);
33
- },
34
- useField: import_useField.useField,
35
- Field: import_useField.Field
36
- };
37
- }
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- createFormFactory
41
- });
42
- //# sourceMappingURL=createFormFactory.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, FormOptions } from '@tanstack/form-core'\n\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 const formOptions = Object.assign({}, defaultOpts, opts)\n return useForm<TFormData>(formOptions)\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAoE;AACpE,qBAAwB;AAQjB,SAAS,kBACd,aACwB;AACxB,SAAO;AAAA,IACL,SAAS,CAAC,SAAS;AACjB,YAAM,cAAc,OAAO,OAAO,CAAC,GAAG,aAAa,IAAI;AACvD,iBAAO,wBAAmB,WAAW;AAAA,IACvC;AAAA,IACA,UAAU;AAAA,IACV,OAAO;AAAA,EACT;AACF;","names":[]}
@@ -1,3 +0,0 @@
1
- import '@tanstack/form-core';
2
- export { a as FormFactory, c as createFormFactory } from './createFormFactory-161e85f9.js';
3
- import 'vue-demi';
@@ -1,3 +0,0 @@
1
- import '@tanstack/form-core';
2
- export { a as FormFactory, c as createFormFactory } from './createFormFactory-161e85f9.js';
3
- import 'vue-demi';
@@ -1,17 +0,0 @@
1
- // src/createFormFactory.ts
2
- import { Field, useField } from "./useField.js";
3
- import { useForm } from "./useForm.js";
4
- function createFormFactory(defaultOpts) {
5
- return {
6
- useForm: (opts) => {
7
- const formOptions = Object.assign({}, defaultOpts, opts);
8
- return useForm(formOptions);
9
- },
10
- useField,
11
- Field
12
- };
13
- }
14
- export {
15
- createFormFactory
16
- };
17
- //# sourceMappingURL=createFormFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, FormOptions } from '@tanstack/form-core'\n\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 const formOptions = Object.assign({}, defaultOpts, opts)\n return useForm<TFormData>(formOptions)\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"mappings":";AAEA,SAA6C,OAAO,gBAAgB;AACpE,SAAS,eAAe;AAQjB,SAAS,kBACd,aACwB;AACxB,SAAO;AAAA,IACL,SAAS,CAAC,SAAS;AACjB,YAAM,cAAc,OAAO,OAAO,CAAC,GAAG,aAAa,IAAI;AACvD,aAAO,QAAmB,WAAW;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/formContext.ts
21
- var formContext_exports = {};
22
- __export(formContext_exports, {
23
- formContext: () => formContext,
24
- provideFormContext: () => provideFormContext,
25
- useFormContext: () => useFormContext
26
- });
27
- module.exports = __toCommonJS(formContext_exports);
28
- var import_vue_demi = require("vue-demi");
29
- var formContext = Symbol("FormContext");
30
- function provideFormContext(val) {
31
- (0, import_vue_demi.provide)(formContext, val);
32
- }
33
- function useFormContext() {
34
- const formApi = (0, import_vue_demi.inject)(formContext);
35
- if (!formApi) {
36
- throw new Error(`You are trying to use the form API outside of a form!`);
37
- }
38
- return formApi;
39
- }
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- formContext,
43
- provideFormContext,
44
- useFormContext
45
- });
46
- //# sourceMappingURL=formContext.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/formContext.ts"],"sourcesContent":["import type { FormApi } from '@tanstack/form-core'\nimport { inject, provide } from 'vue-demi'\n\nexport type FormContext = {\n formApi: FormApi<any>\n parentFieldName?: string\n} | null\n\nexport const formContext = Symbol('FormContext')\n\nexport function provideFormContext(val: FormContext) {\n provide(formContext, val)\n}\n\nexport function useFormContext() {\n const formApi = inject(formContext) as 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAgC;AAOzB,IAAM,cAAc,OAAO,aAAa;AAExC,SAAS,mBAAmB,KAAkB;AACnD,+BAAQ,aAAa,GAAG;AAC1B;AAEO,SAAS,iBAAiB;AAC/B,QAAM,cAAU,wBAAO,WAAW;AAElC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAEA,SAAO;AACT;","names":[]}
@@ -1,14 +0,0 @@
1
- import { FormApi } from '@tanstack/form-core';
2
-
3
- type FormContext = {
4
- formApi: FormApi<any>;
5
- parentFieldName?: string;
6
- } | null;
7
- declare const formContext: unique symbol;
8
- declare function provideFormContext(val: FormContext): void;
9
- declare function useFormContext(): {
10
- formApi: FormApi<any>;
11
- parentFieldName?: string | undefined;
12
- };
13
-
14
- export { FormContext, formContext, provideFormContext, useFormContext };
@@ -1,14 +0,0 @@
1
- import { FormApi } from '@tanstack/form-core';
2
-
3
- type FormContext = {
4
- formApi: FormApi<any>;
5
- parentFieldName?: string;
6
- } | null;
7
- declare const formContext: unique symbol;
8
- declare function provideFormContext(val: FormContext): void;
9
- declare function useFormContext(): {
10
- formApi: FormApi<any>;
11
- parentFieldName?: string | undefined;
12
- };
13
-
14
- export { FormContext, formContext, provideFormContext, useFormContext };
@@ -1,19 +0,0 @@
1
- // src/formContext.ts
2
- import { inject, provide } from "vue-demi";
3
- var formContext = Symbol("FormContext");
4
- function provideFormContext(val) {
5
- provide(formContext, val);
6
- }
7
- function useFormContext() {
8
- const formApi = inject(formContext);
9
- if (!formApi) {
10
- throw new Error(`You are trying to use the form API outside of a form!`);
11
- }
12
- return formApi;
13
- }
14
- export {
15
- formContext,
16
- provideFormContext,
17
- useFormContext
18
- };
19
- //# sourceMappingURL=formContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/formContext.ts"],"sourcesContent":["import type { FormApi } from '@tanstack/form-core'\nimport { inject, provide } from 'vue-demi'\n\nexport type FormContext = {\n formApi: FormApi<any>\n parentFieldName?: string\n} | null\n\nexport const formContext = Symbol('FormContext')\n\nexport function provideFormContext(val: FormContext) {\n provide(formContext, val)\n}\n\nexport function useFormContext() {\n const formApi = inject(formContext) as 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"],"mappings":";AACA,SAAS,QAAQ,eAAe;AAOzB,IAAM,cAAc,OAAO,aAAa;AAExC,SAAS,mBAAmB,KAAkB;AACnD,UAAQ,aAAa,GAAG;AAC1B;AAEO,SAAS,iBAAiB;AAC/B,QAAM,UAAU,OAAO,WAAW;AAElC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAEA,SAAO;AACT;","names":[]}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
-
17
- // src/index.ts
18
- var src_exports = {};
19
- module.exports = __toCommonJS(src_exports);
20
- __reExport(src_exports, require("@tanstack/form-core"), module.exports);
21
- __reExport(src_exports, require("./createFormFactory.cjs"), module.exports);
22
- __reExport(src_exports, require("./formContext.cjs"), module.exports);
23
- __reExport(src_exports, require("./useField.cjs"), module.exports);
24
- __reExport(src_exports, require("./useForm.cjs"), module.exports);
25
- // Annotate the CommonJS export names for ESM import in node:
26
- 0 && (module.exports = {
27
- ...require("@tanstack/form-core"),
28
- ...require("./createFormFactory.cjs"),
29
- ...require("./formContext.cjs"),
30
- ...require("./useField.cjs"),
31
- ...require("./useForm.cjs")
32
- });
33
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@tanstack/form-core'\nexport * from './createFormFactory'\nexport * from './formContext'\nexport * from './useField'\nexport * from './useForm'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,gCAAd;AACA,wBAAc,oCADd;AAEA,wBAAc,8BAFd;AAGA,wBAAc,2BAHd;AAIA,wBAAc,0BAJd;","names":[]}
@@ -1,23 +0,0 @@
1
- import { FormState, FormOptions, FormApi } from '@tanstack/form-core';
2
- export * from '@tanstack/form-core';
3
- import { F as FieldComponent, U as UseField } from './createFormFactory-161e85f9.js';
4
- export { e as Field, d as FieldValue, a as FormFactory, b as UseFieldOptions, c as createFormFactory, u as useField } from './createFormFactory-161e85f9.js';
5
- export { FormContext, formContext, provideFormContext, useFormContext } from './formContext.cjs';
6
- import { NoInfer } from './types.cjs';
7
- import 'vue-demi';
8
-
9
- declare module '@tanstack/form-core' {
10
- interface FormApi<TFormData> {
11
- Provider: (props: Record<string, any> & {}) => any;
12
- provideFormContext: () => void;
13
- Field: FieldComponent<TFormData, TFormData>;
14
- useField: UseField<TFormData>;
15
- useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
16
- Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
17
- selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
18
- }) => any;
19
- }
20
- }
21
- declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
22
-
23
- export { FieldComponent, UseField, useForm };
@@ -1,23 +0,0 @@
1
- import { FormState, FormOptions, FormApi } from '@tanstack/form-core';
2
- export * from '@tanstack/form-core';
3
- import { F as FieldComponent, U as UseField } from './createFormFactory-161e85f9.js';
4
- export { e as Field, d as FieldValue, a as FormFactory, b as UseFieldOptions, c as createFormFactory, u as useField } from './createFormFactory-161e85f9.js';
5
- export { FormContext, formContext, provideFormContext, useFormContext } from './formContext.js';
6
- import { NoInfer } from './types.js';
7
- import 'vue-demi';
8
-
9
- declare module '@tanstack/form-core' {
10
- interface FormApi<TFormData> {
11
- Provider: (props: Record<string, any> & {}) => any;
12
- provideFormContext: () => void;
13
- Field: FieldComponent<TFormData, TFormData>;
14
- useField: UseField<TFormData>;
15
- useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
16
- Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
17
- selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
18
- }) => any;
19
- }
20
- }
21
- declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
22
-
23
- export { FieldComponent, UseField, useForm };
@@ -1,7 +0,0 @@
1
- // src/index.ts
2
- export * from "@tanstack/form-core";
3
- export * from "./createFormFactory.js";
4
- export * from "./formContext.js";
5
- export * from "./useField.js";
6
- export * from "./useForm.js";
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@tanstack/form-core'\nexport * from './createFormFactory'\nexport * from './formContext'\nexport * from './useField'\nexport * from './useForm'\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/types.ts
17
- var types_exports = {};
18
- module.exports = __toCommonJS(types_exports);
19
- //# sourceMappingURL=types.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/types.ts"],"sourcesContent":["export type NoInfer<T> = [T][T extends any ? 0 : never]\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,3 +0,0 @@
1
- type NoInfer<T> = [T][T extends any ? 0 : never];
2
-
3
- export { NoInfer };
@@ -1,3 +0,0 @@
1
- type NoInfer<T> = [T][T extends any ? 0 : never];
2
-
3
- export { NoInfer };
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,9 +0,0 @@
1
- import type { FormApi, FormOptions } from '@tanstack/form-core';
2
- import { type UseField, type FieldComponent } from './useField';
3
- export type FormFactory<TFormData> = {
4
- useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>;
5
- useField: UseField<TFormData>;
6
- Field: FieldComponent<TFormData, TFormData>;
7
- };
8
- export declare function createFormFactory<TFormData>(defaultOpts?: FormOptions<TFormData>): FormFactory<TFormData>;
9
- //# sourceMappingURL=createFormFactory.d.ts.map
@@ -1 +0,0 @@
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;AAE/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,CASxB"}
@@ -1,12 +0,0 @@
1
- import { Field, useField } from './useField';
2
- import { useForm } from './useForm';
3
- export function createFormFactory(defaultOpts) {
4
- return {
5
- useForm: (opts) => {
6
- const formOptions = Object.assign({}, defaultOpts, opts);
7
- return useForm(formOptions);
8
- },
9
- useField: useField,
10
- Field: Field,
11
- };
12
- }