var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React, { useId, useRef, forwardRef } from "react";
import { ADPIcon } from "../adpIcon";
import { cn } from "@utils";
import { textFieldContainerVariants, textFieldLabelVariants, textFieldVariants, textFieldIconVariants, textFieldHelperTextVariants } from "./textFieldVariants";
/**
 * TextField component for collecting text input from users.
 */
export const TextField = forwardRef(function TextField(_a, ref) {
    var { label, size = "md", helperText, error = false, prefixIcon, suffixIcon, className } = _a, props = __rest(_a, ["label", "size", "helperText", "error", "prefixIcon", "suffixIcon", "className"]);
    const inputId = useRef(useId());
    const { id, disabled } = props;
    return (_jsxs("div", { className: cn(textFieldContainerVariants(), className), children: [label !== undefined && (_jsx("label", { htmlFor: id || inputId.current, className: cn(textFieldLabelVariants()), children: label })), _jsxs("div", { className: "relative", children: [prefixIcon && (typeof prefixIcon === "string"
                        ? (_jsx(ADPIcon, { icon: prefixIcon, size: size, fixedWidth: true, className: cn(textFieldIconVariants({ size, position: "prefix" })) }))
                        : (_jsx("div", { className: cn(textFieldIconVariants({ size, position: "prefix" })), children: prefixIcon }))), _jsx("input", Object.assign({ id: id || inputId.current, className: cn(textFieldVariants({
                            size,
                            error,
                            withPrefix: Boolean(prefixIcon),
                            withSuffix: Boolean(suffixIcon)
                        })), disabled: disabled, ref: ref }, props)), suffixIcon && (typeof suffixIcon === "string"
                        ? (_jsx(ADPIcon, { icon: suffixIcon, size: size, fixedWidth: true, className: cn(textFieldIconVariants({ size, position: "suffix" })) }))
                        : (_jsx("div", { className: cn(textFieldIconVariants({ size, position: "suffix" })), children: suffixIcon })))] }), helperText && (_jsx("div", { className: cn(textFieldHelperTextVariants({ error })), children: helperText }))] }));
});
TextField.displayName = "TextField";
//# sourceMappingURL=textField.js.map