lecom-modeler 0.32.1 → 0.32.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -83,4 +83,4 @@
83
83
  height: 100%;
84
84
  object-fit: contain;
85
85
  }
86
- `,y.head.appendChild(N),y.title=p;let T=y.createElement("img");T.alt="Diagram",y.body.appendChild(T),await new Promise((P,O)=>{let S=!1,B=Q=>{S||(S=!0,Q?O(Q):P())};T.onload=()=>B(),T.onerror=()=>B(new Error("Failed to load print image")),T.src=f,T.complete&&T.naturalWidth>0&&B()});let _=g.contentWindow;if(!_)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let I=()=>{g.parentNode&&document.body.removeChild(g)};_.addEventListener("afterprint",I,{once:!0}),window.setTimeout(I,6e4),_.focus(),_.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};var Ce=require("react/jsx-runtime");function Vp(){let{t:e}=(0,Te.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Dp(),[s,l]=(0,Op.useState)(!1);return(0,Ce.jsxs)(Te.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,Ce.jsx)(Te.DropdownMenuTrigger,{asChild:!0,children:(0,Ce.jsx)("div",{children:(0,Ce.jsxs)(Te.Tooltip,{children:[(0,Ce.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(Te.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ce.jsx)(ko.FolderOutputIcon,{})})}),!s&&(0,Ce.jsx)(Te.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,Ce.jsxs)(Te.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ce.jsxs)(Te.Tooltip,{children:[(0,Ce.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,Ce.jsx)(ko.FileImageIcon,{})})}),(0,Ce.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,Ce.jsxs)(Te.Tooltip,{children:[(0,Ce.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:a,onClick:()=>o(),children:(0,Ce.jsx)(ko.FileCodeIcon,{})})}),(0,Ce.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,Ce.jsxs)(Te.Tooltip,{children:[(0,Ce.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,Ce.jsx)(ko.PrinterIcon,{})})}),(0,Ce.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var he=require("react/jsx-runtime"),Hp=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=(0,Ve.useTranslation)(),{clearSelection:i}=Io(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:m}=K(),{getNodes:p,getEdges:h}=(0,Dr.useReactFlow)(),E=(0,Dr.useKeyPress)(["v","V"]),f=(0,Dr.useKeyPress)(["h","H"]),g=(0,go.useCallback)(()=>{i(),m(!0),u(!1)},[i,m,u]),y=(0,go.useCallback)(()=>{u(!0),m(!1)},[u,m]),[x,w]=(0,go.useState)(!1),N=(0,go.useCallback)(async()=>{w(!0);try{let T=p(),_=h(),I=await o({nodes:T,edges:_});n(I)}finally{w(!1)}},[p,h,o,n]);return(0,go.useEffect)(()=>{E&&!c&&a==="edit"&&y()},[E,y,c,a]),(0,go.useEffect)(()=>{f&&!d&&a==="edit"&&g()},[f,g,d,a]),(0,he.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&(0,he.jsxs)(he.Fragment,{children:[(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:y,children:(0,he.jsx)(eo.MousePointerIcon,{})})}),(0,he.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),(0,he.jsx)(ca,{shortcut:"V"})]})]}),(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:g,children:(0,he.jsx)(eo.HandIcon,{})})}),(0,he.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",(0,he.jsx)(ca,{shortcut:"H"})]})]})]}),(0,he.jsx)(Vp,{}),a==="edit"&&(0,he.jsxs)(he.Fragment,{children:[(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:x,onClick:N,children:x?(0,he.jsx)(eo.Loader2Icon,{className:"animate-spin"}):(0,he.jsx)(eo.ListCheckIcon,{})})}),(0,he.jsx)(Ve.TooltipContent,{color:"black",children:r(x?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,he.jsx)(Sp,{disabled:e.length>0||t.length>0})]}),(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:(0,he.jsx)(eo.MapIcon,{})})}),(0,he.jsx)(Ve.TooltipContent,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};var lt=require("@produto-lecom/lecom-ui"),ps=require("lucide-react"),Tt=require("react/jsx-runtime"),Gp=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,lt.useTranslation)();return(0,Tt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Tt.jsxs)(lt.Tooltip,{children:[(0,Tt.jsx)(lt.TooltipTrigger,{asChild:!0,children:(0,Tt.jsx)(lt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,Tt.jsx)(ps.UndoIcon,{})})}),(0,Tt.jsx)(lt.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,Tt.jsxs)(lt.Tooltip,{children:[(0,Tt.jsx)(lt.TooltipTrigger,{asChild:!0,children:(0,Tt.jsx)(lt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,Tt.jsx)(ps.RedoIcon,{})})}),(0,Tt.jsx)(lt.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})};var Fn=require("@xyflow/react"),He=require("@produto-lecom/lecom-ui"),Xn=require("lucide-react");var Re=require("react/jsx-runtime"),Bp=()=>{let{t:e}=(0,He.useTranslation)(),t=(0,Fn.useNodes)(),o=(0,Fn.useEdges)(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=(0,Fn.useReactFlow)(),s=t.length===0&&o.length===0;return(0,Re.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:(0,Re.jsx)(Xn.ScanIcon,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:(0,Re.jsx)(Xn.ZoomOut,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:(0,Re.jsx)(Aa,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:(0,Re.jsx)(Xn.ZoomIn,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var zp=require("@xyflow/react"),to=require("@produto-lecom/lecom-ui"),fs=require("react");var Gt=require("react/jsx-runtime"),Yp=()=>{let e=(0,fs.useRef)(null),{t}=(0,to.useTranslation)(),{setDraggableNode:o}=Vn(),n=(0,zp.useNodes)(),{setIsDragging:r}=K(),[i,a]=(0,fs.useState)(void 0),s=[{type:"START_EVENT",icon:Xr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:cn,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Zn,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Jn,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Sa,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Ca,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:pn,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:mn,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:dn,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Ia,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Yr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a((0,Gt.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Gt.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Gt.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!wo(c.type,n),m=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Gt.jsxs)(to.Tooltip,{children:[(0,Gt.jsx)(to.TooltipTrigger,{asChild:!0,children:(0,Gt.jsx)(to.Button,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:p=>l(p,c),children:(0,Gt.jsx)(c.icon,{})},d)}),(0,Gt.jsx)(to.TooltipContent,{color:"black",side:"right",children:m})]},d)})}),(0,Gt.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var Ze=require("react/jsx-runtime"),ua=e=>e.preventDefault(),pa=(0,Ro.forwardRef)((e,t)=>{let o=(0,oo.useKeyPress)("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=K(),l=(0,Ro.useRef)(null),c=(0,Ro.useRef)(s),d=(0,Ro.useRef)(o),{nodes:u,edges:m,actions:p,events:h,components:E,controls:f}=cp(),{t:g}=(0,Do.useTranslation)();c.current=s,d.current=o;let y=up(l,c,d);(0,Ro.useImperativeHandle)(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection}));let x=s||o||r!=="edit",w=x?[0,1,2]:Ir,N=s||o||y,T=a&&!o&&!y,_=r==="edit"&&T,I=!x&&!y,C=r==="view"||T;return(0,Ze.jsxs)("div",{ref:l,className:"w-full h-full",children:[r==="edit"&&(0,Ze.jsx)(Yp,{}),(0,Ze.jsx)(pp,{}),(0,Ze.jsxs)(oo.ReactFlow,v(b({},h),{id:`modeler-${n}`,className:H({"is-hand-tool":N,"is-pan-tool-active":N}),edges:m,nodes:u,nodeTypes:au,edgeTypes:lu,minZoom:na,maxZoom:mu,panOnDrag:w,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:C,nodesConnectable:_,nodesDraggable:_,connectionLineComponent:ru,selectionMode:oo.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:_?"Delete":null,selectionKeyCode:null,defaultViewport:gu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:ua,onNodeContextMenu:ua,onEdgeContextMenu:ua,proOptions:{hideAttribution:!0},children:[(0,Ze.jsx)(oo.Background,{gap:pu,size:uu,color:du,bgColor:cu}),i&&(0,Ze.jsxs)(Do.Tooltip,{children:[(0,Ze.jsx)(Do.TooltipTrigger,{asChild:!0,children:(0,Ze.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,Ze.jsx)(oo.MiniMap,{pannable:!0,zoomable:!0,position:fu,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,Ze.jsx)(Do.TooltipContent,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),(0,Ze.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,Ze.jsx)(Gp,b({},f)),r!=="readonly"&&(0,Ze.jsx)(Hp,{nodes:u,edges:m,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),(0,Ze.jsx)(Bp,{})]}),(0,Ze.jsx)(E.HelperLines,{})]}))]})});pa.displayName="Editor";var Wp=require("@xyflow/react"),ms=require("react"),Fp=require("react/jsx-runtime"),ry=e=>({width:e.width,height:e.height,transform:e.transform}),fa="rgba(51, 103, 217, 0.4)",zc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,Wp.useStore)(ry),i=(0,ms.useRef)(null);return(0,ms.useEffect)(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=fa,t&&(s.beginPath(),s.strokeStyle=t.color||fa,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||fa,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),(0,Fp.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var Un=require("@produto-lecom/lecom-ui"),Oo=require("react");var Or=require("react/jsx-runtime"),qt=new Map,Xp=(0,Oo.createContext)(null),An=()=>{let e=(0,Oo.useContext)(Xp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Up=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=(0,Oo.useState)(e||"pt_BR");(0,Oo.useEffect)(()=>{e&&(i(e),Un.i18n.changeLanguage(e))},[e]);let a=h=>{let E=qt.size;if(E===0)throw new Error("No modeler instances found");if(E===1||!h){let[g]=qt.values();return g}let f=qt.get(h);if(!f)throw new Error(`Modeler instance with ID "${h}" not found`);return f},s=(h,E)=>{let f=a(E);return f==null?void 0:f.selectElements(h)},l=async h=>{let E=a(h);return E==null?void 0:E.clearSelection()},c=(h,E)=>{let f=a(E);return f==null?void 0:f.configureElement(h)},d=(h,E)=>{let f=a(E);return f==null?void 0:f.getConfigureElement(h)},u=async(h,E)=>{let f=a(E);await(f==null?void 0:f.importFromMxGraph(h))},m=h=>{let E=a(h);return E==null?void 0:E.exportToMxGraph()},p=h=>{let E=a(h);return(E==null?void 0:E.getElementsCount())||0};return(0,Or.jsx)(Xp.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:m,getElementsCount:p,toast:o},children:(0,Or.jsxs)(Un.TooltipProvider,{children:[!o&&(0,Or.jsx)(Un.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};var gs=require("react/jsx-runtime"),qp=(0,Ge.createContext)(null),K=()=>{let e=(0,Ge.useContext)(qp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Zp=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c})=>{let{t:d}=(0,$p.useTranslation)(),{defaultMode:u}=An(),m=(0,Ge.useId)(),[p]=(0,Ge.useState)(o||m),[h,E]=(0,Ge.useState)(n||u||"edit"),[f,g]=(0,Ge.useState)(xr),[y,x]=(0,Ge.useState)(!1),[w,N]=(0,Ge.useState)(!0),[T,_]=(0,Ge.useState)(!1),[I,C]=(0,Ge.useState)(!1),[P,O]=(0,Ge.useState)(!1),[S,B]=(0,Ge.useState)(!1),[Q,$]=(0,Ge.useState)(!1),[J,Y]=(0,Ge.useState)(null);(0,Ge.useEffect)(()=>{n&&E(n)},[n]);let M=(0,Ge.useMemo)(()=>t||Ld(d),[t,d]),R={instanceId:p,initialDiagram:M,mode:h,edgeHighlight:r,lastElementId:f,isInitialized:y,isMinimapOpen:I,isMoveTool:w,isHandTool:T,isDragging:P,isMultipleSelection:Q,isConnecting:S,setLastElementId:g,setIsInitialized:x,reconnectingEdgeId:J,setIsMinimapOpen:C,setIsMoveTool:N,setIsHandTool:_,setIsDragging:O,setIsConnecting:B,setIsMultipleSelection:$,setReconnectingEdgeId:Y,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c};return(0,gs.jsx)(Kp.ReactFlowProvider,{children:(0,gs.jsx)(qp.Provider,{value:R,children:(0,gs.jsx)(pa,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});
86
+ `,y.head.appendChild(N),y.title=p;let T=y.createElement("img");T.alt="Diagram",y.body.appendChild(T),await new Promise((P,O)=>{let S=!1,B=Q=>{S||(S=!0,Q?O(Q):P())};T.onload=()=>B(),T.onerror=()=>B(new Error("Failed to load print image")),T.src=f,T.complete&&T.naturalWidth>0&&B()});let _=g.contentWindow;if(!_)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let I=()=>{g.parentNode&&document.body.removeChild(g)};_.addEventListener("afterprint",I,{once:!0}),window.setTimeout(I,6e4),_.focus(),_.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};var Ce=require("react/jsx-runtime");function Vp(){let{t:e}=(0,Te.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Dp(),[s,l]=(0,Op.useState)(!1);return(0,Ce.jsxs)(Te.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,Ce.jsx)(Te.DropdownMenuTrigger,{asChild:!0,children:(0,Ce.jsx)("div",{children:(0,Ce.jsxs)(Te.Tooltip,{children:[(0,Ce.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(Te.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,Ce.jsx)(ko.FolderOutputIcon,{})})}),!s&&(0,Ce.jsx)(Te.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,Ce.jsxs)(Te.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,Ce.jsxs)(Te.Tooltip,{children:[(0,Ce.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,Ce.jsx)(ko.FileImageIcon,{})})}),(0,Ce.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,Ce.jsxs)(Te.Tooltip,{children:[(0,Ce.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:a,onClick:()=>o(),children:(0,Ce.jsx)(ko.FileCodeIcon,{})})}),(0,Ce.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,Ce.jsxs)(Te.Tooltip,{children:[(0,Ce.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,Ce.jsx)(Te.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,Ce.jsx)(ko.PrinterIcon,{})})}),(0,Ce.jsx)(Te.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var he=require("react/jsx-runtime"),Hp=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=(0,Ve.useTranslation)(),{clearSelection:i}=Io(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:m}=K(),{getNodes:p,getEdges:h}=(0,Dr.useReactFlow)(),E=(0,Dr.useKeyPress)(["v","V"]),f=(0,Dr.useKeyPress)(["h","H"]),g=(0,go.useCallback)(()=>{i(),m(!0),u(!1)},[i,m,u]),y=(0,go.useCallback)(()=>{u(!0),m(!1)},[u,m]),[x,w]=(0,go.useState)(!1),N=(0,go.useCallback)(async()=>{w(!0);try{let T=p(),_=h(),I=await o({nodes:T,edges:_});n(I)}finally{w(!1)}},[p,h,o,n]);return(0,go.useEffect)(()=>{E&&!c&&a==="edit"&&y()},[E,y,c,a]),(0,go.useEffect)(()=>{f&&!d&&a==="edit"&&g()},[f,g,d,a]),(0,he.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&(0,he.jsxs)(he.Fragment,{children:[(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:y,children:(0,he.jsx)(eo.MousePointerIcon,{})})}),(0,he.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),(0,he.jsx)(ca,{shortcut:"V"})]})]}),(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:g,children:(0,he.jsx)(eo.HandIcon,{})})}),(0,he.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",(0,he.jsx)(ca,{shortcut:"H"})]})]})]}),(0,he.jsx)(Vp,{}),a==="edit"&&(0,he.jsxs)(he.Fragment,{children:[(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:x,onClick:N,children:x?(0,he.jsx)(eo.Loader2Icon,{className:"animate-spin"}):(0,he.jsx)(eo.ListCheckIcon,{})})}),(0,he.jsx)(Ve.TooltipContent,{color:"black",children:r(x?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,he.jsx)(Sp,{disabled:e.length>0||t.length>0})]}),(0,he.jsxs)(Ve.Tooltip,{children:[(0,he.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,he.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:(0,he.jsx)(eo.MapIcon,{})})}),(0,he.jsx)(Ve.TooltipContent,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};var lt=require("@produto-lecom/lecom-ui"),ps=require("lucide-react"),Tt=require("react/jsx-runtime"),Gp=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,lt.useTranslation)();return(0,Tt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Tt.jsxs)(lt.Tooltip,{children:[(0,Tt.jsx)(lt.TooltipTrigger,{asChild:!0,children:(0,Tt.jsx)(lt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,Tt.jsx)(ps.UndoIcon,{})})}),(0,Tt.jsx)(lt.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,Tt.jsxs)(lt.Tooltip,{children:[(0,Tt.jsx)(lt.TooltipTrigger,{asChild:!0,children:(0,Tt.jsx)(lt.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,Tt.jsx)(ps.RedoIcon,{})})}),(0,Tt.jsx)(lt.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})};var Fn=require("@xyflow/react"),He=require("@produto-lecom/lecom-ui"),Xn=require("lucide-react");var Re=require("react/jsx-runtime"),Bp=()=>{let{t:e}=(0,He.useTranslation)(),t=(0,Fn.useNodes)(),o=(0,Fn.useEdges)(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=(0,Fn.useReactFlow)(),s=t.length===0&&o.length===0;return(0,Re.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:(0,Re.jsx)(Xn.ScanIcon,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:(0,Re.jsx)(Xn.ZoomOut,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:(0,Re.jsx)(Aa,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:(0,Re.jsx)(Xn.ZoomIn,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var zp=require("@xyflow/react"),to=require("@produto-lecom/lecom-ui"),fs=require("react");var Gt=require("react/jsx-runtime"),Yp=()=>{let e=(0,fs.useRef)(null),{t}=(0,to.useTranslation)(),{setDraggableNode:o}=Vn(),n=(0,zp.useNodes)(),{setIsDragging:r}=K(),[i,a]=(0,fs.useState)(void 0),s=[{type:"START_EVENT",icon:Xr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:cn,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Zn,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Jn,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Sa,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Ca,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:pn,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:mn,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:dn,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Ia,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Yr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a((0,Gt.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Gt.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Gt.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!wo(c.type,n),m=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Gt.jsxs)(to.Tooltip,{children:[(0,Gt.jsx)(to.TooltipTrigger,{asChild:!0,children:(0,Gt.jsx)(to.Button,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:p=>l(p,c),children:(0,Gt.jsx)(c.icon,{})},d)}),(0,Gt.jsx)(to.TooltipContent,{color:"black",side:"right",children:m})]},d)})}),(0,Gt.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var Ze=require("react/jsx-runtime"),ua=e=>e.preventDefault(),pa=(0,Ro.forwardRef)((e,t)=>{let o=(0,oo.useKeyPress)("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=K(),l=(0,Ro.useRef)(null),c=(0,Ro.useRef)(s),d=(0,Ro.useRef)(o),{nodes:u,edges:m,actions:p,events:h,components:E,controls:f}=cp(),{t:g}=(0,Do.useTranslation)();c.current=s,d.current=o;let y=up(l,c,d);(0,Ro.useImperativeHandle)(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection}));let x=s||o||r!=="edit",w=x?[0,1,2]:Ir,N=s||o||y,T=a&&!o&&!y,_=r==="edit"&&T,I=!x&&!y,C=r==="view"||T;return(0,Ze.jsxs)("div",{ref:l,className:"w-full h-full",children:[r==="edit"&&(0,Ze.jsx)(Yp,{}),(0,Ze.jsx)(pp,{}),(0,Ze.jsxs)(oo.ReactFlow,v(b({},h),{id:`modeler-${n}`,className:H({"is-hand-tool":N,"is-pan-tool-active":N}),edges:m,nodes:u,nodeTypes:au,edgeTypes:lu,minZoom:na,maxZoom:mu,panOnDrag:w,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:C,nodesConnectable:_,nodesDraggable:_,connectionLineComponent:ru,selectionMode:oo.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:_?"Delete":null,selectionKeyCode:null,defaultViewport:gu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:ua,onNodeContextMenu:ua,onEdgeContextMenu:ua,proOptions:{hideAttribution:!0},children:[(0,Ze.jsx)(oo.Background,{gap:pu,size:uu,color:du,bgColor:cu}),i&&(0,Ze.jsxs)(Do.Tooltip,{children:[(0,Ze.jsx)(Do.TooltipTrigger,{asChild:!0,children:(0,Ze.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,Ze.jsx)(oo.MiniMap,{pannable:!0,zoomable:!0,position:fu,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,Ze.jsx)(Do.TooltipContent,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),(0,Ze.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,Ze.jsx)(Gp,b({},f)),r!=="readonly"&&(0,Ze.jsx)(Hp,{nodes:u,edges:m,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),(0,Ze.jsx)(Bp,{})]}),(0,Ze.jsx)(E.HelperLines,{})]}))]})});pa.displayName="Editor";var Wp=require("@xyflow/react"),ms=require("react"),Fp=require("react/jsx-runtime"),ry=e=>({width:e.width,height:e.height,transform:e.transform}),fa="rgba(51, 103, 217, 0.4)",zc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,Wp.useStore)(ry),i=(0,ms.useRef)(null);return(0,ms.useEffect)(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=fa,t&&(s.beginPath(),s.strokeStyle=t.color||fa,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||fa,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),(0,Fp.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var Un=require("@produto-lecom/lecom-ui"),Oo=require("react");var Or=require("react/jsx-runtime"),qt=new Map,Xp=(0,Oo.createContext)(null),An=()=>{let e=(0,Oo.useContext)(Xp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Up=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=(0,Oo.useState)(e||"pt_BR");(0,Oo.useEffect)(()=>{e&&(i(e),Un.i18n.changeLanguage(e))},[e]);let a=h=>{let E=qt.size;if(E===0)throw new Error("No modeler instances found");if(E===1||!h){let[g]=qt.values();return g}let f=qt.get(h);if(!f)throw new Error(`Modeler instance with ID "${h}" not found`);return f},s=(h,E)=>{let f=a(E);return f==null?void 0:f.selectElements(h)},l=async h=>{let E=a(h);return E==null?void 0:E.clearSelection()},c=(h,E)=>{let f=a(E);return f==null?void 0:f.configureElement(h)},d=(h,E)=>{let f=a(E);return f==null?void 0:f.getConfigureElement(h)},u=async(h,E)=>{let f=a(E);await(f==null?void 0:f.importFromMxGraph(h))},m=h=>{let E=a(h);return E==null?void 0:E.exportToMxGraph()},p=h=>{let E=a(h);return(E==null?void 0:E.getElementsCount())||0};return(0,Or.jsx)(Xp.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:m,getElementsCount:p,toast:o},children:(0,Or.jsxs)(Un.TooltipProvider,{children:[!o&&(0,Or.jsx)(Un.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};var gs=require("react/jsx-runtime"),qp=(0,Ge.createContext)(null),K=()=>{let e=(0,Ge.useContext)(qp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Zp=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c})=>{let{t:d}=(0,$p.useTranslation)(),{defaultMode:u}=An(),m=(0,Ge.useId)(),[p]=(0,Ge.useState)(o||m),[h,E]=(0,Ge.useState)(n||u||"edit"),[f,g]=(0,Ge.useState)(xr),[y,x]=(0,Ge.useState)(!1),[w,N]=(0,Ge.useState)(!0),[T,_]=(0,Ge.useState)(!1),[I,C]=(0,Ge.useState)(!1),[P,O]=(0,Ge.useState)(!1),[S,B]=(0,Ge.useState)(!1),[Q,$]=(0,Ge.useState)(!1),[J,Y]=(0,Ge.useState)(null);(0,Ge.useEffect)(()=>{n&&E(n)},[n]);let M=(0,Ge.useMemo)(()=>t||Ld(d),[t,d]),R={instanceId:p,initialDiagram:M,mode:h,edgeHighlight:r,lastElementId:f,isInitialized:y,isMinimapOpen:I,isMoveTool:w,isHandTool:T,isDragging:P,isMultipleSelection:Q,isConnecting:S,setLastElementId:g,setIsInitialized:x,reconnectingEdgeId:J,setIsMinimapOpen:C,setIsMoveTool:N,setIsHandTool:_,setIsDragging:O,setIsConnecting:B,setIsMultipleSelection:$,setReconnectingEdgeId:Y,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c};return(0,gs.jsx)(Kp.ReactFlowProvider,{children:(0,gs.jsx)(qp.Provider,{value:R,children:(0,gs.jsx)(pa,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});
package/lib/index.js CHANGED
@@ -83,4 +83,4 @@ var ap=Object.defineProperty,lp=Object.defineProperties;var cp=Object.getOwnProp
83
83
  height: 100%;
84
84
  object-fit: contain;
85
85
  }
86
- `,y.head.appendChild(N),y.title=p;let T=y.createElement("img");T.alt="Diagram",y.body.appendChild(T),await new Promise((P,O)=>{let S=!1,B=Q=>{S||(S=!0,Q?O(Q):P())};T.onload=()=>B(),T.onerror=()=>B(new Error("Failed to load print image")),T.src=f,T.complete&&T.naturalWidth>0&&B()});let _=g.contentWindow;if(!_)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let I=()=>{g.parentNode&&document.body.removeChild(g)};_.addEventListener("afterprint",I,{once:!0}),window.setTimeout(I,6e4),_.focus(),_.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};import{jsx as Pe,jsxs as qo}from"react/jsx-runtime";function Xu(){let{t:e}=Kx(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Fu(),[s,l]=jx(!1);return qo(Xx,{modal:!1,open:s,onOpenChange:l,children:[Pe($x,{asChild:!0,children:Pe("div",{children:qo(mi,{children:[Pe(hi,{asChild:!0,children:Pe(Fx,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Pe(Jx,{})})}),!s&&Pe(gi,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),qo(Ux,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[qo(mi,{children:[Pe(hi,{asChild:!0,children:Pe(Is,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Pe(Zx,{})})}),Pe(gi,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),qo(mi,{children:[Pe(hi,{asChild:!0,children:Pe(Is,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Pe(qx,{})})}),Pe(gi,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),qo(mi,{children:[Pe(hi,{asChild:!0,children:Pe(Is,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Pe(Qx,{})})}),Pe(gi,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as Ku,jsx as Se,jsxs as Lt}from"react/jsx-runtime";var qu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=tE(),{clearSelection:i}=zt(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:m}=K(),{getNodes:p,getEdges:h}=eE(),E=Uu(["v","V"]),f=Uu(["h","H"]),g=As(()=>{i(),m(!0),u(!1)},[i,m,u]),y=As(()=>{u(!0),m(!1)},[u,m]),[x,w]=aE(!1),N=As(async()=>{w(!0);try{let T=p(),_=h(),I=await o({nodes:T,edges:_});n(I)}finally{w(!1)}},[p,h,o,n]);return $u(()=>{E&&!c&&a==="edit"&&y()},[E,y,c,a]),$u(()=>{f&&!d&&a==="edit"&&g()},[f,g,d,a]),Lt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&Lt(Ku,{children:[Lt(xi,{children:[Se(bi,{asChild:!0,children:Se(yi,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:y,children:Se(sE,{})})}),Lt(Ei,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Se(vs,{shortcut:"V"})]})]}),Lt(xi,{children:[Se(bi,{asChild:!0,children:Se(yi,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:g,children:Se(oE,{})})}),Lt(Ei,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Se(vs,{shortcut:"H"})]})]})]}),Se(Xu,{}),a==="edit"&&Lt(Ku,{children:[Lt(xi,{children:[Se(bi,{asChild:!0,children:Se(yi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:x,onClick:N,children:x?Se(rE,{className:"animate-spin"}):Se(nE,{})})}),Se(Ei,{color:"black",children:r(x?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),Se(zu,{disabled:e.length>0||t.length>0})]}),Lt(xi,{children:[Se(bi,{asChild:!0,children:Se(yi,{size:"small",variant:"ghost",color:"grey",className:H(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:Se(iE,{})})}),Se(Ei,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Zu,Tooltip as Ju,TooltipContent as Qu,TooltipTrigger as ju,useTranslation as lE}from"@produto-lecom/lecom-ui";import{RedoIcon as cE,UndoIcon as dE}from"lucide-react";import{jsx as Qt,jsxs as Cs}from"react/jsx-runtime";var ep=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=lE();return Cs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Cs(Ju,{children:[Qt(ju,{asChild:!0,children:Qt(Zu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Qt(dE,{})})}),Qt(Qu,{color:"black",children:r("editor.controls.history.undo")})]}),Cs(Ju,{children:[Qt(ju,{asChild:!0,children:Qt(Zu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Qt(cE,{})})}),Qt(Qu,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as uE,useNodes as pE,useReactFlow as fE}from"@xyflow/react";import{Button as _i,Tooltip as Ti,TooltipContent as Ni,TooltipTrigger as vi,useTranslation as mE}from"@produto-lecom/lecom-ui";import{ScanIcon as gE,ZoomIn as hE,ZoomOut as yE}from"lucide-react";import{jsx as Oe,jsxs as Dn}from"react/jsx-runtime";var tp=()=>{let{t:e}=mE(),t=pE(),o=uE(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=fE(),s=t.length===0&&o.length===0;return Dn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Dn(Ti,{children:[Oe(vi,{asChild:!0,children:Oe(_i,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:Oe(gE,{})})}),Oe(Ni,{color:"black",children:e("editor.controls.zoom.fit")})]}),Dn(Ti,{children:[Oe(vi,{asChild:!0,children:Oe(_i,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:Oe(yE,{})})}),Oe(Ni,{color:"black",children:e("editor.controls.zoom.out")})]}),Dn(Ti,{children:[Oe(vi,{asChild:!0,children:Oe(_i,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:Oe($s,{})})}),Oe(Ni,{color:"black",children:e("editor.controls.zoom.reset")})]}),Dn(Ti,{children:[Oe(vi,{asChild:!0,children:Oe(_i,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:Oe(hE,{})})}),Oe(Ni,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as xE}from"@xyflow/react";import{Button as EE,Tooltip as bE,TooltipContent as _E,TooltipTrigger as TE,useTranslation as NE}from"@produto-lecom/lecom-ui";import{useRef as vE,useState as wE}from"react";import{jsx as Eo,jsxs as op}from"react/jsx-runtime";var np=()=>{let e=vE(null),{t}=NE(),{setDraggableNode:o}=Yo(),n=xE(),{setIsDragging:r}=K(),[i,a]=wE(void 0),s=[{type:"START_EVENT",icon:zn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:bo,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Jo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:jo,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Js,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Zs,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:To,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:No,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:_o,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Us,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Gn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a(Eo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return op("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[Eo("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!Bt(c.type,n),m=u?t("editor.toolbar.start_event_already_exists"):c.label;return op(bE,{children:[Eo(TE,{asChild:!0,children:Eo(EE,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:p=>l(p,c),children:Eo(c.icon,{})},d)}),Eo(_E,{color:"black",side:"right",children:m})]},d)})}),Eo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as dt,jsxs as wi}from"react/jsx-runtime";var Ms=e=>e.preventDefault(),Ps=PE((e,t)=>{let o=ME("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=K(),l=Ss(null),c=Ss(s),d=Ss(o),{nodes:u,edges:m,actions:p,events:h,components:E,controls:f}=vu(),{t:g}=OE();c.current=s,d.current=o;let y=wu(l,c,d);LE(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection}));let x=s||o||r!=="edit",w=x?[0,1,2]:Cn,N=s||o||y,T=a&&!o&&!y,_=r==="edit"&&T,I=!x&&!y,C=r==="view"||T;return wi("div",{ref:l,className:"w-full h-full",children:[r==="edit"&&dt(np,{}),dt(Au,{}),wi(CE,v(b({},h),{id:`modeler-${n}`,className:H({"is-hand-tool":N,"is-pan-tool-active":N}),edges:m,nodes:u,nodeTypes:Dd,edgeTypes:Od,minZoom:Ts,maxZoom:Yd,panOnDrag:w,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:C,nodesConnectable:_,nodesDraggable:_,connectionLineComponent:Ld,selectionMode:SE.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:_?"Delete":null,selectionKeyCode:null,defaultViewport:Wd,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:Ms,onNodeContextMenu:Ms,onEdgeContextMenu:Ms,proOptions:{hideAttribution:!0},children:[dt(IE,{gap:Bd,size:Gd,color:Hd,bgColor:Vd}),i&&wi(kE,{children:[dt(DE,{asChild:!0,children:dt("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:dt(AE,{pannable:!0,zoomable:!0,position:zd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),dt(RE,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),wi("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&dt(ep,b({},f)),r!=="readonly"&&dt(qu,{nodes:u,edges:m,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),dt(tp,{})]}),dt(E.HelperLines,{})]}))]})});Ps.displayName="Editor";import{useStore as VE}from"@xyflow/react";import{useEffect as HE,useRef as GE}from"react";import{jsx as zE}from"react/jsx-runtime";var BE=e=>({width:e.width,height:e.height,transform:e.transform}),Ls="rgba(51, 103, 217, 0.4)",rc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=VE(BE),i=GE(null);return HE(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=Ls,t&&(s.beginPath(),s.strokeStyle=t.color||Ls,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||Ls,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),zE("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as YE,Notification as WE,TooltipProvider as FE}from"@produto-lecom/lecom-ui";import{createContext as XE,useContext as UE,useEffect as $E,useState as KE}from"react";import{jsx as rp,jsxs as ZE}from"react/jsx-runtime";var Et=new Map,ip=XE(null),bn=()=>{let e=UE(ip);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},qE=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=KE(e||"pt_BR");$E(()=>{e&&(i(e),YE.changeLanguage(e))},[e]);let a=h=>{let E=Et.size;if(E===0)throw new Error("No modeler instances found");if(E===1||!h){let[g]=Et.values();return g}let f=Et.get(h);if(!f)throw new Error(`Modeler instance with ID "${h}" not found`);return f},s=(h,E)=>{let f=a(E);return f==null?void 0:f.selectElements(h)},l=async h=>{let E=a(h);return E==null?void 0:E.clearSelection()},c=(h,E)=>{let f=a(E);return f==null?void 0:f.configureElement(h)},d=(h,E)=>{let f=a(E);return f==null?void 0:f.getConfigureElement(h)},u=async(h,E)=>{let f=a(E);await(f==null?void 0:f.importFromMxGraph(h))},m=h=>{let E=a(h);return E==null?void 0:E.exportToMxGraph()},p=h=>{let E=a(h);return(E==null?void 0:E.getElementsCount())||0};return rp(ip.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:m,getElementsCount:p,toast:o},children:ZE(FE,{children:[!o&&rp(WE,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as ks}from"react/jsx-runtime";var sp=jE(null),K=()=>{let e=e1(sp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},r1=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c})=>{let{t:d}=JE(),{defaultMode:u}=bn(),m=o1(),[p]=ut(o||m),[h,E]=ut(n||u||"edit"),[f,g]=ut(vn),[y,x]=ut(!1),[w,N]=ut(!0),[T,_]=ut(!1),[I,C]=ut(!1),[P,O]=ut(!1),[S,B]=ut(!1),[Q,$]=ut(!1),[J,Y]=ut(null);t1(()=>{n&&E(n)},[n]);let M=n1(()=>t||Jc(d),[t,d]),R={instanceId:p,initialDiagram:M,mode:h,edgeHighlight:r,lastElementId:f,isInitialized:y,isMinimapOpen:I,isMoveTool:w,isHandTool:T,isDragging:P,isMultipleSelection:Q,isConnecting:S,setLastElementId:g,setIsInitialized:x,reconnectingEdgeId:J,setIsMinimapOpen:C,setIsMoveTool:N,setIsHandTool:_,setIsDragging:O,setIsConnecting:B,setIsMultipleSelection:$,setReconnectingEdgeId:Y,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c};return ks(QE,{children:ks(sp.Provider,{value:R,children:ks(Ps,{ref:e})})})};export{ve as EditorMode,Ai as ElementPosition,Vn as ElementType,Ci as GatewayElementVariant,at as GatewayVariant,r1 as Modeler,qE as ModelerProvider,ht as NodeAttribute,se as NodeType,et as NodeVariant,Si as RoutingVariant,bn as useModeler};
86
+ `,y.head.appendChild(N),y.title=p;let T=y.createElement("img");T.alt="Diagram",y.body.appendChild(T),await new Promise((P,O)=>{let S=!1,B=Q=>{S||(S=!0,Q?O(Q):P())};T.onload=()=>B(),T.onerror=()=>B(new Error("Failed to load print image")),T.src=f,T.complete&&T.naturalWidth>0&&B()});let _=g.contentWindow;if(!_)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let I=()=>{g.parentNode&&document.body.removeChild(g)};_.addEventListener("afterprint",I,{once:!0}),window.setTimeout(I,6e4),_.focus(),_.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};import{jsx as Pe,jsxs as qo}from"react/jsx-runtime";function Xu(){let{t:e}=Kx(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Fu(),[s,l]=jx(!1);return qo(Xx,{modal:!1,open:s,onOpenChange:l,children:[Pe($x,{asChild:!0,children:Pe("div",{children:qo(mi,{children:[Pe(hi,{asChild:!0,children:Pe(Fx,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Pe(Jx,{})})}),!s&&Pe(gi,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),qo(Ux,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[qo(mi,{children:[Pe(hi,{asChild:!0,children:Pe(Is,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Pe(Zx,{})})}),Pe(gi,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),qo(mi,{children:[Pe(hi,{asChild:!0,children:Pe(Is,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Pe(qx,{})})}),Pe(gi,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),qo(mi,{children:[Pe(hi,{asChild:!0,children:Pe(Is,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Pe(Qx,{})})}),Pe(gi,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as Ku,jsx as Se,jsxs as Lt}from"react/jsx-runtime";var qu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=tE(),{clearSelection:i}=zt(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:m}=K(),{getNodes:p,getEdges:h}=eE(),E=Uu(["v","V"]),f=Uu(["h","H"]),g=As(()=>{i(),m(!0),u(!1)},[i,m,u]),y=As(()=>{u(!0),m(!1)},[u,m]),[x,w]=aE(!1),N=As(async()=>{w(!0);try{let T=p(),_=h(),I=await o({nodes:T,edges:_});n(I)}finally{w(!1)}},[p,h,o,n]);return $u(()=>{E&&!c&&a==="edit"&&y()},[E,y,c,a]),$u(()=>{f&&!d&&a==="edit"&&g()},[f,g,d,a]),Lt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&Lt(Ku,{children:[Lt(xi,{children:[Se(bi,{asChild:!0,children:Se(yi,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:y,children:Se(sE,{})})}),Lt(Ei,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Se(vs,{shortcut:"V"})]})]}),Lt(xi,{children:[Se(bi,{asChild:!0,children:Se(yi,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:g,children:Se(oE,{})})}),Lt(Ei,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Se(vs,{shortcut:"H"})]})]})]}),Se(Xu,{}),a==="edit"&&Lt(Ku,{children:[Lt(xi,{children:[Se(bi,{asChild:!0,children:Se(yi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:x,onClick:N,children:x?Se(rE,{className:"animate-spin"}):Se(nE,{})})}),Se(Ei,{color:"black",children:r(x?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),Se(zu,{disabled:e.length>0||t.length>0})]}),Lt(xi,{children:[Se(bi,{asChild:!0,children:Se(yi,{size:"small",variant:"ghost",color:"grey",className:H(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:Se(iE,{})})}),Se(Ei,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Zu,Tooltip as Ju,TooltipContent as Qu,TooltipTrigger as ju,useTranslation as lE}from"@produto-lecom/lecom-ui";import{RedoIcon as cE,UndoIcon as dE}from"lucide-react";import{jsx as Qt,jsxs as Cs}from"react/jsx-runtime";var ep=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=lE();return Cs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Cs(Ju,{children:[Qt(ju,{asChild:!0,children:Qt(Zu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Qt(dE,{})})}),Qt(Qu,{color:"black",children:r("editor.controls.history.undo")})]}),Cs(Ju,{children:[Qt(ju,{asChild:!0,children:Qt(Zu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Qt(cE,{})})}),Qt(Qu,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as uE,useNodes as pE,useReactFlow as fE}from"@xyflow/react";import{Button as _i,Tooltip as Ti,TooltipContent as Ni,TooltipTrigger as vi,useTranslation as mE}from"@produto-lecom/lecom-ui";import{ScanIcon as gE,ZoomIn as hE,ZoomOut as yE}from"lucide-react";import{jsx as Oe,jsxs as Dn}from"react/jsx-runtime";var tp=()=>{let{t:e}=mE(),t=pE(),o=uE(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=fE(),s=t.length===0&&o.length===0;return Dn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Dn(Ti,{children:[Oe(vi,{asChild:!0,children:Oe(_i,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:Oe(gE,{})})}),Oe(Ni,{color:"black",children:e("editor.controls.zoom.fit")})]}),Dn(Ti,{children:[Oe(vi,{asChild:!0,children:Oe(_i,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:Oe(yE,{})})}),Oe(Ni,{color:"black",children:e("editor.controls.zoom.out")})]}),Dn(Ti,{children:[Oe(vi,{asChild:!0,children:Oe(_i,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:Oe($s,{})})}),Oe(Ni,{color:"black",children:e("editor.controls.zoom.reset")})]}),Dn(Ti,{children:[Oe(vi,{asChild:!0,children:Oe(_i,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:Oe(hE,{})})}),Oe(Ni,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as xE}from"@xyflow/react";import{Button as EE,Tooltip as bE,TooltipContent as _E,TooltipTrigger as TE,useTranslation as NE}from"@produto-lecom/lecom-ui";import{useRef as vE,useState as wE}from"react";import{jsx as Eo,jsxs as op}from"react/jsx-runtime";var np=()=>{let e=vE(null),{t}=NE(),{setDraggableNode:o}=Yo(),n=xE(),{setIsDragging:r}=K(),[i,a]=wE(void 0),s=[{type:"START_EVENT",icon:zn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:bo,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Jo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:jo,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Js,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Zs,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:To,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:No,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:_o,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Us,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Gn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a(Eo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return op("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[Eo("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!Bt(c.type,n),m=u?t("editor.toolbar.start_event_already_exists"):c.label;return op(bE,{children:[Eo(TE,{asChild:!0,children:Eo(EE,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:p=>l(p,c),children:Eo(c.icon,{})},d)}),Eo(_E,{color:"black",side:"right",children:m})]},d)})}),Eo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as dt,jsxs as wi}from"react/jsx-runtime";var Ms=e=>e.preventDefault(),Ps=PE((e,t)=>{let o=ME("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=K(),l=Ss(null),c=Ss(s),d=Ss(o),{nodes:u,edges:m,actions:p,events:h,components:E,controls:f}=vu(),{t:g}=OE();c.current=s,d.current=o;let y=wu(l,c,d);LE(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection}));let x=s||o||r!=="edit",w=x?[0,1,2]:Cn,N=s||o||y,T=a&&!o&&!y,_=r==="edit"&&T,I=!x&&!y,C=r==="view"||T;return wi("div",{ref:l,className:"w-full h-full",children:[r==="edit"&&dt(np,{}),dt(Au,{}),wi(CE,v(b({},h),{id:`modeler-${n}`,className:H({"is-hand-tool":N,"is-pan-tool-active":N}),edges:m,nodes:u,nodeTypes:Dd,edgeTypes:Od,minZoom:Ts,maxZoom:Yd,panOnDrag:w,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:C,nodesConnectable:_,nodesDraggable:_,connectionLineComponent:Ld,selectionMode:SE.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:_?"Delete":null,selectionKeyCode:null,defaultViewport:Wd,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:Ms,onNodeContextMenu:Ms,onEdgeContextMenu:Ms,proOptions:{hideAttribution:!0},children:[dt(IE,{gap:Bd,size:Gd,color:Hd,bgColor:Vd}),i&&wi(kE,{children:[dt(DE,{asChild:!0,children:dt("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:dt(AE,{pannable:!0,zoomable:!0,position:zd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),dt(RE,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),wi("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&dt(ep,b({},f)),r!=="readonly"&&dt(qu,{nodes:u,edges:m,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),dt(tp,{})]}),dt(E.HelperLines,{})]}))]})});Ps.displayName="Editor";import{useStore as VE}from"@xyflow/react";import{useEffect as HE,useRef as GE}from"react";import{jsx as zE}from"react/jsx-runtime";var BE=e=>({width:e.width,height:e.height,transform:e.transform}),Ls="rgba(51, 103, 217, 0.4)",rc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=VE(BE),i=GE(null);return HE(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=Ls,t&&(s.beginPath(),s.strokeStyle=t.color||Ls,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||Ls,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),zE("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as YE,Notification as WE,TooltipProvider as FE}from"@produto-lecom/lecom-ui";import{createContext as XE,useContext as UE,useEffect as $E,useState as KE}from"react";import{jsx as rp,jsxs as ZE}from"react/jsx-runtime";var Et=new Map,ip=XE(null),bn=()=>{let e=UE(ip);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},qE=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=KE(e||"pt_BR");$E(()=>{e&&(i(e),YE.changeLanguage(e))},[e]);let a=h=>{let E=Et.size;if(E===0)throw new Error("No modeler instances found");if(E===1||!h){let[g]=Et.values();return g}let f=Et.get(h);if(!f)throw new Error(`Modeler instance with ID "${h}" not found`);return f},s=(h,E)=>{let f=a(E);return f==null?void 0:f.selectElements(h)},l=async h=>{let E=a(h);return E==null?void 0:E.clearSelection()},c=(h,E)=>{let f=a(E);return f==null?void 0:f.configureElement(h)},d=(h,E)=>{let f=a(E);return f==null?void 0:f.getConfigureElement(h)},u=async(h,E)=>{let f=a(E);await(f==null?void 0:f.importFromMxGraph(h))},m=h=>{let E=a(h);return E==null?void 0:E.exportToMxGraph()},p=h=>{let E=a(h);return(E==null?void 0:E.getElementsCount())||0};return rp(ip.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:m,getElementsCount:p,toast:o},children:ZE(FE,{children:[!o&&rp(WE,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as ks}from"react/jsx-runtime";var sp=jE(null),K=()=>{let e=e1(sp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},r1=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c})=>{let{t:d}=JE(),{defaultMode:u}=bn(),m=o1(),[p]=ut(o||m),[h,E]=ut(n||u||"edit"),[f,g]=ut(vn),[y,x]=ut(!1),[w,N]=ut(!0),[T,_]=ut(!1),[I,C]=ut(!1),[P,O]=ut(!1),[S,B]=ut(!1),[Q,$]=ut(!1),[J,Y]=ut(null);t1(()=>{n&&E(n)},[n]);let M=n1(()=>t||Jc(d),[t,d]),R={instanceId:p,initialDiagram:M,mode:h,edgeHighlight:r,lastElementId:f,isInitialized:y,isMinimapOpen:I,isMoveTool:w,isHandTool:T,isDragging:P,isMultipleSelection:Q,isConnecting:S,setLastElementId:g,setIsInitialized:x,reconnectingEdgeId:J,setIsMinimapOpen:C,setIsMoveTool:N,setIsHandTool:_,setIsDragging:O,setIsConnecting:B,setIsMultipleSelection:$,setReconnectingEdgeId:Y,validateCustomDiagram:i,onElementChanges:a,onConfigureElement:s,onElementClick:l,onSubprocessValidationClick:c};return ks(QE,{children:ks(sp.Provider,{value:R,children:ks(Ps,{ref:e})})})};export{ve as EditorMode,Ai as ElementPosition,Vn as ElementType,Ci as GatewayElementVariant,at as GatewayVariant,r1 as Modeler,qE as ModelerProvider,ht as NodeAttribute,se as NodeType,et as NodeVariant,Si as RoutingVariant,bn as useModeler};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-modeler",
3
- "version": "0.32.1",
3
+ "version": "0.32.2",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",