@tanstack/vue-form 0.11.0 → 0.12.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 (97) hide show
  1. package/dist/cjs/createFormFactory.d.ts +8 -0
  2. package/dist/cjs/formContext.d.ts +11 -0
  3. package/dist/cjs/index.cjs +119 -0
  4. package/dist/cjs/index.cjs.map +1 -0
  5. package/dist/cjs/index.d.cts +5 -0
  6. package/dist/cjs/index.d.ts +5 -0
  7. package/dist/cjs/index.js +119 -0
  8. package/dist/cjs/tests/useField.test.d.ts +1 -0
  9. package/dist/cjs/tests/useForm.test.d.ts +1 -0
  10. package/dist/cjs/tests/utils.d.ts +1 -0
  11. package/dist/cjs/types.d.ts +4 -0
  12. package/dist/cjs/useField.d.ts +38 -0
  13. package/{build/legacy → dist/cjs}/useForm.d.ts +5 -9
  14. package/dist/mjs/createFormFactory.d.ts +8 -0
  15. package/dist/mjs/formContext.d.ts +11 -0
  16. package/dist/mjs/index.d.mts +5 -0
  17. package/dist/mjs/index.d.ts +5 -0
  18. package/dist/mjs/index.js +113 -0
  19. package/dist/mjs/index.mjs +113 -0
  20. package/dist/mjs/index.mjs.map +1 -0
  21. package/dist/mjs/tests/useField.test.d.ts +1 -0
  22. package/dist/mjs/tests/useForm.test.d.ts +1 -0
  23. package/dist/mjs/tests/utils.d.ts +1 -0
  24. package/dist/mjs/types.d.ts +4 -0
  25. package/dist/mjs/useField.d.ts +38 -0
  26. package/{build/modern → dist/mjs}/useForm.d.ts +5 -9
  27. package/package.json +17 -22
  28. package/build/legacy/createFormFactory.cjs +0 -42
  29. package/build/legacy/createFormFactory.cjs.map +0 -1
  30. package/build/legacy/createFormFactory.d.cts +0 -13
  31. package/build/legacy/createFormFactory.d.ts +0 -13
  32. package/build/legacy/createFormFactory.js +0 -17
  33. package/build/legacy/createFormFactory.js.map +0 -1
  34. package/build/legacy/formContext.cjs +0 -46
  35. package/build/legacy/formContext.cjs.map +0 -1
  36. package/build/legacy/formContext.d.cts +0 -14
  37. package/build/legacy/formContext.d.ts +0 -14
  38. package/build/legacy/formContext.js +0 -19
  39. package/build/legacy/formContext.js.map +0 -1
  40. package/build/legacy/index.cjs +0 -33
  41. package/build/legacy/index.cjs.map +0 -1
  42. package/build/legacy/index.d.cts +0 -8
  43. package/build/legacy/index.d.ts +0 -8
  44. package/build/legacy/index.js +0 -7
  45. package/build/legacy/index.js.map +0 -1
  46. package/build/legacy/types.cjs +0 -19
  47. package/build/legacy/types.cjs.map +0 -1
  48. package/build/legacy/types.d.cts +0 -7
  49. package/build/legacy/types.d.ts +0 -7
  50. package/build/legacy/types.js +0 -1
  51. package/build/legacy/types.js.map +0 -1
  52. package/build/legacy/useField.cjs +0 -77
  53. package/build/legacy/useField.cjs.map +0 -1
  54. package/build/legacy/useField.d.cts +0 -40
  55. package/build/legacy/useField.d.ts +0 -40
  56. package/build/legacy/useField.js +0 -51
  57. package/build/legacy/useField.js.map +0 -1
  58. package/build/legacy/useForm.cjs +0 -72
  59. package/build/legacy/useForm.cjs.map +0 -1
  60. package/build/legacy/useForm.d.cts +0 -23
  61. package/build/legacy/useForm.js +0 -52
  62. package/build/legacy/useForm.js.map +0 -1
  63. package/build/modern/createFormFactory.cjs +0 -42
  64. package/build/modern/createFormFactory.cjs.map +0 -1
  65. package/build/modern/createFormFactory.d.cts +0 -13
  66. package/build/modern/createFormFactory.d.ts +0 -13
  67. package/build/modern/createFormFactory.js +0 -17
  68. package/build/modern/createFormFactory.js.map +0 -1
  69. package/build/modern/formContext.cjs +0 -46
  70. package/build/modern/formContext.cjs.map +0 -1
  71. package/build/modern/formContext.d.cts +0 -14
  72. package/build/modern/formContext.d.ts +0 -14
  73. package/build/modern/formContext.js +0 -19
  74. package/build/modern/formContext.js.map +0 -1
  75. package/build/modern/index.cjs +0 -33
  76. package/build/modern/index.cjs.map +0 -1
  77. package/build/modern/index.d.cts +0 -8
  78. package/build/modern/index.d.ts +0 -8
  79. package/build/modern/index.js +0 -7
  80. package/build/modern/index.js.map +0 -1
  81. package/build/modern/types.cjs +0 -19
  82. package/build/modern/types.cjs.map +0 -1
  83. package/build/modern/types.d.cts +0 -7
  84. package/build/modern/types.d.ts +0 -7
  85. package/build/modern/types.js +0 -1
  86. package/build/modern/types.js.map +0 -1
  87. package/build/modern/useField.cjs +0 -77
  88. package/build/modern/useField.cjs.map +0 -1
  89. package/build/modern/useField.d.cts +0 -40
  90. package/build/modern/useField.d.ts +0 -40
  91. package/build/modern/useField.js +0 -51
  92. package/build/modern/useField.js.map +0 -1
  93. package/build/modern/useForm.cjs +0 -72
  94. package/build/modern/useForm.cjs.map +0 -1
  95. package/build/modern/useForm.d.cts +0 -23
  96. package/build/modern/useForm.js +0 -52
  97. package/build/modern/useForm.js.map +0 -1
@@ -1,40 +0,0 @@
1
- import * as _tanstack_form_core from '@tanstack/form-core';
2
- import { DeepKeys, Validator, DeepValue, FieldApi, Narrow } from '@tanstack/form-core';
3
- import { SetupContext, SlotsType, Ref } from 'vue';
4
- import { UseFieldOptions } from './types.cjs';
5
-
6
- declare module '@tanstack/form-core' {
7
- interface FieldApi<TParentData, TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined, TData = DeepValue<TParentData, TName>> {
8
- Field: FieldComponent<TParentData, TFormValidator>;
9
- }
10
- }
11
- type UseField<TParentData, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined> = <TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined>(opts?: {
12
- name: Narrow<TName>;
13
- } & UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator, DeepValue<TParentData, TName>>) => FieldApi<TParentData, TName, TFieldValidator, TFormValidator, DeepValue<TParentData, TName>>;
14
- declare function useField<TParentData, TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined, TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>>(opts: UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator, TData>): {
15
- api: FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>;
16
- state: Readonly<Ref<FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>['state']>>;
17
- };
18
- type FieldValue<TParentData, TName> = TParentData extends any[] ? unknown extends TName ? TParentData[number] : DeepValue<TParentData[number], TName> : DeepValue<TParentData, TName>;
19
- type FieldComponentProps<TParentData, TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined> = (TParentData extends any[] ? {
20
- name?: TName;
21
- index: number;
22
- } : {
23
- name: TName;
24
- index?: never;
25
- }) & Omit<UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator>, 'name' | 'index'>;
26
- type FieldComponent<TParentData, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined> = <TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined, TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>>(fieldOptions: FieldComponentProps<TParentData, TName, TFieldValidator, TFormValidator>, context: SetupContext<{}, SlotsType<{
27
- default: {
28
- field: FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>;
29
- state: FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>['state'];
30
- };
31
- }>>) => any;
32
- declare const Field: <TParentData, TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined>(props: _tanstack_form_core.FieldOptions<TParentData, TName, TFieldValidator, TFormValidator, DeepValue<TParentData, TName>> & {
33
- mode?: "value" | "array" | undefined;
34
- } & ({
35
- [x: `on${Capitalize<string>}`]: ((...args: never) => any) | undefined;
36
- } | {
37
- [x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
38
- })) => any;
39
-
40
- export { Field, FieldComponent, FieldValue, UseField, useField };
@@ -1,40 +0,0 @@
1
- import * as _tanstack_form_core from '@tanstack/form-core';
2
- import { DeepKeys, Validator, DeepValue, FieldApi, Narrow } from '@tanstack/form-core';
3
- import { SetupContext, SlotsType, Ref } from 'vue';
4
- import { UseFieldOptions } from './types.js';
5
-
6
- declare module '@tanstack/form-core' {
7
- interface FieldApi<TParentData, TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined, TData = DeepValue<TParentData, TName>> {
8
- Field: FieldComponent<TParentData, TFormValidator>;
9
- }
10
- }
11
- type UseField<TParentData, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined> = <TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined>(opts?: {
12
- name: Narrow<TName>;
13
- } & UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator, DeepValue<TParentData, TName>>) => FieldApi<TParentData, TName, TFieldValidator, TFormValidator, DeepValue<TParentData, TName>>;
14
- declare function useField<TParentData, TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined, TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>>(opts: UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator, TData>): {
15
- api: FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>;
16
- state: Readonly<Ref<FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>['state']>>;
17
- };
18
- type FieldValue<TParentData, TName> = TParentData extends any[] ? unknown extends TName ? TParentData[number] : DeepValue<TParentData[number], TName> : DeepValue<TParentData, TName>;
19
- type FieldComponentProps<TParentData, TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined> = (TParentData extends any[] ? {
20
- name?: TName;
21
- index: number;
22
- } : {
23
- name: TName;
24
- index?: never;
25
- }) & Omit<UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator>, 'name' | 'index'>;
26
- type FieldComponent<TParentData, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined> = <TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined, TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>>(fieldOptions: FieldComponentProps<TParentData, TName, TFieldValidator, TFormValidator>, context: SetupContext<{}, SlotsType<{
27
- default: {
28
- field: FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>;
29
- state: FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>['state'];
30
- };
31
- }>>) => any;
32
- declare const Field: <TParentData, TName extends DeepKeys<TParentData>, TFieldValidator extends Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined, TFormValidator extends Validator<TParentData, unknown> | undefined = undefined>(props: _tanstack_form_core.FieldOptions<TParentData, TName, TFieldValidator, TFormValidator, DeepValue<TParentData, TName>> & {
33
- mode?: "value" | "array" | undefined;
34
- } & ({
35
- [x: `on${Capitalize<string>}`]: ((...args: never) => any) | undefined;
36
- } | {
37
- [x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
38
- })) => any;
39
-
40
- export { Field, FieldComponent, FieldValue, UseField, useField };
@@ -1,51 +0,0 @@
1
- // src/useField.tsx
2
- import { FieldApi } from "@tanstack/form-core";
3
- import { useStore } from "@tanstack/vue-store";
4
- import { defineComponent, onMounted, onUnmounted, watch } from "vue";
5
- import { provideFormContext, useFormContext } from "./formContext.js";
6
- function useField(opts) {
7
- const { formApi, parentFieldName } = useFormContext();
8
- const fieldApi = (() => {
9
- const api = new FieldApi({
10
- ...opts,
11
- form: formApi,
12
- name: opts.name
13
- });
14
- api.Field = Field;
15
- return api;
16
- })();
17
- const fieldState = useStore(fieldApi.store, (state) => state);
18
- let cleanup;
19
- onMounted(() => {
20
- cleanup = fieldApi.mount();
21
- });
22
- onUnmounted(() => {
23
- cleanup();
24
- });
25
- watch(
26
- () => opts,
27
- () => {
28
- fieldApi.update({ ...opts, form: formApi });
29
- }
30
- );
31
- return { api: fieldApi, state: fieldState };
32
- }
33
- var Field = defineComponent(
34
- (fieldOptions, context) => {
35
- const fieldApi = useField({ ...fieldOptions, ...context.attrs });
36
- provideFormContext({
37
- formApi: fieldApi.api.form,
38
- parentFieldName: fieldApi.api.name
39
- });
40
- return () => context.slots.default({
41
- field: fieldApi.api,
42
- state: fieldApi.state.value
43
- });
44
- },
45
- { name: "Field", inheritAttrs: false }
46
- );
47
- export {
48
- Field,
49
- useField
50
- };
51
- //# sourceMappingURL=useField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import { FieldApi, type Validator } from '@tanstack/form-core'\nimport type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport { defineComponent, onMounted, onUnmounted, watch } from 'vue'\nimport type { SlotsType, SetupContext, Ref } from 'vue'\nimport { provideFormContext, useFormContext } from './formContext'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n TData = DeepValue<TParentData, TName>,\n > {\n Field: FieldComponent<TParentData, TFormValidator>\n }\n}\n\nexport type UseField<\n TParentData,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = <\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n DeepValue<TParentData, TName>\n >,\n) => FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n DeepValue<TParentData, TName>\n>\n\nexport function useField<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,\n>(\n opts: UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >,\n): {\n api: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n >\n state: Readonly<\n Ref<\n FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >['state']\n >\n >\n} {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const fieldApi = (() => {\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: opts.name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })()\n\n const fieldState = useStore(fieldApi.store, (state) => state)\n\n let cleanup!: () => void\n onMounted(() => {\n cleanup = fieldApi.mount()\n })\n\n onUnmounted(() => {\n cleanup()\n })\n\n watch(\n () => opts,\n () => {\n // Keep options up to date as they are rendered\n fieldApi.update({ ...opts, form: formApi } as never)\n },\n )\n\n return { api: fieldApi, state: fieldState } as never\n}\n\nexport type FieldValue<TParentData, TName> = TParentData extends any[]\n ? unknown extends TName\n ? TParentData[number]\n : DeepValue<TParentData[number], TName>\n : DeepValue<TParentData, TName>\n\ntype FieldComponentProps<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<\n UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator>,\n 'name' | 'index'\n >\n\nexport type FieldComponent<\n TParentData,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = <\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,\n>(\n fieldOptions: FieldComponentProps<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator\n >,\n context: SetupContext<\n {},\n SlotsType<{\n default: {\n field: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >\n state: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >['state']\n }\n }>\n >,\n) => any\n\nexport const Field = defineComponent(\n <\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n >(\n fieldOptions: UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator\n >,\n context: SetupContext,\n ) => {\n const fieldApi = useField({ ...fieldOptions, ...context.attrs } as any)\n\n provideFormContext({\n formApi: fieldApi.api.form,\n parentFieldName: fieldApi.api.name,\n } as never)\n\n return () =>\n context.slots.default!({\n field: fieldApi.api,\n state: fieldApi.state.value,\n })\n },\n { name: 'Field', inheritAttrs: false },\n)\n"],"mappings":";AAAA,SAAS,gBAAgC;AAEzC,SAAS,gBAAgB;AACzB,SAAS,iBAAiB,WAAW,aAAa,aAAa;AAE/D,SAAS,oBAAoB,sBAAsB;AA8C5C,SAAS,SAWd,MA6BA;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAI,eAAe;AAEpD,QAAM,YAAY,MAAM;AACtB,UAAM,MAAM,IAAI,SAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN,MAAM,KAAK;AAAA,IACb,CAAU;AAEV,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,GAAG;AAEH,QAAM,aAAa,SAAS,SAAS,OAAO,CAAC,UAAU,KAAK;AAE5D,MAAI;AACJ,YAAU,MAAM;AACd,cAAU,SAAS,MAAM;AAAA,EAC3B,CAAC;AAED,cAAY,MAAM;AAChB,YAAQ;AAAA,EACV,CAAC;AAED;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAEJ,eAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,IACrD;AAAA,EACF;AAEA,SAAO,EAAE,KAAK,UAAU,OAAO,WAAW;AAC5C;AAwEO,IAAM,QAAQ;AAAA,EACnB,CAUE,cAMA,YACG;AACH,UAAM,WAAW,SAAS,EAAE,GAAG,cAAc,GAAG,QAAQ,MAAM,CAAQ;AAEtE,uBAAmB;AAAA,MACjB,SAAS,SAAS,IAAI;AAAA,MACtB,iBAAiB,SAAS,IAAI;AAAA,IAChC,CAAU;AAEV,WAAO,MACL,QAAQ,MAAM,QAAS;AAAA,MACrB,OAAO,SAAS;AAAA,MAChB,OAAO,SAAS,MAAM;AAAA,IACxB,CAAC;AAAA,EACL;AAAA,EACA,EAAE,MAAM,SAAS,cAAc,MAAM;AACvC;","names":[]}
@@ -1,72 +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/useForm.tsx
21
- var useForm_exports = {};
22
- __export(useForm_exports, {
23
- useForm: () => useForm
24
- });
25
- module.exports = __toCommonJS(useForm_exports);
26
- var import_form_core = require("@tanstack/form-core");
27
- var import_vue_store = require("@tanstack/vue-store");
28
- var import_useField = require("./useField.cjs");
29
- var import_formContext = require("./formContext.cjs");
30
- var import_vue = require("vue");
31
- function useForm(opts) {
32
- const formApi = (() => {
33
- const api = new import_form_core.FormApi(opts);
34
- api.Provider = (0, import_vue.defineComponent)(
35
- (_, context) => {
36
- (0, import_vue.onMounted)(api.mount);
37
- (0, import_formContext.provideFormContext)({ formApi });
38
- return () => context.slots.default();
39
- },
40
- { name: "Provider" }
41
- );
42
- api.provideFormContext = () => {
43
- (0, import_vue.onMounted)(api.mount);
44
- (0, import_formContext.provideFormContext)({ formApi });
45
- };
46
- api.Field = import_useField.Field;
47
- api.useField = import_useField.useField;
48
- api.useStore = (selector) => {
49
- return (0, import_vue_store.useStore)(api.store, selector);
50
- };
51
- api.Subscribe = (0, import_vue.defineComponent)(
52
- (props, context) => {
53
- const allProps = { ...props, ...context.attrs };
54
- const selector = allProps.selector ?? ((state) => state);
55
- const data = (0, import_vue_store.useStore)(api.store, selector);
56
- return () => context.slots.default(data.value);
57
- },
58
- {
59
- name: "Subscribe",
60
- inheritAttrs: false
61
- }
62
- );
63
- return api;
64
- })();
65
- formApi.update(opts);
66
- return formApi;
67
- }
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- useForm
71
- });
72
- //# sourceMappingURL=useForm.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/useForm.tsx"],"sourcesContent":["import {\n FormApi,\n type FormState,\n type FormOptions,\n type Validator,\n} from '@tanstack/form-core'\nimport { type NoInfer, useStore } from '@tanstack/vue-store'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { provideFormContext } from './formContext'\nimport {\n type EmitsOptions,\n type SlotsType,\n type SetupContext,\n type Ref,\n defineComponent,\n onMounted,\n} from 'vue'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData, TFormValidator> {\n Provider: (props: Record<string, any> & {}) => any\n provideFormContext: () => void\n Field: FieldComponent<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => Readonly<Ref<TSelected>>\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(\n props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n },\n context: SetupContext<\n EmitsOptions,\n SlotsType<{ default: NoInfer<FormState<TFormData>> }>\n >,\n ) => any\n }\n}\n\nexport function useForm<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n opts?: FormOptions<TFormData, TFormValidator>,\n): FormApi<TFormData, TFormValidator> {\n const formApi = (() => {\n const api = new FormApi<TFormData, TFormValidator>(opts)\n\n api.Provider = defineComponent(\n (_, context) => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n return () => context.slots.default!()\n },\n { name: 'Provider' },\n )\n api.provideFormContext = () => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n }\n api.Field = Field as never\n api.useField = useField as never\n api.useStore = (selector) => {\n return useStore(api.store as never, selector as never) as never\n }\n api.Subscribe = defineComponent(\n (props, context) => {\n const allProps = { ...props, ...context.attrs }\n const selector = allProps.selector ?? ((state) => state)\n const data = useStore(api.store as never, selector as never)\n return () => context.slots.default!(data.value)\n },\n {\n name: 'Subscribe',\n inheritAttrs: false,\n },\n )\n\n return api\n })()\n\n // formApi.useStore((state) => state.isSubmitting)\n formApi.update(opts)\n\n return formApi as never\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAKO;AACP,uBAAuC;AACvC,sBAAoE;AACpE,yBAAmC;AACnC,iBAOO;AAwBA,SAAS,QAId,MACoC;AACpC,QAAM,WAAW,MAAM;AACrB,UAAM,MAAM,IAAI,yBAAmC,IAAI;AAEvD,QAAI,eAAW;AAAA,MACb,CAAC,GAAG,YAAY;AACd,kCAAU,IAAI,KAAK;AACnB,mDAAmB,EAAE,QAA0B,CAAC;AAChD,eAAO,MAAM,QAAQ,MAAM,QAAS;AAAA,MACtC;AAAA,MACA,EAAE,MAAM,WAAW;AAAA,IACrB;AACA,QAAI,qBAAqB,MAAM;AAC7B,gCAAU,IAAI,KAAK;AACnB,iDAAmB,EAAE,QAA0B,CAAC;AAAA,IAClD;AACA,QAAI,QAAQ;AACZ,QAAI,WAAW;AACf,QAAI,WAAW,CAAC,aAAa;AAC3B,iBAAO,2BAAS,IAAI,OAAgB,QAAiB;AAAA,IACvD;AACA,QAAI,gBAAY;AAAA,MACd,CAAC,OAAO,YAAY;AAClB,cAAM,WAAW,EAAE,GAAG,OAAO,GAAG,QAAQ,MAAM;AAC9C,cAAM,WAAW,SAAS,aAAa,CAAC,UAAU;AAClD,cAAM,WAAO,2BAAS,IAAI,OAAgB,QAAiB;AAC3D,eAAO,MAAM,QAAQ,MAAM,QAAS,KAAK,KAAK;AAAA,MAChD;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,cAAc;AAAA,MAChB;AAAA,IACF;AAEA,WAAO;AAAA,EACT,GAAG;AAGH,UAAQ,OAAO,IAAI;AAEnB,SAAO;AACT;","names":[]}
@@ -1,23 +0,0 @@
1
- import { FormState, Validator, FormOptions, FormApi } from '@tanstack/form-core';
2
- import { NoInfer } from '@tanstack/vue-store';
3
- import { FieldComponent, UseField } from './useField.cjs';
4
- import { Ref, SetupContext, EmitsOptions, SlotsType } from 'vue';
5
- import './types.cjs';
6
-
7
- declare module '@tanstack/form-core' {
8
- interface FormApi<TFormData, TFormValidator> {
9
- Provider: (props: Record<string, any> & {}) => any;
10
- provideFormContext: () => void;
11
- Field: FieldComponent<TFormData, TFormValidator>;
12
- useField: UseField<TFormData, TFormValidator>;
13
- useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => Readonly<Ref<TSelected>>;
14
- Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
15
- selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
16
- }, context: SetupContext<EmitsOptions, SlotsType<{
17
- default: NoInfer<FormState<TFormData>>;
18
- }>>) => any;
19
- }
20
- }
21
- declare function useForm<TFormData, TFormValidator extends Validator<TFormData, unknown> | undefined = undefined>(opts?: FormOptions<TFormData, TFormValidator>): FormApi<TFormData, TFormValidator>;
22
-
23
- export { useForm };
@@ -1,52 +0,0 @@
1
- // src/useForm.tsx
2
- import {
3
- FormApi
4
- } from "@tanstack/form-core";
5
- import { useStore } from "@tanstack/vue-store";
6
- import { Field, useField } from "./useField.js";
7
- import { provideFormContext } from "./formContext.js";
8
- import {
9
- defineComponent,
10
- onMounted
11
- } from "vue";
12
- function useForm(opts) {
13
- const formApi = (() => {
14
- const api = new FormApi(opts);
15
- api.Provider = defineComponent(
16
- (_, context) => {
17
- onMounted(api.mount);
18
- provideFormContext({ formApi });
19
- return () => context.slots.default();
20
- },
21
- { name: "Provider" }
22
- );
23
- api.provideFormContext = () => {
24
- onMounted(api.mount);
25
- provideFormContext({ formApi });
26
- };
27
- api.Field = Field;
28
- api.useField = useField;
29
- api.useStore = (selector) => {
30
- return useStore(api.store, selector);
31
- };
32
- api.Subscribe = defineComponent(
33
- (props, context) => {
34
- const allProps = { ...props, ...context.attrs };
35
- const selector = allProps.selector ?? ((state) => state);
36
- const data = useStore(api.store, selector);
37
- return () => context.slots.default(data.value);
38
- },
39
- {
40
- name: "Subscribe",
41
- inheritAttrs: false
42
- }
43
- );
44
- return api;
45
- })();
46
- formApi.update(opts);
47
- return formApi;
48
- }
49
- export {
50
- useForm
51
- };
52
- //# sourceMappingURL=useForm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/useForm.tsx"],"sourcesContent":["import {\n FormApi,\n type FormState,\n type FormOptions,\n type Validator,\n} from '@tanstack/form-core'\nimport { type NoInfer, useStore } from '@tanstack/vue-store'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { provideFormContext } from './formContext'\nimport {\n type EmitsOptions,\n type SlotsType,\n type SetupContext,\n type Ref,\n defineComponent,\n onMounted,\n} from 'vue'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData, TFormValidator> {\n Provider: (props: Record<string, any> & {}) => any\n provideFormContext: () => void\n Field: FieldComponent<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => Readonly<Ref<TSelected>>\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(\n props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n },\n context: SetupContext<\n EmitsOptions,\n SlotsType<{ default: NoInfer<FormState<TFormData>> }>\n >,\n ) => any\n }\n}\n\nexport function useForm<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n opts?: FormOptions<TFormData, TFormValidator>,\n): FormApi<TFormData, TFormValidator> {\n const formApi = (() => {\n const api = new FormApi<TFormData, TFormValidator>(opts)\n\n api.Provider = defineComponent(\n (_, context) => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n return () => context.slots.default!()\n },\n { name: 'Provider' },\n )\n api.provideFormContext = () => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n }\n api.Field = Field as never\n api.useField = useField as never\n api.useStore = (selector) => {\n return useStore(api.store as never, selector as never) as never\n }\n api.Subscribe = defineComponent(\n (props, context) => {\n const allProps = { ...props, ...context.attrs }\n const selector = allProps.selector ?? ((state) => state)\n const data = useStore(api.store as never, selector as never)\n return () => context.slots.default!(data.value)\n },\n {\n name: 'Subscribe',\n inheritAttrs: false,\n },\n )\n\n return api\n })()\n\n // formApi.useStore((state) => state.isSubmitting)\n formApi.update(opts)\n\n return formApi as never\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAIK;AACP,SAAuB,gBAAgB;AACvC,SAA6C,OAAO,gBAAgB;AACpE,SAAS,0BAA0B;AACnC;AAAA,EAKE;AAAA,EACA;AAAA,OACK;AAwBA,SAAS,QAId,MACoC;AACpC,QAAM,WAAW,MAAM;AACrB,UAAM,MAAM,IAAI,QAAmC,IAAI;AAEvD,QAAI,WAAW;AAAA,MACb,CAAC,GAAG,YAAY;AACd,kBAAU,IAAI,KAAK;AACnB,2BAAmB,EAAE,QAA0B,CAAC;AAChD,eAAO,MAAM,QAAQ,MAAM,QAAS;AAAA,MACtC;AAAA,MACA,EAAE,MAAM,WAAW;AAAA,IACrB;AACA,QAAI,qBAAqB,MAAM;AAC7B,gBAAU,IAAI,KAAK;AACnB,yBAAmB,EAAE,QAA0B,CAAC;AAAA,IAClD;AACA,QAAI,QAAQ;AACZ,QAAI,WAAW;AACf,QAAI,WAAW,CAAC,aAAa;AAC3B,aAAO,SAAS,IAAI,OAAgB,QAAiB;AAAA,IACvD;AACA,QAAI,YAAY;AAAA,MACd,CAAC,OAAO,YAAY;AAClB,cAAM,WAAW,EAAE,GAAG,OAAO,GAAG,QAAQ,MAAM;AAC9C,cAAM,WAAW,SAAS,aAAa,CAAC,UAAU;AAClD,cAAM,OAAO,SAAS,IAAI,OAAgB,QAAiB;AAC3D,eAAO,MAAM,QAAQ,MAAM,QAAS,KAAK,KAAK;AAAA,MAChD;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,cAAc;AAAA,MAChB;AAAA,IACF;AAEA,WAAO;AAAA,EACT,GAAG;AAGH,UAAQ,OAAO,IAAI;AAEnB,SAAO;AACT;","names":[]}
@@ -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, Validator } from '@tanstack/form-core'\n\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { useForm } from './useForm'\n\nexport type FormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n useForm: (\n opts?: FormOptions<TFormData, TFormValidator>,\n ) => FormApi<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n Field: FieldComponent<TFormData, TFormValidator>\n}\n\nexport function createFormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n defaultOpts?: FormOptions<TFormData, TFormValidator>,\n): FormFactory<TFormData, TFormValidator> {\n return {\n useForm: (opts) => {\n const formOptions = Object.assign({}, defaultOpts, opts)\n return useForm<TFormData, TFormValidator>(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;AAajB,SAAS,kBAId,aACwC;AACxC,SAAO;AAAA,IACL,SAAS,CAAC,SAAS;AACjB,YAAM,cAAc,OAAO,OAAO,CAAC,GAAG,aAAa,IAAI;AACvD,iBAAO,wBAAmC,WAAW;AAAA,IACvD;AAAA,IACA,UAAU;AAAA,IACV,OAAO;AAAA,EACT;AACF;","names":[]}
@@ -1,13 +0,0 @@
1
- import { Validator, FormOptions, FormApi } from '@tanstack/form-core';
2
- import { UseField, FieldComponent } from './useField.cjs';
3
- import 'vue';
4
- import './types.cjs';
5
-
6
- type FormFactory<TFormData, TFormValidator extends Validator<TFormData, unknown> | undefined = undefined> = {
7
- useForm: (opts?: FormOptions<TFormData, TFormValidator>) => FormApi<TFormData, TFormValidator>;
8
- useField: UseField<TFormData, TFormValidator>;
9
- Field: FieldComponent<TFormData, TFormValidator>;
10
- };
11
- declare function createFormFactory<TFormData, TFormValidator extends Validator<TFormData, unknown> | undefined = undefined>(defaultOpts?: FormOptions<TFormData, TFormValidator>): FormFactory<TFormData, TFormValidator>;
12
-
13
- export { FormFactory, createFormFactory };
@@ -1,13 +0,0 @@
1
- import { Validator, FormOptions, FormApi } from '@tanstack/form-core';
2
- import { UseField, FieldComponent } from './useField.js';
3
- import 'vue';
4
- import './types.js';
5
-
6
- type FormFactory<TFormData, TFormValidator extends Validator<TFormData, unknown> | undefined = undefined> = {
7
- useForm: (opts?: FormOptions<TFormData, TFormValidator>) => FormApi<TFormData, TFormValidator>;
8
- useField: UseField<TFormData, TFormValidator>;
9
- Field: FieldComponent<TFormData, TFormValidator>;
10
- };
11
- declare function createFormFactory<TFormData, TFormValidator extends Validator<TFormData, unknown> | undefined = undefined>(defaultOpts?: FormOptions<TFormData, TFormValidator>): FormFactory<TFormData, TFormValidator>;
12
-
13
- export { FormFactory, createFormFactory };
@@ -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, Validator } from '@tanstack/form-core'\n\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { useForm } from './useForm'\n\nexport type FormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n useForm: (\n opts?: FormOptions<TFormData, TFormValidator>,\n ) => FormApi<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n Field: FieldComponent<TFormData, TFormValidator>\n}\n\nexport function createFormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n defaultOpts?: FormOptions<TFormData, TFormValidator>,\n): FormFactory<TFormData, TFormValidator> {\n return {\n useForm: (opts) => {\n const formOptions = Object.assign({}, defaultOpts, opts)\n return useForm<TFormData, TFormValidator>(formOptions)\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"mappings":";AAEA,SAA6C,OAAO,gBAAgB;AACpE,SAAS,eAAe;AAajB,SAAS,kBAId,aACwC;AACxC,SAAO;AAAA,IACL,SAAS,CAAC,SAAS;AACjB,YAAM,cAAc,OAAO,OAAO,CAAC,GAAG,aAAa,IAAI;AACvD,aAAO,QAAmC,WAAW;AAAA,IACvD;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 = require("vue");
29
- var formContext = Symbol("FormContext");
30
- function provideFormContext(val) {
31
- (0, import_vue.provide)(formContext, val);
32
- }
33
- function useFormContext() {
34
- const formApi = (0, import_vue.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, Validator } from '@tanstack/form-core'\nimport { inject, provide } from 'vue'\n\nexport type FormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n formApi: FormApi<TFormData, TFormValidator>\n parentFieldName?: string\n} | null\n\nexport const formContext = Symbol('FormContext')\n\nexport function provideFormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(val: FormContext<TFormData, TFormValidator>) {\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,iBAAgC;AAUzB,IAAM,cAAc,OAAO,aAAa;AAExC,SAAS,mBAGd,KAA6C;AAC7C,0BAAQ,aAAa,GAAG;AAC1B;AAEO,SAAS,iBAAiB;AAC/B,QAAM,cAAU,mBAAO,WAAW;AAElC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAEA,SAAO;AACT;","names":[]}
@@ -1,14 +0,0 @@
1
- import { Validator, FormApi } from '@tanstack/form-core';
2
-
3
- type FormContext<TFormData = any, TFormValidator extends Validator<TFormData, unknown> | undefined = undefined> = {
4
- formApi: FormApi<TFormData, TFormValidator>;
5
- parentFieldName?: string;
6
- } | null;
7
- declare const formContext: unique symbol;
8
- declare function provideFormContext<TFormData = any, TFormValidator extends Validator<TFormData, unknown> | undefined = undefined>(val: FormContext<TFormData, TFormValidator>): void;
9
- declare function useFormContext(): {
10
- formApi: FormApi<any, undefined>;
11
- parentFieldName?: string | undefined;
12
- };
13
-
14
- export { FormContext, formContext, provideFormContext, useFormContext };
@@ -1,14 +0,0 @@
1
- import { Validator, FormApi } from '@tanstack/form-core';
2
-
3
- type FormContext<TFormData = any, TFormValidator extends Validator<TFormData, unknown> | undefined = undefined> = {
4
- formApi: FormApi<TFormData, TFormValidator>;
5
- parentFieldName?: string;
6
- } | null;
7
- declare const formContext: unique symbol;
8
- declare function provideFormContext<TFormData = any, TFormValidator extends Validator<TFormData, unknown> | undefined = undefined>(val: FormContext<TFormData, TFormValidator>): void;
9
- declare function useFormContext(): {
10
- formApi: FormApi<any, undefined>;
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";
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, Validator } from '@tanstack/form-core'\nimport { inject, provide } from 'vue'\n\nexport type FormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n formApi: FormApi<TFormData, TFormValidator>\n parentFieldName?: string\n} | null\n\nexport const formContext = Symbol('FormContext')\n\nexport function provideFormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(val: FormContext<TFormData, TFormValidator>) {\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;AAUzB,IAAM,cAAc,OAAO,aAAa;AAExC,SAAS,mBAGd,KAA6C;AAC7C,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,8 +0,0 @@
1
- export * from '@tanstack/form-core';
2
- export { FormFactory, createFormFactory } from './createFormFactory.cjs';
3
- export { FormContext, formContext, provideFormContext, useFormContext } from './formContext.cjs';
4
- export { Field, FieldComponent, FieldValue, UseField, useField } from './useField.cjs';
5
- export { useForm } from './useForm.cjs';
6
- import 'vue';
7
- import './types.cjs';
8
- import '@tanstack/vue-store';
@@ -1,8 +0,0 @@
1
- export * from '@tanstack/form-core';
2
- export { FormFactory, createFormFactory } from './createFormFactory.js';
3
- export { FormContext, formContext, provideFormContext, useFormContext } from './formContext.js';
4
- export { Field, FieldComponent, FieldValue, UseField, useField } from './useField.js';
5
- export { useForm } from './useForm.js';
6
- import 'vue';
7
- import './types.js';
8
- import '@tanstack/vue-store';
@@ -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":["import type {\n FieldOptions,\n DeepKeys,\n DeepValue,\n Validator,\n} from '@tanstack/form-core'\n\nexport type UseFieldOptions<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,\n> = FieldOptions<TParentData, TName, TFieldValidator, TFormValidator, TData> & {\n mode?: 'value' | 'array'\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}