diff --git a/src/frontend/src/primitives/Box.tsx b/src/frontend/src/primitives/Box.tsx index 528a6bee..7c06f1f7 100644 --- a/src/frontend/src/primitives/Box.tsx +++ b/src/frontend/src/primitives/Box.tsx @@ -20,6 +20,7 @@ const box = cva({ popover: { padding: 'boxPadding.xs', minWidth: '10rem', + boxShadow: '0 8px 20px #0000001a', }, dialog: { width: '30rem', @@ -38,6 +39,11 @@ const box = cva({ color: 'default.subtle-text', backgroundColor: 'default.subtle', }, + control: { + border: '1px solid {colors.control.border}', + backgroundColor: 'box.bg', + color: 'control.text', + }, }, size: { default: { diff --git a/src/frontend/src/primitives/Field.tsx b/src/frontend/src/primitives/Field.tsx index 689d36b9..b53e5e7c 100644 --- a/src/frontend/src/primitives/Field.tsx +++ b/src/frontend/src/primitives/Field.tsx @@ -10,12 +10,14 @@ import { type CheckboxProps, type CheckboxGroupProps, type RadioGroupProps, + type SelectProps, } from 'react-aria-components' import { FieldDescription } from './FieldDescription' import { FieldErrors } from './FieldErrors' import { Input } from './Input' import { Radio } from './Radio' import { Checkbox } from './Checkbox' +import { Select } from './Select' import { Div } from './Div' const FieldWrapper = styled('div', { @@ -31,12 +33,16 @@ const StyledLabel = styled(Label, { }) type OmittedRACProps = 'type' | 'label' | 'items' | 'description' | 'validate' -type Items = { items: Array<{ value: string; label: ReactNode }> } +type Items = { items: Array<{ value: string; label: T }> } type PartialTextFieldProps = Omit type PartialCheckboxProps = Omit type PartialCheckboxGroupProps = Omit type PartialRadioGroupProps = Omit -type FieldProps = ( +type PartialSelectProps = Omit< + SelectProps, + OmittedRACProps +> +type FieldProps = ( | ({ type: 'text' items?: never @@ -65,6 +71,11 @@ type FieldProps = ( ) => ReactNode | ReactNode[] | true | null | undefined } & Items & PartialRadioGroupProps) + | ({ + type: 'select' + validate?: (value: T) => ReactNode | ReactNode[] | true | null | undefined + } & Items & + PartialSelectProps) ) & { label: string description?: string @@ -82,14 +93,14 @@ type FieldProps = ( * * You can directly pass HTML input props if needed (like required, pattern, etc) */ -export const Field = ({ +export const Field = ({ type, label, description, items, validate, ...props -}: FieldProps) => { +}: FieldProps) => { const LabelAndDescription = ( <> {label} @@ -174,6 +185,20 @@ export const Field = ({ ) } + + if (type === 'select') { + return ( + +