import { getText } from "../../locales/index.js";
import Button from "../button/index.js";
import SortableItem from "./components/SortableItem/index.js";
import { SortableTree } from "../pisellDraggable/index.js";
import React, { useCallback } from "react";
import { PlusOutlined } from "@ant-design/icons";
import classNames from "classnames";
import "./PisellDropSort.less";
//#region src/components/pisellDropSort/PisellDropSort.tsx
const PisellDropSort = ({ value = [], allowDrag = true, allowDelete = true, allowAddChild = true, allowAddRoot = true, allowIsShow = false, disabled = false, spacing = 8, maxLevel = 3, showBorder = true, style, className, onChange, onDelete, onAdd, renderItem: propsRenderItem, leftContent, rightContent, onAddRoot, __designMode, isCustomAction, emptyContent, getItemStyle, canDrop, indentationWidth }) => {
	const renderItem = useCallback((itemProps, ref) => {
		return /* @__PURE__ */ React.createElement(SortableItem, {
			itemProps,
			domRef: ref,
			render: propsRenderItem,
			allowAddChild,
			allowDelete,
			allowDrag,
			allowIsShow,
			disabled,
			onAdd,
			onDelete,
			showBorder,
			spacing,
			maxLevel,
			__designMode,
			isCustomAction,
			getItemStyle
		});
	}, [
		allowAddChild,
		allowDelete,
		allowDrag,
		value,
		disabled,
		maxLevel,
		onAdd,
		onDelete,
		showBorder,
		spacing,
		isCustomAction
	]);
	const handleChange = useCallback((items) => {
		onChange === null || onChange === void 0 || onChange(items);
	}, [onChange]);
	const containerClassName = classNames("pisell-lowcode-drop-sort-container", className);
	return /* @__PURE__ */ React.createElement("div", {
		className: containerClassName,
		style
	}, /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode-drop-sort-container-header" }, /* @__PURE__ */ React.createElement("span", null, leftContent), /* @__PURE__ */ React.createElement("span", null, rightContent || allowAddRoot && !disabled && /* @__PURE__ */ React.createElement(Button, {
		icon: /* @__PURE__ */ React.createElement(PlusOutlined, null),
		type: "primary",
		onClick: () => onAddRoot === null || onAddRoot === void 0 ? void 0 : onAddRoot(),
		size: "large"
	}, getText("pisell-lowcode-drop-sort-add")))), /* @__PURE__ */ React.createElement("div", {
		className: "pisell-lowcode-drop-sort-container-content",
		style: { gap: spacing !== null && spacing !== void 0 ? spacing : 8 }
	}, value.length === 0 && emptyContent ? emptyContent : /* @__PURE__ */ React.createElement(SortableTree, {
		value,
		collapsible: true,
		indicator: false,
		indentationWidth,
		removable: allowDelete,
		renderItem,
		onChange: handleChange,
		canDrop,
		maxLevel
	})));
};
//#endregion
export { PisellDropSort as default };
