"use client" // This is almost a copy of the Input in TempDesignSystem, but since it's tightly coupled // to the error messages we need to duplicate it for now. In the future we should // rewrite it to be more reusable. import { forwardRef } from "react" import { Text, TextField } from "react-aria-components" import { Controller, type RegisterOptions, useFormContext, } from "react-hook-form" import { useIntl } from "react-intl" import Caption from "@scandic-hotels/design-system/Caption" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Input as InputWithLabel } from "@scandic-hotels/design-system/Input" import { getErrorMessage } from "./errors" import styles from "./input.module.css" interface InputProps extends React.InputHTMLAttributes { helpText?: string label: string name: string registerOptions?: RegisterOptions hideError?: boolean } const BookingFlowInput = forwardRef( function Input( { "aria-label": ariaLabel, autoComplete, className = "", disabled = false, helpText = "", label, maxLength, name, placeholder, readOnly = false, registerOptions = {}, type = "text", hideError, inputMode, }, ref ) { const intl = useIntl() const { control } = useFormContext() return ( ( {helpText && !fieldState.error ? ( {helpText} ) : null} {fieldState.error && !hideError ? ( {getErrorMessage(intl, fieldState.error.message)} ) : null} )} /> ) } ) export default BookingFlowInput