import React from 'react'
import { useSurfaceHeight } from '../hooks/useSizedSurface'
import { Space } from '../Space'
import { SimpleText } from '../text/SimpleText'
import { Stack, StackProps } from '../View/Stack'
import { useFormError } from './Form'
import { Label } from './Label'
const FormLabel = ({ children, height }) => (
{children}
)
const FormValueCol = (props: StackProps) =>
export type FormFieldLayout = 'horizontal' | 'vertical'
export type SimpleFormFieldProps = StackProps & {
description?: string
label?: React.ReactNode
layout?: FormFieldLayout
children?: React.ReactNode
name?: string
}
export function SimpleFormField({
name,
label,
children,
layout,
description,
}: SimpleFormFieldProps) {
const error = useFormError(`${label}`)
const height = useSurfaceHeight(1)
const descriptionElement = (
{description}
)
const labelElement = (
)
const valueElement = (
<>
{children}
{error && (
<>
{error}
>
)}
>
)
if (layout === 'vertical') {
return (
{labelElement}
{valueElement}
{descriptionElement}
)
}
return (
{labelElement}
{valueElement}
{descriptionElement}
)
}