/**
 * 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_index = require("../../../node_modules/classnames/index.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_icons = require("@carbon/react/icons");
let _dnd_kit_utilities = require("@dnd-kit/utilities");
let _dnd_kit_sortable = require("@dnd-kit/sortable");
//#region src/components/Datagrid/Datagrid/DraggableElement.tsx
/**
* Copyright IBM Corp. 2024
*
* 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__ */ require_runtime.__toESM(require_index.default);
const blockClass = `${require_settings.pkg.prefix}--datagrid`;
/**
* Single row in the DraggableItemsList used by CustomizeColumnsTearsheet.
*/
const DraggableElement = ({ id, elementId, children, classList, disabled, ariaLabel, isSticky, selected }) => {
	const { attributes, isDragging, listeners, setNodeRef, transform, transition } = (0, _dnd_kit_sortable.useSortable)({
		disabled,
		id
	});
	const { "aria-pressed": ariaPressed, "aria-describedby": ariaDescribedby } = attributes;
	const dragHandle = isSticky ? /* @__PURE__ */ react.default.createElement("div", { className: (0, import_classnames.default)({ disabled }, `${blockClass}__draggable-handleStyle`) }, /* @__PURE__ */ react.default.createElement(_carbon_react_icons.Locked, { size: 16 }), " ") : /* @__PURE__ */ react.default.createElement("button", {
		className: `${blockClass}__draggable-handleStyle`,
		type: "button",
		"aria-label": ariaLabel,
		"aria-describedby": ariaDescribedby,
		"aria-pressed": ariaPressed,
		...listeners
	}, /* @__PURE__ */ react.default.createElement(_carbon_react_icons.Draggable, { size: 16 }));
	const content = /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, dragHandle, children);
	const style = {
		transform: !disabled ? _dnd_kit_utilities.CSS.Transform.toString(transform) : void 0,
		transition
	};
	return /* @__PURE__ */ react.default.createElement("li", {
		className: (0, import_classnames.default)(classList, `${blockClass}__draggable-handleHolder`, {
			[`${blockClass}__draggable-handleHolder--selected`]: selected,
			[`${blockClass}__draggable-handleHolder--sticky`]: isSticky,
			[`${blockClass}__draggable-handleHolder--dragging`]: isDragging
		}),
		id: elementId ? elementId : id,
		ref: setNodeRef,
		style
	}, /* @__PURE__ */ react.default.createElement("div", { className: (0, import_classnames.default)([`${blockClass}__draggable-handleHolder-droppable`]) }, content));
};
DraggableElement.propTypes = {
	ariaLabel: prop_types.default.string.isRequired,
	children: prop_types.default.element.isRequired,
	classList: prop_types.default.string,
	disabled: prop_types.default.bool,
	elementId: prop_types.default.string,
	id: prop_types.default.string.isRequired,
	isSticky: prop_types.default.bool,
	selected: prop_types.default.bool
};
//#endregion
exports.default = DraggableElement;
