|
|
@ -18,14 +18,14 @@ const useFormUtils = < |
|
|
|
|
|
|
|
|
|
|
|
const setMessage = useCallback( |
|
|
|
const setMessage = useCallback( |
|
|
|
(key: keyof M, message?: Message) => { |
|
|
|
(key: keyof M, message?: Message) => { |
|
|
|
messageGroupRef.current.setMessage?.call(null, String(key), message); |
|
|
|
messageGroupRef?.current?.setMessage?.call(null, String(key), message); |
|
|
|
}, |
|
|
|
}, |
|
|
|
[messageGroupRef], |
|
|
|
[messageGroupRef], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const setMessageRe = useCallback( |
|
|
|
const setMessageRe = useCallback( |
|
|
|
(re: RegExp, message?: Message) => { |
|
|
|
(re: RegExp, message?: Message) => { |
|
|
|
messageGroupRef.current.setMessageRe?.call(null, re, message); |
|
|
|
messageGroupRef?.current?.setMessageRe?.call(null, re, message); |
|
|
|
}, |
|
|
|
}, |
|
|
|
[messageGroupRef], |
|
|
|
[messageGroupRef], |
|
|
|
); |
|
|
|
); |
|
|
@ -73,6 +73,13 @@ const useFormUtils = < |
|
|
|
[setValidity], |
|
|
|
[setValidity], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const buildInputUnmountFunction = useCallback( |
|
|
|
|
|
|
|
(key: keyof M) => () => { |
|
|
|
|
|
|
|
unsetKey(key); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[unsetKey], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const isFormInvalid = useMemo( |
|
|
|
const isFormInvalid = useMemo( |
|
|
|
() => Object.values(formValidity).some((isInputValid) => !isInputValid), |
|
|
|
() => Object.values(formValidity).some((isInputValid) => !isInputValid), |
|
|
|
[formValidity], |
|
|
|
[formValidity], |
|
|
@ -81,6 +88,7 @@ const useFormUtils = < |
|
|
|
return { |
|
|
|
return { |
|
|
|
buildFinishInputTestBatchFunction, |
|
|
|
buildFinishInputTestBatchFunction, |
|
|
|
buildInputFirstRenderFunction, |
|
|
|
buildInputFirstRenderFunction, |
|
|
|
|
|
|
|
buildInputUnmountFunction, |
|
|
|
formValidity, |
|
|
|
formValidity, |
|
|
|
isFormInvalid, |
|
|
|
isFormInvalid, |
|
|
|
setFormValidity, |
|
|
|
setFormValidity, |
|
|
|