@juantroconisf/lib 3.5.6 → 3.5.7
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 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -91,7 +91,7 @@ type UXProps<O extends StateType> = Record<keyof O, {
|
|
|
91
91
|
errorMessage: string;
|
|
92
92
|
}>;
|
|
93
93
|
type RegisterHandleFunc<O extends StateType> = (id: keyof O) => ComponentInputProps<O>;
|
|
94
|
-
type ValidateInputFunc<O extends StateType> = (id: keyof O, value: O[keyof O]) => any;
|
|
94
|
+
type ValidateInputFunc<O extends StateType> = (id: keyof O, value: O[keyof O], isTouched?: boolean) => any;
|
|
95
95
|
interface InputRegisterProps<O extends StateType, K extends keyof O, V extends unknown = string> extends ComponentInputProps<O> {
|
|
96
96
|
onValueChange: (value: O[K]) => void;
|
|
97
97
|
value: V;
|
package/dist/index.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ type UXProps<O extends StateType> = Record<keyof O, {
|
|
|
91
91
|
errorMessage: string;
|
|
92
92
|
}>;
|
|
93
93
|
type RegisterHandleFunc<O extends StateType> = (id: keyof O) => ComponentInputProps<O>;
|
|
94
|
-
type ValidateInputFunc<O extends StateType> = (id: keyof O, value: O[keyof O]) => any;
|
|
94
|
+
type ValidateInputFunc<O extends StateType> = (id: keyof O, value: O[keyof O], isTouched?: boolean) => any;
|
|
95
95
|
interface InputRegisterProps<O extends StateType, K extends keyof O, V extends unknown = string> extends ComponentInputProps<O> {
|
|
96
96
|
onValueChange: (value: O[K]) => void;
|
|
97
97
|
value: V;
|
package/dist/index.js
CHANGED
|
@@ -294,8 +294,8 @@ 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
|
);
|
|
297
|
-
const validateInput = (id, value) => {
|
|
298
|
-
const isTouched = touched.current[id], requirements = validations?.[id];
|
|
297
|
+
const validateInput = (id, value, isInputTouched) => {
|
|
298
|
+
const isTouched = isInputTouched === void 0 ? touched.current[id] : isInputTouched, requirements = validations?.[id];
|
|
299
299
|
const [uiErrors] = [
|
|
300
300
|
{
|
|
301
301
|
ref: errors2,
|
|
@@ -331,7 +331,7 @@ function useForm(initialState, { validations, errorMessages } = {}) {
|
|
|
331
331
|
id,
|
|
332
332
|
value: true
|
|
333
333
|
});
|
|
334
|
-
validateInput(id, state[id]);
|
|
334
|
+
validateInput(id, state[id], true);
|
|
335
335
|
}, onValueChange = (id, value) => {
|
|
336
336
|
setState((prev) => handleNestedChange({ state: prev, id, value }));
|
|
337
337
|
validateInput(id, value);
|
package/dist/index.mjs
CHANGED
|
@@ -274,8 +274,8 @@ 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
|
);
|
|
277
|
-
const validateInput = (id, value) => {
|
|
278
|
-
const isTouched = touched.current[id], requirements = validations?.[id];
|
|
277
|
+
const validateInput = (id, value, isInputTouched) => {
|
|
278
|
+
const isTouched = isInputTouched === void 0 ? touched.current[id] : isInputTouched, requirements = validations?.[id];
|
|
279
279
|
const [uiErrors] = [
|
|
280
280
|
{
|
|
281
281
|
ref: errors2,
|
|
@@ -311,7 +311,7 @@ function useForm(initialState, { validations, errorMessages } = {}) {
|
|
|
311
311
|
id,
|
|
312
312
|
value: true
|
|
313
313
|
});
|
|
314
|
-
validateInput(id, state[id]);
|
|
314
|
+
validateInput(id, state[id], true);
|
|
315
315
|
}, onValueChange = (id, value) => {
|
|
316
316
|
setState((prev) => handleNestedChange({ state: prev, id, value }));
|
|
317
317
|
validateInput(id, value);
|