@kopexa/chip
Version:
A Chip is a small block of essential information that represent an input, attribute, or action.
62 lines (59 loc) • 1.98 kB
JavaScript
"use client";
// src/related-control-chip.tsx
import {
ChevronsLeftRightEllipsisIcon,
EqualsIcon,
IntersectIcon,
PartialIcon,
SubsetIcon,
SupersetIcon
} from "@kopexa/icons";
import {
relatedControlChip
} from "@kopexa/theme";
import { Tooltip } from "@kopexa/tooltip";
import * as Slot from "@radix-ui/react-slot";
import { jsx, jsxs } from "react/jsx-runtime";
var MappingIconMapper = {
EQUAL: /* @__PURE__ */ jsx(EqualsIcon, {}),
INTERSECT: /* @__PURE__ */ jsx(IntersectIcon, {}),
SUBSET: /* @__PURE__ */ jsx(SubsetIcon, {}),
PARTIAL: /* @__PURE__ */ jsx(PartialIcon, {}),
SUPERSET: /* @__PURE__ */ jsx(SupersetIcon, {})
};
var RelatedControlChip = ({
refCode,
mappingType,
relation,
asChild
}) => {
const tooltipDisabled = !relation && !mappingType;
const Comp = asChild ? Slot.Root : "span";
const styles = relatedControlChip();
if (!tooltipDisabled) {
return /* @__PURE__ */ jsx(
Tooltip,
{
side: "top",
className: styles.tooltip(),
content: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: mappingType && /* @__PURE__ */ jsxs("div", { className: "flex gap-1 items-center", children: [
/* @__PURE__ */ jsx(ChevronsLeftRightEllipsisIcon, { size: 12 }),
/* @__PURE__ */ jsx("span", { children: "Mapping type" }),
/* @__PURE__ */ jsx(
"div",
{
className: `ml-4 flex w-2.5 h-2.5 justify-center items-center ${mappingType === "SUPERSET" ? "h-5 w-5" : "h-2.5 w-2.5"}`,
children: MappingIconMapper[mappingType]
}
),
/* @__PURE__ */ jsx("span", { className: "capitalize", children: mappingType.toLowerCase() })
] }) }),
children: /* @__PURE__ */ jsx(Comp, { className: styles.root(), children: refCode })
}
);
}
return /* @__PURE__ */ jsx(Comp, { className: styles.root(), children: refCode });
};
export {
RelatedControlChip
};