"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;
const React = require("react");
const StatusBar_1 = require("./StatusBar");
/** 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);
    return (React.createElement(React.Fragment, null,
        React.createElement(StatusBar_1.StatusBar.Field, { ref: target, className: props.className, title: props.title, style: props.style, onClick: hasClickAction ? handleOnIndicatorClick : undefined }, props.children),
        props.popup && (React.createElement(StatusBar_1.StatusBar.Popup, { target: target.current, onClose: () => setIsOpen(false), isOpen: isOpen }, props.popup))));
}
exports.StatusBarIndicator = StatusBarIndicator;
//# sourceMappingURL=Indicator.js.map