Initial import
This commit is contained in:
22
src/components/inputs/primitives/input/plugins/input.plugin.ts
Executable file
22
src/components/inputs/primitives/input/plugins/input.plugin.ts
Executable file
@@ -0,0 +1,22 @@
|
||||
import type { PropsPlugin } from '../../../../../types/component-plugin';
|
||||
import type { InputUIProps } from '../InputUI';
|
||||
import type { InputValidator } from '../types';
|
||||
|
||||
export const trimInputValuePlugin =
|
||||
(): PropsPlugin<InputUIProps> =>
|
||||
(props) => ({
|
||||
...props,
|
||||
onBlur: (event) => {
|
||||
event.target.value = event.target.value.trim();
|
||||
props.onBlur?.(event);
|
||||
},
|
||||
});
|
||||
|
||||
export const createValidInputPlugin =
|
||||
(onValid: InputValidator) =>
|
||||
({ nextValue, previousValue, timing }: Parameters<InputValidator>[0]) =>
|
||||
onValid({
|
||||
nextValue,
|
||||
previousValue,
|
||||
timing,
|
||||
});
|
||||
Reference in New Issue
Block a user