@lerx/promise-modal 0.0.33 → 0.0.35
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/app/ModalManager.d.ts +15 -7
- package/dist/app/ModalManager.d.ts.map +1 -1
- package/dist/bootstrap/BootstrapProvider/BootstrapProvider.d.ts +11 -0
- package/dist/bootstrap/BootstrapProvider/BootstrapProvider.d.ts.map +1 -0
- package/dist/bootstrap/BootstrapProvider/index.d.ts +3 -0
- package/dist/bootstrap/BootstrapProvider/index.d.ts.map +1 -0
- package/dist/bootstrap/BootstrapProvider/type.d.ts +13 -0
- package/dist/bootstrap/BootstrapProvider/type.d.ts.map +1 -0
- package/dist/bootstrap/bootstrap.d.ts +12 -0
- package/dist/bootstrap/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap/index.d.ts +3 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/components/Anchor/Anchor.d.ts.map +1 -1
- package/dist/components/Background/Background.d.ts.map +1 -1
- package/dist/components/Foreground/Foreground.d.ts.map +1 -1
- package/dist/components/Foreground/components/AlertInner.d.ts.map +1 -1
- package/dist/components/Foreground/components/ConfirmInner.d.ts.map +1 -1
- package/dist/components/Foreground/components/PromptInner.d.ts.map +1 -1
- package/dist/core/handle/prompt.d.ts.map +1 -1
- package/dist/hooks/useActiveModalCount.d.ts.map +1 -1
- 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.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/providers/{ModalContext/ModalContext.d.ts → ConfigurationContext/ConfigurationContext.d.ts} +3 -3
- package/dist/providers/ConfigurationContext/ConfigurationContext.d.ts.map +1 -0
- package/dist/providers/{ModalContext/ModalContextProvider.d.ts → ConfigurationContext/ConfigurationContextProvider.d.ts} +4 -9
- package/dist/providers/ConfigurationContext/ConfigurationContextProvider.d.ts.map +1 -0
- package/dist/providers/ConfigurationContext/index.d.ts +3 -0
- package/dist/providers/ConfigurationContext/index.d.ts.map +1 -0
- package/dist/providers/ConfigurationContext/useConfigurationContext.d.ts +13 -0
- package/dist/providers/ConfigurationContext/useConfigurationContext.d.ts.map +1 -0
- package/dist/providers/{ModalDataContext/ModalDataContext.d.ts → ModalManagerContext/ModalManagerContext.d.ts} +3 -3
- package/dist/providers/ModalManagerContext/ModalManagerContext.d.ts.map +1 -0
- package/dist/providers/ModalManagerContext/ModalManagerContextProvider.d.ts +10 -0
- package/dist/providers/ModalManagerContext/ModalManagerContextProvider.d.ts.map +1 -0
- package/dist/providers/ModalManagerContext/index.d.ts +3 -0
- package/dist/providers/ModalManagerContext/index.d.ts.map +1 -0
- package/dist/providers/ModalManagerContext/useModalManagerContext.d.ts +4 -0
- package/dist/providers/ModalManagerContext/useModalManagerContext.d.ts.map +1 -0
- package/dist/providers/UserDefinedContext/UserDefinedContext.d.ts.map +1 -1
- package/dist/providers/UserDefinedContext/UserDefinedContextProvider.d.ts.map +1 -1
- package/dist/providers/index.d.ts +3 -2
- package/dist/providers/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/helpers/getMillisecondsFromDuration.d.ts +0 -2
- package/dist/helpers/getMillisecondsFromDuration.d.ts.map +0 -1
- package/dist/providers/ModalContext/ModalContext.d.ts.map +0 -1
- package/dist/providers/ModalContext/ModalContextProvider.d.ts.map +0 -1
- package/dist/providers/ModalContext/index.d.ts +0 -3
- package/dist/providers/ModalContext/index.d.ts.map +0 -1
- package/dist/providers/ModalContext/useModalContext.d.ts +0 -13
- package/dist/providers/ModalContext/useModalContext.d.ts.map +0 -1
- package/dist/providers/ModalDataContext/ModalDataContext.d.ts.map +0 -1
- package/dist/providers/ModalDataContext/ModalDataContextProvider.d.ts +0 -7
- package/dist/providers/ModalDataContext/ModalDataContextProvider.d.ts.map +0 -1
- package/dist/providers/ModalDataContext/index.d.ts +0 -3
- package/dist/providers/ModalDataContext/index.d.ts.map +0 -1
- package/dist/providers/ModalDataContext/useModalDataContext.d.ts +0 -4
- package/dist/providers/ModalDataContext/useModalDataContext.d.ts.map +0 -1
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import type { Fn } from '../@aileron/types';
|
|
1
2
|
import type { Modal } from '../types';
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
export declare class ModalManager {
|
|
4
|
+
#private;
|
|
5
|
+
static activate(): boolean;
|
|
6
|
+
static anchor(options?: {
|
|
7
|
+
tag?: string;
|
|
8
|
+
prefix?: string;
|
|
9
|
+
root?: HTMLElement;
|
|
10
|
+
}): HTMLElement;
|
|
11
|
+
static get prerender(): Modal[];
|
|
12
|
+
static set openHandler(handler: Fn<[Modal], void>);
|
|
13
|
+
static get unanchored(): boolean;
|
|
14
|
+
static reset(): void;
|
|
15
|
+
static open(modal: Modal): void;
|
|
16
|
+
}
|
|
9
17
|
//# sourceMappingURL=ModalManager.d.ts.map
|
|
@@ -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":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,qBAAa,YAAY;;IAEvB,MAAM,CAAC,QAAQ;IAMf,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;QACtB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,WAAW,CAAC;KACpB,GAAG,WAAW;IAkBf,MAAM,KAAK,SAAS,YAEnB;IAID,MAAM,KAAK,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAGhD;IAED,MAAM,KAAK,UAAU,YAEpB;IAED,MAAM,CAAC,KAAK;IAQZ,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK;CAGzB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BootstrapProviderHandle } from './type';
|
|
2
|
+
export declare const BootstrapProvider: import("react").ForwardRefExoticComponent<{
|
|
3
|
+
usePathname?: import("../../../@aileron/types").Fn<[], {
|
|
4
|
+
pathname: string;
|
|
5
|
+
}>;
|
|
6
|
+
context?: import("../../../@aileron/types").Dictionary;
|
|
7
|
+
root?: HTMLElement | null;
|
|
8
|
+
} & import("../../providers/ConfigurationContext").ConfigurationContextProviderProps & {
|
|
9
|
+
children?: import("react").ReactNode | undefined;
|
|
10
|
+
} & import("react").RefAttributes<BootstrapProviderHandle>>;
|
|
11
|
+
//# sourceMappingURL=BootstrapProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BootstrapProvider.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/BootstrapProvider/BootstrapProvider.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,uBAAuB,EAA0B,MAAM,QAAQ,CAAC;AAE9E,eAAO,MAAM,iBAAiB;;;;;;;;2DAsF7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/BootstrapProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,YAAY,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Dictionary, Fn } from '../../@aileron/types';
|
|
2
|
+
import type { ConfigurationContextProviderProps } from '../../providers/ConfigurationContext';
|
|
3
|
+
export type BootstrapProviderProps = {
|
|
4
|
+
usePathname?: Fn<[], {
|
|
5
|
+
pathname: string;
|
|
6
|
+
}>;
|
|
7
|
+
context?: Dictionary;
|
|
8
|
+
root?: HTMLElement | null;
|
|
9
|
+
} & ConfigurationContextProviderProps;
|
|
10
|
+
export interface BootstrapProviderHandle {
|
|
11
|
+
initialize: Fn<[HTMLElement]>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/BootstrapProvider/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gDAAgD,CAAC;AAExG,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC3B,GAAG,iCAAiC,CAAC;AAEtC,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;CAC/B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Dictionary, Fn } from '../@aileron/types';
|
|
2
|
+
import { type ConfigurationContextProviderProps } from '../providers/ConfigurationContext';
|
|
3
|
+
interface BootstrapProps extends ConfigurationContextProviderProps {
|
|
4
|
+
usePathname: Fn<[], {
|
|
5
|
+
pathname: string;
|
|
6
|
+
}>;
|
|
7
|
+
context?: Dictionary;
|
|
8
|
+
anchor: HTMLElement;
|
|
9
|
+
}
|
|
10
|
+
export declare const bootstrap: ({ ForegroundComponent, BackgroundComponent, TitleComponent, SubtitleComponent, ContentComponent, FooterComponent, usePathname, options, context, anchor, }: BootstrapProps) => import("react").ReactPortal;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap/bootstrap.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,EAEL,KAAK,iCAAiC,EACvC,MAAM,gDAAgD,CAAC;AAIxD,UAAU,cAAe,SAAQ,iCAAiC;IAChE,WAAW,EAAE,EAAE,CAAC,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,eAAO,MAAM,SAAS,+JAWnB,cAAc,gCAkBd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Anchor.d.ts","sourceRoot":"","sources":["../../../src/components/Anchor/Anchor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Anchor.d.ts","sourceRoot":"","sources":["../../../src/components/Anchor/Anchor.tsx"],"names":[],"mappings":"AA4CA,eAAO,MAAM,MAAM,mIAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Background.d.ts","sourceRoot":"","sources":["../../../src/components/Background/Background.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Background.d.ts","sourceRoot":"","sources":["../../../src/components/Background/Background.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,eAAO,MAAM,eAAe,gCAGzB,eAAe,mDAgDjB,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":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,eAAO,MAAM,eAAe,gCAGzB,eAAe,mDAmDjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/AlertInner.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"AlertInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/AlertInner.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAKtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,UAAU,eAAe,CAAC,CAAC;IACzB,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACpB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;CAC3C;AAED,eAAO,MAAM,UAAU,wCACpB,CAAC,uBAAwB,eAAe,CAAC,CAAC,CAAC,8CA2D7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/ConfirmInner.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/ConfirmInner.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,UAAU,iBAAiB,CAAC,CAAC;IAC3B,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACtB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,SAAS,CAAC,CAAC;CACvD;AAED,eAAO,MAAM,YAAY,wCACtB,CAAC,uBAAwB,iBAAiB,CAAC,CAAC,CAAC,8CAkE/C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/PromptInner.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"PromptInner.d.ts","sourceRoot":"","sources":["../../../../src/components/Foreground/components/PromptInner.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,UAAU,gBAAgB,CAAC,CAAC,EAAE,CAAC;IAC7B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC,CAAC;CACpE;AAED,eAAO,MAAM,WAAW,wCACrB,CAAC,EAAE,CAAC,uBAAuB,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,8CAyHnD,CAAC"}
|
|
@@ -1 +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;
|
|
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;AAGtD,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAE/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,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,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,iMAexB,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,eAyBnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActiveModalCount.d.ts","sourceRoot":"","sources":["../../src/hooks/useActiveModalCount.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useActiveModalCount.d.ts","sourceRoot":"","sources":["../../src/hooks/useActiveModalCount.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAKtD,eAAO,MAAM,mBAAmB,cACpB,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC,eACnC,MAAM,GAAG,MAAM,WAW5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAKtD,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
|
|
1
|
+
"use strict";var e,n,t,o,r,i,s,a,l,c,u=require("react/jsx-runtime"),d=require("react"),m=require("@winglet/common-utils"),p=require("@winglet/react-utils"),f=require("@emotion/css"),b=require("react-dom");
|
|
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 I(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 T(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 V,L,_,q,A;"function"==typeof SuppressedError&&SuppressedError;class R{get alive(){return I(this,V,"f")}get visible(){return I(this,L,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,background:r,dimmed:i=!0,manualDestroy:s=!1,closeOnBackdropClick:a=!0,resolve:l,ForegroundComponent:c,BackgroundComponent:u}){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"initiator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"title",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtitle",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"background",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualDestroy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"closeOnBackdropClick",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dimmed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ForegroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BackgroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),V.set(this,void 0),L.set(this,void 0),_.set(this,void 0),q.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.dimmed=i,this.manualDestroy=s,this.closeOnBackdropClick=a,this.ForegroundComponent=c,this.BackgroundComponent=u,T(this,V,!0,"f"),T(this,L,!0,"f"),T(this,_,l,"f")}subscribe(e){return I(this,q,"f").push(e),()=>{T(this,q,I(this,q,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of I(this,q,"f"))e()}resolve(e){I(this,_,"f").call(this,e)}onDestroy(){const e=!0===I(this,V,"f");T(this,V,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===I(this,L,"f");T(this,L,!0,"f"),e&&this.publish()}onHide(){const e=!0===I(this,L,"f");T(this,L,!1,"f"),e&&this.publish()}}V=new WeakMap,L=new WeakMap,_=new WeakMap,q=new WeakMap;class H extends R{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:s,footer:a,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=s,this.footer=a}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class $ extends R{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:s,footer:a,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=s,this.footer=a}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class z extends R{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,dimmed:m,manualDestroy:p,closeOnBackdropClick:f,resolve:b,ForegroundComponent:h,BackgroundComponent:C}){super({id:e,initiator:n,title:o,subtitle:r,background:d,dimmed:m,manualDestroy:p,closeOnBackdropClick:f,resolve:b,ForegroundComponent:h,BackgroundComponent:C}),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}),A.set(this,void 0),this.type=t,this.content=i,this.Input=a,this.defaultValue=s,T(this,A,s,"f"),this.disabled=l,this.returnOnCancel=c,this.footer=u}onChange(e){T(this,A,e,"f")}onConfirm(){this.resolve(I(this,A,"f")??null)}onClose(){this.returnOnCancel?this.resolve(I(this,A,"f")??null):this.resolve(null)}}A=new WeakMap;const Y=e=>{switch(e.type){case"alert":return new H(e);case"confirm":return new $(e);case"prompt":return new z(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},W=/^\s*(\d+)\s*(ms|s|m|h)\s*$/,U=e=>{const[,n,t]=e.match(W)||[];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},J=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})}),G=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=pe(),p=n.useMemo((()=>U(m.duration)),[m]);o.useOnMountLayout((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=m;for(const t of c.prerender){const o=Y({...t,id:d.current++,initiator:u.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});i.current.set(o.id,o),a((e=>[...e,o.id]))}c.setupOpen((t=>{const o=Y({...t,id:d.current++,initiator:u.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});i.current.set(o.id,o),a((e=>[...e.filter((e=>{const n=!i.current.get(e)?.alive;return n&&i.current.delete(e),!n})),o.id]))})),c.clearPrerender()})),n.useLayoutEffect((()=>{for(const e of l.current){const n=i.current.get(e);n?.alive&&(n.initiator===t?n.onShow():n.onHide())}u.current=t}),[l,t]);const f=n.useCallback((e=>i.current.get(e)),[]),b=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onDestroy(),h.current?.())}),[]),h=n.useRef(),C=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onHide(),h.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),p))}),[p]),g=n.useCallback(((e,n)=>{const t=i.current.get(e);t&&"prompt"===t.type&&t.onChange(n)}),[]),y=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onConfirm(),C(e))}),[C]),v=n.useCallback((e=>{const n=i.current.get(e);n&&(n.onClose(),C(e))}),[C]),k=n.useCallback((e=>({modal:f(e),onConfirm:()=>y(e),onClose:()=>v(e),onChange:n=>g(e,n),onDestroy:()=>b(e)})),[f,y,v,g,b]),x=n.useMemo((()=>({modalIds:s,getModalNode:f,onChange:g,onConfirm:y,onClose:v,onDestroy:b,getModal:k,setUpdater:e=>{h.current=e}})),[s,k,f,g,y,v,b]);return e.jsx(J.Provider,{value:x,children:r})})),K=()=>n.useContext(J),Q=e=>{const{getModal:t}=K();return n.useMemo((()=>t(e)),[e,t])},X=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)."}}),Z=e=>e?.visible&&e.dimmed,ee=n.memo(o.withErrorBoundary((()=>{const[t,r]=o.useTick(),{modalIds:i,setUpdater:s}=K();n.useEffect((()=>{s(r)}),[s,r]);const{options:a}=me(),l=S(Z,t);return e.jsx("div",{className:X,style:{transitionDuration:a.duration,backgroundColor:l?a.backdrop:"transparent"},children:i.map((n=>e.jsx(M,{modalId:n},n)))})})));function ne(){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 te=i.css("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:ne}),oe=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:ne}),re=({children:n})=>e.jsx("h2",{className:te,children:n}),ie=({children:n})=>e.jsx("h3",{className:te,children:n}),se=({children:n})=>e.jsx("div",{className:te,children:n}),ae=({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||"취소"})]}),le=n.forwardRef((({id:t,onChangeOrder:o,children:r},i)=>{const s=S(),[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:oe,onClick:o,style:{marginBottom:`calc(25vh + ${a}px)`,marginLeft:`${a}px`,transform:`translate(${l}px, ${l}px)`},children:r})})),ce=()=>{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}},ue=n.createContext({ForegroundComponent:le,TitleComponent:re,SubtitleComponent:ie,ContentComponent:se,FooterComponent:ae,options:{duration:u,backdrop:d,manualDestroy:!1,closeOnBackdropClick:!0}}),de=n.memo((({ForegroundComponent:r,BackgroundComponent:i,TitleComponent:s,SubtitleComponent:a,ContentComponent:l,FooterComponent:m,options:f,context:b,usePathname:h,children:C})=>{const{pathname:g}=(h||ce)(),[,y]=o.useTick(),v=n.useRef(null);o.useOnMount((()=>(v.current=c.anchor("div"),y(),()=>{v.current&&v.current.remove()})));const k=n.useMemo((()=>({BackgroundComponent:i,ForegroundComponent:r||le,TitleComponent:s||re,SubtitleComponent:a||ie,ContentComponent:n.memo(l||se),FooterComponent:n.memo(m||ae),options:{duration:u,backdrop:d,closeOnBackdropClick:!0,manualDestroy:!1,...f}})),[r,i,l,m,a,s,f]);return e.jsxs(ue.Provider,{value:k,children:[C,v.current&&t.createPortal(e.jsx(p,{context:b,children:e.jsx(G,{pathname:g,children:e.jsx(ee,{})})}),v.current)]})})),me=()=>n.useContext(ue),pe=()=>{const{options:e}=n.useContext(ue);return e};exports.ModalProvider=de,exports.alert=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:u,BackgroundComponent:d})=>new Promise(((m,p)=>{try{c.open({type:"alert",subtype:e,resolve:()=>m(),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:u,BackgroundComponent:d})}catch(e){p(e)}})),exports.confirm=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:u,BackgroundComponent:d})=>new Promise(((m,p)=>{try{c.open({type:"confirm",subtype:e,resolve:e=>m(e??!1),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:u,BackgroundComponent:d})}catch(e){p(e)}})),exports.prompt=({defaultValue:e,title:n,subtitle:t,content:o,Input:r,disabled:i,returnOnCancel:s,background:a,footer:l,dimmed:u,manualDestroy:d,closeOnBackdropClick:m,ForegroundComponent:p,BackgroundComponent:f})=>new Promise(((b,h)=>{try{c.open({type:"prompt",resolve:e=>b(e),title:n,subtitle:t,content:o,Input:r,defaultValue:e,disabled:i,returnOnCancel:s,background:a,footer:l,dimmed:u,manualDestroy:d,closeOnBackdropClick:m,ForegroundComponent:p,BackgroundComponent:f})}catch(e){h(e)}})),exports.useActiveModalCount=S,exports.useDestroyAfter=(e,t)=>{const{modal:o,onDestroy:i}=Q(e),s=F(o),a=n.useRef({modal:o,onDestroy:i,milliseconds:r.isString(t)?U(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.useModalAnimation=(e,t)=>{const o=n.useRef(t);o.current=t,n.useLayoutEffect((()=>{if(!o.current)return;let n;return n=e?requestAnimationFrame((()=>o.current.onVisible?.())):requestAnimationFrame((()=>o.current.onHidden?.())),()=>{n&&cancelAnimationFrame(n)}}),[e])},exports.useModalBackdrop=()=>{const{backdrop:e}=pe();return e},exports.useModalDuration=()=>{const{duration:e}=pe();return{duration:e,milliseconds:U(e)}},exports.useModalOptions=pe,exports.useSubscribeModal=F;
|
|
17
|
+
function h(e,n,t,o){if("a"===t&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!o:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?o:"a"===t?o.call(e):o?o.value:n.get(e)}function C(e,n,t,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof n?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,t):r?r.value=t:n.set(e,t),t}"function"==typeof SuppressedError&&SuppressedError;class g{static activate(){return!h(e,e,"f",n)&&C(e,e,!0,"f",n)}static anchor(n){if(h(e,e,"f",t)){const n=document.getElementById(h(e,e,"f",t).id);if(n)return n}const{tag:o="div",prefix:r="promise-modal",root:i=document.body}=n||{},s=document.createElement(o);return s.setAttribute("id",`${r}-${m.getRandomString(36)}`),i.appendChild(s),C(e,e,s,"f",t),s}static get prerender(){return h(e,e,"f",o)}static set openHandler(n){C(e,e,n,"f",r),C(e,e,[],"f",o)}static get unanchored(){return!h(e,e,"f",t)}static reset(){C(e,e,!1,"f",n),C(e,e,null,"f",t),C(e,e,[],"f",o),C(e,e,(n=>h(e,e,"f",o).push(n)),"f",r)}static open(n){h(e,e,"f",r).call(e,n)}}e=g,n={value:!1},t={value:null},o={value:[]},r={value:n=>h(e,e,"f",o).push(n)};class v{get alive(){return h(this,i,"f")}get visible(){return h(this,s,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,background:r,dimmed:c=!0,manualDestroy:u=!1,closeOnBackdropClick:d=!0,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"initiator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"title",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtitle",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"background",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualDestroy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"closeOnBackdropClick",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dimmed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ForegroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BackgroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i.set(this,void 0),s.set(this,void 0),a.set(this,void 0),l.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.dimmed=c,this.manualDestroy=u,this.closeOnBackdropClick=d,this.ForegroundComponent=p,this.BackgroundComponent=f,C(this,i,!0,"f"),C(this,s,!0,"f"),C(this,a,m,"f")}subscribe(e){return h(this,l,"f").push(e),()=>{C(this,l,h(this,l,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of h(this,l,"f"))e()}resolve(e){h(this,a,"f").call(this,e)}onDestroy(){const e=!0===h(this,i,"f");C(this,i,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===h(this,s,"f");C(this,s,!0,"f"),e&&this.publish()}onHide(){const e=!0===h(this,s,"f");C(this,s,!1,"f"),e&&this.publish()}}i=new WeakMap,s=new WeakMap,a=new WeakMap,l=new WeakMap;class y extends v{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:s,footer:a,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=s,this.footer=a}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class k extends v{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:s,footer:a,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=s,this.footer=a}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class x extends v{constructor({id:e,initiator:n,type:t,title:o,subtitle:r,content:i,defaultValue:s,Input:a,disabled:l,returnOnCancel:u,footer:d,background:m,dimmed:p,manualDestroy:f,closeOnBackdropClick:b,resolve:h,ForegroundComponent:g,BackgroundComponent:v}){super({id:e,initiator:n,title:o,subtitle:r,background:m,dimmed:p,manualDestroy:f,closeOnBackdropClick:b,resolve:h,ForegroundComponent:g,BackgroundComponent:v}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"Input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"returnOnCancel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),c.set(this,void 0),this.type=t,this.content=i,this.Input=a,this.defaultValue=s,C(this,c,s,"f"),this.disabled=l,this.returnOnCancel=u,this.footer=d}onChange(e){C(this,c,e,"f")}onConfirm(){this.resolve(h(this,c,"f")??null)}onClose(){this.returnOnCancel?this.resolve(h(this,c,"f")??null):this.resolve(null)}}c=new WeakMap;const j=e=>{switch(e.type){case"alert":return new y(e);case"confirm":return new k(e);case"prompt":return new x(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},w=d.createContext({}),O=d.memo((({usePathname:e,children:n})=>{const t=d.useRef(new Map),[o,r]=d.useState([]),i=p.useReference(o),{pathname:s}=e(),a=d.useRef(s),l=d.useRef(0),c=q(),f=d.useMemo((()=>m.convertMsFromDuration(c.duration)),[c]);p.useOnMountLayout((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=c;for(const o of g.prerender){const i=j({...o,id:l.current++,initiator:a.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});t.current.set(i.id,i),r((e=>[...e,i.id]))}return g.openHandler=o=>{const i=j({...o,id:l.current++,initiator:a.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});t.current.set(i.id,i),r((e=>[...e.filter((e=>{const n=!t.current.get(e)?.alive;return n&&t.current.delete(e),!n})),i.id]))},()=>{g.reset()}})),d.useLayoutEffect((()=>{for(const e of i.current){const n=t.current.get(e);n?.alive&&(n.initiator===s?n.onShow():n.onHide())}a.current=s}),[i,s]);const b=d.useCallback((e=>t.current.get(e)),[]),h=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onDestroy(),C.current?.())}),[]),C=d.useRef(),v=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onHide(),C.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),f))}),[f]),y=d.useCallback(((e,n)=>{const o=t.current.get(e);o&&"prompt"===o.type&&o.onChange(n)}),[]),k=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onConfirm(),v(e))}),[v]),x=d.useCallback((e=>{const n=t.current.get(e);n&&(n.onClose(),v(e))}),[v]),O=d.useCallback((e=>({modal:b(e),onConfirm:()=>k(e),onClose:()=>x(e),onChange:n=>y(e,n),onDestroy:()=>h(e)})),[b,k,x,y,h]),D=d.useMemo((()=>({modalIds:o,getModalNode:b,onChange:y,onConfirm:k,onClose:x,onDestroy:h,getModal:O,setUpdater:e=>{C.current=e}})),[o,O,b,y,k,x,h]);return u.jsx(w.Provider,{value:D,children:n})})),D=()=>d.useContext(w),B=e=>{const{getModal:n}=D();return d.useMemo((()=>n(e)),[e,n])};function F(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const P=f.css("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:F}),M=f.css("production"===process.env.NODE_ENV?{name:"1kuk3a3",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black"}:{name:"16dbbea-frame",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black;label:frame;",toString:F}),S=({children:e})=>u.jsx("h2",{className:P,children:e}),E=({children:e})=>u.jsx("h3",{className:P,children:e}),N=({children:e})=>u.jsx("div",{className:P,children:e}),I=({confirmLabel:e,hideConfirm:n=!1,cancelLabel:t,hideCancel:o=!1,disabled:r,onConfirm:i,onCancel:s})=>u.jsxs("div",{children:[!n&&u.jsx("button",{onClick:i,disabled:r,children:e||"확인"}),!o&&"function"==typeof s&&u.jsx("button",{onClick:s,children:t||"취소"})]}),T=e=>e?.visible,V=(e=T,n=0)=>{const{modalIds:t,getModalNode:o}=D();return d.useMemo((()=>{let n=0;for(const r of t)e(o(r))&&n++;return n}),[o,t,n])},H=d.forwardRef((({id:e,onChangeOrder:n,children:t},o)=>{const r=V(),[i,s]=d.useMemo((()=>{const n=r>1;return[n?Math.floor(e/5)%3*100:0,n?e%5*35:0]}),[r,e]);return u.jsx("div",{ref:o,className:M,onClick:n,style:{marginBottom:`calc(25vh + ${i}px)`,marginLeft:`${i}px`,transform:`translate(${s}px, ${s}px)`},children:t})})),R=d.createContext({}),z=d.memo((({ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:r,FooterComponent:i,options:s,children:a})=>{const l=d.useMemo((()=>({BackgroundComponent:n,ForegroundComponent:e||H,TitleComponent:t||S,SubtitleComponent:o||E,ContentComponent:d.memo(r||N),FooterComponent:d.memo(i||I),options:{duration:"300ms",backdrop:"rgba(0, 0, 0, 0.5)",closeOnBackdropClick:!0,manualDestroy:!1,...s}})),[e,n,r,i,o,t,s]);return u.jsx(R.Provider,{value:l,children:a})})),L=()=>d.useContext(R),q=()=>d.useContext(R).options,A=d.createContext({}),_=({context:e,children:n})=>{const t=d.useMemo((()=>({context:e||{}})),[e]);return u.jsx(A.Provider,{value:t,children:n})},$=()=>d.useContext(A);function W(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const Y=f.css("production"===process.env.NODE_ENV?{name:"u7uu4v",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;}"}:{name:"coymdj-background",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;};label:background;",toString:W}),U=f.css("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:W}),G=f.css("production"===process.env.NODE_ENV?{name:"1wnowod",styles:"display:flex;align-items:center;justify-content:center"}:{name:"xppew7-visible",styles:"display:flex;align-items:center;justify-content:center;label:visible;",toString:W}),J=({modalId:e,onChangeOrder:n})=>{const{BackgroundComponent:t}=L(),{context:o}=$(),{modal:r,onClose:i,onChange:s,onConfirm:a,onDestroy:l}=B(e),c=d.useCallback((e=>{r&&r.closeOnBackdropClick&&r.visible&&i(),e.stopPropagation()}),[r,i]),m=d.useMemo((()=>r?.BackgroundComponent||t),[t,r]);return r?u.jsx("div",{className:f.cx(Y,{[G]:r.manualDestroy?r.alive:r.visible,[U]:r.closeOnBackdropClick&&r.visible}),onClick:c,children:m&&u.jsx(m,{id:r.id,type:r.type,alive:r.alive,visible:r.visible,initiator:r.initiator,manualDestroy:r.manualDestroy,closeOnBackdropClick:r.closeOnBackdropClick,background:r.background,onChange:s,onConfirm:a,onClose:i,onDestroy:l,onChangeOrder:n,context:o})}):null};function K(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const Q=f.css("production"===process.env.NODE_ENV?{name:"12g0hx0",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1"}:{name:"1hcczik-foreground",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1;label:foreground;",toString:K}),X=f.css("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:K}),Z=f.css("production"===process.env.NODE_ENV?{name:"1fmljv2",styles:"display:flex!important;justify-content:center;align-items:center"}:{name:"1p4unab-visible",styles:"display:flex!important;justify-content:center;align-items:center;label:visible;",toString:K}),ee=d.memo((({modal:e,handlers:n})=>{const{title:t,subtitle:o,content:r,footer:i}=d.useMemo((()=>e),[e]),{context:s}=$(),{onConfirm:a}=d.useMemo((()=>n),[n]),l=p.useHandle(a),{TitleComponent:c,SubtitleComponent:f,ContentComponent:b,FooterComponent:h}=L();return u.jsxs(d.Fragment,{children:[t&&(m.isString(t)?u.jsx(c,{context:s,children:t}):t),o&&(m.isString(o)?u.jsx(f,{context:s,children:o}):o),r&&(m.isString(r)?u.jsx(b,{context:s,children:r}):p.renderComponent(r,{onConfirm:l})),!1!==i&&("function"==typeof i?i({onConfirm:l,context:s}):u.jsx(h,{onConfirm:l,confirmLabel:i?.confirm,hideConfirm:i?.hideConfirm,context:s}))]})})),ne=d.memo((({modal:e,handlers:n})=>{const{title:t,subtitle:o,content:r,footer:i}=d.useMemo((()=>e),[e]),{context:s}=$(),{onConfirm:a,onClose:l}=d.useMemo((()=>n),[n]),c=p.useHandle(a),f=p.useHandle(l),{TitleComponent:b,SubtitleComponent:h,ContentComponent:C,FooterComponent:g}=L();return u.jsxs(d.Fragment,{children:[t&&(m.isString(t)?u.jsx(b,{context:s,children:t}):t),o&&(m.isString(o)?u.jsx(h,{context:s,children:o}):o),r&&(m.isString(r)?u.jsx(C,{context:s,children:r}):p.renderComponent(r,{onConfirm:c,onCancel:f,context:s})),!1!==i&&("function"==typeof i?i({onConfirm:c,onCancel:f,context:s}):u.jsx(g,{onConfirm:c,onCancel:f,confirmLabel:i?.confirm,cancelLabel:i?.cancel,hideConfirm:i?.hideConfirm,hideCancel:i?.hideCancel,context:s}))]})})),te=d.memo((({modal:e,handlers:n})=>{const{Input:t,defaultValue:o,disabled:r,title:i,subtitle:s,content:a,footer:l}=d.useMemo((()=>({...e,Input:d.memo(p.withErrorBoundary(e.Input))})),[e]),{context:c}=$(),[f,b]=d.useState(o),{onChange:h,onClose:C,onConfirm:g}=d.useMemo((()=>n),[n]),v=p.useHandle(C),y=p.useHandle((e=>{const n=m.isFunction(e)?e(f):e;b(n),h(n)})),k=d.useCallback((()=>{setTimeout((()=>{g()}))}),[g]),x=d.useMemo((()=>!!f&&!!r?.(f)),[r,f]),{TitleComponent:j,SubtitleComponent:w,ContentComponent:O,FooterComponent:D}=L();return u.jsxs(d.Fragment,{children:[i&&(m.isString(i)?u.jsx(j,{context:c,children:i}):i),s&&(m.isString(s)?u.jsx(w,{context:c,children:s}):s),a&&(m.isString(a)?u.jsx(O,{context:c,children:a}):p.renderComponent(a,{onConfirm:k,onCancel:v,context:c})),t&&u.jsx(t,{defaultValue:o,value:f,onChange:y,onConfirm:k,onCancel:v,context:c}),!1!==l&&("function"==typeof l?l({value:f,disabled:x,onChange:y,onConfirm:k,onCancel:v,context:c}):u.jsx(D,{disabled:x,onConfirm:k,onCancel:v,confirmLabel:l?.confirm,cancelLabel:l?.cancel,hideConfirm:l?.hideConfirm,hideCancel:l?.hideCancel,context:c}))]})})),oe=({modalId:e,onChangeOrder:n})=>{const{ForegroundComponent:t}=L(),{context:o}=$(),{modal:r,onChange:i,onConfirm:s,onClose:a,onDestroy:l}=B(e),c=d.useMemo((()=>r?.ForegroundComponent||t),[t,r]);return r?u.jsx("div",{className:f.cx(Q,{[Z]:r.manualDestroy?r.alive:r.visible,[X]:r.visible}),children:u.jsxs(c,{id:r.id,type:r.type,alive:r.alive,visible:r.visible,initiator:r.initiator,manualDestroy:r.manualDestroy,closeOnBackdropClick:r.closeOnBackdropClick,background:r.background,onChange:i,onConfirm:s,onClose:a,onDestroy:l,onChangeOrder:n,context:o,children:["alert"===r.type&&u.jsx(ee,{modal:r,handlers:{onConfirm:s}}),"confirm"===r.type&&u.jsx(ne,{modal:r,handlers:{onConfirm:s,onClose:a}}),"prompt"===r.type&&u.jsx(te,{modal:r,handlers:{onChange:i,onConfirm:s,onClose:a}})]})}):null},re=e=>{const[n,t]=p.useTick();return p.useOnMount((()=>{if(e)return e.subscribe(t)})),n},ie=f.css("production"===process.env.NODE_ENV?{name:"13dmkf4",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden"}:{name:"yjeu12-presenter",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden;label:presenter;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),{increment:se}=m.counterFactory(1),ae=d.memo((({modalId:e})=>{const n=d.useRef(null),{modal:t}=B(e);re(t);const o=p.useHandle((()=>{n.current&&(n.current.style.zIndex=`${se()}`)}));return u.jsxs("div",{ref:n,className:ie,children:[u.jsx(J,{modalId:e,onChangeOrder:o}),u.jsx(oe,{modalId:e,onChangeOrder:o})]})})),le=f.css("production"===process.env.NODE_ENV?{name:"2hpasy",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out"}:{name:"lhj8co-anchor",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out;label:anchor;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),ce=e=>e?.visible&&e.dimmed,ue=d.memo(p.withErrorBoundary((()=>{const[e,n]=p.useTick(),{modalIds:t,setUpdater:o}=D();d.useEffect((()=>{o(n)}),[o,n]);const r=q(),i=V(ce,e);return u.jsx("div",{className:le,style:{transitionDuration:r.duration,backgroundColor:i?r.backdrop:"transparent"},children:t.map((e=>u.jsx(ae,{modalId:e},e)))})}))),de=({ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:r,FooterComponent:i,usePathname:s,options:a,context:l,anchor:c})=>b.createPortal(u.jsx(_,{context:l,children:u.jsx(z,{ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:r,FooterComponent:i,options:a,children:u.jsx(O,{usePathname:s,children:u.jsx(ue,{})})})}),c),me=()=>{const[e,n]=d.useState(window.location.pathname);return d.useLayoutEffect((()=>{let t;const o=()=>{t&&cancelAnimationFrame(t),e!==window.location.pathname?n(window.location.pathname):t=requestAnimationFrame(o)};return t=requestAnimationFrame(o),()=>{t&&cancelAnimationFrame(t)}}),[e]),{pathname:e}},pe=d.forwardRef((({usePathname:e,ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:s,options:a,context:l,children:c},f)=>{const b=d.useMemo((()=>e||me),[e]),h=d.useRef(g.activate()),C=d.useRef(null),[,v]=p.useTick(),y=d.useCallback((e=>{h.current?(C.current=g.anchor({root:e}),v()):m.printError("ModalProvider is already initialized",["ModalProvider can only be initialized once.","Nesting ModalProvider will be ignored..."],{info:"Something is wrong with the ModalProvider initialization..."})}),[v]);return d.useImperativeHandle(f,(()=>({initialize:y})),[y]),p.useOnMount((()=>(null===f&&y(),()=>{C.current&&C.current.remove()}))),u.jsxs(d.Fragment,{children:[c,C.current&&de({ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:s,usePathname:b,options:a,context:l,anchor:C.current})]})}));exports.ModalProvider=pe,exports.alert=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})=>new Promise(((d,m)=>{try{g.open({type:"alert",subtype:e,resolve:()=>d(),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})}catch(e){m(e)}})),exports.bootstrap=de,exports.confirm=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})=>new Promise(((d,m)=>{try{g.open({type:"confirm",subtype:e,resolve:e=>d(e??!1),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:s,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:c,BackgroundComponent:u})}catch(e){m(e)}})),exports.prompt=({defaultValue:e,title:n,subtitle:t,content:o,Input:r,disabled:i,returnOnCancel:s,background:a,footer:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})=>new Promise(((f,b)=>{try{g.open({type:"prompt",resolve:e=>f(e),title:n,subtitle:t,content:o,Input:r,defaultValue:e,disabled:i,returnOnCancel:s,background:a,footer:l,dimmed:c,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:m,BackgroundComponent:p})}catch(e){b(e)}})),exports.useActiveModalCount=V,exports.useDestroyAfter=(e,n)=>{const{modal:t,onDestroy:o}=B(e),r=re(t),i=d.useRef({modal:t,onDestroy:o,milliseconds:m.isString(n)?m.convertMsFromDuration(n):n});d.useEffect((()=>{const{modal:e,onDestroy:n,milliseconds:t}=i.current;if(!e||e.visible||!e.alive)return;const o=setTimeout((()=>{n()}),t);return()=>{o&&clearTimeout(o)}}),[r])},exports.useModalAnimation=(e,n)=>{const t=d.useRef(n);t.current=n,d.useLayoutEffect((()=>{if(!t.current)return;let n;return n=e?requestAnimationFrame((()=>t.current.onVisible?.())):requestAnimationFrame((()=>t.current.onHidden?.())),()=>{n&&cancelAnimationFrame(n)}}),[e])},exports.useModalBackdrop=()=>q().backdrop,exports.useModalDuration=()=>{const e=q();return{duration:e.duration,milliseconds:m.convertMsFromDuration(e.duration)}},exports.useModalOptions=q,exports.useSubscribeModal=re;
|
|
18
18
|
//# sourceMappingURL=index.cjs.js.map
|