@tanstack/react-form 0.0.10 → 0.0.12

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 (87) hide show
  1. package/build/lib/_virtual/_rollupPluginBabelHelpers.cjs +19 -0
  2. package/build/lib/_virtual/_rollupPluginBabelHelpers.cjs.map +1 -0
  3. package/build/{cjs → lib}/_virtual/_rollupPluginBabelHelpers.js +1 -17
  4. package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  5. package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.cjs +19 -0
  6. package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.cjs.map +1 -0
  7. package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.js +17 -0
  8. package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.js.map +1 -0
  9. package/build/lib/createFormFactory.cjs +20 -0
  10. package/build/lib/createFormFactory.cjs.map +1 -0
  11. package/build/{types/react-form/src → lib}/createFormFactory.d.ts +1 -0
  12. package/build/lib/createFormFactory.d.ts.map +1 -0
  13. package/build/lib/createFormFactory.js +18 -0
  14. package/build/{cjs → lib}/createFormFactory.js.map +1 -1
  15. package/build/lib/createFormFactory.legacy.cjs +20 -0
  16. package/build/lib/createFormFactory.legacy.cjs.map +1 -0
  17. package/build/lib/createFormFactory.legacy.js +18 -0
  18. package/build/lib/createFormFactory.legacy.js.map +1 -0
  19. package/build/{cjs/formContext.js → lib/formContext.cjs} +4 -19
  20. package/build/lib/formContext.cjs.map +1 -0
  21. package/build/{types/react-form/src → lib}/formContext.d.ts +1 -0
  22. package/build/lib/formContext.d.ts.map +1 -0
  23. package/build/lib/formContext.js +13 -0
  24. package/build/{cjs → lib}/formContext.js.map +1 -1
  25. package/build/lib/formContext.legacy.cjs +35 -0
  26. package/build/lib/formContext.legacy.cjs.map +1 -0
  27. package/build/lib/formContext.legacy.js +13 -0
  28. package/build/lib/formContext.legacy.js.map +1 -0
  29. package/build/{cjs/index.js → lib/index.cjs} +4 -16
  30. package/build/lib/index.cjs.map +1 -0
  31. package/build/{types/react-form/src → lib}/index.d.ts +1 -0
  32. package/build/lib/index.d.ts.map +1 -0
  33. package/build/lib/index.js +5 -0
  34. package/build/{cjs → lib}/index.js.map +1 -1
  35. package/build/lib/index.legacy.cjs +26 -0
  36. package/build/lib/index.legacy.cjs.map +1 -0
  37. package/build/lib/index.legacy.js +5 -0
  38. package/build/lib/index.legacy.js.map +1 -0
  39. package/build/lib/tests/createFormFactory.test.d.ts +2 -0
  40. package/build/lib/tests/createFormFactory.test.d.ts.map +1 -0
  41. package/build/lib/tests/useForm.test.d.ts +2 -0
  42. package/build/lib/tests/useForm.test.d.ts.map +1 -0
  43. package/build/{cjs/useField.js → lib/useField.cjs} +22 -24
  44. package/build/lib/useField.cjs.map +1 -0
  45. package/build/{types/react-form/src → lib}/useField.d.ts +1 -1
  46. package/build/lib/useField.d.ts.map +1 -0
  47. package/build/lib/useField.js +74 -0
  48. package/build/lib/useField.js.map +1 -0
  49. package/build/lib/useField.legacy.cjs +96 -0
  50. package/build/lib/useField.legacy.cjs.map +1 -0
  51. package/build/lib/useField.legacy.js +74 -0
  52. package/build/lib/useField.legacy.js.map +1 -0
  53. package/build/lib/useForm.cjs +50 -0
  54. package/build/lib/useForm.cjs.map +1 -0
  55. package/build/{types/react-form/src → lib}/useForm.d.ts +1 -0
  56. package/build/lib/useForm.d.ts.map +1 -0
  57. package/build/lib/useForm.js +48 -0
  58. package/build/lib/useForm.js.map +1 -0
  59. package/build/lib/useForm.legacy.cjs +50 -0
  60. package/build/lib/useForm.legacy.cjs.map +1 -0
  61. package/build/lib/useForm.legacy.js +48 -0
  62. package/build/lib/useForm.legacy.js.map +1 -0
  63. package/package.json +30 -12
  64. package/src/tests/createFormFactory.test.tsx +39 -0
  65. package/src/tests/useForm.test.tsx +75 -0
  66. package/src/useField.tsx +2 -2
  67. package/src/useForm.tsx +3 -2
  68. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  69. package/build/cjs/createFormFactory.js +0 -31
  70. package/build/cjs/useField.js.map +0 -1
  71. package/build/cjs/useForm.js +0 -67
  72. package/build/cjs/useForm.js.map +0 -1
  73. package/build/esm/index.js +0 -154
  74. package/build/esm/index.js.map +0 -1
  75. package/build/stats-html.html +0 -2689
  76. package/build/stats-react.json +0 -355
  77. package/build/types/form-core/src/FieldApi.d.ts +0 -79
  78. package/build/types/form-core/src/FormApi.d.ts +0 -78
  79. package/build/types/form-core/src/index.d.ts +0 -3
  80. package/build/types/form-core/src/utils.d.ts +0 -22
  81. package/build/types/index.d.ts +0 -74
  82. package/build/types/react-form/src/tests/test.test.d.ts +0 -0
  83. package/build/umd/index.development.js +0 -991
  84. package/build/umd/index.development.js.map +0 -1
  85. package/build/umd/index.production.js +0 -43
  86. package/build/umd/index.production.js.map +0 -1
  87. package/src/tests/test.test.tsx +0 -5
@@ -0,0 +1,39 @@
1
+ import { render } from '@testing-library/react'
2
+ import '@testing-library/jest-dom'
3
+ import * as React from 'react'
4
+ import { createFormFactory } from '..'
5
+
6
+ describe('createFormFactory', () => {
7
+ it('should allow default values to be set', async () => {
8
+ type Person = {
9
+ firstName: string
10
+ lastName: string
11
+ }
12
+
13
+ const formFactory = createFormFactory<Person>({
14
+ defaultValues: {
15
+ firstName: 'FirstName',
16
+ lastName: 'LastName',
17
+ },
18
+ })
19
+
20
+ function Comp() {
21
+ const form = formFactory.useForm({})
22
+
23
+ return (
24
+ <form.Provider>
25
+ <form.Field
26
+ name="firstName"
27
+ children={(field) => {
28
+ return <p>{field.getInputProps().value}</p>
29
+ }}
30
+ />
31
+ </form.Provider>
32
+ )
33
+ }
34
+
35
+ const { findByText, queryByText } = render(<Comp />)
36
+ expect(await findByText('FirstName')).toBeInTheDocument()
37
+ expect(queryByText('LastName')).not.toBeInTheDocument()
38
+ })
39
+ })
@@ -0,0 +1,75 @@
1
+ import { fireEvent, render } from '@testing-library/react'
2
+ import userEvent from '@testing-library/user-event'
3
+ import '@testing-library/jest-dom'
4
+ import * as React from 'react'
5
+ import { createFormFactory } from '..'
6
+
7
+ const user = userEvent.setup()
8
+
9
+ describe('useForm', () => {
10
+ it('preserves field state', async () => {
11
+ type Person = {
12
+ firstName: string
13
+ lastName: string
14
+ }
15
+
16
+ const formFactory = createFormFactory<Person>()
17
+
18
+ function Comp() {
19
+ const form = formFactory.useForm()
20
+
21
+ return (
22
+ <form.Provider>
23
+ <form.Field
24
+ name="firstName"
25
+ defaultValue={''}
26
+ children={(field) => {
27
+ return (
28
+ <input data-testid="fieldinput" {...field.getInputProps()} />
29
+ )
30
+ }}
31
+ />
32
+ </form.Provider>
33
+ )
34
+ }
35
+
36
+ const { getByTestId, queryByText } = render(<Comp />)
37
+ const input = getByTestId('fieldinput')
38
+ expect(queryByText('FirstName')).not.toBeInTheDocument()
39
+ await user.type(input, 'FirstName')
40
+ expect(input).toHaveValue('FirstName')
41
+ })
42
+
43
+ it('should allow default values to be set', async () => {
44
+ type Person = {
45
+ firstName: string
46
+ lastName: string
47
+ }
48
+
49
+ const formFactory = createFormFactory<Person>()
50
+
51
+ function Comp() {
52
+ const form = formFactory.useForm({
53
+ defaultValues: {
54
+ firstName: 'FirstName',
55
+ lastName: 'LastName',
56
+ },
57
+ })
58
+
59
+ return (
60
+ <form.Provider>
61
+ <form.Field
62
+ name="firstName"
63
+ children={(field) => {
64
+ return <p>{field.getInputProps().value}</p>
65
+ }}
66
+ />
67
+ </form.Provider>
68
+ )
69
+ }
70
+
71
+ const { findByText, queryByText } = render(<Comp />)
72
+ expect(await findByText('FirstName')).toBeInTheDocument()
73
+ expect(queryByText('LastName')).not.toBeInTheDocument()
74
+ })
75
+ })
package/src/useField.tsx CHANGED
@@ -54,10 +54,10 @@ export function useField<TData, TFormData>(
54
54
  })
55
55
 
56
56
  // Keep options up to date as they are rendered
57
- fieldApi.update({ ...opts, form: formApi })
57
+ fieldApi.update({ ...opts, form: formApi } as never)
58
58
 
59
59
  useStore(
60
- fieldApi.store,
60
+ fieldApi.store as any,
61
61
  opts.mode === 'array'
62
62
  ? (state: any) => {
63
63
  return [state.meta, Object.keys(state.value || []).length]
package/src/useForm.tsx CHANGED
@@ -41,6 +41,7 @@ export function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {
41
41
  // @ts-ignore
42
42
  const api = new FormApi<TData>(opts)
43
43
 
44
+ // eslint-disable-next-line react/display-name
44
45
  api.Provider = (props) => (
45
46
  <formContext.Provider {...props} value={{ formApi: api }} />
46
47
  )
@@ -57,7 +58,7 @@ export function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {
57
58
  selector,
58
59
  ) => {
59
60
  // eslint-disable-next-line react-hooks/rules-of-hooks
60
- return useStore(api.store, selector as any) as any
61
+ return useStore(api.store as any, selector as any) as any
61
62
  }
62
63
  api.Subscribe = (
63
64
  // @ts-ignore
@@ -66,7 +67,7 @@ export function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {
66
67
  return functionalUpdate(
67
68
  props.children,
68
69
  // eslint-disable-next-line react-hooks/rules-of-hooks
69
- useStore(api.store, props.selector as any),
70
+ useStore(api.store as any, props.selector as any),
70
71
  ) as any
71
72
  }
72
73
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,31 +0,0 @@
1
- /**
2
- * react-form
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- var useField = require('./useField.js');
16
- var useForm = require('./useForm.js');
17
-
18
- function createFormFactory(defaultOpts) {
19
- return {
20
- useForm: opts => {
21
- return useForm.useForm({ ...defaultOpts,
22
- ...opts
23
- });
24
- },
25
- useField: useField.useField,
26
- Field: useField.Field
27
- };
28
- }
29
-
30
- exports.createFormFactory = createFormFactory;
31
- //# sourceMappingURL=createFormFactory.js.map
@@ -1 +0,0 @@
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\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;AAAX,GAAA,GAA+BC,0BAAc,EAAnD,CAAA;AAEA,EAAA,MAAM,CAACC,QAAD,CAAA,GAAaC,gBAAK,CAACC,QAAN,CAA2C,MAAM;AAClE,IAAA,MAAMC,IAAI,GAAG,CACX,OAAOP,IAAI,CAACQ,KAAZ,KAAsB,QAAtB,GACI,CAACN,eAAD,EAAkBF,IAAI,CAACQ,KAAvB,EAA8BR,IAAI,CAACO,IAAnC,CADJ,GAEI,CAACL,eAAD,EAAkBF,IAAI,CAACO,IAAvB,CAHO,EAKVE,MALU,CAKFC,CAAD,IAAOA,CAAC,KAAKC,SALV,EAMVC,IANU,CAML,GANK,CAAb,CAAA;AAQA,IAAA,MAAMC,GAAG,GAAG,IAAIC,iBAAJ,CAAa,EAAE,GAAGd,IAAL;AAAWe,MAAAA,IAAI,EAAEd,OAAjB;AAA0BM,MAAAA,IAAI,EAAEA,IAAAA;AAAhC,KAAb,CAAZ,CAAA;IAEAM,GAAG,CAACG,KAAJ,GAAYA,KAAZ,CAAA;AAEA,IAAA,OAAOH,GAAP,CAAA;GAbiB,CAAnB,CAJ4B;;AAqB5BT,EAAAA,QAAQ,CAACa,MAAT,CAAgB,EAAE,GAAGjB,IAAL;AAAWe,IAAAA,IAAI,EAAEd,OAAAA;GAAjC,CAAA,CAAA;AAEAiB,EAAAA,mBAAQ,CACNd,QAAQ,CAACe,KADH,EAENnB,IAAI,CAACoB,IAAL,KAAc,OAAd,GACKC,KAAD,IAAgB;AACd,IAAA,OAAO,CAACA,KAAK,CAACC,IAAP,EAAaC,MAAM,CAACC,IAAP,CAAYH,KAAK,CAACI,KAAN,IAAe,EAA3B,CAAA,CAA+BC,MAA5C,CAAP,CAAA;AACD,GAHL,GAIIf,SANE,CAAR,CAvB4B;;EAiC5BN,gBAAK,CAACsB,SAAN,CAAgB,MAAMvB,QAAQ,CAACwB,KAAT,EAAtB,EAAwC,CAACxB,QAAD,CAAxC,CAAA,CAAA;AAEA,EAAA,OAAOA,QAAP,CAAA;AACD;AAGD;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;EAEA,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;;;;;"}
@@ -1,67 +0,0 @@
1
- /**
2
- * react-form
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
16
- var formCore = require('@tanstack/form-core');
17
- var reactStore = require('@tanstack/react-store');
18
- var React = require('react');
19
- var useField = require('./useField.js');
20
- var formContext = require('./formContext.js');
21
-
22
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23
-
24
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
25
-
26
- function useForm(opts) {
27
- const [formApi] = React__default["default"].useState(() => {
28
- // @ts-ignore
29
- const api = new formCore.FormApi(opts);
30
-
31
- api.Provider = props => /*#__PURE__*/React__default["default"].createElement(formContext.formContext.Provider, _rollupPluginBabelHelpers["extends"]({}, props, {
32
- value: {
33
- formApi: api
34
- }
35
- }));
36
-
37
- api.getFormProps = () => {
38
- return {
39
- onSubmit: formApi.handleSubmit,
40
- disabled: api.state.isSubmitting
41
- };
42
- };
43
-
44
- api.Field = useField.Field;
45
- api.useField = useField.useField;
46
-
47
- api.useStore = ( // @ts-ignore
48
- selector) => {
49
- // eslint-disable-next-line react-hooks/rules-of-hooks
50
- return reactStore.useStore(api.store, selector);
51
- };
52
-
53
- api.Subscribe = ( // @ts-ignore
54
- props) => {
55
- return formCore.functionalUpdate(props.children, // eslint-disable-next-line react-hooks/rules-of-hooks
56
- reactStore.useStore(api.store, props.selector));
57
- };
58
-
59
- return api;
60
- });
61
- formApi.useStore(state => state.isSubmitting);
62
- formApi.update(opts);
63
- return formApi;
64
- }
65
-
66
- exports.useForm = useForm;
67
- //# sourceMappingURL=useForm.js.map
@@ -1 +0,0 @@
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\nexport type FormSubmitEvent = React.FormEvent<HTMLFormElement>\n\ndeclare module '@tanstack/form-core' {\n interface Register {\n FormSubmitEvent: FormSubmitEvent\n }\n\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Provider: (props: { children: any }) => any\n getFormProps: () => FormProps\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 type FormProps = {\n onSubmit: (e: FormSubmitEvent) => void\n disabled: boolean\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.Provider = (props) => (\n <formContext.Provider {...props} value={{ formApi: api }} />\n )\n api.getFormProps = () => {\n return {\n onSubmit: formApi.handleSubmit,\n disabled: api.state.isSubmitting,\n }\n }\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.useStore((state) => state.isSubmitting)\n formApi.update(opts)\n\n return formApi as any\n}\n"],"names":["useForm","opts","formApi","React","useState","api","FormApi","Provider","props","formContext","_extends","getFormProps","onSubmit","handleSubmit","disabled","state","isSubmitting","Field","useField","useStore","selector","store","Subscribe","functionalUpdate","children","update"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsCO,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;;IAEAI,GAAG,CAACE,QAAJ,GAAgBC,KAAD,iBACbL,wCAACM,uBAAD,CAAa,QAAb,EAAAC,oCAAA,CAAA,EAAA,EAA0BF,KAA1B,EAAA;AAAiC,MAAA,KAAK,EAAE;AAAEN,QAAAA,OAAO,EAAEG,GAAAA;AAAX,OAAA;KAD1C,CAAA,CAAA,CAAA;;IAGAA,GAAG,CAACM,YAAJ,GAAmB,MAAM;MACvB,OAAO;QACLC,QAAQ,EAAEV,OAAO,CAACW,YADb;AAELC,QAAAA,QAAQ,EAAET,GAAG,CAACU,KAAJ,CAAUC,YAAAA;OAFtB,CAAA;KADF,CAAA;;IAMAX,GAAG,CAACY,KAAJ,GAAYA,cAAZ,CAAA;IACAZ,GAAG,CAACa,QAAJ,GAAeA,iBAAf,CAAA;;IACAb,GAAG,CAACc,QAAJ,GAAe;AAEbC,IAAAA,QAFa,KAGV;AACH;AACA,MAAA,OAAOD,mBAAQ,CAACd,GAAG,CAACgB,KAAL,EAAYD,QAAZ,CAAf,CAAA;KALF,CAAA;;IAOAf,GAAG,CAACiB,SAAJ,GAAgB;AAEdd,IAAAA,KAFc,KAGX;AACH,MAAA,OAAOe,yBAAgB,CACrBf,KAAK,CAACgB,QADe;MAGrBL,mBAAQ,CAACd,GAAG,CAACgB,KAAL,EAAYb,KAAK,CAACY,QAAlB,CAHa,CAAvB,CAAA;KAJF,CAAA;;AAWA,IAAA,OAAOf,GAAP,CAAA;AACD,GAlCiB,CAAlB,CAAA;AAoCAH,EAAAA,OAAO,CAACiB,QAAR,CAAkBJ,KAAD,IAAWA,KAAK,CAACC,YAAlC,CAAA,CAAA;EACAd,OAAO,CAACuB,MAAR,CAAexB,IAAf,CAAA,CAAA;AAEA,EAAA,OAAOC,OAAP,CAAA;AACD;;;;"}
@@ -1,154 +0,0 @@
1
- /**
2
- * react-form
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- import { FieldApi, functionalUpdate, FormApi } from '@tanstack/form-core';
12
- export { FieldApi, FormApi, functionalUpdate } from '@tanstack/form-core';
13
- import { useStore } from '@tanstack/react-store';
14
- import * as React from 'react';
15
- import React__default from 'react';
16
-
17
- function _extends() {
18
- _extends = Object.assign ? Object.assign.bind() : function (target) {
19
- for (var i = 1; i < arguments.length; i++) {
20
- var source = arguments[i];
21
-
22
- for (var key in source) {
23
- if (Object.prototype.hasOwnProperty.call(source, key)) {
24
- target[key] = source[key];
25
- }
26
- }
27
- }
28
-
29
- return target;
30
- };
31
- return _extends.apply(this, arguments);
32
- }
33
-
34
- const formContext = /*#__PURE__*/React.createContext(null);
35
- function useFormContext() {
36
- const formApi = React.useContext(formContext);
37
-
38
- if (!formApi) {
39
- throw new Error("You are trying to use the form API outside of a form!");
40
- }
41
-
42
- return formApi;
43
- }
44
-
45
- function useField(opts) {
46
- // Get the form API either manually or from context
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
60
-
61
- fieldApi.update({ ...opts,
62
- form: formApi
63
- });
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
67
-
68
- React.useEffect(() => fieldApi.mount(), [fieldApi]);
69
- return fieldApi;
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>
86
-
87
- function Field({
88
- children,
89
- ...fieldOptions
90
- }) {
91
- const fieldApi = useField(fieldOptions);
92
- return /*#__PURE__*/React.createElement(formContext.Provider, {
93
- value: {
94
- formApi: fieldApi.form,
95
- parentFieldName: fieldApi.name
96
- },
97
- children: functionalUpdate(children, fieldApi)
98
- });
99
- }
100
-
101
- function useForm(opts) {
102
- const [formApi] = React__default.useState(() => {
103
- // @ts-ignore
104
- const api = new FormApi(opts);
105
-
106
- api.Provider = props => /*#__PURE__*/React__default.createElement(formContext.Provider, _extends({}, props, {
107
- value: {
108
- formApi: api
109
- }
110
- }));
111
-
112
- api.getFormProps = () => {
113
- return {
114
- onSubmit: formApi.handleSubmit,
115
- disabled: api.state.isSubmitting
116
- };
117
- };
118
-
119
- api.Field = Field;
120
- api.useField = useField;
121
-
122
- api.useStore = ( // @ts-ignore
123
- selector) => {
124
- // eslint-disable-next-line react-hooks/rules-of-hooks
125
- return useStore(api.store, selector);
126
- };
127
-
128
- api.Subscribe = ( // @ts-ignore
129
- props) => {
130
- return functionalUpdate(props.children, // eslint-disable-next-line react-hooks/rules-of-hooks
131
- useStore(api.store, props.selector));
132
- };
133
-
134
- return api;
135
- });
136
- formApi.useStore(state => state.isSubmitting);
137
- formApi.update(opts);
138
- return formApi;
139
- }
140
-
141
- function createFormFactory(defaultOpts) {
142
- return {
143
- useForm: opts => {
144
- return useForm({ ...defaultOpts,
145
- ...opts
146
- });
147
- },
148
- useField: useField,
149
- Field: Field
150
- };
151
- }
152
-
153
- export { Field, createFormFactory, useField, useForm };
154
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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\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\nexport type FormSubmitEvent = React.FormEvent<HTMLFormElement>\n\ndeclare module '@tanstack/form-core' {\n interface Register {\n FormSubmitEvent: FormSubmitEvent\n }\n\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Provider: (props: { children: any }) => any\n getFormProps: () => FormProps\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 type FormProps = {\n onSubmit: (e: FormSubmitEvent) => void\n disabled: boolean\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.Provider = (props) => (\n <formContext.Provider {...props} value={{ formApi: api }} />\n )\n api.getFormProps = () => {\n return {\n onSubmit: formApi.handleSubmit,\n disabled: api.state.isSubmitting,\n }\n }\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.useStore((state) => state.isSubmitting)\n formApi.update(opts)\n\n return formApi as any\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","Provider","props","getFormProps","onSubmit","handleSubmit","disabled","isSubmitting","selector","Subscribe","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,CAAC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