mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 04:20:55 +00:00
2 lines
8.4 KiB
JavaScript
2 lines
8.4 KiB
JavaScript
import{av as Fe,r as g,ad as ze,K as Q,N,cn as je,ag as W,j as w,co as Z,a1 as G,cp as ke,Q as Ie,cq as Ae,X as _e,af as Me,ah as $e,aj as Ke,cr as Ve,cs as Le,E as X,ct as Ue,cu as Xe,cv as Y,cw as q,cx as B,cy as Ye,cz as qe,V as Be,ak as He,aq as Qe,a8 as We,cA as Ze,ao as Ge,ap as Je,W as eo,cB as oo,Y as to}from"./index-7T7TTikv.js";import{u as ro}from"./use-uncontrolled-tg0LIUAX.js";function ao(e,r={active:!0}){return typeof e!="function"||!r.active?r.onKeyDown||Fe:t=>{var s;t.key==="Escape"&&(e(t),(s=r.onTrigger)==null||s.call(r))}}const H=["mousedown","touchstart"];function so(e,r,t){const s=g.useRef(null);return g.useEffect(()=>{const d=l=>{const{target:i}=l??{};if(Array.isArray(t)){const n=(i==null?void 0:i.hasAttribute("data-ignore-outside-clicks"))||!document.body.contains(i)&&i.tagName!=="HTML";t.every(c=>!!c&&!l.composedPath().includes(c))&&!n&&e()}else s.current&&!s.current.contains(i)&&e()};return(r||H).forEach(l=>document.addEventListener(l,d)),()=>{(r||H).forEach(l=>document.removeEventListener(l,d))}},[s,e,t]),s}const[no,J]=ze("Popover component was not found in the tree");var ee={dropdown:"m_38a85659",arrow:"m_a31dc6c1",overlay:"m_3d7bc908"};const io={},F=Q((e,r)=>{var C,E,y,m;const t=N("PopoverDropdown",io,e),{className:s,style:d,vars:l,children:i,onKeyDownCapture:n,variant:a,classNames:c,styles:f,...O}=t,o=J(),D=je({opened:o.opened,shouldReturnFocus:o.returnFocus}),R=o.withRoles?{"aria-labelledby":o.getTargetId(),id:o.getDropdownId(),role:"dialog",tabIndex:-1}:{},b=W(r,o.floating);return o.disabled?null:w.jsx(Z,{...o.portalProps,withinPortal:o.withinPortal,children:w.jsx(G,{mounted:o.opened,...o.transitionProps,transition:((C=o.transitionProps)==null?void 0:C.transition)||"fade",duration:((E=o.transitionProps)==null?void 0:E.duration)??150,keepMounted:o.keepMounted,exitDuration:typeof((y=o.transitionProps)==null?void 0:y.exitDuration)=="number"?o.transitionProps.exitDuration:(m=o.transitionProps)==null?void 0:m.duration,children:v=>w.jsx(ke,{active:o.trapFocus&&o.opened,innerRef:b,children:w.jsxs(Ie,{...R,...O,variant:a,onKeyDownCapture:ao(()=>{var S,x;(S=o.onClose)==null||S.call(o),(x=o.onDismiss)==null||x.call(o)},{active:o.closeOnEscape,onTrigger:D,onKeyDown:n}),"data-position":o.placement,"data-fixed":o.floatingStrategy==="fixed"||void 0,...o.getStyles("dropdown",{className:s,props:t,classNames:c,styles:f,style:[{...v,zIndex:o.zIndex,top:o.y??0,left:o.x??0,width:o.width==="target"?void 0:_e(o.width)},o.resolvedStyles.dropdown,f==null?void 0:f.dropdown,d]}),children:[i,w.jsx(Ae,{ref:o.arrowRef,arrowX:o.arrowX,arrowY:o.arrowY,visible:o.withArrow,position:o.placement,arrowSize:o.arrowSize,arrowRadius:o.arrowRadius,arrowOffset:o.arrowOffset,arrowPosition:o.arrowPosition,...o.getStyles("arrow",{props:t,classNames:c,styles:f})})]})})})})});F.classes=ee;F.displayName="@mantine/core/PopoverDropdown";const lo={refProp:"ref",popupType:"dialog"},oe=Q((e,r)=>{const{children:t,refProp:s,popupType:d,...l}=N("PopoverTarget",lo,e);if(!Me(t))throw new Error("Popover.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");const i=l,n=J(),a=W(n.reference,$e(t),r),c=n.withRoles?{"aria-haspopup":d,"aria-expanded":n.opened,"aria-controls":n.getDropdownId(),id:n.getTargetId()}:{};return g.cloneElement(t,{...i,...c,...n.targetProps,className:Ke(n.targetProps.className,i.className,t.props.className),[s]:a,...n.controlled?null:{onClick:n.onToggle}})});oe.displayName="@mantine/core/PopoverTarget";function co(e){if(e===void 0)return{shift:!0,flip:!0};const r={...e};return e.shift===void 0&&(r.shift=!0),e.flip===void 0&&(r.flip=!0),r}function uo(e,r){const t=co(e.middlewares),s=[Ue(e.offset)];return t.shift&&s.push(Xe(typeof t.shift=="boolean"?{limiter:Y(),padding:5}:{limiter:Y(),padding:5,...t.shift})),t.flip&&s.push(typeof t.flip=="boolean"?q():q(t.flip)),t.inline&&s.push(typeof t.inline=="boolean"?B():B(t.inline)),s.push(Ye({element:e.arrowRef,padding:e.arrowOffset})),(t.size||e.width==="target")&&s.push(qe({...typeof t.size=="boolean"?{}:t.size,apply({rects:d,availableWidth:l,availableHeight:i,...n}){var f;const c=((f=r().refs.floating.current)==null?void 0:f.style)??{};t.size&&(typeof t.size=="object"&&t.size.apply?t.size.apply({rects:d,availableWidth:l,availableHeight:i,...n}):Object.assign(c,{maxWidth:`${l}px`,maxHeight:`${i}px`})),e.width==="target"&&Object.assign(c,{width:`${d.reference.width}px`})}})),s}function fo(e){const[r,t]=ro({value:e.opened,defaultValue:e.defaultOpened,finalValue:!1,onChange:e.onChange}),s=g.useRef(r),d=()=>{r&&!e.disabled&&t(!1)},l=()=>!e.disabled&&t(!r),i=Ve({strategy:e.strategy,placement:e.position,middleware:uo(e,()=>i)});return Le({opened:r,position:e.position,positionDependencies:e.positionDependencies||[],floating:i}),X(()=>{var n;(n=e.onPositionChange)==null||n.call(e,i.placement)},[i.placement]),X(()=>{var n,a;r!==s.current&&(r?(a=e.onOpen)==null||a.call(e):(n=e.onClose)==null||n.call(e)),s.current=r},[r,e.onClose,e.onOpen]),{floating:i,controlled:typeof e.opened=="boolean",opened:r,onClose:d,onToggle:l}}const po={position:"bottom",offset:8,positionDependencies:[],transitionProps:{transition:"fade",duration:150},middlewares:{flip:!0,shift:!0,inline:!1},arrowSize:7,arrowOffset:5,arrowRadius:0,arrowPosition:"side",closeOnClickOutside:!0,withinPortal:!0,closeOnEscape:!0,trapFocus:!1,withRoles:!0,returnFocus:!1,withOverlay:!1,clickOutsideEvents:["mousedown","touchstart"],zIndex:Je("popover"),__staticSelector:"Popover",width:"max-content"},go=eo((e,{radius:r,shadow:t})=>({dropdown:{"--popover-radius":r===void 0?void 0:to(r),"--popover-shadow":oo(t)}}));function T(e){var M,$,K,V,L,U;const r=N("Popover",po,e),{children:t,position:s,offset:d,onPositionChange:l,positionDependencies:i,opened:n,transitionProps:a,onExitTransitionEnd:c,onEnterTransitionEnd:f,width:O,middlewares:o,withArrow:D,arrowSize:R,arrowOffset:b,arrowRadius:C,arrowPosition:E,unstyled:y,classNames:m,styles:v,closeOnClickOutside:S,withinPortal:x,portalProps:te,closeOnEscape:re,clickOutsideEvents:ae,trapFocus:se,onClose:ne,onDismiss:P,onOpen:ie,onChange:le,zIndex:de,radius:ce,shadow:ue,id:fe,defaultOpened:pe,__staticSelector:z,withRoles:ge,disabled:j,returnFocus:we,variant:he,keepMounted:me,vars:ye,floatingStrategy:k,withOverlay:ve,overlayProps:h,...xe}=r,I=Be({name:z,props:r,classes:ee,classNames:m,styles:v,unstyled:y,rootSelector:"dropdown",vars:ye,varsResolver:go}),{resolvedStyles:Pe}=He({classNames:m,styles:v,props:r}),A=g.useRef(null),[Oe,De]=g.useState(null),[Re,be]=g.useState(null),{dir:Ce}=Qe(),_=We(fe),u=fo({middlewares:o,width:O,position:Ze(Ce,s),offset:typeof d=="number"?d+(D?R/2:0):d,arrowRef:A,arrowOffset:b,onPositionChange:l,positionDependencies:i,opened:n,defaultOpened:pe,onChange:le,onOpen:ie,onClose:ne,onDismiss:P,strategy:k,disabled:j});so(()=>{S&&(u.onClose(),P==null||P())},ae,[Oe,Re]);const Ee=g.useCallback(p=>{De(p),u.floating.refs.setReference(p)},[u.floating.refs.setReference]),Se=g.useCallback(p=>{be(p),u.floating.refs.setFloating(p)},[u.floating.refs.setFloating]),Te=g.useCallback(()=>{var p;(p=a==null?void 0:a.onExited)==null||p.call(a),c==null||c()},[a==null?void 0:a.onExited,c]),Ne=g.useCallback(()=>{var p;(p=a==null?void 0:a.onEntered)==null||p.call(a),f==null||f()},[a==null?void 0:a.onEntered,f]);return w.jsxs(no,{value:{returnFocus:we,disabled:j,controlled:u.controlled,reference:Ee,floating:Se,x:u.floating.x,y:u.floating.y,arrowX:(K=($=(M=u.floating)==null?void 0:M.middlewareData)==null?void 0:$.arrow)==null?void 0:K.x,arrowY:(U=(L=(V=u.floating)==null?void 0:V.middlewareData)==null?void 0:L.arrow)==null?void 0:U.y,opened:u.opened,arrowRef:A,transitionProps:{...a,onExited:Te,onEntered:Ne},width:O,withArrow:D,arrowSize:R,arrowOffset:b,arrowRadius:C,arrowPosition:E,placement:u.floating.placement,trapFocus:se,withinPortal:x,portalProps:te,zIndex:de,radius:ce,shadow:ue,closeOnEscape:re,onDismiss:P,onClose:u.onClose,onToggle:u.onToggle,getTargetId:()=>`${_}-target`,getDropdownId:()=>`${_}-dropdown`,withRoles:ge,targetProps:xe,__staticSelector:z,classNames:m,styles:v,unstyled:y,variant:he,keepMounted:me,getStyles:I,resolvedStyles:Pe,floatingStrategy:k},children:[t,ve&&w.jsx(G,{transition:"fade",mounted:u.opened,duration:(a==null?void 0:a.duration)||250,exitDuration:(a==null?void 0:a.exitDuration)||250,children:p=>w.jsx(Z,{withinPortal:x,children:w.jsx(Ge,{...h,...I("overlay",{className:h==null?void 0:h.className,style:[p,h==null?void 0:h.style]})})})})]})}T.Target=oe;T.Dropdown=F;T.displayName="@mantine/core/Popover";T.extend=e=>e;export{T as P,so as u};
|