2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
import{r as s,O as re,Q as pe,S as Y,U as Qe,V as Re,W as N,X as ve,j as l,Y as Ze,Z as Je,N as Pe,_ as Ce,$ as Me,a0 as et,a1 as F,u as I,c as w,a2 as Ee,a3 as tt,a4 as nt,a5 as ot,a6 as st,a7 as Ne,a8 as Be,a9 as rt,aa as at}from"./index-B92aEPQH.js";import{d as it}from"./Card-DPmHd5BI.js";const lt=typeof global<"u"&&global.navigator&&global.navigator.product==="ReactNative",ct=typeof document<"u",Oe=ct||lt?s.useLayoutEffect:s.useEffect,ke=e=>!e||typeof e=="function"?e:t=>{e.current=t};function dt(e,t){const n=ke(e),o=ke(t);return r=>{n&&n(r),o&&o(r)}}function ye(e,t){return s.useMemo(()=>dt(e,t),[e,t])}var se;function je(e){if((!se&&se!==0||e)&&re){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t),se=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return se}function ut(){return s.useState(null)}function fe(e){e===void 0&&(e=pe());try{var t=e.activeElement;return!t||!t.nodeName?null:t}catch{return e.body}}function ft(e){const t=s.useRef(e);return t.current=e,t}function ht(e){const t=ft(e);s.useEffect(()=>()=>t.current(),[])}function gt(e=document){const t=e.defaultView;return Math.abs(t.innerWidth-e.documentElement.clientWidth)}const Se=Qe("modal-open");class be{constructor({ownerDocument:t,handleContainerOverflow:n=!0,isRTL:o=!1}={}){this.handleContainerOverflow=n,this.isRTL=o,this.modals=[],this.ownerDocument=t}getScrollbarWidth(){return gt(this.ownerDocument)}getElement(){return(this.ownerDocument||document).body}setModalAttributes(t){}removeModalAttributes(t){}setContainerStyle(t){const n={overflow:"hidden"},o=this.isRTL?"paddingLeft":"paddingRight",r=this.getElement();t.style={overflow:r.style.overflow,[o]:r.style[o]},t.scrollBarWidth&&(n[o]=`${parseInt(Y(r,o)||"0",10)+t.scrollBarWidth}px`),r.setAttribute(Se,""),Y(r,n)}reset(){[...this.modals].forEach(t=>this.remove(t))}removeContainerStyle(t){const n=this.getElement();n.removeAttribute(Se),Object.assign(n.style,t.style)}add(t){let n=this.modals.indexOf(t);return n!==-1||(n=this.modals.length,this.modals.push(t),this.setModalAttributes(t),n!==0)||(this.state={scrollBarWidth:this.getScrollbarWidth(),style:{}},this.handleContainerOverflow&&this.setContainerStyle(this.state)),n}remove(t){const n=this.modals.indexOf(t);n!==-1&&(this.modals.splice(n,1),!this.modals.length&&this.handleContainerOverflow&&this.removeContainerStyle(this.state),this.removeModalAttributes(t))}isTopModal(t){return!!this.modals.length&&this.modals[this.modals.length-1]===t}}const he=(e,t)=>re?e==null?(t||pe()).body:(typeof e=="function"&&(e=e()),e&&"current"in e&&(e=e.current),e&&("nodeType"in e||e.getBoundingClientRect)?e:null):null;function mt(e,t){const n=Re(),[o,r]=s.useState(()=>he(e,n?.document));if(!o){const a=he(e);a&&r(a)}return s.useEffect(()=>{},[t,o]),s.useEffect(()=>{const a=he(e);a!==o&&r(a)},[e,o]),o}function Et({children:e,in:t,onExited:n,mountOnEnter:o,unmountOnExit:r}){const a=s.useRef(null),u=s.useRef(t),f=N(n);s.useEffect(()=>{t?u.current=!0:f(a.current)},[t,f]);const g=ye(a,ve(e)),d=s.cloneElement(e,{ref:g});return t?d:r||!u.current&&o?null:d}const pt=["onEnter","onEntering","onEntered","onExit","onExiting","onExited","addEndListener","children"];function Rt(e,t){if(e==null)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.indexOf(o)>=0)continue;n[o]=e[o]}return n}function vt(e){let{onEnter:t,onEntering:n,onEntered:o,onExit:r,onExiting:a,onExited:u,addEndListener:f,children:g}=e,d=Rt(e,pt);const m=s.useRef(null),p=ye(m,ve(g)),E=b=>C=>{b&&m.current&&b(m.current,C)},v=s.useCallback(E(t),[t]),$=s.useCallback(E(n),[n]),O=s.useCallback(E(o),[o]),_=s.useCallback(E(r),[r]),y=s.useCallback(E(a),[a]),H=s.useCallback(E(u),[u]),k=s.useCallback(E(f),[f]);return Object.assign({},d,{nodeRef:m},t&&{onEnter:v},n&&{onEntering:$},o&&{onEntered:O},r&&{onExit:_},a&&{onExiting:y},u&&{onExited:H},f&&{addEndListener:k},{children:typeof g=="function"?(b,C)=>g(b,Object.assign({},C,{ref:p})):s.cloneElement(g,{ref:p})})}const yt=["component"];function bt(e,t){if(e==null)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.indexOf(o)>=0)continue;n[o]=e[o]}return n}const Tt=s.forwardRef((e,t)=>{let{component:n}=e,o=bt(e,yt);const r=vt(o);return l.jsx(n,Object.assign({ref:t},r))});function xt({in:e,onTransition:t}){const n=s.useRef(null),o=s.useRef(!0),r=N(t);return Oe(()=>{if(!n.current)return;let a=!1;return r({in:e,element:n.current,initial:o.current,isStale:()=>a}),()=>{a=!0}},[e,r]),Oe(()=>(o.current=!1,()=>{o.current=!0}),[]),n}function wt({children:e,in:t,onExited:n,onEntered:o,transition:r}){const[a,u]=s.useState(!t);t&&a&&u(!1);const f=xt({in:!!t,onTransition:d=>{const m=()=>{d.isStale()||(d.in?o?.(d.element,d.initial):(u(!0),n?.(d.element)))};Promise.resolve(r(d)).then(m,p=>{throw d.in||u(!0),p})}}),g=ye(f,ve(e));return a&&!t?null:s.cloneElement(e,{ref:g})}function Ae(e,t,n){return e?l.jsx(Tt,Object.assign({},n,{component:e})):t?l.jsx(wt,Object.assign({},n,{transition:t})):l.jsx(Et,Object.assign({},n))}const Ct=["show","role","className","style","children","backdrop","keyboard","onBackdropClick","onEscapeKeyDown","transition","runTransition","backdropTransition","runBackdropTransition","autoFocus","enforceFocus","restoreFocus","restoreFocusOptions","renderDialog","renderBackdrop","manager","container","onShow","onHide","onExit","onExited","onExiting","onEnter","onEntering","onEntered"];function Mt(e,t){if(e==null)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.indexOf(o)>=0)continue;n[o]=e[o]}return n}let ge;function Nt(e){return ge||(ge=new be({ownerDocument:e?.document})),ge}function Ot(e){const t=Re(),n=e||Nt(t),o=s.useRef({dialog:null,backdrop:null});return Object.assign(o.current,{add:()=>n.add(o.current),remove:()=>n.remove(o.current),isTopModal:()=>n.isTopModal(o.current),setDialogRef:s.useCallback(r=>{o.current.dialog=r},[]),setBackdropRef:s.useCallback(r=>{o.current.backdrop=r},[])})}const De=s.forwardRef((e,t)=>{let{show:n=!1,role:o="dialog",className:r,style:a,children:u,backdrop:f=!0,keyboard:g=!0,onBackdropClick:d,onEscapeKeyDown:m,transition:p,runTransition:E,backdropTransition:v,runBackdropTransition:$,autoFocus:O=!0,enforceFocus:_=!0,restoreFocus:y=!0,restoreFocusOptions:H,renderDialog:k,renderBackdrop:b=c=>l.jsx("div",Object.assign({},c)),manager:C,container:ae,onShow:q,onHide:U=()=>{},onExit:ie,onExited:K,onExiting:Q,onEnter:Z,onEntering:J,onEntered:P}=e,le=Mt(e,Ct);const T=Re(),j=mt(ae),h=Ot(C),ce=Ze(),ee=Je(n),[M,S]=s.useState(!n),R=s.useRef(null);s.useImperativeHandle(t,()=>h,[h]),re&&!ee&&n&&(R.current=fe(T?.document)),n&&M&&S(!1);const x=N(()=>{if(h.add(),A.current=Ce(document,"keydown",ue),V.current=Ce(document,"focus",()=>setTimeout(de),!0),q&&q(),O){var c,oe;const X=fe((c=(oe=h.dialog)==null?void 0:oe.ownerDocument)!=null?c:T?.document);h.dialog&&X&&!Me(h.dialog,X)&&(R.current=X,h.dialog.focus())}}),G=N(()=>{if(h.remove(),A.current==null||A.current(),V.current==null||V.current(),y){var c;(c=R.current)==null||c.focus==null||c.focus(H),R.current=null}});s.useEffect(()=>{!n||!j||x()},[n,j,x]),s.useEffect(()=>{M&&G()},[M,G]),ht(()=>{G()});const de=N(()=>{if(!_||!ce()||!h.isTopModal())return;const c=fe(T?.document);h.dialog&&c&&!Me(h.dialog,c)&&h.dialog.focus()}),te=N(c=>{c.target===c.currentTarget&&(d?.(c),f===!0&&U())}),ue=N(c=>{g&&et(c)&&h.isTopModal()&&(m?.(c),c.defaultPrevented||U())}),V=s.useRef(),A=s.useRef(),ne=(...c)=>{S(!0),K?.(...c)};if(!j)return null;const L=Object.assign({role:o,ref:h.setDialogRef,"aria-modal":o==="dialog"?!0:void 0},le,{style:a,className:r,tabIndex:-1});let z=k?k(L):l.jsx("div",Object.assign({},L,{children:s.cloneElement(u,{role:"document"})}));z=Ae(p,E,{unmountOnExit:!0,mountOnEnter:!0,appear:!0,in:!!n,onExit:ie,onExiting:Q,onExited:ne,onEnter:Z,onEntering:J,onEntered:P,children:z});let B=null;return f&&(B=b({ref:h.setBackdropRef,onClick:te}),B=Ae(v,$,{in:!!n,appear:!0,mountOnEnter:!0,unmountOnExit:!0,children:B})),l.jsx(l.Fragment,{children:Pe.createPortal(l.jsxs(l.Fragment,{children:[B,z]}),j)})});De.displayName="Modal";const kt=Object.assign(De,{Manager:be});function jt(e,t){return e.classList?e.classList.contains(t):(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")!==-1}function St(e,t){e.classList?e.classList.add(t):jt(e,t)||(typeof e.className=="string"?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))}function Le(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function At(e,t){e.classList?e.classList.remove(t):typeof e.className=="string"?e.className=Le(e.className,t):e.setAttribute("class",Le(e.className&&e.className.baseVal||"",t))}const W={FIXED_CONTENT:".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",STICKY_CONTENT:".sticky-top",NAVBAR_TOGGLER:".navbar-toggler"};class Lt extends be{adjustAndStore(t,n,o){const r=n.style[t];n.dataset[t]=r,Y(n,{[t]:`${parseFloat(Y(n,t))+o}px`})}restore(t,n){const o=n.dataset[t];o!==void 0&&(delete n.dataset[t],Y(n,{[t]:o}))}setContainerStyle(t){super.setContainerStyle(t);const n=this.getElement();if(St(n,"modal-open"),!t.scrollBarWidth)return;const o=this.isRTL?"paddingLeft":"paddingRight",r=this.isRTL?"marginLeft":"marginRight";F(n,W.FIXED_CONTENT).forEach(a=>this.adjustAndStore(o,a,t.scrollBarWidth)),F(n,W.STICKY_CONTENT).forEach(a=>this.adjustAndStore(r,a,-t.scrollBarWidth)),F(n,W.NAVBAR_TOGGLER).forEach(a=>this.adjustAndStore(r,a,t.scrollBarWidth))}removeContainerStyle(t){super.removeContainerStyle(t);const n=this.getElement();At(n,"modal-open");const o=this.isRTL?"paddingLeft":"paddingRight",r=this.isRTL?"marginLeft":"marginRight";F(n,W.FIXED_CONTENT).forEach(a=>this.restore(o,a)),F(n,W.STICKY_CONTENT).forEach(a=>this.restore(r,a)),F(n,W.NAVBAR_TOGGLER).forEach(a=>this.restore(r,a))}}let me;function Bt(e){return me||(me=new Lt(e)),me}const Fe=s.forwardRef(({className:e,bsPrefix:t,as:n="div",...o},r)=>(t=I(t,"modal-body"),l.jsx(n,{ref:r,className:w(e,t),...o})));Fe.displayName="ModalBody";const We=s.createContext({onHide(){}}),Te=s.forwardRef(({bsPrefix:e,className:t,contentClassName:n,centered:o,size:r,fullscreen:a,children:u,scrollable:f,...g},d)=>{e=I(e,"modal");const m=`${e}-dialog`,p=typeof a=="string"?`${e}-fullscreen-${a}`:`${e}-fullscreen`;return l.jsx("div",{...g,ref:d,className:w(m,t,r&&`${e}-${r}`,o&&`${m}-centered`,f&&`${m}-scrollable`,a&&p),children:l.jsx("div",{className:w(`${e}-content`,n),children:u})})});Te.displayName="ModalDialog";const Ie=s.forwardRef(({className:e,bsPrefix:t,as:n="div",...o},r)=>(t=I(t,"modal-footer"),l.jsx(n,{ref:r,className:w(e,t),...o})));Ie.displayName="ModalFooter";const $e=s.forwardRef(({closeLabel:e="Close",closeVariant:t,closeButton:n=!1,onHide:o,children:r,...a},u)=>{const f=s.useContext(We),g=Ee(()=>{f?.onHide(),o?.()});return l.jsxs("div",{ref:u,...a,children:[r,n&&l.jsx(tt,{"aria-label":e,variant:t,onClick:g})]})});$e.displayName="AbstractModalHeader";const _e=s.forwardRef(({bsPrefix:e,className:t,closeLabel:n="Close",closeButton:o=!1,...r},a)=>(e=I(e,"modal-header"),l.jsx($e,{ref:a,...r,className:w(t,e),closeLabel:n,closeButton:o})));_e.displayName="ModalHeader";const Dt=it("h4"),He=s.forwardRef(({className:e,bsPrefix:t,as:n=Dt,...o},r)=>(t=I(t,"modal-title"),l.jsx(n,{ref:r,className:w(e,t),...o})));He.displayName="ModalTitle";function Ft(e){return l.jsx(Be,{...e,timeout:null})}function Wt(e){return l.jsx(Be,{...e,timeout:null})}const Ue=s.forwardRef(({bsPrefix:e,className:t,style:n,dialogClassName:o,contentClassName:r,children:a,dialogAs:u=Te,"data-bs-theme":f,"aria-labelledby":g,"aria-describedby":d,"aria-label":m,show:p=!1,animation:E=!0,backdrop:v=!0,keyboard:$=!0,onEscapeKeyDown:O,onShow:_,onHide:y,container:H,autoFocus:k=!0,enforceFocus:b=!0,restoreFocus:C=!0,restoreFocusOptions:ae,onEntered:q,onExit:U,onExiting:ie,onEnter:K,onEntering:Q,onExited:Z,backdropClassName:J,manager:P,...le},T)=>{const[j,h]=s.useState({}),[ce,ee]=s.useState(!1),M=s.useRef(!1),S=s.useRef(!1),R=s.useRef(null),[x,G]=ut(),de=nt(T,G),te=Ee(y),ue=ot();e=I(e,"modal");const V=s.useMemo(()=>({onHide:te}),[te]);function A(){return P||Bt({isRTL:ue})}function ne(i){if(!re)return;const D=A().getScrollbarWidth()>0,we=i.scrollHeight>pe(i).documentElement.clientHeight;h({paddingRight:D&&!we?je():void 0,paddingLeft:!D&&we?je():void 0})}const L=Ee(()=>{x&&ne(x.dialog)});st(()=>{Ne(window,"resize",L),R.current==null||R.current()});const z=()=>{M.current=!0},B=i=>{M.current&&x&&i.target===x.dialog&&(S.current=!0),M.current=!1},c=()=>{ee(!0),R.current=at(x.dialog,()=>{ee(!1)})},oe=i=>{i.target===i.currentTarget&&c()},X=i=>{if(v==="static"){oe(i);return}if(S.current||i.target!==i.currentTarget){S.current=!1;return}y?.()},Ke=i=>{$?O?.(i):(i.preventDefault(),v==="static"&&c())},Ge=(i,D)=>{i&&ne(i),K?.(i,D)},Ve=i=>{R.current==null||R.current(),U?.(i)},ze=(i,D)=>{Q?.(i,D),rt(window,"resize",L)},Xe=i=>{i&&(i.style.display=""),Z?.(i),Ne(window,"resize",L)},Ye=s.useCallback(i=>l.jsx("div",{...i,className:w(`${e}-backdrop`,J,!E&&"show")}),[E,J,e]),xe={...n,...j};xe.display="block";const qe=i=>l.jsx("div",{role:"dialog",...i,style:xe,className:w(t,e,ce&&`${e}-static`,!E&&"show"),onClick:v?X:void 0,onMouseUp:B,"data-bs-theme":f,"aria-label":m,"aria-labelledby":g,"aria-describedby":d,children:l.jsx(u,{...le,onMouseDown:z,className:o,contentClassName:r,children:a})});return l.jsx(We.Provider,{value:V,children:l.jsx(kt,{show:p,ref:de,backdrop:v,container:H,keyboard:!0,autoFocus:k,enforceFocus:b,restoreFocus:C,restoreFocusOptions:ae,onEscapeKeyDown:Ke,onShow:_,onHide:y,onEnter:Ge,onEntering:ze,onEntered:q,onExit:Ve,onExiting:ie,onExited:Xe,manager:A(),transition:E?Ft:void 0,backdropTransition:E?Wt:void 0,renderBackdrop:Ye,renderDialog:qe})})});Ue.displayName="Modal";const _t=Object.assign(Ue,{Body:Fe,Header:_e,Title:He,Footer:Ie,Dialog:Te,TRANSITION_DURATION:300,BACKDROP_TRANSITION_DURATION:150});export{_t as M,_e as a,Fe as b,Ie as c,He as d};
|