import * as React from "react"; import dashify from "dashify"; import { NumericFormat } from "react-number-format"; import type * as T from "./Input.types"; import { Box } from "../Box"; import { Label } from "../Label"; import { HelpText } from "../HelpText"; import { cx } from "../../utils"; import { inputStyles } from "./Input.styles"; import { match, P } from "ts-pattern"; const Input = React.forwardRef( ( { label, helpText, money, numericFormatOptions, hideLabel = false, symbol = "$", currency = "USD", hasError, ...props }, forwardedRef ) => { const htmlId = dashify(label); const classes = cx( inputStyles({ hasError }), { "pr-12": currency, "text-right": money, }, props.className ); const moneyDecoratorsClasses = [ "pointer-events-none", "absolute", "inset-y-0", "flex", "items-center", ]; return ( {match(money) .with(true, () => ( <> {symbol} {currency} )) .otherwise(() => ( ))} {match(helpText) .with(P.not(P.nullish), () => ( {helpText} )) .otherwise(() => null)} ); } ); export { Input };