import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { cnb } from "cnbuilder";
import { forwardRef } from "react";
import { box } from "../box/styles.js";
import { bem } from "../utils/bem.js";
const styles = bem("rmd-text-field-addon");
/**
 * @since 6.0.0
 */ export function textFieldAddon(options = {}) {
    const { className, after, presentational } = options;
    return cnb(styles({
        before: !after,
        after,
        presentational
    }), box({
        disablePadding: true
    }), 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, disabled, pointerEvents, children, className, ...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