@lerx/promise-modal 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Background/Background.d.ts.map +1 -1
- package/dist/components/Foreground/Foreground.d.ts.map +1 -1
- package/dist/core/handle/alert.d.ts +4 -2
- package/dist/core/handle/alert.d.ts.map +1 -1
- package/dist/core/handle/confirm.d.ts +4 -2
- package/dist/core/handle/confirm.d.ts.map +1 -1
- package/dist/core/handle/prompt.d.ts +4 -2
- package/dist/core/handle/prompt.d.ts.map +1 -1
- package/dist/core/node/ModalNode/AbstractBaseNode.d.ts +4 -2
- package/dist/core/node/ModalNode/AbstractBaseNode.d.ts.map +1 -1
- package/dist/core/node/ModalNode/AlertNode.d.ts +1 -1
- package/dist/core/node/ModalNode/AlertNode.d.ts.map +1 -1
- package/dist/core/node/ModalNode/ConfirmNode.d.ts +1 -1
- package/dist/core/node/ModalNode/ConfirmNode.d.ts.map +1 -1
- package/dist/core/node/ModalNode/PromptNode.d.ts +1 -1
- package/dist/core/node/ModalNode/PromptNode.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 +3 -3
- package/dist/providers/ModalContext/ModalContext.d.ts.map +1 -1
- package/dist/types/base.d.ts +6 -1
- package/dist/types/base.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Background.d.ts","sourceRoot":"","sources":["../../../src/components/Background/Background.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,eAAO,MAAM,UAAU,+BAAgC,eAAe,
|
|
1
|
+
{"version":3,"file":"Background.d.ts","sourceRoot":"","sources":["../../../src/components/Background/Background.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,eAAO,MAAM,UAAU,+BAAgC,eAAe,mDA8CrE,CAAC"}
|
|
@@ -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":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,eAAO,MAAM,UAAU,+BAAgC,eAAe,mDAiDrE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import type { AlertContentProps, AlertFooterRender, FooterOptions, ModalBackground } from '../../types';
|
|
2
|
+
import type { AlertContentProps, AlertFooterRender, BackgroundComponent, FooterOptions, ForegroundComponent, ModalBackground } from '../../types';
|
|
3
3
|
interface AlertProps<B> {
|
|
4
4
|
subtype?: 'info' | 'success' | 'warning' | 'error';
|
|
5
5
|
title?: ReactNode;
|
|
@@ -9,7 +9,9 @@ interface AlertProps<B> {
|
|
|
9
9
|
footer?: AlertFooterRender | Pick<FooterOptions, 'confirm' | 'hideConfirm'> | false;
|
|
10
10
|
manualDestroy?: boolean;
|
|
11
11
|
closeOnBackdropClick?: boolean;
|
|
12
|
+
ForegroundComponent?: ForegroundComponent;
|
|
13
|
+
BackgroundComponent?: BackgroundComponent;
|
|
12
14
|
}
|
|
13
|
-
export declare const alert: <B = any>({ subtype, title, subtitle, content, background, footer, manualDestroy, closeOnBackdropClick, }: AlertProps<B>) => Promise<void>;
|
|
15
|
+
export declare const alert: <B = any>({ subtype, title, subtitle, content, background, footer, manualDestroy, closeOnBackdropClick, ForegroundComponent, BackgroundComponent, }: AlertProps<B>) => Promise<void>;
|
|
14
16
|
export {};
|
|
15
17
|
//# sourceMappingURL=alert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../../src/core/handle/alert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAE/B,UAAU,UAAU,CAAC,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACnD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACvD,UAAU,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,EACH,iBAAiB,GACjB,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,aAAa,CAAC,GAC9C,KAAK,CAAC;IACV,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../../src/core/handle/alert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAE/B,UAAU,UAAU,CAAC,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACnD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACvD,UAAU,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,EACH,iBAAiB,GACjB,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,aAAa,CAAC,GAC9C,KAAK,CAAC;IACV,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,KAAK,GAAI,CAAC,mJAWpB,UAAU,CAAC,CAAC,CAAC,kBAqBf,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import type { ConfirmContentProps, ConfirmFooterRender, FooterOptions, ModalBackground } from '../../types';
|
|
2
|
+
import type { BackgroundComponent, ConfirmContentProps, ConfirmFooterRender, FooterOptions, ForegroundComponent, ModalBackground } from '../../types';
|
|
3
3
|
interface ConfirmProps<B> {
|
|
4
4
|
subtype?: 'info' | 'success' | 'warning' | 'error';
|
|
5
5
|
title?: ReactNode;
|
|
@@ -9,7 +9,9 @@ interface ConfirmProps<B> {
|
|
|
9
9
|
footer?: ConfirmFooterRender | FooterOptions | false;
|
|
10
10
|
closeOnBackdropClick?: boolean;
|
|
11
11
|
manualDestroy?: boolean;
|
|
12
|
+
ForegroundComponent?: ForegroundComponent;
|
|
13
|
+
BackgroundComponent?: BackgroundComponent;
|
|
12
14
|
}
|
|
13
|
-
export declare const confirm: <B = any>({ subtype, title, subtitle, content, background, footer, manualDestroy, closeOnBackdropClick, }: ConfirmProps<B>) => Promise<boolean>;
|
|
15
|
+
export declare const confirm: <B = any>({ subtype, title, subtitle, content, background, footer, manualDestroy, closeOnBackdropClick, ForegroundComponent, BackgroundComponent, }: ConfirmProps<B>) => Promise<boolean>;
|
|
14
16
|
export {};
|
|
15
17
|
//# sourceMappingURL=confirm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm.d.ts","sourceRoot":"","sources":["../../../src/core/handle/confirm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAE/B,UAAU,YAAY,CAAC,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACnD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,mBAAmB,CAAC,CAAC;IACzD,UAAU,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,mBAAmB,GAAG,aAAa,GAAG,KAAK,CAAC;IACrD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"confirm.d.ts","sourceRoot":"","sources":["../../../src/core/handle/confirm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAE/B,UAAU,YAAY,CAAC,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACnD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,mBAAmB,CAAC,CAAC;IACzD,UAAU,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,mBAAmB,GAAG,aAAa,GAAG,KAAK,CAAC;IACrD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C;AAED,eAAO,MAAM,OAAO,GAAI,CAAC,mJAWtB,YAAY,CAAC,CAAC,CAAC,qBAqBjB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import type { FooterOptions, ModalBackground, PromptContentProps, PromptFooterRender, PromptInputProps } from '../../types';
|
|
2
|
+
import type { BackgroundComponent, FooterOptions, ForegroundComponent, ModalBackground, PromptContentProps, PromptFooterRender, PromptInputProps } from '../../types';
|
|
3
3
|
interface PromptProps<T, B = any> {
|
|
4
4
|
title?: ReactNode;
|
|
5
5
|
subtitle?: ReactNode;
|
|
@@ -12,7 +12,9 @@ interface PromptProps<T, B = any> {
|
|
|
12
12
|
footer?: PromptFooterRender<T> | FooterOptions | false;
|
|
13
13
|
manualDestroy?: boolean;
|
|
14
14
|
closeOnBackdropClick?: boolean;
|
|
15
|
+
ForegroundComponent?: ForegroundComponent;
|
|
16
|
+
BackgroundComponent?: BackgroundComponent;
|
|
15
17
|
}
|
|
16
|
-
export declare const prompt: <T, B = any>({ defaultValue, title, subtitle, content, Input, disabled, returnOnCancel, background, footer, manualDestroy, closeOnBackdropClick, }: PromptProps<T, B>) => Promise<T>;
|
|
18
|
+
export declare const prompt: <T, B = any>({ defaultValue, title, subtitle, content, Input, disabled, returnOnCancel, background, footer, manualDestroy, closeOnBackdropClick, ForegroundComponent, BackgroundComponent, }: PromptProps<T, B>) => Promise<T>;
|
|
17
19
|
export {};
|
|
18
20
|
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -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,aAAa,EACb,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;
|
|
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,eA6BnB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { Fn } from '../../../@aileron/types';
|
|
3
|
-
import type { BaseModal, ManagedEntity, ModalBackground } from '../../../types';
|
|
3
|
+
import type { BackgroundComponent, BaseModal, ForegroundComponent, ManagedEntity, ModalBackground } from '../../../types';
|
|
4
4
|
type BaseNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;
|
|
5
5
|
export declare abstract class BaseNode<T, B> {
|
|
6
6
|
#private;
|
|
@@ -11,9 +11,11 @@ export declare abstract class BaseNode<T, B> {
|
|
|
11
11
|
readonly background?: ModalBackground<B>;
|
|
12
12
|
readonly manualDestroy: boolean;
|
|
13
13
|
readonly closeOnBackdropClick: boolean;
|
|
14
|
+
readonly ForegroundComponent?: ForegroundComponent;
|
|
15
|
+
readonly BackgroundComponent?: BackgroundComponent;
|
|
14
16
|
get alive(): boolean;
|
|
15
17
|
get visible(): boolean;
|
|
16
|
-
constructor({ id, initiator, title, subtitle, background, manualDestroy, closeOnBackdropClick, resolve, }: BaseNodeProps<T, B>);
|
|
18
|
+
constructor({ id, initiator, title, subtitle, background, manualDestroy, closeOnBackdropClick, resolve, ForegroundComponent, BackgroundComponent, }: BaseNodeProps<T, B>);
|
|
17
19
|
subscribe(listener: Fn): () => void;
|
|
18
20
|
publish(): void;
|
|
19
21
|
protected resolve(result: T | null): void;
|
|
@@ -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,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,CAA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;IAiBtB,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"}
|
|
@@ -7,7 +7,7 @@ export declare class AlertNode<B> extends BaseNode<null, B> {
|
|
|
7
7
|
readonly subtype?: 'info' | 'success' | 'warning' | 'error';
|
|
8
8
|
readonly content?: ReactNode | ComponentType<AlertContentProps>;
|
|
9
9
|
readonly footer?: AlertFooterRender | Pick<FooterOptions, 'confirm' | 'hideConfirm'> | false;
|
|
10
|
-
constructor({ id, initiator, type, subtype, title, subtitle, content, footer, background, manualDestroy, closeOnBackdropClick, resolve, }: AlertNodeProps<B>);
|
|
10
|
+
constructor({ id, initiator, type, subtype, title, subtitle, content, footer, background, manualDestroy, closeOnBackdropClick, resolve, ForegroundComponent, BackgroundComponent, }: AlertNodeProps<B>);
|
|
11
11
|
onClose(): void;
|
|
12
12
|
onConfirm(): void;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertNode.d.ts","sourceRoot":"","sources":["../../../../src/core/node/ModalNode/AlertNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,KAAK,cAAc,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;AAEvD,qBAAa,SAAS,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;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AC,aAAa,EAAE,SAAS,GAAG,aAAa,CAAC,GAC9C,KAAK,CAAC;gBAEE,EACV,EAAE,EACF,SAAS,EACT,IAAI,EACJ,OAAO,EACP,KAAK,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACnB,mBAAmB,GACpB,EAAE,cAAc,CAAC,CAAC,CAAC;IAkBpB,OAAO;IAGP,SAAS;CAGV"}
|
|
@@ -7,7 +7,7 @@ export declare class ConfirmNode<B> extends BaseNode<boolean, B> {
|
|
|
7
7
|
readonly subtype?: 'info' | 'success' | 'warning' | 'error';
|
|
8
8
|
readonly content?: ReactNode | ComponentType<ConfirmContentProps>;
|
|
9
9
|
readonly footer?: ConfirmFooterRender | FooterOptions | false;
|
|
10
|
-
constructor({ id, initiator, type, subtype, title, subtitle, content, footer, background, manualDestroy, closeOnBackdropClick, resolve, }: ConfirmNodeProps<B>);
|
|
10
|
+
constructor({ id, initiator, type, subtype, title, subtitle, content, footer, background, manualDestroy, closeOnBackdropClick, resolve, ForegroundComponent, BackgroundComponent, }: ConfirmNodeProps<B>);
|
|
11
11
|
onClose(): void;
|
|
12
12
|
onConfirm(): void;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmNode.d.ts","sourceRoot":"","sources":["../../../../src/core/node/ModalNode/ConfirmNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,KAAK,gBAAgB,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;AAE3D,qBAAa,WAAW,C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AE,mBAAmB,GAAG,aAAa,GAAG,KAAK,CAAC;gBAElD,EACV,EAAE,EACF,SAAS,EACT,IAAI,EACJ,OAAO,EACP,KAAK,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACnB,mBAAmB,GACpB,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAkBtB,OAAO;IAGP,SAAS;CAGV"}
|
|
@@ -11,7 +11,7 @@ export declare class PromptNode<T, B> extends BaseNode<T, B> {
|
|
|
11
11
|
readonly disabled?: (value: T) => boolean;
|
|
12
12
|
readonly returnOnCancel?: boolean;
|
|
13
13
|
readonly footer?: PromptFooterRender<T> | FooterOptions | false;
|
|
14
|
-
constructor({ id, initiator, type, title, subtitle, content, defaultValue, Input, disabled, returnOnCancel, footer, background, manualDestroy, closeOnBackdropClick, resolve, }: PromptNodeProps<T, B>);
|
|
14
|
+
constructor({ id, initiator, type, title, subtitle, content, defaultValue, Input, disabled, returnOnCancel, footer, background, manualDestroy, closeOnBackdropClick, resolve, ForegroundComponent, BackgroundComponent, }: PromptNodeProps<T, B>);
|
|
15
15
|
onChange(value: T): void;
|
|
16
16
|
onConfirm(): void;
|
|
17
17
|
onClose(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptNode.d.ts","sourceRoot":"","sources":["../../../../src/core/node/ModalNode/PromptNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,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CAAC;AAE/D,qBAAa,UAAU,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;;IAClD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACjE,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IAC1D,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IAC1C,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,KAAK,CAAC;gBAGpD,EACV,EAAE,EACF,SAAS,EACT,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,cAAc,EACd,MAAM,EACN,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACnB,mBAAmB,GACpB,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;IAuBxB,QAAQ,CAAC,KAAK,EAAE,CAAC;IAGjB,SAAS;IAGT,OAAO;CAIR"}
|
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"),o=require("react-dom"),t=require("@winglet/react-utils"),r=require("@winglet/common-utils"),i=require("@emotion/css");const s={current:[]},a={current:e=>{s.current.push(e)}},l={current:null},c={get prerender(){return s.current},clearPrerender(){s.current=[]},open(e){a.current(e)},setupOpen(e){a.current=e},anchor(e,n="promise-modal"){if(l.current){const e=document.getElementById(l.current.id);if(e)return e}const o=document.createElement(e);return o.setAttribute("id",`${n}-${r.getRandomString(36)}`),document.body.appendChild(o),l.current=o,o}},u="300ms",d="rgba(0, 0, 0, 0.5)";function m(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const p=i.css("production"===process.env.NODE_ENV?{name:"u7uu4v",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;}"}:{name:"coymdj-background",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;};label:background;",toString:m}),f=i.css("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:m}),b=i.css("production"===process.env.NODE_ENV?{name:"1wnowod",styles:"display:flex;align-items:center;justify-content:center"}:{name:"xppew7-visible",styles:"display:flex;align-items:center;justify-content:center;label:visible;",toString:m}),h=({modalId:o,onChangeOrder:t})=>{const{BackgroundComponent:r}=ae(),{modal:s,onClose:a,onChange:l,onConfirm:c,onDestroy:u}=U(o),d=n.useCallback((e=>{s&&s.closeOnBackdropClick&&s.visible&&a(),e.stopPropagation()}),[s,a]),m=n.useMemo((()=>s?.BackgroundComponent||r),[r,s]);return s?e.jsx("div",{className:i.cx(p,{[b]:s.manualDestroy?s.alive:s.visible,[f]:s.closeOnBackdropClick&&s.visible}),onClick:d,children:m&&e.jsx(m,{id:s.id,type:s.type,alive:s.alive,visible:s.visible,initiator:s.initiator,manualDestroy:s.manualDestroy,closeOnBackdropClick:s.closeOnBackdropClick,background:s.background,onChange:l,onConfirm:c,onClose:a,onDestroy:u,onChangeOrder:t})}):null};function C(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const g=i.css("production"===process.env.NODE_ENV?{name:"12g0hx0",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1"}:{name:"1hcczik-foreground",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1;label:foreground;",toString:C}),y=i.css("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:C}),v=i.css("production"===process.env.NODE_ENV?{name:"1fmljv2",styles:"display:flex!important;justify-content:center;align-items:center"}:{name:"1p4unab-visible",styles:"display:flex!important;justify-content:center;align-items:center;label:visible;",toString:C}),k=n.memo((({modal:o,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>o),[o]),{onConfirm:u}=n.useMemo((()=>i),[i]),d=t.useHandle(u),{TitleComponent:m,SubtitleComponent:p,ContentComponent:f,FooterComponent:b}=ae();return e.jsxs(n.Fragment,{children:[s&&(r.isString(s)?e.jsx(m,{children:s}):s),a&&(r.isString(a)?e.jsx(p,{children:a}):a),l&&(r.isString(l)?e.jsx(f,{children:l}):t.renderComponent(l,{onConfirm:d})),!1!==c&&("function"==typeof c?c({onConfirm:d}):e.jsx(b,{onConfirm:d,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm}))]})})),x=n.memo((({modal:o,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>o),[o]),{onConfirm:u,onClose:d}=n.useMemo((()=>i),[i]),m=t.useHandle(u),p=t.useHandle(d),{TitleComponent:f,SubtitleComponent:b,ContentComponent:h,FooterComponent:C}=ae();return e.jsxs(n.Fragment,{children:[s&&(r.isString(s)?e.jsx(f,{children:s}):s),a&&(r.isString(a)?e.jsx(b,{children:a}):a),l&&(r.isString(l)?e.jsx(h,{children:l}):t.renderComponent(l,{onConfirm:m,onCancel:p})),!1!==c&&("function"==typeof c?c({onConfirm:m,onCancel:p}):e.jsx(C,{onConfirm:m,onCancel:p,confirmLabel:c?.confirm,cancelLabel:c?.cancel,hideConfirm:c?.hideConfirm,hideCancel:c?.hideCancel}))]})})),j=n.memo((({modal:o,handlers:i})=>{const{Input:s,defaultValue:a,disabled:l,title:c,subtitle:u,content:d,footer:m}=n.useMemo((()=>({...o,Input:n.memo(t.withErrorBoundary(o.Input))})),[o]),[p,f]=n.useState(a),{onChange:b,onClose:h,onConfirm:C}=n.useMemo((()=>i),[i]),g=t.useHandle(h),y=t.useHandle((e=>{const n=r.isFunction(e)?e(p):e;f(n),b(n)})),v=n.useCallback((()=>{setTimeout((()=>{C()}))}),[C]),k=n.useMemo((()=>!!p&&!!l?.(p)),[l,p]),{TitleComponent:x,SubtitleComponent:j,ContentComponent:O,FooterComponent:w}=ae();return e.jsxs(n.Fragment,{children:[c&&(r.isString(c)?e.jsx(x,{children:c}):c),u&&(r.isString(u)?e.jsx(j,{children:u}):u),d&&(r.isString(d)?e.jsx(O,{children:d}):t.renderComponent(d,{onConfirm:v,onCancel:g})),s&&e.jsx(s,{defaultValue:a,value:p,onChange:y,onConfirm:v}),!1!==m&&("function"==typeof m?m({onConfirm:v,onCancel:g,onChange:y,value:p,disabled:k}):e.jsx(w,{onConfirm:v,onCancel:g,disabled:k,confirmLabel:m?.confirm,cancelLabel:m?.cancel,hideConfirm:m?.hideConfirm,hideCancel:m?.hideCancel}))]})})),O=({modalId:o,onChangeOrder:t})=>{const{ForegroundComponent:r}=ae(),{modal:s,onChange:a,onConfirm:l,onClose:c,onDestroy:u}=U(o),d=n.useMemo((()=>s?.ForegroundComponent||r),[r,s]);return s?e.jsx("div",{className:i.cx(g,{[v]:s.manualDestroy?s.alive:s.visible,[y]:s.visible}),children:e.jsxs(d,{id:s.id,type:s.type,alive:s.alive,visible:s.visible,initiator:s.initiator,manualDestroy:s.manualDestroy,closeOnBackdropClick:s.closeOnBackdropClick,background:s.background,onChange:a,onConfirm:l,onClose:c,onDestroy:u,onChangeOrder:t,children:["alert"===s.type&&e.jsx(k,{modal:s,handlers:{onConfirm:l}}),"confirm"===s.type&&e.jsx(x,{modal:s,handlers:{onConfirm:l,onClose:c}}),"prompt"===s.type&&e.jsx(j,{modal:s,handlers:{onChange:a,onConfirm:l,onClose:c}})]})}):null},w=e=>{const[n,o]=t.useTick();return t.useOnMount((()=>{if(e)return e.subscribe(o)})),n},D=i.css("production"===process.env.NODE_ENV?{name:"13dmkf4",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden"}:{name:"yjeu12-presenter",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden;label:presenter;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}});let B=1;const F=n.memo((({modalId:o})=>{const r=n.useRef(null),{modal:i}=U(o);w(i);const s=t.useHandle((()=>{r.current&&(r.current.style.zIndex=""+B++)}));return e.jsxs("div",{ref:r,className:D,children:[e.jsx(h,{modalId:o,onChangeOrder:s}),e.jsx(O,{modalId:o,onChangeOrder:s})]})})),P=(e=0)=>{const{modalIds:o,getModalNode:t}=Y();return n.useMemo((()=>{let e=0;for(const n of o)t(n)?.visible&&e++;return e}),[t,o,e])};
|
|
2
2
|
/******************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -14,5 +14,5 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
16
|
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
17
|
-
function P(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 S(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 M,F,I,V,T;"function"==typeof SuppressedError&&SuppressedError;class L{get alive(){return P(this,M,"f")}get visible(){return P(this,F,"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}),M.set(this,void 0),F.set(this,void 0),I.set(this,void 0),V.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.manualDestroy=i,this.closeOnBackdropClick=s,S(this,M,!0,"f"),S(this,F,!0,"f"),S(this,I,a,"f")}subscribe(e){return P(this,V,"f").push(e),()=>{S(this,V,P(this,V,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of P(this,V,"f"))e()}resolve(e){P(this,I,"f").call(this,e)}onDestroy(){const e=!0===P(this,M,"f");S(this,M,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===P(this,F,"f");S(this,F,!0,"f"),e&&this.publish()}onHide(){const e=!0===P(this,F,"f");S(this,F,!1,"f"),e&&this.publish()}}M=new WeakMap,F=new WeakMap,I=new WeakMap,V=new WeakMap;class R extends L{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 _ extends L{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 L{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,S(this,T,s,"f"),this.disabled=l,this.returnOnCancel=c,this.footer=u}onChange(e){S(this,T,e,"f")}onConfirm(){this.resolve(P(this,T,"f")??null)}onClose(){this.returnOnCancel?this.resolve(P(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,t]=e.match(z)||[];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},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: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=le(),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(A.Provider,{value:x,children:r})})),Y=()=>n.useContext(A),U=e=>{const{getModal:t}=Y();return n.useMemo((()=>t(e)),[e,t])},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(o.withErrorBoundary((()=>{const[t,r]=o.useTick(),{modalIds:i,setUpdater:s}=Y();n.useEffect((()=>{s(r)}),[s,r]);const{options:a}=ae(),l=N(t);return e.jsx("div",{className:G,style:{transitionDuration:a.duration,backgroundColor:l?a.backdrop:"transparent"},children:i.map((n=>e.jsx(E,{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}),te=({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||"취소"})]}),oe=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:X,onClick:o,style:{marginBottom:`calc(25vh + ${a}px)`,marginLeft:`${a}px`,transform:`translate(${l}px, ${l}px)`},children:r})})),re=()=>{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}},ie=n.createContext({ForegroundComponent:oe,TitleComponent:Z,SubtitleComponent:ee,ContentComponent:ne,FooterComponent:te,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]=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||oe,TitleComponent:s||Z,SubtitleComponent:a||ee,ContentComponent:n.memo(l||ne),FooterComponent:n.memo(m||te),options:{duration:u,backdrop:d,closeOnBackdropClick:!0,manualDestroy:!1,...p}})),[r,i,l,m,a,s,p]);return e.jsxs(ie.Provider,{value:v,children:[b,y.current&&t.createPortal(e.jsx(W,{pathname:h,children:e.jsx(J,{})}),y.current)]})})),ae=()=>n.useContext(ie),le=()=>{const{options:e}=n.useContext(ie);return e};exports.ModalProvider=se,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}=U(e),s=w(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}=le();return e},exports.useModalDuration=()=>{const{duration:e}=le();return{duration:e,milliseconds:$(e)}},exports.useModalOptions=le,exports.useSubscribeModal=w;
|
|
17
|
+
function E(e,n,o,t){if("a"===o&&!t)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!t:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?t:"a"===o?t.call(e):t?t.value:n.get(e)}function M(e,n,o,t,r){if("m"===t)throw new TypeError("Private method is not writable");if("a"===t&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof n?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===t?r.call(e,o):r?r.value=o:n.set(e,o),o}var N,S,I,V,T;"function"==typeof SuppressedError&&SuppressedError;class L{get alive(){return E(this,N,"f")}get visible(){return E(this,S,"f")}constructor({id:e,initiator:n,title:o,subtitle:t,background:r,manualDestroy:i=!1,closeOnBackdropClick:s=!0,resolve:a,ForegroundComponent:l,BackgroundComponent:c}){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"initiator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"title",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtitle",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"background",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualDestroy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"closeOnBackdropClick",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ForegroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BackgroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),N.set(this,void 0),S.set(this,void 0),I.set(this,void 0),V.set(this,[]),this.id=e,this.initiator=n,this.title=o,this.subtitle=t,this.background=r,this.manualDestroy=i,this.closeOnBackdropClick=s,this.ForegroundComponent=l,this.BackgroundComponent=c,M(this,N,!0,"f"),M(this,S,!0,"f"),M(this,I,a,"f")}subscribe(e){return E(this,V,"f").push(e),()=>{M(this,V,E(this,V,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of E(this,V,"f"))e()}resolve(e){E(this,I,"f").call(this,e)}onDestroy(){const e=!0===E(this,N,"f");M(this,N,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===E(this,S,"f");M(this,S,!0,"f"),e&&this.publish()}onHide(){const e=!0===E(this,S,"f");M(this,S,!1,"f"),e&&this.publish()}}N=new WeakMap,S=new WeakMap,I=new WeakMap,V=new WeakMap;class R extends L{constructor({id:e,initiator:n,type:o,subtype:t,title:r,subtitle:i,content:s,footer:a,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}){super({id:e,initiator:n,title:r,subtitle:i,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=o,this.subtype=t,this.content=s,this.footer=a}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class _ extends L{constructor({id:e,initiator:n,type:o,subtype:t,title:r,subtitle:i,content:s,footer:a,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}){super({id:e,initiator:n,title:r,subtitle:i,background:l,manualDestroy:c,closeOnBackdropClick:u,resolve:d,ForegroundComponent:m,BackgroundComponent:p}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=o,this.subtype=t,this.content=s,this.footer=a}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class q extends L{constructor({id:e,initiator:n,type:o,title:t,subtitle:r,content:i,defaultValue:s,Input:a,disabled:l,returnOnCancel:c,footer:u,background:d,manualDestroy:m,closeOnBackdropClick:p,resolve:f,ForegroundComponent:b,BackgroundComponent:h}){super({id:e,initiator:n,title:t,subtitle:r,background:d,manualDestroy:m,closeOnBackdropClick:p,resolve:f,ForegroundComponent:b,BackgroundComponent:h}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"Input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"returnOnCancel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),T.set(this,void 0),this.type=o,this.content=i,this.Input=a,this.defaultValue=s,M(this,T,s,"f"),this.disabled=l,this.returnOnCancel=c,this.footer=u}onChange(e){M(this,T,e,"f")}onConfirm(){this.resolve(E(this,T,"f")??null)}onClose(){this.returnOnCancel?this.resolve(E(this,T,"f")??null):this.resolve(null)}}T=new WeakMap;const H=e=>{switch(e.type){case"alert":return new R(e);case"confirm":return new _(e);case"prompt":return new q(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},z=/^\s*(\d+)\s*(ms|s|m|h)\s*$/,$=e=>{const[,n,o]=e.match(z)||[];if(!n||!o)return 0;const t=parseInt(n);return"ms"===o?t:"s"===o?1e3*t:"m"===o?60*t*1e3:"h"===o?60*t*60*1e3:0},A=n.createContext({modalIds:[],getModalNode:r.undefinedFunction,onChange:r.undefinedFunction,onConfirm:r.undefinedFunction,onClose:r.undefinedFunction,onDestroy:r.undefinedFunction,setUpdater:r.undefinedFunction,getModal:()=>({modal:void 0,onConfirm:r.undefinedFunction,onClose:r.undefinedFunction,onChange:r.undefinedFunction,onDestroy:r.undefinedFunction})}),W=n.memo((({pathname:o,children:r})=>{const i=n.useRef(new Map),[s,a]=n.useState([]),l=t.useReference(s),u=n.useRef(o),d=n.useRef(0),m=le(),p=n.useMemo((()=>$(m.duration)),[m]);t.useOnMountLayout((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=m;for(const o of c.prerender){const t=H({...o,id:d.current++,initiator:u.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});i.current.set(t.id,t),a((e=>[...e,t.id]))}c.setupOpen((o=>{const t=H({...o,id:d.current++,initiator:u.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});i.current.set(t.id,t),a((e=>[...e.filter((e=>{const n=!i.current.get(e)?.alive;return n&&i.current.delete(e),!n})),t.id]))})),c.clearPrerender()})),n.useLayoutEffect((()=>{for(const e of l.current){const n=i.current.get(e);n?.alive&&(n.initiator===o?n.onShow():n.onHide())}u.current=o}),[l,o]);const f=n.useCallback((e=>i.current.get(e)),[]),b=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onDestroy(),h.current?.())}),[]),h=n.useRef(),C=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onHide(),h.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),p))}),[p]),g=n.useCallback(((e,n)=>{const o=i.current.get(e);o&&"prompt"===o.type&&o.onChange(n)}),[]),y=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onConfirm(),C(e))}),[C]),v=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onClose(),C(e))}),[C]),k=n.useCallback((e=>({modal:f(e),onConfirm:()=>y(e),onClose:()=>v(e),onChange:n=>g(e,n),onDestroy:()=>b(e)})),[f,y,v,g,b]),x=n.useMemo((()=>({modalIds:s,getModalNode:f,onChange:g,onConfirm:y,onClose:v,onDestroy:b,getModal:k,setUpdater:e=>{h.current=e}})),[s,k,f,g,y,v,b]);return e.jsx(A.Provider,{value:x,children:r})})),Y=()=>n.useContext(A),U=e=>{const{getModal:o}=Y();return n.useMemo((()=>o(e)),[e,o])},G=i.css("production"===process.env.NODE_ENV?{name:"2hpasy",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out"}:{name:"lhj8co-anchor",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out;label:anchor;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),J=n.memo(t.withErrorBoundary((()=>{const[o,r]=t.useTick(),{modalIds:i,setUpdater:s}=Y();n.useEffect((()=>{s(r)}),[s,r]);const{options:a}=ae(),l=P(o);return e.jsx("div",{className:G,style:{transitionDuration:a.duration,backgroundColor:l?a.backdrop:"transparent"},children:i.map((n=>e.jsx(F,{modalId:n},n)))})})));function K(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const Q=i.css("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:K}),X=i.css("production"===process.env.NODE_ENV?{name:"1kuk3a3",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black"}:{name:"16dbbea-frame",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black;label:frame;",toString:K}),Z=({children:n})=>e.jsx("h2",{className:Q,children:n}),ee=({children:n})=>e.jsx("h3",{className:Q,children:n}),ne=({children:n})=>e.jsx("div",{className:Q,children:n}),oe=({confirmLabel:n,hideConfirm:o=!1,cancelLabel:t,hideCancel:r=!1,disabled:i,onConfirm:s,onCancel:a})=>e.jsxs("div",{children:[!o&&e.jsx("button",{onClick:s,disabled:i,children:n||"확인"}),!r&&"function"==typeof a&&e.jsx("button",{onClick:a,children:t||"취소"})]}),te=n.forwardRef((({id:o,onChangeOrder:t,children:r},i)=>{const s=P(),[a,l]=n.useMemo((()=>{const e=s>1;return[e?Math.floor(o/5)%3*100:0,e?o%5*35:0]}),[s,o]);return e.jsx("div",{ref:i,className:X,onClick:t,style:{marginBottom:`calc(25vh + ${a}px)`,marginLeft:`${a}px`,transform:`translate(${l}px, ${l}px)`},children:r})})),re=()=>{const[e,o]=n.useState(window.location.pathname);return n.useLayoutEffect((()=>{let n;const t=()=>{n&&cancelAnimationFrame(n),e!==window.location.pathname?o(window.location.pathname):n=requestAnimationFrame(t)};return n=requestAnimationFrame(t),()=>{n&&cancelAnimationFrame(n)}}),[e]),{pathname:e}},ie=n.createContext({ForegroundComponent:te,TitleComponent:Z,SubtitleComponent:ee,ContentComponent:ne,FooterComponent:oe,options:{duration:u,backdrop:d,manualDestroy:!1,closeOnBackdropClick:!0}}),se=n.memo((({ForegroundComponent:r,BackgroundComponent:i,TitleComponent:s,SubtitleComponent:a,ContentComponent:l,FooterComponent:m,options:p,usePathname:f,children:b})=>{const{pathname:h}=(f||re)(),[,C]=t.useTick(),g=n.useRef(null);t.useOnMount((()=>(g.current=c.anchor("div"),C(),()=>{g.current&&g.current.remove()})));const y=n.useMemo((()=>({BackgroundComponent:i,ForegroundComponent:r||te,TitleComponent:s||Z,SubtitleComponent:a||ee,ContentComponent:n.memo(l||ne),FooterComponent:n.memo(m||oe),options:{duration:u,backdrop:d,closeOnBackdropClick:!0,manualDestroy:!1,...p}})),[r,i,l,m,a,s,p]);return e.jsxs(ie.Provider,{value:y,children:[b,g.current&&o.createPortal(e.jsx(W,{pathname:h,children:e.jsx(J,{})}),g.current)]})})),ae=()=>n.useContext(ie),le=()=>{const{options:e}=n.useContext(ie);return e};exports.ModalProvider=se,exports.alert=({subtype:e,title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})=>new Promise(((d,m)=>{try{c.open({type:"alert",subtype:e,resolve:()=>d(),title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})}catch(e){m(e)}})),exports.confirm=({subtype:e,title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})=>new Promise(((d,m)=>{try{c.open({type:"confirm",subtype:e,resolve:e=>d(e??!1),title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:s,closeOnBackdropClick:a,ForegroundComponent:l,BackgroundComponent:u})}catch(e){m(e)}})),exports.prompt=({defaultValue:e,title:n,subtitle:o,content:t,Input:r,disabled:i,returnOnCancel:s,background:a,footer:l,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})=>new Promise(((f,b)=>{try{c.open({type:"prompt",resolve:e=>f(e),title:n,subtitle:o,content:t,Input:({defaultValue:e,onChange:n,onConfirm:o})=>r({defaultValue:e,onChange:n,onConfirm:o}),defaultValue:e,disabled:i,returnOnCancel:s,background:a,footer:l,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})}catch(e){b(e)}})),exports.useDestroyAfter=(e,o)=>{const{modal:t,onDestroy:i}=U(e),s=w(t),a=n.useRef({modal:t,onDestroy:i,milliseconds:r.isString(o)?$(o):o});n.useEffect((()=>{const{modal:e,onDestroy:n,milliseconds:o}=a.current;if(!e||e.visible||!e.alive)return;const t=setTimeout((()=>{n()}),o);return()=>{t&&clearTimeout(t)}}),[s])},exports.useModalBackdrop=()=>{const{backdrop:e}=le();return e},exports.useModalDuration=()=>{const{duration:e}=le();return{duration:e,milliseconds:$(e)}},exports.useModalOptions=le,exports.useSubscribeModal=w;
|
|
18
18
|
//# sourceMappingURL=index.cjs.js.map
|