@kopexa/chip
Version:
A Chip is a small block of essential information that represent an input, attribute, or action.
86 lines (84 loc) • 4.01 kB
JavaScript
"use client";
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/related-control-chip.tsx
var related_control_chip_exports = {};
__export(related_control_chip_exports, {
RelatedControlChip: () => RelatedControlChip
});
module.exports = __toCommonJS(related_control_chip_exports);
var import_icons = require("@kopexa/icons");
var import_theme = require("@kopexa/theme");
var import_tooltip = require("@kopexa/tooltip");
var Slot = __toESM(require("@radix-ui/react-slot"));
var import_jsx_runtime = require("react/jsx-runtime");
var MappingIconMapper = {
EQUAL: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.EqualsIcon, {}),
INTERSECT: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.IntersectIcon, {}),
SUBSET: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.SubsetIcon, {}),
PARTIAL: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.PartialIcon, {}),
SUPERSET: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.SupersetIcon, {})
};
var RelatedControlChip = ({
refCode,
mappingType,
relation,
asChild
}) => {
const tooltipDisabled = !relation && !mappingType;
const Comp = asChild ? Slot.Root : "span";
const styles = (0, import_theme.relatedControlChip)();
if (!tooltipDisabled) {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_tooltip.Tooltip,
{
side: "top",
className: styles.tooltip(),
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex flex-col gap-1", children: mappingType && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-1 items-center", children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ChevronsLeftRightEllipsisIcon, { size: 12 }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Mapping type" }),
/* @__PURE__ */ (0, import_jsx_runtime.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__ */ (0, import_jsx_runtime.jsx)("span", { className: "capitalize", children: mappingType.toLowerCase() })
] }) }),
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Comp, { className: styles.root(), children: refCode })
}
);
}
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Comp, { className: styles.root(), children: refCode });
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
RelatedControlChip
});