/** @license MIT | @cube-dev/ui-kit v0.135.1 | Cube Dev Team */
import { ItemAction } from "../../actions/ItemAction/ItemAction.js";
import { CloseIcon } from "../../../icons/CloseIcon.js";
import { MoreIcon } from "../../../icons/MoreIcon.js";
import { FilterPicker } from "../../fields/FilterPicker/FilterPicker.js";
import { jsx } from "react/jsx-runtime";

//#region src/components/navigation/Tabs/TabPicker.tsx
/**
* Tab picker component that displays a dropdown menu of all tabs.
*
* Used in the Tabs suffix area when tabs overflow to provide quick navigation
* to any tab without scrolling.
*/
function TabPicker({ tabs, selectedKey, onSelect, onDelete, size, type = "default", isReorderable, onReorder }) {
	const isDeletable = !!onDelete;
	return /* @__PURE__ */ jsx(FilterPicker, {
		selectionMode: "single",
		selectedKey,
		renderSummary: false,
		icon: /* @__PURE__ */ jsx(MoreIcon, {}),
		rightIcon: null,
		shape: "sharp",
		type: "neutral",
		size: size === "xsmall" ? "small" : size,
		styles: { border: type === "file" ? {
			"": 0,
			"!:first-child": "left"
		} : 0 },
		triggerStyles: { border: 0 },
		"aria-label": "Select tab",
		isReorderable,
		onReorder,
		onSelectionChange: (key) => {
			if (key != null) onSelect(String(key));
		},
		children: tabs.map((tab) => /* @__PURE__ */ jsx(FilterPicker.Item, {
			icon: tab.icon,
			textValue: typeof tab.title === "string" ? tab.title : String(tab.key),
			autoHideActions: isDeletable,
			actions: isDeletable ? /* @__PURE__ */ jsx(ItemAction, {
				icon: /* @__PURE__ */ jsx(CloseIcon, {}),
				theme: "danger",
				"aria-label": "Close",
				onPress: () => {
					onDelete(tab.key);
				}
			}) : void 0,
			children: tab.title
		}, tab.key))
	});
}

//#endregion
export { TabPicker };
//# sourceMappingURL=TabPicker.js.map