2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-11-02 14:15:45 +00:00

Add icon to clear text input value

This commit is contained in:
Oliver Walters
2023-07-27 21:10:05 +10:00
parent b54a77baad
commit 00cbac5f06

View File

@@ -2,6 +2,7 @@ import { Alert, Checkbox, NumberInput, Select, TextInput } from '@mantine/core';
import { DateInput } from '@mantine/dates';
import { UseFormReturnType } from '@mantine/form';
import { useDebouncedValue } from '@mantine/hooks';
import { IconX } from '@tabler/icons-react';
import { useQuery } from '@tanstack/react-query';
import { ReactNode } from 'react';
import { useMemo, useState } from 'react';
@@ -177,6 +178,11 @@ export function ApiFormField({
{...definition}
type="url"
onChange={(event) => onChange(event.currentTarget.value)}
rightSection={
definition.value && !definition.required ? (
<IconX size="1rem" color="red" onClick={() => onChange('')} />
) : null
}
/>
);
case 'email':
@@ -185,6 +191,11 @@ export function ApiFormField({
{...definition}
type="email"
onChange={(event) => onChange(event.currentTarget.value)}
rightSection={
definition.value && !definition.required ? (
<IconX size="1rem" color="red" onClick={() => onChange('')} />
) : null
}
/>
);
case 'string':
@@ -192,6 +203,11 @@ export function ApiFormField({
<TextInput
{...definition}
onChange={(event) => onChange(event.currentTarget.value)}
rightSection={
definition.value && !definition.required ? (
<IconX size="1rem" color="red" onClick={() => onChange('')} />
) : null
}
/>
);
case 'boolean':