import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { cnb } from "cnbuilder";
import { forwardRef } from "react";
import { bem } from "../utils/bem.js";
const styles = bem("rmd-text-field-addon");
/**
 * @remarks \@since 6.0.0
 */ export function textFieldAddon(options = {}) {
    const { className, after = false, presentational = false } = options;
    return cnb(styles({
        before: !after,
        after,
        presentational
    }), className);
}
/**
 * **Server Component**
 *
 * This component is used to add an an icon before or after the text field with
 * correct styling.
 */ export const TextFieldAddon = /*#__PURE__*/ forwardRef(function TextFieldAddon(props, ref) {
    const { after = false, children, className, disabled = false, pointerEvents = false, ...remaining } = props;
    if (!children) {
        return null;
    }
    if (disabled) {
        return /*#__PURE__*/ _jsx(_Fragment, {
            children: children
        });
    }
    return /*#__PURE__*/ _jsx("span", {
        ...remaining,
        ref: ref,
        className: textFieldAddon({
            after,
            presentational: !pointerEvents,
            className
        }),
        children: children
    });
});

//# sourceMappingURL=TextFieldAddon.js.map