/**
 * 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.
 */

const require_runtime = require('../../../../../_virtual/_rolldown/runtime.js');
const require_settings = require('../../../../../settings.js');
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let _carbon_react = require("@carbon/react");

//#region src/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.jsx
/**
* Copyright IBM Corp. 2021, 2025
*
* 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 blockClass = `${require_settings.pkg.prefix}--datagrid__row-size`;
const RowSizeRadioGroup = (0, react.forwardRef)((props, ref) => {
	const { rowSizes = [
		{ value: "xl" },
		{ value: "lg" },
		{ value: "md" },
		{ value: "sm" },
		{ value: "xs" }
	], selectedOption = "lg", onChange, legendText, rowSizeLabels = {
		xl: "Extra large",
		lg: "Large (default)",
		md: "Medium",
		sm: "Small",
		xs: "Extra small"
	}, tableId } = props;
	return /* @__PURE__ */ react.default.createElement("div", {
		className: `${blockClass}-dropdown`,
		role: "presentation",
		ref
	}, /* @__PURE__ */ react.default.createElement(_carbon_react.RadioButtonGroup, {
		legendText,
		name: `${tableId}--row-height-group`,
		orientation: "vertical",
		defaultSelected: getBackwardCompatibleRowSize(selectedOption),
		onChange
	}, rowSizes && Array.isArray(rowSizes) && rowSizes.map((option) => {
		let labelText;
		try {
			labelText = option.labelText || rowSizeLabels[option.value];
		} catch (e) {
			labelText = option.value;
		}
		return /* @__PURE__ */ react.default.createElement(_carbon_react.RadioButton, {
			className: `${blockClass}-radio-button`,
			key: option.value,
			labelText,
			value: option.value,
			id: `${tableId || "datagrid"}--row-density--${option.value}`
		});
	})));
});
const getBackwardCompatibleRowSize = (rowSize) => {
	return {
		tall: "xl",
		normal: "lg",
		short: "sm",
		compact: "xs"
	}[rowSize] || rowSize;
};
RowSizeRadioGroup.propTypes = {
	legendText: prop_types.default.string,
	onChange: prop_types.default.func.isRequired,
	rowSizeLabels: prop_types.default.object,
	rowSizes: prop_types.default.array.isRequired,
	selectedOption: prop_types.default.string.isRequired,
	tableId: prop_types.default.string.isRequired
};

//#endregion
exports.default = RowSizeRadioGroup;