react-box-tools
Version:
Box tools react components, utils and hooks
2 lines (1 loc) • 1.33 kB
JavaScript
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),l=require("./clsx-CeOg4f1g.cjs"),f=require("./shakeElement-wd-duhQ7.cjs"),n=require("react"),h=e=>{const{show:s,backdrop:x=!0,shakeClass:m,movable:j,onFirstOpen:o,onOpen:a,onClose:c,keepMount:v=!1,className:b,size:N="md",position:y="center",children:$,...O}=e,d=n.useRef(null),[r,u]=n.useState(!1),[i,k]=n.useState(!1);return n.useEffect(()=>{!i&&s&&(k(!0),o&&o()),s&&!r&&(document.body.style.overflow="hidden",u(!0),a&&a()),!s&&r&&(document.querySelectorAll(".modal.show").length<=1&&(document.body.style.overflow="visible"),u(!1),c&&c())},[s,r,i,a,c,o]),!v&&!s||!i&&!s?t.jsx(t.Fragment,{}):t.jsxs("div",{className:l.clsx(`modal ${s&&"show"} ${x&&"backdrop"} ${b}`),children:[t.jsx("div",{...O,ref:d,className:l.clsx(`modal-content ${N} ${y}`),children:$}),j&&s&&t.jsx(f.MoveElement,{elementRef:d}),m&&s&&t.jsx(f.ShakeElement,{className:m,elementRef:d})]})},S=e=>t.jsx("div",{...e,className:l.clsx(`modal-head ${e.className}`),children:e.children}),g=e=>t.jsx("div",{...e,className:l.clsx(`modal-body ${e.className}`),children:e.children}),q=e=>t.jsx("div",{...e,className:l.clsx(`modal-foot ${e.className}`),children:e.children}),w=Object.assign(h,{Head:S,Body:g,Foot:q});exports.Component=h;exports.Modal=w;
;