react-f0rm 0.4.0 → 0.4.1

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 (38) hide show
  1. package/dist/devtools/index.cjs.js +20 -13
  2. package/dist/devtools/index.cjs.js.map +1 -1
  3. package/dist/devtools/index.d.ts +1 -1
  4. package/dist/devtools/index.mjs +20 -13
  5. package/dist/devtools/index.mjs.map +1 -1
  6. package/dist/{form-b9441d8c.cjs.js → form-B4r7INJ0.cjs.js} +10 -39
  7. package/dist/form-B4r7INJ0.cjs.js.map +1 -0
  8. package/dist/{form-61297bc0.d.ts → form-DeRFdFKE.d.ts} +2 -2
  9. package/dist/{form-94c70b4b.mjs → form-R1hDKjBm.mjs} +11 -40
  10. package/dist/form-R1hDKjBm.mjs.map +1 -0
  11. package/dist/index.cjs.js +20 -13
  12. package/dist/index.cjs.js.map +1 -1
  13. package/dist/index.d.ts +11 -8
  14. package/dist/index.mjs +21 -14
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/index.umd.js +20 -13
  17. package/dist/index.umd.js.map +1 -1
  18. package/dist/index.umd.min.js +2 -2
  19. package/dist/index.umd.min.js.map +1 -1
  20. package/dist/resolvers/standard-schema.cjs.js +1 -1
  21. package/dist/resolvers/standard-schema.cjs.js.map +1 -1
  22. package/dist/resolvers/standard-schema.d.ts +2 -2
  23. package/dist/resolvers/standard-schema.mjs +1 -1
  24. package/dist/resolvers/standard-schema.mjs.map +1 -1
  25. package/dist/resolvers/yup.cjs.js +5 -7
  26. package/dist/resolvers/yup.cjs.js.map +1 -1
  27. package/dist/resolvers/yup.d.ts +2 -2
  28. package/dist/resolvers/yup.mjs +5 -7
  29. package/dist/resolvers/yup.mjs.map +1 -1
  30. package/dist/resolvers/zod.cjs.js +5 -7
  31. package/dist/resolvers/zod.cjs.js.map +1 -1
  32. package/dist/resolvers/zod.d.ts +2 -2
  33. package/dist/resolvers/zod.mjs +5 -7
  34. package/dist/resolvers/zod.mjs.map +1 -1
  35. package/dist/{validate-148fe167.d.ts → validate-B7S9EiRT.d.ts} +1 -1
  36. package/package.json +52 -51
  37. package/dist/form-94c70b4b.mjs.map +0 -1
  38. package/dist/form-b9441d8c.cjs.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { F as FieldPath, N as Name, a as Form$1, P as PathValueOf, b as FieldError, O as Options, c as Path } from './form-61297bc0.js';
2
- export { f as FieldErrorEntry, u as FieldState, a3 as HandleSubmitOptions, e as PathValue, R as ReValidateMode, U as ResetFieldOptions, Q as ResetOptions, S as SetFieldOptions, a5 as SetFocusOptions, g as VALIDATION_OUTCOME, i as ValidateResult, V as ValidationMode, h as ValidationOutcome, A as clearErrors, d as createForm, Z as ensureValidate, H as getDirtyFields, n as getError, o as getErrorByPath, r as getErrors, p as getFieldErrors, q as getFieldErrorsByPath, v as getFieldState, t as getFirstError, I as getTouchedFields, k as getValue, l as getValueByPath, j as getValues, a4 as handleSubmit, X as hasErrors, D as hasTouched, E as hasTouchedByPath, a0 as incrementSubmitCount, G as isDirty, J as isTouched, K as removeField, L as removeFieldByPath, T as reset, W as resetField, a2 as setDisabled, y as setError, z as setErrorByPath, a6 as setFocus, M as setInitialValues, $ as setIsSubmitting, a1 as setSubmitSuccessful, B as setTouched, C as setTouchedByPath, x as setValidatingByPath, s as setValue, m as setValueByPath, Y as trigger, w as unsetValidatingByPath, _ as validate } from './form-61297bc0.js';
1
+ import { a as FieldPath, N as Name, F as Form$1, P as PathValueOf, b as FieldError, c as Path, O as Options } from './form-DeRFdFKE.js';
2
+ export { d as FieldErrorEntry, e as FieldState, H as HandleSubmitOptions, f as PathValue, R as ReValidateMode, g as ResetFieldOptions, h as ResetOptions, S as SetFieldOptions, i as SetFocusOptions, V as VALIDATION_OUTCOME, j as ValidateResult, k as ValidationMode, l as ValidationOutcome, m as clearErrors, n as createForm, o as ensureValidate, p as getDirtyFields, q as getError, r as getErrorByPath, s as getErrors, t as getFieldErrors, u as getFieldErrorsByPath, v as getFieldState, w as getFirstError, x as getTouchedFields, y as getValue, z as getValueByPath, A as getValues, B as handleSubmit, C as hasErrors, D as hasTouched, E as hasTouchedByPath, G as incrementSubmitCount, I as isDirty, J as isTouched, K as removeField, L as removeFieldByPath, M as reset, Q as resetField, T as setDisabled, U as setError, W as setErrorByPath, X as setFocus, Y as setInitialValues, Z as setIsSubmitting, _ as setSubmitSuccessful, $ as setTouched, a0 as setTouchedByPath, a1 as setValidatingByPath, a2 as setValue, a3 as setValueByPath, a4 as trigger, a5 as unsetValidatingByPath, a6 as validate } from './form-DeRFdFKE.js';
3
+ import { V as Validator } from './validate-B7S9EiRT.js';
3
4
  import * as React from 'react';
4
5
  import { ReactNode } from 'react';
5
- import { V as Validator } from './validate-148fe167.js';
6
6
  import { EventEmitter } from '@for-fun/event-emitter';
7
7
 
8
8
  /** Type tag of a failed rule, as stored on the resulting FieldError. */
@@ -317,7 +317,7 @@ declare function subscribe(form: Form$1, options: SubscribeOptions): () => void;
317
317
  * this component is a thin wrapper that binds it to the rendered <form>.
318
318
  */
319
319
  interface FormProps<T extends Record<string, any> = any> extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit'> {
320
- form?: Form<T>;
320
+ form?: Form$1<T>;
321
321
  /**
322
322
  * Provide into an isolated context from `createFormContext()` instead of
323
323
  * the module-level one — `<Form context={ProfileForm.context}>` keeps the
@@ -327,7 +327,7 @@ interface FormProps<T extends Record<string, any> = any> extends Omit<React.Form
327
327
  * `useField` do not see it; that is the point of the isolation. Omitted,
328
328
  * the form lands in the module-level FormContext as before.
329
329
  */
330
- context?: React.Context<Form<any> | null>;
330
+ context?: React.Context<Form$1<any> | null>;
331
331
  initialValues?: T;
332
332
  /**
333
333
  * Controlled external values. When the `values` reference changes, the
@@ -338,8 +338,11 @@ interface FormProps<T extends Record<string, any> = any> extends Omit<React.Form
338
338
  * `values` reference never clobber what the user is typing.
339
339
  */
340
340
  values?: T;
341
- onSubmit?: (values: T, e: React.FormEvent) => void;
342
- onValidSubmit?: (values: T, e: React.FormEvent) => void;
341
+ /** May be async — the submit flow awaits it, so form.isSubmitting
342
+ * covers the entire flight. */
343
+ onSubmit?: (values: T, e: React.FormEvent) => void | Promise<void>;
344
+ /** May be async, same as onSubmit. */
345
+ onValidSubmit?: (values: T, e: React.FormEvent) => void | Promise<void>;
343
346
  /**
344
347
  * Called when validation fails.
345
348
  * @param errors array of {path, type, message} entries in insertion
@@ -468,5 +471,5 @@ interface SelectComponent {
468
471
  }
469
472
  declare const Select: SelectComponent;
470
473
 
471
- export { Checkbox, CheckboxGroupContext, CheckboxGroupProvider, Field, FieldError, FieldPath, Form, FormContext, Form$1 as FormInstance, FormProvider, Name, Options, PathValueOf, Select, createFormContext, subscribe, useCheckboxGroupContext, useDirtyFields, useError, useErrorByPath, useField, useFieldArray, useFieldErrors, useFieldErrorsByPath, useForm, useFormContext, useHasErrors, useIsDirty, useIsSubmitting, useSubmitCount, useTouched, useTouchedByPath, useTouchedFields, useValue, useValueByPath, useWatch };
474
+ export { Checkbox, CheckboxGroupContext, CheckboxGroupProvider, Field, FieldError, FieldPath, Form, FormContext, Form$1 as FormInstance, FormProvider, Name, Options, Path, PathValueOf, Select, Validator, createFormContext, subscribe, useCheckboxGroupContext, useDirtyFields, useError, useErrorByPath, useField, useFieldArray, useFieldErrors, useFieldErrorsByPath, useForm, useFormContext, useHasErrors, useIsDirty, useIsSubmitting, useSubmitCount, useTouched, useTouchedByPath, useTouchedFields, useValue, useValueByPath, useWatch };
472
475
  export type { FieldRules, SubscribeEvent, SubscribeOptions, WatchScope };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { useState, useRef, useEffect, useCallback, useMemo, useContext, useReducer, createContext, createElement } from 'react';
2
+ import React__default, { useCallback, useRef, useState, useEffect, useMemo, useContext, useReducer, createContext, createElement } from 'react';
3
3
 
4
4
  function getSet(ee, key) {
5
5
  var set = ee.get(key);
@@ -11,7 +11,7 @@ function getSet(ee, key) {
11
11
  function create$2() {
12
12
  return new Map();
13
13
  }
14
- function emit$1(ee, key) {
14
+ function emit(ee, key) {
15
15
  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
16
16
  args[_key - 2] = arguments[_key];
17
17
  }
@@ -166,7 +166,6 @@ function create$1(name) {
166
166
  return { value, key: JSON.stringify(value) };
167
167
  }
168
168
 
169
- const emit = emit$1;
170
169
  const VALIDATION_OUTCOME = /* @__PURE__ */ Symbol("validation-outcome");
171
170
  function create(options) {
172
171
  const emitter = create$2();
@@ -761,7 +760,7 @@ function requireUseSyncExternalStoreShim_production () {
761
760
  var nextValue = latestGetSnapshot();
762
761
  return !objectIs(inst, nextValue);
763
762
  } catch (error) {
764
- return !0;
763
+ return true;
765
764
  }
766
765
  }
767
766
  function useSyncExternalStore$1(subscribe, getSnapshot) {
@@ -803,7 +802,7 @@ function requireUseSyncExternalStoreShim_development () {
803
802
  function useSyncExternalStore$2(subscribe, getSnapshot) {
804
803
  didWarnOld18Alpha ||
805
804
  void 0 === React.startTransition ||
806
- ((didWarnOld18Alpha = !0),
805
+ ((didWarnOld18Alpha = true),
807
806
  console.error(
808
807
  "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
809
808
  ));
@@ -814,7 +813,7 @@ function requireUseSyncExternalStoreShim_development () {
814
813
  (console.error(
815
814
  "The result of getSnapshot should be cached to avoid an infinite loop"
816
815
  ),
817
- (didWarnUncachedGetSnapshot = !0));
816
+ (didWarnUncachedGetSnapshot = true));
818
817
  }
819
818
  cachedValue = useState({
820
819
  inst: { value: value, getSnapshot: getSnapshot }
@@ -848,7 +847,7 @@ function requireUseSyncExternalStoreShim_development () {
848
847
  var nextValue = latestGetSnapshot();
849
848
  return !objectIs(inst, nextValue);
850
849
  } catch (error) {
851
- return !0;
850
+ return true;
852
851
  }
853
852
  }
854
853
  function useSyncExternalStore$1(subscribe, getSnapshot) {
@@ -864,8 +863,8 @@ function requireUseSyncExternalStoreShim_development () {
864
863
  useEffect = React.useEffect,
865
864
  useLayoutEffect = React.useLayoutEffect,
866
865
  useDebugValue = React.useDebugValue,
867
- didWarnOld18Alpha = !1,
868
- didWarnUncachedGetSnapshot = !1,
866
+ didWarnOld18Alpha = false,
867
+ didWarnUncachedGetSnapshot = false,
869
868
  shim =
870
869
  "undefined" === typeof window ||
871
870
  "undefined" === typeof window.document ||
@@ -882,13 +881,21 @@ function requireUseSyncExternalStoreShim_development () {
882
881
  return useSyncExternalStoreShim_development;
883
882
  }
884
883
 
885
- if (process.env.NODE_ENV === 'production') {
886
- shim.exports = requireUseSyncExternalStoreShim_production();
887
- } else {
888
- shim.exports = requireUseSyncExternalStoreShim_development();
884
+ var hasRequiredShim;
885
+
886
+ function requireShim () {
887
+ if (hasRequiredShim) return shim.exports;
888
+ hasRequiredShim = 1;
889
+
890
+ if (process.env.NODE_ENV === 'production') {
891
+ shim.exports = requireUseSyncExternalStoreShim_production();
892
+ } else {
893
+ shim.exports = requireUseSyncExternalStoreShim_development();
894
+ }
895
+ return shim.exports;
889
896
  }
890
897
 
891
- var shimExports = shim.exports;
898
+ var shimExports = requireShim();
892
899
 
893
900
  function isDescendant(key, ancestorKey) {
894
901
  return key.startsWith(`${ancestorKey.slice(0, -1)},`);