/*---------------------------------------------------------------------------------------------
 * 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 { Icon } from "@itwin/core-react";
import { SvgCursor } from "@itwin/itwinui-icons-react";
import classnames from "classnames";
import { StatusBarCornerComponentContext } from "../statusbar/StatusBarCornerComponentContext";
import "./SelectionCount.scss";
/** Status field component used to display the number of selected items.
 * @note Use [[useSelectionSetSize]] hook to get the selection count.
 * @beta
 */
export function SelectionCountField(props) {
    const cornerContext = React.useContext(StatusBarCornerComponentContext);
    const className = classnames("uifw-statusFields-selectionCount", cornerContext === "left-corner" && "uifw-left-corner", cornerContext === "right-corner" && "uifw-right-corner", props.className);
    return (React.createElement("div", { className: className, style: props.style },
        React.createElement(Icon, { iconSpec: React.createElement(SvgCursor, null) }),
        props.count));
}
/** React hook that returns element count of a selection set.
 * @beta
 */
export function useSelectionSetSize(args) {
    const [size, setSize] = React.useState(0);
    const { iModel } = args;
    React.useEffect(() => {
        if (!iModel) {
            setSize(0);
            return;
        }
        setSize(iModel.selectionSet.size);
        return iModel.selectionSet.onChanged.addListener((ev) => {
            setSize(ev.set.size);
        });
    }, [iModel]);
    return size;
}
//# sourceMappingURL=SelectionCount.js.map