mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
committed by
GitHub
parent
ada2a35c0b
commit
8a7e0f89d2
@@ -14,6 +14,12 @@ export const debugInput = () => {
|
|||||||
placeholder: '420',
|
placeholder: '420',
|
||||||
description: 'Description that tells you what this input field does',
|
description: 'Description that tells you what this input field does',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'time',
|
||||||
|
format: '12',
|
||||||
|
label: 'Locker Time',
|
||||||
|
description: 'Description that tells you what this input field does',
|
||||||
|
},
|
||||||
{ type: 'checkbox', label: 'Some checkbox' },
|
{ type: 'checkbox', label: 'Some checkbox' },
|
||||||
{ type: 'input', label: 'Locker PIN', password: true, icon: 'lock' },
|
{ type: 'input', label: 'Locker PIN', password: true, icon: 'lock' },
|
||||||
{ type: 'checkbox', label: 'Some other checkbox', checked: true },
|
{ type: 'checkbox', label: 'Some other checkbox', checked: true },
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ const InputDialog: React.FC = () => {
|
|||||||
{
|
{
|
||||||
value:
|
value:
|
||||||
row.type !== 'checkbox'
|
row.type !== 'checkbox'
|
||||||
? row.type === 'date' || row.type === 'date-range'
|
? row.type === 'date' || row.type === 'date-range' || row.type === 'time'
|
||||||
? // Set date to current one if default is set to true
|
? // Set date to current one if default is set to true
|
||||||
row.default === true
|
row.default === true
|
||||||
? new Date().getTime()
|
? new Date().getTime()
|
||||||
@@ -146,7 +146,7 @@ const InputDialog: React.FC = () => {
|
|||||||
{row.type === 'number' && <NumberField control={form.control} row={row} index={index} />}
|
{row.type === 'number' && <NumberField control={form.control} row={row} index={index} />}
|
||||||
{row.type === 'slider' && <SliderField control={form.control} row={row} index={index} />}
|
{row.type === 'slider' && <SliderField control={form.control} row={row} index={index} />}
|
||||||
{row.type === 'color' && <ColorField control={form.control} row={row} index={index} />}
|
{row.type === 'color' && <ColorField control={form.control} row={row} index={index} />}
|
||||||
{row.type === 'date' || row.type === 'date-range' ? (
|
{row.type === 'date' || row.type === 'date-range' || row.type === 'time' ? (
|
||||||
<DateField control={form.control} row={row} index={index} />
|
<DateField control={form.control} row={row} index={index} />
|
||||||
) : null}
|
) : null}
|
||||||
{row.type === 'textarea' && (
|
{row.type === 'textarea' && (
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { IDateInput } from '../../../../interfaces/dialog';
|
import { IDateInput } from '../../../../interfaces/dialog';
|
||||||
import { Control, useController } from 'react-hook-form';
|
import { Control, useController } from 'react-hook-form';
|
||||||
import { FormValues } from '../../InputDialog';
|
import { FormValues } from '../../InputDialog';
|
||||||
import { DatePicker, DateRangePicker } from '@mantine/dates';
|
import { DatePicker, DateRangePicker, TimeInput } from '@mantine/dates';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -19,7 +19,7 @@ const DateField: React.FC<Props> = (props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{props.row.type === 'date' ? (
|
{props.row.type === 'date' && (
|
||||||
<DatePicker
|
<DatePicker
|
||||||
value={controller.field.value ? new Date(controller.field.value) : controller.field.value}
|
value={controller.field.value ? new Date(controller.field.value) : controller.field.value}
|
||||||
name={controller.field.name}
|
name={controller.field.name}
|
||||||
@@ -38,8 +38,8 @@ const DateField: React.FC<Props> = (props) => {
|
|||||||
minDate={props.row.min ? new Date(props.row.min) : undefined}
|
minDate={props.row.min ? new Date(props.row.min) : undefined}
|
||||||
maxDate={props.row.max ? new Date(props.row.max) : undefined}
|
maxDate={props.row.max ? new Date(props.row.max) : undefined}
|
||||||
/>
|
/>
|
||||||
) : (
|
)}
|
||||||
props.row.type === 'date-range' && (
|
{props.row.type === 'date-range' && (
|
||||||
<DateRangePicker
|
<DateRangePicker
|
||||||
value={
|
value={
|
||||||
controller.field.value
|
controller.field.value
|
||||||
@@ -65,8 +65,25 @@ const DateField: React.FC<Props> = (props) => {
|
|||||||
minDate={props.row.min ? new Date(props.row.min) : undefined}
|
minDate={props.row.min ? new Date(props.row.min) : undefined}
|
||||||
maxDate={props.row.max ? new Date(props.row.max) : undefined}
|
maxDate={props.row.max ? new Date(props.row.max) : undefined}
|
||||||
/>
|
/>
|
||||||
)
|
)}
|
||||||
)}
|
|
||||||
|
{props.row.type === 'time' && (
|
||||||
|
<TimeInput
|
||||||
|
value={controller.field.value ? new Date(controller.field.value) : controller.field.value}
|
||||||
|
name={controller.field.name}
|
||||||
|
ref={controller.field.ref}
|
||||||
|
onBlur={controller.field.onBlur}
|
||||||
|
onChange={(date) => controller.field.onChange(date ? date.getTime() : null)}
|
||||||
|
label={props.row.label}
|
||||||
|
description={props.row.description}
|
||||||
|
placeholder={props.row.placeholder}
|
||||||
|
disabled={props.row.disabled}
|
||||||
|
format={props.row.format || "12"}
|
||||||
|
withAsterisk={props.row.required}
|
||||||
|
clearable={props.row.clearable}
|
||||||
|
icon={props.row.icon && <FontAwesomeIcon fixedWidth icon={props.row.icon} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -70,11 +70,12 @@ export interface IColorInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IDateInput {
|
export interface IDateInput {
|
||||||
type: 'date' | 'date-range';
|
type: 'date' | 'date-range' | 'time';
|
||||||
label: string;
|
label: string;
|
||||||
default?: string | [string, string] | true;
|
default?: string | [string, string] | true;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
format?: '12' | '24' | undefined;
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
clearable?: boolean;
|
clearable?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user