mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 07:26:02 +01:00
37 lines
1019 B
TypeScript
37 lines
1019 B
TypeScript
import { Select } from '@mantine/core';
|
|
import { ISelect } from '../../../../interfaces/dialog';
|
|
import { Control, FieldValues, useController, UseFormRegisterReturn, UseFormSetValue } from 'react-hook-form';
|
|
import { FormValues } from '../../InputDialog';
|
|
|
|
interface Props {
|
|
row: ISelect;
|
|
index: number;
|
|
control: Control<FormValues>;
|
|
}
|
|
|
|
const SelectField: 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 (
|
|
<Select
|
|
data={props.row.options}
|
|
value={controller.field.value}
|
|
name={controller.field.name}
|
|
ref={controller.field.ref}
|
|
onBlur={controller.field.onBlur}
|
|
onChange={controller.field.onChange}
|
|
disabled={props.row.disabled}
|
|
label={props.row.label}
|
|
description={props.row.description}
|
|
withAsterisk={props.row.required}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default SelectField;
|