import { CSSProperties, FieldsetHTMLAttributes, ReactNode } from 'react'; import { DataTestAutoId, Size, WithChildren, WithOptionalChildren } from '../../core/types.js'; export interface FieldGroupProps extends DataTestAutoId, FieldsetHTMLAttributes { legend: string; labelProps?: Omit; supportLabelProps?: Omit; tooltip?: ReactNode; className?: string; helpLabel?: string; errorLabel?: string; description?: string; } export interface InputProps { "aria-describedby"?: string; "aria-invalid"?: boolean; id?: string; } export type InputGroupProps = WithOptionalChildren & DataTestAutoId & { id?: string; className?: string; "data-testid"?: string; "data-size"?: Size; errorLabel?: ReactNode; helpLabel?: ReactNode; inline?: boolean; label: ReactNode; labelProps?: Omit; supportLabelProps?: Omit; description?: string; tooltip?: ReactNode; style?: CSSProperties; render?: (props: InputProps) => JSX.Element; }; export type LabelVariant = "small" | "medium" | "large"; export interface LabelProps extends WithChildren { id?: string; variant?: LabelVariant; srOnly?: boolean; standAlone?: boolean; htmlFor?: string; className?: string; style?: CSSProperties; } export type SupportLabelType = "help" | "error" | "warning" | "success"; export interface SupportLabelProps { /** * En ID er påkrevd for å kunne referere til SupportLabel med aria-describedby. * * @example * ```tsx * const uid = useId(); * const supportId = useId(); * const hasSupportText = helpLabel || errorLabel; * const describedBy = hasSupportText ? supportId : undefined; * * return ( *
* * * *
* ); * ``` */ id: string; /** * @deprecated Bruk `label` for å få samme resultat. */ helpLabel?: ReactNode; /** * @deprecated Bruk `label` og `labelType="warning"` for å få samme resultat. */ errorLabel?: ReactNode; label?: ReactNode; /** * Bestemmer hvilket ikon som skal vises: * * - "help" viser ikke noe ikon * - "warning" viser WarningIcon, det som tidligere ble vist med `errorLabel` * - "error" viser ErrorIcon * - "success" viser SuccessIcon * * @default "help" */ labelType?: SupportLabelType; className?: string; srOnly?: boolean; }