import React from "react"; import { Box, Flex, Icon, Tab, TabList, Text, Tooltip, } from "@chakra-ui/react"; // Shared dimensions and surface styles for text and icon selectors. const OUTER_RADIUS = { base: "10px", lg: "12px" }; const ITEM_RADIUS = { base: "7px", lg: "8px" }; const COMPACT_HEIGHT = { base: "36px", lg: "44px" }; /** * items: [{ value, title, icon, tooltip?, isDisabled? }] * mode: "icon" or "text"; tooltip falls back to title. * selectionMode="tabs": Chakra Tabs controls the selected tab/keyboard behavior. * selectionMode="options": each item is its own button; clicks select only that item. * renderItem optionally wraps an item (e.g. with a guide target). */ export default function SegmentedSelector({ items = [], mode = "text", selectionMode = "options", value, onChange, isDisabled = false, compact = false, renderItem, ...containerProps }) { const isTabs = selectionMode === "tabs"; const surfaceProps = { p: 1, gap: 1, bg: "gray.100", borderWidth: "1px", borderColor: "gray.200", borderRadius: OUTER_RADIUS, boxShadow: "inner", flexShrink: 0, }; const children = items.map((item, index) => { const title = item.title ?? item.label ?? ""; const tooltip = item.tooltip || title; const selected = !isTabs && item.value === value; const hasIcon = mode === "icon" && item.icon; const optionDisabled = isDisabled || item.isDisabled; const content = hasIcon ? (