@tanstack/react-form 0.0.7 → 0.0.9

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 (37) hide show
  1. package/build/cjs/createFormFactory.js +2 -3
  2. package/build/cjs/createFormFactory.js.map +1 -1
  3. package/build/cjs/formContext.js.map +1 -1
  4. package/build/cjs/index.js +1 -2
  5. package/build/cjs/index.js.map +1 -1
  6. package/build/cjs/useField.js +46 -11
  7. package/build/cjs/useField.js.map +1 -1
  8. package/build/cjs/useForm.js +6 -4
  9. package/build/cjs/useForm.js.map +1 -1
  10. package/build/esm/index.js +47 -22
  11. package/build/esm/index.js.map +1 -1
  12. package/build/stats-html.html +1 -1
  13. package/build/stats-react.json +97 -153
  14. package/build/types/form-core/src/FieldApi.d.ts +2 -1
  15. package/build/types/form-core/src/FormApi.d.ts +2 -2
  16. package/build/types/form-core/src/utils.d.ts +7 -1
  17. package/build/types/index.d.ts +30 -22
  18. package/build/types/react-form/src/createFormFactory.d.ts +2 -3
  19. package/build/types/react-form/src/formContext.d.ts +8 -2
  20. package/build/types/react-form/src/index.d.ts +2 -4
  21. package/build/types/react-form/src/useField.d.ts +23 -8
  22. package/build/types/react-form/src/useForm.d.ts +2 -3
  23. package/build/umd/index.development.js +58 -32
  24. package/build/umd/index.development.js.map +1 -1
  25. package/build/umd/index.production.js +2 -2
  26. package/build/umd/index.production.js.map +1 -1
  27. package/package.json +2 -2
  28. package/src/createFormFactory.ts +4 -5
  29. package/src/formContext.ts +4 -1
  30. package/src/index.ts +2 -5
  31. package/src/useField.tsx +138 -0
  32. package/src/useForm.tsx +7 -6
  33. package/build/cjs/Field.js +0 -54
  34. package/build/cjs/Field.js.map +0 -1
  35. package/build/types/react-form/src/Field.d.ts +0 -9
  36. package/src/Field.tsx +0 -36
  37. package/src/useField.ts +0 -50
@@ -14,7 +14,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
14
14
 
15
15
  var useField = require('./useField.js');
16
16
  var useForm = require('./useForm.js');
17
- var Field = require('./Field.js');
18
17
 
19
18
  function createFormFactory(defaultOpts) {
20
19
  return {
@@ -23,8 +22,8 @@ function createFormFactory(defaultOpts) {
23
22
  ...opts
24
23
  });
25
24
  },
26
- useField: useField.createUseField(),
27
- Field: Field.createFieldComponent()
25
+ useField: useField.useField,
26
+ Field: useField.Field
28
27
  };
29
28
  }
30
29
 
@@ -1 +1 @@
1
- {"version":3,"file":"createFormFactory.js","sources":["../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, FormOptions } from '@tanstack/form-core'\nimport { createUseField, type UseField } from './useField'\nimport { useForm } from './useForm'\nimport { createFieldComponent, type FieldComponent } from './Field'\n\nexport type FormFactory<TFormData> = {\n useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>\n useField: UseField<TFormData>\n Field: FieldComponent<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: createUseField<TFormData>(),\n Field: createFieldComponent<TFormData>(),\n }\n}\n"],"names":["createFormFactory","defaultOpts","useForm","opts","useField","createUseField","Field","createFieldComponent"],"mappings":";;;;;;;;;;;;;;;;;;AAWO,SAASA,iBAAT,CACLC,WADK,EAEmB;EACxB,OAAO;IACLC,OAAO,EAAGC,IAAD,IAAU;AACjB,MAAA,OAAOD,eAAO,CAAY,EAAE,GAAGD,WAAL;QAAkB,GAAGE,IAAAA;AAArB,OAAZ,CAAd,CAAA;KAFG;IAILC,QAAQ,EAAEC,uBAAc,EAJnB;AAKLC,IAAAA,KAAK,EAAEC,0BAAoB,EAAA;GAL7B,CAAA;AAOD;;;;"}
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,iBAAT,CACLC,WADK,EAEmB;EACxB,OAAO;IACLC,OAAO,EAAGC,IAAD,IAAU;AACjB,MAAA,OAAOD,eAAO,CAAY,EAAE,GAAGD,WAAL;QAAkB,GAAGE,IAAAA;AAArB,OAAZ,CAAd,CAAA;KAFG;AAILC,IAAAA,QAAQ,EAAEA,iBAJL;AAKLC,IAAAA,KAAK,EAAEA,cAAAA;GALT,CAAA;AAOD;;;;"}
@@ -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<FormApi<any> | 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,aAAN,CAAyC,IAAzC,EAApB;AAEA,SAASC,cAAT,GAA0B;AAC/B,EAAA,MAAMC,OAAO,GAAGH,gBAAK,CAACI,UAAN,CAAiBL,WAAjB,CAAhB,CAAA;;EAEA,IAAI,CAACI,OAAL,EAAc;IACZ,MAAM,IAAIE,KAAJ,CAAN,uDAAA,CAAA,CAAA;AACD,GAAA;;AAED,EAAA,OAAOF,OAAP,CAAA;AACD;;;;;"}
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,gBAAK,CAACC,aAAN,CAGjB,IAHiB,EAApB;AAKA,SAASC,cAAT,GAA0B;AAC/B,EAAA,MAAMC,OAAO,GAAGH,gBAAK,CAACI,UAAN,CAAiBL,WAAjB,CAAhB,CAAA;;EAEA,IAAI,CAACI,OAAL,EAAc;IACZ,MAAM,IAAIE,KAAJ,CAAN,uDAAA,CAAA,CAAA;AACD,GAAA;;AAED,EAAA,OAAOF,OAAP,CAAA;AACD;;;;;"}
@@ -14,7 +14,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
14
14
 
15
15
  var formCore = require('@tanstack/form-core');
16
16
  var useForm = require('./useForm.js');
17
- var Field = require('./Field.js');
18
17
  var useField = require('./useField.js');
19
18
  var createFormFactory = require('./createFormFactory.js');
20
19
 
@@ -33,7 +32,7 @@ Object.defineProperty(exports, 'functionalUpdate', {
33
32
  get: function () { return formCore.functionalUpdate; }
34
33
  });
35
34
  exports.useForm = useForm.useForm;
36
- exports.Field = Field.Field;
35
+ exports.Field = useField.Field;
37
36
  exports.useField = useField.useField;
38
37
  exports.createFormFactory = createFormFactory.createFormFactory;
39
38
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -37,27 +37,62 @@ function _interopNamespace(e) {
37
37
 
38
38
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
39
39
 
40
- function createUseField() {
41
- return opts => {
42
- return useField(opts);
43
- };
44
- }
45
40
  function useField(opts) {
46
41
  // Get the form API either manually or from context
47
- const formApi = formContext.useFormContext();
48
- const [fieldApi] = React__namespace.useState(() => new formCore.FieldApi({ ...opts,
49
- form: formApi
50
- })); // Keep options up to date as they are rendered
42
+ const {
43
+ formApi,
44
+ parentFieldName
45
+ } = formContext.useFormContext();
46
+ const [fieldApi] = React__namespace.useState(() => {
47
+ 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({ ...opts,
49
+ form: formApi,
50
+ name: name
51
+ });
52
+ api.Field = Field;
53
+ return api;
54
+ }); // Keep options up to date as they are rendered
51
55
 
52
56
  fieldApi.update({ ...opts,
53
57
  form: formApi
54
58
  });
55
- reactStore.useStore(fieldApi.store); // Instantiates field meta and removes it when unrendered
59
+ reactStore.useStore(fieldApi.store, opts.mode === 'array' ? state => {
60
+ return [state.meta, Object.keys(state.value || []).length];
61
+ } : undefined); // Instantiates field meta and removes it when unrendered
56
62
 
57
63
  React__namespace.useEffect(() => fieldApi.mount(), [fieldApi]);
58
64
  return fieldApi;
65
+ } // export type FieldValue<TFormData, TField> = TFormData extends any[]
66
+ // ? TField extends `[${infer TIndex extends number | 'i'}].${infer TRest}`
67
+ // ? DeepValue<TFormData[TIndex extends 'i' ? number : TIndex], TRest>
68
+ // : TField extends `[${infer TIndex extends number | 'i'}]`
69
+ // ? TFormData[TIndex extends 'i' ? number : TIndex]
70
+ // : never
71
+ // : TField extends `${infer TPrefix}[${infer TIndex extends
72
+ // | number
73
+ // | 'i'}].${infer TRest}`
74
+ // ? DeepValue<
75
+ // DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex],
76
+ // TRest
77
+ // >
78
+ // : TField extends `${infer TPrefix}[${infer TIndex extends number | 'i'}]`
79
+ // ? DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex]
80
+ // : DeepValue<TFormData, TField>
81
+
82
+ function Field({
83
+ children,
84
+ ...fieldOptions
85
+ }) {
86
+ const fieldApi = useField(fieldOptions);
87
+ return /*#__PURE__*/React__namespace.createElement(formContext.formContext.Provider, {
88
+ value: {
89
+ formApi: fieldApi.form,
90
+ parentFieldName: fieldApi.name
91
+ },
92
+ children: formCore.functionalUpdate(children, fieldApi)
93
+ });
59
94
  }
60
95
 
61
- exports.createUseField = createUseField;
96
+ exports.Field = Field;
62
97
  exports.useField = useField;
63
98
  //# sourceMappingURL=useField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useField.js","sources":["../../src/useField.ts"],"sourcesContent":["import * as React from 'react'\n//\nimport { useStore } from '@tanstack/react-store'\nimport type { DeepKeys, DeepValue, FieldOptions } from '@tanstack/form-core'\nimport { FieldApi } from '@tanstack/form-core'\nimport { useFormContext } from './formContext'\nimport type { FormFactory } from './createFormFactory'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldOptions<TData, TFormData> {\n formFactory?: FormFactory<TFormData>\n }\n}\n\nexport type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(\n opts?: { name: TField } & FieldOptions<\n DeepValue<TFormData, TField>,\n TFormData\n >,\n) => FieldApi<DeepValue<TFormData, TField>, TFormData>\n\nexport function createUseField<TFormData>(): UseField<TFormData> {\n return (opts) => {\n return useField(opts as any)\n }\n}\n\nexport function useField<TData, TFormData>(\n opts: FieldOptions<TData, TFormData> & {\n // selector: (state: FieldApi<TData, TFormData>) => TSelected\n },\n): FieldApi<TData, TFormData> {\n // Get the form API either manually or from context\n const formApi = useFormContext()\n\n const [fieldApi] = React.useState<FieldApi<TData, TFormData>>(\n () => new FieldApi({ ...opts, form: formApi }),\n )\n\n // Keep options up to date as they are rendered\n fieldApi.update({ ...opts, form: formApi })\n\n useStore(fieldApi.store)\n\n // Instantiates field meta and removes it when unrendered\n React.useEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi\n}\n"],"names":["createUseField","opts","useField","formApi","useFormContext","fieldApi","React","useState","FieldApi","form","update","useStore","store","useEffect","mount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,SAASA,cAAT,GAA0D;AAC/D,EAAA,OAAQC,IAAD,IAAU;IACf,OAAOC,QAAQ,CAACD,IAAD,CAAf,CAAA;GADF,CAAA;AAGD,CAAA;AAEM,SAASC,QAAT,CACLD,IADK,EAIuB;AAC5B;EACA,MAAME,OAAO,GAAGC,0BAAc,EAA9B,CAAA;AAEA,EAAA,MAAM,CAACC,QAAD,CAAaC,GAAAA,gBAAK,CAACC,QAAN,CACjB,MAAM,IAAIC,iBAAJ,CAAa,EAAE,GAAGP,IAAL;AAAWQ,IAAAA,IAAI,EAAEN,OAAAA;GAA9B,CADW,CAAnB,CAJ4B;;AAS5BE,EAAAA,QAAQ,CAACK,MAAT,CAAgB,EAAE,GAAGT,IAAL;AAAWQ,IAAAA,IAAI,EAAEN,OAAAA;GAAjC,CAAA,CAAA;AAEAQ,EAAAA,mBAAQ,CAACN,QAAQ,CAACO,KAAV,CAAR,CAX4B;;EAc5BN,gBAAK,CAACO,SAAN,CAAgB,MAAMR,QAAQ,CAACS,KAAT,EAAtB,EAAwC,CAACT,QAAD,CAAxC,CAAA,CAAA;AAEA,EAAA,OAAOA,QAAP,CAAA;AACD;;;;;"}
1
+ {"version":3,"file":"useField.js","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 })\n\n useStore(\n fieldApi.store,\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 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","formContext","functionalUpdate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCO,SAASA,QAAT,CACLC,IADK,EAEuB;AAC5B;EACA,MAAM;IAAEC,OAAF;AAAWC,IAAAA,eAAAA;AAA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D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoCO,SAASY,KAAT,CAAiC;EACtCa,QADsC;EAEtC,GAAGC,YAAAA;AAFmC,CAAjC,EAKgC;AACrC,EAAA,MAAM1B,QAAQ,GAAGL,QAAQ,CAAC+B,YAAD,CAAzB,CAAA;EACA,oBACEzB,gBAAA,CAAA,aAAA,CAAC0B,uBAAD,CAAa,QAAb,EAAA;AACE,IAAA,KAAK,EAAE;MAAE9B,OAAO,EAAEG,QAAQ,CAACW,IAApB;MAA0Bb,eAAe,EAAEE,QAAQ,CAACG,IAAAA;KAD7D;AAEE,IAAA,QAAQ,EAAEyB,yBAAgB,CAACH,QAAD,EAAWzB,QAAX,CAAA;GAH9B,CAAA,CAAA;AAMD;;;;;"}
@@ -16,7 +16,6 @@ var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js
16
16
  var formCore = require('@tanstack/form-core');
17
17
  var reactStore = require('@tanstack/react-store');
18
18
  var React = require('react');
19
- var Field = require('./Field.js');
20
19
  var useField = require('./useField.js');
21
20
  var formContext = require('./formContext.js');
22
21
 
@@ -29,8 +28,8 @@ function useForm(opts) {
29
28
  // @ts-ignore
30
29
  const api = new formCore.FormApi(opts);
31
30
  api.Form = createFormComponent(api);
32
- api.Field = Field.createFieldComponent();
33
- api.useField = useField.createUseField();
31
+ api.Field = useField.Field;
32
+ api.useField = useField.useField;
34
33
 
35
34
  api.useStore = ( // @ts-ignore
36
35
  selector) => {
@@ -46,6 +45,7 @@ function useForm(opts) {
46
45
 
47
46
  return api;
48
47
  });
48
+ formApi.update(opts);
49
49
  return formApi;
50
50
  }
51
51
 
@@ -57,7 +57,9 @@ function createFormComponent(formApi) {
57
57
  }) => {
58
58
  const isSubmitting = formApi.useStore(state => state.isSubmitting);
59
59
  return /*#__PURE__*/React__default["default"].createElement(formContext.formContext.Provider, {
60
- value: formApi
60
+ value: {
61
+ formApi
62
+ }
61
63
  }, noFormElement ? children : /*#__PURE__*/React__default["default"].createElement("form", _rollupPluginBabelHelpers["extends"]({
62
64
  onSubmit: formApi.handleSubmit,
63
65
  disabled: isSubmitting
@@ -1 +1 @@
1
- {"version":3,"file":"useForm.js","sources":["../../src/useForm.tsx"],"sourcesContent":["import type { FormState, FormOptions } from '@tanstack/form-core'\nimport { FormApi, functionalUpdate } from '@tanstack/form-core'\nimport type { NoInfer } from '@tanstack/react-store'\nimport { useStore } from '@tanstack/react-store'\nimport React from 'react'\nimport { createFieldComponent, type FieldComponent } from './Field'\nimport { createUseField, type UseField } from './useField'\nimport { formContext } from './formContext'\n\ndeclare module '@tanstack/form-core' {\n interface Register {\n FormSubmitEvent: React.FormEvent<HTMLFormElement>\n }\n\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Form: FormComponent\n Field: FieldComponent<TFormData>\n useField: UseField<TFormData>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => TSelected\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n children:\n | ((state: NoInfer<TSelected>) => React.ReactNode)\n | React.ReactNode\n }) => any\n }\n}\n\nexport function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {\n const [formApi] = React.useState(() => {\n // @ts-ignore\n const api = new FormApi<TData>(opts)\n\n api.Form = createFormComponent(api)\n api.Field = createFieldComponent<TData>()\n api.useField = createUseField<TData>()\n api.useStore = (\n // @ts-ignore\n selector,\n ) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useStore(api.store, selector as any) as any\n }\n api.Subscribe = (\n // @ts-ignore\n props,\n ) => {\n return functionalUpdate(\n props.children,\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useStore(api.store, props.selector as any),\n ) as any\n }\n\n return api\n })\n\n return formApi as any\n}\n\nexport type FormProps = React.HTMLProps<HTMLFormElement> & {\n children: React.ReactNode\n noFormElement?: boolean\n}\n\nexport type FormComponent = (props: FormProps) => any\n\nfunction createFormComponent(formApi: FormApi<any>) {\n const Form: FormComponent = ({ children, noFormElement, ...rest }) => {\n const isSubmitting = formApi.useStore((state) => state.isSubmitting)\n\n return (\n <formContext.Provider value={formApi}>\n {noFormElement ? (\n children\n ) : (\n <form\n onSubmit={formApi.handleSubmit}\n disabled={isSubmitting}\n {...rest}\n >\n {children}\n </form>\n )}\n </formContext.Provider>\n )\n }\n\n return Form\n}\n"],"names":["useForm","opts","formApi","React","useState","api","FormApi","Form","createFormComponent","Field","createFieldComponent","useField","createUseField","useStore","selector","store","Subscribe","props","functionalUpdate","children","noFormElement","rest","isSubmitting","state","formContext","_extends","handleSubmit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+BO,SAASA,OAAT,CAAwBC,IAAxB,EAAmE;AACxE,EAAA,MAAM,CAACC,OAAD,CAAA,GAAYC,yBAAK,CAACC,QAAN,CAAe,MAAM;AACrC;AACA,IAAA,MAAMC,GAAG,GAAG,IAAIC,gBAAJ,CAAmBL,IAAnB,CAAZ,CAAA;AAEAI,IAAAA,GAAG,CAACE,IAAJ,GAAWC,mBAAmB,CAACH,GAAD,CAA9B,CAAA;AACAA,IAAAA,GAAG,CAACI,KAAJ,GAAYC,0BAAoB,EAAhC,CAAA;AACAL,IAAAA,GAAG,CAACM,QAAJ,GAAeC,uBAAc,EAA7B,CAAA;;IACAP,GAAG,CAACQ,QAAJ,GAAe;AAEbC,IAAAA,QAFa,KAGV;AACH;AACA,MAAA,OAAOD,mBAAQ,CAACR,GAAG,CAACU,KAAL,EAAYD,QAAZ,CAAf,CAAA;KALF,CAAA;;IAOAT,GAAG,CAACW,SAAJ,GAAgB;AAEdC,IAAAA,KAFc,KAGX;AACH,MAAA,OAAOC,yBAAgB,CACrBD,KAAK,CAACE,QADe;MAGrBN,mBAAQ,CAACR,GAAG,CAACU,KAAL,EAAYE,KAAK,CAACH,QAAlB,CAHa,CAAvB,CAAA;KAJF,CAAA;;AAWA,IAAA,OAAOT,GAAP,CAAA;AACD,GA1BiB,CAAlB,CAAA;AA4BA,EAAA,OAAOH,OAAP,CAAA;AACD,CAAA;;AASD,SAASM,mBAAT,CAA6BN,OAA7B,EAAoD;EAClD,MAAMK,IAAmB,GAAG,CAAC;IAAEY,QAAF;IAAYC,aAAZ;IAA2B,GAAGC,IAAAA;AAA9B,GAAD,KAA0C;IACpE,MAAMC,YAAY,GAAGpB,OAAO,CAACW,QAAR,CAAkBU,KAAD,IAAWA,KAAK,CAACD,YAAlC,CAArB,CAAA;IAEA,oBACEnB,yBAAA,CAAA,aAAA,CAACqB,uBAAD,CAAa,QAAb,EAAA;AAAsB,MAAA,KAAK,EAAEtB,OAAAA;KAC1BkB,EAAAA,aAAa,GACZD,QADY,gBAGZhB,yBAAA,CAAA,aAAA,CAAA,MAAA,EAAAsB,oCAAA,CAAA;MACE,QAAQ,EAAEvB,OAAO,CAACwB,YADpB;AAEE,MAAA,QAAQ,EAAEJ,YAAAA;AAFZ,KAAA,EAGMD,IAHN,CAAA,EAKGF,QALH,CAJJ,CADF,CAAA;GAHF,CAAA;;AAoBA,EAAA,OAAOZ,IAAP,CAAA;AACD;;;;"}
1
+ {"version":3,"file":"useForm.js","sources":["../../src/useForm.tsx"],"sourcesContent":["import type { FormState, FormOptions } from '@tanstack/form-core'\nimport { FormApi, functionalUpdate } from '@tanstack/form-core'\nimport type { NoInfer } from '@tanstack/react-store'\nimport { useStore } from '@tanstack/react-store'\nimport React from 'react'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { formContext } from './formContext'\n\ndeclare module '@tanstack/form-core' {\n interface Register {\n FormSubmitEvent: React.FormEvent<HTMLFormElement>\n }\n\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Form: FormComponent\n Field: FieldComponent<TFormData, TFormData>\n useField: UseField<TFormData>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => TSelected\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n children:\n | ((state: NoInfer<TSelected>) => React.ReactNode)\n | React.ReactNode\n }) => any\n }\n}\n\nexport function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {\n const [formApi] = React.useState(() => {\n // @ts-ignore\n const api = new FormApi<TData>(opts)\n\n api.Form = createFormComponent(api)\n api.Field = Field as any\n api.useField = useField as any\n api.useStore = (\n // @ts-ignore\n selector,\n ) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useStore(api.store, selector as any) as any\n }\n api.Subscribe = (\n // @ts-ignore\n props,\n ) => {\n return functionalUpdate(\n props.children,\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useStore(api.store, props.selector as any),\n ) as any\n }\n\n return api\n })\n\n formApi.update(opts)\n\n return formApi as any\n}\n\nexport type FormProps = React.HTMLProps<HTMLFormElement> & {\n children: React.ReactNode\n noFormElement?: boolean\n}\n\nexport type FormComponent = (props: FormProps) => any\n\nfunction createFormComponent(formApi: FormApi<any>) {\n const Form: FormComponent = ({ children, noFormElement, ...rest }) => {\n const isSubmitting = formApi.useStore((state) => state.isSubmitting)\n\n return (\n <formContext.Provider value={{ formApi }}>\n {noFormElement ? (\n children\n ) : (\n <form\n onSubmit={formApi.handleSubmit}\n disabled={isSubmitting}\n {...rest}\n >\n {children}\n </form>\n )}\n </formContext.Provider>\n )\n }\n\n return Form\n}\n"],"names":["useForm","opts","formApi","React","useState","api","FormApi","Form","createFormComponent","Field","useField","useStore","selector","store","Subscribe","props","functionalUpdate","children","update","noFormElement","rest","isSubmitting","state","formContext","_extends","handleSubmit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BO,SAASA,OAAT,CAAwBC,IAAxB,EAAmE;AACxE,EAAA,MAAM,CAACC,OAAD,CAAA,GAAYC,yBAAK,CAACC,QAAN,CAAe,MAAM;AACrC;AACA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AAEtB,OAAO,CAACuB,YADpB;AAEE,MAAA,QAAQ,EAAEJ,YAAAA;AAFZ,KAAA,EAGMD,IAHN,CAAA,EAKGH,QALH,CAJJ,CADF,CAAA;GAHF,CAAA;;AAoBA,EAAA,OAAOV,IAAP,CAAA;AACD;;;;"}
@@ -42,38 +42,60 @@ function useFormContext() {
42
42
  return formApi;
43
43
  }
44
44
 
45
- function createUseField() {
46
- return opts => {
47
- return useField(opts);
48
- };
49
- }
50
45
  function useField(opts) {
51
46
  // Get the form API either manually or from context
52
- const formApi = useFormContext();
53
- const [fieldApi] = React.useState(() => new FieldApi({ ...opts,
54
- form: formApi
55
- })); // Keep options up to date as they are rendered
47
+ const {
48
+ formApi,
49
+ parentFieldName
50
+ } = useFormContext();
51
+ const [fieldApi] = React.useState(() => {
52
+ const name = (typeof opts.index === 'number' ? [parentFieldName, opts.index, opts.name] : [parentFieldName, opts.name]).filter(d => d !== undefined).join('.');
53
+ const api = new FieldApi({ ...opts,
54
+ form: formApi,
55
+ name: name
56
+ });
57
+ api.Field = Field;
58
+ return api;
59
+ }); // Keep options up to date as they are rendered
56
60
 
57
61
  fieldApi.update({ ...opts,
58
62
  form: formApi
59
63
  });
60
- useStore(fieldApi.store); // Instantiates field meta and removes it when unrendered
64
+ useStore(fieldApi.store, opts.mode === 'array' ? state => {
65
+ return [state.meta, Object.keys(state.value || []).length];
66
+ } : undefined); // Instantiates field meta and removes it when unrendered
61
67
 
62
68
  React.useEffect(() => fieldApi.mount(), [fieldApi]);
63
69
  return fieldApi;
64
- }
70
+ } // export type FieldValue<TFormData, TField> = TFormData extends any[]
71
+ // ? TField extends `[${infer TIndex extends number | 'i'}].${infer TRest}`
72
+ // ? DeepValue<TFormData[TIndex extends 'i' ? number : TIndex], TRest>
73
+ // : TField extends `[${infer TIndex extends number | 'i'}]`
74
+ // ? TFormData[TIndex extends 'i' ? number : TIndex]
75
+ // : never
76
+ // : TField extends `${infer TPrefix}[${infer TIndex extends
77
+ // | number
78
+ // | 'i'}].${infer TRest}`
79
+ // ? DeepValue<
80
+ // DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex],
81
+ // TRest
82
+ // >
83
+ // : TField extends `${infer TPrefix}[${infer TIndex extends number | 'i'}]`
84
+ // ? DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex]
85
+ // : DeepValue<TFormData, TField>
65
86
 
66
- function createFieldComponent() {
67
- const ConnectedField = props => /*#__PURE__*/React.createElement(Field, props);
68
-
69
- return ConnectedField;
70
- }
71
87
  function Field({
72
88
  children,
73
89
  ...fieldOptions
74
90
  }) {
75
91
  const fieldApi = useField(fieldOptions);
76
- return functionalUpdate(children, fieldApi);
92
+ return /*#__PURE__*/React.createElement(formContext.Provider, {
93
+ value: {
94
+ formApi: fieldApi.form,
95
+ parentFieldName: fieldApi.name
96
+ },
97
+ children: functionalUpdate(children, fieldApi)
98
+ });
77
99
  }
78
100
 
79
101
  function useForm(opts) {
@@ -81,8 +103,8 @@ function useForm(opts) {
81
103
  // @ts-ignore
82
104
  const api = new FormApi(opts);
83
105
  api.Form = createFormComponent(api);
84
- api.Field = createFieldComponent();
85
- api.useField = createUseField();
106
+ api.Field = Field;
107
+ api.useField = useField;
86
108
 
87
109
  api.useStore = ( // @ts-ignore
88
110
  selector) => {
@@ -98,6 +120,7 @@ function useForm(opts) {
98
120
 
99
121
  return api;
100
122
  });
123
+ formApi.update(opts);
101
124
  return formApi;
102
125
  }
103
126
 
@@ -109,7 +132,9 @@ function createFormComponent(formApi) {
109
132
  }) => {
110
133
  const isSubmitting = formApi.useStore(state => state.isSubmitting);
111
134
  return /*#__PURE__*/React__default.createElement(formContext.Provider, {
112
- value: formApi
135
+ value: {
136
+ formApi
137
+ }
113
138
  }, noFormElement ? children : /*#__PURE__*/React__default.createElement("form", _extends({
114
139
  onSubmit: formApi.handleSubmit,
115
140
  disabled: isSubmitting
@@ -126,8 +151,8 @@ function createFormFactory(defaultOpts) {
126
151
  ...opts
127
152
  });
128
153
  },
129
- useField: createUseField(),
130
- Field: createFieldComponent()
154
+ useField: useField,
155
+ Field: Field
131
156
  };
132
157
  }
133
158
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/formContext.ts","../../src/useField.ts","../../src/Field.tsx","../../src/useForm.tsx","../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi } from '@tanstack/form-core'\nimport * as React from 'react'\n\nexport const formContext = React.createContext<FormApi<any> | 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","import * as React from 'react'\n//\nimport { useStore } from '@tanstack/react-store'\nimport type { DeepKeys, DeepValue, FieldOptions } from '@tanstack/form-core'\nimport { FieldApi } from '@tanstack/form-core'\nimport { useFormContext } from './formContext'\nimport type { FormFactory } from './createFormFactory'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldOptions<TData, TFormData> {\n formFactory?: FormFactory<TFormData>\n }\n}\n\nexport type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(\n opts?: { name: TField } & FieldOptions<\n DeepValue<TFormData, TField>,\n TFormData\n >,\n) => FieldApi<DeepValue<TFormData, TField>, TFormData>\n\nexport function createUseField<TFormData>(): UseField<TFormData> {\n return (opts) => {\n return useField(opts as any)\n }\n}\n\nexport function useField<TData, TFormData>(\n opts: FieldOptions<TData, TFormData> & {\n // selector: (state: FieldApi<TData, TFormData>) => TSelected\n },\n): FieldApi<TData, TFormData> {\n // Get the form API either manually or from context\n const formApi = useFormContext()\n\n const [fieldApi] = React.useState<FieldApi<TData, TFormData>>(\n () => new FieldApi({ ...opts, form: formApi }),\n )\n\n // Keep options up to date as they are rendered\n fieldApi.update({ ...opts, form: formApi })\n\n useStore(fieldApi.store)\n\n // Instantiates field meta and removes it when unrendered\n React.useEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi\n}\n","import * as React from 'react'\nimport {\n functionalUpdate,\n type DeepKeys,\n type DeepValue,\n type FieldApi,\n type FieldOptions,\n} from '@tanstack/form-core'\nimport { useField } from './useField'\n\n//\n\nexport type FieldComponent<TFormData> = <TField extends DeepKeys<TFormData>>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<DeepValue<TFormData, TField>, TFormData>) => any\n name: TField\n} & Omit<FieldOptions<DeepValue<TFormData, TField>, TFormData>, 'name'>) => any\n\nexport function createFieldComponent<TFormData>() {\n const ConnectedField: FieldComponent<TFormData> = (props) => (\n <Field {...(props as any)} />\n )\n return ConnectedField\n}\n\nexport function Field<TData, TFormData>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TData, TFormData>) => any\n} & FieldOptions<TData, TFormData>) {\n const fieldApi = useField(fieldOptions as any)\n return functionalUpdate(children, fieldApi as any)\n}\n","import type { FormState, FormOptions } from '@tanstack/form-core'\nimport { FormApi, functionalUpdate } from '@tanstack/form-core'\nimport type { NoInfer } from '@tanstack/react-store'\nimport { useStore } from '@tanstack/react-store'\nimport React from 'react'\nimport { createFieldComponent, type FieldComponent } from './Field'\nimport { createUseField, type UseField } from './useField'\nimport { formContext } from './formContext'\n\ndeclare module '@tanstack/form-core' {\n interface Register {\n FormSubmitEvent: React.FormEvent<HTMLFormElement>\n }\n\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Form: FormComponent\n Field: FieldComponent<TFormData>\n useField: UseField<TFormData>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => TSelected\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n children:\n | ((state: NoInfer<TSelected>) => React.ReactNode)\n | React.ReactNode\n }) => any\n }\n}\n\nexport function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {\n const [formApi] = React.useState(() => {\n // @ts-ignore\n const api = new FormApi<TData>(opts)\n\n api.Form = createFormComponent(api)\n api.Field = createFieldComponent<TData>()\n api.useField = createUseField<TData>()\n api.useStore = (\n // @ts-ignore\n selector,\n ) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useStore(api.store, selector as any) as any\n }\n api.Subscribe = (\n // @ts-ignore\n props,\n ) => {\n return functionalUpdate(\n props.children,\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useStore(api.store, props.selector as any),\n ) as any\n }\n\n return api\n })\n\n return formApi as any\n}\n\nexport type FormProps = React.HTMLProps<HTMLFormElement> & {\n children: React.ReactNode\n noFormElement?: boolean\n}\n\nexport type FormComponent = (props: FormProps) => any\n\nfunction createFormComponent(formApi: FormApi<any>) {\n const Form: FormComponent = ({ children, noFormElement, ...rest }) => {\n const isSubmitting = formApi.useStore((state) => state.isSubmitting)\n\n return (\n <formContext.Provider value={formApi}>\n {noFormElement ? (\n children\n ) : (\n <form\n onSubmit={formApi.handleSubmit}\n disabled={isSubmitting}\n {...rest}\n >\n {children}\n </form>\n )}\n </formContext.Provider>\n )\n }\n\n return Form\n}\n","import type { FormApi, FormOptions } from '@tanstack/form-core'\nimport { createUseField, type UseField } from './useField'\nimport { useForm } from './useForm'\nimport { createFieldComponent, type FieldComponent } from './Field'\n\nexport type FormFactory<TFormData> = {\n useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>\n useField: UseField<TFormData>\n Field: FieldComponent<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: createUseField<TFormData>(),\n Field: createFieldComponent<TFormData>(),\n }\n}\n"],"names":["formContext","React","createContext","useFormContext","formApi","useContext","Error","createUseField","opts","useField","fieldApi","useState","FieldApi","form","update","useStore","store","useEffect","mount","createFieldComponent","ConnectedField","props","Field","children","fieldOptions","functionalUpdate","useForm","api","FormApi","Form","createFormComponent","selector","Subscrib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;IAA2B,GAAGC,IAAAA;AAA9B,GAAD,KAA0C;IACpE,MAAMC,YAAY,GAAG/B,OAAO,CAACW,QAAR,CAAkBqB,KAAD,IAAWA,KAAK,CAACD,YAAlC,CAArB,CAAA;IAEA,oBACElC,cAAA,CAAA,aAAA,CAAC,WAAD,CAAa,QAAb,EAAA;AAAsB,MAAA,KAAK,EAAEG,OAAAA;KAC1B6B,EAAAA,aAAa,GACZV,QADY,gBAGZtB,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,QAAA,CAAA;MACE,QAAQ,EAAEG,OAAO,CAACiC,YADpB;AAEE,MAAA,QAAQ,EAAEF,YAAAA;AAFZ,KAAA,EAGMD,IAHN,CAAA,EAKGX,QALH,CAJJ,CADF,CAAA;GAHF,CAAA;;AAoBA,EAAA,OAAOM,IAAP,CAAA;AACD;;ACjFM,SAASS,iBAAT,CACLC,WADK,EAEmB;EACxB,OAAO;IACLb,OAAO,EAAGlB,IAAD,IAAU;AACjB,MAAA,OAAOkB,OAAO,CAAY,EAAE,GAAGa,WAAL;QAAkB,GAAG/B,IAAAA;AAArB,OAAZ,CAAd,CAAA;KAFG;IAILC,QAAQ,EAAEF,cAAc,EAJnB;AAKLe,IAAAA,KAAK,EAAEH,oBAAoB,EAAA;GAL7B,CAAA;AAOD;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/formContext.ts","../../src/useField.tsx","../../src/useForm.tsx","../../src/createFormFactory.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","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 })\n\n useStore(\n fieldApi.store,\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 return (\n <formContext.Provider\n value={{ formApi: fieldApi.form, parentFieldName: fieldApi.name }}\n children={functionalUpdate(children, fieldApi as any)}\n />\n )\n}\n","import type { FormState, FormOptions } from '@tanstack/form-core'\nimport { FormApi, functionalUpdate } from '@tanstack/form-core'\nimport type { NoInfer } from '@tanstack/react-store'\nimport { useStore } from '@tanstack/react-store'\nimport React from 'react'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { formContext } from './formContext'\n\ndeclare module '@tanstack/form-core' {\n interface Register {\n FormSubmitEvent: React.FormEvent<HTMLFormElement>\n }\n\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Form: FormComponent\n Field: FieldComponent<TFormData, TFormData>\n useField: UseField<TFormData>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => TSelected\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n children:\n | ((state: NoInfer<TSelected>) => React.ReactNode)\n | React.ReactNode\n }) => any\n }\n}\n\nexport function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {\n const [formApi] = React.useState(() => {\n // @ts-ignore\n const api = new FormApi<TData>(opts)\n\n api.Form = createFormComponent(api)\n api.Field = Field as any\n api.useField = useField as any\n api.useStore = (\n // @ts-ignore\n selector,\n ) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useStore(api.store, selector as any) as any\n }\n api.Subscribe = (\n // @ts-ignore\n props,\n ) => {\n return functionalUpdate(\n props.children,\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useStore(api.store, props.selector as any),\n ) as any\n }\n\n return api\n })\n\n formApi.update(opts)\n\n return formApi as any\n}\n\nexport type FormProps = React.HTMLProps<HTMLFormElement> & {\n children: React.ReactNode\n noFormElement?: boolean\n}\n\nexport type FormComponent = (props: FormProps) => any\n\nfunction createFormComponent(formApi: FormApi<any>) {\n const Form: FormComponent = ({ children, noFormElement, ...rest }) => {\n const isSubmitting = formApi.useStore((state) => state.isSubmitting)\n\n return (\n <formContext.Provider value={{ formApi }}>\n {noFormElement ? (\n children\n ) : (\n <form\n onSubmit={formApi.handleSubmit}\n disabled={isSubmitting}\n {...rest}\n >\n {children}\n </form>\n )}\n </formContext.Provider>\n )\n }\n\n return Form\n}\n","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":["formContext","React","createContext","useFormContext","formApi","useContext","Error","useField","opts","parentFieldName","fieldApi","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","functionalUpdate","useForm","FormApi","Form","createFormComponent","selector","Subscribe","props","noFormElement","rest","isSubmitting","handleSubmit","createFormFactory","defaultOpts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,WAAW,gBAAGC,KAAK,CAACC,aAAN,CAGjB,IAHiB,CAApB,CAAA;AAKA,SAASC,cAAT,GAA0B;AAC/B,EAAA,MAAMC,OAAO,GAAGH,KAAK,CAACI,UAAN,CAAiBL,WAAjB,CAAhB,CAAA;;EAEA,IAAI,CAACI,OAAL,EAAc;IACZ,MAAM,IAAIE,KAAJ,CAAN,uDAAA,CAAA,CAAA;AACD,GAAA;;AAED,EAAA,OAAOF,OAAP,CAAA;AACD;;ACiBM,SAASG,QAAT,CACLC,IADK,EAEuB;AAC5B;EACA,MAAM;IAAEJ,OAAF;AAAWK,IAAAA,eAAAA;AAAX,GAAA,GAA+BN,cAAc,EAAnD,CAAA;AAEA,EAAA,MAAM,CAACO,QAAD,CAAA,GAAaT,KAAK,CAACU,QAAN,CAA2C,MAAM;AAClE,IAAA,MAAMC,IAAI,GAAG,CACX,OAAOJ,IAAI,CAACK,KAAZ,KAAsB,QAAtB,GACI,CAACJ,eAAD,EAAkBD,IAAI,CAACK,KAAvB,EAA8BL,IAAI,CAACI,IAAnC,CADJ,GAEI,CAACH,eAAD,EAAkBD,IAAI,CAACI,IAAvB,CAHO,EAKVE,MALU,CAKFC,CAAD,I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AkBG,KAAD,IAAWA,KAAK,CAACoB,YAAlC,CAArB,CAAA;IAEA,oBACE7C,cAAA,CAAA,aAAA,CAAC,WAAD,CAAa,QAAb,EAAA;AAAsB,MAAA,KAAK,EAAE;AAAEG,QAAAA,OAAAA;AAAF,OAAA;KAC1BwC,EAAAA,aAAa,GACZV,QADY,gBAGZjC,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,QAAA,CAAA;MACE,QAAQ,EAAEG,OAAO,CAAC2C,YADpB;AAEE,MAAA,QAAQ,EAAED,YAAAA;AAFZ,KAAA,EAGMD,IAHN,CAAA,EAKGX,QALH,CAJJ,CADF,CAAA;GAHF,CAAA;;AAoBA,EAAA,OAAOK,IAAP,CAAA;AACD;;ACnFM,SAASS,iBAAT,CACLC,WADK,EAEmB;EACxB,OAAO;IACLZ,OAAO,EAAG7B,IAAD,IAAU;AACjB,MAAA,OAAO6B,OAAO,CAAY,EAAE,GAAGY,WAAL;QAAkB,GAAGzC,IAAAA;AAArB,OAAZ,CAAd,CAAA;KAFG;AAILD,IAAAA,QAAQ,EAAEA,QAJL;AAKLc,IAAAA,KAAK,EAAEA,KAAAA;GALT,CAAA;AAOD;;;;"}
@@ -2669,7 +2669,7 @@ var drawChart = (function (exports) {
2669
2669
  </script>
2670
2670
  <script>
2671
2671
  /*<!--*/
2672
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"node_modules/.pnpm","children":[{"name":"@tanstack+store@0.0.1-beta.84/node_modules/@tanstack/store/build/esm/index.js","uid":"b353-25"},{"name":"@tanstack+react-store@0.0.1-beta.84_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-store/build/esm/index.js","uid":"b353-31"}]},{"name":"packages","children":[{"name":"form-core/build/esm/index.js","uid":"b353-27"},{"name":"react-form/src","children":[{"uid":"b353-33","name":"formContext.ts"},{"uid":"b353-35","name":"useField.ts"},{"uid":"b353-37","name":"Field.tsx"},{"uid":"b353-39","name":"useForm.tsx"},{"uid":"b353-41","name":"createFormFactory.ts"},{"uid":"b353-43","name":"index.ts"}]}]},{"uid":"b353-29","name":"\u0000rollupPluginBabelHelpers.js"}]}],"isRoot":true},"nodeParts":{"b353-25":{"renderedLength":1288,"gzipLength":497,"brotliLength":0,"mainUid":"b353-24"},"b353-27":{"renderedLength":23458,"gzipLength":5139,"brotliLength":0,"mainUid":"b353-26"},"b353-29":{"renderedLength":431,"gzipLength":240,"brotliLength":0,"mainUid":"b353-28"},"b353-31":{"renderedLength":978,"gzipLength":456,"brotliLength":0,"mainUid":"b353-30"},"b353-33":{"renderedLength":296,"gzipLength":200,"brotliLength":0,"mainUid":"b353-32"},"b353-35":{"renderedLength":610,"gzipLength":324,"brotliLength":0,"mainUid":"b353-34"},"b353-37":{"renderedLength":320,"gzipLength":203,"brotliLength":0,"mainUid":"b353-36"},"b353-39":{"renderedLength":1264,"gzipLength":486,"brotliLength":0,"mainUid":"b353-38"},"b353-41":{"renderedLength":242,"gzipLength":153,"brotliLength":0,"mainUid":"b353-40"},"b353-43":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"b353-42"}},"nodeMetas":{"b353-24":{"id":"/node_modules/.pnpm/@tanstack+store@0.0.1-beta.84/node_modules/@tanstack/store/build/esm/index.js","moduleParts":{"index.production.js":"b353-25"},"imported":[],"importedBy":[{"uid":"b353-26"},{"uid":"b353-30"}]},"b353-26":{"id":"/packages/form-core/build/esm/index.js","moduleParts":{"index.production.js":"b353-27"},"imported":[{"uid":"b353-24"}],"importedBy":[{"uid":"b353-42"},{"uid":"b353-38"},{"uid":"b353-36"},{"uid":"b353-34"}]},"b353-28":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"b353-29"},"imported":[],"importedBy":[{"uid":"b353-38"}]},"b353-30":{"id":"/node_modules/.pnpm/@tanstack+react-store@0.0.1-beta.84_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-store/build/esm/index.js","moduleParts":{"index.production.js":"b353-31"},"imported":[{"uid":"b353-45"},{"uid":"b353-24"}],"importedBy":[{"uid":"b353-38"},{"uid":"b353-34"}]},"b353-32":{"id":"/packages/react-form/src/formContext.ts","moduleParts":{"index.production.js":"b353-33"},"imported":[{"uid":"b353-44"}],"importedBy":[{"uid":"b353-38"},{"uid":"b353-34"}]},"b353-34":{"id":"/packages/react-form/src/useField.ts","moduleParts":{"index.production.js":"b353-35"},"imported":[{"uid":"b353-44"},{"uid":"b353-30"},{"uid":"b353-26"},{"uid":"b353-32"}],"importedBy":[{"uid":"b353-42"},{"uid":"b353-38"},{"uid":"b353-36"},{"uid":"b353-40"}]},"b353-36":{"id":"/packages/react-form/src/Field.tsx","moduleParts":{"index.production.js":"b353-37"},"imported":[{"uid":"b353-44"},{"uid":"b353-26"},{"uid":"b353-34"}],"importedBy":[{"uid":"b353-42"},{"uid":"b353-38"},{"uid":"b353-40"}]},"b353-38":{"id":"/packages/react-form/src/useForm.tsx","moduleParts":{"index.production.js":"b353-39"},"imported":[{"uid":"b353-28"},{"uid":"b353-26"},{"uid":"b353-30"},{"uid":"b353-44"},{"uid":"b353-36"},{"uid":"b353-34"},{"uid":"b353-32"}],"importedBy":[{"uid":"b353-42"},{"uid":"b353-40"}]},"b353-40":{"id":"/packages/react-form/src/createFormFactory.ts","moduleParts":{"index.production.js":"b353-41"},"imported":[{"uid":"b353-34"},{"uid":"b353-38"},{"uid":"b353-36"}],"importedBy":[{"uid":"b353-42"}]},"b353-42":{"id":"/packages/react-form/src/index.ts","moduleParts":{"index.production.js":"b353-43"},"imported":[{"uid":"b353-26"},{"uid":"b353-38"},{"uid":"b353-36"},{"uid":"b353-34"},{"uid":"b353-40"}],"importedBy":[],"isEntry":true},"b353-44":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"b353-38"},{"uid":"b353-36"},{"uid":"b353-34"},{"uid":"b353-32"}],"isExternal":true},"b353-45":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"b353-30"}],"isExternal":true}},"env":{"rollup":"2.78.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2672
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"node_modules/.pnpm","children":[{"name":"@tanstack+store@0.0.1-beta.84/node_modules/@tanstack/store/build/esm/index.js","uid":"766a-25"},{"name":"@tanstack+react-store@0.0.1-beta.84_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-store/build/esm/index.js","uid":"766a-31"}]},{"name":"packages","children":[{"name":"form-core/build/esm/index.js","uid":"766a-27"},{"name":"react-form/src","children":[{"uid":"766a-33","name":"formContext.ts"},{"uid":"766a-35","name":"useField.tsx"},{"uid":"766a-37","name":"useForm.tsx"},{"uid":"766a-39","name":"createFormFactory.ts"},{"uid":"766a-41","name":"index.ts"}]}]},{"uid":"766a-29","name":"\u0000rollupPluginBabelHelpers.js"}]}],"isRoot":true},"nodeParts":{"766a-25":{"renderedLength":1288,"gzipLength":497,"brotliLength":0,"mainUid":"766a-24"},"766a-27":{"renderedLength":23508,"gzipLength":5149,"brotliLength":0,"mainUid":"766a-26"},"766a-29":{"renderedLength":431,"gzipLength":240,"brotliLength":0,"mainUid":"766a-28"},"766a-31":{"renderedLength":978,"gzipLength":456,"brotliLength":0,"mainUid":"766a-30"},"766a-33":{"renderedLength":296,"gzipLength":200,"brotliLength":0,"mainUid":"766a-32"},"766a-35":{"renderedLength":2096,"gzipLength":779,"brotliLength":0,"mainUid":"766a-34"},"766a-37":{"renderedLength":1287,"gzipLength":495,"brotliLength":0,"mainUid":"766a-36"},"766a-39":{"renderedLength":217,"gzipLength":138,"brotliLength":0,"mainUid":"766a-38"},"766a-41":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"766a-40"}},"nodeMetas":{"766a-24":{"id":"/node_modules/.pnpm/@tanstack+store@0.0.1-beta.84/node_modules/@tanstack/store/build/esm/index.js","moduleParts":{"index.production.js":"766a-25"},"imported":[],"importedBy":[{"uid":"766a-26"},{"uid":"766a-30"}]},"766a-26":{"id":"/packages/form-core/build/esm/index.js","moduleParts":{"index.production.js":"766a-27"},"imported":[{"uid":"766a-24"}],"importedBy":[{"uid":"766a-40"},{"uid":"766a-36"},{"uid":"766a-34"}]},"766a-28":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"766a-29"},"imported":[],"importedBy":[{"uid":"766a-36"}]},"766a-30":{"id":"/node_modules/.pnpm/@tanstack+react-store@0.0.1-beta.84_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-store/build/esm/index.js","moduleParts":{"index.production.js":"766a-31"},"imported":[{"uid":"766a-43"},{"uid":"766a-24"}],"importedBy":[{"uid":"766a-36"},{"uid":"766a-34"}]},"766a-32":{"id":"/packages/react-form/src/formContext.ts","moduleParts":{"index.production.js":"766a-33"},"imported":[{"uid":"766a-42"}],"importedBy":[{"uid":"766a-36"},{"uid":"766a-34"}]},"766a-34":{"id":"/packages/react-form/src/useField.tsx","moduleParts":{"index.production.js":"766a-35"},"imported":[{"uid":"766a-42"},{"uid":"766a-30"},{"uid":"766a-26"},{"uid":"766a-32"}],"importedBy":[{"uid":"766a-40"},{"uid":"766a-36"},{"uid":"766a-38"}]},"766a-36":{"id":"/packages/react-form/src/useForm.tsx","moduleParts":{"index.production.js":"766a-37"},"imported":[{"uid":"766a-28"},{"uid":"766a-26"},{"uid":"766a-30"},{"uid":"766a-42"},{"uid":"766a-34"},{"uid":"766a-32"}],"importedBy":[{"uid":"766a-40"},{"uid":"766a-38"}]},"766a-38":{"id":"/packages/react-form/src/createFormFactory.ts","moduleParts":{"index.production.js":"766a-39"},"imported":[{"uid":"766a-34"},{"uid":"766a-36"}],"importedBy":[{"uid":"766a-40"}]},"766a-40":{"id":"/packages/react-form/src/index.ts","moduleParts":{"index.production.js":"766a-41"},"imported":[{"uid":"766a-26"},{"uid":"766a-36"},{"uid":"766a-34"},{"uid":"766a-38"}],"importedBy":[],"isEntry":true},"766a-42":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"766a-36"},{"uid":"766a-34"},{"uid":"766a-32"}],"isExternal":true},"766a-43":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"766a-30"}],"isExternal":true}},"env":{"rollup":"2.78.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2673
2673
 
2674
2674
  const run = () => {
2675
2675
  const width = window.innerWidth;