/*---------------------------------------------------------------------------------------------
 * 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 { StatusBarPopup } from "./popup/Popup.js";
import { StatusBarField } from "./Field.js";
/** General-purpose [[StatusBar]] indicator.
 * @beta
 * @deprecated in 4.14.0. Use [iTwinUI Button](https://itwinui.bentley.com/docs/button) (or other components) and {@link StatusBarPopover AppUI StatusBarPopover} instead.
 */
// eslint-disable-next-line @typescript-eslint/no-deprecated
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(StatusBarField, { ref: target, className: props.className, title: props.title, style: props.style, onClick: hasClickAction ? handleOnIndicatorClick : undefined }, props.children),
        props.popup && (
        // eslint-disable-next-line @typescript-eslint/no-deprecated
        React.createElement(StatusBarPopup, { target: target.current, onClose: () => setIsOpen(false), isOpen: isOpen }, props.popup))));
}
//# sourceMappingURL=Indicator.js.map