"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TooltipSelectPluginView = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const BaseTooltip_1 = require("../BaseTooltip/index.js");
const TooltipSelect_1 = require("./TooltipSelect.js");
/** @deprecated */
class TooltipSelectPluginView extends BaseTooltip_1.BaseTooltipPluginView {
    buttonText;
    items;
    buildAttrs;
    withSearch;
    enableHideOnBlur;
    constructor(view, options) {
        super(view, options);
        this.buttonText = options.buttonText;
        this.items = options.items;
        this.buildAttrs = options.buildAttrs;
        this.withSearch = options.withSearch ?? true;
        this.enableHideOnBlur = options.disableHideOnBlur !== true;
        if (this.enableHideOnBlur) {
            this.view.dom.addEventListener('focus', this.onViewFocus);
        }
    }
    destroy() {
        super.destroy();
        this.view.dom.removeEventListener('focus', this.onViewFocus);
    }
    renderContent(currentNode) {
        return ((0, jsx_runtime_1.jsx)(TooltipSelect_1.TooltipButton, { domRef: currentNode.dom, buttonTitle: this.buttonText?.(currentNode.node), items: this.items, onUpdate: (v) => this.changeAttrsCb(this.buildAttrs(v), { setFocus: true }), withSearch: this.withSearch, onOutsideClick: this.onOutsideClick }));
    }
    onOutsideClick = () => {
        if (this.enableHideOnBlur && !this.view.hasFocus()) {
            this.manualHidden = true;
            this.render();
        }
    };
    onViewFocus = () => {
        this.manualHidden = false;
        this.render();
    };
}
exports.TooltipSelectPluginView = TooltipSelectPluginView;
//# sourceMappingURL=index.js.map
