@lerx/promise-modal 0.0.17 → 0.0.19
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/@aileron/types/function.d.ts +1 -1
- package/dist/components/Background/Background.d.ts +1 -1
- package/dist/components/Background/Background.d.ts.map +1 -1
- package/dist/components/Background/index.d.ts +1 -1
- package/dist/components/Background/index.d.ts.map +1 -1
- package/dist/components/Foreground/Foreground.d.ts +1 -1
- package/dist/components/Foreground/Foreground.d.ts.map +1 -1
- package/dist/components/Foreground/components/AlertInner.d.ts.map +1 -1
- package/dist/components/Foreground/components/ConfirmInner.d.ts.map +1 -1
- package/dist/components/Foreground/components/PromptInner.d.ts.map +1 -1
- package/dist/components/Foreground/index.d.ts +1 -1
- package/dist/components/Foreground/index.d.ts.map +1 -1
- package/dist/components/Presenter/Presenter.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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/providers/ModalContext/ModalContext.d.ts +5 -5
- package/dist/providers/ModalContext/ModalContext.d.ts.map +1 -1
- package/dist/providers/ModalContext/ModalContextProvider.d.ts +7 -6
- package/dist/providers/ModalContext/ModalContextProvider.d.ts.map +1 -1
- package/dist/providers/UserDefinedContext/UserDefinedContext.d.ts +6 -0
- package/dist/providers/UserDefinedContext/UserDefinedContext.d.ts.map +1 -0
- package/dist/providers/UserDefinedContext/UserDefinedContextProvider.d.ts +8 -0
- package/dist/providers/UserDefinedContext/UserDefinedContextProvider.d.ts.map +1 -0
- package/dist/providers/UserDefinedContext/index.d.ts +3 -0
- package/dist/providers/UserDefinedContext/index.d.ts.map +1 -0
- package/dist/providers/UserDefinedContext/useUserDefinedContext.d.ts +3 -0
- package/dist/providers/UserDefinedContext/useUserDefinedContext.d.ts.map +1 -0
- package/dist/types/alert.d.ts +7 -5
- package/dist/types/alert.d.ts.map +1 -1
- package/dist/types/base.d.ts +8 -2
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/confirm.d.ts +7 -5
- package/dist/types/confirm.d.ts.map +1 -1
- package/dist/types/modal.d.ts +4 -3
- package/dist/types/modal.d.ts.map +1 -1
- package/dist/types/prompt.d.ts +14 -12
- package/dist/types/prompt.d.ts.map +1 -1
- package/package.json +12 -11
|
@@ -2,7 +2,7 @@ export interface Fn<Params extends Array<any> = [], Return = void> {
|
|
|
2
2
|
(...props: Params): Return;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
export interface AsyncFn<Params extends Array<any
|
|
5
|
+
export interface AsyncFn<Params extends Array<any> = [], Return = void> {
|
|
6
6
|
(...props: Params): Promise<Return>;
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ModalLayerProps } from '../../types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const BackgroundFrame: ({ modalId, onChangeOrder, }: ModalLayerProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
3
3
|
//# sourceMappingURL=Background.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Background.d.ts","sourceRoot":"","sources":["../../../src/components/Background/Background.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Background.d.ts","sourceRoot":"","sources":["../../../src/components/Background/Background.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,eAAO,MAAM,eAAe,gCAGzB,eAAe,mDAgDjB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Background } from './Background';
|
|
1
|
+
export { BackgroundFrame as Background } from './Background';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Background/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Background/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ModalLayerProps } from '../../types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const ForegroundFrame: ({ modalId, onChangeOrder, }: ModalLayerProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
3
3
|
//# sourceMappingURL=Foreground.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Foreground.d.ts","sourceRoot":"","sources":["../../../src/components/Foreground/Foreground.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Foreground.d.ts","sourceRoot":"","sources":["../../../src/components/Foreground/Foreground.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,eAAO,MAAM,eAAe,gCAGzB,eAAe,mDAmDjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/AlertInner.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"AlertInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/AlertInner.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,UAAU,eAAe,CAAC,CAAC;IACzB,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACpB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;CAC3C;AAED,eAAO,MAAM,UAAU,wCACpB,CAAC,uBAAwB,eAAe,CAAC,CAAC,CAAC,8CA2D7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/ConfirmInner.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/ConfirmInner.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,UAAU,iBAAiB,CAAC,CAAC;IAC3B,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACtB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,SAAS,CAAC,CAAC;CACvD;AAED,eAAO,MAAM,YAAY,wCACtB,CAAC,uBAAwB,iBAAiB,CAAC,CAAC,CAAC,8CAkE/C,CAAC"}
|
|
@@ -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;
|
|
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;AAGvD,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,8CAyHnD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Foreground } from './Foreground';
|
|
1
|
+
export { ForegroundFrame as Foreground } from './Foreground';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Foreground/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Foreground/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Presenter.d.ts","sourceRoot":"","sources":["../../../src/components/Presenter/Presenter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Presenter.d.ts","sourceRoot":"","sources":["../../../src/components/Presenter/Presenter.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAM1D,eAAO,MAAM,SAAS,oDAAsB,YAAY,6CAetD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/core/handle/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAI/B,UAAU,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG;IAC9B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACxD,KAAK,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IACjD,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,KAAK,CAAC;IACvD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C;AAED,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,CAAC,yLAcxB,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/core/handle/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAI/B,UAAU,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG;IAC9B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACxD,KAAK,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IACjD,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,KAAK,CAAC;IACvD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C;AAED,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,CAAC,yLAcxB,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,eAwBnB,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),n=require("react"),
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),n=require("react"),t=require("react-dom"),o=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 t=document.createElement(e);return t.setAttribute("id",`${n}-${r.getRandomString(36)}`),document.body.appendChild(t),l.current=t,t}},u="300ms",d="rgba(0, 0, 0, 0.5)",m=n.createContext({context:r.EMPTY_OBJECT}),p=({context:t,children:o})=>{const i=n.useMemo((()=>({context:t||r.EMPTY_OBJECT})),[t]);return e.jsx(m.Provider,{value:i,children:o})},f=()=>n.useContext(m);function b(){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 h=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:b}),C=i.css("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:b}),g=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:b}),y=({modalId:t,onChangeOrder:o})=>{const{BackgroundComponent:r}=ue(),{context:s}=f(),{modal:a,onClose:l,onChange:c,onConfirm:u,onDestroy:d}=K(t),m=n.useCallback((e=>{a&&a.closeOnBackdropClick&&a.visible&&l(),e.stopPropagation()}),[a,l]),p=n.useMemo((()=>a?.BackgroundComponent||r),[r,a]);return a?e.jsx("div",{className:i.cx(h,{[g]:a.manualDestroy?a.alive:a.visible,[C]:a.closeOnBackdropClick&&a.visible}),onClick:m,children:p&&e.jsx(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:c,onConfirm:u,onClose:l,onDestroy:d,onChangeOrder:o,context:s})}):null};function v(){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 k=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:v}),x=i.css("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:v}),j=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:v}),O=n.memo((({modal:t,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>t),[t]),{context:u}=f(),{onConfirm:d}=n.useMemo((()=>i),[i]),m=o.useHandle(d),{TitleComponent:p,SubtitleComponent:b,ContentComponent:h,FooterComponent:C}=ue();return e.jsxs(n.Fragment,{children:[s&&(r.isString(s)?e.jsx(p,{context:u,children:s}):s),a&&(r.isString(a)?e.jsx(b,{context:u,children:a}):a),l&&(r.isString(l)?e.jsx(h,{context:u,children:l}):o.renderComponent(l,{onConfirm:m})),!1!==c&&("function"==typeof c?c({onConfirm:m,context:u}):e.jsx(C,{onConfirm:m,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm,context:u}))]})})),w=n.memo((({modal:t,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>t),[t]),{context:u}=f(),{onConfirm:d,onClose:m}=n.useMemo((()=>i),[i]),p=o.useHandle(d),b=o.useHandle(m),{TitleComponent:h,SubtitleComponent:C,ContentComponent:g,FooterComponent:y}=ue();return e.jsxs(n.Fragment,{children:[s&&(r.isString(s)?e.jsx(h,{context:u,children:s}):s),a&&(r.isString(a)?e.jsx(C,{context:u,children:a}):a),l&&(r.isString(l)?e.jsx(g,{context:u,children:l}):o.renderComponent(l,{onConfirm:p,onCancel:b,context:u})),!1!==c&&("function"==typeof c?c({onConfirm:p,onCancel:b,context:u}):e.jsx(y,{onConfirm:p,onCancel:b,confirmLabel:c?.confirm,cancelLabel:c?.cancel,hideConfirm:c?.hideConfirm,hideCancel:c?.hideCancel,context:u}))]})})),D=n.memo((({modal:t,handlers:i})=>{const{Input:s,defaultValue:a,disabled:l,title:c,subtitle:u,content:d,footer:m}=n.useMemo((()=>({...t,Input:n.memo(o.withErrorBoundary(t.Input))})),[t]),{context:p}=f(),[b,h]=n.useState(a),{onChange:C,onClose:g,onConfirm:y}=n.useMemo((()=>i),[i]),v=o.useHandle(g),k=o.useHandle((e=>{const n=r.isFunction(e)?e(b):e;h(n),C(n)})),x=n.useCallback((()=>{setTimeout((()=>{y()}))}),[y]),j=n.useMemo((()=>!!b&&!!l?.(b)),[l,b]),{TitleComponent:O,SubtitleComponent:w,ContentComponent:D,FooterComponent:B}=ue();return e.jsxs(n.Fragment,{children:[c&&(r.isString(c)?e.jsx(O,{context:p,children:c}):c),u&&(r.isString(u)?e.jsx(w,{context:p,children:u}):u),d&&(r.isString(d)?e.jsx(D,{context:p,children:d}):o.renderComponent(d,{onConfirm:x,onCancel:v,context:p})),s&&e.jsx(s,{defaultValue:a,value:b,onChange:k,onConfirm:x,onCancel:v,context:p}),!1!==m&&("function"==typeof m?m({value:b,disabled:j,onChange:k,onConfirm:x,onCancel:v,context:p}):e.jsx(B,{disabled:j,onConfirm:x,onCancel:v,confirmLabel:m?.confirm,cancelLabel:m?.cancel,hideConfirm:m?.hideConfirm,hideCancel:m?.hideCancel,context:p}))]})})),B=({modalId:t,onChangeOrder:o})=>{const{ForegroundComponent:r}=ue(),{context:s}=f(),{modal:a,onChange:l,onConfirm:c,onClose:u,onDestroy:d}=K(t),m=n.useMemo((()=>a?.ForegroundComponent||r),[r,a]);return a?e.jsx("div",{className:i.cx(k,{[j]:a.manualDestroy?a.alive:a.visible,[x]:a.visible}),children:e.jsxs(m,{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:c,onClose:u,onDestroy:d,onChangeOrder:o,context:s,children:["alert"===a.type&&e.jsx(O,{modal:a,handlers:{onConfirm:c}}),"confirm"===a.type&&e.jsx(w,{modal:a,handlers:{onConfirm:c,onClose:u}}),"prompt"===a.type&&e.jsx(D,{modal:a,handlers:{onChange:l,onConfirm:c,onClose:u}})]})}):null},F=e=>{const[n,t]=o.useTick();return o.useOnMount((()=>{if(e)return e.subscribe(t)})),n},P=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)."}}),{increment:E}=r.counterFactory(1),M=n.memo((({modalId:t})=>{const r=n.useRef(null),{modal:i}=K(t);F(i);const s=o.useHandle((()=>{r.current&&(r.current.style.zIndex=`${E()}`)}));return e.jsxs("div",{ref:r,className:P,children:[e.jsx(y,{modalId:t,onChangeOrder:s}),e.jsx(B,{modalId:t,onChangeOrder:s})]})})),N=(e=0)=>{const{modalIds:t,getModalNode:o}=G();return n.useMemo((()=>{let e=0;for(const n of t)o(n)?.visible&&e++;return e}),[o,t,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,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;
|
|
17
|
+
function S(e,n,t,o){if("a"===t&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!o:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?o:"a"===t?o.call(e):o?o.value:n.get(e)}function I(e,n,t,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof n?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,t):r?r.value=t:n.set(e,t),t}var T,V,_,L,R;"function"==typeof SuppressedError&&SuppressedError;class q{get alive(){return S(this,T,"f")}get visible(){return S(this,V,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,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}),T.set(this,void 0),V.set(this,void 0),_.set(this,void 0),L.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.manualDestroy=i,this.closeOnBackdropClick=s,this.ForegroundComponent=l,this.BackgroundComponent=c,I(this,T,!0,"f"),I(this,V,!0,"f"),I(this,_,a,"f")}subscribe(e){return S(this,L,"f").push(e),()=>{I(this,L,S(this,L,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of S(this,L,"f"))e()}resolve(e){S(this,_,"f").call(this,e)}onDestroy(){const e=!0===S(this,T,"f");I(this,T,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===S(this,V,"f");I(this,V,!0,"f"),e&&this.publish()}onHide(){const e=!0===S(this,V,"f");I(this,V,!1,"f"),e&&this.publish()}}T=new WeakMap,V=new WeakMap,_=new WeakMap,L=new WeakMap;class H extends q{constructor({id:e,initiator:n,type:t,subtype:o,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=t,this.subtype=o,this.content=s,this.footer=a}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class $ extends q{constructor({id:e,initiator:n,type:t,subtype:o,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=t,this.subtype=o,this.content=s,this.footer=a}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class z extends q{constructor({id:e,initiator:n,type:t,title:o,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:o,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}),R.set(this,void 0),this.type=t,this.content=i,this.Input=a,this.defaultValue=s,I(this,R,s,"f"),this.disabled=l,this.returnOnCancel=c,this.footer=u}onChange(e){I(this,R,e,"f")}onConfirm(){this.resolve(S(this,R,"f")??null)}onClose(){this.returnOnCancel?this.resolve(S(this,R,"f")??null):this.resolve(null)}}R=new WeakMap;const Y=e=>{switch(e.type){case"alert":return new H(e);case"confirm":return new $(e);case"prompt":return new z(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},A=/^\s*(\d+)\s*(ms|s|m|h)\s*$/,W=e=>{const[,n,t]=e.match(A)||[];if(!n||!t)return 0;const o=parseInt(n);return"ms"===t?o:"s"===t?1e3*o:"m"===t?60*o*1e3:"h"===t?60*o*60*1e3:0},U=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})}),J=n.memo((({pathname:t,children:r})=>{const i=n.useRef(new Map),[s,a]=n.useState([]),l=o.useReference(s),u=n.useRef(t),d=n.useRef(0),m=de(),p=n.useMemo((()=>W(m.duration)),[m]);o.useOnMountLayout((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=m;for(const t of c.prerender){const o=Y({...t,id:d.current++,initiator:u.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});i.current.set(o.id,o),a((e=>[...e,o.id]))}c.setupOpen((t=>{const o=Y({...t,id:d.current++,initiator:u.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});i.current.set(o.id,o),a((e=>[...e.filter((e=>{const n=!i.current.get(e)?.alive;return n&&i.current.delete(e),!n})),o.id]))})),c.clearPrerender()})),n.useLayoutEffect((()=>{for(const e of l.current){const n=i.current.get(e);n?.alive&&(n.initiator===t?n.onShow():n.onHide())}u.current=t}),[l,t]);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 t=i.current.get(e);t&&"prompt"===t.type&&t.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(U.Provider,{value:x,children:r})})),G=()=>n.useContext(U),K=e=>{const{getModal:t}=G();return n.useMemo((()=>t(e)),[e,t])},Q=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)."}}),X=n.memo(o.withErrorBoundary((()=>{const[t,r]=o.useTick(),{modalIds:i,setUpdater:s}=G();n.useEffect((()=>{s(r)}),[s,r]);const{options:a}=ue(),l=N(t);return e.jsx("div",{className:Q,style:{transitionDuration:a.duration,backgroundColor:l?a.backdrop:"transparent"},children:i.map((n=>e.jsx(M,{modalId:n},n)))})})));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 ee=i.css("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:Z}),ne=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:Z}),te=({children:n})=>e.jsx("h2",{className:ee,children:n}),oe=({children:n})=>e.jsx("h3",{className:ee,children:n}),re=({children:n})=>e.jsx("div",{className:ee,children:n}),ie=({confirmLabel:n,hideConfirm:t=!1,cancelLabel:o,hideCancel:r=!1,disabled:i,onConfirm:s,onCancel:a})=>e.jsxs("div",{children:[!t&&e.jsx("button",{onClick:s,disabled:i,children:n||"확인"}),!r&&"function"==typeof a&&e.jsx("button",{onClick:a,children:o||"취소"})]}),se=n.forwardRef((({id:t,onChangeOrder:o,children:r},i)=>{const s=N(),[a,l]=n.useMemo((()=>{const e=s>1;return[e?Math.floor(t/5)%3*100:0,e?t%5*35:0]}),[s,t]);return e.jsx("div",{ref:i,className:ne,onClick:o,style:{marginBottom:`calc(25vh + ${a}px)`,marginLeft:`${a}px`,transform:`translate(${l}px, ${l}px)`},children:r})})),ae=()=>{const[e,t]=n.useState(window.location.pathname);return n.useLayoutEffect((()=>{let n;const o=()=>{n&&cancelAnimationFrame(n),e!==window.location.pathname?t(window.location.pathname):n=requestAnimationFrame(o)};return n=requestAnimationFrame(o),()=>{n&&cancelAnimationFrame(n)}}),[e]),{pathname:e}},le=n.createContext({ForegroundComponent:se,TitleComponent:te,SubtitleComponent:oe,ContentComponent:re,FooterComponent:ie,options:{duration:u,backdrop:d,manualDestroy:!1,closeOnBackdropClick:!0}}),ce=n.memo((({ForegroundComponent:r,BackgroundComponent:i,TitleComponent:s,SubtitleComponent:a,ContentComponent:l,FooterComponent:m,options:f,context:b,usePathname:h,children:C})=>{const{pathname:g}=(h||ae)(),[,y]=o.useTick(),v=n.useRef(null);o.useOnMount((()=>(v.current=c.anchor("div"),y(),()=>{v.current&&v.current.remove()})));const k=n.useMemo((()=>({BackgroundComponent:i,ForegroundComponent:r||se,TitleComponent:s||te,SubtitleComponent:a||oe,ContentComponent:n.memo(l||re),FooterComponent:n.memo(m||ie),options:{duration:u,backdrop:d,closeOnBackdropClick:!0,manualDestroy:!1,...f}})),[r,i,l,m,a,s,f]);return e.jsxs(le.Provider,{value:k,children:[C,v.current&&t.createPortal(e.jsx(p,{context:b,children:e.jsx(J,{pathname:g,children:e.jsx(X,{})})}),v.current)]})})),ue=()=>n.useContext(le),de=()=>{const{options:e}=n.useContext(le);return e};exports.ModalProvider=ce,exports.alert=({subtype:e,title:n,subtitle:t,content:o,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:t,content:o,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})}catch(e){m(e)}})),exports.confirm=({subtype:e,title:n,subtitle:t,content:o,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:t,content:o,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})}catch(e){m(e)}})),exports.prompt=({defaultValue:e,title:n,subtitle:t,content:o,Input:r,disabled:i,returnOnCancel:s,background:a,footer:l,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})=>new Promise(((f,b)=>{try{c.open({type:"prompt",resolve:e=>f(e),title:n,subtitle:t,content:o,Input:r,defaultValue:e,disabled:i,returnOnCancel:s,background:a,footer:l,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})}catch(e){b(e)}})),exports.useDestroyAfter=(e,t)=>{const{modal:o,onDestroy:i}=K(e),s=F(o),a=n.useRef({modal:o,onDestroy:i,milliseconds:r.isString(t)?W(t):t});n.useEffect((()=>{const{modal:e,onDestroy:n,milliseconds:t}=a.current;if(!e||e.visible||!e.alive)return;const o=setTimeout((()=>{n()}),t);return()=>{o&&clearTimeout(o)}}),[s])},exports.useModalBackdrop=()=>{const{backdrop:e}=de();return e},exports.useModalDuration=()=>{const{duration:e}=de();return{duration:e,milliseconds:W(e)}},exports.useModalOptions=de,exports.useSubscribeModal=F;
|
|
18
18
|
//# sourceMappingURL=index.cjs.js.map
|