"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module StatusBar
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatusBarIndicator = void 0;
require("./Indicator.scss");
const classnames_1 = require("classnames");
const React = require("react");
const appui_layout_react_1 = require("@itwin/appui-layout-react");
/** General-purpose [[StatusBar]] indicator.
 * @beta
 */
function StatusBarIndicator(props) {
    const hasClickAction = !!props.onClick || !!props.popup;
    const [isOpen, setIsOpen] = React.useState(!!props.defaultIsOpen);
    const handleOnIndicatorClick = () => {
        var _a;
        setIsOpen(!isOpen);
        (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props);
    };
    const target = React.useRef(null);
    const classNames = (0, classnames_1.default)("uifw-statusbar-indicator", hasClickAction && "uifw-action", props.className);
    return (React.createElement(React.Fragment, null,
        React.createElement(appui_layout_react_1.FooterIndicator // eslint-disable-line deprecation/deprecation
        , { ref: target, className: classNames, title: props.title, style: props.style, onClick: handleOnIndicatorClick, ...{
                role: "button",
                tabIndex: -1,
            } }, props.children),
        props.popup && React.createElement(appui_layout_react_1.FooterPopup // eslint-disable-line deprecation/deprecation
        , { target: target.current, onClose: () => setIsOpen(false), isOpen: isOpen }, props.popup)));
}
exports.StatusBarIndicator = StatusBarIndicator;
//# sourceMappingURL=Indicator.js.map