mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 23:16:03 +01:00
feat(web/input): required fields
This commit is contained in:
@@ -11,7 +11,13 @@ interface Props {
|
||||
|
||||
const CheckboxField: React.FC<Props> = (props) => {
|
||||
return (
|
||||
<Checkbox {...props.register} sx={{ display: 'flex' }} label={props.row.label} defaultChecked={props.row.checked} />
|
||||
<Checkbox
|
||||
{...props.register}
|
||||
sx={{ display: 'flex' }}
|
||||
required={props.row.required}
|
||||
label={props.row.label}
|
||||
defaultChecked={props.row.checked}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ const ColorField: React.FC<Props> = (props) => {
|
||||
name: `test.${props.index}.value`,
|
||||
control: props.control,
|
||||
defaultValue: props.row.default,
|
||||
rules: { required: props.row.required },
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -29,6 +30,7 @@ const ColorField: React.FC<Props> = (props) => {
|
||||
disabled={props.row.disabled}
|
||||
defaultValue={props.row.default}
|
||||
format={props.row.format}
|
||||
withAsterisk={props.row.required}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -30,6 +30,7 @@ const InputField: React.FC<Props> = (props) => {
|
||||
icon={props.row.icon && <FontAwesomeIcon icon={props.row.icon} fixedWidth />}
|
||||
placeholder={props.row.placeholder}
|
||||
disabled={props.row.disabled}
|
||||
withAsterisk={props.row.required}
|
||||
/>
|
||||
) : (
|
||||
<PasswordInput
|
||||
@@ -40,6 +41,7 @@ const InputField: React.FC<Props> = (props) => {
|
||||
icon={props.row.icon && <FontAwesomeIcon icon={props.row.icon} fixedWidth />}
|
||||
placeholder={props.row.placeholder}
|
||||
disabled={props.row.disabled}
|
||||
withAsterisk={props.row.required}
|
||||
visibilityToggleIcon={({ reveal, size }) => (
|
||||
<FontAwesomeIcon
|
||||
icon={reveal ? 'eye-slash' : 'eye'}
|
||||
|
||||
@@ -16,6 +16,7 @@ const NumberField: React.FC<Props> = (props) => {
|
||||
name: `test.${props.index}.value`,
|
||||
control: props.control,
|
||||
defaultValue: props.row.default,
|
||||
rules: { required: props.row.required },
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -32,6 +33,7 @@ const NumberField: React.FC<Props> = (props) => {
|
||||
max={props.row.max}
|
||||
disabled={props.row.disabled}
|
||||
icon={props.row.icon && <FontAwesomeIcon icon={props.row.icon} fixedWidth />}
|
||||
withAsterisk={props.row.required}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@ const SelectField: React.FC<Props> = (props) => {
|
||||
name: `test.${props.index}.value`,
|
||||
control: props.control,
|
||||
defaultValue: props.row.default,
|
||||
rules: { required: props.row.required },
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -28,6 +29,7 @@ const SelectField: React.FC<Props> = (props) => {
|
||||
disabled={props.row.disabled}
|
||||
label={props.row.label}
|
||||
description={props.row.description}
|
||||
withAsterisk={props.row.required}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user