UNPKG

@carbon/ibm-products

Version:
27 lines (25 loc) 1.25 kB
/** * Copyright IBM Corp. 2020, 2026 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ require("../../../_virtual/_rolldown/runtime.js"); let _carbon_layout = require("@carbon/layout"); //#region src/components/DataSpreadsheet/utils/getSpreadsheetWidth.js /** * Copyright IBM Corp. 2022, 2022 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ const getSpreadsheetWidth = ({ type, headerGroup, scrollBarSizeValue, totalVisibleColumns, defaultColumn, totalColumnsWidth, visibleColumns }) => { const additionalWidth = scrollBarSizeValue + defaultColumn.rowHeaderWidth; if (!totalVisibleColumns) { if (type === "header") return (0, _carbon_layout.px)(parseInt(headerGroup.getHeaderGroupProps().style.width) + additionalWidth); if (type !== "header") return totalColumnsWidth + additionalWidth; } if (totalVisibleColumns) return visibleColumns.map((item, index) => index <= totalVisibleColumns - 1 && (item?.width || defaultColumn?.width)).reduce((prev, curr) => prev + curr, 0) + additionalWidth; }; //#endregion exports.getSpreadsheetWidth = getSpreadsheetWidth;