@tanstack/react-form 0.0.5 → 0.0.6

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/Field.js +2 -5
  2. package/build/cjs/Field.js.map +1 -1
  3. package/build/cjs/createFormFactory.js +32 -0
  4. package/build/cjs/createFormFactory.js.map +1 -0
  5. package/build/cjs/formContext.js +1 -5
  6. package/build/cjs/formContext.js.map +1 -1
  7. package/build/cjs/index.js +14 -9
  8. package/build/cjs/index.js.map +1 -1
  9. package/build/cjs/useField.js +4 -12
  10. package/build/cjs/useField.js.map +1 -1
  11. package/build/cjs/useForm.js +6 -31
  12. package/build/cjs/useForm.js.map +1 -1
  13. package/build/esm/index.js +24 -50
  14. package/build/esm/index.js.map +1 -1
  15. package/build/stats-html.html +1 -1
  16. package/build/stats-react.json +145 -107
  17. package/build/types/form-core/src/FieldApi.d.ts +11 -10
  18. package/build/types/form-core/src/FormApi.d.ts +12 -12
  19. package/build/types/form-core/src/utils.d.ts +10 -10
  20. package/build/types/index.d.ts +22 -10
  21. package/build/types/react-form/src/Field.d.ts +3 -3
  22. package/build/types/react-form/src/createFormFactory.d.ts +9 -0
  23. package/build/types/react-form/src/formContext.d.ts +1 -1
  24. package/build/types/react-form/src/index.d.ts +10 -4
  25. package/build/types/react-form/src/useField.d.ts +9 -3
  26. package/build/types/react-form/src/useForm.d.ts +5 -3
  27. package/build/umd/index.development.js +24 -54
  28. package/build/umd/index.development.js.map +1 -1
  29. package/build/umd/index.production.js +2 -2
  30. package/build/umd/index.production.js.map +1 -1
  31. package/package.json +2 -2
  32. package/src/Field.tsx +2 -3
  33. package/src/createFormFactory.ts +22 -0
  34. package/src/formContext.ts +1 -5
  35. package/src/index.ts +35 -4
  36. package/src/useField.ts +13 -17
  37. package/src/useForm.tsx +11 -43
@@ -12,7 +12,6 @@
12
12
 
13
13
  Object.defineProperty(exports, '__esModule', { value: true });
14
14
 
15
- var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
16
15
  var React = require('react');
17
16
  var formCore = require('@tanstack/form-core');
18
17
  var useField = require('./useField.js');
@@ -37,10 +36,8 @@ function _interopNamespace(e) {
37
36
 
38
37
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
39
38
 
40
- function createFieldComponent(formApi) {
41
- const ConnectedField = props => /*#__PURE__*/React__namespace.createElement(Field, _rollupPluginBabelHelpers["extends"]({}, props, {
42
- form: formApi
43
- }));
39
+ function createFieldComponent() {
40
+ const ConnectedField = props => /*#__PURE__*/React__namespace.createElement(Field, props);
44
41
 
45
42
  return ConnectedField;
46
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sources":["../../src/Field.tsx"],"sourcesContent":["import * as React from 'react'\nimport {\n functionalUpdate,\n type DeepKeys,\n type DeepValue,\n type FieldApi,\n type FieldOptions,\n type FormApi,\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>(formApi: FormApi<TFormData>) {\n const ConnectedField: FieldComponent<TFormData> = (props) => (\n <Field {...(props as any)} form={formApi} />\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"],"names":["createFieldComponent","formApi","ConnectedField","props","React","Field","children","fieldOptions","fieldApi","useField","functionalUpdate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,SAASA,oBAAT,CAAyCC,OAAzC,EAAsE;AAC3E,EAAA,MAAMC,cAAyC,GAAIC,KAAD,iBAChDC,gBAAC,CAAA,aAAA,CAAA,KAAD,2CAAYD,KAAZ,EAAA;AAA2B,IAAA,IAAI,EAAEF,OAAAA;GADnC,CAAA,CAAA,CAAA;;AAGA,EAAA,OAAOC,cAAP,CAAA;AACD,CAAA;AAEM,SAASG,KAAT,CAAiC;EACtCC,QADsC;EAEtC,GAAGC,YAAAA;AAFmC,CAAjC,EAK6B;AAClC,EAAA,MAAMC,QAAQ,GAAGC,iBAAQ,CAACF,YAAD,CAAzB,CAAA;AACA,EAAA,OAAOG,yBAAgB,CAACJ,QAAD,EAAWE,QAAX,CAAvB,CAAA;AACD;;;;;"}
1
+ {"version":3,"file":"Field.js","sources":["../../src/Field.tsx"],"sourcesContent":["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"],"names":["createFieldComponent","ConnectedField","props","React","Field","children","fieldOptions","fieldApi","useField","functionalUpdate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,SAASA,oBAAT,GAA2C;EAChD,MAAMC,cAAyC,GAAIC,KAAD,iBAChDC,+BAAC,KAAD,EAAYD,KAAZ,CADF,CAAA;;AAGA,EAAA,OAAOD,cAAP,CAAA;AACD,CAAA;AAEM,SAASG,KAAT,CAAiC;EACtCC,QADsC;EAEtC,GAAGC,YAAAA;AAFmC,CAAjC,EAK6B;AAClC,EAAA,MAAMC,QAAQ,GAAGC,iBAAQ,CAACF,YAAD,CAAzB,CAAA;AACA,EAAA,OAAOG,yBAAgB,CAACJ,QAAD,EAAWE,QAAX,CAAvB,CAAA;AACD;;;;;"}
@@ -0,0 +1,32 @@
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
+ var Field = require('./Field.js');
18
+
19
+ function createFormFactory(defaultOpts) {
20
+ return {
21
+ useForm: opts => {
22
+ return useForm.useForm({ ...defaultOpts,
23
+ ...opts
24
+ });
25
+ },
26
+ useField: useField.createUseField(),
27
+ Field: Field.createFieldComponent()
28
+ };
29
+ }
30
+
31
+ exports.createFormFactory = createFormFactory;
32
+ //# sourceMappingURL=createFormFactory.js.map
@@ -0,0 +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;;;;"}
@@ -35,13 +35,9 @@ function _interopNamespace(e) {
35
35
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
36
36
 
37
37
  const formContext = /*#__PURE__*/React__namespace.createContext(null);
38
- function useFormContext(customFormApi) {
38
+ function useFormContext() {
39
39
  const formApi = React__namespace.useContext(formContext);
40
40
 
41
- if (customFormApi) {
42
- return customFormApi;
43
- }
44
-
45
41
  if (!formApi) {
46
42
  throw new Error("You are trying to use the form API outside of a form!");
47
43
  }
@@ -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(customFormApi?: FormApi<any>) {\n const formApi = React.useContext(formContext)\n\n if (customFormApi) {\n return customFormApi\n }\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","customFormApi","formApi","useContext","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,WAAW,gBAAGC,gBAAK,CAACC,aAAN,CAAyC,IAAzC,EAApB;AAEA,SAASC,cAAT,CAAwBC,aAAxB,EAAsD;AAC3D,EAAA,MAAMC,OAAO,GAAGJ,gBAAK,CAACK,UAAN,CAAiBN,WAAjB,CAAhB,CAAA;;AAEA,EAAA,IAAII,aAAJ,EAAmB;AACjB,IAAA,OAAOA,aAAP,CAAA;AACD,GAAA;;EAED,IAAI,CAACC,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<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;;;;;"}
@@ -16,19 +16,24 @@ var formCore = require('@tanstack/form-core');
16
16
  var useForm = require('./useForm.js');
17
17
  var Field = require('./Field.js');
18
18
  var useField = require('./useField.js');
19
+ var createFormFactory = require('./createFormFactory.js');
19
20
 
20
21
 
21
22
 
22
- exports.createFormComponent = useForm.createFormComponent;
23
+ Object.defineProperty(exports, 'FieldApi', {
24
+ enumerable: true,
25
+ get: function () { return formCore.FieldApi; }
26
+ });
27
+ Object.defineProperty(exports, 'FormApi', {
28
+ enumerable: true,
29
+ get: function () { return formCore.FormApi; }
30
+ });
31
+ Object.defineProperty(exports, 'functionalUpdate', {
32
+ enumerable: true,
33
+ get: function () { return formCore.functionalUpdate; }
34
+ });
23
35
  exports.useForm = useForm.useForm;
24
36
  exports.Field = Field.Field;
25
- exports.createFieldComponent = Field.createFieldComponent;
26
- exports.createUseField = useField.createUseField;
27
37
  exports.useField = useField.useField;
28
- Object.keys(formCore).forEach(function (k) {
29
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
30
- enumerable: true,
31
- get: function () { return formCore[k]; }
32
- });
33
- });
38
+ exports.createFormFactory = createFormFactory.createFormFactory;
34
39
  //# 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,22 +37,14 @@ function _interopNamespace(e) {
37
37
 
38
38
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
39
39
 
40
- function createUseField(formApi) {
41
- const useFormField = opts => {
42
- return useField({ ...opts,
43
- form: formApi
44
- });
40
+ function createUseField() {
41
+ return opts => {
42
+ return useField(opts);
45
43
  };
46
-
47
- return useFormField;
48
44
  }
49
45
  function useField(opts) {
50
- // invariant( // TODO:
51
- // opts.name,
52
- // `useField: A field is required to use this hook. eg, useField('myField', options)`
53
- // )
54
46
  // Get the form API either manually or from context
55
- const formApi = formContext.useFormContext(opts.form);
47
+ const formApi = formContext.useFormContext();
56
48
  const [fieldApi] = React__namespace.useState(() => new formCore.FieldApi({ ...opts,
57
49
  form: formApi
58
50
  })); // Keep options up to date as they are rendered
@@ -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 {\n DeepKeys,\n DeepValue,\n FieldOptions,\n FormApi,\n} from '@tanstack/form-core'\nimport { FieldApi } from '@tanstack/form-core'\nimport { useFormContext } from './formContext'\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>(formApi: FormApi<TFormData>) {\n const useFormField: UseField<TFormData> = (opts) => {\n return useField({ ...opts, form: formApi } as any)\n }\n\n return useFormField\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 // invariant( // TODO:\n // opts.name,\n // `useField: A field is required to use this hook. eg, useField('myField', options)`\n // )\n\n // Get the form API either manually or from context\n const formApi = useFormContext(opts.form)\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","formApi","useFormField","opts","useField","form","useFormContext","fieldApi","React","useState","FieldApi","update","useStore","store","useEffect","mount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,SAASA,cAAT,CAAmCC,OAAnC,EAAgE;EACrE,MAAMC,YAAiC,GAAIC,IAAD,IAAU;AAClD,IAAA,OAAOC,QAAQ,CAAC,EAAE,GAAGD,IAAL;AAAWE,MAAAA,IAAI,EAAEJ,OAAAA;AAAjB,KAAD,CAAf,CAAA;GADF,CAAA;;AAIA,EAAA,OAAOC,YAAP,CAAA;AACD,CAAA;AAEM,SAASE,QAAT,CACLD,IADK,EAIuB;AAC5B;AACA;AACA;AACA;AAEA;AACA,EAAA,MAAMF,OAAO,GAAGK,0BAAc,CAACH,IAAI,CAACE,IAAN,CAA9B,CAAA;AAEA,EAAA,MAAM,CAACE,QAAD,CAAaC,GAAAA,gBAAK,CAACC,QAAN,CACjB,MAAM,IAAIC,iBAAJ,CAAa,EAAE,GAAGP,IAAL;AAAWE,IAAAA,IAAI,EAAEJ,OAAAA;GAA9B,CADW,CAAnB,CAT4B;;AAc5BM,EAAAA,QAAQ,CAACI,MAAT,CAAgB,EAAE,GAAGR,IAAL;AAAWE,IAAAA,IAAI,EAAEJ,OAAAA;GAAjC,CAAA,CAAA;AAEAW,EAAAA,mBAAQ,CAACL,QAAQ,CAACM,KAAV,CAAR,CAhB4B;;EAmB5BL,gBAAK,CAACM,SAAN,CAAgB,MAAMP,QAAQ,CAACQ,KAAT,EAAtB,EAAwC,CAACR,QAAD,CAAxC,CAAA,CAAA;AAEA,EAAA,OAAOA,QAAP,CAAA;AACD;;;;;"}
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;;;;;"}
@@ -24,14 +24,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
24
24
 
25
25
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
26
26
 
27
- //
28
27
  function useForm(opts) {
29
28
  const [formApi] = React__default["default"].useState(() => {
30
29
  // @ts-ignore
31
- const api = new formCore.FormApi(opts || {});
30
+ const api = new formCore.FormApi(opts);
32
31
  api.Form = createFormComponent(api);
33
- api.Field = Field.createFieldComponent(api);
34
- api.useField = useField.createUseField(api);
32
+ api.Field = Field.createFieldComponent();
33
+ api.useField = useField.createUseField();
35
34
 
36
35
  api.useStore = ( // @ts-ignore
37
36
  selector) => {
@@ -46,10 +45,10 @@ function useForm(opts) {
46
45
  };
47
46
 
48
47
  return api;
49
- }); // React.useEffect(() => formApi.mount(), [])
50
-
48
+ });
51
49
  return formApi;
52
50
  }
51
+
53
52
  function createFormComponent(formApi) {
54
53
  const Form = ({
55
54
  children,
@@ -62,35 +61,11 @@ function createFormComponent(formApi) {
62
61
  }, noFormElement ? children : /*#__PURE__*/React__default["default"].createElement("form", _rollupPluginBabelHelpers["extends"]({
63
62
  onSubmit: formApi.handleSubmit,
64
63
  disabled: isSubmitting
65
- }, rest), formApi.options.debugForm ? /*#__PURE__*/React__default["default"].createElement("div", {
66
- style: {
67
- margin: '2rem 0'
68
- }
69
- }, /*#__PURE__*/React__default["default"].createElement("div", {
70
- style: {
71
- fontWeight: 'bolder'
72
- }
73
- }, "Form State"), /*#__PURE__*/React__default["default"].createElement("pre", null, /*#__PURE__*/React__default["default"].createElement("code", null, JSON.stringify(formApi, safeStringifyReplace(), 2)))) : null, children));
64
+ }, rest), children));
74
65
  };
75
66
 
76
67
  return Form;
77
68
  }
78
69
 
79
- function safeStringifyReplace() {
80
- const set = new Set();
81
- return (_key, value) => {
82
- if (typeof value === 'object' || Array.isArray(value)) {
83
- if (set.has(value)) {
84
- return '(circular value)';
85
- }
86
-
87
- set.add(value);
88
- }
89
-
90
- return typeof value === 'function' ? undefined : value;
91
- };
92
- }
93
-
94
- exports.createFormComponent = createFormComponent;
95
70
  exports.useForm = useForm;
96
71
  //# sourceMappingURL=useForm.js.map
@@ -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 // 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//\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(api)\n api.useField = createUseField(api)\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\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),\n ) as any\n }\n\n return api\n })\n\n // React.useEffect(() => formApi.mount(), [])\n\n return formApi\n}\n\nexport type FormProps = React.HTMLProps<HTMLFormElement> & {\n children: React.ReactNode\n noFormElement?: boolean\n}\n\nexport type FormComponent = (props: FormProps) => any\n\nexport function 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 {formApi.options.debugForm ? (\n <div\n style={{\n margin: '2rem 0',\n }}\n >\n <div\n style={{\n fontWeight: 'bolder',\n }}\n >\n Form State\n </div>\n <pre>\n <code>\n {JSON.stringify(formApi, safeStringifyReplace(), 2)}\n </code>\n </pre>\n </div>\n ) : null}\n {children}\n </form>\n )}\n </formContext.Provider>\n )\n }\n\n return Form\n}\n\nfunction safeStringifyReplace() {\n const set = new Set()\n return (_key: string, value: any) => {\n if (typeof value === 'object' || Array.isArray(value)) {\n if (set.has(value)) {\n return '(circular value)'\n }\n set.add(value)\n }\n return typeof value === 'function' ? undefined : value\n }\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","options","debugForm","margin","fontWeight","JSON","stringify","safeStringifyReplace","set","Set","_key","value","Array","isArray","has","add","undefined"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;AAEO,SAASA,OAAT,CAAwBC,IAAxB,EAAmE;AACxE,EAAA,MAAM,CAACC,OAAD,CAAA,GAAYC,yBAAK,CAACC,QAAN,CAAe,MAAM;AACrC;IACA,MAAMC,GAAG,GAAG,IAAIC,gBAAJ,CAAmBL,IAAI,IAAI,EAA3B,CAAZ,CAAA;AAEAI,IAAAA,GAAG,CAACE,IAAJ,GAAWC,mBAAmB,CAACH,GAAD,CAA9B,CAAA;AACAA,IAAAA,GAAG,CAACI,KAAJ,GAAYC,0BAAoB,CAACL,GAAD,CAAhC,CAAA;AACAA,IAAAA,GAAG,CAACM,QAAJ,GAAeC,uBAAc,CAACP,GAAD,CAA7B,CAAA;;IACAA,GAAG,CAACQ,QAAJ,GAAe;AAEbC,IAAAA,QAFa,KAGV;AACH;AACA,MAAA,OAAOD,mBAAQ,CA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G4B,CAAAA,aAAAA,CAAAA,MAAAA,EAAAA,IAAAA,EAAAA,IAAI,CAACC,SAAL,CAAe9B,OAAf,EAAwB+B,oBAAoB,EAA5C,EAAgD,CAAhD,CADH,CADF,CAZF,CADD,GAmBG,IAxBN,EAyBGd,QAzBH,CAJJ,CADF,CAAA;GAHF,CAAA;;AAwCA,EAAA,OAAOZ,IAAP,CAAA;AACD,CAAA;;AAED,SAAS0B,oBAAT,GAAgC;AAC9B,EAAA,MAAMC,GAAG,GAAG,IAAIC,GAAJ,EAAZ,CAAA;AACA,EAAA,OAAO,CAACC,IAAD,EAAeC,KAAf,KAA8B;IACnC,IAAI,OAAOA,KAAP,KAAiB,QAAjB,IAA6BC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAjC,EAAuD;AACrD,MAAA,IAAIH,GAAG,CAACM,GAAJ,CAAQH,KAAR,CAAJ,EAAoB;AAClB,QAAA,OAAO,kBAAP,CAAA;AACD,OAAA;;MACDH,GAAG,CAACO,GAAJ,CAAQJ,KAAR,CAAA,CAAA;AACD,KAAA;;AACD,IAAA,OAAO,OAAOA,KAAP,KAAiB,UAAjB,GAA8BK,SAA9B,GAA0CL,KAAjD,CAAA;GAPF,CAAA;AASD;;;;;"}
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,CA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AACwB,YADpB;AAEE,MAAA,QAAQ,EAAEJ,YAAAA;AAFZ,KAAA,EAGMD,IAHN,CAAA,EAKGF,QALH,CAJJ,CADF,CAAA;GAHF,CAAA;;AAoBA,EAAA,OAAOZ,IAAP,CAAA;AACD;;;;"}
@@ -9,7 +9,7 @@
9
9
  * @license MIT
10
10
  */
11
11
  import { FieldApi, functionalUpdate, FormApi } from '@tanstack/form-core';
12
- export * from '@tanstack/form-core';
12
+ export { FieldApi, FormApi, functionalUpdate } from '@tanstack/form-core';
13
13
  import { useStore } from '@tanstack/react-store';
14
14
  import * as React from 'react';
15
15
  import React__default from 'react';
@@ -32,13 +32,9 @@ function _extends() {
32
32
  }
33
33
 
34
34
  const formContext = /*#__PURE__*/React.createContext(null);
35
- function useFormContext(customFormApi) {
35
+ function useFormContext() {
36
36
  const formApi = React.useContext(formContext);
37
37
 
38
- if (customFormApi) {
39
- return customFormApi;
40
- }
41
-
42
38
  if (!formApi) {
43
39
  throw new Error("You are trying to use the form API outside of a form!");
44
40
  }
@@ -46,22 +42,14 @@ function useFormContext(customFormApi) {
46
42
  return formApi;
47
43
  }
48
44
 
49
- function createUseField(formApi) {
50
- const useFormField = opts => {
51
- return useField({ ...opts,
52
- form: formApi
53
- });
45
+ function createUseField() {
46
+ return opts => {
47
+ return useField(opts);
54
48
  };
55
-
56
- return useFormField;
57
49
  }
58
50
  function useField(opts) {
59
- // invariant( // TODO:
60
- // opts.name,
61
- // `useField: A field is required to use this hook. eg, useField('myField', options)`
62
- // )
63
51
  // Get the form API either manually or from context
64
- const formApi = useFormContext(opts.form);
52
+ const formApi = useFormContext();
65
53
  const [fieldApi] = React.useState(() => new FieldApi({ ...opts,
66
54
  form: formApi
67
55
  })); // Keep options up to date as they are rendered
@@ -75,10 +63,8 @@ function useField(opts) {
75
63
  return fieldApi;
76
64
  }
77
65
 
78
- function createFieldComponent(formApi) {
79
- const ConnectedField = props => /*#__PURE__*/React.createElement(Field, _extends({}, props, {
80
- form: formApi
81
- }));
66
+ function createFieldComponent() {
67
+ const ConnectedField = props => /*#__PURE__*/React.createElement(Field, props);
82
68
 
83
69
  return ConnectedField;
84
70
  }
@@ -90,14 +76,13 @@ function Field({
90
76
  return functionalUpdate(children, fieldApi);
91
77
  }
92
78
 
93
- //
94
79
  function useForm(opts) {
95
80
  const [formApi] = React__default.useState(() => {
96
81
  // @ts-ignore
97
- const api = new FormApi(opts || {});
82
+ const api = new FormApi(opts);
98
83
  api.Form = createFormComponent(api);
99
- api.Field = createFieldComponent(api);
100
- api.useField = createUseField(api);
84
+ api.Field = createFieldComponent();
85
+ api.useField = createUseField();
101
86
 
102
87
  api.useStore = ( // @ts-ignore
103
88
  selector) => {
@@ -112,10 +97,10 @@ function useForm(opts) {
112
97
  };
113
98
 
114
99
  return api;
115
- }); // React.useEffect(() => formApi.mount(), [])
116
-
100
+ });
117
101
  return formApi;
118
102
  }
103
+
119
104
  function createFormComponent(formApi) {
120
105
  const Form = ({
121
106
  children,
@@ -128,34 +113,23 @@ function createFormComponent(formApi) {
128
113
  }, noFormElement ? children : /*#__PURE__*/React__default.createElement("form", _extends({
129
114
  onSubmit: formApi.handleSubmit,
130
115
  disabled: isSubmitting
131
- }, rest), formApi.options.debugForm ? /*#__PURE__*/React__default.createElement("div", {
132
- style: {
133
- margin: '2rem 0'
134
- }
135
- }, /*#__PURE__*/React__default.createElement("div", {
136
- style: {
137
- fontWeight: 'bolder'
138
- }
139
- }, "Form State"), /*#__PURE__*/React__default.createElement("pre", null, /*#__PURE__*/React__default.createElement("code", null, JSON.stringify(formApi, safeStringifyReplace(), 2)))) : null, children));
116
+ }, rest), children));
140
117
  };
141
118
 
142
119
  return Form;
143
120
  }
144
121
 
145
- function safeStringifyReplace() {
146
- const set = new Set();
147
- return (_key, value) => {
148
- if (typeof value === 'object' || Array.isArray(value)) {
149
- if (set.has(value)) {
150
- return '(circular value)';
151
- }
152
-
153
- set.add(value);
154
- }
155
-
156
- return typeof value === 'function' ? undefined : value;
122
+ function createFormFactory(defaultOpts) {
123
+ return {
124
+ useForm: opts => {
125
+ return useForm({ ...defaultOpts,
126
+ ...opts
127
+ });
128
+ },
129
+ useField: createUseField(),
130
+ Field: createFieldComponent()
157
131
  };
158
132
  }
159
133
 
160
- export { Field, createFieldComponent, createFormComponent, createUseField, useField, useForm };
134
+ export { Field, createFormFactory, useField, useForm };
161
135
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/formContext.ts","../../src/useField.ts","../../src/Field.tsx","../../src/useForm.tsx"],"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(customFormApi?: FormApi<any>) {\n const formApi = React.useContext(formContext)\n\n if (customFormApi) {\n return customFormApi\n }\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 FormApi,\n} from '@tanstack/form-core'\nimport { FieldApi } from '@tanstack/form-core'\nimport { useFormContext } from './formContext'\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>(formApi: FormApi<TFormData>) {\n const useFormField: UseField<TFormData> = (opts) => {\n return useField({ ...opts, form: formApi } as any)\n }\n\n return useFormField\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 // invariant( // TODO:\n // opts.name,\n // `useField: A field is required to use this hook. eg, useField('myField', options)`\n // )\n\n // Get the form API either manually or from context\n const formApi = useFormContext(opts.form)\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 type FormApi,\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>(formApi: FormApi<TFormData>) {\n const ConnectedField: FieldComponent<TFormData> = (props) => (\n <Field {...(props as any)} form={formApi} />\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 // 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//\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(api)\n api.useField = createUseField(api)\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\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),\n ) as any\n }\n\n return api\n })\n\n // React.useEffect(() => formApi.mount(), [])\n\n return formApi\n}\n\nexport type FormProps = React.HTMLProps<HTMLFormElement> & {\n children: React.ReactNode\n noFormElement?: boolean\n}\n\nexport type FormComponent = (props: FormProps) => any\n\nexport function 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 {formApi.options.debugForm ? (\n <div\n style={{\n margin: '2rem 0',\n }}\n >\n <div\n style={{\n fontWeight: 'bolder',\n }}\n >\n Form State\n </div>\n <pre>\n <code>\n {JSON.stringify(formApi, safeStringifyReplace(), 2)}\n </code>\n </pre>\n </div>\n ) : null}\n {children}\n </form>\n )}\n </formContext.Provider>\n )\n }\n\n return Form\n}\n\nfunction safeStringifyReplace() {\n const set = new Set()\n return (_key: string, value: any) => {\n if (typeof value === 'object' || Array.isArray(value)) {\n if (set.has(value)) {\n return '(circular value)'\n }\n set.add(value)\n }\n return typeof value === 'function' ? undefined : value\n }\n}\n"],"names":["formContext","React","createContext","useFormContext","customFormApi","formApi","useContext","Error","createUseField","useFormField","opts","useField","form","fieldApi","useState","FieldApi","update","useStore","store","useEffect","mount","createFieldComponent","ConnectedField","props","Field","children","fieldOptions","functionalUpdate","useForm","api","FormApi","Form","createFormComponent","selector","Subscribe","noFormElement","rest","isSubmitting","state","handleSubmit","options","debugForm","margin","fontWeight","JSON","stringify","safeStringifyReplace","set","Set","_key","value","Array","isArray","has","add","undefined"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,WAAW,gBAAGC,KAAK,CAACC,aAAN,CAAyC,IAAzC,CAApB,CAAA;AAEA,SAASC,cAAT,CAAwBC,aAAxB,EAAsD;AAC3D,EAAA,MAAMC,OAAO,GAAGJ,KAAK,CAACK,UAAN,CAAiBN,WAAjB,CAAhB,CAAA;;AAEA,EAAA,IAAII,aAAJ,EAAmB;AACjB,IAAA,OAAOA,aAAP,CAAA;AACD,GAAA;;EAED,IAAI,CAACC,OAAL,EAAc;IACZ,MAAM,IAAIE,KAAJ,CAAN,uDAAA,CAAA,CAAA;AACD,GAAA;;AAED,EAAA,OAAOF,OAAP,CAAA;AACD;;ACEM,SAASG,cAAT,CAAmCH,OAAnC,EAAgE;EACrE,MAAMI,YAAiC,GAAIC,IAAD,IAAU;AAClD,IAAA,OAAOC,QAAQ,CAAC,EAAE,GAAGD,IAAL;AAAWE,MAAAA,IAAI,EAAEP,OAAAA;AAAjB,KAAD,CAAf,CAAA;GADF,CAAA;;AAIA,EAAA,OAAOI,YAAP,CAAA;AACD,CAAA;AAEM,SAASE,QAAT,CACLD,IADK,EAIuB;AAC5B;AACA;AACA;AACA;AAEA;AACA,EAAA,MAAML,OAAO,GAAGF,cAAc,CAACO,IAAI,CAACE,IAAN,CAA9B,CAAA;AAEA,EAAA,MAAM,CAACC,QAAD,CAAaZ,GAAAA,KAAK,CAACa,QAAN,CACjB,MAAM,IAAIC,QAAJ,CAAa,EAAE,GAAGL,IAAL;AAAWE,IAAAA,IAAI,EAA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A,KAAA,EAAA;AACE,MAAA,KAAK,EAAE;AACL0C,QAAAA,UAAU,EAAE,QAAA;AADP,OAAA;KANX,EAAA,YAAA,CAAA,eAYE1C,uDACEA,cACG2C,CAAAA,aAAAA,CAAAA,MAAAA,EAAAA,IAAAA,EAAAA,IAAI,CAACC,SAAL,CAAexC,OAAf,EAAwByC,oBAAoB,EAA5C,EAAgD,CAAhD,CADH,CADF,CAZF,CADD,GAmBG,IAxBN,EAyBGrB,QAzBH,CAJJ,CADF,CAAA;GAHF,CAAA;;AAwCA,EAAA,OAAOM,IAAP,CAAA;AACD,CAAA;;AAED,SAASe,oBAAT,GAAgC;AAC9B,EAAA,MAAMC,GAAG,GAAG,IAAIC,GAAJ,EAAZ,CAAA;AACA,EAAA,OAAO,CAACC,IAAD,EAAeC,KAAf,KAA8B;IACnC,IAAI,OAAOA,KAAP,KAAiB,QAAjB,IAA6BC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAjC,EAAuD;AACrD,MAAA,IAAIH,GAAG,CAACM,GAAJ,CAAQH,KAAR,CAAJ,EAAoB;AAClB,QAAA,OAAO,kBAAP,CAAA;AACD,OAAA;;MACDH,GAAG,CAACO,GAAJ,CAAQJ,KAAR,CAAA,CAAA;AACD,KAAA;;AACD,IAAA,OAAO,OAAOA,KAAP,KAAiB,UAAjB,GAA8BK,SAA9B,GAA0CL,KAAjD,CAAA;GAPF,CAAA;AASD;;;;"}
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","Subscribe","noFormElement","rest","isSubmitting","state","handleSubmit","createFormFactory","defaultOpts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,WAAW,gBAAGC,KAAK,CAACC,aAAN,CAAyC,IAAzC,CAApB,CAAA;AAEA,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;;ACSM,SAASG,cAAT,GAA0D;AAC/D,EAAA,OAAQC,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,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;;;;"}
@@ -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":"3676-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":"3676-31"}]},{"name":"packages","children":[{"name":"form-core/build/esm/index.js","uid":"3676-27"},{"name":"react-form/src","children":[{"uid":"3676-33","name":"formContext.ts"},{"uid":"3676-35","name":"useField.ts"},{"uid":"3676-37","name":"Field.tsx"},{"uid":"3676-39","name":"useForm.tsx"},{"uid":"3676-41","name":"index.ts"}]}]},{"uid":"3676-29","name":"\u0000rollupPluginBabelHelpers.js"}]}],"isRoot":true},"nodeParts":{"3676-25":{"renderedLength":1288,"gzipLength":497,"brotliLength":0,"mainUid":"3676-24"},"3676-27":{"renderedLength":23393,"gzipLength":5130,"brotliLength":0,"mainUid":"3676-26"},"3676-29":{"renderedLength":431,"gzipLength":240,"brotliLength":0,"mainUid":"3676-28"},"3676-31":{"renderedLength":978,"gzipLength":456,"brotliLength":0,"mainUid":"3676-30"},"3676-33":{"renderedLength":369,"gzipLength":218,"brotliLength":0,"mainUid":"3676-32"},"3676-35":{"renderedLength":850,"gzipLength":417,"brotliLength":0,"mainUid":"3676-34"},"3676-37":{"renderedLength":370,"gzipLength":227,"brotliLength":0,"mainUid":"3676-36"},"3676-39":{"renderedLength":2160,"gzipLength":767,"brotliLength":0,"mainUid":"3676-38"},"3676-41":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"3676-40"}},"nodeMetas":{"3676-24":{"id":"/node_modules/.pnpm/@tanstack+store@0.0.1-beta.84/node_modules/@tanstack/store/build/esm/index.js","moduleParts":{"index.production.js":"3676-25"},"imported":[],"importedBy":[{"uid":"3676-26"},{"uid":"3676-30"}]},"3676-26":{"id":"/packages/form-core/build/esm/index.js","moduleParts":{"index.production.js":"3676-27"},"imported":[{"uid":"3676-24"}],"importedBy":[{"uid":"3676-40"},{"uid":"3676-38"},{"uid":"3676-36"},{"uid":"3676-34"}]},"3676-28":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"3676-29"},"imported":[],"importedBy":[{"uid":"3676-38"},{"uid":"3676-36"}]},"3676-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":"3676-31"},"imported":[{"uid":"3676-43"},{"uid":"3676-24"}],"importedBy":[{"uid":"3676-38"},{"uid":"3676-34"}]},"3676-32":{"id":"/packages/react-form/src/formContext.ts","moduleParts":{"index.production.js":"3676-33"},"imported":[{"uid":"3676-42"}],"importedBy":[{"uid":"3676-38"},{"uid":"3676-34"}]},"3676-34":{"id":"/packages/react-form/src/useField.ts","moduleParts":{"index.production.js":"3676-35"},"imported":[{"uid":"3676-42"},{"uid":"3676-30"},{"uid":"3676-26"},{"uid":"3676-32"}],"importedBy":[{"uid":"3676-40"},{"uid":"3676-38"},{"uid":"3676-36"}]},"3676-36":{"id":"/packages/react-form/src/Field.tsx","moduleParts":{"index.production.js":"3676-37"},"imported":[{"uid":"3676-28"},{"uid":"3676-42"},{"uid":"3676-26"},{"uid":"3676-34"}],"importedBy":[{"uid":"3676-40"},{"uid":"3676-38"}]},"3676-38":{"id":"/packages/react-form/src/useForm.tsx","moduleParts":{"index.production.js":"3676-39"},"imported":[{"uid":"3676-28"},{"uid":"3676-26"},{"uid":"3676-30"},{"uid":"3676-42"},{"uid":"3676-36"},{"uid":"3676-34"},{"uid":"3676-32"}],"importedBy":[{"uid":"3676-40"}]},"3676-40":{"id":"/packages/react-form/src/index.ts","moduleParts":{"index.production.js":"3676-41"},"imported":[{"uid":"3676-26"},{"uid":"3676-38"},{"uid":"3676-36"},{"uid":"3676-34"}],"importedBy":[],"isEntry":true},"3676-42":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"3676-38"},{"uid":"3676-36"},{"uid":"3676-34"},{"uid":"3676-32"}],"isExternal":true},"3676-43":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"3676-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":"dff6-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":"dff6-31"}]},{"name":"packages","children":[{"name":"form-core/build/esm/index.js","uid":"dff6-27"},{"name":"react-form/src","children":[{"uid":"dff6-33","name":"formContext.ts"},{"uid":"dff6-35","name":"useField.ts"},{"uid":"dff6-37","name":"Field.tsx"},{"uid":"dff6-39","name":"useForm.tsx"},{"uid":"dff6-41","name":"createFormFactory.ts"},{"uid":"dff6-43","name":"index.ts"}]}]},{"uid":"dff6-29","name":"\u0000rollupPluginBabelHelpers.js"}]}],"isRoot":true},"nodeParts":{"dff6-25":{"renderedLength":1288,"gzipLength":497,"brotliLength":0,"mainUid":"dff6-24"},"dff6-27":{"renderedLength":23394,"gzipLength":5131,"brotliLength":0,"mainUid":"dff6-26"},"dff6-29":{"renderedLength":431,"gzipLength":240,"brotliLength":0,"mainUid":"dff6-28"},"dff6-31":{"renderedLength":978,"gzipLength":456,"brotliLength":0,"mainUid":"dff6-30"},"dff6-33":{"renderedLength":296,"gzipLength":200,"brotliLength":0,"mainUid":"dff6-32"},"dff6-35":{"renderedLength":610,"gzipLength":324,"brotliLength":0,"mainUid":"dff6-34"},"dff6-37":{"renderedLength":320,"gzipLength":203,"brotliLength":0,"mainUid":"dff6-36"},"dff6-39":{"renderedLength":1264,"gzipLength":486,"brotliLength":0,"mainUid":"dff6-38"},"dff6-41":{"renderedLength":242,"gzipLength":153,"brotliLength":0,"mainUid":"dff6-40"},"dff6-43":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"dff6-42"}},"nodeMetas":{"dff6-24":{"id":"/node_modules/.pnpm/@tanstack+store@0.0.1-beta.84/node_modules/@tanstack/store/build/esm/index.js","moduleParts":{"index.production.js":"dff6-25"},"imported":[],"importedBy":[{"uid":"dff6-26"},{"uid":"dff6-30"}]},"dff6-26":{"id":"/packages/form-core/build/esm/index.js","moduleParts":{"index.production.js":"dff6-27"},"imported":[{"uid":"dff6-24"}],"importedBy":[{"uid":"dff6-42"},{"uid":"dff6-38"},{"uid":"dff6-36"},{"uid":"dff6-34"}]},"dff6-28":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"dff6-29"},"imported":[],"importedBy":[{"uid":"dff6-38"}]},"dff6-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":"dff6-31"},"imported":[{"uid":"dff6-45"},{"uid":"dff6-24"}],"importedBy":[{"uid":"dff6-38"},{"uid":"dff6-34"}]},"dff6-32":{"id":"/packages/react-form/src/formContext.ts","moduleParts":{"index.production.js":"dff6-33"},"imported":[{"uid":"dff6-44"}],"importedBy":[{"uid":"dff6-38"},{"uid":"dff6-34"}]},"dff6-34":{"id":"/packages/react-form/src/useField.ts","moduleParts":{"index.production.js":"dff6-35"},"imported":[{"uid":"dff6-44"},{"uid":"dff6-30"},{"uid":"dff6-26"},{"uid":"dff6-32"}],"importedBy":[{"uid":"dff6-42"},{"uid":"dff6-38"},{"uid":"dff6-36"},{"uid":"dff6-40"}]},"dff6-36":{"id":"/packages/react-form/src/Field.tsx","moduleParts":{"index.production.js":"dff6-37"},"imported":[{"uid":"dff6-44"},{"uid":"dff6-26"},{"uid":"dff6-34"}],"importedBy":[{"uid":"dff6-42"},{"uid":"dff6-38"},{"uid":"dff6-40"}]},"dff6-38":{"id":"/packages/react-form/src/useForm.tsx","moduleParts":{"index.production.js":"dff6-39"},"imported":[{"uid":"dff6-28"},{"uid":"dff6-26"},{"uid":"dff6-30"},{"uid":"dff6-44"},{"uid":"dff6-36"},{"uid":"dff6-34"},{"uid":"dff6-32"}],"importedBy":[{"uid":"dff6-42"},{"uid":"dff6-40"}]},"dff6-40":{"id":"/packages/react-form/src/createFormFactory.ts","moduleParts":{"index.production.js":"dff6-41"},"imported":[{"uid":"dff6-34"},{"uid":"dff6-38"},{"uid":"dff6-36"}],"importedBy":[{"uid":"dff6-42"}]},"dff6-42":{"id":"/packages/react-form/src/index.ts","moduleParts":{"index.production.js":"dff6-43"},"imported":[{"uid":"dff6-26"},{"uid":"dff6-38"},{"uid":"dff6-36"},{"uid":"dff6-34"},{"uid":"dff6-40"}],"importedBy":[],"isEntry":true},"dff6-44":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"dff6-38"},{"uid":"dff6-36"},{"uid":"dff6-34"},{"uid":"dff6-32"}],"isExternal":true},"dff6-45":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"dff6-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;