"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 UiProvider
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultDialogGridContainer = exports.DialogGridContainer = exports.ToolSettingsGridContainer = void 0;
require("./DefaultDialogGridContainer.scss");
const classnames_1 = require("classnames");
const React = require("react");
const ToolSettingsContent_1 = require("../widgets/ToolSettingsContent");
var LayoutMode;
(function (LayoutMode) {
    LayoutMode[LayoutMode["Wide"] = 0] = "Wide";
    LayoutMode[LayoutMode["Narrow"] = 1] = "Narrow";
})(LayoutMode || (LayoutMode = {}));
/**
 * Component to provide grid of property editors
 * @public
 */
function ToolSettingsGridContainer({ componentGenerator, }) {
    const { availableContentWidth } = React.useContext(ToolSettingsContent_1.ToolSettingsContentContext);
    const layoutMode = toLayoutMode(availableContentWidth);
    const className = (0, classnames_1.default)("uifw-tool-settings-grid-container", LayoutMode.Narrow === layoutMode && "uifw-default-narrow");
    return (React.createElement(DialogGridContainer, { componentGenerator: componentGenerator, containerClassName: className }));
}
exports.ToolSettingsGridContainer = ToolSettingsGridContainer;
/** @internal */
function DialogGridContainer({ componentGenerator, containerClassName, }) {
    const className = (0, classnames_1.default)("uifw-default-container", containerClassName);
    return (React.createElement("div", { className: className }, componentGenerator.uiDataProvider.rows.map((row, index) => componentGenerator.getRow(row, index))));
}
exports.DialogGridContainer = DialogGridContainer;
/** DefaultDialogGridContainer populates a React node with the items specified by the UiLayoutDataProvider
 * @public
 */
function DefaultDialogGridContainer({ componentGenerator, isToolSettings, }) {
    return !!isToolSettings ? (React.createElement(ToolSettingsGridContainer, { componentGenerator: componentGenerator })) : (React.createElement(DialogGridContainer, { componentGenerator: componentGenerator }));
}
exports.DefaultDialogGridContainer = DefaultDialogGridContainer;
const toLayoutMode = (width) => {
    return width < 250 && width > 0 ? LayoutMode.Narrow : LayoutMode.Wide;
};
//# sourceMappingURL=DefaultDialogGridContainer.js.map