-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathOxqlField.tsx
More file actions
30 lines (27 loc) · 858 Bytes
/
Copy pathOxqlField.tsx
File metadata and controls
30 lines (27 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* Copyright Oxide Computer Company
*/
import type { FieldPath, FieldValues } from 'react-hook-form'
import type { TextAreaProps } from '~/ui/lib/TextInput'
import { TextField, type TextFieldProps } from './TextField'
export function OxqlField<
TFieldValues extends FieldValues,
TName extends FieldPath<TFieldValues>,
>(
props: Omit<TextFieldProps<TFieldValues, TName>, 'validate'> & Omit<TextAreaProps, 'as'>
) {
return (
<TextField
as="textarea"
fieldClassName="font-mono!"
validate={(value) =>
typeof value === 'string' && value.trim() ? undefined : 'Enter a query'
}
{...props}
/>
)
}