@lerx/promise-modal 0.0.16 → 0.0.17
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/dist/components/Foreground/components/PromptInner.d.ts.map +1 -1
- package/dist/core/handle/prompt.d.ts.map +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/types/prompt.d.ts +1 -0
- package/dist/types/prompt.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/PromptInner.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,UAAU,gBAAgB,CAAC,CAAC,EAAE,CAAC;IAC7B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC,CAAC;CACpE;AAED,eAAO,MAAM,WAAW,wCACrB,CAAC,EAAE,CAAC,uBAAuB,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"PromptInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/PromptInner.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,UAAU,gBAAgB,CAAC,CAAC,EAAE,CAAC;IAC7B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAA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-
"use strict";var e=require("react/jsx-runtime"),n=require("react"),o=require("react-dom"),t=require("@winglet/react-utils"),r=require("@winglet/common-utils"),i=require("@emotion/css");const s={current:[]},a={current:e=>{s.current.push(e)}},l={current:null},c={get prerender(){return s.current},clearPrerender(){s.current=[]},open(e){a.current(e)},setupOpen(e){a.current=e},anchor(e,n="promise-modal"){if(l.current){const e=document.getElementById(l.current.id);if(e)return e}const o=document.createElement(e);return o.setAttribute("id",`${n}-${r.getRandomString(36)}`),document.body.appendChild(o),l.current=o,o}},u="300ms",d="rgba(0, 0, 0, 0.5)";function m(){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=i.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:m}),f=i.css("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:m}),b=i.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:m}),h=({modalId:o,onChangeOrder:t})=>{const{BackgroundComponent:r}=ae(),{modal:s,onClose:a,onChange:l,onConfirm:c,onDestroy:u}=U(o),d=n.useCallback((e=>{s&&s.closeOnBackdropClick&&s.visible&&a(),e.stopPropagation()}),[s,a]),m=n.useMemo((()=>s?.BackgroundComponent||r),[r,s]);return s?e.jsx("div",{className:i.cx(p,{[b]:s.manualDestroy?s.alive:s.visible,[f]:s.closeOnBackdropClick&&s.visible}),onClick:d,children:m&&e.jsx(m,{id:s.id,type:s.type,alive:s.alive,visible:s.visible,initiator:s.initiator,manualDestroy:s.manualDestroy,closeOnBackdropClick:s.closeOnBackdropClick,background:s.background,onChange:l,onConfirm:c,onClose:a,onDestroy:u,onChangeOrder:t})}):null};function C(){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 g=i.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:C}),y=i.css("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:C}),v=i.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:C}),k=n.memo((({modal:o,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>o),[o]),{onConfirm:u}=n.useMemo((()=>i),[i]),d=t.useHandle(u),{TitleComponent:m,SubtitleComponent:p,ContentComponent:f,FooterComponent:b}=ae();return e.jsxs(n.Fragment,{children:[s&&(r.isString(s)?e.jsx(m,{children:s}):s),a&&(r.isString(a)?e.jsx(p,{children:a}):a),l&&(r.isString(l)?e.jsx(f,{children:l}):t.renderComponent(l,{onConfirm:d})),!1!==c&&("function"==typeof c?c({onConfirm:d}):e.jsx(b,{onConfirm:d,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm}))]})})),x=n.memo((({modal:o,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>o),[o]),{onConfirm:u,onClose:d}=n.useMemo((()=>i),[i]),m=t.useHandle(u),p=t.useHandle(d),{TitleComponent:f,SubtitleComponent:b,ContentComponent:h,FooterComponent:C}=ae();return e.jsxs(n.Fragment,{children:[s&&(r.isString(s)?e.jsx(f,{children:s}):s),a&&(r.isString(a)?e.jsx(b,{children:a}):a),l&&(r.isString(l)?e.jsx(h,{children:l}):t.renderComponent(l,{onConfirm:m,onCancel:p})),!1!==c&&("function"==typeof c?c({onConfirm:m,onCancel:p}):e.jsx(C,{onConfirm:m,onCancel:p,confirmLabel:c?.confirm,cancelLabel:c?.cancel,hideConfirm:c?.hideConfirm,hideCancel:c?.hideCancel}))]})})),j=n.memo((({modal:o,handlers:i})=>{const{Input:s,defaultValue:a,disabled:l,title:c,subtitle:u,content:d,footer:m}=n.useMemo((()=>({...o,Input:n.memo(t.withErrorBoundary(o.Input))})),[o]),[p,f]=n.useState(a),{onChange:b,onClose:h,onConfirm:C}=n.useMemo((()=>i),[i]),g=t.useHandle(h),y=t.useHandle((e=>{const n=r.isFunction(e)?e(p):e;f(n),b(n)})),v=n.useCallback((()=>{setTimeout((()=>{C()}))}),[C]),k=n.useMemo((()=>!!p&&!!l?.(p)),[l,p]),{TitleComponent:x,SubtitleComponent:j,ContentComponent:O,FooterComponent:w}=ae();return e.jsxs(n.Fragment,{children:[c&&(r.isString(c)?e.jsx(x,{children:c}):c),u&&(r.isString(u)?e.jsx(j,{children:u}):u),d&&(r.isString(d)?e.jsx(O,{children:d}):t.renderComponent(d,{onConfirm:v,onCancel:g})),s&&e.jsx(s,{defaultValue:a,value:p,onChange:y,onConfirm:v}),!1!==m&&("function"==typeof m?m({onConfirm:v,onCancel:g,
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),n=require("react"),o=require("react-dom"),t=require("@winglet/react-utils"),r=require("@winglet/common-utils"),i=require("@emotion/css");const s={current:[]},a={current:e=>{s.current.push(e)}},l={current:null},c={get prerender(){return s.current},clearPrerender(){s.current=[]},open(e){a.current(e)},setupOpen(e){a.current=e},anchor(e,n="promise-modal"){if(l.current){const e=document.getElementById(l.current.id);if(e)return e}const o=document.createElement(e);return o.setAttribute("id",`${n}-${r.getRandomString(36)}`),document.body.appendChild(o),l.current=o,o}},u="300ms",d="rgba(0, 0, 0, 0.5)";function m(){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=i.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:m}),f=i.css("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:m}),b=i.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:m}),h=({modalId:o,onChangeOrder:t})=>{const{BackgroundComponent:r}=ae(),{modal:s,onClose:a,onChange:l,onConfirm:c,onDestroy:u}=U(o),d=n.useCallback((e=>{s&&s.closeOnBackdropClick&&s.visible&&a(),e.stopPropagation()}),[s,a]),m=n.useMemo((()=>s?.BackgroundComponent||r),[r,s]);return s?e.jsx("div",{className:i.cx(p,{[b]:s.manualDestroy?s.alive:s.visible,[f]:s.closeOnBackdropClick&&s.visible}),onClick:d,children:m&&e.jsx(m,{id:s.id,type:s.type,alive:s.alive,visible:s.visible,initiator:s.initiator,manualDestroy:s.manualDestroy,closeOnBackdropClick:s.closeOnBackdropClick,background:s.background,onChange:l,onConfirm:c,onClose:a,onDestroy:u,onChangeOrder:t})}):null};function C(){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 g=i.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:C}),y=i.css("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:C}),v=i.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:C}),k=n.memo((({modal:o,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>o),[o]),{onConfirm:u}=n.useMemo((()=>i),[i]),d=t.useHandle(u),{TitleComponent:m,SubtitleComponent:p,ContentComponent:f,FooterComponent:b}=ae();return e.jsxs(n.Fragment,{children:[s&&(r.isString(s)?e.jsx(m,{children:s}):s),a&&(r.isString(a)?e.jsx(p,{children:a}):a),l&&(r.isString(l)?e.jsx(f,{children:l}):t.renderComponent(l,{onConfirm:d})),!1!==c&&("function"==typeof c?c({onConfirm:d}):e.jsx(b,{onConfirm:d,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm}))]})})),x=n.memo((({modal:o,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>o),[o]),{onConfirm:u,onClose:d}=n.useMemo((()=>i),[i]),m=t.useHandle(u),p=t.useHandle(d),{TitleComponent:f,SubtitleComponent:b,ContentComponent:h,FooterComponent:C}=ae();return e.jsxs(n.Fragment,{children:[s&&(r.isString(s)?e.jsx(f,{children:s}):s),a&&(r.isString(a)?e.jsx(b,{children:a}):a),l&&(r.isString(l)?e.jsx(h,{children:l}):t.renderComponent(l,{onConfirm:m,onCancel:p})),!1!==c&&("function"==typeof c?c({onConfirm:m,onCancel:p}):e.jsx(C,{onConfirm:m,onCancel:p,confirmLabel:c?.confirm,cancelLabel:c?.cancel,hideConfirm:c?.hideConfirm,hideCancel:c?.hideCancel}))]})})),j=n.memo((({modal:o,handlers:i})=>{const{Input:s,defaultValue:a,disabled:l,title:c,subtitle:u,content:d,footer:m}=n.useMemo((()=>({...o,Input:n.memo(t.withErrorBoundary(o.Input))})),[o]),[p,f]=n.useState(a),{onChange:b,onClose:h,onConfirm:C}=n.useMemo((()=>i),[i]),g=t.useHandle(h),y=t.useHandle((e=>{const n=r.isFunction(e)?e(p):e;f(n),b(n)})),v=n.useCallback((()=>{setTimeout((()=>{C()}))}),[C]),k=n.useMemo((()=>!!p&&!!l?.(p)),[l,p]),{TitleComponent:x,SubtitleComponent:j,ContentComponent:O,FooterComponent:w}=ae();return e.jsxs(n.Fragment,{children:[c&&(r.isString(c)?e.jsx(x,{children:c}):c),u&&(r.isString(u)?e.jsx(j,{children:u}):u),d&&(r.isString(d)?e.jsx(O,{children:d}):t.renderComponent(d,{onConfirm:v,onCancel:g})),s&&e.jsx(s,{defaultValue:a,value:p,onChange:y,onConfirm:v,onCancel:g}),!1!==m&&("function"==typeof m?m({onChange:y,onConfirm:v,onCancel:g,value:p,disabled:k}):e.jsx(w,{onConfirm:v,onCancel:g,disabled:k,confirmLabel:m?.confirm,cancelLabel:m?.cancel,hideConfirm:m?.hideConfirm,hideCancel:m?.hideCancel}))]})})),O=({modalId:o,onChangeOrder:t})=>{const{ForegroundComponent:r}=ae(),{modal:s,onChange:a,onConfirm:l,onClose:c,onDestroy:u}=U(o),d=n.useMemo((()=>s?.ForegroundComponent||r),[r,s]);return s?e.jsx("div",{className:i.cx(g,{[v]:s.manualDestroy?s.alive:s.visible,[y]:s.visible}),children:e.jsxs(d,{id:s.id,type:s.type,alive:s.alive,visible:s.visible,initiator:s.initiator,manualDestroy:s.manualDestroy,closeOnBackdropClick:s.closeOnBackdropClick,background:s.background,onChange:a,onConfirm:l,onClose:c,onDestroy:u,onChangeOrder:t,children:["alert"===s.type&&e.jsx(k,{modal:s,handlers:{onConfirm:l}}),"confirm"===s.type&&e.jsx(x,{modal:s,handlers:{onConfirm:l,onClose:c}}),"prompt"===s.type&&e.jsx(j,{modal:s,handlers:{onChange:a,onConfirm:l,onClose:c}})]})}):null},w=e=>{const[n,o]=t.useTick();return t.useOnMount((()=>{if(e)return e.subscribe(o)})),n},D=i.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)."}});let B=1;const F=n.memo((({modalId:o})=>{const r=n.useRef(null),{modal:i}=U(o);w(i);const s=t.useHandle((()=>{r.current&&(r.current.style.zIndex=""+B++)}));return e.jsxs("div",{ref:r,className:D,children:[e.jsx(h,{modalId:o,onChangeOrder:s}),e.jsx(O,{modalId:o,onChangeOrder:s})]})})),P=(e=0)=>{const{modalIds:o,getModalNode:t}=Y();return n.useMemo((()=>{let e=0;for(const n of o)t(n)?.visible&&e++;return e}),[t,o,e])};
|
|
2
2
|
/******************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -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 E(e,n,o,t){if("a"===o&&!t)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!t:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?t:"a"===o?t.call(e):t?t.value:n.get(e)}function M(e,n,o,t,r){if("m"===t)throw new TypeError("Private method is not writable");if("a"===t&&!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"===t?r.call(e,o):r?r.value=o:n.set(e,o),o}var N,S,I,V,T;"function"==typeof SuppressedError&&SuppressedError;class L{get alive(){return E(this,N,"f")}get visible(){return E(this,S,"f")}constructor({id:e,initiator:n,title:o,subtitle:t,background:r,manualDestroy:i=!1,closeOnBackdropClick:s=!0,resolve:a,ForegroundComponent:l,BackgroundComponent:c}){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,"ForegroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BackgroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),N.set(this,void 0),S.set(this,void 0),I.set(this,void 0),V.set(this,[]),this.id=e,this.initiator=n,this.title=o,this.subtitle=t,this.background=r,this.manualDestroy=i,this.closeOnBackdropClick=s,this.ForegroundComponent=l,this.BackgroundComponent=c,M(this,N,!0,"f"),M(this,S,!0,"f"),M(this,I,a,"f")}subscribe(e){return E(this,V,"f").push(e),()=>{M(this,V,E(this,V,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of E(this,V,"f"))e()}resolve(e){E(this,I,"f").call(this,e)}onDestroy(){const e=!0===E(this,N,"f");M(this,N,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===E(this,S,"f");M(this,S,!0,"f"),e&&this.publish()}onHide(){const e=!0===E(this,S,"f");M(this,S,!1,"f"),e&&this.publish()}}N=new WeakMap,S=new WeakMap,I=new WeakMap,V=new WeakMap;class R extends L{constructor({id:e,initiator:n,type:o,subtype:t,title:r,subtitle:i,content:s,footer:a,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}){super({id:e,initiator:n,title:r,subtitle:i,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}),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=o,this.subtype=t,this.content=s,this.footer=a}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class _ extends L{constructor({id:e,initiator:n,type:o,subtype:t,title:r,subtitle:i,content:s,footer:a,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}){super({id:e,initiator:n,title:r,subtitle:i,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}),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=o,this.subtype=t,this.content=s,this.footer=a}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class q extends L{constructor({id:e,initiator:n,type:o,title:t,subtitle:r,content:i,defaultValue:s,Input:a,disabled:l,returnOnCancel:c,footer:u,background:d,manualDestroy:m,closeOnBackdropClick:p,resolve:f,ForegroundComponent:b,BackgroundComponent:h}){super({id:e,initiator:n,title:t,subtitle:r,background:d,manualDestroy:m,closeOnBackdropClick:p,resolve:f,ForegroundComponent:b,BackgroundComponent:h}),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}),T.set(this,void 0),this.type=o,this.content=i,this.Input=a,this.defaultValue=s,M(this,T,s,"f"),this.disabled=l,this.returnOnCancel=c,this.footer=u}onChange(e){M(this,T,e,"f")}onConfirm(){this.resolve(E(this,T,"f")??null)}onClose(){this.returnOnCancel?this.resolve(E(this,T,"f")??null):this.resolve(null)}}T=new WeakMap;const H=e=>{switch(e.type){case"alert":return new R(e);case"confirm":return new _(e);case"prompt":return new q(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},z=/^\s*(\d+)\s*(ms|s|m|h)\s*$/,$=e=>{const[,n,o]=e.match(z)||[];if(!n||!o)return 0;const t=parseInt(n);return"ms"===o?t:"s"===o?1e3*t:"m"===o?60*t*1e3:"h"===o?60*t*60*1e3:0},A=n.createContext({modalIds:[],getModalNode:r.undefinedFunction,onChange:r.undefinedFunction,onConfirm:r.undefinedFunction,onClose:r.undefinedFunction,onDestroy:r.undefinedFunction,setUpdater:r.undefinedFunction,getModal:()=>({modal:void 0,onConfirm:r.undefinedFunction,onClose:r.undefinedFunction,onChange:r.undefinedFunction,onDestroy:r.undefinedFunction})}),W=n.memo((({pathname:o,children:r})=>{const i=n.useRef(new Map),[s,a]=n.useState([]),l=t.useReference(s),u=n.useRef(o),d=n.useRef(0),m=le(),p=n.useMemo((()=>$(m.duration)),[m]);t.useOnMountLayout((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=m;for(const o of c.prerender){const t=H({...o,id:d.current++,initiator:u.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});i.current.set(t.id,t),a((e=>[...e,t.id]))}c.setupOpen((o=>{const t=H({...o,id:d.current++,initiator:u.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});i.current.set(t.id,t),a((e=>[...e.filter((e=>{const n=!i.current.get(e)?.alive;return n&&i.current.delete(e),!n})),t.id]))})),c.clearPrerender()})),n.useLayoutEffect((()=>{for(const e of l.current){const n=i.current.get(e);n?.alive&&(n.initiator===o?n.onShow():n.onHide())}u.current=o}),[l,o]);const f=n.useCallback((e=>i.current.get(e)),[]),b=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onDestroy(),h.current?.())}),[]),h=n.useRef(),C=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onHide(),h.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),p))}),[p]),g=n.useCallback(((e,n)=>{const o=i.current.get(e);o&&"prompt"===o.type&&o.onChange(n)}),[]),y=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onConfirm(),C(e))}),[C]),v=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onClose(),C(e))}),[C]),k=n.useCallback((e=>({modal:f(e),onConfirm:()=>y(e),onClose:()=>v(e),onChange:n=>g(e,n),onDestroy:()=>b(e)})),[f,y,v,g,b]),x=n.useMemo((()=>({modalIds:s,getModalNode:f,onChange:g,onConfirm:y,onClose:v,onDestroy:b,getModal:k,setUpdater:e=>{h.current=e}})),[s,k,f,g,y,v,b]);return e.jsx(A.Provider,{value:x,children:r})})),Y=()=>n.useContext(A),U=e=>{const{getModal:o}=Y();return n.useMemo((()=>o(e)),[e,o])},G=i.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)."}}),J=n.memo(t.withErrorBoundary((()=>{const[o,r]=t.useTick(),{modalIds:i,setUpdater:s}=Y();n.useEffect((()=>{s(r)}),[s,r]);const{options:a}=ae(),l=P(o);return e.jsx("div",{className:G,style:{transitionDuration:a.duration,backgroundColor:l?a.backdrop:"transparent"},children:i.map((n=>e.jsx(F,{modalId:n},n)))})})));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=i.css("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:K}),X=i.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:K}),Z=({children:n})=>e.jsx("h2",{className:Q,children:n}),ee=({children:n})=>e.jsx("h3",{className:Q,children:n}),ne=({children:n})=>e.jsx("div",{className:Q,children:n}),oe=({confirmLabel:n,hideConfirm:o=!1,cancelLabel:t,hideCancel:r=!1,disabled:i,onConfirm:s,onCancel:a})=>e.jsxs("div",{children:[!o&&e.jsx("button",{onClick:s,disabled:i,children:n||"확인"}),!r&&"function"==typeof a&&e.jsx("button",{onClick:a,children:t||"취소"})]}),te=n.forwardRef((({id:o,onChangeOrder:t,children:r},i)=>{const s=P(),[a,l]=n.useMemo((()=>{const e=s>1;return[e?Math.floor(o/5)%3*100:0,e?o%5*35:0]}),[s,o]);return e.jsx("div",{ref:i,className:X,onClick:t,style:{marginBottom:`calc(25vh + ${a}px)`,marginLeft:`${a}px`,transform:`translate(${l}px, ${l}px)`},children:r})})),re=()=>{const[e,o]=n.useState(window.location.pathname);return n.useLayoutEffect((()=>{let n;const t=()=>{n&&cancelAnimationFrame(n),e!==window.location.pathname?o(window.location.pathname):n=requestAnimationFrame(t)};return n=requestAnimationFrame(t),()=>{n&&cancelAnimationFrame(n)}}),[e]),{pathname:e}},ie=n.createContext({ForegroundComponent:te,TitleComponent:Z,SubtitleComponent:ee,ContentComponent:ne,FooterComponent:oe,options:{duration:u,backdrop:d,manualDestroy:!1,closeOnBackdropClick:!0}}),se=n.memo((({ForegroundComponent:r,BackgroundComponent:i,TitleComponent:s,SubtitleComponent:a,ContentComponent:l,FooterComponent:m,options:p,usePathname:f,children:b})=>{const{pathname:h}=(f||re)(),[,C]=t.useTick(),g=n.useRef(null);t.useOnMount((()=>(g.current=c.anchor("div"),C(),()=>{g.current&&g.current.remove()})));const y=n.useMemo((()=>({BackgroundComponent:i,ForegroundComponent:r||te,TitleComponent:s||Z,SubtitleComponent:a||ee,ContentComponent:n.memo(l||ne),FooterComponent:n.memo(m||oe),options:{duration:u,backdrop:d,closeOnBackdropClick:!0,manualDestroy:!1,...p}})),[r,i,l,m,a,s,p]);return e.jsxs(ie.Provider,{value:y,children:[b,g.current&&o.createPortal(e.jsx(W,{pathname:h,children:e.jsx(J,{})}),g.current)]})})),ae=()=>n.useContext(ie),le=()=>{const{options:e}=n.useContext(ie);return e};exports.ModalProvider=se,exports.alert=({subtype:e,title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})=>new Promise(((d,m)=>{try{c.open({type:"alert",subtype:e,resolve:()=>d(),title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})}catch(e){m(e)}})),exports.confirm=({subtype:e,title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})=>new Promise(((d,m)=>{try{c.open({type:"confirm",subtype:e,resolve:e=>d(e??!1),title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})}catch(e){m(e)}})),exports.prompt=({defaultValue:e,title:n,subtitle:o,content:t,Input:r,disabled:i,returnOnCancel:s,background:a,footer:l,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})=>new Promise(((f,b)=>{try{c.open({type:"prompt",resolve:e=>f(e),title:n,subtitle:o,content:t,Input:({defaultValue:e,onChange:n,onConfirm:o})=>r({defaultValue:e,onChange:n,onConfirm:o}),defaultValue:e,disabled:i,returnOnCancel:s,background:a,footer:l,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})}catch(e){b(e)}})),exports.useDestroyAfter=(e,o)=>{const{modal:t,onDestroy:i}=U(e),s=w(t),a=n.useRef({modal:t,onDestroy:i,milliseconds:r.isString(o)?$(o):o});n.useEffect((()=>{const{modal:e,onDestroy:n,milliseconds:o}=a.current;if(!e||e.visible||!e.alive)return;const t=setTimeout((()=>{n()}),o);return()=>{t&&clearTimeout(t)}}),[s])},exports.useModalBackdrop=()=>{const{backdrop:e}=le();return e},exports.useModalDuration=()=>{const{duration:e}=le();return{duration:e,milliseconds:$(e)}},exports.useModalOptions=le,exports.useSubscribeModal=w;
|
|
17
|
+
function E(e,n,o,t){if("a"===o&&!t)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!t:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?t:"a"===o?t.call(e):t?t.value:n.get(e)}function M(e,n,o,t,r){if("m"===t)throw new TypeError("Private method is not writable");if("a"===t&&!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"===t?r.call(e,o):r?r.value=o:n.set(e,o),o}var N,S,I,V,T;"function"==typeof SuppressedError&&SuppressedError;class L{get alive(){return E(this,N,"f")}get visible(){return E(this,S,"f")}constructor({id:e,initiator:n,title:o,subtitle:t,background:r,manualDestroy:i=!1,closeOnBackdropClick:s=!0,resolve:a,ForegroundComponent:l,BackgroundComponent:c}){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,"ForegroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BackgroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),N.set(this,void 0),S.set(this,void 0),I.set(this,void 0),V.set(this,[]),this.id=e,this.initiator=n,this.title=o,this.subtitle=t,this.background=r,this.manualDestroy=i,this.closeOnBackdropClick=s,this.ForegroundComponent=l,this.BackgroundComponent=c,M(this,N,!0,"f"),M(this,S,!0,"f"),M(this,I,a,"f")}subscribe(e){return E(this,V,"f").push(e),()=>{M(this,V,E(this,V,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of E(this,V,"f"))e()}resolve(e){E(this,I,"f").call(this,e)}onDestroy(){const e=!0===E(this,N,"f");M(this,N,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===E(this,S,"f");M(this,S,!0,"f"),e&&this.publish()}onHide(){const e=!0===E(this,S,"f");M(this,S,!1,"f"),e&&this.publish()}}N=new WeakMap,S=new WeakMap,I=new WeakMap,V=new WeakMap;class R extends L{constructor({id:e,initiator:n,type:o,subtype:t,title:r,subtitle:i,content:s,footer:a,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}){super({id:e,initiator:n,title:r,subtitle:i,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}),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=o,this.subtype=t,this.content=s,this.footer=a}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class _ extends L{constructor({id:e,initiator:n,type:o,subtype:t,title:r,subtitle:i,content:s,footer:a,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}){super({id:e,initiator:n,title:r,subtitle:i,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}),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=o,this.subtype=t,this.content=s,this.footer=a}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class q extends L{constructor({id:e,initiator:n,type:o,title:t,subtitle:r,content:i,defaultValue:s,Input:a,disabled:l,returnOnCancel:c,footer:u,background:d,manualDestroy:m,closeOnBackdropClick:p,resolve:f,ForegroundComponent:b,BackgroundComponent:h}){super({id:e,initiator:n,title:t,subtitle:r,background:d,manualDestroy:m,closeOnBackdropClick:p,resolve:f,ForegroundComponent:b,BackgroundComponent:h}),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}),T.set(this,void 0),this.type=o,this.content=i,this.Input=a,this.defaultValue=s,M(this,T,s,"f"),this.disabled=l,this.returnOnCancel=c,this.footer=u}onChange(e){M(this,T,e,"f")}onConfirm(){this.resolve(E(this,T,"f")??null)}onClose(){this.returnOnCancel?this.resolve(E(this,T,"f")??null):this.resolve(null)}}T=new WeakMap;const H=e=>{switch(e.type){case"alert":return new R(e);case"confirm":return new _(e);case"prompt":return new q(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},z=/^\s*(\d+)\s*(ms|s|m|h)\s*$/,$=e=>{const[,n,o]=e.match(z)||[];if(!n||!o)return 0;const t=parseInt(n);return"ms"===o?t:"s"===o?1e3*t:"m"===o?60*t*1e3:"h"===o?60*t*60*1e3:0},A=n.createContext({modalIds:[],getModalNode:r.undefinedFunction,onChange:r.undefinedFunction,onConfirm:r.undefinedFunction,onClose:r.undefinedFunction,onDestroy:r.undefinedFunction,setUpdater:r.undefinedFunction,getModal:()=>({modal:void 0,onConfirm:r.undefinedFunction,onClose:r.undefinedFunction,onChange:r.undefinedFunction,onDestroy:r.undefinedFunction})}),W=n.memo((({pathname:o,children:r})=>{const i=n.useRef(new Map),[s,a]=n.useState([]),l=t.useReference(s),u=n.useRef(o),d=n.useRef(0),m=le(),p=n.useMemo((()=>$(m.duration)),[m]);t.useOnMountLayout((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=m;for(const o of c.prerender){const t=H({...o,id:d.current++,initiator:u.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});i.current.set(t.id,t),a((e=>[...e,t.id]))}c.setupOpen((o=>{const t=H({...o,id:d.current++,initiator:u.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});i.current.set(t.id,t),a((e=>[...e.filter((e=>{const n=!i.current.get(e)?.alive;return n&&i.current.delete(e),!n})),t.id]))})),c.clearPrerender()})),n.useLayoutEffect((()=>{for(const e of l.current){const n=i.current.get(e);n?.alive&&(n.initiator===o?n.onShow():n.onHide())}u.current=o}),[l,o]);const f=n.useCallback((e=>i.current.get(e)),[]),b=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onDestroy(),h.current?.())}),[]),h=n.useRef(),C=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onHide(),h.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),p))}),[p]),g=n.useCallback(((e,n)=>{const o=i.current.get(e);o&&"prompt"===o.type&&o.onChange(n)}),[]),y=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onConfirm(),C(e))}),[C]),v=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onClose(),C(e))}),[C]),k=n.useCallback((e=>({modal:f(e),onConfirm:()=>y(e),onClose:()=>v(e),onChange:n=>g(e,n),onDestroy:()=>b(e)})),[f,y,v,g,b]),x=n.useMemo((()=>({modalIds:s,getModalNode:f,onChange:g,onConfirm:y,onClose:v,onDestroy:b,getModal:k,setUpdater:e=>{h.current=e}})),[s,k,f,g,y,v,b]);return e.jsx(A.Provider,{value:x,children:r})})),Y=()=>n.useContext(A),U=e=>{const{getModal:o}=Y();return n.useMemo((()=>o(e)),[e,o])},G=i.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)."}}),J=n.memo(t.withErrorBoundary((()=>{const[o,r]=t.useTick(),{modalIds:i,setUpdater:s}=Y();n.useEffect((()=>{s(r)}),[s,r]);const{options:a}=ae(),l=P(o);return e.jsx("div",{className:G,style:{transitionDuration:a.duration,backgroundColor:l?a.backdrop:"transparent"},children:i.map((n=>e.jsx(F,{modalId:n},n)))})})));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=i.css("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:K}),X=i.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:K}),Z=({children:n})=>e.jsx("h2",{className:Q,children:n}),ee=({children:n})=>e.jsx("h3",{className:Q,children:n}),ne=({children:n})=>e.jsx("div",{className:Q,children:n}),oe=({confirmLabel:n,hideConfirm:o=!1,cancelLabel:t,hideCancel:r=!1,disabled:i,onConfirm:s,onCancel:a})=>e.jsxs("div",{children:[!o&&e.jsx("button",{onClick:s,disabled:i,children:n||"확인"}),!r&&"function"==typeof a&&e.jsx("button",{onClick:a,children:t||"취소"})]}),te=n.forwardRef((({id:o,onChangeOrder:t,children:r},i)=>{const s=P(),[a,l]=n.useMemo((()=>{const e=s>1;return[e?Math.floor(o/5)%3*100:0,e?o%5*35:0]}),[s,o]);return e.jsx("div",{ref:i,className:X,onClick:t,style:{marginBottom:`calc(25vh + ${a}px)`,marginLeft:`${a}px`,transform:`translate(${l}px, ${l}px)`},children:r})})),re=()=>{const[e,o]=n.useState(window.location.pathname);return n.useLayoutEffect((()=>{let n;const t=()=>{n&&cancelAnimationFrame(n),e!==window.location.pathname?o(window.location.pathname):n=requestAnimationFrame(t)};return n=requestAnimationFrame(t),()=>{n&&cancelAnimationFrame(n)}}),[e]),{pathname:e}},ie=n.createContext({ForegroundComponent:te,TitleComponent:Z,SubtitleComponent:ee,ContentComponent:ne,FooterComponent:oe,options:{duration:u,backdrop:d,manualDestroy:!1,closeOnBackdropClick:!0}}),se=n.memo((({ForegroundComponent:r,BackgroundComponent:i,TitleComponent:s,SubtitleComponent:a,ContentComponent:l,FooterComponent:m,options:p,usePathname:f,children:b})=>{const{pathname:h}=(f||re)(),[,C]=t.useTick(),g=n.useRef(null);t.useOnMount((()=>(g.current=c.anchor("div"),C(),()=>{g.current&&g.current.remove()})));const y=n.useMemo((()=>({BackgroundComponent:i,ForegroundComponent:r||te,TitleComponent:s||Z,SubtitleComponent:a||ee,ContentComponent:n.memo(l||ne),FooterComponent:n.memo(m||oe),options:{duration:u,backdrop:d,closeOnBackdropClick:!0,manualDestroy:!1,...p}})),[r,i,l,m,a,s,p]);return e.jsxs(ie.Provider,{value:y,children:[b,g.current&&o.createPortal(e.jsx(W,{pathname:h,children:e.jsx(J,{})}),g.current)]})})),ae=()=>n.useContext(ie),le=()=>{const{options:e}=n.useContext(ie);return e};exports.ModalProvider=se,exports.alert=({subtype:e,title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})=>new Promise(((d,m)=>{try{c.open({type:"alert",subtype:e,resolve:()=>d(),title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})}catch(e){m(e)}})),exports.confirm=({subtype:e,title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})=>new Promise(((d,m)=>{try{c.open({type:"confirm",subtype:e,resolve:e=>d(e??!1),title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})}catch(e){m(e)}})),exports.prompt=({defaultValue:e,title:n,subtitle:o,content:t,Input:r,disabled:i,returnOnCancel:s,background:a,footer:l,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})=>new Promise(((f,b)=>{try{c.open({type:"prompt",resolve:e=>f(e),title:n,subtitle:o,content:t,Input:({defaultValue:e,onChange:n,onConfirm:o,onCancel:t})=>r({defaultValue:e,onChange:n,onConfirm:o,onCancel:t}),defaultValue:e,disabled:i,returnOnCancel:s,background:a,footer:l,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})}catch(e){b(e)}})),exports.useDestroyAfter=(e,o)=>{const{modal:t,onDestroy:i}=U(e),s=w(t),a=n.useRef({modal:t,onDestroy:i,milliseconds:r.isString(o)?$(o):o});n.useEffect((()=>{const{modal:e,onDestroy:n,milliseconds:o}=a.current;if(!e||e.visible||!e.alive)return;const t=setTimeout((()=>{n()}),o);return()=>{t&&clearTimeout(t)}}),[s])},exports.useModalBackdrop=()=>{const{backdrop:e}=le();return e},exports.useModalDuration=()=>{const{duration:e}=le();return{duration:e,milliseconds:$(e)}},exports.useModalOptions=le,exports.useSubscribeModal=w;
|
|
18
18
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/app/ModalManager.ts","../src/app/constant.ts","../src/components/Background/classNames.emotion.ts","../src/components/Background/Background.tsx","../src/components/Foreground/classNames.emotion.ts","../src/components/Foreground/components/AlertInner.tsx","../src/components/Foreground/components/ConfirmInner.tsx","../src/components/Foreground/components/PromptInner.tsx","../src/components/Foreground/Foreground.tsx","../src/hooks/useSubscribeModal.ts","../src/components/Presenter/classNames.emotion.ts","../src/components/Presenter/Presenter.tsx","../src/hooks/useActiveModalCount.ts","../src/core/node/ModalNode/AbstractBaseNode.ts","../src/core/node/ModalNode/AlertNode.ts","../src/core/node/ModalNode/ConfirmNode.ts","../src/core/node/ModalNode/PromptNode.ts","../src/core/node/nodeFactory.ts","../src/helpers/getMillisecondsFromDuration.ts","../src/providers/ModalDataContext/ModalDataContext.ts","../src/providers/ModalDataContext/ModalDataContextProvider.tsx","../src/providers/ModalDataContext/useModalDataContext.ts","../src/components/Anchor/classNames.emotion.ts","../src/components/Anchor/Anchor.tsx","../src/components/FallbackComponents/classNames.emotion.ts","../src/components/FallbackComponents/FallbackTitle.tsx","../src/components/FallbackComponents/FallbackSubtitle.tsx","../src/components/FallbackComponents/FallbackContent.tsx","../src/components/FallbackComponents/FallbackFooter.tsx","../src/components/FallbackComponents/FallbackForegroundFrame.tsx","../src/hooks/useDefaultPathname.ts","../src/providers/ModalContext/ModalContext.ts","../src/providers/ModalContext/ModalContextProvider.tsx","../src/providers/ModalContext/useModalContext.ts","../src/core/handle/alert.ts","../src/core/handle/confirm.ts","../src/core/handle/prompt.ts","../src/hooks/useDestroyAfter.ts"],"sourcesContent":["import { MutableRefObject } from 'react';\n\nimport { getRandomString } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { Modal } from '@/promise-modal/types';\n\nconst prerenderListRef: MutableRefObject<Modal[]> = {\n current: [],\n};\n\nconst openModalRef: MutableRefObject<Fn<[Modal], void>> = {\n current: (modal: Modal) => {\n prerenderListRef.current.push(modal);\n },\n};\n\nconst anchorRef: MutableRefObject<HTMLElement | null> = {\n current: null,\n};\n\nexport const ModalManager = {\n get prerender() {\n return prerenderListRef.current;\n },\n clearPrerender() {\n prerenderListRef.current = [];\n },\n open(modal: Modal) {\n openModalRef.current(modal);\n },\n setupOpen(open: (modal: Modal) => void) {\n openModalRef.current = open;\n },\n anchor(name: string, prefix = 'promise-modal'): HTMLElement {\n if (anchorRef.current) {\n const anchor = document.getElementById(anchorRef.current.id);\n if (anchor) return anchor;\n }\n const node = document.createElement(name);\n node.setAttribute('id', `${prefix}-${getRandomString(36)}`);\n document.body.appendChild(node);\n anchorRef.current = node;\n return node;\n },\n};\n","import type { Color, Duration } from '@aileron/types';\n\nexport const DEFAULT_ANIMATION_DURATION: Duration = '300ms';\n\nexport const DEFAULT_BACKDROP_COLOR: Color = 'rgba(0, 0, 0, 0.5)';\n","import { css } from '@emotion/css';\n\nexport const background = css`\n display: none;\n position: fixed;\n inset: 0;\n z-index: -999;\n pointer-events: none;\n > * {\n pointer-events: none;\n }\n`;\n\nexport const active = css`\n pointer-events: all;\n`;\n\nexport const visible = css`\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n","import { type MouseEvent, useCallback, useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, background, visible } from './classNames.emotion';\n\nexport const Background = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { BackgroundComponent } = useModalContext();\n const { modal, onClose, onChange, onConfirm, onDestroy } = useModal(modalId);\n\n const handleClose = useCallback(\n (event: MouseEvent) => {\n if (modal && modal.closeOnBackdropClick && modal.visible) onClose();\n event.stopPropagation();\n },\n [modal, onClose],\n );\n\n const Background = useMemo(\n () => modal?.BackgroundComponent || BackgroundComponent,\n [BackgroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(background, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.closeOnBackdropClick && modal.visible,\n })}\n onClick={handleClose}\n >\n {Background && (\n <Background\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n />\n )}\n </div>\n );\n};\n","import { css } from '@emotion/css';\n\nexport const foreground = css`\n pointer-events: none;\n display: none;\n position: fixed;\n inset: 0;\n z-index: 1;\n`;\n\nexport const active = css`\n > * {\n pointer-events: all;\n }\n`;\n\nexport const visible = css`\n display: flex !important;\n justify-content: center;\n align-items: center;\n`;\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { AlertNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface AlertInnerProps<B> {\n modal: AlertNode<B>;\n handlers: Pick<ModalActions, 'onConfirm'>;\n}\n\nexport const AlertInner = memo(\n <B,>({ modal, handlers }: AlertInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { onConfirm } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({ onConfirm: handleConfirm })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n confirmLabel={footer?.confirm}\n hideConfirm={footer?.hideConfirm}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { ConfirmNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface ConfirmInnerProps<B> {\n modal: ConfirmNode<B>;\n handlers: Pick<ModalActions, 'onConfirm' | 'onClose'>;\n}\n\nexport const ConfirmInner = memo(\n <B,>({ modal, handlers }: ConfirmInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { onConfirm, onClose } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n const handleClose = useHandle(onClose);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useCallback, useMemo, useState } from 'react';\n\nimport { isFunction, isString } from '@winglet/common-utils';\nimport {\n renderComponent,\n useHandle,\n withErrorBoundary,\n} from '@winglet/react-utils';\n\nimport type { PromptNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface PromptInnerProps<T, B> {\n modal: PromptNode<T, B>;\n handlers: Pick<ModalActions, 'onChange' | 'onClose' | 'onConfirm'>;\n}\n\nexport const PromptInner = memo(\n <T, B>({ modal, handlers }: PromptInnerProps<T, B>) => {\n const {\n Input,\n defaultValue,\n disabled: checkDisabled,\n title,\n subtitle,\n content,\n footer,\n } = useMemo(\n () => ({\n ...modal,\n Input: memo(withErrorBoundary(modal.Input)),\n }),\n [modal],\n );\n\n const [value, setValue] = useState<T | undefined>(defaultValue);\n\n const { onChange, onClose, onConfirm } = useMemo(\n () => handlers,\n [handlers],\n );\n\n const handleClose = useHandle(onClose);\n const handleChange = useHandle(\n (inputValue?: T | ((prevState: T | undefined) => T | undefined)) => {\n const input = isFunction(inputValue) ? inputValue(value) : inputValue;\n setValue(input);\n onChange(input);\n },\n );\n\n const handleConfirm = useCallback(() => {\n // NOTE: wait for the next tick to ensure the value is updated\n setTimeout(() => {\n onConfirm();\n });\n }, [onConfirm]);\n\n const disabled = useMemo(\n () => (value ? !!checkDisabled?.(value) : false),\n [checkDisabled, value],\n );\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n\n {Input && (\n <Input\n defaultValue={defaultValue}\n value={value}\n onChange={handleChange}\n onConfirm={handleConfirm}\n />\n )}\n\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n onChange: handleChange,\n value,\n disabled,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n disabled={disabled}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, foreground, visible } from './classNames.emotion';\nimport { AlertInner, ConfirmInner, PromptInner } from './components';\n\nexport const Foreground = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { ForegroundComponent } = useModalContext();\n\n const { modal, onChange, onConfirm, onClose, onDestroy } = useModal(modalId);\n\n const Foreground = useMemo(\n () => modal?.ForegroundComponent || ForegroundComponent,\n [ForegroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(foreground, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.visible,\n })}\n >\n <Foreground\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n >\n {modal.type === 'alert' && (\n <AlertInner modal={modal} handlers={{ onConfirm }} />\n )}\n {modal.type === 'confirm' && (\n <ConfirmInner modal={modal} handlers={{ onConfirm, onClose }} />\n )}\n {modal.type === 'prompt' && (\n <PromptInner\n modal={modal}\n handlers={{ onChange, onConfirm, onClose }}\n />\n )}\n </Foreground>\n </div>\n );\n};\n","import { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { ModalNode } from '@/promise-modal/core';\n\nexport const useSubscribeModal = (modal?: ModalNode) => {\n const [tick, update] = useTick();\n useOnMount(() => {\n if (!modal) return;\n const unsubscribe = modal.subscribe(update);\n return unsubscribe;\n });\n return tick;\n};\n","import { css } from '@emotion/css';\n\nexport const presenter = css`\n position: fixed;\n inset: 0;\n pointer-events: none;\n overflow: hidden;\n`;\n","import { memo, useRef } from 'react';\n\nimport { useHandle } from '@winglet/react-utils';\n\nimport { Background } from '@/promise-modal/components/Background';\nimport { Foreground } from '@/promise-modal/components/Foreground';\nimport { useSubscribeModal } from '@/promise-modal/hooks/useSubscribeModal';\nimport { useModal } from '@/promise-modal/providers';\nimport type { ModalIdProps } from '@/promise-modal/types';\n\nimport { presenter } from './classNames.emotion';\n\nlet zIndex = 1;\n\nexport const Presenter = memo(({ modalId }: ModalIdProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { modal } = useModal(modalId);\n useSubscribeModal(modal);\n const handleChangeOrder = useHandle(() => {\n if (ref.current) {\n ref.current.style.zIndex = `${zIndex++}`;\n }\n });\n return (\n <div ref={ref} className={presenter}>\n <Background modalId={modalId} onChangeOrder={handleChangeOrder} />\n <Foreground modalId={modalId} onChangeOrder={handleChangeOrder} />\n </div>\n );\n});\n","import { useMemo } from 'react';\n\nimport { useModalDataContext } from '../providers';\n\nexport const useActiveModalCount = (tick: string | number = 0) => {\n const { modalIds, getModalNode } = useModalDataContext();\n return useMemo(() => {\n let count = 0;\n for (const id of modalIds) {\n if (getModalNode(id)?.visible) count++;\n }\n return count;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getModalNode, modalIds, tick]);\n};\n","import type { ReactNode } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type {\n BackgroundComponent,\n BaseModal,\n ForegroundComponent,\n ManagedEntity,\n ModalBackground,\n} from '@/promise-modal/types';\n\ntype BaseNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;\n\nexport abstract class BaseNode<T, B> {\n readonly id: number;\n readonly initiator: string;\n\n readonly title?: ReactNode;\n readonly subtitle?: ReactNode;\n readonly background?: ModalBackground<B>;\n\n readonly manualDestroy: boolean;\n readonly closeOnBackdropClick: boolean;\n\n readonly ForegroundComponent?: ForegroundComponent;\n readonly BackgroundComponent?: BackgroundComponent;\n\n #alive: boolean;\n get alive() {\n return this.#alive;\n }\n #visible: boolean;\n get visible() {\n return this.#visible;\n }\n\n #resolve: (result: T | null) => void;\n #listeners: Fn[] = [];\n\n constructor({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy = false,\n closeOnBackdropClick = true,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: BaseNodeProps<T, B>) {\n this.id = id;\n this.initiator = initiator;\n this.title = title;\n this.subtitle = subtitle;\n this.background = background;\n this.manualDestroy = manualDestroy;\n this.closeOnBackdropClick = closeOnBackdropClick;\n\n this.ForegroundComponent = ForegroundComponent;\n this.BackgroundComponent = BackgroundComponent;\n\n this.#alive = true;\n this.#visible = true;\n this.#resolve = resolve;\n }\n\n subscribe(listener: Fn) {\n this.#listeners.push(listener);\n return () => {\n this.#listeners = this.#listeners.filter((l) => l !== listener);\n };\n }\n publish() {\n for (const listener of this.#listeners) listener();\n }\n protected resolve(result: T | null) {\n this.#resolve(result);\n }\n onDestroy() {\n const needPublish = this.#alive === true;\n this.#alive = false;\n if (this.manualDestroy && needPublish) this.publish();\n }\n onShow() {\n const needPublish = this.#visible === false;\n this.#visible = true;\n if (needPublish) this.publish();\n }\n onHide() {\n const needPublish = this.#visible === true;\n this.#visible = false;\n if (needPublish) this.publish();\n }\n abstract onClose(): void;\n abstract onConfirm(): void;\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n AlertContentProps,\n AlertFooterRender,\n AlertModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype AlertNodeProps<B> = AlertModal<B> & ManagedEntity;\n\nexport class AlertNode<B> extends BaseNode<null, B> {\n readonly type: 'alert';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<AlertContentProps>;\n readonly footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AlertNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(null);\n }\n onConfirm() {\n this.resolve(null);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n ConfirmContentProps,\n ConfirmFooterRender,\n ConfirmModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype ConfirmNodeProps<B> = ConfirmModal<B> & ManagedEntity;\n\nexport class ConfirmNode<B> extends BaseNode<boolean, B> {\n readonly type: 'confirm';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<ConfirmContentProps>;\n readonly footer?: ConfirmFooterRender | FooterOptions | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: ConfirmNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(false);\n }\n onConfirm() {\n this.resolve(true);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n FooterOptions,\n ManagedEntity,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n PromptModal,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype PromptNodeProps<T, B> = PromptModal<T, B> & ManagedEntity;\n\nexport class PromptNode<T, B> extends BaseNode<T, B> {\n readonly type: 'prompt';\n readonly content?: ReactNode | ComponentType<PromptContentProps>;\n readonly defaultValue: T | undefined;\n readonly Input: (props: PromptInputProps<T>) => ReactNode;\n readonly disabled?: (value: T) => boolean;\n readonly returnOnCancel?: boolean;\n readonly footer?: PromptFooterRender<T> | FooterOptions | false;\n #value: T | undefined;\n\n constructor({\n id,\n initiator,\n type,\n title,\n subtitle,\n content,\n defaultValue,\n Input,\n disabled,\n returnOnCancel,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: PromptNodeProps<T, B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.content = content;\n this.Input = Input;\n this.defaultValue = defaultValue;\n this.#value = defaultValue;\n this.disabled = disabled;\n this.returnOnCancel = returnOnCancel;\n this.footer = footer;\n }\n\n onChange(value: T) {\n this.#value = value;\n }\n onConfirm() {\n this.resolve(this.#value ?? null);\n }\n onClose() {\n if (this.returnOnCancel) this.resolve(this.#value ?? null);\n else this.resolve(null);\n }\n}\n","import type { ManagedModal } from '@/promise-modal/types';\n\nimport { AlertNode, ConfirmNode, PromptNode } from './ModalNode';\n\nexport const nodeFactory = <T, B>(modal: ManagedModal<T, B>) => {\n switch (modal.type) {\n case 'alert':\n return new AlertNode<B>(modal);\n case 'confirm':\n return new ConfirmNode<B>(modal);\n case 'prompt':\n return new PromptNode<T, B>(modal);\n }\n // @ts-expect-error: This state is unreachable by design and should NEVER occur.\n throw new Error(`Unknown modal: ${modal.type}`, { modal });\n};\n","const DURATION_REGEX = /^\\s*(\\d+)\\s*(ms|s|m|h)\\s*$/;\n\nexport const getMillisecondsFromDuration = (input: string) => {\n const [, durationString, unit] = input.match(DURATION_REGEX) || [];\n if (!durationString || !unit) return 0;\n const duration = parseInt(durationString);\n if (unit === 'ms') return duration;\n if (unit === 's') return duration * 1000;\n if (unit === 'm') return duration * 60 * 1000;\n if (unit === 'h') return duration * 60 * 60 * 1000;\n else return 0;\n};\n","import { createContext } from 'react';\n\nimport { undefinedFunction } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport type { ModalActions, ModalHandlersWithId } from '@/promise-modal/types';\n\nexport interface ModalDataContextProps extends ModalHandlersWithId {\n modalIds: ModalNode['id'][];\n getModal: Fn<[id: ModalNode['id']], ModalActions>;\n getModalNode: Fn<[id: ModalNode['id']], ModalNode | undefined>;\n setUpdater: Fn<[updater: Fn]>;\n}\n\nexport const ModalDataContext = createContext<ModalDataContextProps>({\n modalIds: [],\n getModalNode: undefinedFunction,\n onChange: undefinedFunction,\n onConfirm: undefinedFunction,\n onClose: undefinedFunction,\n onDestroy: undefinedFunction,\n setUpdater: undefinedFunction,\n getModal: () => ({\n modal: undefined,\n onConfirm: undefinedFunction,\n onClose: undefinedFunction,\n onChange: undefinedFunction,\n onDestroy: undefinedFunction,\n }),\n});\n","import {\n type PropsWithChildren,\n memo,\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useOnMountLayout, useReference } from '@winglet/react-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport { type ModalNode, nodeFactory } from '@/promise-modal/core';\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\nimport { useModalOptions } from '@/promise-modal/providers';\nimport type { Modal } from '@/promise-modal/types';\n\nimport { ModalDataContext } from './ModalDataContext';\n\ninterface ModalDataContextProviderProps {\n pathname: string;\n}\n\nexport const ModalDataContextProvider = memo(\n ({\n pathname,\n children,\n }: PropsWithChildren<ModalDataContextProviderProps>) => {\n const modalDictionary = useRef<Map<ModalNode['id'], ModalNode>>(new Map());\n\n const [modalIds, setModalIds] = useState<ModalNode['id'][]>([]);\n const modalIdsRef = useReference(modalIds);\n\n const initiator = useRef(pathname);\n const modalIdSequence = useRef(0);\n\n const options = useModalOptions();\n\n const duration = useMemo(\n () => getMillisecondsFromDuration(options.duration),\n [options],\n );\n\n useOnMountLayout(() => {\n const { manualDestroy, closeOnBackdropClick } = options;\n\n for (const data of ModalManager.prerender) {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => [...ids, modal.id]);\n }\n\n ModalManager.setupOpen((data: Modal) => {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => {\n const aliveIds = ids.filter((id) => {\n const destroyed = !modalDictionary.current.get(id)?.alive;\n if (destroyed) modalDictionary.current.delete(id);\n return !destroyed;\n });\n return [...aliveIds, modal.id];\n });\n });\n ModalManager.clearPrerender();\n });\n\n useLayoutEffect(() => {\n for (const id of modalIdsRef.current) {\n const modal = modalDictionary.current.get(id);\n if (!modal?.alive) continue;\n if (modal.initiator === pathname) modal.onShow();\n else modal.onHide();\n }\n initiator.current = pathname;\n }, [modalIdsRef, pathname]);\n\n const getModalNode = useCallback((modalId: ModalNode['id']) => {\n return modalDictionary.current.get(modalId);\n }, []);\n\n const onDestroy = useCallback((modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onDestroy();\n updaterRef.current?.();\n }, []);\n\n const updaterRef = useRef<Fn>();\n const hideModal = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onHide();\n updaterRef.current?.();\n if (!modal.manualDestroy)\n setTimeout(() => {\n modal.onDestroy();\n }, duration);\n },\n [duration],\n );\n\n const onChange = useCallback((modalId: ModalNode['id'], value: any) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n if (modal.type === 'prompt') modal.onChange(value);\n }, []);\n\n const onConfirm = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onConfirm();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const onClose = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onClose();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const getModal = useCallback(\n (modalId: ModalNode['id']) => ({\n modal: getModalNode(modalId),\n onConfirm: () => onConfirm(modalId),\n onClose: () => onClose(modalId),\n onChange: (value: any) => onChange(modalId, value),\n onDestroy: () => onDestroy(modalId),\n }),\n [getModalNode, onConfirm, onClose, onChange, onDestroy],\n );\n\n const value = useMemo(() => {\n return {\n modalIds,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n getModal,\n setUpdater: (updater: Fn) => {\n updaterRef.current = updater;\n },\n };\n }, [\n modalIds,\n getModal,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n ]);\n\n return (\n <ModalDataContext.Provider value={value}>\n {children}\n </ModalDataContext.Provider>\n );\n },\n);\n","import { useContext, useMemo } from 'react';\n\nimport type { ManagedModal } from '@/promise-modal/types';\n\nimport { ModalDataContext } from './ModalDataContext';\n\nexport const useModalDataContext = () => useContext(ModalDataContext);\n\nexport const useModal = (id: ManagedModal['id']) => {\n const { getModal } = useModalDataContext();\n return useMemo(() => getModal(id), [id, getModal]);\n};\n","import { css } from '@emotion/css';\n\nexport const anchor = css`\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: 1000;\n transition: background-color ease-in-out;\n`;\n","import { memo, useEffect } from 'react';\n\nimport { useTick, withErrorBoundary } from '@winglet/react-utils';\n\nimport { Presenter } from '@/promise-modal/components/Presenter';\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport { useModalContext } from '@/promise-modal/providers';\nimport { useModalDataContext } from '@/promise-modal/providers/ModalDataContext';\n\nimport { anchor } from './classNames.emotion';\n\nconst AnchorInner = () => {\n const [key, update] = useTick();\n\n const { modalIds, setUpdater } = useModalDataContext();\n\n useEffect(() => {\n setUpdater(update);\n }, [setUpdater, update]);\n\n const { options } = useModalContext();\n\n const dimmed = useActiveModalCount(key);\n\n return (\n <div\n className={anchor}\n style={{\n transitionDuration: options.duration,\n backgroundColor: dimmed ? options.backdrop : 'transparent',\n }}\n >\n {modalIds.map((id) => {\n return <Presenter key={id} modalId={id} />;\n })}\n </div>\n );\n};\n\nexport const Anchor = memo(withErrorBoundary(AnchorInner));\n","import { css } from '@emotion/css';\n\nexport const fallback = css`\n margin: unset;\n`;\n\nexport const frame = css`\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n background-color: white;\n padding: 20px 80px;\n gap: 10px;\n border: 1px solid black;\n`;\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackTitle = ({ children }: PropsWithChildren) => {\n return <h2 className={fallback}>{children}</h2>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackSubtitle = ({ children }: PropsWithChildren) => {\n return <h3 className={fallback}>{children}</h3>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackContent = ({ children }: PropsWithChildren) => {\n return <div className={fallback}>{children}</div>;\n};\n","import type { FooterComponentProps } from '@/promise-modal/types';\n\nexport const FallbackFooter = ({\n confirmLabel,\n hideConfirm = false,\n cancelLabel,\n hideCancel = false,\n disabled,\n onConfirm,\n onCancel,\n}: FooterComponentProps) => {\n return (\n <div>\n {!hideConfirm && (\n <button onClick={onConfirm} disabled={disabled}>\n {confirmLabel || '확인'}\n </button>\n )}\n\n {!hideCancel && typeof onCancel === 'function' && (\n <button onClick={onCancel}>{cancelLabel || '취소'}</button>\n )}\n </div>\n );\n};\n","import {\n type ForwardedRef,\n type PropsWithChildren,\n forwardRef,\n useMemo,\n} from 'react';\n\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport type { ModalFrameProps } from '@/promise-modal/types';\n\nimport { frame } from './classNames.emotion';\n\nconst MAX_MODAL_COUNT = 5;\nconst MAX_MODAL_LEVEL = 3;\n\nexport const FallbackForegroundFrame = forwardRef(\n (\n { id, onChangeOrder, children }: PropsWithChildren<ModalFrameProps>,\n ref: ForwardedRef<HTMLDivElement>,\n ) => {\n const activeCount = useActiveModalCount();\n const [level, offset] = useMemo(() => {\n const stacked = activeCount > 1;\n const level = stacked\n ? (Math.floor(id / MAX_MODAL_COUNT) % MAX_MODAL_LEVEL) * 100\n : 0;\n const offset = stacked ? (id % MAX_MODAL_COUNT) * 35 : 0;\n return [level, offset];\n }, [activeCount, id]);\n\n return (\n <div\n ref={ref}\n className={frame}\n onClick={onChangeOrder}\n style={{\n marginBottom: `calc(25vh + ${level}px)`,\n marginLeft: `${level}px`,\n transform: `translate(${offset}px, ${offset}px)`,\n }}\n >\n {children}\n </div>\n );\n },\n);\n","import { useLayoutEffect, useState } from 'react';\n\nexport const usePathname = () => {\n const [pathname, setPathname] = useState(window.location.pathname);\n\n useLayoutEffect(() => {\n let requestId: number;\n\n const checkPathname = () => {\n if (requestId) cancelAnimationFrame(requestId);\n if (pathname !== window.location.pathname) {\n setPathname(window.location.pathname);\n } else {\n requestId = requestAnimationFrame(checkPathname);\n }\n };\n\n requestId = requestAnimationFrame(checkPathname);\n\n return () => {\n if (requestId) cancelAnimationFrame(requestId);\n };\n }, [pathname]);\n\n return { pathname };\n};\n","import {\n type ComponentType,\n type PropsWithChildren,\n createContext,\n} from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport type {\n BackgroundComponent,\n FooterComponentProps,\n ForegroundComponent,\n} from '@/promise-modal/types';\n\nexport interface ModalContextProps {\n ForegroundComponent: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n TitleComponent: ComponentType<PropsWithChildren>;\n SubtitleComponent: ComponentType<PropsWithChildren>;\n ContentComponent: ComponentType<PropsWithChildren>;\n FooterComponent: ComponentType<FooterComponentProps>;\n options: {\n duration: Duration;\n backdrop: Color;\n manualDestroy: boolean;\n closeOnBackdropClick: boolean;\n };\n}\n\nexport const ModalContext = createContext<ModalContextProps>({\n ForegroundComponent: FallbackForegroundFrame,\n TitleComponent: FallbackTitle,\n SubtitleComponent: FallbackSubtitle,\n ContentComponent: FallbackContent,\n FooterComponent: FallbackFooter,\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n manualDestroy: false,\n closeOnBackdropClick: true,\n },\n});\n","import {\n type ComponentType,\n type PropsWithChildren,\n memo,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport { Anchor } from '@/promise-modal/components/Anchor';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport { usePathname as useDefaultPathname } from '@/promise-modal/hooks/useDefaultPathname';\nimport type {\n FooterComponentProps,\n ModalFrameProps,\n} from '@/promise-modal/types';\n\nimport { ModalDataContextProvider } from '../ModalDataContext';\nimport { ModalContext } from './ModalContext';\n\ninterface ModalContextProviderProps {\n BackgroundComponent?: ComponentType<ModalFrameProps>;\n ForegroundComponent?: ComponentType<ModalFrameProps>;\n TitleComponent?: ComponentType<PropsWithChildren>;\n SubtitleComponent?: ComponentType<PropsWithChildren>;\n ContentComponent?: ComponentType<PropsWithChildren>;\n FooterComponent?: ComponentType<FooterComponentProps>;\n options?: {\n /** Modal transition time(ms, s) */\n duration?: Duration;\n /** Modal backdrop color */\n backdrop?: Color;\n /** Whether to destroy the modal manually */\n manualDestroy?: boolean;\n /** Whether to close the modal when the backdrop is clicked */\n closeOnBackdropClick?: boolean;\n };\n usePathname?: () => { pathname: string };\n}\n\nexport const ModalContextProvider = memo(\n ({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n options,\n usePathname,\n children,\n }: PropsWithChildren<ModalContextProviderProps>) => {\n const { pathname } = (usePathname || useDefaultPathname)();\n const [, update] = useTick();\n const portalRef = useRef<HTMLElement | null>(null);\n\n useOnMount(() => {\n portalRef.current = ModalManager.anchor('div');\n update();\n return () => {\n if (portalRef.current) {\n portalRef.current.remove();\n }\n };\n });\n\n const value = useMemo(\n () => ({\n BackgroundComponent,\n ForegroundComponent: ForegroundComponent || FallbackForegroundFrame,\n TitleComponent: TitleComponent || FallbackTitle,\n SubtitleComponent: SubtitleComponent || FallbackSubtitle,\n ContentComponent: memo(ContentComponent || FallbackContent),\n FooterComponent: memo(FooterComponent || FallbackFooter),\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n closeOnBackdropClick: true,\n manualDestroy: false,\n ...options,\n } satisfies ModalContextProviderProps['options'],\n }),\n [\n ForegroundComponent,\n BackgroundComponent,\n ContentComponent,\n FooterComponent,\n SubtitleComponent,\n TitleComponent,\n options,\n ],\n );\n\n return (\n <ModalContext.Provider value={value}>\n {children}\n {portalRef.current &&\n createPortal(\n <ModalDataContextProvider pathname={pathname}>\n <Anchor />\n </ModalDataContextProvider>,\n portalRef.current,\n )}\n </ModalContext.Provider>\n );\n },\n);\n","import { useContext } from 'react';\n\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\n\nimport { ModalContext } from './ModalContext';\n\nexport const useModalContext = () => useContext(ModalContext);\n\nexport const useModalOptions = () => {\n const { options } = useContext(ModalContext);\n return options;\n};\n\nexport const useModalDuration = () => {\n const { duration } = useModalOptions();\n return { duration, milliseconds: getMillisecondsFromDuration(duration) };\n};\n\nexport const useModalBackdrop = () => {\n const { backdrop } = useModalOptions();\n return backdrop;\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n AlertContentProps,\n AlertFooterRender,\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface AlertProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<AlertContentProps>;\n background?: ModalBackground<B>;\n footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const alert = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: AlertProps<B>) => {\n return new Promise<void>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'alert',\n subtype,\n resolve: () => resolve(),\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n BackgroundComponent,\n ConfirmContentProps,\n ConfirmFooterRender,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface ConfirmProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<ConfirmContentProps>;\n background?: ModalBackground<B>;\n footer?: ConfirmFooterRender | FooterOptions | false;\n closeOnBackdropClick?: boolean;\n manualDestroy?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const confirm = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: ConfirmProps<B>) => {\n return new Promise<boolean>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'confirm',\n subtype,\n resolve: (result) => resolve(result ?? false),\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n} from '@/promise-modal/types';\n\nimport { ModalManager } from '../../app/ModalManager';\n\ninterface PromptProps<T, B = any> {\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<PromptContentProps>;\n Input: (props: PromptInputProps<T>) => ReactNode;\n defaultValue?: T;\n disabled?: (value: T) => boolean;\n returnOnCancel?: boolean;\n background?: ModalBackground<B>;\n footer?: PromptFooterRender<T> | FooterOptions | false;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const prompt = <T, B = any>({\n defaultValue,\n title,\n subtitle,\n content,\n Input,\n disabled,\n returnOnCancel,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: PromptProps<T, B>) => {\n return new Promise<T>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'prompt',\n resolve: (result) => resolve(result as T),\n title,\n subtitle,\n content,\n Input: ({ defaultValue, onChange, onConfirm }: PromptInputProps<T>) =>\n Input({\n defaultValue,\n onChange,\n onConfirm,\n }),\n defaultValue,\n disabled,\n returnOnCancel,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import { useEffect, useRef } from 'react';\n\nimport { isString } from '@winglet/common-utils';\n\nimport type { Duration } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\n\nimport { useModal } from '../providers';\nimport { useSubscribeModal } from './useSubscribeModal';\n\nexport const useDestroyAfter = (\n modalId: ModalNode['id'],\n duration: Duration | number,\n) => {\n const { modal, onDestroy } = useModal(modalId);\n const tick = useSubscribeModal(modal);\n\n const reference = useRef({\n modal,\n onDestroy,\n milliseconds: isString(duration)\n ? getMillisecondsFromDuration(duration)\n : duration,\n });\n\n useEffect(() => {\n const { modal, onDestroy, milliseconds } = reference.current;\n if (!modal || modal.visible || !modal.alive) return;\n const timer = setTimeout(() => {\n onDestroy();\n }, milliseconds);\n return () => {\n if (timer) clearTimeout(timer);\n };\n }, [tick]);\n};\n"],"names":["prerenderListRef","current","openModalRef","modal","push","anchorRef","ModalManager","prerender","clearPrerender","open","setupOpen","anchor","name","prefix","document","getElementById","id","node","createElement","setAttribute","getRandomString","body","appendChild","DEFAULT_ANIMATION_DURATION","DEFAULT_BACKDROP_COLOR","background","css","process","env","NODE_ENV","styles","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","active","visible","Background","modalId","onChangeOrder","BackgroundComponent","useModalContext","onClose","onChange","onConfirm","onDestroy","useModal","handleClose","useCallback","event","closeOnBackdropClick","stopPropagation","useMemo","_jsx","jsx","className","cx","visible$1","manualDestroy","alive","active$1","onClick","children","type","initiator","foreground","AlertInner","memo","handlers","title","subtitle","content","footer","handleConfirm","useHandle","TitleComponent","SubtitleComponent","ContentComponent","FooterComponent","_jsxs","Fragment","isString","renderComponent","confirmLabel","confirm","hideConfirm","ConfirmInner","onCancel","cancelLabel","cancel","hideCancel","PromptInner","Input","defaultValue","disabled","checkDisabled","withErrorBoundary","value","setValue","useState","handleChange","inputValue","input","isFunction","setTimeout","Foreground","ForegroundComponent","useSubscribeModal","tick","update","useTick","useOnMount","subscribe","presenter","zIndex","Presenter","ref","useRef","handleChangeOrder","style","useActiveModalCount","modalIds","getModalNode","useModalDataContext","count","BaseNode","__classPrivateFieldGet","this","_BaseNode_alive","_BaseNode_visible","constructor","resolve","Object","defineProperty","set","_BaseNode_resolve","_BaseNode_listeners","__classPrivateFieldSet","listener","filter","l","publish","result","call","needPublish","onShow","onHide","AlertNode","subtype","super","ConfirmNode","PromptNode","returnOnCancel","_PromptNode_value","nodeFactory","Error","DURATION_REGEX","getMillisecondsFromDuration","durationString","unit","match","duration","parseInt","ModalDataContext","createContext","undefinedFunction","setUpdater","getModal","undefined","ModalDataContextProvider","pathname","modalDictionary","Map","setModalIds","modalIdsRef","useReference","modalIdSequence","options","useModalOptions","useOnMountLayout","data","ids","destroyed","get","delete","useLayoutEffect","updaterRef","hideModal","updater","Provider","useContext","Anchor","key","useEffect","dimmed","transitionDuration","backgroundColor","backdrop","map","fallback","frame","FallbackTitle","FallbackSubtitle","FallbackContent","FallbackFooter","FallbackForegroundFrame","forwardRef","activeCount","level","offset","stacked","Math","floor","marginBottom","marginLeft","transform","usePathname","setPathname","window","location","requestId","checkPathname","cancelAnimationFrame","requestAnimationFrame","ModalContext","ModalContextProvider","useDefaultPathname","portalRef","remove","jsxs","createPortal","Promise","reject","error","reference","milliseconds","timer","clearTimeout"],"mappings":"yLAQA,MAAMA,EAA8C,CAClDC,QAAS,IAGLC,EAAoD,CACxDD,QAAUE,IACRH,EAAiBC,QAAQG,KAAKD,EAAM,GAIlCE,EAAkD,CACtDJ,QAAS,MAGEK,EAAe,CAC1B,aAAIC,GACF,OAAOP,EAAiBC,OACzB,EACD,cAAAO,GACER,EAAiBC,QAAU,EAC5B,EACD,IAAAQ,CAAKN,GACHD,EAAaD,QAAQE,EACtB,EACD,SAAAO,CAAUD,GACRP,EAAaD,QAAUQ,CACxB,EACD,MAAAE,CAAOC,EAAcC,EAAS,iBAC5B,GAAIR,EAAUJ,QAAS,CACrB,MAAMU,EAASG,SAASC,eAAeV,EAAUJ,QAAQe,IACzD,GAAIL,EAAQ,OAAOA,EAErB,MAAMM,EAAOH,SAASI,cAAcN,GAIpC,OAHAK,EAAKE,aAAa,KAAM,GAAGN,KAAUO,EAAeA,gBAAC,OACrDN,SAASO,KAAKC,YAAYL,GAC1BZ,EAAUJ,QAAUgB,EACbA,CACR,GC3CUM,EAAuC,QAEvCC,EAAgC,0QCFtC,MAAMC,EAAaC,EAAAA,IAAG,eAAAC,QAAAC,IAAAC,SAAA,CAAAjB,KAAA,SAAAkB,OAAA,iGAAA,CAAAlB,KAAA,oBAAAkB,OAAA,kHAAAC,SAAAC,IAWhBC,EAASP,EAAAA,IAAG,eAAAC,QAAAC,IAAAC,SAAA,CAAAjB,KAAA,SAAAkB,OAAA,sBAAA,CAAAlB,KAAA,iBAAAkB,OAAA,mCAAAC,SAAAC,IAIZE,EAAUR,EAAAA,IAAG,eAAAC,QAAAC,IAAAC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AC,UACAqB,MAAO,EAAGC,eAAclD,WAAUC,eAChCgD,EAAM,CACJC,eACAlD,WACAC,cAEJiD,eACAC,WACA0D,iBACA7H,aACA6C,SACAd,gBACAR,uBACAwD,sBACAlE,wBAEF,MAAOiM,GACPD,EAAOC,+BC1DkB,CAC7BnM,EACA2H,KAEA,MAAM5J,MAAEA,EAAKwC,UAAEA,GAAcC,EAASR,GAChCsE,EAAOD,EAAkBtG,GAEzBqO,EAAYrH,EAAAA,OAAO,CACvBhH,QACAwC,YACA8L,aAAc1J,EAAQA,SAACgF,GACnBJ,EAA4BI,GAC5BA,IAGNgC,EAAAA,WAAU,KACR,MAAM5L,MAAEA,EAAKwC,UAAEA,EAAS8L,aAAEA,GAAiBD,EAAUvO,QACrD,IAAKE,GAASA,EAAM+B,UAAY/B,EAAMsD,MAAO,OAC7C,MAAMiL,EAAQpI,YAAW,KACvB3D,GAAW,GACV8L,GACH,MAAO,KACDC,GAAOC,aAAaD,EAAM,CAC/B,GACA,CAAChI,GAAM,2BJlBoB,KAC9B,MAAMyF,SAAEA,GAAanB,KACrB,OAAOmB,CAAQ,2BAPe,KAC9B,MAAMpC,SAAEA,GAAaiB,KACrB,MAAO,CAAEjB,WAAU0E,aAAc9E,EAA4BI,GAAW"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/app/ModalManager.ts","../src/app/constant.ts","../src/components/Background/classNames.emotion.ts","../src/components/Background/Background.tsx","../src/components/Foreground/classNames.emotion.ts","../src/components/Foreground/components/AlertInner.tsx","../src/components/Foreground/components/ConfirmInner.tsx","../src/components/Foreground/components/PromptInner.tsx","../src/components/Foreground/Foreground.tsx","../src/hooks/useSubscribeModal.ts","../src/components/Presenter/classNames.emotion.ts","../src/components/Presenter/Presenter.tsx","../src/hooks/useActiveModalCount.ts","../src/core/node/ModalNode/AbstractBaseNode.ts","../src/core/node/ModalNode/AlertNode.ts","../src/core/node/ModalNode/ConfirmNode.ts","../src/core/node/ModalNode/PromptNode.ts","../src/core/node/nodeFactory.ts","../src/helpers/getMillisecondsFromDuration.ts","../src/providers/ModalDataContext/ModalDataContext.ts","../src/providers/ModalDataContext/ModalDataContextProvider.tsx","../src/providers/ModalDataContext/useModalDataContext.ts","../src/components/Anchor/classNames.emotion.ts","../src/components/Anchor/Anchor.tsx","../src/components/FallbackComponents/classNames.emotion.ts","../src/components/FallbackComponents/FallbackTitle.tsx","../src/components/FallbackComponents/FallbackSubtitle.tsx","../src/components/FallbackComponents/FallbackContent.tsx","../src/components/FallbackComponents/FallbackFooter.tsx","../src/components/FallbackComponents/FallbackForegroundFrame.tsx","../src/hooks/useDefaultPathname.ts","../src/providers/ModalContext/ModalContext.ts","../src/providers/ModalContext/ModalContextProvider.tsx","../src/providers/ModalContext/useModalContext.ts","../src/core/handle/alert.ts","../src/core/handle/confirm.ts","../src/core/handle/prompt.ts","../src/hooks/useDestroyAfter.ts"],"sourcesContent":["import { MutableRefObject } from 'react';\n\nimport { getRandomString } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { Modal } from '@/promise-modal/types';\n\nconst prerenderListRef: MutableRefObject<Modal[]> = {\n current: [],\n};\n\nconst openModalRef: MutableRefObject<Fn<[Modal], void>> = {\n current: (modal: Modal) => {\n prerenderListRef.current.push(modal);\n },\n};\n\nconst anchorRef: MutableRefObject<HTMLElement | null> = {\n current: null,\n};\n\nexport const ModalManager = {\n get prerender() {\n return prerenderListRef.current;\n },\n clearPrerender() {\n prerenderListRef.current = [];\n },\n open(modal: Modal) {\n openModalRef.current(modal);\n },\n setupOpen(open: (modal: Modal) => void) {\n openModalRef.current = open;\n },\n anchor(name: string, prefix = 'promise-modal'): HTMLElement {\n if (anchorRef.current) {\n const anchor = document.getElementById(anchorRef.current.id);\n if (anchor) return anchor;\n }\n const node = document.createElement(name);\n node.setAttribute('id', `${prefix}-${getRandomString(36)}`);\n document.body.appendChild(node);\n anchorRef.current = node;\n return node;\n },\n};\n","import type { Color, Duration } from '@aileron/types';\n\nexport const DEFAULT_ANIMATION_DURATION: Duration = '300ms';\n\nexport const DEFAULT_BACKDROP_COLOR: Color = 'rgba(0, 0, 0, 0.5)';\n","import { css } from '@emotion/css';\n\nexport const background = css`\n display: none;\n position: fixed;\n inset: 0;\n z-index: -999;\n pointer-events: none;\n > * {\n pointer-events: none;\n }\n`;\n\nexport const active = css`\n pointer-events: all;\n`;\n\nexport const visible = css`\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n","import { type MouseEvent, useCallback, useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, background, visible } from './classNames.emotion';\n\nexport const Background = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { BackgroundComponent } = useModalContext();\n const { modal, onClose, onChange, onConfirm, onDestroy } = useModal(modalId);\n\n const handleClose = useCallback(\n (event: MouseEvent) => {\n if (modal && modal.closeOnBackdropClick && modal.visible) onClose();\n event.stopPropagation();\n },\n [modal, onClose],\n );\n\n const Background = useMemo(\n () => modal?.BackgroundComponent || BackgroundComponent,\n [BackgroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(background, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.closeOnBackdropClick && modal.visible,\n })}\n onClick={handleClose}\n >\n {Background && (\n <Background\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n />\n )}\n </div>\n );\n};\n","import { css } from '@emotion/css';\n\nexport const foreground = css`\n pointer-events: none;\n display: none;\n position: fixed;\n inset: 0;\n z-index: 1;\n`;\n\nexport const active = css`\n > * {\n pointer-events: all;\n }\n`;\n\nexport const visible = css`\n display: flex !important;\n justify-content: center;\n align-items: center;\n`;\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { AlertNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface AlertInnerProps<B> {\n modal: AlertNode<B>;\n handlers: Pick<ModalActions, 'onConfirm'>;\n}\n\nexport const AlertInner = memo(\n <B,>({ modal, handlers }: AlertInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { onConfirm } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({ onConfirm: handleConfirm })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n confirmLabel={footer?.confirm}\n hideConfirm={footer?.hideConfirm}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { ConfirmNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface ConfirmInnerProps<B> {\n modal: ConfirmNode<B>;\n handlers: Pick<ModalActions, 'onConfirm' | 'onClose'>;\n}\n\nexport const ConfirmInner = memo(\n <B,>({ modal, handlers }: ConfirmInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { onConfirm, onClose } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n const handleClose = useHandle(onClose);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useCallback, useMemo, useState } from 'react';\n\nimport { isFunction, isString } from '@winglet/common-utils';\nimport {\n renderComponent,\n useHandle,\n withErrorBoundary,\n} from '@winglet/react-utils';\n\nimport type { PromptNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface PromptInnerProps<T, B> {\n modal: PromptNode<T, B>;\n handlers: Pick<ModalActions, 'onChange' | 'onClose' | 'onConfirm'>;\n}\n\nexport const PromptInner = memo(\n <T, B>({ modal, handlers }: PromptInnerProps<T, B>) => {\n const {\n Input,\n defaultValue,\n disabled: checkDisabled,\n title,\n subtitle,\n content,\n footer,\n } = useMemo(\n () => ({\n ...modal,\n Input: memo(withErrorBoundary(modal.Input)),\n }),\n [modal],\n );\n\n const [value, setValue] = useState<T | undefined>(defaultValue);\n\n const { onChange, onClose, onConfirm } = useMemo(\n () => handlers,\n [handlers],\n );\n\n const handleClose = useHandle(onClose);\n const handleChange = useHandle(\n (inputValue?: T | ((prevState: T | undefined) => T | undefined)) => {\n const input = isFunction(inputValue) ? inputValue(value) : inputValue;\n setValue(input);\n onChange(input);\n },\n );\n\n const handleConfirm = useCallback(() => {\n // NOTE: wait for the next tick to ensure the value is updated\n setTimeout(() => {\n onConfirm();\n });\n }, [onConfirm]);\n\n const disabled = useMemo(\n () => (value ? !!checkDisabled?.(value) : false),\n [checkDisabled, value],\n );\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n\n {Input && (\n <Input\n defaultValue={defaultValue}\n value={value}\n onChange={handleChange}\n onConfirm={handleConfirm}\n onCancel={handleClose}\n />\n )}\n\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onChange: handleChange,\n onConfirm: handleConfirm,\n onCancel: handleClose,\n value,\n disabled,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n disabled={disabled}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, foreground, visible } from './classNames.emotion';\nimport { AlertInner, ConfirmInner, PromptInner } from './components';\n\nexport const Foreground = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { ForegroundComponent } = useModalContext();\n\n const { modal, onChange, onConfirm, onClose, onDestroy } = useModal(modalId);\n\n const Foreground = useMemo(\n () => modal?.ForegroundComponent || ForegroundComponent,\n [ForegroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(foreground, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.visible,\n })}\n >\n <Foreground\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n >\n {modal.type === 'alert' && (\n <AlertInner modal={modal} handlers={{ onConfirm }} />\n )}\n {modal.type === 'confirm' && (\n <ConfirmInner modal={modal} handlers={{ onConfirm, onClose }} />\n )}\n {modal.type === 'prompt' && (\n <PromptInner\n modal={modal}\n handlers={{ onChange, onConfirm, onClose }}\n />\n )}\n </Foreground>\n </div>\n );\n};\n","import { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { ModalNode } from '@/promise-modal/core';\n\nexport const useSubscribeModal = (modal?: ModalNode) => {\n const [tick, update] = useTick();\n useOnMount(() => {\n if (!modal) return;\n const unsubscribe = modal.subscribe(update);\n return unsubscribe;\n });\n return tick;\n};\n","import { css } from '@emotion/css';\n\nexport const presenter = css`\n position: fixed;\n inset: 0;\n pointer-events: none;\n overflow: hidden;\n`;\n","import { memo, useRef } from 'react';\n\nimport { useHandle } from '@winglet/react-utils';\n\nimport { Background } from '@/promise-modal/components/Background';\nimport { Foreground } from '@/promise-modal/components/Foreground';\nimport { useSubscribeModal } from '@/promise-modal/hooks/useSubscribeModal';\nimport { useModal } from '@/promise-modal/providers';\nimport type { ModalIdProps } from '@/promise-modal/types';\n\nimport { presenter } from './classNames.emotion';\n\nlet zIndex = 1;\n\nexport const Presenter = memo(({ modalId }: ModalIdProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { modal } = useModal(modalId);\n useSubscribeModal(modal);\n const handleChangeOrder = useHandle(() => {\n if (ref.current) {\n ref.current.style.zIndex = `${zIndex++}`;\n }\n });\n return (\n <div ref={ref} className={presenter}>\n <Background modalId={modalId} onChangeOrder={handleChangeOrder} />\n <Foreground modalId={modalId} onChangeOrder={handleChangeOrder} />\n </div>\n );\n});\n","import { useMemo } from 'react';\n\nimport { useModalDataContext } from '../providers';\n\nexport const useActiveModalCount = (tick: string | number = 0) => {\n const { modalIds, getModalNode } = useModalDataContext();\n return useMemo(() => {\n let count = 0;\n for (const id of modalIds) {\n if (getModalNode(id)?.visible) count++;\n }\n return count;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getModalNode, modalIds, tick]);\n};\n","import type { ReactNode } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type {\n BackgroundComponent,\n BaseModal,\n ForegroundComponent,\n ManagedEntity,\n ModalBackground,\n} from '@/promise-modal/types';\n\ntype BaseNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;\n\nexport abstract class BaseNode<T, B> {\n readonly id: number;\n readonly initiator: string;\n\n readonly title?: ReactNode;\n readonly subtitle?: ReactNode;\n readonly background?: ModalBackground<B>;\n\n readonly manualDestroy: boolean;\n readonly closeOnBackdropClick: boolean;\n\n readonly ForegroundComponent?: ForegroundComponent;\n readonly BackgroundComponent?: BackgroundComponent;\n\n #alive: boolean;\n get alive() {\n return this.#alive;\n }\n #visible: boolean;\n get visible() {\n return this.#visible;\n }\n\n #resolve: (result: T | null) => void;\n #listeners: Fn[] = [];\n\n constructor({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy = false,\n closeOnBackdropClick = true,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: BaseNodeProps<T, B>) {\n this.id = id;\n this.initiator = initiator;\n this.title = title;\n this.subtitle = subtitle;\n this.background = background;\n this.manualDestroy = manualDestroy;\n this.closeOnBackdropClick = closeOnBackdropClick;\n\n this.ForegroundComponent = ForegroundComponent;\n this.BackgroundComponent = BackgroundComponent;\n\n this.#alive = true;\n this.#visible = true;\n this.#resolve = resolve;\n }\n\n subscribe(listener: Fn) {\n this.#listeners.push(listener);\n return () => {\n this.#listeners = this.#listeners.filter((l) => l !== listener);\n };\n }\n publish() {\n for (const listener of this.#listeners) listener();\n }\n protected resolve(result: T | null) {\n this.#resolve(result);\n }\n onDestroy() {\n const needPublish = this.#alive === true;\n this.#alive = false;\n if (this.manualDestroy && needPublish) this.publish();\n }\n onShow() {\n const needPublish = this.#visible === false;\n this.#visible = true;\n if (needPublish) this.publish();\n }\n onHide() {\n const needPublish = this.#visible === true;\n this.#visible = false;\n if (needPublish) this.publish();\n }\n abstract onClose(): void;\n abstract onConfirm(): void;\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n AlertContentProps,\n AlertFooterRender,\n AlertModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype AlertNodeProps<B> = AlertModal<B> & ManagedEntity;\n\nexport class AlertNode<B> extends BaseNode<null, B> {\n readonly type: 'alert';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<AlertContentProps>;\n readonly footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AlertNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(null);\n }\n onConfirm() {\n this.resolve(null);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n ConfirmContentProps,\n ConfirmFooterRender,\n ConfirmModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype ConfirmNodeProps<B> = ConfirmModal<B> & ManagedEntity;\n\nexport class ConfirmNode<B> extends BaseNode<boolean, B> {\n readonly type: 'confirm';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<ConfirmContentProps>;\n readonly footer?: ConfirmFooterRender | FooterOptions | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: ConfirmNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(false);\n }\n onConfirm() {\n this.resolve(true);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n FooterOptions,\n ManagedEntity,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n PromptModal,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype PromptNodeProps<T, B> = PromptModal<T, B> & ManagedEntity;\n\nexport class PromptNode<T, B> extends BaseNode<T, B> {\n readonly type: 'prompt';\n readonly content?: ReactNode | ComponentType<PromptContentProps>;\n readonly defaultValue: T | undefined;\n readonly Input: (props: PromptInputProps<T>) => ReactNode;\n readonly disabled?: (value: T) => boolean;\n readonly returnOnCancel?: boolean;\n readonly footer?: PromptFooterRender<T> | FooterOptions | false;\n #value: T | undefined;\n\n constructor({\n id,\n initiator,\n type,\n title,\n subtitle,\n content,\n defaultValue,\n Input,\n disabled,\n returnOnCancel,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: PromptNodeProps<T, B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.content = content;\n this.Input = Input;\n this.defaultValue = defaultValue;\n this.#value = defaultValue;\n this.disabled = disabled;\n this.returnOnCancel = returnOnCancel;\n this.footer = footer;\n }\n\n onChange(value: T) {\n this.#value = value;\n }\n onConfirm() {\n this.resolve(this.#value ?? null);\n }\n onClose() {\n if (this.returnOnCancel) this.resolve(this.#value ?? null);\n else this.resolve(null);\n }\n}\n","import type { ManagedModal } from '@/promise-modal/types';\n\nimport { AlertNode, ConfirmNode, PromptNode } from './ModalNode';\n\nexport const nodeFactory = <T, B>(modal: ManagedModal<T, B>) => {\n switch (modal.type) {\n case 'alert':\n return new AlertNode<B>(modal);\n case 'confirm':\n return new ConfirmNode<B>(modal);\n case 'prompt':\n return new PromptNode<T, B>(modal);\n }\n // @ts-expect-error: This state is unreachable by design and should NEVER occur.\n throw new Error(`Unknown modal: ${modal.type}`, { modal });\n};\n","const DURATION_REGEX = /^\\s*(\\d+)\\s*(ms|s|m|h)\\s*$/;\n\nexport const getMillisecondsFromDuration = (input: string) => {\n const [, durationString, unit] = input.match(DURATION_REGEX) || [];\n if (!durationString || !unit) return 0;\n const duration = parseInt(durationString);\n if (unit === 'ms') return duration;\n if (unit === 's') return duration * 1000;\n if (unit === 'm') return duration * 60 * 1000;\n if (unit === 'h') return duration * 60 * 60 * 1000;\n else return 0;\n};\n","import { createContext } from 'react';\n\nimport { undefinedFunction } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport type { ModalActions, ModalHandlersWithId } from '@/promise-modal/types';\n\nexport interface ModalDataContextProps extends ModalHandlersWithId {\n modalIds: ModalNode['id'][];\n getModal: Fn<[id: ModalNode['id']], ModalActions>;\n getModalNode: Fn<[id: ModalNode['id']], ModalNode | undefined>;\n setUpdater: Fn<[updater: Fn]>;\n}\n\nexport const ModalDataContext = createContext<ModalDataContextProps>({\n modalIds: [],\n getModalNode: undefinedFunction,\n onChange: undefinedFunction,\n onConfirm: undefinedFunction,\n onClose: undefinedFunction,\n onDestroy: undefinedFunction,\n setUpdater: undefinedFunction,\n getModal: () => ({\n modal: undefined,\n onConfirm: undefinedFunction,\n onClose: undefinedFunction,\n onChange: undefinedFunction,\n onDestroy: undefinedFunction,\n }),\n});\n","import {\n type PropsWithChildren,\n memo,\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useOnMountLayout, useReference } from '@winglet/react-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport { type ModalNode, nodeFactory } from '@/promise-modal/core';\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\nimport { useModalOptions } from '@/promise-modal/providers';\nimport type { Modal } from '@/promise-modal/types';\n\nimport { ModalDataContext } from './ModalDataContext';\n\ninterface ModalDataContextProviderProps {\n pathname: string;\n}\n\nexport const ModalDataContextProvider = memo(\n ({\n pathname,\n children,\n }: PropsWithChildren<ModalDataContextProviderProps>) => {\n const modalDictionary = useRef<Map<ModalNode['id'], ModalNode>>(new Map());\n\n const [modalIds, setModalIds] = useState<ModalNode['id'][]>([]);\n const modalIdsRef = useReference(modalIds);\n\n const initiator = useRef(pathname);\n const modalIdSequence = useRef(0);\n\n const options = useModalOptions();\n\n const duration = useMemo(\n () => getMillisecondsFromDuration(options.duration),\n [options],\n );\n\n useOnMountLayout(() => {\n const { manualDestroy, closeOnBackdropClick } = options;\n\n for (const data of ModalManager.prerender) {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => [...ids, modal.id]);\n }\n\n ModalManager.setupOpen((data: Modal) => {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => {\n const aliveIds = ids.filter((id) => {\n const destroyed = !modalDictionary.current.get(id)?.alive;\n if (destroyed) modalDictionary.current.delete(id);\n return !destroyed;\n });\n return [...aliveIds, modal.id];\n });\n });\n ModalManager.clearPrerender();\n });\n\n useLayoutEffect(() => {\n for (const id of modalIdsRef.current) {\n const modal = modalDictionary.current.get(id);\n if (!modal?.alive) continue;\n if (modal.initiator === pathname) modal.onShow();\n else modal.onHide();\n }\n initiator.current = pathname;\n }, [modalIdsRef, pathname]);\n\n const getModalNode = useCallback((modalId: ModalNode['id']) => {\n return modalDictionary.current.get(modalId);\n }, []);\n\n const onDestroy = useCallback((modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onDestroy();\n updaterRef.current?.();\n }, []);\n\n const updaterRef = useRef<Fn>();\n const hideModal = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onHide();\n updaterRef.current?.();\n if (!modal.manualDestroy)\n setTimeout(() => {\n modal.onDestroy();\n }, duration);\n },\n [duration],\n );\n\n const onChange = useCallback((modalId: ModalNode['id'], value: any) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n if (modal.type === 'prompt') modal.onChange(value);\n }, []);\n\n const onConfirm = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onConfirm();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const onClose = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onClose();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const getModal = useCallback(\n (modalId: ModalNode['id']) => ({\n modal: getModalNode(modalId),\n onConfirm: () => onConfirm(modalId),\n onClose: () => onClose(modalId),\n onChange: (value: any) => onChange(modalId, value),\n onDestroy: () => onDestroy(modalId),\n }),\n [getModalNode, onConfirm, onClose, onChange, onDestroy],\n );\n\n const value = useMemo(() => {\n return {\n modalIds,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n getModal,\n setUpdater: (updater: Fn) => {\n updaterRef.current = updater;\n },\n };\n }, [\n modalIds,\n getModal,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n ]);\n\n return (\n <ModalDataContext.Provider value={value}>\n {children}\n </ModalDataContext.Provider>\n );\n },\n);\n","import { useContext, useMemo } from 'react';\n\nimport type { ManagedModal } from '@/promise-modal/types';\n\nimport { ModalDataContext } from './ModalDataContext';\n\nexport const useModalDataContext = () => useContext(ModalDataContext);\n\nexport const useModal = (id: ManagedModal['id']) => {\n const { getModal } = useModalDataContext();\n return useMemo(() => getModal(id), [id, getModal]);\n};\n","import { css } from '@emotion/css';\n\nexport const anchor = css`\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: 1000;\n transition: background-color ease-in-out;\n`;\n","import { memo, useEffect } from 'react';\n\nimport { useTick, withErrorBoundary } from '@winglet/react-utils';\n\nimport { Presenter } from '@/promise-modal/components/Presenter';\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport { useModalContext } from '@/promise-modal/providers';\nimport { useModalDataContext } from '@/promise-modal/providers/ModalDataContext';\n\nimport { anchor } from './classNames.emotion';\n\nconst AnchorInner = () => {\n const [key, update] = useTick();\n\n const { modalIds, setUpdater } = useModalDataContext();\n\n useEffect(() => {\n setUpdater(update);\n }, [setUpdater, update]);\n\n const { options } = useModalContext();\n\n const dimmed = useActiveModalCount(key);\n\n return (\n <div\n className={anchor}\n style={{\n transitionDuration: options.duration,\n backgroundColor: dimmed ? options.backdrop : 'transparent',\n }}\n >\n {modalIds.map((id) => {\n return <Presenter key={id} modalId={id} />;\n })}\n </div>\n );\n};\n\nexport const Anchor = memo(withErrorBoundary(AnchorInner));\n","import { css } from '@emotion/css';\n\nexport const fallback = css`\n margin: unset;\n`;\n\nexport const frame = css`\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n background-color: white;\n padding: 20px 80px;\n gap: 10px;\n border: 1px solid black;\n`;\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackTitle = ({ children }: PropsWithChildren) => {\n return <h2 className={fallback}>{children}</h2>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackSubtitle = ({ children }: PropsWithChildren) => {\n return <h3 className={fallback}>{children}</h3>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackContent = ({ children }: PropsWithChildren) => {\n return <div className={fallback}>{children}</div>;\n};\n","import type { FooterComponentProps } from '@/promise-modal/types';\n\nexport const FallbackFooter = ({\n confirmLabel,\n hideConfirm = false,\n cancelLabel,\n hideCancel = false,\n disabled,\n onConfirm,\n onCancel,\n}: FooterComponentProps) => {\n return (\n <div>\n {!hideConfirm && (\n <button onClick={onConfirm} disabled={disabled}>\n {confirmLabel || '확인'}\n </button>\n )}\n\n {!hideCancel && typeof onCancel === 'function' && (\n <button onClick={onCancel}>{cancelLabel || '취소'}</button>\n )}\n </div>\n );\n};\n","import {\n type ForwardedRef,\n type PropsWithChildren,\n forwardRef,\n useMemo,\n} from 'react';\n\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport type { ModalFrameProps } from '@/promise-modal/types';\n\nimport { frame } from './classNames.emotion';\n\nconst MAX_MODAL_COUNT = 5;\nconst MAX_MODAL_LEVEL = 3;\n\nexport const FallbackForegroundFrame = forwardRef(\n (\n { id, onChangeOrder, children }: PropsWithChildren<ModalFrameProps>,\n ref: ForwardedRef<HTMLDivElement>,\n ) => {\n const activeCount = useActiveModalCount();\n const [level, offset] = useMemo(() => {\n const stacked = activeCount > 1;\n const level = stacked\n ? (Math.floor(id / MAX_MODAL_COUNT) % MAX_MODAL_LEVEL) * 100\n : 0;\n const offset = stacked ? (id % MAX_MODAL_COUNT) * 35 : 0;\n return [level, offset];\n }, [activeCount, id]);\n\n return (\n <div\n ref={ref}\n className={frame}\n onClick={onChangeOrder}\n style={{\n marginBottom: `calc(25vh + ${level}px)`,\n marginLeft: `${level}px`,\n transform: `translate(${offset}px, ${offset}px)`,\n }}\n >\n {children}\n </div>\n );\n },\n);\n","import { useLayoutEffect, useState } from 'react';\n\nexport const usePathname = () => {\n const [pathname, setPathname] = useState(window.location.pathname);\n\n useLayoutEffect(() => {\n let requestId: number;\n\n const checkPathname = () => {\n if (requestId) cancelAnimationFrame(requestId);\n if (pathname !== window.location.pathname) {\n setPathname(window.location.pathname);\n } else {\n requestId = requestAnimationFrame(checkPathname);\n }\n };\n\n requestId = requestAnimationFrame(checkPathname);\n\n return () => {\n if (requestId) cancelAnimationFrame(requestId);\n };\n }, [pathname]);\n\n return { pathname };\n};\n","import {\n type ComponentType,\n type PropsWithChildren,\n createContext,\n} from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport type {\n BackgroundComponent,\n FooterComponentProps,\n ForegroundComponent,\n} from '@/promise-modal/types';\n\nexport interface ModalContextProps {\n ForegroundComponent: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n TitleComponent: ComponentType<PropsWithChildren>;\n SubtitleComponent: ComponentType<PropsWithChildren>;\n ContentComponent: ComponentType<PropsWithChildren>;\n FooterComponent: ComponentType<FooterComponentProps>;\n options: {\n duration: Duration;\n backdrop: Color;\n manualDestroy: boolean;\n closeOnBackdropClick: boolean;\n };\n}\n\nexport const ModalContext = createContext<ModalContextProps>({\n ForegroundComponent: FallbackForegroundFrame,\n TitleComponent: FallbackTitle,\n SubtitleComponent: FallbackSubtitle,\n ContentComponent: FallbackContent,\n FooterComponent: FallbackFooter,\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n manualDestroy: false,\n closeOnBackdropClick: true,\n },\n});\n","import {\n type ComponentType,\n type PropsWithChildren,\n memo,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport { Anchor } from '@/promise-modal/components/Anchor';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport { usePathname as useDefaultPathname } from '@/promise-modal/hooks/useDefaultPathname';\nimport type {\n FooterComponentProps,\n ModalFrameProps,\n} from '@/promise-modal/types';\n\nimport { ModalDataContextProvider } from '../ModalDataContext';\nimport { ModalContext } from './ModalContext';\n\ninterface ModalContextProviderProps {\n BackgroundComponent?: ComponentType<ModalFrameProps>;\n ForegroundComponent?: ComponentType<ModalFrameProps>;\n TitleComponent?: ComponentType<PropsWithChildren>;\n SubtitleComponent?: ComponentType<PropsWithChildren>;\n ContentComponent?: ComponentType<PropsWithChildren>;\n FooterComponent?: ComponentType<FooterComponentProps>;\n options?: {\n /** Modal transition time(ms, s) */\n duration?: Duration;\n /** Modal backdrop color */\n backdrop?: Color;\n /** Whether to destroy the modal manually */\n manualDestroy?: boolean;\n /** Whether to close the modal when the backdrop is clicked */\n closeOnBackdropClick?: boolean;\n };\n usePathname?: () => { pathname: string };\n}\n\nexport const ModalContextProvider = memo(\n ({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n options,\n usePathname,\n children,\n }: PropsWithChildren<ModalContextProviderProps>) => {\n const { pathname } = (usePathname || useDefaultPathname)();\n const [, update] = useTick();\n const portalRef = useRef<HTMLElement | null>(null);\n\n useOnMount(() => {\n portalRef.current = ModalManager.anchor('div');\n update();\n return () => {\n if (portalRef.current) {\n portalRef.current.remove();\n }\n };\n });\n\n const value = useMemo(\n () => ({\n BackgroundComponent,\n ForegroundComponent: ForegroundComponent || FallbackForegroundFrame,\n TitleComponent: TitleComponent || FallbackTitle,\n SubtitleComponent: SubtitleComponent || FallbackSubtitle,\n ContentComponent: memo(ContentComponent || FallbackContent),\n FooterComponent: memo(FooterComponent || FallbackFooter),\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n closeOnBackdropClick: true,\n manualDestroy: false,\n ...options,\n } satisfies ModalContextProviderProps['options'],\n }),\n [\n ForegroundComponent,\n BackgroundComponent,\n ContentComponent,\n FooterComponent,\n SubtitleComponent,\n TitleComponent,\n options,\n ],\n );\n\n return (\n <ModalContext.Provider value={value}>\n {children}\n {portalRef.current &&\n createPortal(\n <ModalDataContextProvider pathname={pathname}>\n <Anchor />\n </ModalDataContextProvider>,\n portalRef.current,\n )}\n </ModalContext.Provider>\n );\n },\n);\n","import { useContext } from 'react';\n\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\n\nimport { ModalContext } from './ModalContext';\n\nexport const useModalContext = () => useContext(ModalContext);\n\nexport const useModalOptions = () => {\n const { options } = useContext(ModalContext);\n return options;\n};\n\nexport const useModalDuration = () => {\n const { duration } = useModalOptions();\n return { duration, milliseconds: getMillisecondsFromDuration(duration) };\n};\n\nexport const useModalBackdrop = () => {\n const { backdrop } = useModalOptions();\n return backdrop;\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n AlertContentProps,\n AlertFooterRender,\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface AlertProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<AlertContentProps>;\n background?: ModalBackground<B>;\n footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const alert = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: AlertProps<B>) => {\n return new Promise<void>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'alert',\n subtype,\n resolve: () => resolve(),\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n BackgroundComponent,\n ConfirmContentProps,\n ConfirmFooterRender,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface ConfirmProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<ConfirmContentProps>;\n background?: ModalBackground<B>;\n footer?: ConfirmFooterRender | FooterOptions | false;\n closeOnBackdropClick?: boolean;\n manualDestroy?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const confirm = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: ConfirmProps<B>) => {\n return new Promise<boolean>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'confirm',\n subtype,\n resolve: (result) => resolve(result ?? false),\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n} from '@/promise-modal/types';\n\nimport { ModalManager } from '../../app/ModalManager';\n\ninterface PromptProps<T, B = any> {\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<PromptContentProps>;\n Input: (props: PromptInputProps<T>) => ReactNode;\n defaultValue?: T;\n disabled?: (value: T) => boolean;\n returnOnCancel?: boolean;\n background?: ModalBackground<B>;\n footer?: PromptFooterRender<T> | FooterOptions | false;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const prompt = <T, B = any>({\n defaultValue,\n title,\n subtitle,\n content,\n Input,\n disabled,\n returnOnCancel,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: PromptProps<T, B>) => {\n return new Promise<T>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'prompt',\n resolve: (result) => resolve(result as T),\n title,\n subtitle,\n content,\n Input: ({\n defaultValue,\n onChange,\n onConfirm,\n onCancel,\n }: PromptInputProps<T>) =>\n Input({\n defaultValue,\n onChange,\n onConfirm,\n onCancel,\n }),\n defaultValue,\n disabled,\n returnOnCancel,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import { useEffect, useRef } from 'react';\n\nimport { isString } from '@winglet/common-utils';\n\nimport type { Duration } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\n\nimport { useModal } from '../providers';\nimport { useSubscribeModal } from './useSubscribeModal';\n\nexport const useDestroyAfter = (\n modalId: ModalNode['id'],\n duration: Duration | number,\n) => {\n const { modal, onDestroy } = useModal(modalId);\n const tick = useSubscribeModal(modal);\n\n const reference = useRef({\n modal,\n onDestroy,\n milliseconds: isString(duration)\n ? getMillisecondsFromDuration(duration)\n : duration,\n });\n\n useEffect(() => {\n const { modal, onDestroy, milliseconds } = reference.current;\n if (!modal || modal.visible || !modal.alive) return;\n const timer = setTimeout(() => {\n onDestroy();\n }, milliseconds);\n return () => {\n if (timer) clearTimeout(timer);\n };\n }, [tick]);\n};\n"],"names":["prerenderListRef","current","openModalRef","modal","push","anchorRef","ModalManager","prerender","clearPrerender","open","setupOpen","anchor","name","prefix","document","getElementById","id","node","createElement","setAttribute","getRandomString","body","appendChild","DEFAULT_ANIMATION_DURATION","DEFAULT_BACKDROP_COLOR","background","css","process","env","NODE_ENV","styles","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","active","visible","Background","modalId","onChangeOrder","BackgroundComponent","useModalContext","onClose","onChange","onConfirm","onDestroy","useModal","handleClose","useCallback","event","closeOnBackdropClick","stopPropagation","useMemo","_jsx","jsx","className","cx","visible$1","manualDestroy","alive","active$1","onClick","children","type","initiator","foreground","AlertInner","memo","handlers","title","subtitle","content","footer","handleConfirm","useHandle","TitleComponent","SubtitleComponent","ContentComponent","FooterComponent","_jsxs","Fragment","isString","renderComponent","confirmLabel","confirm","hideConfirm","ConfirmInner","onCancel","cancelLabel","cancel","hideCancel","PromptInner","Input","defaultValue","disabled","checkDisabled","withErrorBoundary","value","setValue","useState","handleChange","inputValue","input","isFunction","setTimeout","Foreground","ForegroundComponent","useSubscribeModal","tick","update","useTick","useOnMount","subscribe","presenter","zIndex","Presenter","ref","useRef","handleChangeOrder","style","useActiveModalCount","modalIds","getModalNode","useModalDataContext","count","BaseNode","__classPrivateFieldGet","this","_BaseNode_alive","_BaseNode_visible","constructor","resolve","Object","defineProperty","set","_BaseNode_resolve","_BaseNode_listeners","__classPrivateFieldSet","listener","filter","l","publish","result","call","needPublish","onShow","onHide","AlertNode","subtype","super","ConfirmNode","PromptNode","returnOnCancel","_PromptNode_value","nodeFactory","Error","DURATION_REGEX","getMillisecondsFromDuration","durationString","unit","match","duration","parseInt","ModalDataContext","createContext","undefinedFunction","setUpdater","getModal","undefined","ModalDataContextProvider","pathname","modalDictionary","Map","setModalIds","modalIdsRef","useReference","modalIdSequence","options","useModalOptions","useOnMountLayout","data","ids","destroyed","get","delete","useLayoutEffect","updaterRef","hideModal","updater","Provider","useContext","Anchor","key","useEffect","dimmed","transitionDuration","backgroundColor","backdrop","map","fallback","frame","FallbackTitle","FallbackSubtitle","FallbackContent","FallbackFooter","FallbackForegroundFrame","forwardRef","activeCount","level","offset","stacked","Math","floor","marginBottom","marginLeft","transform","usePathname","setPathname","window","location","requestId","checkPathname","cancelAnimationFrame","requestAnimationFrame","ModalContext","ModalContextProvider","useDefaultPathname","portalRef","remove","jsxs","createPortal","Promise","reject","error","reference","milliseconds","timer","clearTimeout"],"mappings":"yLAQA,MAAMA,EAA8C,CAClDC,QAAS,IAGLC,EAAoD,CACxDD,QAAUE,IACRH,EAAiBC,QAAQG,KAAKD,EAAM,GAIlC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AAQA,SAACgF,GACnBJ,EAA4BI,GAC5BA,IAGNgC,EAAAA,WAAU,KACR,MAAM5L,MAAEA,EAAKwC,UAAEA,EAAS8L,aAAEA,GAAiBD,EAAUvO,QACrD,IAAKE,GAASA,EAAM+B,UAAY/B,EAAMsD,MAAO,OAC7C,MAAMiL,EAAQpI,YAAW,KACvB3D,GAAW,GACV8L,GACH,MAAO,KACDC,GAAOC,aAAaD,EAAM,CAC/B,GACA,CAAChI,GAAM,2BJlBoB,KAC9B,MAAMyF,SAAEA,GAAanB,KACrB,OAAOmB,CAAQ,2BAPe,KAC9B,MAAMpC,SAAEA,GAAaiB,KACrB,MAAO,CAAEjB,WAAU0E,aAAc9E,EAA4BI,GAAW"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useCallback as o,useMemo as t,memo as r,Fragment as i,useState as a,useRef as l,createContext as s,useLayoutEffect as c,useContext as d,useEffect as u,forwardRef as p}from"react";import{createPortal as m}from"react-dom";import{useHandle as f,renderComponent as b,withErrorBoundary as h,useTick as C,useOnMount as g,useReference as y,useOnMountLayout as v}from"@winglet/react-utils";import{getRandomString as k,isString as O,isFunction as w,undefinedFunction as D}from"@winglet/common-utils";import{css as B,cx as x}from"@emotion/css";const j={current:[]},P={current:e=>{j.current.push(e)}},N={current:null},E={get prerender(){return j.current},clearPrerender(){j.current=[]},open(e){P.current(e)},setupOpen(e){P.current=e},anchor(e,n="promise-modal"){if(N.current){const e=document.getElementById(N.current.id);if(e)return e}const o=document.createElement(e);return o.setAttribute("id",`${n}-${k(36)}`),document.body.appendChild(o),N.current=o,o}},F="300ms",I="rgba(0, 0, 0, 0.5)";function S(){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 V=B("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:S}),T=B("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:S}),M=B("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:S}),_=({modalId:n,onChangeOrder:r})=>{const{BackgroundComponent:i}=Fe(),{modal:a,onClose:l,onChange:s,onConfirm:c,onDestroy:d}=Ce(n),u=o((e=>{a&&a.closeOnBackdropClick&&a.visible&&l(),e.stopPropagation()}),[a,l]),p=t((()=>a?.BackgroundComponent||i),[i,a]);return a?e("div",{className:x(V,{[M]:a.manualDestroy?a.alive:a.visible,[T]:a.closeOnBackdropClick&&a.visible}),onClick:u,children:p&&e(p,{id:a.id,type:a.type,alive:a.alive,visible:a.visible,initiator:a.initiator,manualDestroy:a.manualDestroy,closeOnBackdropClick:a.closeOnBackdropClick,background:a.background,onChange:s,onConfirm:c,onClose:l,onDestroy:d,onChangeOrder:r})}):null};function z(){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 L=B("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:z}),$=B("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:z}),A=B("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:z}),W=r((({modal:o,handlers:r})=>{const{title:a,subtitle:l,content:s,footer:c}=t((()=>o),[o]),{onConfirm:d}=t((()=>r),[r]),u=f(d),{TitleComponent:p,SubtitleComponent:m,ContentComponent:h,FooterComponent:C}=Fe();return n(i,{children:[a&&(O(a)?e(p,{children:a}):a),l&&(O(l)?e(m,{children:l}):l),s&&(O(s)?e(h,{children:s}):b(s,{onConfirm:u})),!1!==c&&("function"==typeof c?c({onConfirm:u}):e(C,{onConfirm:u,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm}))]})})),Y=r((({modal:o,handlers:r})=>{const{title:a,subtitle:l,content:s,footer:c}=t((()=>o),[o]),{onConfirm:d,onClose:u}=t((()=>r),[r]),p=f(d),m=f(u),{TitleComponent:h,SubtitleComponent:C,ContentComponent:g,FooterComponent:y}=Fe();return n(i,{children:[a&&(O(a)?e(h,{children:a}):a),l&&(O(l)?e(C,{children:l}):l),s&&(O(s)?e(g,{children:s}):b(s,{onConfirm:p,onCancel:m})),!1!==c&&("function"==typeof c?c({onConfirm:p,onCancel:m}):e(y,{onConfirm:p,onCancel:m,confirmLabel:c?.confirm,cancelLabel:c?.cancel,hideConfirm:c?.hideConfirm,hideCancel:c?.hideCancel}))]})})),U=r((({modal:l,handlers:s})=>{const{Input:c,defaultValue:d,disabled:u,title:p,subtitle:m,content:C,footer:g}=t((()=>({...l,Input:r(h(l.Input))})),[l]),[y,v]=a(d),{onChange:k,onClose:D,onConfirm:B}=t((()=>s),[s]),x=f(D),j=f((e=>{const n=w(e)?e(y):e;v(n),k(n)})),P=o((()=>{setTimeout((()=>{B()}))}),[B]),N=t((()=>!!y&&!!u?.(y)),[u,y]),{TitleComponent:E,SubtitleComponent:F,ContentComponent:I,FooterComponent:S}=Fe();return n(i,{children:[p&&(O(p)?e(E,{children:p}):p),m&&(O(m)?e(F,{children:m}):m),C&&(O(C)?e(I,{children:C}):b(C,{onConfirm:P,onCancel:x})),c&&e(c,{defaultValue:d,value:y,onChange:j,onConfirm:P}),!1!==g&&("function"==typeof g?g({onConfirm:P,onCancel:x,
|
|
1
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useCallback as o,useMemo as t,memo as r,Fragment as i,useState as a,useRef as l,createContext as s,useLayoutEffect as c,useContext as d,useEffect as u,forwardRef as p}from"react";import{createPortal as m}from"react-dom";import{useHandle as f,renderComponent as b,withErrorBoundary as h,useTick as C,useOnMount as g,useReference as y,useOnMountLayout as v}from"@winglet/react-utils";import{getRandomString as k,isString as O,isFunction as w,undefinedFunction as D}from"@winglet/common-utils";import{css as B,cx as x}from"@emotion/css";const j={current:[]},P={current:e=>{j.current.push(e)}},N={current:null},E={get prerender(){return j.current},clearPrerender(){j.current=[]},open(e){P.current(e)},setupOpen(e){P.current=e},anchor(e,n="promise-modal"){if(N.current){const e=document.getElementById(N.current.id);if(e)return e}const o=document.createElement(e);return o.setAttribute("id",`${n}-${k(36)}`),document.body.appendChild(o),N.current=o,o}},F="300ms",I="rgba(0, 0, 0, 0.5)";function S(){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 V=B("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:S}),T=B("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:S}),M=B("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:S}),_=({modalId:n,onChangeOrder:r})=>{const{BackgroundComponent:i}=Fe(),{modal:a,onClose:l,onChange:s,onConfirm:c,onDestroy:d}=Ce(n),u=o((e=>{a&&a.closeOnBackdropClick&&a.visible&&l(),e.stopPropagation()}),[a,l]),p=t((()=>a?.BackgroundComponent||i),[i,a]);return a?e("div",{className:x(V,{[M]:a.manualDestroy?a.alive:a.visible,[T]:a.closeOnBackdropClick&&a.visible}),onClick:u,children:p&&e(p,{id:a.id,type:a.type,alive:a.alive,visible:a.visible,initiator:a.initiator,manualDestroy:a.manualDestroy,closeOnBackdropClick:a.closeOnBackdropClick,background:a.background,onChange:s,onConfirm:c,onClose:l,onDestroy:d,onChangeOrder:r})}):null};function z(){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 L=B("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:z}),$=B("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:z}),A=B("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:z}),W=r((({modal:o,handlers:r})=>{const{title:a,subtitle:l,content:s,footer:c}=t((()=>o),[o]),{onConfirm:d}=t((()=>r),[r]),u=f(d),{TitleComponent:p,SubtitleComponent:m,ContentComponent:h,FooterComponent:C}=Fe();return n(i,{children:[a&&(O(a)?e(p,{children:a}):a),l&&(O(l)?e(m,{children:l}):l),s&&(O(s)?e(h,{children:s}):b(s,{onConfirm:u})),!1!==c&&("function"==typeof c?c({onConfirm:u}):e(C,{onConfirm:u,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm}))]})})),Y=r((({modal:o,handlers:r})=>{const{title:a,subtitle:l,content:s,footer:c}=t((()=>o),[o]),{onConfirm:d,onClose:u}=t((()=>r),[r]),p=f(d),m=f(u),{TitleComponent:h,SubtitleComponent:C,ContentComponent:g,FooterComponent:y}=Fe();return n(i,{children:[a&&(O(a)?e(h,{children:a}):a),l&&(O(l)?e(C,{children:l}):l),s&&(O(s)?e(g,{children:s}):b(s,{onConfirm:p,onCancel:m})),!1!==c&&("function"==typeof c?c({onConfirm:p,onCancel:m}):e(y,{onConfirm:p,onCancel:m,confirmLabel:c?.confirm,cancelLabel:c?.cancel,hideConfirm:c?.hideConfirm,hideCancel:c?.hideCancel}))]})})),U=r((({modal:l,handlers:s})=>{const{Input:c,defaultValue:d,disabled:u,title:p,subtitle:m,content:C,footer:g}=t((()=>({...l,Input:r(h(l.Input))})),[l]),[y,v]=a(d),{onChange:k,onClose:D,onConfirm:B}=t((()=>s),[s]),x=f(D),j=f((e=>{const n=w(e)?e(y):e;v(n),k(n)})),P=o((()=>{setTimeout((()=>{B()}))}),[B]),N=t((()=>!!y&&!!u?.(y)),[u,y]),{TitleComponent:E,SubtitleComponent:F,ContentComponent:I,FooterComponent:S}=Fe();return n(i,{children:[p&&(O(p)?e(E,{children:p}):p),m&&(O(m)?e(F,{children:m}):m),C&&(O(C)?e(I,{children:C}):b(C,{onConfirm:P,onCancel:x})),c&&e(c,{defaultValue:d,value:y,onChange:j,onConfirm:P,onCancel:x}),!1!==g&&("function"==typeof g?g({onChange:j,onConfirm:P,onCancel:x,value:y,disabled:N}):e(S,{onConfirm:P,onCancel:x,disabled:N,confirmLabel:g?.confirm,cancelLabel:g?.cancel,hideConfirm:g?.hideConfirm,hideCancel:g?.hideCancel}))]})})),q=({modalId:o,onChangeOrder:r})=>{const{ForegroundComponent:i}=Fe(),{modal:a,onChange:l,onConfirm:s,onClose:c,onDestroy:d}=Ce(o),u=t((()=>a?.ForegroundComponent||i),[i,a]);return a?e("div",{className:x(L,{[A]:a.manualDestroy?a.alive:a.visible,[$]:a.visible}),children:n(u,{id:a.id,type:a.type,alive:a.alive,visible:a.visible,initiator:a.initiator,manualDestroy:a.manualDestroy,closeOnBackdropClick:a.closeOnBackdropClick,background:a.background,onChange:l,onConfirm:s,onClose:c,onDestroy:d,onChangeOrder:r,children:["alert"===a.type&&e(W,{modal:a,handlers:{onConfirm:s}}),"confirm"===a.type&&e(Y,{modal:a,handlers:{onConfirm:s,onClose:c}}),"prompt"===a.type&&e(U,{modal:a,handlers:{onChange:l,onConfirm:s,onClose:c}})]})}):null},H=e=>{const[n,o]=C();return g((()=>{if(e)return e.subscribe(o)})),n},G=B("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)."}});let J=1;const K=r((({modalId:o})=>{const t=l(null),{modal:r}=Ce(o);H(r);const i=f((()=>{t.current&&(t.current.style.zIndex=""+J++)}));return n("div",{ref:t,className:G,children:[e(_,{modalId:o,onChangeOrder:i}),e(q,{modalId:o,onChangeOrder:i})]})})),Q=(e=0)=>{const{modalIds:n,getModalNode:o}=he();return t((()=>{let e=0;for(const t of n)o(t)?.visible&&e++;return e}),[o,n,e])},R=({subtype:e,title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})=>new Promise(((d,u)=>{try{E.open({type:"alert",subtype:e,resolve:()=>d(),title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})}catch(e){u(e)}})),X=({subtype:e,title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})=>new Promise(((d,u)=>{try{E.open({type:"confirm",subtype:e,resolve:e=>d(e??!1),title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})}catch(e){u(e)}})),Z=({defaultValue:e,title:n,subtitle:o,content:t,Input:r,disabled:i,returnOnCancel:a,background:l,footer:s,manualDestroy:c,closeOnBackdropClick:d,ForegroundComponent:u,BackgroundComponent:p})=>new Promise(((m,f)=>{try{E.open({type:"prompt",resolve:e=>m(e),title:n,subtitle:o,content:t,Input:({defaultValue:e,onChange:n,onConfirm:o,onCancel:t})=>r({defaultValue:e,onChange:n,onConfirm:o,onCancel:t}),defaultValue:e,disabled:i,returnOnCancel:a,background:l,footer:s,manualDestroy:c,closeOnBackdropClick:d,ForegroundComponent:u,BackgroundComponent:p})}catch(e){f(e)}}));
|
|
2
2
|
/******************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/app/ModalManager.ts","../src/app/constant.ts","../src/components/Background/classNames.emotion.ts","../src/components/Background/Background.tsx","../src/components/Foreground/classNames.emotion.ts","../src/components/Foreground/components/AlertInner.tsx","../src/components/Foreground/components/ConfirmInner.tsx","../src/components/Foreground/components/PromptInner.tsx","../src/components/Foreground/Foreground.tsx","../src/hooks/useSubscribeModal.ts","../src/components/Presenter/classNames.emotion.ts","../src/components/Presenter/Presenter.tsx","../src/hooks/useActiveModalCount.ts","../src/core/handle/alert.ts","../src/core/handle/confirm.ts","../src/core/handle/prompt.ts","../src/core/node/ModalNode/AbstractBaseNode.ts","../src/core/node/ModalNode/AlertNode.ts","../src/core/node/ModalNode/ConfirmNode.ts","../src/core/node/ModalNode/PromptNode.ts","../src/core/node/nodeFactory.ts","../src/helpers/getMillisecondsFromDuration.ts","../src/providers/ModalDataContext/ModalDataContext.ts","../src/providers/ModalDataContext/ModalDataContextProvider.tsx","../src/providers/ModalDataContext/useModalDataContext.ts","../src/components/Anchor/classNames.emotion.ts","../src/components/Anchor/Anchor.tsx","../src/components/FallbackComponents/classNames.emotion.ts","../src/components/FallbackComponents/FallbackTitle.tsx","../src/components/FallbackComponents/FallbackSubtitle.tsx","../src/components/FallbackComponents/FallbackContent.tsx","../src/components/FallbackComponents/FallbackFooter.tsx","../src/components/FallbackComponents/FallbackForegroundFrame.tsx","../src/hooks/useDefaultPathname.ts","../src/providers/ModalContext/ModalContext.ts","../src/providers/ModalContext/ModalContextProvider.tsx","../src/providers/ModalContext/useModalContext.ts","../src/hooks/useDestroyAfter.ts"],"sourcesContent":["import { MutableRefObject } from 'react';\n\nimport { getRandomString } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { Modal } from '@/promise-modal/types';\n\nconst prerenderListRef: MutableRefObject<Modal[]> = {\n current: [],\n};\n\nconst openModalRef: MutableRefObject<Fn<[Modal], void>> = {\n current: (modal: Modal) => {\n prerenderListRef.current.push(modal);\n },\n};\n\nconst anchorRef: MutableRefObject<HTMLElement | null> = {\n current: null,\n};\n\nexport const ModalManager = {\n get prerender() {\n return prerenderListRef.current;\n },\n clearPrerender() {\n prerenderListRef.current = [];\n },\n open(modal: Modal) {\n openModalRef.current(modal);\n },\n setupOpen(open: (modal: Modal) => void) {\n openModalRef.current = open;\n },\n anchor(name: string, prefix = 'promise-modal'): HTMLElement {\n if (anchorRef.current) {\n const anchor = document.getElementById(anchorRef.current.id);\n if (anchor) return anchor;\n }\n const node = document.createElement(name);\n node.setAttribute('id', `${prefix}-${getRandomString(36)}`);\n document.body.appendChild(node);\n anchorRef.current = node;\n return node;\n },\n};\n","import type { Color, Duration } from '@aileron/types';\n\nexport const DEFAULT_ANIMATION_DURATION: Duration = '300ms';\n\nexport const DEFAULT_BACKDROP_COLOR: Color = 'rgba(0, 0, 0, 0.5)';\n","import { css } from '@emotion/css';\n\nexport const background = css`\n display: none;\n position: fixed;\n inset: 0;\n z-index: -999;\n pointer-events: none;\n > * {\n pointer-events: none;\n }\n`;\n\nexport const active = css`\n pointer-events: all;\n`;\n\nexport const visible = css`\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n","import { type MouseEvent, useCallback, useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, background, visible } from './classNames.emotion';\n\nexport const Background = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { BackgroundComponent } = useModalContext();\n const { modal, onClose, onChange, onConfirm, onDestroy } = useModal(modalId);\n\n const handleClose = useCallback(\n (event: MouseEvent) => {\n if (modal && modal.closeOnBackdropClick && modal.visible) onClose();\n event.stopPropagation();\n },\n [modal, onClose],\n );\n\n const Background = useMemo(\n () => modal?.BackgroundComponent || BackgroundComponent,\n [BackgroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(background, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.closeOnBackdropClick && modal.visible,\n })}\n onClick={handleClose}\n >\n {Background && (\n <Background\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n />\n )}\n </div>\n );\n};\n","import { css } from '@emotion/css';\n\nexport const foreground = css`\n pointer-events: none;\n display: none;\n position: fixed;\n inset: 0;\n z-index: 1;\n`;\n\nexport const active = css`\n > * {\n pointer-events: all;\n }\n`;\n\nexport const visible = css`\n display: flex !important;\n justify-content: center;\n align-items: center;\n`;\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { AlertNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface AlertInnerProps<B> {\n modal: AlertNode<B>;\n handlers: Pick<ModalActions, 'onConfirm'>;\n}\n\nexport const AlertInner = memo(\n <B,>({ modal, handlers }: AlertInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { onConfirm } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({ onConfirm: handleConfirm })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n confirmLabel={footer?.confirm}\n hideConfirm={footer?.hideConfirm}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { ConfirmNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface ConfirmInnerProps<B> {\n modal: ConfirmNode<B>;\n handlers: Pick<ModalActions, 'onConfirm' | 'onClose'>;\n}\n\nexport const ConfirmInner = memo(\n <B,>({ modal, handlers }: ConfirmInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { onConfirm, onClose } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n const handleClose = useHandle(onClose);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useCallback, useMemo, useState } from 'react';\n\nimport { isFunction, isString } from '@winglet/common-utils';\nimport {\n renderComponent,\n useHandle,\n withErrorBoundary,\n} from '@winglet/react-utils';\n\nimport type { PromptNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface PromptInnerProps<T, B> {\n modal: PromptNode<T, B>;\n handlers: Pick<ModalActions, 'onChange' | 'onClose' | 'onConfirm'>;\n}\n\nexport const PromptInner = memo(\n <T, B>({ modal, handlers }: PromptInnerProps<T, B>) => {\n const {\n Input,\n defaultValue,\n disabled: checkDisabled,\n title,\n subtitle,\n content,\n footer,\n } = useMemo(\n () => ({\n ...modal,\n Input: memo(withErrorBoundary(modal.Input)),\n }),\n [modal],\n );\n\n const [value, setValue] = useState<T | undefined>(defaultValue);\n\n const { onChange, onClose, onConfirm } = useMemo(\n () => handlers,\n [handlers],\n );\n\n const handleClose = useHandle(onClose);\n const handleChange = useHandle(\n (inputValue?: T | ((prevState: T | undefined) => T | undefined)) => {\n const input = isFunction(inputValue) ? inputValue(value) : inputValue;\n setValue(input);\n onChange(input);\n },\n );\n\n const handleConfirm = useCallback(() => {\n // NOTE: wait for the next tick to ensure the value is updated\n setTimeout(() => {\n onConfirm();\n });\n }, [onConfirm]);\n\n const disabled = useMemo(\n () => (value ? !!checkDisabled?.(value) : false),\n [checkDisabled, value],\n );\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n\n {Input && (\n <Input\n defaultValue={defaultValue}\n value={value}\n onChange={handleChange}\n onConfirm={handleConfirm}\n />\n )}\n\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n onChange: handleChange,\n value,\n disabled,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n disabled={disabled}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, foreground, visible } from './classNames.emotion';\nimport { AlertInner, ConfirmInner, PromptInner } from './components';\n\nexport const Foreground = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { ForegroundComponent } = useModalContext();\n\n const { modal, onChange, onConfirm, onClose, onDestroy } = useModal(modalId);\n\n const Foreground = useMemo(\n () => modal?.ForegroundComponent || ForegroundComponent,\n [ForegroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(foreground, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.visible,\n })}\n >\n <Foreground\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n >\n {modal.type === 'alert' && (\n <AlertInner modal={modal} handlers={{ onConfirm }} />\n )}\n {modal.type === 'confirm' && (\n <ConfirmInner modal={modal} handlers={{ onConfirm, onClose }} />\n )}\n {modal.type === 'prompt' && (\n <PromptInner\n modal={modal}\n handlers={{ onChange, onConfirm, onClose }}\n />\n )}\n </Foreground>\n </div>\n );\n};\n","import { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { ModalNode } from '@/promise-modal/core';\n\nexport const useSubscribeModal = (modal?: ModalNode) => {\n const [tick, update] = useTick();\n useOnMount(() => {\n if (!modal) return;\n const unsubscribe = modal.subscribe(update);\n return unsubscribe;\n });\n return tick;\n};\n","import { css } from '@emotion/css';\n\nexport const presenter = css`\n position: fixed;\n inset: 0;\n pointer-events: none;\n overflow: hidden;\n`;\n","import { memo, useRef } from 'react';\n\nimport { useHandle } from '@winglet/react-utils';\n\nimport { Background } from '@/promise-modal/components/Background';\nimport { Foreground } from '@/promise-modal/components/Foreground';\nimport { useSubscribeModal } from '@/promise-modal/hooks/useSubscribeModal';\nimport { useModal } from '@/promise-modal/providers';\nimport type { ModalIdProps } from '@/promise-modal/types';\n\nimport { presenter } from './classNames.emotion';\n\nlet zIndex = 1;\n\nexport const Presenter = memo(({ modalId }: ModalIdProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { modal } = useModal(modalId);\n useSubscribeModal(modal);\n const handleChangeOrder = useHandle(() => {\n if (ref.current) {\n ref.current.style.zIndex = `${zIndex++}`;\n }\n });\n return (\n <div ref={ref} className={presenter}>\n <Background modalId={modalId} onChangeOrder={handleChangeOrder} />\n <Foreground modalId={modalId} onChangeOrder={handleChangeOrder} />\n </div>\n );\n});\n","import { useMemo } from 'react';\n\nimport { useModalDataContext } from '../providers';\n\nexport const useActiveModalCount = (tick: string | number = 0) => {\n const { modalIds, getModalNode } = useModalDataContext();\n return useMemo(() => {\n let count = 0;\n for (const id of modalIds) {\n if (getModalNode(id)?.visible) count++;\n }\n return count;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getModalNode, modalIds, tick]);\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n AlertContentProps,\n AlertFooterRender,\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface AlertProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<AlertContentProps>;\n background?: ModalBackground<B>;\n footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const alert = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: AlertProps<B>) => {\n return new Promise<void>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'alert',\n subtype,\n resolve: () => resolve(),\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n BackgroundComponent,\n ConfirmContentProps,\n ConfirmFooterRender,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface ConfirmProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<ConfirmContentProps>;\n background?: ModalBackground<B>;\n footer?: ConfirmFooterRender | FooterOptions | false;\n closeOnBackdropClick?: boolean;\n manualDestroy?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const confirm = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: ConfirmProps<B>) => {\n return new Promise<boolean>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'confirm',\n subtype,\n resolve: (result) => resolve(result ?? false),\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n} from '@/promise-modal/types';\n\nimport { ModalManager } from '../../app/ModalManager';\n\ninterface PromptProps<T, B = any> {\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<PromptContentProps>;\n Input: (props: PromptInputProps<T>) => ReactNode;\n defaultValue?: T;\n disabled?: (value: T) => boolean;\n returnOnCancel?: boolean;\n background?: ModalBackground<B>;\n footer?: PromptFooterRender<T> | FooterOptions | false;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const prompt = <T, B = any>({\n defaultValue,\n title,\n subtitle,\n content,\n Input,\n disabled,\n returnOnCancel,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: PromptProps<T, B>) => {\n return new Promise<T>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'prompt',\n resolve: (result) => resolve(result as T),\n title,\n subtitle,\n content,\n Input: ({ defaultValue, onChange, onConfirm }: PromptInputProps<T>) =>\n Input({\n defaultValue,\n onChange,\n onConfirm,\n }),\n defaultValue,\n disabled,\n returnOnCancel,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ReactNode } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type {\n BackgroundComponent,\n BaseModal,\n ForegroundComponent,\n ManagedEntity,\n ModalBackground,\n} from '@/promise-modal/types';\n\ntype BaseNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;\n\nexport abstract class BaseNode<T, B> {\n readonly id: number;\n readonly initiator: string;\n\n readonly title?: ReactNode;\n readonly subtitle?: ReactNode;\n readonly background?: ModalBackground<B>;\n\n readonly manualDestroy: boolean;\n readonly closeOnBackdropClick: boolean;\n\n readonly ForegroundComponent?: ForegroundComponent;\n readonly BackgroundComponent?: BackgroundComponent;\n\n #alive: boolean;\n get alive() {\n return this.#alive;\n }\n #visible: boolean;\n get visible() {\n return this.#visible;\n }\n\n #resolve: (result: T | null) => void;\n #listeners: Fn[] = [];\n\n constructor({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy = false,\n closeOnBackdropClick = true,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: BaseNodeProps<T, B>) {\n this.id = id;\n this.initiator = initiator;\n this.title = title;\n this.subtitle = subtitle;\n this.background = background;\n this.manualDestroy = manualDestroy;\n this.closeOnBackdropClick = closeOnBackdropClick;\n\n this.ForegroundComponent = ForegroundComponent;\n this.BackgroundComponent = BackgroundComponent;\n\n this.#alive = true;\n this.#visible = true;\n this.#resolve = resolve;\n }\n\n subscribe(listener: Fn) {\n this.#listeners.push(listener);\n return () => {\n this.#listeners = this.#listeners.filter((l) => l !== listener);\n };\n }\n publish() {\n for (const listener of this.#listeners) listener();\n }\n protected resolve(result: T | null) {\n this.#resolve(result);\n }\n onDestroy() {\n const needPublish = this.#alive === true;\n this.#alive = false;\n if (this.manualDestroy && needPublish) this.publish();\n }\n onShow() {\n const needPublish = this.#visible === false;\n this.#visible = true;\n if (needPublish) this.publish();\n }\n onHide() {\n const needPublish = this.#visible === true;\n this.#visible = false;\n if (needPublish) this.publish();\n }\n abstract onClose(): void;\n abstract onConfirm(): void;\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n AlertContentProps,\n AlertFooterRender,\n AlertModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype AlertNodeProps<B> = AlertModal<B> & ManagedEntity;\n\nexport class AlertNode<B> extends BaseNode<null, B> {\n readonly type: 'alert';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<AlertContentProps>;\n readonly footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AlertNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(null);\n }\n onConfirm() {\n this.resolve(null);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n ConfirmContentProps,\n ConfirmFooterRender,\n ConfirmModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype ConfirmNodeProps<B> = ConfirmModal<B> & ManagedEntity;\n\nexport class ConfirmNode<B> extends BaseNode<boolean, B> {\n readonly type: 'confirm';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<ConfirmContentProps>;\n readonly footer?: ConfirmFooterRender | FooterOptions | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: ConfirmNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(false);\n }\n onConfirm() {\n this.resolve(true);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n FooterOptions,\n ManagedEntity,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n PromptModal,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype PromptNodeProps<T, B> = PromptModal<T, B> & ManagedEntity;\n\nexport class PromptNode<T, B> extends BaseNode<T, B> {\n readonly type: 'prompt';\n readonly content?: ReactNode | ComponentType<PromptContentProps>;\n readonly defaultValue: T | undefined;\n readonly Input: (props: PromptInputProps<T>) => ReactNode;\n readonly disabled?: (value: T) => boolean;\n readonly returnOnCancel?: boolean;\n readonly footer?: PromptFooterRender<T> | FooterOptions | false;\n #value: T | undefined;\n\n constructor({\n id,\n initiator,\n type,\n title,\n subtitle,\n content,\n defaultValue,\n Input,\n disabled,\n returnOnCancel,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: PromptNodeProps<T, B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.content = content;\n this.Input = Input;\n this.defaultValue = defaultValue;\n this.#value = defaultValue;\n this.disabled = disabled;\n this.returnOnCancel = returnOnCancel;\n this.footer = footer;\n }\n\n onChange(value: T) {\n this.#value = value;\n }\n onConfirm() {\n this.resolve(this.#value ?? null);\n }\n onClose() {\n if (this.returnOnCancel) this.resolve(this.#value ?? null);\n else this.resolve(null);\n }\n}\n","import type { ManagedModal } from '@/promise-modal/types';\n\nimport { AlertNode, ConfirmNode, PromptNode } from './ModalNode';\n\nexport const nodeFactory = <T, B>(modal: ManagedModal<T, B>) => {\n switch (modal.type) {\n case 'alert':\n return new AlertNode<B>(modal);\n case 'confirm':\n return new ConfirmNode<B>(modal);\n case 'prompt':\n return new PromptNode<T, B>(modal);\n }\n // @ts-expect-error: This state is unreachable by design and should NEVER occur.\n throw new Error(`Unknown modal: ${modal.type}`, { modal });\n};\n","const DURATION_REGEX = /^\\s*(\\d+)\\s*(ms|s|m|h)\\s*$/;\n\nexport const getMillisecondsFromDuration = (input: string) => {\n const [, durationString, unit] = input.match(DURATION_REGEX) || [];\n if (!durationString || !unit) return 0;\n const duration = parseInt(durationString);\n if (unit === 'ms') return duration;\n if (unit === 's') return duration * 1000;\n if (unit === 'm') return duration * 60 * 1000;\n if (unit === 'h') return duration * 60 * 60 * 1000;\n else return 0;\n};\n","import { createContext } from 'react';\n\nimport { undefinedFunction } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport type { ModalActions, ModalHandlersWithId } from '@/promise-modal/types';\n\nexport interface ModalDataContextProps extends ModalHandlersWithId {\n modalIds: ModalNode['id'][];\n getModal: Fn<[id: ModalNode['id']], ModalActions>;\n getModalNode: Fn<[id: ModalNode['id']], ModalNode | undefined>;\n setUpdater: Fn<[updater: Fn]>;\n}\n\nexport const ModalDataContext = createContext<ModalDataContextProps>({\n modalIds: [],\n getModalNode: undefinedFunction,\n onChange: undefinedFunction,\n onConfirm: undefinedFunction,\n onClose: undefinedFunction,\n onDestroy: undefinedFunction,\n setUpdater: undefinedFunction,\n getModal: () => ({\n modal: undefined,\n onConfirm: undefinedFunction,\n onClose: undefinedFunction,\n onChange: undefinedFunction,\n onDestroy: undefinedFunction,\n }),\n});\n","import {\n type PropsWithChildren,\n memo,\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useOnMountLayout, useReference } from '@winglet/react-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport { type ModalNode, nodeFactory } from '@/promise-modal/core';\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\nimport { useModalOptions } from '@/promise-modal/providers';\nimport type { Modal } from '@/promise-modal/types';\n\nimport { ModalDataContext } from './ModalDataContext';\n\ninterface ModalDataContextProviderProps {\n pathname: string;\n}\n\nexport const ModalDataContextProvider = memo(\n ({\n pathname,\n children,\n }: PropsWithChildren<ModalDataContextProviderProps>) => {\n const modalDictionary = useRef<Map<ModalNode['id'], ModalNode>>(new Map());\n\n const [modalIds, setModalIds] = useState<ModalNode['id'][]>([]);\n const modalIdsRef = useReference(modalIds);\n\n const initiator = useRef(pathname);\n const modalIdSequence = useRef(0);\n\n const options = useModalOptions();\n\n const duration = useMemo(\n () => getMillisecondsFromDuration(options.duration),\n [options],\n );\n\n useOnMountLayout(() => {\n const { manualDestroy, closeOnBackdropClick } = options;\n\n for (const data of ModalManager.prerender) {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => [...ids, modal.id]);\n }\n\n ModalManager.setupOpen((data: Modal) => {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => {\n const aliveIds = ids.filter((id) => {\n const destroyed = !modalDictionary.current.get(id)?.alive;\n if (destroyed) modalDictionary.current.delete(id);\n return !destroyed;\n });\n return [...aliveIds, modal.id];\n });\n });\n ModalManager.clearPrerender();\n });\n\n useLayoutEffect(() => {\n for (const id of modalIdsRef.current) {\n const modal = modalDictionary.current.get(id);\n if (!modal?.alive) continue;\n if (modal.initiator === pathname) modal.onShow();\n else modal.onHide();\n }\n initiator.current = pathname;\n }, [modalIdsRef, pathname]);\n\n const getModalNode = useCallback((modalId: ModalNode['id']) => {\n return modalDictionary.current.get(modalId);\n }, []);\n\n const onDestroy = useCallback((modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onDestroy();\n updaterRef.current?.();\n }, []);\n\n const updaterRef = useRef<Fn>();\n const hideModal = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onHide();\n updaterRef.current?.();\n if (!modal.manualDestroy)\n setTimeout(() => {\n modal.onDestroy();\n }, duration);\n },\n [duration],\n );\n\n const onChange = useCallback((modalId: ModalNode['id'], value: any) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n if (modal.type === 'prompt') modal.onChange(value);\n }, []);\n\n const onConfirm = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onConfirm();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const onClose = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onClose();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const getModal = useCallback(\n (modalId: ModalNode['id']) => ({\n modal: getModalNode(modalId),\n onConfirm: () => onConfirm(modalId),\n onClose: () => onClose(modalId),\n onChange: (value: any) => onChange(modalId, value),\n onDestroy: () => onDestroy(modalId),\n }),\n [getModalNode, onConfirm, onClose, onChange, onDestroy],\n );\n\n const value = useMemo(() => {\n return {\n modalIds,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n getModal,\n setUpdater: (updater: Fn) => {\n updaterRef.current = updater;\n },\n };\n }, [\n modalIds,\n getModal,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n ]);\n\n return (\n <ModalDataContext.Provider value={value}>\n {children}\n </ModalDataContext.Provider>\n );\n },\n);\n","import { useContext, useMemo } from 'react';\n\nimport type { ManagedModal } from '@/promise-modal/types';\n\nimport { ModalDataContext } from './ModalDataContext';\n\nexport const useModalDataContext = () => useContext(ModalDataContext);\n\nexport const useModal = (id: ManagedModal['id']) => {\n const { getModal } = useModalDataContext();\n return useMemo(() => getModal(id), [id, getModal]);\n};\n","import { css } from '@emotion/css';\n\nexport const anchor = css`\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: 1000;\n transition: background-color ease-in-out;\n`;\n","import { memo, useEffect } from 'react';\n\nimport { useTick, withErrorBoundary } from '@winglet/react-utils';\n\nimport { Presenter } from '@/promise-modal/components/Presenter';\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport { useModalContext } from '@/promise-modal/providers';\nimport { useModalDataContext } from '@/promise-modal/providers/ModalDataContext';\n\nimport { anchor } from './classNames.emotion';\n\nconst AnchorInner = () => {\n const [key, update] = useTick();\n\n const { modalIds, setUpdater } = useModalDataContext();\n\n useEffect(() => {\n setUpdater(update);\n }, [setUpdater, update]);\n\n const { options } = useModalContext();\n\n const dimmed = useActiveModalCount(key);\n\n return (\n <div\n className={anchor}\n style={{\n transitionDuration: options.duration,\n backgroundColor: dimmed ? options.backdrop : 'transparent',\n }}\n >\n {modalIds.map((id) => {\n return <Presenter key={id} modalId={id} />;\n })}\n </div>\n );\n};\n\nexport const Anchor = memo(withErrorBoundary(AnchorInner));\n","import { css } from '@emotion/css';\n\nexport const fallback = css`\n margin: unset;\n`;\n\nexport const frame = css`\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n background-color: white;\n padding: 20px 80px;\n gap: 10px;\n border: 1px solid black;\n`;\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackTitle = ({ children }: PropsWithChildren) => {\n return <h2 className={fallback}>{children}</h2>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackSubtitle = ({ children }: PropsWithChildren) => {\n return <h3 className={fallback}>{children}</h3>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackContent = ({ children }: PropsWithChildren) => {\n return <div className={fallback}>{children}</div>;\n};\n","import type { FooterComponentProps } from '@/promise-modal/types';\n\nexport const FallbackFooter = ({\n confirmLabel,\n hideConfirm = false,\n cancelLabel,\n hideCancel = false,\n disabled,\n onConfirm,\n onCancel,\n}: FooterComponentProps) => {\n return (\n <div>\n {!hideConfirm && (\n <button onClick={onConfirm} disabled={disabled}>\n {confirmLabel || '확인'}\n </button>\n )}\n\n {!hideCancel && typeof onCancel === 'function' && (\n <button onClick={onCancel}>{cancelLabel || '취소'}</button>\n )}\n </div>\n );\n};\n","import {\n type ForwardedRef,\n type PropsWithChildren,\n forwardRef,\n useMemo,\n} from 'react';\n\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport type { ModalFrameProps } from '@/promise-modal/types';\n\nimport { frame } from './classNames.emotion';\n\nconst MAX_MODAL_COUNT = 5;\nconst MAX_MODAL_LEVEL = 3;\n\nexport const FallbackForegroundFrame = forwardRef(\n (\n { id, onChangeOrder, children }: PropsWithChildren<ModalFrameProps>,\n ref: ForwardedRef<HTMLDivElement>,\n ) => {\n const activeCount = useActiveModalCount();\n const [level, offset] = useMemo(() => {\n const stacked = activeCount > 1;\n const level = stacked\n ? (Math.floor(id / MAX_MODAL_COUNT) % MAX_MODAL_LEVEL) * 100\n : 0;\n const offset = stacked ? (id % MAX_MODAL_COUNT) * 35 : 0;\n return [level, offset];\n }, [activeCount, id]);\n\n return (\n <div\n ref={ref}\n className={frame}\n onClick={onChangeOrder}\n style={{\n marginBottom: `calc(25vh + ${level}px)`,\n marginLeft: `${level}px`,\n transform: `translate(${offset}px, ${offset}px)`,\n }}\n >\n {children}\n </div>\n );\n },\n);\n","import { useLayoutEffect, useState } from 'react';\n\nexport const usePathname = () => {\n const [pathname, setPathname] = useState(window.location.pathname);\n\n useLayoutEffect(() => {\n let requestId: number;\n\n const checkPathname = () => {\n if (requestId) cancelAnimationFrame(requestId);\n if (pathname !== window.location.pathname) {\n setPathname(window.location.pathname);\n } else {\n requestId = requestAnimationFrame(checkPathname);\n }\n };\n\n requestId = requestAnimationFrame(checkPathname);\n\n return () => {\n if (requestId) cancelAnimationFrame(requestId);\n };\n }, [pathname]);\n\n return { pathname };\n};\n","import {\n type ComponentType,\n type PropsWithChildren,\n createContext,\n} from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport type {\n BackgroundComponent,\n FooterComponentProps,\n ForegroundComponent,\n} from '@/promise-modal/types';\n\nexport interface ModalContextProps {\n ForegroundComponent: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n TitleComponent: ComponentType<PropsWithChildren>;\n SubtitleComponent: ComponentType<PropsWithChildren>;\n ContentComponent: ComponentType<PropsWithChildren>;\n FooterComponent: ComponentType<FooterComponentProps>;\n options: {\n duration: Duration;\n backdrop: Color;\n manualDestroy: boolean;\n closeOnBackdropClick: boolean;\n };\n}\n\nexport const ModalContext = createContext<ModalContextProps>({\n ForegroundComponent: FallbackForegroundFrame,\n TitleComponent: FallbackTitle,\n SubtitleComponent: FallbackSubtitle,\n ContentComponent: FallbackContent,\n FooterComponent: FallbackFooter,\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n manualDestroy: false,\n closeOnBackdropClick: true,\n },\n});\n","import {\n type ComponentType,\n type PropsWithChildren,\n memo,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport { Anchor } from '@/promise-modal/components/Anchor';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport { usePathname as useDefaultPathname } from '@/promise-modal/hooks/useDefaultPathname';\nimport type {\n FooterComponentProps,\n ModalFrameProps,\n} from '@/promise-modal/types';\n\nimport { ModalDataContextProvider } from '../ModalDataContext';\nimport { ModalContext } from './ModalContext';\n\ninterface ModalContextProviderProps {\n BackgroundComponent?: ComponentType<ModalFrameProps>;\n ForegroundComponent?: ComponentType<ModalFrameProps>;\n TitleComponent?: ComponentType<PropsWithChildren>;\n SubtitleComponent?: ComponentType<PropsWithChildren>;\n ContentComponent?: ComponentType<PropsWithChildren>;\n FooterComponent?: ComponentType<FooterComponentProps>;\n options?: {\n /** Modal transition time(ms, s) */\n duration?: Duration;\n /** Modal backdrop color */\n backdrop?: Color;\n /** Whether to destroy the modal manually */\n manualDestroy?: boolean;\n /** Whether to close the modal when the backdrop is clicked */\n closeOnBackdropClick?: boolean;\n };\n usePathname?: () => { pathname: string };\n}\n\nexport const ModalContextProvider = memo(\n ({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n options,\n usePathname,\n children,\n }: PropsWithChildren<ModalContextProviderProps>) => {\n const { pathname } = (usePathname || useDefaultPathname)();\n const [, update] = useTick();\n const portalRef = useRef<HTMLElement | null>(null);\n\n useOnMount(() => {\n portalRef.current = ModalManager.anchor('div');\n update();\n return () => {\n if (portalRef.current) {\n portalRef.current.remove();\n }\n };\n });\n\n const value = useMemo(\n () => ({\n BackgroundComponent,\n ForegroundComponent: ForegroundComponent || FallbackForegroundFrame,\n TitleComponent: TitleComponent || FallbackTitle,\n SubtitleComponent: SubtitleComponent || FallbackSubtitle,\n ContentComponent: memo(ContentComponent || FallbackContent),\n FooterComponent: memo(FooterComponent || FallbackFooter),\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n closeOnBackdropClick: true,\n manualDestroy: false,\n ...options,\n } satisfies ModalContextProviderProps['options'],\n }),\n [\n ForegroundComponent,\n BackgroundComponent,\n ContentComponent,\n FooterComponent,\n SubtitleComponent,\n TitleComponent,\n options,\n ],\n );\n\n return (\n <ModalContext.Provider value={value}>\n {children}\n {portalRef.current &&\n createPortal(\n <ModalDataContextProvider pathname={pathname}>\n <Anchor />\n </ModalDataContextProvider>,\n portalRef.current,\n )}\n </ModalContext.Provider>\n );\n },\n);\n","import { useContext } from 'react';\n\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\n\nimport { ModalContext } from './ModalContext';\n\nexport const useModalContext = () => useContext(ModalContext);\n\nexport const useModalOptions = () => {\n const { options } = useContext(ModalContext);\n return options;\n};\n\nexport const useModalDuration = () => {\n const { duration } = useModalOptions();\n return { duration, milliseconds: getMillisecondsFromDuration(duration) };\n};\n\nexport const useModalBackdrop = () => {\n const { backdrop } = useModalOptions();\n return backdrop;\n};\n","import { useEffect, useRef } from 'react';\n\nimport { isString } from '@winglet/common-utils';\n\nimport type { Duration } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\n\nimport { useModal } from '../providers';\nimport { useSubscribeModal } from './useSubscribeModal';\n\nexport const useDestroyAfter = (\n modalId: ModalNode['id'],\n duration: Duration | number,\n) => {\n const { modal, onDestroy } = useModal(modalId);\n const tick = useSubscribeModal(modal);\n\n const reference = useRef({\n modal,\n onDestroy,\n milliseconds: isString(duration)\n ? getMillisecondsFromDuration(duration)\n : duration,\n });\n\n useEffect(() => {\n const { modal, onDestroy, milliseconds } = reference.current;\n if (!modal || modal.visible || !modal.alive) return;\n const timer = setTimeout(() => {\n onDestroy();\n }, milliseconds);\n return () => {\n if (timer) clearTimeout(timer);\n };\n }, [tick]);\n};\n"],"names":["prerenderListRef","current","openModalRef","modal","push","anchorRef","ModalManager","prerender","clearPrerender","open","setupOpen","anchor","name","prefix","document","getElementById","id","node","createElement","setAttribute","getRandomString","body","appendChild","DEFAULT_ANIMATION_DURATION","DEFAULT_BACKDROP_COLOR","background","css","process","env","NODE_ENV","styles","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","active","visible","Background","modalId","onChangeOrder","BackgroundComponent","useModalContext","onClose","onChange","onConfirm","onDestroy","useModal","handleClose","useCallback","event","closeOnBackdropClick","stopPropagation","useMemo","_jsx","className","cx","visible$1","manualDestroy","alive","active$1","onClick","children","type","initiator","foreground","AlertInner","memo","handlers","title","subtitle","content","footer","handleConfirm","useHandle","TitleComponent","SubtitleComponent","ContentComponent","FooterComponent","_jsxs","Fragment","isString","renderComponent","confirmLabel","confirm","hideConfirm","ConfirmInner","onCancel","cancelLabel","cancel","hideCancel","PromptInner","Input","defaultValue","disabled","checkDisabled","withErrorBoundary","value","setValue","useState","handleChange","inputValue","input","isFunction","setTimeout","Foreground","ForegroundComponent","useSubscribeModal","tick","update","useTick","useOnMount","subscribe","presenter","zIndex","Presenter","ref","useRef","handleChangeOrder","style","useActiveModalCount","modalIds","getModalNode","useModalDataContext","count","alert","subtype","Promise","resolve","reject","error","result","prompt","returnOnCancel","BaseNode","__classPrivateFieldGet","this","_BaseNode_alive","_BaseNode_visible","constructor","Object","defineProperty","set","_BaseNode_resolve","_BaseNode_listeners","__classPrivateFieldSet","listener","filter","l","publish","call","needPublish","onShow","onHide","AlertNode","super","ConfirmNode","PromptNode","_PromptNode_value","nodeFactory","Error","DURATION_REGEX","getMillisecondsFromDuration","durationString","unit","match","duration","parseInt","ModalDataContext","createContext","undefinedFunction","setUpdater","getModal","undefined","ModalDataContextProvider","pathname","modalDictionary","Map","setModalIds","modalIdsRef","useReference","modalIdSequence","options","useModalOptions","useOnMountLayout","data","ids","destroyed","get","delete","useLayoutEffect","updaterRef","hideModal","updater","Provider","useContext","Anchor","key","useEffect","dimmed","transitionDuration","backgroundColor","backdrop","map","fallback","frame","FallbackTitle","FallbackSubtitle","FallbackContent","FallbackFooter","FallbackForegroundFrame","forwardRef","activeCount","level","offset","stacked","Math","floor","marginBottom","marginLeft","transform","usePathname","setPathname","window","location","requestId","checkPathname","cancelAnimationFrame","requestAnimationFrame","ModalContext","ModalContextProvider","useDefaultPathname","portalRef","remove","createPortal","useModalDuration","milliseconds","useModalBackdrop","useDestroyAfter","reference","timer","clearTimeout"],"mappings":"+kBAQA,MAAMA,EAA8C,CAClDC,QAAS,IAGLC,EAAoD,CACxDD,QAAUE,IACRH,EAAiBC,QAAQG,KAAKD,EAAM,GAIlCE,EAAkD,CACtDJ,QAAS,MAGEK,EAAe,CAC1B,aAAIC,GACF,OAAOP,EAAiBC,OACzB,EACD,cAAAO,GACER,EAAiBC,QAAU,EAC5B,EACD,IAAAQ,CAAKN,GACHD,EAAaD,QAAQE,EACtB,EACD,SAAAO,CAAUD,GACRP,EAAaD,QAAUQ,CACxB,EACD,MAAAE,CAAOC,EAAcC,EAAS,iBA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B,KAC9B,MAAMnC,SAAEA,GAAanB,KACrB,OAAOmB,CAAQ,ECRJoC,GAAkB,CAC7BvM,EACA+H,KAEA,MAAMhK,MAAEA,EAAKwC,UAAEA,GAAcC,GAASR,GAChCqE,EAAOD,EAAkBrG,GAEzByO,EAAY1H,EAAO,CACvB/G,QACAwC,YACA8L,aAAc3J,EAASqF,GACnBJ,GAA4BI,GAC5BA,IAGNgC,GAAU,KACR,MAAMhM,MAAEA,EAAKwC,UAAEA,EAAS8L,aAAEA,GAAiBG,EAAU3O,QACrD,IAAKE,GAASA,EAAM+B,UAAY/B,EAAMqD,MAAO,OAC7C,MAAMqL,EAAQxI,YAAW,KACvB1D,GAAW,GACV8L,GACH,MAAO,KACDI,GAAOC,aAAaD,EAAM,CAC/B,GACA,CAACpI,GAAM"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/app/ModalManager.ts","../src/app/constant.ts","../src/components/Background/classNames.emotion.ts","../src/components/Background/Background.tsx","../src/components/Foreground/classNames.emotion.ts","../src/components/Foreground/components/AlertInner.tsx","../src/components/Foreground/components/ConfirmInner.tsx","../src/components/Foreground/components/PromptInner.tsx","../src/components/Foreground/Foreground.tsx","../src/hooks/useSubscribeModal.ts","../src/components/Presenter/classNames.emotion.ts","../src/components/Presenter/Presenter.tsx","../src/hooks/useActiveModalCount.ts","../src/core/handle/alert.ts","../src/core/handle/confirm.ts","../src/core/handle/prompt.ts","../src/core/node/ModalNode/AbstractBaseNode.ts","../src/core/node/ModalNode/AlertNode.ts","../src/core/node/ModalNode/ConfirmNode.ts","../src/core/node/ModalNode/PromptNode.ts","../src/core/node/nodeFactory.ts","../src/helpers/getMillisecondsFromDuration.ts","../src/providers/ModalDataContext/ModalDataContext.ts","../src/providers/ModalDataContext/ModalDataContextProvider.tsx","../src/providers/ModalDataContext/useModalDataContext.ts","../src/components/Anchor/classNames.emotion.ts","../src/components/Anchor/Anchor.tsx","../src/components/FallbackComponents/classNames.emotion.ts","../src/components/FallbackComponents/FallbackTitle.tsx","../src/components/FallbackComponents/FallbackSubtitle.tsx","../src/components/FallbackComponents/FallbackContent.tsx","../src/components/FallbackComponents/FallbackFooter.tsx","../src/components/FallbackComponents/FallbackForegroundFrame.tsx","../src/hooks/useDefaultPathname.ts","../src/providers/ModalContext/ModalContext.ts","../src/providers/ModalContext/ModalContextProvider.tsx","../src/providers/ModalContext/useModalContext.ts","../src/hooks/useDestroyAfter.ts"],"sourcesContent":["import { MutableRefObject } from 'react';\n\nimport { getRandomString } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { Modal } from '@/promise-modal/types';\n\nconst prerenderListRef: MutableRefObject<Modal[]> = {\n current: [],\n};\n\nconst openModalRef: MutableRefObject<Fn<[Modal], void>> = {\n current: (modal: Modal) => {\n prerenderListRef.current.push(modal);\n },\n};\n\nconst anchorRef: MutableRefObject<HTMLElement | null> = {\n current: null,\n};\n\nexport const ModalManager = {\n get prerender() {\n return prerenderListRef.current;\n },\n clearPrerender() {\n prerenderListRef.current = [];\n },\n open(modal: Modal) {\n openModalRef.current(modal);\n },\n setupOpen(open: (modal: Modal) => void) {\n openModalRef.current = open;\n },\n anchor(name: string, prefix = 'promise-modal'): HTMLElement {\n if (anchorRef.current) {\n const anchor = document.getElementById(anchorRef.current.id);\n if (anchor) return anchor;\n }\n const node = document.createElement(name);\n node.setAttribute('id', `${prefix}-${getRandomString(36)}`);\n document.body.appendChild(node);\n anchorRef.current = node;\n return node;\n },\n};\n","import type { Color, Duration } from '@aileron/types';\n\nexport const DEFAULT_ANIMATION_DURATION: Duration = '300ms';\n\nexport const DEFAULT_BACKDROP_COLOR: Color = 'rgba(0, 0, 0, 0.5)';\n","import { css } from '@emotion/css';\n\nexport const background = css`\n display: none;\n position: fixed;\n inset: 0;\n z-index: -999;\n pointer-events: none;\n > * {\n pointer-events: none;\n }\n`;\n\nexport const active = css`\n pointer-events: all;\n`;\n\nexport const visible = css`\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n","import { type MouseEvent, useCallback, useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, background, visible } from './classNames.emotion';\n\nexport const Background = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { BackgroundComponent } = useModalContext();\n const { modal, onClose, onChange, onConfirm, onDestroy } = useModal(modalId);\n\n const handleClose = useCallback(\n (event: MouseEvent) => {\n if (modal && modal.closeOnBackdropClick && modal.visible) onClose();\n event.stopPropagation();\n },\n [modal, onClose],\n );\n\n const Background = useMemo(\n () => modal?.BackgroundComponent || BackgroundComponent,\n [BackgroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(background, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.closeOnBackdropClick && modal.visible,\n })}\n onClick={handleClose}\n >\n {Background && (\n <Background\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n />\n )}\n </div>\n );\n};\n","import { css } from '@emotion/css';\n\nexport const foreground = css`\n pointer-events: none;\n display: none;\n position: fixed;\n inset: 0;\n z-index: 1;\n`;\n\nexport const active = css`\n > * {\n pointer-events: all;\n }\n`;\n\nexport const visible = css`\n display: flex !important;\n justify-content: center;\n align-items: center;\n`;\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { AlertNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface AlertInnerProps<B> {\n modal: AlertNode<B>;\n handlers: Pick<ModalActions, 'onConfirm'>;\n}\n\nexport const AlertInner = memo(\n <B,>({ modal, handlers }: AlertInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { onConfirm } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({ onConfirm: handleConfirm })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n confirmLabel={footer?.confirm}\n hideConfirm={footer?.hideConfirm}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { ConfirmNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface ConfirmInnerProps<B> {\n modal: ConfirmNode<B>;\n handlers: Pick<ModalActions, 'onConfirm' | 'onClose'>;\n}\n\nexport const ConfirmInner = memo(\n <B,>({ modal, handlers }: ConfirmInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { onConfirm, onClose } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n const handleClose = useHandle(onClose);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useCallback, useMemo, useState } from 'react';\n\nimport { isFunction, isString } from '@winglet/common-utils';\nimport {\n renderComponent,\n useHandle,\n withErrorBoundary,\n} from '@winglet/react-utils';\n\nimport type { PromptNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface PromptInnerProps<T, B> {\n modal: PromptNode<T, B>;\n handlers: Pick<ModalActions, 'onChange' | 'onClose' | 'onConfirm'>;\n}\n\nexport const PromptInner = memo(\n <T, B>({ modal, handlers }: PromptInnerProps<T, B>) => {\n const {\n Input,\n defaultValue,\n disabled: checkDisabled,\n title,\n subtitle,\n content,\n footer,\n } = useMemo(\n () => ({\n ...modal,\n Input: memo(withErrorBoundary(modal.Input)),\n }),\n [modal],\n );\n\n const [value, setValue] = useState<T | undefined>(defaultValue);\n\n const { onChange, onClose, onConfirm } = useMemo(\n () => handlers,\n [handlers],\n );\n\n const handleClose = useHandle(onClose);\n const handleChange = useHandle(\n (inputValue?: T | ((prevState: T | undefined) => T | undefined)) => {\n const input = isFunction(inputValue) ? inputValue(value) : inputValue;\n setValue(input);\n onChange(input);\n },\n );\n\n const handleConfirm = useCallback(() => {\n // NOTE: wait for the next tick to ensure the value is updated\n setTimeout(() => {\n onConfirm();\n });\n }, [onConfirm]);\n\n const disabled = useMemo(\n () => (value ? !!checkDisabled?.(value) : false),\n [checkDisabled, value],\n );\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n\n {Input && (\n <Input\n defaultValue={defaultValue}\n value={value}\n onChange={handleChange}\n onConfirm={handleConfirm}\n onCancel={handleClose}\n />\n )}\n\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onChange: handleChange,\n onConfirm: handleConfirm,\n onCancel: handleClose,\n value,\n disabled,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n disabled={disabled}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, foreground, visible } from './classNames.emotion';\nimport { AlertInner, ConfirmInner, PromptInner } from './components';\n\nexport const Foreground = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { ForegroundComponent } = useModalContext();\n\n const { modal, onChange, onConfirm, onClose, onDestroy } = useModal(modalId);\n\n const Foreground = useMemo(\n () => modal?.ForegroundComponent || ForegroundComponent,\n [ForegroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(foreground, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.visible,\n })}\n >\n <Foreground\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n >\n {modal.type === 'alert' && (\n <AlertInner modal={modal} handlers={{ onConfirm }} />\n )}\n {modal.type === 'confirm' && (\n <ConfirmInner modal={modal} handlers={{ onConfirm, onClose }} />\n )}\n {modal.type === 'prompt' && (\n <PromptInner\n modal={modal}\n handlers={{ onChange, onConfirm, onClose }}\n />\n )}\n </Foreground>\n </div>\n );\n};\n","import { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { ModalNode } from '@/promise-modal/core';\n\nexport const useSubscribeModal = (modal?: ModalNode) => {\n const [tick, update] = useTick();\n useOnMount(() => {\n if (!modal) return;\n const unsubscribe = modal.subscribe(update);\n return unsubscribe;\n });\n return tick;\n};\n","import { css } from '@emotion/css';\n\nexport const presenter = css`\n position: fixed;\n inset: 0;\n pointer-events: none;\n overflow: hidden;\n`;\n","import { memo, useRef } from 'react';\n\nimport { useHandle } from '@winglet/react-utils';\n\nimport { Background } from '@/promise-modal/components/Background';\nimport { Foreground } from '@/promise-modal/components/Foreground';\nimport { useSubscribeModal } from '@/promise-modal/hooks/useSubscribeModal';\nimport { useModal } from '@/promise-modal/providers';\nimport type { ModalIdProps } from '@/promise-modal/types';\n\nimport { presenter } from './classNames.emotion';\n\nlet zIndex = 1;\n\nexport const Presenter = memo(({ modalId }: ModalIdProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { modal } = useModal(modalId);\n useSubscribeModal(modal);\n const handleChangeOrder = useHandle(() => {\n if (ref.current) {\n ref.current.style.zIndex = `${zIndex++}`;\n }\n });\n return (\n <div ref={ref} className={presenter}>\n <Background modalId={modalId} onChangeOrder={handleChangeOrder} />\n <Foreground modalId={modalId} onChangeOrder={handleChangeOrder} />\n </div>\n );\n});\n","import { useMemo } from 'react';\n\nimport { useModalDataContext } from '../providers';\n\nexport const useActiveModalCount = (tick: string | number = 0) => {\n const { modalIds, getModalNode } = useModalDataContext();\n return useMemo(() => {\n let count = 0;\n for (const id of modalIds) {\n if (getModalNode(id)?.visible) count++;\n }\n return count;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getModalNode, modalIds, tick]);\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n AlertContentProps,\n AlertFooterRender,\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface AlertProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<AlertContentProps>;\n background?: ModalBackground<B>;\n footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const alert = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: AlertProps<B>) => {\n return new Promise<void>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'alert',\n subtype,\n resolve: () => resolve(),\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n BackgroundComponent,\n ConfirmContentProps,\n ConfirmFooterRender,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface ConfirmProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<ConfirmContentProps>;\n background?: ModalBackground<B>;\n footer?: ConfirmFooterRender | FooterOptions | false;\n closeOnBackdropClick?: boolean;\n manualDestroy?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const confirm = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: ConfirmProps<B>) => {\n return new Promise<boolean>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'confirm',\n subtype,\n resolve: (result) => resolve(result ?? false),\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n} from '@/promise-modal/types';\n\nimport { ModalManager } from '../../app/ModalManager';\n\ninterface PromptProps<T, B = any> {\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<PromptContentProps>;\n Input: (props: PromptInputProps<T>) => ReactNode;\n defaultValue?: T;\n disabled?: (value: T) => boolean;\n returnOnCancel?: boolean;\n background?: ModalBackground<B>;\n footer?: PromptFooterRender<T> | FooterOptions | false;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const prompt = <T, B = any>({\n defaultValue,\n title,\n subtitle,\n content,\n Input,\n disabled,\n returnOnCancel,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: PromptProps<T, B>) => {\n return new Promise<T>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'prompt',\n resolve: (result) => resolve(result as T),\n title,\n subtitle,\n content,\n Input: ({\n defaultValue,\n onChange,\n onConfirm,\n onCancel,\n }: PromptInputProps<T>) =>\n Input({\n defaultValue,\n onChange,\n onConfirm,\n onCancel,\n }),\n defaultValue,\n disabled,\n returnOnCancel,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ReactNode } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type {\n BackgroundComponent,\n BaseModal,\n ForegroundComponent,\n ManagedEntity,\n ModalBackground,\n} from '@/promise-modal/types';\n\ntype BaseNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;\n\nexport abstract class BaseNode<T, B> {\n readonly id: number;\n readonly initiator: string;\n\n readonly title?: ReactNode;\n readonly subtitle?: ReactNode;\n readonly background?: ModalBackground<B>;\n\n readonly manualDestroy: boolean;\n readonly closeOnBackdropClick: boolean;\n\n readonly ForegroundComponent?: ForegroundComponent;\n readonly BackgroundComponent?: BackgroundComponent;\n\n #alive: boolean;\n get alive() {\n return this.#alive;\n }\n #visible: boolean;\n get visible() {\n return this.#visible;\n }\n\n #resolve: (result: T | null) => void;\n #listeners: Fn[] = [];\n\n constructor({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy = false,\n closeOnBackdropClick = true,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: BaseNodeProps<T, B>) {\n this.id = id;\n this.initiator = initiator;\n this.title = title;\n this.subtitle = subtitle;\n this.background = background;\n this.manualDestroy = manualDestroy;\n this.closeOnBackdropClick = closeOnBackdropClick;\n\n this.ForegroundComponent = ForegroundComponent;\n this.BackgroundComponent = BackgroundComponent;\n\n this.#alive = true;\n this.#visible = true;\n this.#resolve = resolve;\n }\n\n subscribe(listener: Fn) {\n this.#listeners.push(listener);\n return () => {\n this.#listeners = this.#listeners.filter((l) => l !== listener);\n };\n }\n publish() {\n for (const listener of this.#listeners) listener();\n }\n protected resolve(result: T | null) {\n this.#resolve(result);\n }\n onDestroy() {\n const needPublish = this.#alive === true;\n this.#alive = false;\n if (this.manualDestroy && needPublish) this.publish();\n }\n onShow() {\n const needPublish = this.#visible === false;\n this.#visible = true;\n if (needPublish) this.publish();\n }\n onHide() {\n const needPublish = this.#visible === true;\n this.#visible = false;\n if (needPublish) this.publish();\n }\n abstract onClose(): void;\n abstract onConfirm(): void;\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n AlertContentProps,\n AlertFooterRender,\n AlertModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype AlertNodeProps<B> = AlertModal<B> & ManagedEntity;\n\nexport class AlertNode<B> extends BaseNode<null, B> {\n readonly type: 'alert';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<AlertContentProps>;\n readonly footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AlertNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(null);\n }\n onConfirm() {\n this.resolve(null);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n ConfirmContentProps,\n ConfirmFooterRender,\n ConfirmModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype ConfirmNodeProps<B> = ConfirmModal<B> & ManagedEntity;\n\nexport class ConfirmNode<B> extends BaseNode<boolean, B> {\n readonly type: 'confirm';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<ConfirmContentProps>;\n readonly footer?: ConfirmFooterRender | FooterOptions | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: ConfirmNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(false);\n }\n onConfirm() {\n this.resolve(true);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n FooterOptions,\n ManagedEntity,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n PromptModal,\n} from '@/promise-modal/types';\n\nimport { BaseNode } from './AbstractBaseNode';\n\ntype PromptNodeProps<T, B> = PromptModal<T, B> & ManagedEntity;\n\nexport class PromptNode<T, B> extends BaseNode<T, B> {\n readonly type: 'prompt';\n readonly content?: ReactNode | ComponentType<PromptContentProps>;\n readonly defaultValue: T | undefined;\n readonly Input: (props: PromptInputProps<T>) => ReactNode;\n readonly disabled?: (value: T) => boolean;\n readonly returnOnCancel?: boolean;\n readonly footer?: PromptFooterRender<T> | FooterOptions | false;\n #value: T | undefined;\n\n constructor({\n id,\n initiator,\n type,\n title,\n subtitle,\n content,\n defaultValue,\n Input,\n disabled,\n returnOnCancel,\n footer,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: PromptNodeProps<T, B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.content = content;\n this.Input = Input;\n this.defaultValue = defaultValue;\n this.#value = defaultValue;\n this.disabled = disabled;\n this.returnOnCancel = returnOnCancel;\n this.footer = footer;\n }\n\n onChange(value: T) {\n this.#value = value;\n }\n onConfirm() {\n this.resolve(this.#value ?? null);\n }\n onClose() {\n if (this.returnOnCancel) this.resolve(this.#value ?? null);\n else this.resolve(null);\n }\n}\n","import type { ManagedModal } from '@/promise-modal/types';\n\nimport { AlertNode, ConfirmNode, PromptNode } from './ModalNode';\n\nexport const nodeFactory = <T, B>(modal: ManagedModal<T, B>) => {\n switch (modal.type) {\n case 'alert':\n return new AlertNode<B>(modal);\n case 'confirm':\n return new ConfirmNode<B>(modal);\n case 'prompt':\n return new PromptNode<T, B>(modal);\n }\n // @ts-expect-error: This state is unreachable by design and should NEVER occur.\n throw new Error(`Unknown modal: ${modal.type}`, { modal });\n};\n","const DURATION_REGEX = /^\\s*(\\d+)\\s*(ms|s|m|h)\\s*$/;\n\nexport const getMillisecondsFromDuration = (input: string) => {\n const [, durationString, unit] = input.match(DURATION_REGEX) || [];\n if (!durationString || !unit) return 0;\n const duration = parseInt(durationString);\n if (unit === 'ms') return duration;\n if (unit === 's') return duration * 1000;\n if (unit === 'm') return duration * 60 * 1000;\n if (unit === 'h') return duration * 60 * 60 * 1000;\n else return 0;\n};\n","import { createContext } from 'react';\n\nimport { undefinedFunction } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport type { ModalActions, ModalHandlersWithId } from '@/promise-modal/types';\n\nexport interface ModalDataContextProps extends ModalHandlersWithId {\n modalIds: ModalNode['id'][];\n getModal: Fn<[id: ModalNode['id']], ModalActions>;\n getModalNode: Fn<[id: ModalNode['id']], ModalNode | undefined>;\n setUpdater: Fn<[updater: Fn]>;\n}\n\nexport const ModalDataContext = createContext<ModalDataContextProps>({\n modalIds: [],\n getModalNode: undefinedFunction,\n onChange: undefinedFunction,\n onConfirm: undefinedFunction,\n onClose: undefinedFunction,\n onDestroy: undefinedFunction,\n setUpdater: undefinedFunction,\n getModal: () => ({\n modal: undefined,\n onConfirm: undefinedFunction,\n onClose: undefinedFunction,\n onChange: undefinedFunction,\n onDestroy: undefinedFunction,\n }),\n});\n","import {\n type PropsWithChildren,\n memo,\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useOnMountLayout, useReference } from '@winglet/react-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport { type ModalNode, nodeFactory } from '@/promise-modal/core';\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\nimport { useModalOptions } from '@/promise-modal/providers';\nimport type { Modal } from '@/promise-modal/types';\n\nimport { ModalDataContext } from './ModalDataContext';\n\ninterface ModalDataContextProviderProps {\n pathname: string;\n}\n\nexport const ModalDataContextProvider = memo(\n ({\n pathname,\n children,\n }: PropsWithChildren<ModalDataContextProviderProps>) => {\n const modalDictionary = useRef<Map<ModalNode['id'], ModalNode>>(new Map());\n\n const [modalIds, setModalIds] = useState<ModalNode['id'][]>([]);\n const modalIdsRef = useReference(modalIds);\n\n const initiator = useRef(pathname);\n const modalIdSequence = useRef(0);\n\n const options = useModalOptions();\n\n const duration = useMemo(\n () => getMillisecondsFromDuration(options.duration),\n [options],\n );\n\n useOnMountLayout(() => {\n const { manualDestroy, closeOnBackdropClick } = options;\n\n for (const data of ModalManager.prerender) {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => [...ids, modal.id]);\n }\n\n ModalManager.setupOpen((data: Modal) => {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => {\n const aliveIds = ids.filter((id) => {\n const destroyed = !modalDictionary.current.get(id)?.alive;\n if (destroyed) modalDictionary.current.delete(id);\n return !destroyed;\n });\n return [...aliveIds, modal.id];\n });\n });\n ModalManager.clearPrerender();\n });\n\n useLayoutEffect(() => {\n for (const id of modalIdsRef.current) {\n const modal = modalDictionary.current.get(id);\n if (!modal?.alive) continue;\n if (modal.initiator === pathname) modal.onShow();\n else modal.onHide();\n }\n initiator.current = pathname;\n }, [modalIdsRef, pathname]);\n\n const getModalNode = useCallback((modalId: ModalNode['id']) => {\n return modalDictionary.current.get(modalId);\n }, []);\n\n const onDestroy = useCallback((modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onDestroy();\n updaterRef.current?.();\n }, []);\n\n const updaterRef = useRef<Fn>();\n const hideModal = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onHide();\n updaterRef.current?.();\n if (!modal.manualDestroy)\n setTimeout(() => {\n modal.onDestroy();\n }, duration);\n },\n [duration],\n );\n\n const onChange = useCallback((modalId: ModalNode['id'], value: any) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n if (modal.type === 'prompt') modal.onChange(value);\n }, []);\n\n const onConfirm = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onConfirm();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const onClose = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onClose();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const getModal = useCallback(\n (modalId: ModalNode['id']) => ({\n modal: getModalNode(modalId),\n onConfirm: () => onConfirm(modalId),\n onClose: () => onClose(modalId),\n onChange: (value: any) => onChange(modalId, value),\n onDestroy: () => onDestroy(modalId),\n }),\n [getModalNode, onConfirm, onClose, onChange, onDestroy],\n );\n\n const value = useMemo(() => {\n return {\n modalIds,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n getModal,\n setUpdater: (updater: Fn) => {\n updaterRef.current = updater;\n },\n };\n }, [\n modalIds,\n getModal,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n ]);\n\n return (\n <ModalDataContext.Provider value={value}>\n {children}\n </ModalDataContext.Provider>\n );\n },\n);\n","import { useContext, useMemo } from 'react';\n\nimport type { ManagedModal } from '@/promise-modal/types';\n\nimport { ModalDataContext } from './ModalDataContext';\n\nexport const useModalDataContext = () => useContext(ModalDataContext);\n\nexport const useModal = (id: ManagedModal['id']) => {\n const { getModal } = useModalDataContext();\n return useMemo(() => getModal(id), [id, getModal]);\n};\n","import { css } from '@emotion/css';\n\nexport const anchor = css`\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: 1000;\n transition: background-color ease-in-out;\n`;\n","import { memo, useEffect } from 'react';\n\nimport { useTick, withErrorBoundary } from '@winglet/react-utils';\n\nimport { Presenter } from '@/promise-modal/components/Presenter';\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport { useModalContext } from '@/promise-modal/providers';\nimport { useModalDataContext } from '@/promise-modal/providers/ModalDataContext';\n\nimport { anchor } from './classNames.emotion';\n\nconst AnchorInner = () => {\n const [key, update] = useTick();\n\n const { modalIds, setUpdater } = useModalDataContext();\n\n useEffect(() => {\n setUpdater(update);\n }, [setUpdater, update]);\n\n const { options } = useModalContext();\n\n const dimmed = useActiveModalCount(key);\n\n return (\n <div\n className={anchor}\n style={{\n transitionDuration: options.duration,\n backgroundColor: dimmed ? options.backdrop : 'transparent',\n }}\n >\n {modalIds.map((id) => {\n return <Presenter key={id} modalId={id} />;\n })}\n </div>\n );\n};\n\nexport const Anchor = memo(withErrorBoundary(AnchorInner));\n","import { css } from '@emotion/css';\n\nexport const fallback = css`\n margin: unset;\n`;\n\nexport const frame = css`\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n background-color: white;\n padding: 20px 80px;\n gap: 10px;\n border: 1px solid black;\n`;\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackTitle = ({ children }: PropsWithChildren) => {\n return <h2 className={fallback}>{children}</h2>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackSubtitle = ({ children }: PropsWithChildren) => {\n return <h3 className={fallback}>{children}</h3>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackContent = ({ children }: PropsWithChildren) => {\n return <div className={fallback}>{children}</div>;\n};\n","import type { FooterComponentProps } from '@/promise-modal/types';\n\nexport const FallbackFooter = ({\n confirmLabel,\n hideConfirm = false,\n cancelLabel,\n hideCancel = false,\n disabled,\n onConfirm,\n onCancel,\n}: FooterComponentProps) => {\n return (\n <div>\n {!hideConfirm && (\n <button onClick={onConfirm} disabled={disabled}>\n {confirmLabel || '확인'}\n </button>\n )}\n\n {!hideCancel && typeof onCancel === 'function' && (\n <button onClick={onCancel}>{cancelLabel || '취소'}</button>\n )}\n </div>\n );\n};\n","import {\n type ForwardedRef,\n type PropsWithChildren,\n forwardRef,\n useMemo,\n} from 'react';\n\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport type { ModalFrameProps } from '@/promise-modal/types';\n\nimport { frame } from './classNames.emotion';\n\nconst MAX_MODAL_COUNT = 5;\nconst MAX_MODAL_LEVEL = 3;\n\nexport const FallbackForegroundFrame = forwardRef(\n (\n { id, onChangeOrder, children }: PropsWithChildren<ModalFrameProps>,\n ref: ForwardedRef<HTMLDivElement>,\n ) => {\n const activeCount = useActiveModalCount();\n const [level, offset] = useMemo(() => {\n const stacked = activeCount > 1;\n const level = stacked\n ? (Math.floor(id / MAX_MODAL_COUNT) % MAX_MODAL_LEVEL) * 100\n : 0;\n const offset = stacked ? (id % MAX_MODAL_COUNT) * 35 : 0;\n return [level, offset];\n }, [activeCount, id]);\n\n return (\n <div\n ref={ref}\n className={frame}\n onClick={onChangeOrder}\n style={{\n marginBottom: `calc(25vh + ${level}px)`,\n marginLeft: `${level}px`,\n transform: `translate(${offset}px, ${offset}px)`,\n }}\n >\n {children}\n </div>\n );\n },\n);\n","import { useLayoutEffect, useState } from 'react';\n\nexport const usePathname = () => {\n const [pathname, setPathname] = useState(window.location.pathname);\n\n useLayoutEffect(() => {\n let requestId: number;\n\n const checkPathname = () => {\n if (requestId) cancelAnimationFrame(requestId);\n if (pathname !== window.location.pathname) {\n setPathname(window.location.pathname);\n } else {\n requestId = requestAnimationFrame(checkPathname);\n }\n };\n\n requestId = requestAnimationFrame(checkPathname);\n\n return () => {\n if (requestId) cancelAnimationFrame(requestId);\n };\n }, [pathname]);\n\n return { pathname };\n};\n","import {\n type ComponentType,\n type PropsWithChildren,\n createContext,\n} from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport type {\n BackgroundComponent,\n FooterComponentProps,\n ForegroundComponent,\n} from '@/promise-modal/types';\n\nexport interface ModalContextProps {\n ForegroundComponent: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n TitleComponent: ComponentType<PropsWithChildren>;\n SubtitleComponent: ComponentType<PropsWithChildren>;\n ContentComponent: ComponentType<PropsWithChildren>;\n FooterComponent: ComponentType<FooterComponentProps>;\n options: {\n duration: Duration;\n backdrop: Color;\n manualDestroy: boolean;\n closeOnBackdropClick: boolean;\n };\n}\n\nexport const ModalContext = createContext<ModalContextProps>({\n ForegroundComponent: FallbackForegroundFrame,\n TitleComponent: FallbackTitle,\n SubtitleComponent: FallbackSubtitle,\n ContentComponent: FallbackContent,\n FooterComponent: FallbackFooter,\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n manualDestroy: false,\n closeOnBackdropClick: true,\n },\n});\n","import {\n type ComponentType,\n type PropsWithChildren,\n memo,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport { Anchor } from '@/promise-modal/components/Anchor';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport { usePathname as useDefaultPathname } from '@/promise-modal/hooks/useDefaultPathname';\nimport type {\n FooterComponentProps,\n ModalFrameProps,\n} from '@/promise-modal/types';\n\nimport { ModalDataContextProvider } from '../ModalDataContext';\nimport { ModalContext } from './ModalContext';\n\ninterface ModalContextProviderProps {\n BackgroundComponent?: ComponentType<ModalFrameProps>;\n ForegroundComponent?: ComponentType<ModalFrameProps>;\n TitleComponent?: ComponentType<PropsWithChildren>;\n SubtitleComponent?: ComponentType<PropsWithChildren>;\n ContentComponent?: ComponentType<PropsWithChildren>;\n FooterComponent?: ComponentType<FooterComponentProps>;\n options?: {\n /** Modal transition time(ms, s) */\n duration?: Duration;\n /** Modal backdrop color */\n backdrop?: Color;\n /** Whether to destroy the modal manually */\n manualDestroy?: boolean;\n /** Whether to close the modal when the backdrop is clicked */\n closeOnBackdropClick?: boolean;\n };\n usePathname?: () => { pathname: string };\n}\n\nexport const ModalContextProvider = memo(\n ({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n options,\n usePathname,\n children,\n }: PropsWithChildren<ModalContextProviderProps>) => {\n const { pathname } = (usePathname || useDefaultPathname)();\n const [, update] = useTick();\n const portalRef = useRef<HTMLElement | null>(null);\n\n useOnMount(() => {\n portalRef.current = ModalManager.anchor('div');\n update();\n return () => {\n if (portalRef.current) {\n portalRef.current.remove();\n }\n };\n });\n\n const value = useMemo(\n () => ({\n BackgroundComponent,\n ForegroundComponent: ForegroundComponent || FallbackForegroundFrame,\n TitleComponent: TitleComponent || FallbackTitle,\n SubtitleComponent: SubtitleComponent || FallbackSubtitle,\n ContentComponent: memo(ContentComponent || FallbackContent),\n FooterComponent: memo(FooterComponent || FallbackFooter),\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n closeOnBackdropClick: true,\n manualDestroy: false,\n ...options,\n } satisfies ModalContextProviderProps['options'],\n }),\n [\n ForegroundComponent,\n BackgroundComponent,\n ContentComponent,\n FooterComponent,\n SubtitleComponent,\n TitleComponent,\n options,\n ],\n );\n\n return (\n <ModalContext.Provider value={value}>\n {children}\n {portalRef.current &&\n createPortal(\n <ModalDataContextProvider pathname={pathname}>\n <Anchor />\n </ModalDataContextProvider>,\n portalRef.current,\n )}\n </ModalContext.Provider>\n );\n },\n);\n","import { useContext } from 'react';\n\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\n\nimport { ModalContext } from './ModalContext';\n\nexport const useModalContext = () => useContext(ModalContext);\n\nexport const useModalOptions = () => {\n const { options } = useContext(ModalContext);\n return options;\n};\n\nexport const useModalDuration = () => {\n const { duration } = useModalOptions();\n return { duration, milliseconds: getMillisecondsFromDuration(duration) };\n};\n\nexport const useModalBackdrop = () => {\n const { backdrop } = useModalOptions();\n return backdrop;\n};\n","import { useEffect, useRef } from 'react';\n\nimport { isString } from '@winglet/common-utils';\n\nimport type { Duration } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\n\nimport { useModal } from '../providers';\nimport { useSubscribeModal } from './useSubscribeModal';\n\nexport const useDestroyAfter = (\n modalId: ModalNode['id'],\n duration: Duration | number,\n) => {\n const { modal, onDestroy } = useModal(modalId);\n const tick = useSubscribeModal(modal);\n\n const reference = useRef({\n modal,\n onDestroy,\n milliseconds: isString(duration)\n ? getMillisecondsFromDuration(duration)\n : duration,\n });\n\n useEffect(() => {\n const { modal, onDestroy, milliseconds } = reference.current;\n if (!modal || modal.visible || !modal.alive) return;\n const timer = setTimeout(() => {\n onDestroy();\n }, milliseconds);\n return () => {\n if (timer) clearTimeout(timer);\n };\n }, [tick]);\n};\n"],"names":["prerenderListRef","current","openModalRef","modal","push","anchorRef","ModalManager","prerender","clearPrerender","open","setupOpen","anchor","name","prefix","document","getElementById","id","node","createElement","setAttribute","getRandomString","body","appendChild","DEFAULT_ANIMATION_DURATION","DEFAULT_BACKDROP_COLOR","background","css","process","env","NODE_ENV","styles","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","active","visible","Background","modalId","onChangeOrder","BackgroundComponent","useModalContext","onClose","onChange","onConfirm","onDestroy","useModal","handleClose","useCallback","event","closeOnBackdropClick","stopPropagation","useMemo","_jsx","className","cx","visible$1","manualDestroy","alive","active$1","onClick","children","type","initiator","foreground","AlertInner","memo","handlers","title","subtitle","content","footer","handleConfirm","useHandle","TitleComponent","SubtitleComponent","ContentComponent","FooterComponent","_jsxs","Fragment","isString","renderComponent","confirmLabel","confirm","hideConfirm","ConfirmInner","onCancel","cancelLabel","cancel","hideCancel","PromptInner","Input","defaultValue","disabled","checkDisabled","withErrorBoundary","value","setValue","useState","handleChange","inputValue","input","isFunction","setTimeout","Foreground","ForegroundComponent","useSubscribeModal","tick","update","useTick","useOnMount","subscribe","presenter","zIndex","Presenter","ref","useRef","handleChangeOrder","style","useActiveModalCount","modalIds","getModalNode","useModalDataContext","count","alert","subtype","Promise","resolve","reject","error","result","prompt","returnOnCancel","BaseNode","__classPrivateFieldGet","this","_BaseNode_alive","_BaseNode_visible","constructor","Object","defineProperty","set","_BaseNode_resolve","_BaseNode_listeners","__classPrivateFieldSet","listener","filter","l","publish","call","needPublish","onShow","onHide","AlertNode","super","ConfirmNode","PromptNode","_PromptNode_value","nodeFactory","Error","DURATION_REGEX","getMillisecondsFromDuration","durationString","unit","match","duration","parseInt","ModalDataContext","createContext","undefinedFunction","setUpdater","getModal","undefined","ModalDataContextProvider","pathname","modalDictionary","Map","setModalIds","modalIdsRef","useReference","modalIdSequence","options","useModalOptions","useOnMountLayout","data","ids","destroyed","get","delete","useLayoutEffect","updaterRef","hideModal","updater","Provider","useContext","Anchor","key","useEffect","dimmed","transitionDuration","backgroundColor","backdrop","map","fallback","frame","FallbackTitle","FallbackSubtitle","FallbackContent","FallbackFooter","FallbackForegroundFrame","forwardRef","activeCount","level","offset","stacked","Math","floor","marginBottom","marginLeft","transform","usePathname","setPathname","window","location","requestId","checkPathname","cancelAnimationFrame","requestAnimationFrame","ModalContext","ModalContextProvider","useDefaultPathname","portalRef","remove","createPortal","useModalDuration","milliseconds","useModalBackdrop","useDestroyAfter","reference","timer","clearTimeout"],"mappings":"+kBAQA,MAAMA,EAA8C,CAClDC,QAAS,IAGLC,EAAoD,CACxDD,QAAUE,IACRH,EAAiBC,QAAQG,KAAKD,EAAM,GAIlCE,EAAkD,CACtDJ,QAAS,MAGEK,EAAe,CAC1B,aAAIC,GACF,OAAOP,EAAiBC,OACzB,EACD,cAAAO,GACER,EAAiBC,QAAU,EAC5B,EACD,IAAAQ,CAAKN,GACHD,EAAaD,QAAQE,EACtB,EACD,SAAAO,CAAUD,GACRP,EAAaD,QAAUQ,CACxB,EACD,MAAAE,CAAOC,EAAcC,EAAS,iBAC5B,GAA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,EAG7DuE,GAAmB,KAC9B,MAAMnC,SAAEA,GAAanB,KACrB,OAAOmB,CAAQ,ECRJoC,GAAkB,CAC7BvM,EACA+H,KAEA,MAAMhK,MAAEA,EAAKwC,UAAEA,GAAcC,GAASR,GAChCqE,EAAOD,EAAkBrG,GAEzByO,EAAY1H,EAAO,CACvB/G,QACAwC,YACA8L,aAAc3J,EAASqF,GACnBJ,GAA4BI,GAC5BA,IAGNgC,GAAU,KACR,MAAMhM,MAAEA,EAAKwC,UAAEA,EAAS8L,aAAEA,GAAiBG,EAAU3O,QACrD,IAAKE,GAASA,EAAM+B,UAAY/B,EAAMqD,MAAO,OAC7C,MAAMqL,EAAQxI,YAAW,KACvB1D,GAAW,GACV8L,GACH,MAAO,KACDI,GAAOC,aAAaD,EAAM,CAC/B,GACA,CAACpI,GAAM"}
|
package/dist/types/prompt.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface PromptInputProps<T> {
|
|
|
13
13
|
defaultValue?: T;
|
|
14
14
|
onChange: SetStateFn<T | undefined>;
|
|
15
15
|
onConfirm?: VoidFunction;
|
|
16
|
+
onCancel?: VoidFunction;
|
|
16
17
|
}
|
|
17
18
|
export type PromptContentProps = ContentComponentProps;
|
|
18
19
|
export interface PromptModal<T = any, B = any> extends BaseModal<T, B> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/types/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE9E,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE;IAC1C,SAAS,EAAE,YAAY,CAAC;IACxB,QAAQ,EAAE,YAAY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BAAqB,CAAC;AAEvD,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,CAAE,SAAQ,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IACpE,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACxD,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,KAAK,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,KAAK,OAAO,CAAC;IAC7C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,KAAK,CAAC;CACxD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lerx/promise-modal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/vincent-kk/albatrion.git",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@emotion/css": "^11.0.0",
|
|
43
|
-
"@winglet/common-utils": "^0.0.
|
|
44
|
-
"@winglet/react-utils": "^0.0.
|
|
43
|
+
"@winglet/common-utils": "^0.0.17",
|
|
44
|
+
"@winglet/react-utils": "^0.0.17"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@babel/core": "^7.26.0",
|