UNPKG

@hitachivantara/uikit-react-lab

Version:

Contributed React components to UI Kit by the community.

50 lines (49 loc) 1.35 kB
import { isValidElement } from "react"; //#region src/Flow/Node/utils.ts var isInputGroup = (input) => { return "inputs" in input; }; var isOutputGroup = (output) => { return "outputs" in output; }; var 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; }; var renderedIcon = (actionIcon) => isValidElement(actionIcon) ? actionIcon : actionIcon?.(); var identifyHandles = (handles) => { let idx = 0; return handles?.map((handle) => { if (isInputGroup(handle)) return { ...handle, inputs: handle.inputs.map((x) => { const identifiedHandle = x.id != null ? x : { ...x, id: String(idx) }; idx += 1; return identifiedHandle; }) }; if (isOutputGroup(handle)) return { ...handle, outputs: handle.outputs.map((x) => { const identifiedHandle = x.id != null ? x : { ...x, id: String(idx) }; idx += 1; return identifiedHandle; }) }; const identifiedHandle = handle.id != null ? handle : { ...handle, id: String(idx) }; idx += 1; return identifiedHandle; }); }; //#endregion export { identifyHandles, isConnected, isInputGroup, isOutputGroup, renderedIcon };