/*---------------------------------------------------------------------------------------------
 * 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 * as React from "react";
import { StatusBar } from "./StatusBar";
/** General-purpose [[StatusBar]] indicator.
 * @beta
 */
export function StatusBarIndicator(props) {
    const hasClickAction = !!props.onClick || !!props.popup;
    const [isOpen, setIsOpen] = React.useState(!!props.defaultIsOpen);
    const handleOnIndicatorClick = () => {
        setIsOpen(!isOpen);
        props.onClick?.();
    };
    const target = React.useRef(null);
    return (React.createElement(React.Fragment, null,
        React.createElement(StatusBar.Field, { ref: target, className: props.className, title: props.title, style: props.style, onClick: hasClickAction ? handleOnIndicatorClick : undefined }, props.children),
        props.popup && (React.createElement(StatusBar.Popup, { target: target.current, onClose: () => setIsOpen(false), isOpen: isOpen }, props.popup))));
}
//# sourceMappingURL=Indicator.js.map