@juantroconisf/lib 3.5.5 → 3.5.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.
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +2 -1
- package/dist/index.mjs +2 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -70,7 +70,6 @@ interface FormChangeState<O extends StateType> {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
interface FormOptions<O extends StateType> {
|
|
73
|
-
state: O;
|
|
74
73
|
validations?: {
|
|
75
74
|
[key in keyof O]?: ValidatorParams;
|
|
76
75
|
};
|
|
@@ -130,6 +129,6 @@ interface UseFormChangeResponse<O extends StateType> {
|
|
|
130
129
|
|
|
131
130
|
declare function useFormChange<O extends StateType>({ state: initialState, validations, errorMessages, }: FormChangeState<O>): UseFormChangeResponse<O>;
|
|
132
131
|
|
|
133
|
-
declare function useForm<O extends StateType>(initialState: O, { validations, errorMessages }
|
|
132
|
+
declare function useForm<O extends StateType>(initialState: O, { validations, errorMessages }?: FormOptions<O>): UseFormChangeResponse<O>;
|
|
134
133
|
|
|
135
134
|
export { type BlurFunc, type ComponentInputProps, type FormChangeState, type FormOptions, type GetNestedValueByKey, type GetValidationFunc, type GetValidationResponse, type MapValidator, type NXErrorFunc, type NestedChangeProps, NextUIError, type PreservedKeys, type RegisterFunc, type RegisterHandleFunc, type RequiredValidationFunc, type StateType, type TouchedType, type UXProps, type UseFormChangeResponse, type UseValidationFunc, type ValidateInputFunc, type Validator, type ValidatorErrorMessage$1 as ValidatorErrorMessage, type ValidatorFunction, type ValidatorParams$1 as ValidatorParams, type ValidatorTypes, type ValueChangeFunc, useForm, useFormChange };
|
package/dist/index.d.ts
CHANGED
|
@@ -70,7 +70,6 @@ interface FormChangeState<O extends StateType> {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
interface FormOptions<O extends StateType> {
|
|
73
|
-
state: O;
|
|
74
73
|
validations?: {
|
|
75
74
|
[key in keyof O]?: ValidatorParams;
|
|
76
75
|
};
|
|
@@ -130,6 +129,6 @@ interface UseFormChangeResponse<O extends StateType> {
|
|
|
130
129
|
|
|
131
130
|
declare function useFormChange<O extends StateType>({ state: initialState, validations, errorMessages, }: FormChangeState<O>): UseFormChangeResponse<O>;
|
|
132
131
|
|
|
133
|
-
declare function useForm<O extends StateType>(initialState: O, { validations, errorMessages }
|
|
132
|
+
declare function useForm<O extends StateType>(initialState: O, { validations, errorMessages }?: FormOptions<O>): UseFormChangeResponse<O>;
|
|
134
133
|
|
|
135
134
|
export { type BlurFunc, type ComponentInputProps, type FormChangeState, type FormOptions, type GetNestedValueByKey, type GetValidationFunc, type GetValidationResponse, type MapValidator, type NXErrorFunc, type NestedChangeProps, NextUIError, type PreservedKeys, type RegisterFunc, type RegisterHandleFunc, type RequiredValidationFunc, type StateType, type TouchedType, type UXProps, type UseFormChangeResponse, type UseValidationFunc, type ValidateInputFunc, type Validator, type ValidatorErrorMessage$1 as ValidatorErrorMessage, type ValidatorFunction, type ValidatorParams$1 as ValidatorParams, type ValidatorTypes, type ValueChangeFunc, useForm, useFormChange };
|
package/dist/index.js
CHANGED
|
@@ -290,7 +290,7 @@ function useFormChange({
|
|
|
290
290
|
|
|
291
291
|
// src/hooks/useForm.tsx
|
|
292
292
|
var import_react2 = require("react");
|
|
293
|
-
function useForm(initialState, { validations, errorMessages }) {
|
|
293
|
+
function useForm(initialState, { validations, errorMessages } = {}) {
|
|
294
294
|
const [state, setState] = (0, import_react2.useState)(initialState), falseState = allToValue(state, false), touched = (0, import_react2.useRef)(falseState), errors2 = (0, import_react2.useRef)({ ...falseState }), realErrors = (0, import_react2.useRef)({ ...falseState }), { getValidation } = useValidation(), ux = (0, import_react2.useRef)(
|
|
295
295
|
allToValue(state, { isInvalid: false, errorMessage: "" })
|
|
296
296
|
);
|
|
@@ -331,6 +331,7 @@ function useForm(initialState, { validations, errorMessages }) {
|
|
|
331
331
|
id,
|
|
332
332
|
value: true
|
|
333
333
|
});
|
|
334
|
+
validateInput(id, state[id]);
|
|
334
335
|
}, onValueChange = (id, value) => {
|
|
335
336
|
setState((prev) => handleNestedChange({ state: prev, id, value }));
|
|
336
337
|
validateInput(id, value);
|
package/dist/index.mjs
CHANGED
|
@@ -270,7 +270,7 @@ function useFormChange({
|
|
|
270
270
|
|
|
271
271
|
// src/hooks/useForm.tsx
|
|
272
272
|
import { useState as useState2, useRef as useRef2 } from "react";
|
|
273
|
-
function useForm(initialState, { validations, errorMessages }) {
|
|
273
|
+
function useForm(initialState, { validations, errorMessages } = {}) {
|
|
274
274
|
const [state, setState] = useState2(initialState), falseState = allToValue(state, false), touched = useRef2(falseState), errors2 = useRef2({ ...falseState }), realErrors = useRef2({ ...falseState }), { getValidation } = useValidation(), ux = useRef2(
|
|
275
275
|
allToValue(state, { isInvalid: false, errorMessage: "" })
|
|
276
276
|
);
|
|
@@ -311,6 +311,7 @@ function useForm(initialState, { validations, errorMessages }) {
|
|
|
311
311
|
id,
|
|
312
312
|
value: true
|
|
313
313
|
});
|
|
314
|
+
validateInput(id, state[id]);
|
|
314
315
|
}, onValueChange = (id, value) => {
|
|
315
316
|
setState((prev) => handleNestedChange({ state: prev, id, value }));
|
|
316
317
|
validateInput(id, value);
|