import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Combobox } from "@powerhousedao/design-system/connect";
import { Controller } from "react-hook-form";
import { twMerge } from "tailwind-merge";
export function RWATableSelect(props) {
    const { options, name, control, rules, errorMessage, errorMessageClassName, disabled = false, ...restProps } = props;
    const invalid = props["aria-invalid"] === "true";
    return (_jsx(Controller, { control: control, name: name, render: ({ field: { onChange, onBlur, value } }) => disabled ? (_jsx(_Fragment, { children: options.find((option) => option.value === value)?.label })) : (_jsxs(_Fragment, { children: [_jsx(Combobox, { isDisabled: disabled, onBlur: onBlur, onChange: (option) => !!option &&
                        typeof option === "object" &&
                        "value" in option &&
                        onChange(option.value), options: options, value: options.find((option) => option.value === value) ?? null, ...restProps }), invalid && !!errorMessage ? (_jsx("p", { className: twMerge("text-sm text-red-900", errorMessageClassName), role: "alert", children: errorMessage })) : null] })), rules: rules }));
}
//# sourceMappingURL=select.js.map