@juantroconisf/lib 2.2.7 → 2.2.9
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -4
- package/dist/index.mjs +3 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ChangeEvent } from 'react';
|
|
2
|
+
import { ChangeEvent, FocusEvent } from 'react';
|
|
3
3
|
import { InputProps } from '@nextui-org/react';
|
|
4
4
|
|
|
5
5
|
type ValidatorFunction<T, U> = (val: T, ...args: U[]) => boolean;
|
|
@@ -39,7 +39,7 @@ interface RegisterInputProps extends ValidationProps {
|
|
|
39
39
|
|
|
40
40
|
declare function useFormChange<InitialObj extends object>(initialObj: InitialObj): {
|
|
41
41
|
onChange: ({ target: { id, value }, }: ChangeEvent<HTMLInputElement>) => void;
|
|
42
|
-
onBlur: ({ target: { id } }:
|
|
42
|
+
onBlur: ({ target: { id } }: FocusEvent<HTMLInputElement>) => void;
|
|
43
43
|
state: InitialObj;
|
|
44
44
|
setState: react.Dispatch<react.SetStateAction<InitialObj>>;
|
|
45
45
|
register: <K extends keyof InitialObj>(id: K, validations?: ValidatorParams, errorMessages?: ValidatorErrorMessage) => RegisterInputProps;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ChangeEvent } from 'react';
|
|
2
|
+
import { ChangeEvent, FocusEvent } from 'react';
|
|
3
3
|
import { InputProps } from '@nextui-org/react';
|
|
4
4
|
|
|
5
5
|
type ValidatorFunction<T, U> = (val: T, ...args: U[]) => boolean;
|
|
@@ -39,7 +39,7 @@ interface RegisterInputProps extends ValidationProps {
|
|
|
39
39
|
|
|
40
40
|
declare function useFormChange<InitialObj extends object>(initialObj: InitialObj): {
|
|
41
41
|
onChange: ({ target: { id, value }, }: ChangeEvent<HTMLInputElement>) => void;
|
|
42
|
-
onBlur: ({ target: { id } }:
|
|
42
|
+
onBlur: ({ target: { id } }: FocusEvent<HTMLInputElement>) => void;
|
|
43
43
|
state: InitialObj;
|
|
44
44
|
setState: react.Dispatch<react.SetStateAction<InitialObj>>;
|
|
45
45
|
register: <K extends keyof InitialObj>(id: K, validations?: ValidatorParams, errorMessages?: ValidatorErrorMessage) => RegisterInputProps;
|
package/dist/index.js
CHANGED
|
@@ -57,7 +57,7 @@ function handleNestedChange({
|
|
|
57
57
|
var allToValue = (obj, value) => Object.keys(obj).reduce(
|
|
58
58
|
(acc, key) => ({
|
|
59
59
|
...acc,
|
|
60
|
-
[key]:
|
|
60
|
+
[key]: value
|
|
61
61
|
}),
|
|
62
62
|
{}
|
|
63
63
|
);
|
|
@@ -69,8 +69,7 @@ var regex = {
|
|
|
69
69
|
var map = {
|
|
70
70
|
string: (val) => Boolean(val),
|
|
71
71
|
number: (val) => String(val) !== "",
|
|
72
|
-
|
|
73
|
-
object: (val) => Object.keys(val).length > 0
|
|
72
|
+
object: (val) => val !== null && Object.keys(val).length > 0
|
|
74
73
|
};
|
|
75
74
|
var requiredValidation = (value) => Array.isArray(value) ? value.length > 0 : map[typeof value](value);
|
|
76
75
|
var errors = {
|
|
@@ -198,7 +197,7 @@ function useFormChange(initialObj) {
|
|
|
198
197
|
return {
|
|
199
198
|
id,
|
|
200
199
|
onChange,
|
|
201
|
-
onBlur
|
|
200
|
+
onBlur,
|
|
202
201
|
value,
|
|
203
202
|
isInvalid: hasValidations ? !inputValidations.isValid : false,
|
|
204
203
|
errorMessage: hasValidations ? inputValidations.validationProps.errorMessage : ""
|
package/dist/index.mjs
CHANGED
|
@@ -39,7 +39,7 @@ function handleNestedChange({
|
|
|
39
39
|
var allToValue = (obj, value) => Object.keys(obj).reduce(
|
|
40
40
|
(acc, key) => ({
|
|
41
41
|
...acc,
|
|
42
|
-
[key]:
|
|
42
|
+
[key]: value
|
|
43
43
|
}),
|
|
44
44
|
{}
|
|
45
45
|
);
|
|
@@ -51,8 +51,7 @@ var regex = {
|
|
|
51
51
|
var map = {
|
|
52
52
|
string: (val) => Boolean(val),
|
|
53
53
|
number: (val) => String(val) !== "",
|
|
54
|
-
|
|
55
|
-
object: (val) => Object.keys(val).length > 0
|
|
54
|
+
object: (val) => val !== null && Object.keys(val).length > 0
|
|
56
55
|
};
|
|
57
56
|
var requiredValidation = (value) => Array.isArray(value) ? value.length > 0 : map[typeof value](value);
|
|
58
57
|
var errors = {
|
|
@@ -180,7 +179,7 @@ function useFormChange(initialObj) {
|
|
|
180
179
|
return {
|
|
181
180
|
id,
|
|
182
181
|
onChange,
|
|
183
|
-
onBlur
|
|
182
|
+
onBlur,
|
|
184
183
|
value,
|
|
185
184
|
isInvalid: hasValidations ? !inputValidations.isValid : false,
|
|
186
185
|
errorMessage: hasValidations ? inputValidations.validationProps.errorMessage : ""
|