@hitachivantara/uikit-react-lab
Version:
Contributed React components for the NEXT UI Kit.
55 lines (54 loc) • 1.67 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const react = require("react");
const isInputGroup = (input) => {
return "inputs" in input;
};
const isOutputGroup = (output) => {
return "outputs" in output;
};
const isConnected = (id, type, handleId, edges) => {
if (type === "target") {
return edges.some((e) => e.target === id && e.targetHandle === handleId);
}
if (type === "source") {
return edges.some((e) => e.source === id && e.sourceHandle === handleId);
}
return false;
};
const renderedIcon = (actionIcon) => react.isValidElement(actionIcon) ? actionIcon : actionIcon?.();
const identifyHandles = (handles) => {
let idx = 0;
return handles?.map(
(handle) => {
if (isInputGroup(handle)) {
return {
...handle,
inputs: handle.inputs.map((x) => {
const identifiedHandle2 = x.id != null ? x : { ...x, id: String(idx) };
idx += 1;
return identifiedHandle2;
})
};
}
if (isOutputGroup(handle)) {
return {
...handle,
outputs: handle.outputs.map((x) => {
const identifiedHandle2 = x.id != null ? x : { ...x, id: String(idx) };
idx += 1;
return identifiedHandle2;
})
};
}
const identifiedHandle = handle.id != null ? handle : { ...handle, id: String(idx) };
idx += 1;
return identifiedHandle;
}
);
};
exports.identifyHandles = identifyHandles;
exports.isConnected = isConnected;
exports.isInputGroup = isInputGroup;
exports.isOutputGroup = isOutputGroup;
exports.renderedIcon = renderedIcon;