mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
feat(web/input): textarea row
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
|||||||
IColorInput,
|
IColorInput,
|
||||||
OptionValue,
|
OptionValue,
|
||||||
IDateInput,
|
IDateInput,
|
||||||
|
ITextarea,
|
||||||
} from '../../interfaces/dialog';
|
} from '../../interfaces/dialog';
|
||||||
import InputField from './components/fields/input';
|
import InputField from './components/fields/input';
|
||||||
import CheckboxField from './components/fields/checkbox';
|
import CheckboxField from './components/fields/checkbox';
|
||||||
@@ -21,10 +22,11 @@ import SliderField from './components/fields/slider';
|
|||||||
import { useFieldArray, useForm } from 'react-hook-form';
|
import { useFieldArray, useForm } from 'react-hook-form';
|
||||||
import ColorField from './components/fields/color';
|
import ColorField from './components/fields/color';
|
||||||
import DateField from './components/fields/date';
|
import DateField from './components/fields/date';
|
||||||
|
import TextareaField from './components/fields/textarea';
|
||||||
|
|
||||||
export interface InputProps {
|
export interface InputProps {
|
||||||
heading: string;
|
heading: string;
|
||||||
rows: Array<IInput | ICheckbox | ISelect | INumber | ISlider | IColorInput | IDateInput>;
|
rows: Array<IInput | ICheckbox | ISelect | INumber | ISlider | IColorInput | IDateInput | ITextarea>;
|
||||||
options?: {
|
options?: {
|
||||||
allowCancel?: boolean;
|
allowCancel?: boolean;
|
||||||
};
|
};
|
||||||
@@ -145,6 +147,13 @@ const InputDialog: React.FC = () => {
|
|||||||
{row.type === 'date' || row.type === 'date-range' ? (
|
{row.type === 'date' || row.type === 'date-range' ? (
|
||||||
<DateField control={form.control} row={row} index={index} />
|
<DateField control={form.control} row={row} index={index} />
|
||||||
) : null}
|
) : null}
|
||||||
|
{row.type === 'textarea' && (
|
||||||
|
<TextareaField
|
||||||
|
register={form.register(`test.${index}.value`, { required: row.required })}
|
||||||
|
row={row}
|
||||||
|
index={index}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
31
web/src/features/dialog/components/fields/textarea.tsx
Normal file
31
web/src/features/dialog/components/fields/textarea.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { Textarea } from '@mantine/core';
|
||||||
|
import { UseFormRegisterReturn } from 'react-hook-form';
|
||||||
|
import { ITextarea } from '../../../../interfaces/dialog';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
register: UseFormRegisterReturn;
|
||||||
|
row: ITextarea;
|
||||||
|
index: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TextareaField: React.FC<Props> = (props) => {
|
||||||
|
return (
|
||||||
|
<Textarea
|
||||||
|
{...props.register}
|
||||||
|
defaultValue={props.row.default}
|
||||||
|
label={props.row.label}
|
||||||
|
description={props.row.description}
|
||||||
|
icon={props.row.icon && <FontAwesomeIcon icon={props.row.icon} fixedWidth />}
|
||||||
|
placeholder={props.row.placeholder}
|
||||||
|
disabled={props.row.disabled}
|
||||||
|
withAsterisk={props.row.required}
|
||||||
|
autosize={props.row.autosize}
|
||||||
|
minRows={props.row.min}
|
||||||
|
maxRows={props.row.max}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TextareaField;
|
||||||
@@ -81,3 +81,17 @@ export interface IDateInput {
|
|||||||
max?: string;
|
max?: string;
|
||||||
icon?: IconProp;
|
icon?: IconProp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ITextarea {
|
||||||
|
type: 'textarea';
|
||||||
|
label: string;
|
||||||
|
default?: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
description?: string;
|
||||||
|
required?: boolean;
|
||||||
|
placeholder?: string;
|
||||||
|
icon?: IconProp;
|
||||||
|
autosize?: boolean;
|
||||||
|
min?: number;
|
||||||
|
max?: number;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user