/*---------------------------------------------------------------------------------------------
* 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
 */
import "./Indicator.scss";
import classnames from "classnames";
import * as React from "react";
import { FooterIndicator, FooterPopup } from "@itwin/appui-layout-react";
/** General-purpose [[StatusBar]] indicator.
 * @beta
 */
export 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 = classnames("uifw-statusbar-indicator", hasClickAction && "uifw-action", props.className);
    return (React.createElement(React.Fragment, null,
        React.createElement(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(FooterPopup // eslint-disable-line deprecation/deprecation
        , { target: target.current, onClose: () => setIsOpen(false), isOpen: isOpen }, props.popup)));
}
//# sourceMappingURL=Indicator.js.map