mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { NumberInput } from '@mantine/core';
|
|
import { INumber } from '../../../../typings/dialog';
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
import { Control, useController } from 'react-hook-form';
|
|
import { FormValues } from '../../InputDialog';
|
|
|
|
interface Props {
|
|
row: INumber;
|
|
index: number;
|
|
control: Control<FormValues>;
|
|
}
|
|
|
|
const NumberField: React.FC<Props> = (props) => {
|
|
const controller = useController({
|
|
name: `test.${props.index}.value`,
|
|
control: props.control,
|
|
defaultValue: props.row.default,
|
|
rules: { required: props.row.required },
|
|
});
|
|
|
|
return (
|
|
<NumberInput
|
|
value={controller.field.value}
|
|
name={controller.field.name}
|
|
ref={controller.field.ref}
|
|
onBlur={controller.field.onBlur}
|
|
onChange={controller.field.onChange}
|
|
label={props.row.label}
|
|
description={props.row.description}
|
|
defaultValue={props.row.default}
|
|
min={props.row.min}
|
|
max={props.row.max}
|
|
disabled={props.row.disabled}
|
|
icon={props.row.icon && <FontAwesomeIcon icon={props.row.icon} fixedWidth />}
|
|
withAsterisk={props.row.required}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default NumberField;
|