"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.useSelectionSetSize = exports.SelectionCountField = void 0;
const core_react_1 = require("@itwin/core-react");
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
const classnames_1 = require("classnames");
const React = require("react");
require("./SelectionCount.scss");
/** Status field component used to display the number of selected items.
 * @note Use [[useSelectionSetSize]] hook to get the selection count.
 * @beta
 */
function SelectionCountField(props) {
    const className = (0, classnames_1.default)("uifw-statusFields-selectionCount", props.className);
    return (React.createElement("div", { className: className, style: props.style },
        React.createElement(core_react_1.Icon, { iconSpec: React.createElement(itwinui_icons_react_1.SvgCursor, null) }),
        props.count));
}
exports.SelectionCountField = SelectionCountField;
/** React hook that returns element count of a selection set.
 * @beta
 */
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;
}
exports.useSelectionSetSize = useSelectionSetSize;
//# sourceMappingURL=SelectionCount.js.map