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.
- package/dist/devtools/index.cjs.js +20 -13
- package/dist/devtools/index.cjs.js.map +1 -1
- package/dist/devtools/index.d.ts +1 -1
- package/dist/devtools/index.mjs +20 -13
- package/dist/devtools/index.mjs.map +1 -1
- package/dist/{form-b9441d8c.cjs.js → form-B4r7INJ0.cjs.js} +10 -39
- package/dist/form-B4r7INJ0.cjs.js.map +1 -0
- package/dist/{form-61297bc0.d.ts → form-DeRFdFKE.d.ts} +2 -2
- package/dist/{form-94c70b4b.mjs → form-R1hDKjBm.mjs} +11 -40
- package/dist/form-R1hDKjBm.mjs.map +1 -0
- package/dist/index.cjs.js +20 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +11 -8
- package/dist/index.mjs +21 -14
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +20 -13
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +2 -2
- package/dist/index.umd.min.js.map +1 -1
- package/dist/resolvers/standard-schema.cjs.js +1 -1
- package/dist/resolvers/standard-schema.cjs.js.map +1 -1
- package/dist/resolvers/standard-schema.d.ts +2 -2
- package/dist/resolvers/standard-schema.mjs +1 -1
- package/dist/resolvers/standard-schema.mjs.map +1 -1
- package/dist/resolvers/yup.cjs.js +5 -7
- package/dist/resolvers/yup.cjs.js.map +1 -1
- package/dist/resolvers/yup.d.ts +2 -2
- package/dist/resolvers/yup.mjs +5 -7
- package/dist/resolvers/yup.mjs.map +1 -1
- package/dist/resolvers/zod.cjs.js +5 -7
- package/dist/resolvers/zod.cjs.js.map +1 -1
- package/dist/resolvers/zod.d.ts +2 -2
- package/dist/resolvers/zod.mjs +5 -7
- package/dist/resolvers/zod.mjs.map +1 -1
- package/dist/{validate-148fe167.d.ts → validate-B7S9EiRT.d.ts} +1 -1
- package/package.json +52 -51
- package/dist/form-94c70b4b.mjs.map +0 -1
- package/dist/form-b9441d8c.cjs.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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
|
-
|
|
342
|
-
|
|
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, {
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
|
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 =
|
|
868
|
-
didWarnUncachedGetSnapshot =
|
|
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
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
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 =
|
|
898
|
+
var shimExports = requireShim();
|
|
892
899
|
|
|
893
900
|
function isDescendant(key, ancestorKey) {
|
|
894
901
|
return key.startsWith(`${ancestorKey.slice(0, -1)},`);
|