@lerx/promise-modal 0.0.2 → 0.0.4
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/{types → @aileron/types}/function.d.ts +4 -4
- package/dist/@aileron/types/index.d.ts +4 -0
- package/dist/@aileron/types/object.d.ts +11 -0
- package/dist/{types/units.d.ts → @aileron/types/unit.d.ts} +4 -6
- package/dist/@aileron/types/utility.d.ts +39 -0
- package/dist/app/ModalManager.d.ts.map +1 -1
- package/dist/app/constant.d.ts +3 -2
- package/dist/app/constant.d.ts.map +1 -1
- package/dist/components/Anchor/classNames.emotion.d.ts +2 -0
- package/dist/components/Anchor/classNames.emotion.d.ts.map +1 -0
- package/dist/components/Background/classNames.emotion.d.ts +4 -0
- package/dist/components/Background/classNames.emotion.d.ts.map +1 -0
- package/dist/components/FallbackComponents/classNames.emotion.d.ts +3 -0
- package/dist/components/FallbackComponents/classNames.emotion.d.ts.map +1 -0
- package/dist/components/Foreground/classNames.emotion.d.ts +3 -0
- package/dist/components/Foreground/classNames.emotion.d.ts.map +1 -0
- package/dist/components/Presenter/classNames.emotion.d.ts +2 -0
- package/dist/components/Presenter/classNames.emotion.d.ts.map +1 -0
- package/dist/core/node/ModalNode/AbstractBaseNode.d.ts +1 -0
- package/dist/core/node/ModalNode/AbstractBaseNode.d.ts.map +1 -1
- package/dist/hooks/useDestroyAfter.d.ts +1 -0
- package/dist/hooks/useDestroyAfter.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 +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/providers/ModalContext/ModalContext.d.ts +2 -1
- package/dist/providers/ModalContext/ModalContext.d.ts.map +1 -1
- package/dist/providers/ModalContext/ModalContextProvider.d.ts +1 -0
- package/dist/providers/ModalContext/ModalContextProvider.d.ts.map +1 -1
- package/dist/providers/ModalContext/useModalContext.d.ts +4 -4
- package/dist/providers/ModalContext/useModalContext.d.ts.map +1 -1
- package/dist/providers/ModalDataContext/ModalDataContext.d.ts +1 -0
- package/dist/providers/ModalDataContext/ModalDataContext.d.ts.map +1 -1
- package/dist/providers/ModalDataContext/ModalDataContextProvider.d.ts.map +1 -1
- package/dist/types/modal.d.ts +1 -0
- package/dist/types/modal.d.ts.map +1 -1
- package/dist/types/prompt.d.ts +1 -0
- package/dist/types/prompt.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/types/object.d.ts +0 -14
- package/dist/types/styles.d.ts +0 -4
- package/dist/types/utility.d.ts +0 -45
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
export interface Fn<Params extends Array<any> = [], Return = void> {
|
|
2
2
|
(...props: Params): Return;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export interface AsyncFn<Params extends Array<any>, Return = void> {
|
|
6
6
|
(...props: Params): Promise<Return>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export type SetStateFn<S = unknown> = (
|
|
10
10
|
value: S | ((prevState: S) => S),
|
|
11
11
|
) => void;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
export type Parameter<
|
|
14
14
|
F extends Fn<[any]> | SetStateFn<any> | undefined,
|
|
15
15
|
I extends number = 0,
|
|
16
16
|
> = Parameters<NonNullable<F>>[I];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Dictionary<T = any> = Record<string, T>;
|
|
2
|
+
|
|
3
|
+
export type StringDictionary = Dictionary<string>;
|
|
4
|
+
|
|
5
|
+
export type DeepRequired<T> = {
|
|
6
|
+
[P in keyof T]-?: NonNullable<T[P]> extends object
|
|
7
|
+
? NonNullable<T[P]> extends any[]
|
|
8
|
+
? DeepRequired<NonNullable<T[P]>[number]>[]
|
|
9
|
+
: DeepRequired<NonNullable<T[P]>>
|
|
10
|
+
: T[P];
|
|
11
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export type DomSize =
|
|
2
2
|
| number
|
|
3
3
|
| `${number}%`
|
|
4
4
|
| `${number}px`
|
|
@@ -8,14 +8,12 @@ declare type DomSize =
|
|
|
8
8
|
| `${number}vw`
|
|
9
9
|
| `calc(${string})`;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
export type Color =
|
|
12
12
|
| `#${string}`
|
|
13
13
|
| `rgb(${number}, ${number}, ${number})`
|
|
14
14
|
| `rgba(${number}, ${number}, ${number}, ${number})`
|
|
15
15
|
| `var(--${string})`;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
export type Time = `${number}ms` | `${number}s`;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
declare type Roll<T> = { [K in keyof T]: T[K] };
|
|
19
|
+
export type Duration = `${number}ms`;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type Nullish<T> = T | null | undefined;
|
|
2
|
+
|
|
3
|
+
/** T에서 key in K를 추출하고, 이를 Required로 설정 */
|
|
4
|
+
export type PickRequired<T, K extends keyof T> = Required<Pick<T, K>>;
|
|
5
|
+
|
|
6
|
+
/** T에서 key in K를 추출하고, 이를 Partial로 설정 */
|
|
7
|
+
export type PickPartial<T, K extends keyof T> = Partial<Pick<T, K>>;
|
|
8
|
+
|
|
9
|
+
/** T에서 key in K를 제거하고, 나머지를 Required로 설정 */
|
|
10
|
+
export type OmitRequired<T, K extends keyof T> = Required<Omit<T, K>>;
|
|
11
|
+
|
|
12
|
+
/** T에서 key in K를 제거하고, 나머지를 Partial로 설정 */
|
|
13
|
+
export type OmitPartial<T, K extends keyof T> = Partial<Omit<T, K>>;
|
|
14
|
+
|
|
15
|
+
/** T에서 key in K는 Required로 설정하고, 나머지는 Partial로 설정 */
|
|
16
|
+
export type PickAndPartial<T, K extends keyof T> = PickRequired<T, K> &
|
|
17
|
+
OmitPartial<T, K>;
|
|
18
|
+
|
|
19
|
+
/** T에서 K를 Required로 설정하고, 나머지는 유지 */
|
|
20
|
+
export type RequiredBy<T, K extends keyof T> = PickRequired<T, K> & T;
|
|
21
|
+
|
|
22
|
+
/** T에서 K를 Partial로 설정하고, 나머지는 유지 */
|
|
23
|
+
export type PartialBy<T, K extends keyof T> = PickPartial<T, K> & Omit<T, K>;
|
|
24
|
+
|
|
25
|
+
export type Roll<T> = { [K in keyof T]: T[K] };
|
|
26
|
+
|
|
27
|
+
export type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
|
|
28
|
+
|
|
29
|
+
export type ExpandRecursively<T> = T extends object
|
|
30
|
+
? T extends infer O
|
|
31
|
+
? { [K in keyof O]: ExpandRecursively<O[K]> }
|
|
32
|
+
: never
|
|
33
|
+
: T;
|
|
34
|
+
|
|
35
|
+
export type WithKey<T> = T & { key: string };
|
|
36
|
+
|
|
37
|
+
export type ElementOf<T extends any[]> = T[number];
|
|
38
|
+
|
|
39
|
+
export type Params<T extends Array<string>> = Record<T[number], string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalManager.d.ts","sourceRoot":"","sources":["../../src/app/ModalManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ModalManager.d.ts","sourceRoot":"","sources":["../../src/app/ModalManager.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAgBnD,eAAO,MAAM,YAAY;;;gBAOX,KAAK;oBAGD,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;iBAGzB,MAAM,mBAA2B,WAAW;CAW1D,CAAC"}
|
package/dist/app/constant.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
import type { Color, Duration } from '../@aileron/types';
|
|
2
|
+
export declare const DEFAULT_ANIMATION_DURATION: Duration;
|
|
3
|
+
export declare const DEFAULT_BACKDROP_COLOR: Color;
|
|
3
4
|
//# sourceMappingURL=constant.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/app/constant.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/app/constant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEtD,eAAO,MAAM,0BAA0B,EAAE,QAAkB,CAAC;AAE5D,eAAO,MAAM,sBAAsB,EAAE,KAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.emotion.d.ts","sourceRoot":"","sources":["../../../src/components/Anchor/classNames.emotion.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,QAOf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.emotion.d.ts","sourceRoot":"","sources":["../../../src/components/Background/classNames.emotion.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,QAOf,CAAC;AACH,eAAO,MAAM,MAAM,QAOjB,CAAC;AACH,eAAO,MAAM,OAAO,QAOlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.emotion.d.ts","sourceRoot":"","sources":["../../../src/components/FallbackComponents/classNames.emotion.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,QAOnB,CAAC;AACH,eAAO,MAAM,KAAK,QAOhB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.emotion.d.ts","sourceRoot":"","sources":["../../../src/components/Foreground/classNames.emotion.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,QAOf,CAAC;AACH,eAAO,MAAM,MAAM,QAOjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.emotion.d.ts","sourceRoot":"","sources":["../../../src/components/Presenter/classNames.emotion.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,QAOf,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Fn } from '../../../@aileron/types';
|
|
2
3
|
import type { BaseModal, ManagedEntity, ModalBackground } from '../../../types';
|
|
3
4
|
type BaseNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;
|
|
4
5
|
export declare abstract class BaseNode<T, B> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractBaseNode.d.ts","sourceRoot":"","sources":["../../../../src/core/node/ModalNode/AbstractBaseNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAE/B,KAAK,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,aAAa,CAAC;AAE3D,8BAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC;;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAEzC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;IAGvC,IAAI,KAAK,YAER;IAED,IAAI,OAAO,YAEV;gBAKW,EACV,EAAE,EACF,SAAS,EACT,KAAK,EACL,QAAQ,EACR,UAAU,EACV,aAAqB,EACrB,oBAA2B,EAC3B,OAAO,GACR,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;IActB,SAAS,CAAC,QAAQ,EAAE,EAAE;IAMtB,OAAO;IAGP,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI;IAGlC,SAAS;IAKT,MAAM;IAKN,MAAM;IAKN,QAAQ,CAAC,OAAO,IAAI,IAAI;IACxB,QAAQ,CAAC,SAAS,IAAI,IAAI;CAC3B"}
|
|
1
|
+
{"version":3,"file":"AbstractBaseNode.d.ts","sourceRoot":"","sources":["../../../../src/core/node/ModalNode/AbstractBaseNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEzC,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAE/B,KAAK,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,aAAa,CAAC;AAE3D,8BAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC;;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAEzC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;IAGvC,IAAI,KAAK,YAER;IAED,IAAI,OAAO,YAEV;gBAKW,EACV,EAAE,EACF,SAAS,EACT,KAAK,EACL,QAAQ,EACR,UAAU,EACV,aAAqB,EACrB,oBAA2B,EAC3B,OAAO,GACR,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;IActB,SAAS,CAAC,QAAQ,EAAE,EAAE;IAMtB,OAAO;IAGP,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI;IAGlC,SAAS;IAKT,MAAM;IAKN,MAAM;IAKN,QAAQ,CAAC,OAAO,IAAI,IAAI;IACxB,QAAQ,CAAC,SAAS,IAAI,IAAI;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDestroyAfter.d.ts","sourceRoot":"","sources":["../../src/hooks/useDestroyAfter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMtD,eAAO,MAAM,eAAe,YACjB,SAAS,CAAC,IAAI,CAAC,YACd,QAAQ,GAAG,MAAM,SAuB5B,CAAC"}
|
|
1
|
+
{"version":3,"file":"useDestroyAfter.d.ts","sourceRoot":"","sources":["../../src/hooks/useDestroyAfter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMtD,eAAO,MAAM,eAAe,YACjB,SAAS,CAAC,IAAI,CAAC,YACd,QAAQ,GAAG,MAAM,SAuB5B,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),
|
|
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="modal-anchor"){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.getRandomNumber()}`),document.body.appendChild(t),l.current=t,t}},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:"1p2ejpq-root",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;};label:root;",toString:m}),f=i.css("production"===process.env.NODE_ENV?{name:"10wde3l",styles:"pointer-events:all!important"}:{name:"3a0g0-active",styles:"pointer-events:all!important;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:t,onChangeOrder:o})=>{const{BackgroundComponent:r}=se(),{modal:s,onClose:a,onChange:l,onConfirm:c,onDestroy:u}=Y(t),d=n.useCallback((e=>{s&&s.closeOnBackdropClick&&s.visible&&a(),e.stopPropagation()}),[s,a]);if(!s)return null;const m=s.manualDestroy?s.alive:s.visible;return e.jsx("div",{className:i.cx(p,{[b]:m,[f]:s.closeOnBackdropClick&&m}),onClick:d,children:r&&e.jsx(r,{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:o})})};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 y=i.css("production"===process.env.NODE_ENV?{name:"12g0hx0",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1"}:{name:"10jnv7e-root",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1;label:root;",toString:C}),v=i.css("production"===process.env.NODE_ENV?{name:"16yx055",styles:"display:flex!important;justify-content:center;align-items:center;>*{pointer-events:all;}"}:{name:"127acw3-active",styles:"display:flex!important;justify-content:center;align-items:center;>*{pointer-events:all;};label:active;",toString:C}),g=n.memo((({modal:t,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>t),[t]),{onConfirm:u}=n.useMemo((()=>i),[i]),d=o.useHandle(u),{TitleComponent:m,SubtitleComponent:p,ContentComponent:f,FooterComponent:b}=se();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}):o.renderComponent(l,{onConfirm:d})),!1!==c&&("function"==typeof c?c({onConfirm:d}):e.jsx(b,{onConfirm:d,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm}))]})})),k=n.memo((({modal:t,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>t),[t]),{onConfirm:u,onClose:d}=n.useMemo((()=>i),[i]),m=o.useHandle(u),p=o.useHandle(d),{TitleComponent:f,SubtitleComponent:b,ContentComponent:h,FooterComponent:C}=se();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}):o.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}))]})})),x=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(t.Input)})),[t]),[p,f]=n.useState(a),{onChange:b,onClose:h,onConfirm:C}=n.useMemo((()=>i),[i]),y=o.useHandle(h),v=o.useHandle((e=>{const n=r.isFunction(e)?e(p):e;f(n),b(n)})),g=n.useCallback((()=>{setTimeout((()=>{C()}))}),[C]),k=n.useMemo((()=>!!p&&!!l?.(p)),[l,p]),{TitleComponent:x,SubtitleComponent:j,ContentComponent:O,FooterComponent:w}=se();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}):o.renderComponent(d,{onConfirm:g,onCancel:y})),s&&e.jsx(s,{defaultValue:a,value:p,onChange:v,onConfirm:g}),!1!==m&&("function"==typeof m?m({onConfirm:g,onCancel:y,onChange:v,value:p,disabled:k}):e.jsx(w,{onConfirm:g,onCancel:y,disabled:k,confirmLabel:m?.confirm,cancelLabel:m?.cancel,hideConfirm:m?.hideConfirm,hideCancel:m?.hideCancel}))]})})),j=({modalId:n,onChangeOrder:t})=>{const{ForegroundComponent:o}=se(),{modal:r,onChange:s,onConfirm:a,onClose:l,onDestroy:c}=Y(n);return r?e.jsx("div",{className:i.cx(y,{[v]:r.manualDestroy?r.alive:r.visible}),children:e.jsxs(o,{id:r.id,type:r.type,alive:r.alive,visible:r.visible,initiator:r.initiator,manualDestroy:r.manualDestroy,closeOnBackdropClick:r.closeOnBackdropClick,background:r.background,onChange:s,onConfirm:a,onClose:l,onDestroy:c,onChangeOrder:t,children:["alert"===r.type&&e.jsx(g,{modal:r,handlers:{onConfirm:a}}),"confirm"===r.type&&e.jsx(k,{modal:r,handlers:{onConfirm:a,onClose:l}}),"prompt"===r.type&&e.jsx(x,{modal:r,handlers:{onChange:s,onConfirm:a,onClose:l}})]})}):null},O=e=>{const[n,t]=o.useTick();return o.useOnMount((()=>{if(e)return e.subscribe(t)})),n},w=i.css("production"===process.env.NODE_ENV?{name:"13dmkf4",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden"}:{name:"1kdr2v-root",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden;label:root;",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 D=1;const B=n.memo((({modalId:t})=>{const r=n.useRef(null),{modal:i}=Y(t);O(i);const s=o.useHandle((()=>{r.current&&(r.current.style.zIndex=""+D++)}));return e.jsxs("div",{ref:r,className:w,children:[e.jsx(h,{modalId:t,onChangeOrder:s}),e.jsx(j,{modalId:t,onChangeOrder:s})]})})),P=(e=0)=>{const{modalIds:t,getModalNode:o}=W();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 O(e,o,t,n){if("a"===t&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof o?e!==o||!n:!o.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?n:"a"===t?n.call(e):n?n.value:o.get(e)}function D(e,o,t,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof o?e!==o||!r:!o.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,t):r?r.value=t:o.set(e,t),t}var w,V,Z,U,W;"function"==typeof SuppressedError&&SuppressedError;class R{get alive(){return O(this,w,"f")}get visible(){return O(this,V,"f")}constructor({id:e,initiator:o,title:t,subtitle:n,background:r,manualDestroy:i=!1,closeOnBackdropClick:l=!0,resolve:s}){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}),w.set(this,void 0),V.set(this,void 0),Z.set(this,void 0),U.set(this,[]),this.id=e,this.initiator=o,this.title=t,this.subtitle=n,this.background=r,this.manualDestroy=i,this.closeOnBackdropClick=l,D(this,w,!0,"f"),D(this,V,!0,"f"),D(this,Z,s,"f")}subscribe(e){return O(this,U,"f").push(e),()=>{D(this,U,O(this,U,"f").filter((o=>o!==e)),"f")}}publish(){for(const e of O(this,U,"f"))e()}resolve(e){O(this,Z,"f").call(this,e)}onDestroy(){const e=!0===O(this,w,"f");D(this,w,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===O(this,V,"f");D(this,V,!0,"f"),e&&this.publish()}onHide(){const e=!0===O(this,V,"f");D(this,V,!1,"f"),e&&this.publish()}}w=new WeakMap,V=new WeakMap,Z=new WeakMap,U=new WeakMap;class L extends R{constructor({id:e,initiator:o,type:t,subtype:n,title:r,subtitle:i,content:l,footer:s,background:a,manualDestroy:c,closeOnBackdropClick:u,resolve:d}){super({id:e,initiator:o,title:r,subtitle:i,background:a,manualDestroy:c,closeOnBackdropClick:u,resolve:d}),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=n,this.content=l,this.footer=s}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class z extends R{constructor({id:e,initiator:o,type:t,subtype:n,title:r,subtitle:i,content:l,footer:s,background:a,manualDestroy:c,closeOnBackdropClick:u,resolve:d}){super({id:e,initiator:o,title:r,subtitle:i,background:a,manualDestroy:c,closeOnBackdropClick:u,resolve:d}),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=n,this.content=l,this.footer=s}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class X extends R{constructor({id:e,initiator:o,type:t,title:n,subtitle:r,content:i,defaultValue:l,Input:s,disabled:a,returnOnCancel:c,footer:u,background:d,manualDestroy:m,closeOnBackdropClick:b,resolve:p}){super({id:e,initiator:o,title:n,subtitle:r,background:d,manualDestroy:m,closeOnBackdropClick:b,resolve:p}),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}),W.set(this,void 0),this.type=t,this.content=i,this.Input=s,this.defaultValue=l,D(this,W,l,"f"),this.disabled=a,this.returnOnCancel=c,this.footer=u}onChange(e){D(this,W,e,"f")}onConfirm(){this.resolve(O(this,W,"f")??null)}onClose(){this.returnOnCancel?this.resolve(O(this,W,"f")??null):this.resolve(null)}}W=new WeakMap;const N=e=>{switch(e.type){case"alert":return new L(e);case"confirm":return new z(e);case"prompt":return new X(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},M=/^\s*(\d+)\s*(ms|s|m|h)\s*$/,J=e=>{const[,o,t]=e.match(M)||[];if(!o||!t)return 0;const n=parseInt(o);return"ms"===t?n:"s"===t?1e3*n:"m"===t?60*n*1e3:"h"===t?60*n*60*1e3:0},S=o.createContext({modalIds:[],getModalNode:u,onChange:u,onConfirm:u,onClose:u,onDestroy:u,setUpdater:u,getModal:()=>({modal:void 0,onConfirm:u,onClose:u,onChange:u,onDestroy:u})}),Y=o.memo((({pathname:t,children:n})=>{const r=o.useRef(new Map),[l,s]=o.useState([]),a=i(l),c=o.useRef(t),u=o.useRef(0),d=ie(),m=o.useMemo((()=>J(d.duration)),[d]);var b;b=()=>{const{manualDestroy:e,closeOnBackdropClick:o}=d;for(const t of f.prerender){const n=N({...t,id:u.current++,initiator:c.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:o});r.current.set(n.id,n),s((e=>[...e,n.id]))}f.setupOpen((t=>{const n=N({...t,id:u.current++,initiator:c.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:o});r.current.set(n.id,n),s((e=>[...e.filter((e=>{const o=!r.current.get(e)?.alive;return o&&r.current.delete(e),!o})),n.id]))})),f.clearPrerender()},o.useLayoutEffect(b,[]),o.useLayoutEffect((()=>{for(const e of a.current){const o=r.current.get(e);o?.alive&&(o.initiator===t?o.onShow():o.onHide())}c.current=t}),[a,t]);const p=o.useCallback((e=>r.current.get(e)),[]),C=o.useCallback((e=>{const o=r.current.get(e);o&&(o.onDestroy(),h.current?.())}),[]),h=o.useRef(),y=o.useCallback((e=>{const o=r.current.get(e);o&&(o.onHide(),h.current?.(),o.manualDestroy||setTimeout((()=>{o.onDestroy()}),m))}),[m]),g=o.useCallback(((e,o)=>{const t=r.current.get(e);t&&"prompt"===t.type&&t.onChange(o)}),[]),v=o.useCallback((e=>{const o=r.current.get(e);o&&(o.onConfirm(),y(e))}),[y]),k=o.useCallback((e=>{const o=r.current.get(e);o&&(o.onClose(),y(e))}),[y]),x=o.useCallback((e=>({modal:p(e),onConfirm:()=>v(e),onClose:()=>k(e),onChange:o=>g(e,o),onDestroy:()=>C(e)})),[p,v,k,g,C]),I=o.useMemo((()=>({modalIds:l,getModalNode:p,onChange:g,onConfirm:v,onClose:k,onDestroy:C,getModal:x,setUpdater:e=>{h.current=e}})),[l,x,p,g,v,k,C]);return e.jsx(S.Provider,{value:I,children:n})})),E=()=>o.useContext(S),P=e=>{const{getModal:t}=E();return o.useMemo((()=>t(e)),[e,t])};r(".Anchor-module__root___7N-Qo{align-items:center;display:flex;inset:0;justify-content:center;pointer-events:none;position:fixed;transition:background-color ease-in-out;z-index:1000}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkFuY2hvci5tb2R1bGUuY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDZCQUVFLGtCQUFtQixDQURuQixZQUFhLENBSWIsT0FBUSxDQUZSLHNCQUF1QixDQUd2QixtQkFBb0IsQ0FGcEIsY0FBZSxDQUlmLHVDQUF3QyxDQUR4QyxZQUVGIiwiZmlsZSI6IkFuY2hvci5tb2R1bGUuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiLnJvb3Qge1xuICBkaXNwbGF5OiBmbGV4O1xuICBhbGlnbi1pdGVtczogY2VudGVyO1xuICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjtcbiAgcG9zaXRpb246IGZpeGVkO1xuICBpbnNldDogMDtcbiAgcG9pbnRlci1ldmVudHM6IG5vbmU7XG4gIHotaW5kZXg6IDEwMDA7XG4gIHRyYW5zaXRpb246IGJhY2tncm91bmQtY29sb3IgZWFzZS1pbi1vdXQ7XG59XG4iXX0= */");const A=o.memo((()=>{const[t,n]=a(),{modalIds:r,setUpdater:i}=E();o.useEffect((()=>{i(n)}),[i,n]);const{options:l}=re(),s=G(t);return e.jsx("div",{className:"Anchor-module__root___7N-Qo",style:{transitionDuration:l.duration,backgroundColor:s?l.backdrop:"transparent"},children:r.map((o=>e.jsx(Q,{modalId:o},o)))})}));var H="styles-module__fallback___g8MEI";r(".styles-module__fallback___g8MEI{margin:unset}.styles-module__frame___1mKAZ{align-items:center;background-color:#fff;border:1px solid #000;display:flex;flex-direction:column;gap:10px;justify-content:center;padding:20px 80px}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy5tb2R1bGUuY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGlDQUNFLFlBQ0YsQ0FFQSw4QkFJRSxrQkFBbUIsQ0FDbkIscUJBQXVCLENBR3ZCLHFCQUF1QixDQVB2QixZQUFhLENBQ2IscUJBQXNCLENBS3RCLFFBQVMsQ0FKVCxzQkFBdUIsQ0FHdkIsaUJBR0YiLCJmaWxlIjoic3R5bGVzLm1vZHVsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyIuZmFsbGJhY2sge1xuICBtYXJnaW46IHVuc2V0O1xufVxuXG4uZnJhbWUge1xuICBkaXNwbGF5OiBmbGV4O1xuICBmbGV4LWRpcmVjdGlvbjogY29sdW1uO1xuICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjtcbiAgYWxpZ24taXRlbXM6IGNlbnRlcjtcbiAgYmFja2dyb3VuZC1jb2xvcjogd2hpdGU7XG4gIHBhZGRpbmc6IDIwcHggODBweDtcbiAgZ2FwOiAxMHB4O1xuICBib3JkZXI6IDFweCBzb2xpZCBibGFjaztcbn1cbiJdfQ== */");const T=({children:o})=>e.jsx("h2",{className:H,children:o}),$=({children:o})=>e.jsx("h3",{className:H,children:o}),q=({children:o})=>e.jsx("div",{className:H,children:o}),K=({confirmLabel:o,hideConfirm:t=!1,cancelLabel:n,hideCancel:r=!1,disabled:i,onConfirm:l,onCancel:s})=>e.jsxs("div",{children:[!t&&e.jsx("button",{onClick:l,disabled:i,children:o||"확인"}),!r&&"function"==typeof s&&e.jsx("button",{onClick:s,children:n||"취소"})]}),ee=o.forwardRef((({id:t,onChangeOrder:n,children:r},i)=>{const l=G(),[s,a]=o.useMemo((()=>{const e=l>1;return[e?Math.floor(t/5)%3*100:0,e?t%5*35:0]}),[l,t]);return e.jsx("div",{ref:i,className:"styles-module__frame___1mKAZ",onClick:n,style:{marginBottom:`calc(25vh + ${s}px)`,marginLeft:`${s}px`,transform:`translate(${a}px, ${a}px)`},children:r})})),oe=()=>{const[e,t]=o.useState(window.location.pathname);return o.useLayoutEffect((()=>{let o;const n=()=>{o&&cancelAnimationFrame(o),e!==window.location.pathname?t(window.location.pathname):o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>{o&&cancelAnimationFrame(o)}}),[e]),{pathname:e}},te=o.createContext({ForegroundComponent:ee,TitleComponent:T,SubtitleComponent:$,ContentComponent:q,FooterComponent:K,options:{duration:C,backdrop:h,manualDestroy:!1,closeOnBackdropClick:!0}}),ne=o.memo((({ForegroundComponent:n,BackgroundComponent:r,TitleComponent:i,SubtitleComponent:l,ContentComponent:c,FooterComponent:u,options:d,usePathname:m,children:b})=>{const{pathname:p}=(m||oe)(),[,y]=a(),g=o.useRef(null);s((()=>(g.current=f.anchor("div"),y(),()=>{g.current&&g.current.remove()})));const v=o.useMemo((()=>({BackgroundComponent:r,ForegroundComponent:n||ee,TitleComponent:i||T,SubtitleComponent:l||$,ContentComponent:o.memo(c||q),FooterComponent:o.memo(u||K),options:{duration:C,backdrop:h,closeOnBackdropClick:!0,manualDestroy:!1,...d}})),[n,r,c,u,l,i,d]);return e.jsxs(te.Provider,{value:v,children:[b,g.current&&t.createPortal(e.jsx(Y,{pathname:p,children:e.jsx(A,{})}),g.current)]})})),re=()=>o.useContext(te),ie=()=>{const{options:e}=o.useContext(te);return e};exports.ModalProvider=ne,exports.alert=({subtype:e,title:o,subtitle:t,content:n,background:r,footer:i,manualDestroy:l,closeOnBackdropClick:s})=>new Promise(((a,c)=>{try{f.open({type:"alert",subtype:e,resolve:()=>a(),title:o,subtitle:t,content:n,background:r,footer:i,manualDestroy:l,closeOnBackdropClick:s})}catch(e){c(e)}})),exports.confirm=({subtype:e,title:o,subtitle:t,content:n,background:r,footer:i,manualDestroy:l,closeOnBackdropClick:s})=>new Promise(((a,c)=>{try{f.open({type:"confirm",subtype:e,resolve:e=>a(e??!1),title:o,subtitle:t,content:n,background:r,footer:i,manualDestroy:l,closeOnBackdropClick:s})}catch(e){c(e)}})),exports.prompt=({defaultValue:e,title:o,subtitle:t,content:n,Input:r,disabled:i,returnOnCancel:l,background:s,footer:a,manualDestroy:c,closeOnBackdropClick:u})=>new Promise(((d,m)=>{try{f.open({type:"prompt",resolve:e=>d(e),title:o,subtitle:t,content:n,Input:({defaultValue:e,onChange:o,onConfirm:t})=>r({defaultValue:e,onChange:o,onConfirm:t}),defaultValue:e,disabled:i,returnOnCancel:l,background:s,footer:a,manualDestroy:c,closeOnBackdropClick:u})}catch(e){m(e)}})),exports.useDestroyAfter=(e,t)=>{const{modal:n,onDestroy:r}=P(e),i=F(n),l=o.useRef({modal:n,onDestroy:r,milliseconds:d(t)?J(t):t});o.useEffect((()=>{const{modal:e,onDestroy:o,milliseconds:t}=l.current;if(!e||e.visible||!e.alive)return;const n=setTimeout((()=>{o()}),t);return()=>{n&&clearTimeout(n)}}),[i])},exports.useModalBackdrop=()=>{const{backdrop:e}=ie();return e},exports.useModalDuration=()=>{const{duration:e}=ie();return{duration:e,milliseconds:J(e)}},exports.useModalOptions=ie,exports.useSubscribeModal=F;
|
|
17
|
+
function N(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 M(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 S,E,F,I,T;"function"==typeof SuppressedError&&SuppressedError;class V{get alive(){return N(this,S,"f")}get visible(){return N(this,E,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,background:r,manualDestroy:i=!1,closeOnBackdropClick:s=!0,resolve:a}){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}),S.set(this,void 0),E.set(this,void 0),F.set(this,void 0),I.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.manualDestroy=i,this.closeOnBackdropClick=s,M(this,S,!0,"f"),M(this,E,!0,"f"),M(this,F,a,"f")}subscribe(e){return N(this,I,"f").push(e),()=>{M(this,I,N(this,I,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of N(this,I,"f"))e()}resolve(e){N(this,F,"f").call(this,e)}onDestroy(){const e=!0===N(this,S,"f");M(this,S,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===N(this,E,"f");M(this,E,!0,"f"),e&&this.publish()}onHide(){const e=!0===N(this,E,"f");M(this,E,!1,"f"),e&&this.publish()}}S=new WeakMap,E=new WeakMap,F=new WeakMap,I=new WeakMap;class L extends V{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}){super({id:e,initiator:n,title:r,subtitle:i,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d}),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 R extends V{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}){super({id:e,initiator:n,title:r,subtitle:i,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d}),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 q extends V{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}){super({id:e,initiator:n,title:o,subtitle:r,background:d,manualDestroy:m,closeOnBackdropClick:p,resolve:f}),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=t,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(N(this,T,"f")??null)}onClose(){this.returnOnCancel?this.resolve(N(this,T,"f")??null):this.resolve(null)}}T=new WeakMap;const H=e=>{switch(e.type){case"alert":return new L(e);case"confirm":return new R(e);case"prompt":return new q(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},_=/^\s*(\d+)\s*(ms|s|m|h)\s*$/,$=e=>{const[,n,t]=e.match(_)||[];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},z=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})}),A=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=ae(),p=n.useMemo((()=>$(m.duration)),[m]);o.useOnMountLayout((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=m;for(const t of c.prerender){const o=H({...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=H({...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]),y=n.useCallback(((e,n)=>{const t=i.current.get(e);t&&"prompt"===t.type&&t.onChange(n)}),[]),v=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onConfirm(),C(e))}),[C]),g=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onClose(),C(e))}),[C]),k=n.useCallback((e=>({modal:f(e),onConfirm:()=>v(e),onClose:()=>g(e),onChange:n=>y(e,n),onDestroy:()=>b(e)})),[f,v,g,y,b]),x=n.useMemo((()=>({modalIds:s,getModalNode:f,onChange:y,onConfirm:v,onClose:g,onDestroy:b,getModal:k,setUpdater:e=>{h.current=e}})),[s,k,f,y,v,g,b]);return e.jsx(z.Provider,{value:x,children:r})})),W=()=>n.useContext(z),Y=e=>{const{getModal:t}=W();return n.useMemo((()=>t(e)),[e,t])},U=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:"khha1y-root",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:root;",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)."}}),G=n.memo((()=>{const[t,r]=o.useTick(),{modalIds:i,setUpdater:s}=W();n.useEffect((()=>{s(r)}),[s,r]);const{options:a}=se(),l=P(t);return e.jsx("div",{className:U,style:{transitionDuration:a.duration,backgroundColor:l?a.backdrop:"transparent"},children:i.map((n=>e.jsx(B,{modalId:n},n)))})}));function J(){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:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:J}),Q=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:J}),X=({children:n})=>e.jsx("h2",{className:K,children:n}),Z=({children:n})=>e.jsx("h3",{className:K,children:n}),ee=({children:n})=>e.jsx("div",{className:K,children:n}),ne=({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||"취소"})]}),te=n.forwardRef((({id:t,onChangeOrder:o,children:r},i)=>{const s=P(),[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:Q,onClick:o,style:{marginBottom:`calc(25vh + ${a}px)`,marginLeft:`${a}px`,transform:`translate(${l}px, ${l}px)`},children:r})})),oe=()=>{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}},re=n.createContext({ForegroundComponent:te,TitleComponent:X,SubtitleComponent:Z,ContentComponent:ee,FooterComponent:ne,options:{duration:u,backdrop:d,manualDestroy:!1,closeOnBackdropClick:!0}}),ie=n.memo((({ForegroundComponent:r,BackgroundComponent:i,TitleComponent:s,SubtitleComponent:a,ContentComponent:l,FooterComponent:m,options:p,usePathname:f,children:b})=>{const{pathname:h}=(f||oe)(),[,C]=o.useTick(),y=n.useRef(null);o.useOnMount((()=>(y.current=c.anchor("div"),C(),()=>{y.current&&y.current.remove()})));const v=n.useMemo((()=>({BackgroundComponent:i,ForegroundComponent:r||te,TitleComponent:s||X,SubtitleComponent:a||Z,ContentComponent:n.memo(l||ee),FooterComponent:n.memo(m||ne),options:{duration:u,backdrop:d,closeOnBackdropClick:!0,manualDestroy:!1,...p}})),[r,i,l,m,a,s,p]);return e.jsxs(re.Provider,{value:v,children:[b,y.current&&t.createPortal(e.jsx(A,{pathname:h,children:e.jsx(G,{})}),y.current)]})})),se=()=>n.useContext(re),ae=()=>{const{options:e}=n.useContext(re);return e};exports.ModalProvider=ie,exports.alert=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a})=>new Promise(((l,u)=>{try{c.open({type:"alert",subtype:e,resolve:()=>l(),title:n,subtitle:t,content:o,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a})}catch(e){u(e)}})),exports.confirm=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a})=>new Promise(((l,u)=>{try{c.open({type:"confirm",subtype:e,resolve:e=>l(e??!1),title:n,subtitle:t,content:o,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a})}catch(e){u(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})=>new Promise(((m,p)=>{try{c.open({type:"prompt",resolve:e=>m(e),title:n,subtitle:t,content:o,Input:({defaultValue:e,onChange:n,onConfirm:t})=>r({defaultValue:e,onChange:n,onConfirm:t}),defaultValue:e,disabled:i,returnOnCancel:s,background:a,footer:l,manualDestroy:u,closeOnBackdropClick:d})}catch(e){p(e)}})),exports.useDestroyAfter=(e,t)=>{const{modal:o,onDestroy:i}=Y(e),s=O(o),a=n.useRef({modal:o,onDestroy:i,milliseconds:r.isString(t)?$(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}=ae();return e},exports.useModalDuration=()=>{const{duration:e}=ae();return{duration:e,milliseconds:$(e)}},exports.useModalOptions=ae,exports.useSubscribeModal=O;
|
|
18
18
|
//# sourceMappingURL=index.cjs.js.map
|