|
|
@ -20,6 +20,7 @@ type InputWithRefOptionalPropsWithDefault< |
|
|
|
> = { |
|
|
|
> = { |
|
|
|
createInputOnChangeHandlerOptions?: CreateInputOnChangeHandlerOptions<TypeName>; |
|
|
|
createInputOnChangeHandlerOptions?: CreateInputOnChangeHandlerOptions<TypeName>; |
|
|
|
required?: boolean; |
|
|
|
required?: boolean; |
|
|
|
|
|
|
|
valueKey?: string; |
|
|
|
valueType?: TypeName; |
|
|
|
valueType?: TypeName; |
|
|
|
}; |
|
|
|
}; |
|
|
|
type InputWithRefOptionalPropsWithoutDefault = { |
|
|
|
type InputWithRefOptionalPropsWithoutDefault = { |
|
|
@ -57,6 +58,7 @@ const INPUT_WITH_REF_DEFAULT_PROPS: Required< |
|
|
|
InputWithRefOptionalPropsWithoutDefault = { |
|
|
|
InputWithRefOptionalPropsWithoutDefault = { |
|
|
|
createInputOnChangeHandlerOptions: {}, |
|
|
|
createInputOnChangeHandlerOptions: {}, |
|
|
|
required: false, |
|
|
|
required: false, |
|
|
|
|
|
|
|
valueKey: 'value', |
|
|
|
valueType: 'string', |
|
|
|
valueType: 'string', |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -71,6 +73,7 @@ const InputWithRef = forwardRef( |
|
|
|
inputTestBatch, |
|
|
|
inputTestBatch, |
|
|
|
onFirstRender, |
|
|
|
onFirstRender, |
|
|
|
required: isRequired = INPUT_WITH_REF_DEFAULT_PROPS.required, |
|
|
|
required: isRequired = INPUT_WITH_REF_DEFAULT_PROPS.required, |
|
|
|
|
|
|
|
valueKey = INPUT_WITH_REF_DEFAULT_PROPS.valueKey, |
|
|
|
valueType = INPUT_WITH_REF_DEFAULT_PROPS.valueType as TypeName, |
|
|
|
valueType = INPUT_WITH_REF_DEFAULT_PROPS.valueType as TypeName, |
|
|
|
}: InputWithRefProps<TypeName, InputComponent>, |
|
|
|
}: InputWithRefProps<TypeName, InputComponent>, |
|
|
|
ref: ForwardedRef<InputForwardedRefContent<TypeName>>, |
|
|
|
ref: ForwardedRef<InputForwardedRefContent<TypeName>>, |
|
|
@ -123,17 +126,9 @@ const InputWithRef = forwardRef( |
|
|
|
})), |
|
|
|
})), |
|
|
|
[initOnBlur, testInput], |
|
|
|
[initOnBlur, testInput], |
|
|
|
); |
|
|
|
); |
|
|
|
const onFocus = useMemo<InputBaseProps['onFocus']>( |
|
|
|
const onChange = useMemo( |
|
|
|
() => |
|
|
|
() => |
|
|
|
initOnFocus ?? |
|
|
|
createInputOnChangeHandler<TypeName>({ |
|
|
|
(inputTestBatch && |
|
|
|
|
|
|
|
(() => { |
|
|
|
|
|
|
|
inputTestBatch.defaults?.onSuccess?.call(null, { append: {} }); |
|
|
|
|
|
|
|
})), |
|
|
|
|
|
|
|
[initOnFocus, inputTestBatch], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onChange = createInputOnChangeHandler<TypeName>({ |
|
|
|
|
|
|
|
postSet: (...args) => { |
|
|
|
postSet: (...args) => { |
|
|
|
setIsChangedByUser(true); |
|
|
|
setIsChangedByUser(true); |
|
|
|
initOnChange?.call(null, ...args); |
|
|
|
initOnChange?.call(null, ...args); |
|
|
@ -142,7 +137,24 @@ const InputWithRef = forwardRef( |
|
|
|
set: setValue, |
|
|
|
set: setValue, |
|
|
|
setType: valueType, |
|
|
|
setType: valueType, |
|
|
|
...restCreateInputOnChangeHandlerOptions, |
|
|
|
...restCreateInputOnChangeHandlerOptions, |
|
|
|
}); |
|
|
|
}), |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
initOnChange, |
|
|
|
|
|
|
|
postSetAppend, |
|
|
|
|
|
|
|
restCreateInputOnChangeHandlerOptions, |
|
|
|
|
|
|
|
setValue, |
|
|
|
|
|
|
|
valueType, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
const onFocus = useMemo<InputBaseProps['onFocus']>( |
|
|
|
|
|
|
|
() => |
|
|
|
|
|
|
|
initOnFocus ?? |
|
|
|
|
|
|
|
(inputTestBatch && |
|
|
|
|
|
|
|
(() => { |
|
|
|
|
|
|
|
inputTestBatch.defaults?.onSuccess?.call(null, { append: {} }); |
|
|
|
|
|
|
|
})), |
|
|
|
|
|
|
|
[initOnFocus, inputTestBatch], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (isFirstRender) { |
|
|
|
if (isFirstRender) { |
|
|
@ -167,7 +179,7 @@ const InputWithRef = forwardRef( |
|
|
|
onChange, |
|
|
|
onChange, |
|
|
|
onFocus, |
|
|
|
onFocus, |
|
|
|
required: isRequired, |
|
|
|
required: isRequired, |
|
|
|
value: inputValue, |
|
|
|
[valueKey]: inputValue, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|