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

import { __toESM } from "../../../_virtual/_rolldown/runtime.js";
import { require_classnames } from "../../../node_modules/classnames/index.js";
import pconsole_default from "../../../global/js/utils/pconsole.js";
import { pkg } from "../../../settings.js";
import { getDevtoolsProps } from "../../../global/js/utils/devtools.js";
import { InlineEditProvider } from "./addons/InlineEdit/InlineEditContext/InlineEditContext.js";
import { FilterProvider } from "./addons/Filtering/FilterProvider.js";
import { DatagridContent } from "./DatagridContent.js";
import React from "react";
import PropTypes from "prop-types";
//#region src/components/Datagrid/Datagrid/Datagrid.tsx
/**
* Copyright IBM Corp. 2020, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var import_classnames = /* @__PURE__ */ __toESM(require_classnames());
const blockClass = `${pkg.prefix}--datagrid`;
const componentName = "Datagrid";
/**
* The `Datagrid` component is an extension of Carbon's DataTable component. At the most basic level, the `Datagrid` component takes in columns and rows and renders a data table. There is a set of data table extensions which this component provides support for, these can be found [here](https://pages.github.ibm.com/carbon/ibm-products/components/datagrid/overview/). This component is data driven and allows you to choose what pieces will be included based on the hooks/plugins that are provided.
* @deprecated
*/
const Datagrid = React.forwardRef(({ datagridState, ariaToolbarLabel, ...rest }, ref) => {
	if (!datagridState) {
		pconsole_default.warn("Datagrid was not passed datagridState which is required to render this component.");
		return;
	}
	const { withVirtualScroll, DatagridPagination, isFetching, tableId, filterProps, className, state } = datagridState;
	const rows = DatagridPagination && datagridState.page || datagridState.rows;
	const props = {
		datagridState,
		ariaToolbarLabel
	};
	return /* @__PURE__ */ React.createElement(FilterProvider, {
		filters: state?.filters,
		filterProps,
		tableId
	}, /* @__PURE__ */ React.createElement(InlineEditProvider, null, /* @__PURE__ */ React.createElement("div", {
		...rest,
		id: tableId,
		ref,
		className: (0, import_classnames.default)(className, blockClass, withVirtualScroll ? `${blockClass}__datagridWrap` : `${blockClass}__datagridWrap-simple`, !isFetching && rows.length === 0 ? `${blockClass}__empty-state` : ""),
		...getDevtoolsProps(componentName)
	}, filterProps?.variation === "panel" ? /* @__PURE__ */ React.createElement("div", { className: `${blockClass}__datagridWithPanel ${blockClass}__displayFlex` }, /* @__PURE__ */ React.createElement(DatagridContent, props)) : /* @__PURE__ */ React.createElement(DatagridContent, props))));
});
/**@ts-ignore*/
Datagrid.deprecated = {
	level: "warn",
	details: `For more information, please refer to the migration docs https://github.com/carbon-design-system/tanstack-carbon`
};
Datagrid.displayName = componentName;
Datagrid.propTypes = {
	/**
	* Specify a label to be read by screen readers on the container node
	* 'aria-label' of the TableToolbar component.
	*/
	ariaToolbarLabel: PropTypes.string,
	/**
	* The data grid state, much of it being supplied by the useDatagrid hook
	*/
	/**@ts-ignore */
	datagridState: PropTypes.object.isRequired
};
//#endregion
export { Datagrid };
