"use client"
import { forwardRef, type HTMLAttributes, type WheelEvent } from "react"
import { Text, TextField } from "react-aria-components"
import { Controller, useFormContext } from "react-hook-form"
import { useIntl } from "react-intl"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { Input as InputWithLabel } from "@scandic-hotels/design-system/Input"
import Caption from "@/components/TempDesignSystem/Text/Caption"
import { getErrorMessage } from "./errors"
import styles from "./input.module.css"
import type { InputProps } from "./input"
const Input = 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()
let numberAttributes: HTMLAttributes = {}
if (type === "number") {
numberAttributes.onWheel = function (evt: WheelEvent) {
evt.currentTarget.blur()
}
}
return (
(
{helpText && !fieldState.error ? (
{helpText}
) : null}
{fieldState.error && !hideError ? (
{getErrorMessage(intl, fieldState.error.message)}
) : null}
)}
/>
)
})
export default Input