update basic number input
This commit is contained in:
parent
d9636c4fb7
commit
5b6cf900e0
4 changed files with 39 additions and 15 deletions
25
src/components/Table/Inputs/NumberInput.tsx
Normal file
25
src/components/Table/Inputs/NumberInput.tsx
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import React, { type ChangeEventHandler } from 'react';
|
||||
|
||||
interface Props {
|
||||
onChange: (value: string | string[] | number | number[] | null) => void;
|
||||
keyData: string;
|
||||
}
|
||||
|
||||
export default function NumberInput({ keyData, onChange }: Props): JSX.Element {
|
||||
const onSelectChange: ChangeEventHandler<HTMLInputElement> = ({
|
||||
target,
|
||||
}): void => {
|
||||
const value = parseInt(target.value);
|
||||
onChange(isNaN(value) ? null : value);
|
||||
};
|
||||
|
||||
return (
|
||||
<input
|
||||
name={`number-input-${keyData}`}
|
||||
id="foo"
|
||||
type="number"
|
||||
placeholder="1"
|
||||
onChange={onSelectChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue