/*---------------------------------------------------------------------------------------------
 * 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 "./SelectionCount.scss";
import classnames from "classnames";
import * as React from "react";
import { FooterIndicator } from "@itwin/appui-layout-react";
import { Icon } from "@itwin/core-react";
import { SvgCursor } from "@itwin/itwinui-icons-react";
/** 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 className = classnames("uifw-statusFields-selectionCount", props.className);
    return (React.createElement(FooterIndicator, { 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);
    }, [iModel]);
    React.useEffect(() => {
        if (!iModel)
            return;
        return iModel.selectionSet.onChanged.addListener((ev) => {
            setSize(ev.set.size);
        });
    }, [iModel]);
    return size;
}
//# sourceMappingURL=SelectionCount.js.map