mirror of
https://github.com/inventree/InvenTree.git
synced 2025-11-03 14:45:42 +00:00
Add icon to clear text input value
This commit is contained in:
@@ -2,6 +2,7 @@ import { Alert, Checkbox, NumberInput, Select, TextInput } from '@mantine/core';
|
|||||||
import { DateInput } from '@mantine/dates';
|
import { DateInput } from '@mantine/dates';
|
||||||
import { UseFormReturnType } from '@mantine/form';
|
import { UseFormReturnType } from '@mantine/form';
|
||||||
import { useDebouncedValue } from '@mantine/hooks';
|
import { useDebouncedValue } from '@mantine/hooks';
|
||||||
|
import { IconX } from '@tabler/icons-react';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
@@ -177,6 +178,11 @@ export function ApiFormField({
|
|||||||
{...definition}
|
{...definition}
|
||||||
type="url"
|
type="url"
|
||||||
onChange={(event) => onChange(event.currentTarget.value)}
|
onChange={(event) => onChange(event.currentTarget.value)}
|
||||||
|
rightSection={
|
||||||
|
definition.value && !definition.required ? (
|
||||||
|
<IconX size="1rem" color="red" onClick={() => onChange('')} />
|
||||||
|
) : null
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case 'email':
|
case 'email':
|
||||||
@@ -185,6 +191,11 @@ export function ApiFormField({
|
|||||||
{...definition}
|
{...definition}
|
||||||
type="email"
|
type="email"
|
||||||
onChange={(event) => onChange(event.currentTarget.value)}
|
onChange={(event) => onChange(event.currentTarget.value)}
|
||||||
|
rightSection={
|
||||||
|
definition.value && !definition.required ? (
|
||||||
|
<IconX size="1rem" color="red" onClick={() => onChange('')} />
|
||||||
|
) : null
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case 'string':
|
case 'string':
|
||||||
@@ -192,6 +203,11 @@ export function ApiFormField({
|
|||||||
<TextInput
|
<TextInput
|
||||||
{...definition}
|
{...definition}
|
||||||
onChange={(event) => onChange(event.currentTarget.value)}
|
onChange={(event) => onChange(event.currentTarget.value)}
|
||||||
|
rightSection={
|
||||||
|
definition.value && !definition.required ? (
|
||||||
|
<IconX size="1rem" color="red" onClick={() => onChange('')} />
|
||||||
|
) : null
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
|
|||||||
Reference in New Issue
Block a user