New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@rvf/core

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rvf/core - npm Package Compare versions

Comparing version 6.1.4 to 6.3.0

.turbo/turbo-typecheck.log

103

dist/index.cjs.js

@@ -68,2 +68,3 @@ "use strict";

getFormId: () => getFormId,
getFormIdOption: () => getFormIdOption,
getFormProps: () => getFormProps,

@@ -185,4 +186,8 @@ getNextCheckboxValue: () => getNextCheckboxValue,

};
var getFormId = (state) => state.formProps.id;
var getFormProps = (state) => state.formProps;
var getFormId = (state) => state.formProps.id ?? state.defaultFormId;
var getFormIdOption = (state) => state.formProps.id;
var getFormProps = (state) => ({
...state.formProps,
id: getFormId(state)
});
var getFormAction = (state) => state.formProps.action;

@@ -641,3 +646,4 @@

flags,
serverValidationErrors = {}
serverValidationErrors = {},
defaultFormId
}) => create()(

@@ -657,3 +663,7 @@ immer((set, get) => ({

submitSource,
formProps,
formProps: {
...formProps,
id: formProps.id
},
defaultFormId,
flags,

@@ -868,2 +878,36 @@ /////// Validation

let result = void 0;
const runSubmission = async (data) => {
try {
let response;
if (get().submitSource === "state") {
response = await mutableImplStore.onSubmit(data, submitterOptions);
} else {
if (!formData)
throw new Error(
"Missing form data. This is likely a bug in RVF"
);
response = await mutableImplStore.onSubmit(
data,
formData,
submitterOptions
);
}
try {
await mutableImplStore.onSubmitSuccess?.(response);
} finally {
set((state) => {
state.submitStatus = "success";
});
}
} catch (err) {
try {
await mutableImplStore.onSubmitFailure?.(err);
} finally {
set((state) => {
state.submitStatus = "error";
});
}
}
};
let submitted = false;
try {

@@ -890,2 +934,6 @@ await mutableImplStore.onBeforeSubmit?.({

},
performSubmit: async (data) => {
submitted = true;
await runSubmission(data);
},
submitterOptions

@@ -906,2 +954,4 @@ });

}
if (submitted)
return;
if (!result)

@@ -927,34 +977,3 @@ result = await doValidation();

}
try {
let response;
if (get().submitSource === "state") {
response = await mutableImplStore.onSubmit(
result.data,
submitterOptions
);
} else {
if (!formData)
throw new Error("Missing form data. This is likely a bug in RVF");
response = await mutableImplStore.onSubmit(
result.data,
formData,
submitterOptions
);
}
try {
await mutableImplStore.onSubmitSuccess?.(response);
} finally {
set((state) => {
state.submitStatus = "success";
});
}
} catch (err) {
try {
await mutableImplStore.onSubmitFailure?.(err);
} finally {
set((state) => {
state.submitStatus = "error";
});
}
}
await runSubmission(result.data);
},

@@ -971,3 +990,6 @@ /////// Actions

state.validationBehaviorConfig = validationBehaviorConfig2;
state.formProps = formProps2;
state.formProps = {
...formProps2,
id: formProps2.id ?? state.formProps.id
};
state.flags = flags2;

@@ -1676,3 +1698,4 @@ });

formProps,
flags
flags,
defaultFormId
}) => {

@@ -1704,3 +1727,4 @@ const transientFieldRefs = createRefStore();

formProps,
flags
flags,
defaultFormId
});

@@ -1804,2 +1828,3 @@ const subformCache = /* @__PURE__ */ new Map();

getFormId,
getFormIdOption,
getFormProps,

@@ -1806,0 +1831,0 @@ getNextCheckboxValue,

@@ -115,5 +115,19 @@ import * as zustand_react from 'zustand/react';

* Cancels the form submission and sets the submit status to `error`.
*
* This is intended for advanced use-cases.
* By using this, you're taking control of the submission lifecycle.
* `onSubmitFailure` will _not_ be called as a result of this.
*/
cancelSubmit: () => never;
/**
* This is intended for advanced use-cases.
* By using this, you're taking control of the submission lifecycle.
*
* Manually invokes the `handleSubmit` function,
* allowing you to customize the data that is submitted.
* This will not trigger any validations, so make sure to use `getValidatedData`
* if you want to run validations before submitting.
*/
performSubmit: (data: FormOutputData) => Promise<void>;
/**
* The options passed to the form submission by the submitter.

@@ -138,3 +152,3 @@ * This usually comes from props passed to your submit button,

action?: string;
id: string;
id?: string;
};

@@ -158,2 +172,3 @@ type StoreFlags = {

flags: StoreFlags;
defaultFormId: string;
};

@@ -250,2 +265,3 @@ type SubmitterOptions = {

serverValidationErrors: FieldErrors;
defaultFormId: string;
};

@@ -256,3 +272,3 @@ declare const renameFlatFieldStateKeys: <Obj extends Record<string, any>>(obj: Obj, path: string, updater: (key: string) => string) => void;

declare const toArrayBehavior: (config?: ValidationBehaviorConfig) => FieldArrayValidationBehaviorConfig;
declare const createFormStateStore: ({ defaultValues, controlledFieldRefs, transientFieldRefs, fieldSerializerRefs, resolvers, mutableImplStore, formRef, submitSource, validationBehaviorConfig, formProps, flags, serverValidationErrors, }: FormStoreInit) => zustand_react.UseBoundStore<Omit<zustand.StoreApi<FormStoreValue>, "setState"> & {
declare const createFormStateStore: ({ defaultValues, controlledFieldRefs, transientFieldRefs, fieldSerializerRefs, resolvers, mutableImplStore, formRef, submitSource, validationBehaviorConfig, formProps, flags, serverValidationErrors, defaultFormId, }: FormStoreInit) => zustand_react.UseBoundStore<Omit<zustand.StoreApi<FormStoreValue>, "setState"> & {
setState(nextStateOrUpdater: FormStoreValue | Partial<FormStoreValue> | ((state: immer.WritableDraft<FormStoreValue>) => void), shouldReplace?: boolean | undefined): void;

@@ -280,2 +296,3 @@ }>;

flags: StoreFlags;
defaultFormId: string;
} & SubmitTypes<FormOutputData>;

@@ -302,3 +319,3 @@ interface FormScope<FormInputData> {

}
declare const createFormScope: <FormInputData extends FieldValues, FormOutputData>({ defaultValues, serverValidationErrors, validator, onSubmit, onSubmitSuccess, onSubmitFailure, onBeforeSubmit, onInvalidSubmit, validationBehaviorConfig, submitSource, formProps, flags, }: FormInit<FormInputData, FormOutputData>) => FormScope<FormInputData>;
declare const createFormScope: <FormInputData extends FieldValues, FormOutputData>({ defaultValues, serverValidationErrors, validator, onSubmit, onSubmitSuccess, onSubmitFailure, onBeforeSubmit, onInvalidSubmit, validationBehaviorConfig, submitSource, formProps, flags, defaultFormId, }: FormInit<FormInputData, FormOutputData>) => FormScope<FormInputData>;
declare const scopeFormScope: (parentForm: FormScope<unknown>, prefix: string) => FormScope<unknown>;

@@ -344,3 +361,7 @@

declare const getFormId: (state: FormStoreValue) => string;
declare const getFormProps: (state: FormStoreValue) => StoreFormProps;
declare const getFormIdOption: (state: FormStoreValue) => string | undefined;
declare const getFormProps: (state: FormStoreValue) => {
id: string;
action?: string;
};
declare const getFormAction: (state: FormStoreValue) => string | undefined;

@@ -383,2 +404,2 @@

export { AllProps, BeforeSubmitApi, CreateValidatorArg, DomSubmitHandler, ErrorResult, FORM_ID_FIELD_NAME, FieldArrayValidationBehavior, FieldArrayValidationBehaviorConfig, FieldErrors, FieldSerializer, FieldValue, FieldValues, FormControl, FormScope, FormStore, FormStoreInit, FormStoreValue, GenericObject, Invalid, MultiFileInputValue, MutableImplStore, NativeValueByType, NumberInputValue, RefStore, ResolverQueue, ScopedValues, SingleFileInputValue, StateSubmitHandler, StoreFlags, StoreFormProps, SubmitStatus, SubmitterOptions, SuccessResult, Valid, ValidationBehavior, ValidationBehaviorConfig, ValidationErrorResponseData, ValidationResult, Validator, ValidatorData, ValidatorError, ValueOfInputType, createFormScope, createFormStateStore, createRefStore, createResolverQueue, createValidator, deleteFieldsWithPrefix, focusFirst, focusOrReport, getAllDirty, getAllErrors, getAllTouched, getArrayUpdateKey, getCheckboxChecked, getElementsWithNames, getFieldArrayKeys, getFieldDefaultValue, getFieldDirty, getFieldError, getFieldTouched, getFieldValue, getFormAction, getFormControlValue, getFormId, getFormProps, getNextCheckboxValue, getNextNativeValue, getOriginalObject, getRadioChecked, isEvent, isFormControl, isValidationErrorResponse, moveFieldArrayKeys, objectFromPathEntries, onNativeBlur, onNativeChange, preprocessFormData, registerFormElementEvents, renameFlatFieldStateKeys, scopeFormScope, setFormControlValue, sortByPosition, toArrayBehavior };
export { AllProps, BeforeSubmitApi, CreateValidatorArg, DomSubmitHandler, ErrorResult, FORM_ID_FIELD_NAME, FieldArrayValidationBehavior, FieldArrayValidationBehaviorConfig, FieldErrors, FieldSerializer, FieldValue, FieldValues, FormControl, FormScope, FormStore, FormStoreInit, FormStoreValue, GenericObject, Invalid, MultiFileInputValue, MutableImplStore, NativeValueByType, NumberInputValue, RefStore, ResolverQueue, ScopedValues, SingleFileInputValue, StateSubmitHandler, StoreFlags, StoreFormProps, SubmitStatus, SubmitterOptions, SuccessResult, Valid, ValidationBehavior, ValidationBehaviorConfig, ValidationErrorResponseData, ValidationResult, Validator, ValidatorData, ValidatorError, ValueOfInputType, createFormScope, createFormStateStore, createRefStore, createResolverQueue, createValidator, deleteFieldsWithPrefix, focusFirst, focusOrReport, getAllDirty, getAllErrors, getAllTouched, getArrayUpdateKey, getCheckboxChecked, getElementsWithNames, getFieldArrayKeys, getFieldDefaultValue, getFieldDirty, getFieldError, getFieldTouched, getFieldValue, getFormAction, getFormControlValue, getFormId, getFormIdOption, getFormProps, getNextCheckboxValue, getNextNativeValue, getOriginalObject, getRadioChecked, isEvent, isFormControl, isValidationErrorResponse, moveFieldArrayKeys, objectFromPathEntries, onNativeBlur, onNativeChange, preprocessFormData, registerFormElementEvents, renameFlatFieldStateKeys, scopeFormScope, setFormControlValue, sortByPosition, toArrayBehavior };

@@ -115,4 +115,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;

};
var getFormId = (state) => state.formProps.id;
var getFormProps = (state) => state.formProps;
var getFormId = (state) => state.formProps.id ?? state.defaultFormId;
var getFormIdOption = (state) => state.formProps.id;
var getFormProps = (state) => ({
...state.formProps,
id: getFormId(state)
});
var getFormAction = (state) => state.formProps.action;

@@ -571,3 +575,4 @@

flags,
serverValidationErrors = {}
serverValidationErrors = {},
defaultFormId
}) => create()(

@@ -587,3 +592,7 @@ immer((set, get) => ({

submitSource,
formProps,
formProps: {
...formProps,
id: formProps.id
},
defaultFormId,
flags,

@@ -798,2 +807,36 @@ /////// Validation

let result = void 0;
const runSubmission = async (data) => {
try {
let response;
if (get().submitSource === "state") {
response = await mutableImplStore.onSubmit(data, submitterOptions);
} else {
if (!formData)
throw new Error(
"Missing form data. This is likely a bug in RVF"
);
response = await mutableImplStore.onSubmit(
data,
formData,
submitterOptions
);
}
try {
await mutableImplStore.onSubmitSuccess?.(response);
} finally {
set((state) => {
state.submitStatus = "success";
});
}
} catch (err) {
try {
await mutableImplStore.onSubmitFailure?.(err);
} finally {
set((state) => {
state.submitStatus = "error";
});
}
}
};
let submitted = false;
try {

@@ -820,2 +863,6 @@ await mutableImplStore.onBeforeSubmit?.({

},
performSubmit: async (data) => {
submitted = true;
await runSubmission(data);
},
submitterOptions

@@ -836,2 +883,4 @@ });

}
if (submitted)
return;
if (!result)

@@ -857,34 +906,3 @@ result = await doValidation();

}
try {
let response;
if (get().submitSource === "state") {
response = await mutableImplStore.onSubmit(
result.data,
submitterOptions
);
} else {
if (!formData)
throw new Error("Missing form data. This is likely a bug in RVF");
response = await mutableImplStore.onSubmit(
result.data,
formData,
submitterOptions
);
}
try {
await mutableImplStore.onSubmitSuccess?.(response);
} finally {
set((state) => {
state.submitStatus = "success";
});
}
} catch (err) {
try {
await mutableImplStore.onSubmitFailure?.(err);
} finally {
set((state) => {
state.submitStatus = "error";
});
}
}
await runSubmission(result.data);
},

@@ -901,3 +919,6 @@ /////// Actions

state.validationBehaviorConfig = validationBehaviorConfig2;
state.formProps = formProps2;
state.formProps = {
...formProps2,
id: formProps2.id ?? state.formProps.id
};
state.flags = flags2;

@@ -1608,3 +1629,4 @@ });

formProps,
flags
flags,
defaultFormId
}) => {

@@ -1636,3 +1658,4 @@ const transientFieldRefs = createRefStore();

formProps,
flags
flags,
defaultFormId
});

@@ -1735,2 +1758,3 @@ const subformCache = /* @__PURE__ */ new Map();

getFormId,
getFormIdOption,
getFormProps,

@@ -1737,0 +1761,0 @@ getNextCheckboxValue,

{
"name": "@rvf/core",
"version": "6.1.4",
"version": "6.3.0",
"description": "Easy, predictable form state management for React",

@@ -5,0 +5,0 @@ "main": "./dist/index.cjs.js",

@@ -11,2 +11,2 @@ # RVF Core

The API of this package is not currently stable and does not follow semver. The version reflects the current
version of the other RVF pacakges. Eventually this API will be stablized for you to make your own RVF adapters.
version of the other RVF packages. Eventually this API will be stablized for you to make your own RVF adapters.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc