@lerx/promise-modal 0.0.37 → 0.0.38

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.
@@ -1 +1 @@
1
- {"version":3,"file":"BootstrapProvider.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/BootstrapProvider/BootstrapProvider.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,uBAAuB,EAA0B,MAAM,QAAQ,CAAC;AAE9E,eAAO,MAAM,iBAAiB;;;;;;;;2DAsF7B,CAAC"}
1
+ {"version":3,"file":"BootstrapProvider.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/BootstrapProvider/BootstrapProvider.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,uBAAuB,EAA0B,MAAM,QAAQ,CAAC;AAE9E,eAAO,MAAM,iBAAiB;;;;;;;;2DAiE7B,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { Dictionary, Fn } from '../@aileron/types';
2
- import { type ConfigurationContextProviderProps } from '../providers/ConfigurationContext';
1
+ import type { Dictionary, Fn } from '../../../@aileron/types';
2
+ import { type ConfigurationContextProviderProps } from '../../../providers/ConfigurationContext';
3
3
  interface BootstrapProps extends ConfigurationContextProviderProps {
4
4
  usePathname: Fn<[], {
5
5
  pathname: string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../../src/bootstrap/BootstrapProvider/helpers/bootstrap.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,EAEL,KAAK,iCAAiC,EACvC,MAAM,gDAAgD,CAAC;AAIxD,UAAU,cAAe,SAAQ,iCAAiC;IAChE,WAAW,EAAE,EAAE,CAAC,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,eAAO,MAAM,SAAS,+JAWnB,cAAc,gCAkBd,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const useInitialize: () => {
2
+ readonly anchorRef: import("react").MutableRefObject<HTMLElement | null>;
3
+ readonly handleInitialize: (root?: HTMLElement) => void;
4
+ };
5
+ //# sourceMappingURL=useInitialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInitialize.d.ts","sourceRoot":"","sources":["../../../../src/bootstrap/BootstrapProvider/hooks/useInitialize.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa;;uCAMd,WAAW;CAuBtB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { BootstrapProvider } from './BootstrapProvider';
2
+ export { useBootstrap } from './useBootstrap';
2
3
  export type { BootstrapProviderHandle, BootstrapProviderProps } from './type';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/BootstrapProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,YAAY,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/BootstrapProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,YAAY,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { BootstrapProviderProps } from './type';
2
+ export declare const useBootstrap: ({ usePathname: useExternalPathname, ForegroundComponent, BackgroundComponent, TitleComponent, SubtitleComponent, ContentComponent, FooterComponent, options, context, mode, }?: BootstrapProviderProps & {
3
+ mode?: "manual" | "auto";
4
+ }) => {
5
+ portal: import("react").ReactPortal | null;
6
+ initialize: (element: HTMLElement) => void;
7
+ };
8
+ //# sourceMappingURL=useBootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBootstrap.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/BootstrapProvider/useBootstrap.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAErD,eAAO,MAAM,YAAY,mLAWtB,sBAAsB,GAAG;IAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;CAAE;;0BAgB1C,WAAW;CAsBxB,CAAC"}
@@ -1,3 +1,2 @@
1
- export { bootstrap } from './bootstrap';
2
- export { BootstrapProvider, type BootstrapProviderHandle, type BootstrapProviderProps, } from './BootstrapProvider';
1
+ export { useBootstrap, BootstrapProvider, type BootstrapProviderHandle, type BootstrapProviderProps, } from './BootstrapProvider';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -14,5 +14,5 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
16
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
17
- function h(e,n,t,o){if("a"===t&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!o:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?o:"a"===t?o.call(e):o?o.value:n.get(e)}function C(e,n,t,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof n?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,t):r?r.value=t:n.set(e,t),t}"function"==typeof SuppressedError&&SuppressedError;class g{static activate(){return!h(e,e,"f",n)&&C(e,e,!0,"f",n)}static anchor(n){if(h(e,e,"f",t)){const n=document.getElementById(h(e,e,"f",t).id);if(n)return n}const{tag:o="div",prefix:r="promise-modal",root:i=document.body}=n||{},s=document.createElement(o);return s.setAttribute("id",`${r}-${m.getRandomString(36)}`),i.appendChild(s),C(e,e,s,"f",t),s}static get prerender(){return h(e,e,"f",o)}static set openHandler(n){C(e,e,n,"f",r),C(e,e,[],"f",o)}static get unanchored(){return!h(e,e,"f",t)}static reset(){C(e,e,!1,"f",n),C(e,e,null,"f",t),C(e,e,[],"f",o),C(e,e,(n=>h(e,e,"f",o).push(n)),"f",r)}static open(n){h(e,e,"f",r).call(e,n)}}e=g,n={value:!1},t={value:null},o={value:[]},r={value:n=>h(e,e,"f",o).push(n)};class v{get alive(){return h(this,i,"f")}get visible(){return h(this,s,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,background:r,dimmed:c=!0,manualDestroy:u=!1,closeOnBackdropClick:d=!0,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"initiator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"title",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtitle",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"background",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualDestroy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"closeOnBackdropClick",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dimmed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ForegroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BackgroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i.set(this,void 0),s.set(this,void 0),a.set(this,void 0),l.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.dimmed=c,this.manualDestroy=u,this.closeOnBackdropClick=d,this.ForegroundComponent=p,this.BackgroundComponent=f,C(this,i,!0,"f"),C(this,s,!0,"f"),C(this,a,m,"f")}subscribe(e){return h(this,l,"f").push(e),()=>{C(this,l,h(this,l,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of h(this,l,"f"))e()}resolve(e){h(this,a,"f").call(this,e)}onDestroy(){const e=!0===h(this,i,"f");C(this,i,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===h(this,s,"f");C(this,s,!0,"f"),e&&this.publish()}onHide(){const e=!0===h(this,s,"f");C(this,s,!1,"f"),e&&this.publish()}}i=new WeakMap,s=new WeakMap,a=new WeakMap,l=new WeakMap;class y extends v{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:s,footer:a,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=s,this.footer=a}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class k extends v{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:s,footer:a,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=s,this.footer=a}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class x extends v{constructor({id:e,initiator:n,type:t,title:o,subtitle:r,content:i,defaultValue:s,Input:a,disabled:l,returnOnCancel:u,footer:d,background:m,dimmed:p,manualDestroy:f,closeOnBackdropClick:b,resolve:h,ForegroundComponent:g,BackgroundComponent:v}){super({id:e,initiator:n,title:o,subtitle:r,background:m,dimmed:p,manualDestroy:f,closeOnBackdropClick:b,resolve:h,ForegroundComponent:g,BackgroundComponent:v}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"Input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"returnOnCancel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),c.set(this,void 0),this.type=t,this.content=i,this.Input=a,this.defaultValue=s,C(this,c,s,"f"),this.disabled=l,this.returnOnCancel=u,this.footer=d}onChange(e){C(this,c,e,"f")}onConfirm(){this.resolve(h(this,c,"f")??null)}onClose(){this.returnOnCancel?this.resolve(h(this,c,"f")??null):this.resolve(null)}}c=new WeakMap;const j=e=>{switch(e.type){case"alert":return new y(e);case"confirm":return new k(e);case"prompt":return new x(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},w=d.createContext({}),O=d.memo((({usePathname:e,children:n})=>{const t=d.useRef(new Map),[o,r]=d.useState([]),i=p.useReference(o),{pathname:s}=e(),a=d.useRef(s),l=d.useRef(0),c=q(),f=d.useMemo((()=>m.convertMsFromDuration(c.duration)),[c]);p.useOnMountLayout((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=c;for(const o of g.prerender){const i=j({...o,id:l.current++,initiator:a.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});t.current.set(i.id,i),r((e=>[...e,i.id]))}return g.openHandler=o=>{const i=j({...o,id:l.current++,initiator:a.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});t.current.set(i.id,i),r((e=>[...e.filter((e=>{const n=!t.current.get(e)?.alive;return n&&t.current.delete(e),!n})),i.id]))},()=>{g.reset()}})),d.useLayoutEffect((()=>{for(const e of i.current){const n=t.current.get(e);n?.alive&&(n.initiator===s?n.onShow():n.onHide())}a.current=s}),[i,s]);const b=d.useCallback((e=>t.current.get(e)),[]),h=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onDestroy(),C.current?.())}),[]),C=d.useRef(),v=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onHide(),C.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),f))}),[f]),y=d.useCallback(((e,n)=>{const o=t.current.get(e);o&&"prompt"===o.type&&o.onChange(n)}),[]),k=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onConfirm(),v(e))}),[v]),x=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onClose(),v(e))}),[v]),O=d.useCallback((e=>({modal:b(e),onConfirm:()=>k(e),onClose:()=>x(e),onChange:n=>y(e,n),onDestroy:()=>h(e)})),[b,k,x,y,h]),D=d.useMemo((()=>({modalIds:o,getModalNode:b,onChange:y,onConfirm:k,onClose:x,onDestroy:h,getModal:O,setUpdater:e=>{C.current=e}})),[o,O,b,y,k,x,h]);return u.jsx(w.Provider,{value:D,children:n})})),D=()=>d.useContext(w),B=e=>{const{getModal:n}=D();return d.useMemo((()=>n(e)),[e,n])};function F(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const P=f.css("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:F}),M=f.css("production"===process.env.NODE_ENV?{name:"1kuk3a3",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black"}:{name:"16dbbea-frame",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black;label:frame;",toString:F}),S=({children:e})=>u.jsx("h2",{className:P,children:e}),E=({children:e})=>u.jsx("h3",{className:P,children:e}),N=({children:e})=>u.jsx("div",{className:P,children:e}),I=({confirmLabel:e,hideConfirm:n=!1,cancelLabel:t,hideCancel:o=!1,disabled:r,onConfirm:i,onCancel:s})=>u.jsxs("div",{children:[!n&&u.jsx("button",{onClick:i,disabled:r,children:e||"확인"}),!o&&"function"==typeof s&&u.jsx("button",{onClick:s,children:t||"취소"})]}),T=e=>e?.visible,V=(e=T,n=0)=>{const{modalIds:t,getModalNode:o}=D();return d.useMemo((()=>{let n=0;for(const r of t)e(o(r))&&n++;return n}),[o,t,n])},H=d.forwardRef((({id:e,onChangeOrder:n,children:t},o)=>{const r=V(),[i,s]=d.useMemo((()=>{const n=r>1;return[n?Math.floor(e/5)%3*100:0,n?e%5*35:0]}),[r,e]);return u.jsx("div",{ref:o,className:M,onClick:n,style:{marginBottom:`calc(25vh + ${i}px)`,marginLeft:`${i}px`,transform:`translate(${s}px, ${s}px)`},children:t})})),R=d.createContext({}),z=d.memo((({ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:r,FooterComponent:i,options:s,children:a})=>{const l=d.useMemo((()=>({BackgroundComponent:n,ForegroundComponent:e||H,TitleComponent:t||S,SubtitleComponent:o||E,ContentComponent:d.memo(r||N),FooterComponent:d.memo(i||I),options:{duration:"300ms",backdrop:"rgba(0, 0, 0, 0.5)",closeOnBackdropClick:!0,manualDestroy:!1,...s}})),[e,n,r,i,o,t,s]);return u.jsx(R.Provider,{value:l,children:a})})),L=()=>d.useContext(R),q=()=>d.useContext(R).options,A=d.createContext({}),_=({context:e,children:n})=>{const t=d.useMemo((()=>({context:e||{}})),[e]);return u.jsx(A.Provider,{value:t,children:n})},$=()=>d.useContext(A);function W(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const Y=f.css("production"===process.env.NODE_ENV?{name:"u7uu4v",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;}"}:{name:"coymdj-background",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;};label:background;",toString:W}),U=f.css("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:W}),G=f.css("production"===process.env.NODE_ENV?{name:"1wnowod",styles:"display:flex;align-items:center;justify-content:center"}:{name:"xppew7-visible",styles:"display:flex;align-items:center;justify-content:center;label:visible;",toString:W}),J=({modalId:e,onChangeOrder:n})=>{const{BackgroundComponent:t}=L(),{context:o}=$(),{modal:r,onClose:i,onChange:s,onConfirm:a,onDestroy:l}=B(e),c=d.useCallback((e=>{r&&r.closeOnBackdropClick&&r.visible&&i(),e.stopPropagation()}),[r,i]),m=d.useMemo((()=>r?.BackgroundComponent||t),[t,r]);return r?u.jsx("div",{className:f.cx(Y,{[G]:r.manualDestroy?r.alive:r.visible,[U]:r.closeOnBackdropClick&&r.visible}),onClick:c,children:m&&u.jsx(m,{id:r.id,type:r.type,alive:r.alive,visible:r.visible,initiator:r.initiator,manualDestroy:r.manualDestroy,closeOnBackdropClick:r.closeOnBackdropClick,background:r.background,onChange:s,onConfirm:a,onClose:i,onDestroy:l,onChangeOrder:n,context:o})}):null};function K(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const Q=f.css("production"===process.env.NODE_ENV?{name:"12g0hx0",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1"}:{name:"1hcczik-foreground",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1;label:foreground;",toString:K}),X=f.css("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:K}),Z=f.css("production"===process.env.NODE_ENV?{name:"1fmljv2",styles:"display:flex!important;justify-content:center;align-items:center"}:{name:"1p4unab-visible",styles:"display:flex!important;justify-content:center;align-items:center;label:visible;",toString:K}),ee=d.memo((({modal:e,handlers:n})=>{const{title:t,subtitle:o,content:r,footer:i}=d.useMemo((()=>e),[e]),{context:s}=$(),{onConfirm:a}=d.useMemo((()=>n),[n]),l=p.useHandle(a),{TitleComponent:c,SubtitleComponent:f,ContentComponent:b,FooterComponent:h}=L();return u.jsxs(d.Fragment,{children:[t&&(m.isString(t)?u.jsx(c,{context:s,children:t}):t),o&&(m.isString(o)?u.jsx(f,{context:s,children:o}):o),r&&(m.isString(r)?u.jsx(b,{context:s,children:r}):p.renderComponent(r,{onConfirm:l})),!1!==i&&("function"==typeof i?i({onConfirm:l,context:s}):u.jsx(h,{onConfirm:l,confirmLabel:i?.confirm,hideConfirm:i?.hideConfirm,context:s}))]})})),ne=d.memo((({modal:e,handlers:n})=>{const{title:t,subtitle:o,content:r,footer:i}=d.useMemo((()=>e),[e]),{context:s}=$(),{onConfirm:a,onClose:l}=d.useMemo((()=>n),[n]),c=p.useHandle(a),f=p.useHandle(l),{TitleComponent:b,SubtitleComponent:h,ContentComponent:C,FooterComponent:g}=L();return u.jsxs(d.Fragment,{children:[t&&(m.isString(t)?u.jsx(b,{context:s,children:t}):t),o&&(m.isString(o)?u.jsx(h,{context:s,children:o}):o),r&&(m.isString(r)?u.jsx(C,{context:s,children:r}):p.renderComponent(r,{onConfirm:c,onCancel:f,context:s})),!1!==i&&("function"==typeof i?i({onConfirm:c,onCancel:f,context:s}):u.jsx(g,{onConfirm:c,onCancel:f,confirmLabel:i?.confirm,cancelLabel:i?.cancel,hideConfirm:i?.hideConfirm,hideCancel:i?.hideCancel,context:s}))]})})),te=d.memo((({modal:e,handlers:n})=>{const{Input:t,defaultValue:o,disabled:r,title:i,subtitle:s,content:a,footer:l}=d.useMemo((()=>({...e,Input:d.memo(p.withErrorBoundary(e.Input))})),[e]),{context:c}=$(),[f,b]=d.useState(o),{onChange:h,onClose:C,onConfirm:g}=d.useMemo((()=>n),[n]),v=p.useHandle(C),y=p.useHandle((e=>{const n=m.isFunction(e)?e(f):e;b(n),h(n)})),k=d.useCallback((()=>{setTimeout((()=>{g()}))}),[g]),x=d.useMemo((()=>!!f&&!!r?.(f)),[r,f]),{TitleComponent:j,SubtitleComponent:w,ContentComponent:O,FooterComponent:D}=L();return u.jsxs(d.Fragment,{children:[i&&(m.isString(i)?u.jsx(j,{context:c,children:i}):i),s&&(m.isString(s)?u.jsx(w,{context:c,children:s}):s),a&&(m.isString(a)?u.jsx(O,{context:c,children:a}):p.renderComponent(a,{onConfirm:k,onCancel:v,context:c})),t&&u.jsx(t,{defaultValue:o,value:f,onChange:y,onConfirm:k,onCancel:v,context:c}),!1!==l&&("function"==typeof l?l({value:f,disabled:x,onChange:y,onConfirm:k,onCancel:v,context:c}):u.jsx(D,{disabled:x,onConfirm:k,onCancel:v,confirmLabel:l?.confirm,cancelLabel:l?.cancel,hideConfirm:l?.hideConfirm,hideCancel:l?.hideCancel,context:c}))]})})),oe=({modalId:e,onChangeOrder:n})=>{const{ForegroundComponent:t}=L(),{context:o}=$(),{modal:r,onChange:i,onConfirm:s,onClose:a,onDestroy:l}=B(e),c=d.useMemo((()=>r?.ForegroundComponent||t),[t,r]);return r?u.jsx("div",{className:f.cx(Q,{[Z]:r.manualDestroy?r.alive:r.visible,[X]:r.visible}),children:u.jsxs(c,{id:r.id,type:r.type,alive:r.alive,visible:r.visible,initiator:r.initiator,manualDestroy:r.manualDestroy,closeOnBackdropClick:r.closeOnBackdropClick,background:r.background,onChange:i,onConfirm:s,onClose:a,onDestroy:l,onChangeOrder:n,context:o,children:["alert"===r.type&&u.jsx(ee,{modal:r,handlers:{onConfirm:s}}),"confirm"===r.type&&u.jsx(ne,{modal:r,handlers:{onConfirm:s,onClose:a}}),"prompt"===r.type&&u.jsx(te,{modal:r,handlers:{onChange:i,onConfirm:s,onClose:a}})]})}):null},re=e=>{const[n,t]=p.useTick();return p.useOnMount((()=>{if(e)return e.subscribe(t)})),n},ie=f.css("production"===process.env.NODE_ENV?{name:"13dmkf4",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden"}:{name:"yjeu12-presenter",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden;label:presenter;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),{increment:se}=m.counterFactory(1),ae=d.memo((({modalId:e})=>{const n=d.useRef(null),{modal:t}=B(e);re(t);const o=p.useHandle((()=>{n.current&&(n.current.style.zIndex=`${se()}`)}));return u.jsxs("div",{ref:n,className:ie,children:[u.jsx(J,{modalId:e,onChangeOrder:o}),u.jsx(oe,{modalId:e,onChangeOrder:o})]})})),le=f.css("production"===process.env.NODE_ENV?{name:"2hpasy",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out"}:{name:"lhj8co-anchor",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out;label:anchor;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),ce=e=>e?.visible&&e.dimmed,ue=d.memo(p.withErrorBoundary((()=>{const[e,n]=p.useTick(),{modalIds:t,setUpdater:o}=D();d.useEffect((()=>{o(n)}),[o,n]);const r=q(),i=V(ce,e);return u.jsx("div",{className:le,style:{transitionDuration:r.duration,backgroundColor:i?r.backdrop:"transparent"},children:t.map((e=>u.jsx(ae,{modalId:e},e)))})}))),de=({ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:r,FooterComponent:i,usePathname:s,options:a,context:l,anchor:c})=>b.createPortal(u.jsx(_,{context:l,children:u.jsx(z,{ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:r,FooterComponent:i,options:a,children:u.jsx(O,{usePathname:s,children:u.jsx(ue,{})})})}),c),me=()=>{const[e,n]=d.useState(window.location.pathname);return d.useLayoutEffect((()=>{let t;const o=()=>{t&&cancelAnimationFrame(t),e!==window.location.pathname?n(window.location.pathname):t=requestAnimationFrame(o)};return t=requestAnimationFrame(o),()=>{t&&cancelAnimationFrame(t)}}),[e]),{pathname:e}},pe=d.forwardRef((({usePathname:e,ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:s,options:a,context:l,children:c},f)=>{const b=d.useMemo((()=>e||me),[e]),h=d.useRef(g.activate()),C=d.useRef(null),[,v]=p.useTick(),y=d.useCallback((e=>{h.current?(C.current=g.anchor({root:e}),v()):m.printError("ModalProvider is already initialized",["ModalProvider can only be initialized once.","Nesting ModalProvider will be ignored..."],{info:"Something is wrong with the ModalProvider initialization..."})}),[v]);return d.useImperativeHandle(f,(()=>({initialize:y})),[y]),p.useOnMount((()=>(null===f&&y(),()=>{C.current&&C.current.remove()}))),u.jsxs(d.Fragment,{children:[c,C.current&&de({ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:s,usePathname:b,options:a,context:l,anchor:C.current})]})}));exports.ModalProvider=pe,exports.alert=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})=>new Promise(((d,m)=>{try{g.open({type:"alert",subtype:e,resolve:()=>d(),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})}catch(e){m(e)}})),exports.bootstrap=de,exports.confirm=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})=>new Promise(((d,m)=>{try{g.open({type:"confirm",subtype:e,resolve:e=>d(e??!1),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})}catch(e){m(e)}})),exports.prompt=({defaultValue:e,title:n,subtitle:t,content:o,Input:r,disabled:i,returnOnCancel:s,background:a,footer:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})=>new Promise(((f,b)=>{try{g.open({type:"prompt",resolve:e=>f(e),title:n,subtitle:t,content:o,Input:r,defaultValue:e,disabled:i,returnOnCancel:s,background:a,footer:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})}catch(e){b(e)}})),exports.useActiveModalCount=V,exports.useDestroyAfter=(e,n)=>{const{modal:t,onDestroy:o}=B(e),r=re(t),i=d.useRef({modal:t,onDestroy:o,milliseconds:m.isString(n)?m.convertMsFromDuration(n):n});d.useEffect((()=>{const{modal:e,onDestroy:n,milliseconds:t}=i.current;if(!e||e.visible||!e.alive)return;const o=setTimeout((()=>{n()}),t);return()=>{o&&clearTimeout(o)}}),[r])},exports.useModalAnimation=(e,n)=>{const t=d.useRef(n);t.current=n,d.useLayoutEffect((()=>{if(!t.current)return;let n;return n=e?requestAnimationFrame((()=>t.current.onVisible?.())):requestAnimationFrame((()=>t.current.onHidden?.())),()=>{n&&cancelAnimationFrame(n)}}),[e])},exports.useModalBackdrop=()=>q().backdrop,exports.useModalDuration=()=>{const e=q();return{duration:e.duration,milliseconds:m.convertMsFromDuration(e.duration)}},exports.useModalOptions=q,exports.useSubscribeModal=re;
17
+ function h(e,n,t,o){if("a"===t&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!o:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?o:"a"===t?o.call(e):o?o.value:n.get(e)}function C(e,n,t,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof n?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,t):r?r.value=t:n.set(e,t),t}"function"==typeof SuppressedError&&SuppressedError;class g{static activate(){return!h(e,e,"f",n)&&C(e,e,!0,"f",n)}static anchor(n){if(h(e,e,"f",t)){const n=document.getElementById(h(e,e,"f",t).id);if(n)return n}const{tag:o="div",prefix:r="promise-modal",root:i=document.body}=n||{},s=document.createElement(o);return s.setAttribute("id",`${r}-${m.getRandomString(36)}`),i.appendChild(s),C(e,e,s,"f",t),s}static get prerender(){return h(e,e,"f",o)}static set openHandler(n){C(e,e,n,"f",r),C(e,e,[],"f",o)}static get unanchored(){return!h(e,e,"f",t)}static reset(){C(e,e,!1,"f",n),C(e,e,null,"f",t),C(e,e,[],"f",o),C(e,e,(n=>h(e,e,"f",o).push(n)),"f",r)}static open(n){h(e,e,"f",r).call(e,n)}}e=g,n={value:!1},t={value:null},o={value:[]},r={value:n=>h(e,e,"f",o).push(n)};class v{get alive(){return h(this,i,"f")}get visible(){return h(this,s,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,background:r,dimmed:c=!0,manualDestroy:u=!1,closeOnBackdropClick:d=!0,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"initiator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"title",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtitle",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"background",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualDestroy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"closeOnBackdropClick",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dimmed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ForegroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BackgroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i.set(this,void 0),s.set(this,void 0),a.set(this,void 0),l.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.dimmed=c,this.manualDestroy=u,this.closeOnBackdropClick=d,this.ForegroundComponent=p,this.BackgroundComponent=f,C(this,i,!0,"f"),C(this,s,!0,"f"),C(this,a,m,"f")}subscribe(e){return h(this,l,"f").push(e),()=>{C(this,l,h(this,l,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of h(this,l,"f"))e()}resolve(e){h(this,a,"f").call(this,e)}onDestroy(){const e=!0===h(this,i,"f");C(this,i,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===h(this,s,"f");C(this,s,!0,"f"),e&&this.publish()}onHide(){const e=!0===h(this,s,"f");C(this,s,!1,"f"),e&&this.publish()}}i=new WeakMap,s=new WeakMap,a=new WeakMap,l=new WeakMap;class y extends v{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:s,footer:a,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=s,this.footer=a}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class k extends v{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:s,footer:a,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=s,this.footer=a}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class x extends v{constructor({id:e,initiator:n,type:t,title:o,subtitle:r,content:i,defaultValue:s,Input:a,disabled:l,returnOnCancel:u,footer:d,background:m,dimmed:p,manualDestroy:f,closeOnBackdropClick:b,resolve:h,ForegroundComponent:g,BackgroundComponent:v}){super({id:e,initiator:n,title:o,subtitle:r,background:m,dimmed:p,manualDestroy:f,closeOnBackdropClick:b,resolve:h,ForegroundComponent:g,BackgroundComponent:v}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"Input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"returnOnCancel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),c.set(this,void 0),this.type=t,this.content=i,this.Input=a,this.defaultValue=s,C(this,c,s,"f"),this.disabled=l,this.returnOnCancel=u,this.footer=d}onChange(e){C(this,c,e,"f")}onConfirm(){this.resolve(h(this,c,"f")??null)}onClose(){this.returnOnCancel?this.resolve(h(this,c,"f")??null):this.resolve(null)}}c=new WeakMap;const j=e=>{switch(e.type){case"alert":return new y(e);case"confirm":return new k(e);case"prompt":return new x(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},w=d.createContext({}),O=d.memo((({usePathname:e,children:n})=>{const t=d.useRef(new Map),[o,r]=d.useState([]),i=p.useReference(o),{pathname:s}=e(),a=d.useRef(s),l=d.useRef(0),c=q(),f=d.useMemo((()=>m.convertMsFromDuration(c.duration)),[c]);p.useOnMountLayout((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=c;for(const o of g.prerender){const i=j({...o,id:l.current++,initiator:a.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});t.current.set(i.id,i),r((e=>[...e,i.id]))}return g.openHandler=o=>{const i=j({...o,id:l.current++,initiator:a.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});t.current.set(i.id,i),r((e=>[...e.filter((e=>{const n=!t.current.get(e)?.alive;return n&&t.current.delete(e),!n})),i.id]))},()=>{g.reset()}})),d.useLayoutEffect((()=>{for(const e of i.current){const n=t.current.get(e);n?.alive&&(n.initiator===s?n.onShow():n.onHide())}a.current=s}),[i,s]);const b=d.useCallback((e=>t.current.get(e)),[]),h=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onDestroy(),C.current?.())}),[]),C=d.useRef(),v=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onHide(),C.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),f))}),[f]),y=d.useCallback(((e,n)=>{const o=t.current.get(e);o&&"prompt"===o.type&&o.onChange(n)}),[]),k=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onConfirm(),v(e))}),[v]),x=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onClose(),v(e))}),[v]),O=d.useCallback((e=>({modal:b(e),onConfirm:()=>k(e),onClose:()=>x(e),onChange:n=>y(e,n),onDestroy:()=>h(e)})),[b,k,x,y,h]),B=d.useMemo((()=>({modalIds:o,getModalNode:b,onChange:y,onConfirm:k,onClose:x,onDestroy:h,getModal:O,setUpdater:e=>{C.current=e}})),[o,O,b,y,k,x,h]);return u.jsx(w.Provider,{value:B,children:n})})),B=()=>d.useContext(w),D=e=>{const{getModal:n}=B();return d.useMemo((()=>n(e)),[e,n])};function F(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const M=f.css("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:F}),P=f.css("production"===process.env.NODE_ENV?{name:"1kuk3a3",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black"}:{name:"16dbbea-frame",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black;label:frame;",toString:F}),S=({children:e})=>u.jsx("h2",{className:M,children:e}),E=({children:e})=>u.jsx("h3",{className:M,children:e}),N=({children:e})=>u.jsx("div",{className:M,children:e}),I=({confirmLabel:e,hideConfirm:n=!1,cancelLabel:t,hideCancel:o=!1,disabled:r,onConfirm:i,onCancel:s})=>u.jsxs("div",{children:[!n&&u.jsx("button",{onClick:i,disabled:r,children:e||"확인"}),!o&&"function"==typeof s&&u.jsx("button",{onClick:s,children:t||"취소"})]}),T=e=>e?.visible,V=(e=T,n=0)=>{const{modalIds:t,getModalNode:o}=B();return d.useMemo((()=>{let n=0;for(const r of t)e(o(r))&&n++;return n}),[o,t,n])},z=d.forwardRef((({id:e,onChangeOrder:n,children:t},o)=>{const r=V(),[i,s]=d.useMemo((()=>{const n=r>1;return[n?Math.floor(e/5)%3*100:0,n?e%5*35:0]}),[r,e]);return u.jsx("div",{ref:o,className:P,onClick:n,style:{marginBottom:`calc(25vh + ${i}px)`,marginLeft:`${i}px`,transform:`translate(${s}px, ${s}px)`},children:t})})),R=d.createContext({}),H=d.memo((({ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:r,FooterComponent:i,options:s,children:a})=>{const l=d.useMemo((()=>({BackgroundComponent:n,ForegroundComponent:e||z,TitleComponent:t||S,SubtitleComponent:o||E,ContentComponent:d.memo(r||N),FooterComponent:d.memo(i||I),options:{duration:"300ms",backdrop:"rgba(0, 0, 0, 0.5)",closeOnBackdropClick:!0,manualDestroy:!1,...s}})),[e,n,r,i,o,t,s]);return u.jsx(R.Provider,{value:l,children:a})})),L=()=>d.useContext(R),q=()=>d.useContext(R).options,A=d.createContext({}),_=({context:e,children:n})=>{const t=d.useMemo((()=>({context:e||{}})),[e]);return u.jsx(A.Provider,{value:t,children:n})},$=()=>d.useContext(A),W=()=>{const[e,n]=d.useState(window.location.pathname);return d.useLayoutEffect((()=>{let t;const o=()=>{t&&cancelAnimationFrame(t),e!==window.location.pathname?n(window.location.pathname):t=requestAnimationFrame(o)};return t=requestAnimationFrame(o),()=>{t&&cancelAnimationFrame(t)}}),[e]),{pathname:e}};function Y(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const U=f.css("production"===process.env.NODE_ENV?{name:"u7uu4v",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;}"}:{name:"coymdj-background",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;};label:background;",toString:Y}),G=f.css("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:Y}),J=f.css("production"===process.env.NODE_ENV?{name:"1wnowod",styles:"display:flex;align-items:center;justify-content:center"}:{name:"xppew7-visible",styles:"display:flex;align-items:center;justify-content:center;label:visible;",toString:Y}),K=({modalId:e,onChangeOrder:n})=>{const{BackgroundComponent:t}=L(),{context:o}=$(),{modal:r,onClose:i,onChange:s,onConfirm:a,onDestroy:l}=D(e),c=d.useCallback((e=>{r&&r.closeOnBackdropClick&&r.visible&&i(),e.stopPropagation()}),[r,i]),m=d.useMemo((()=>r?.BackgroundComponent||t),[t,r]);return r?u.jsx("div",{className:f.cx(U,{[J]:r.manualDestroy?r.alive:r.visible,[G]:r.closeOnBackdropClick&&r.visible}),onClick:c,children:m&&u.jsx(m,{id:r.id,type:r.type,alive:r.alive,visible:r.visible,initiator:r.initiator,manualDestroy:r.manualDestroy,closeOnBackdropClick:r.closeOnBackdropClick,background:r.background,onChange:s,onConfirm:a,onClose:i,onDestroy:l,onChangeOrder:n,context:o})}):null};function Q(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const X=f.css("production"===process.env.NODE_ENV?{name:"12g0hx0",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1"}:{name:"1hcczik-foreground",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1;label:foreground;",toString:Q}),Z=f.css("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:Q}),ee=f.css("production"===process.env.NODE_ENV?{name:"1fmljv2",styles:"display:flex!important;justify-content:center;align-items:center"}:{name:"1p4unab-visible",styles:"display:flex!important;justify-content:center;align-items:center;label:visible;",toString:Q}),ne=d.memo((({modal:e,handlers:n})=>{const{title:t,subtitle:o,content:r,footer:i}=d.useMemo((()=>e),[e]),{context:s}=$(),{onConfirm:a}=d.useMemo((()=>n),[n]),l=p.useHandle(a),{TitleComponent:c,SubtitleComponent:f,ContentComponent:b,FooterComponent:h}=L();return u.jsxs(d.Fragment,{children:[t&&(m.isString(t)?u.jsx(c,{context:s,children:t}):t),o&&(m.isString(o)?u.jsx(f,{context:s,children:o}):o),r&&(m.isString(r)?u.jsx(b,{context:s,children:r}):p.renderComponent(r,{onConfirm:l})),!1!==i&&("function"==typeof i?i({onConfirm:l,context:s}):u.jsx(h,{onConfirm:l,confirmLabel:i?.confirm,hideConfirm:i?.hideConfirm,context:s}))]})})),te=d.memo((({modal:e,handlers:n})=>{const{title:t,subtitle:o,content:r,footer:i}=d.useMemo((()=>e),[e]),{context:s}=$(),{onConfirm:a,onClose:l}=d.useMemo((()=>n),[n]),c=p.useHandle(a),f=p.useHandle(l),{TitleComponent:b,SubtitleComponent:h,ContentComponent:C,FooterComponent:g}=L();return u.jsxs(d.Fragment,{children:[t&&(m.isString(t)?u.jsx(b,{context:s,children:t}):t),o&&(m.isString(o)?u.jsx(h,{context:s,children:o}):o),r&&(m.isString(r)?u.jsx(C,{context:s,children:r}):p.renderComponent(r,{onConfirm:c,onCancel:f,context:s})),!1!==i&&("function"==typeof i?i({onConfirm:c,onCancel:f,context:s}):u.jsx(g,{onConfirm:c,onCancel:f,confirmLabel:i?.confirm,cancelLabel:i?.cancel,hideConfirm:i?.hideConfirm,hideCancel:i?.hideCancel,context:s}))]})})),oe=d.memo((({modal:e,handlers:n})=>{const{Input:t,defaultValue:o,disabled:r,title:i,subtitle:s,content:a,footer:l}=d.useMemo((()=>({...e,Input:d.memo(p.withErrorBoundary(e.Input))})),[e]),{context:c}=$(),[f,b]=d.useState(o),{onChange:h,onClose:C,onConfirm:g}=d.useMemo((()=>n),[n]),v=p.useHandle(C),y=p.useHandle((e=>{const n=m.isFunction(e)?e(f):e;b(n),h(n)})),k=d.useCallback((()=>{setTimeout((()=>{g()}))}),[g]),x=d.useMemo((()=>!!f&&!!r?.(f)),[r,f]),{TitleComponent:j,SubtitleComponent:w,ContentComponent:O,FooterComponent:B}=L();return u.jsxs(d.Fragment,{children:[i&&(m.isString(i)?u.jsx(j,{context:c,children:i}):i),s&&(m.isString(s)?u.jsx(w,{context:c,children:s}):s),a&&(m.isString(a)?u.jsx(O,{context:c,children:a}):p.renderComponent(a,{onConfirm:k,onCancel:v,context:c})),t&&u.jsx(t,{defaultValue:o,value:f,onChange:y,onConfirm:k,onCancel:v,context:c}),!1!==l&&("function"==typeof l?l({value:f,disabled:x,onChange:y,onConfirm:k,onCancel:v,context:c}):u.jsx(B,{disabled:x,onConfirm:k,onCancel:v,confirmLabel:l?.confirm,cancelLabel:l?.cancel,hideConfirm:l?.hideConfirm,hideCancel:l?.hideCancel,context:c}))]})})),re=({modalId:e,onChangeOrder:n})=>{const{ForegroundComponent:t}=L(),{context:o}=$(),{modal:r,onChange:i,onConfirm:s,onClose:a,onDestroy:l}=D(e),c=d.useMemo((()=>r?.ForegroundComponent||t),[t,r]);return r?u.jsx("div",{className:f.cx(X,{[ee]:r.manualDestroy?r.alive:r.visible,[Z]:r.visible}),children:u.jsxs(c,{id:r.id,type:r.type,alive:r.alive,visible:r.visible,initiator:r.initiator,manualDestroy:r.manualDestroy,closeOnBackdropClick:r.closeOnBackdropClick,background:r.background,onChange:i,onConfirm:s,onClose:a,onDestroy:l,onChangeOrder:n,context:o,children:["alert"===r.type&&u.jsx(ne,{modal:r,handlers:{onConfirm:s}}),"confirm"===r.type&&u.jsx(te,{modal:r,handlers:{onConfirm:s,onClose:a}}),"prompt"===r.type&&u.jsx(oe,{modal:r,handlers:{onChange:i,onConfirm:s,onClose:a}})]})}):null},ie=e=>{const[n,t]=p.useTick();return p.useOnMount((()=>{if(e)return e.subscribe(t)})),n},se=f.css("production"===process.env.NODE_ENV?{name:"13dmkf4",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden"}:{name:"yjeu12-presenter",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden;label:presenter;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),{increment:ae}=m.counterFactory(1),le=d.memo((({modalId:e})=>{const n=d.useRef(null),{modal:t}=D(e);ie(t);const o=p.useHandle((()=>{n.current&&(n.current.style.zIndex=`${ae()}`)}));return u.jsxs("div",{ref:n,className:se,children:[u.jsx(K,{modalId:e,onChangeOrder:o}),u.jsx(re,{modalId:e,onChangeOrder:o})]})})),ce=f.css("production"===process.env.NODE_ENV?{name:"2hpasy",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out"}:{name:"lhj8co-anchor",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out;label:anchor;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),ue=e=>e?.visible&&e.dimmed,de=d.memo(p.withErrorBoundary((()=>{const[e,n]=p.useTick(),{modalIds:t,setUpdater:o}=B();d.useEffect((()=>{o(n)}),[o,n]);const r=q(),i=V(ue,e);return u.jsx("div",{className:ce,style:{transitionDuration:r.duration,backgroundColor:i?r.backdrop:"transparent"},children:t.map((e=>u.jsx(le,{modalId:e},e)))})}))),me=({ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:r,FooterComponent:i,usePathname:s,options:a,context:l,anchor:c})=>b.createPortal(u.jsx(_,{context:l,children:u.jsx(H,{ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:r,FooterComponent:i,options:a,children:u.jsx(O,{usePathname:s,children:u.jsx(de,{})})})}),c),pe=()=>{const e=d.useRef(g.activate()),n=d.useRef(null),[,t]=p.useTick(),o=d.useCallback((o=>{e.current?(n.current=g.anchor({root:o}),t()):m.printError("ModalProvider is already initialized",["ModalProvider can only be initialized once.","Nesting ModalProvider will be ignored..."],{info:"Something is wrong with the ModalProvider initialization..."})}),[t]);return{anchorRef:n,handleInitialize:o}},fe=d.forwardRef((({usePathname:e,ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:s,options:a,context:l,children:c},m)=>{const f=d.useMemo((()=>e||W),[e]),{anchorRef:b,handleInitialize:h}=pe();return d.useImperativeHandle(m,(()=>({initialize:h})),[h]),p.useOnMount((()=>(null===m&&h(),()=>{b.current&&b.current.remove()}))),u.jsxs(d.Fragment,{children:[c,b.current&&me({ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:s,usePathname:f,options:a,context:l,anchor:b.current})]})}));exports.ModalProvider=fe,exports.alert=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})=>new Promise(((d,m)=>{try{g.open({type:"alert",subtype:e,resolve:()=>d(),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})}catch(e){m(e)}})),exports.confirm=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})=>new Promise(((d,m)=>{try{g.open({type:"confirm",subtype:e,resolve:e=>d(e??!1),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})}catch(e){m(e)}})),exports.prompt=({defaultValue:e,title:n,subtitle:t,content:o,Input:r,disabled:i,returnOnCancel:s,background:a,footer:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})=>new Promise(((f,b)=>{try{g.open({type:"prompt",resolve:e=>f(e),title:n,subtitle:t,content:o,Input:r,defaultValue:e,disabled:i,returnOnCancel:s,background:a,footer:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})}catch(e){b(e)}})),exports.useActiveModalCount=V,exports.useDestroyAfter=(e,n)=>{const{modal:t,onDestroy:o}=D(e),r=ie(t),i=d.useRef({modal:t,onDestroy:o,milliseconds:m.isString(n)?m.convertMsFromDuration(n):n});d.useEffect((()=>{const{modal:e,onDestroy:n,milliseconds:t}=i.current;if(!e||e.visible||!e.alive)return;const o=setTimeout((()=>{n()}),t);return()=>{o&&clearTimeout(o)}}),[r])},exports.useInitializeModal=({usePathname:e,ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:s,options:a,context:l,mode:c="auto"}={})=>{const u=d.useMemo((()=>e||W),[e]),{anchorRef:m,handleInitialize:f}=pe();p.useOnMount((()=>("auto"===c&&f(),()=>{m.current&&m.current.remove()})));const b=d.useCallback((e=>{"manual"===c&&f(e)}),[c,f]);return{portal:m.current&&me({usePathname:u,ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:s,options:a,context:l,anchor:m.current}),initialize:b}},exports.useModalAnimation=(e,n)=>{const t=d.useRef(n);t.current=n,d.useLayoutEffect((()=>{if(!t.current)return;let n;return n=e?requestAnimationFrame((()=>t.current.onVisible?.())):requestAnimationFrame((()=>t.current.onHidden?.())),()=>{n&&cancelAnimationFrame(n)}}),[e])},exports.useModalBackdrop=()=>q().backdrop,exports.useModalDuration=()=>{const e=q();return{duration:e.duration,milliseconds:m.convertMsFromDuration(e.duration)}},exports.useModalOptions=q,exports.useSubscribeModal=ie;
18
18
  //# sourceMappingURL=index.cjs.js.map