@lerx/promise-modal 0.0.32 → 0.0.34

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.
Files changed (57) hide show
  1. package/dist/app/ModalManager.d.ts +14 -7
  2. package/dist/app/ModalManager.d.ts.map +1 -1
  3. package/dist/components/Anchor/Anchor.d.ts.map +1 -1
  4. package/dist/components/Background/Background.d.ts.map +1 -1
  5. package/dist/components/Foreground/Foreground.d.ts.map +1 -1
  6. package/dist/components/Foreground/components/AlertInner.d.ts.map +1 -1
  7. package/dist/components/Foreground/components/ConfirmInner.d.ts.map +1 -1
  8. package/dist/components/Foreground/components/PromptInner.d.ts.map +1 -1
  9. package/dist/core/handle/prompt.d.ts.map +1 -1
  10. package/dist/hooks/useActiveModalCount.d.ts.map +1 -1
  11. package/dist/hooks/useDestroyAfter.d.ts.map +1 -1
  12. package/dist/index.cjs.js +2 -2
  13. package/dist/index.cjs.js.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.esm.js +2 -3
  17. package/dist/index.esm.js.map +1 -1
  18. package/dist/providers/{ModalContext/ModalContext.d.ts → ConfigurationContext/ConfigurationContext.d.ts} +3 -3
  19. package/dist/providers/ConfigurationContext/ConfigurationContext.d.ts.map +1 -0
  20. package/dist/providers/{ModalContext/ModalContextProvider.d.ts → ConfigurationContext/ConfigurationContextProvider.d.ts} +4 -9
  21. package/dist/providers/ConfigurationContext/ConfigurationContextProvider.d.ts.map +1 -0
  22. package/dist/providers/ConfigurationContext/index.d.ts +3 -0
  23. package/dist/providers/ConfigurationContext/index.d.ts.map +1 -0
  24. package/dist/providers/ConfigurationContext/useConfigurationContext.d.ts +13 -0
  25. package/dist/providers/ConfigurationContext/useConfigurationContext.d.ts.map +1 -0
  26. package/dist/providers/Initializer/Initializer.d.ts +12 -0
  27. package/dist/providers/Initializer/Initializer.d.ts.map +1 -0
  28. package/dist/providers/Initializer/index.d.ts +2 -0
  29. package/dist/providers/Initializer/index.d.ts.map +1 -0
  30. package/dist/providers/{ModalDataContext/ModalDataContext.d.ts → ModalManagerContext/ModalManagerContext.d.ts} +3 -3
  31. package/dist/providers/ModalManagerContext/ModalManagerContext.d.ts.map +1 -0
  32. package/dist/providers/ModalManagerContext/ModalManagerContextProvider.d.ts +7 -0
  33. package/dist/providers/ModalManagerContext/ModalManagerContextProvider.d.ts.map +1 -0
  34. package/dist/providers/ModalManagerContext/index.d.ts +3 -0
  35. package/dist/providers/ModalManagerContext/index.d.ts.map +1 -0
  36. package/dist/providers/ModalManagerContext/useModalManagerContext.d.ts +4 -0
  37. package/dist/providers/ModalManagerContext/useModalManagerContext.d.ts.map +1 -0
  38. package/dist/providers/UserDefinedContext/UserDefinedContext.d.ts.map +1 -1
  39. package/dist/providers/UserDefinedContext/UserDefinedContextProvider.d.ts.map +1 -1
  40. package/dist/providers/index.d.ts +4 -2
  41. package/dist/providers/index.d.ts.map +1 -1
  42. package/package.json +3 -3
  43. package/dist/helpers/getMillisecondsFromDuration.d.ts +0 -2
  44. package/dist/helpers/getMillisecondsFromDuration.d.ts.map +0 -1
  45. package/dist/providers/ModalContext/ModalContext.d.ts.map +0 -1
  46. package/dist/providers/ModalContext/ModalContextProvider.d.ts.map +0 -1
  47. package/dist/providers/ModalContext/index.d.ts +0 -3
  48. package/dist/providers/ModalContext/index.d.ts.map +0 -1
  49. package/dist/providers/ModalContext/useModalContext.d.ts +0 -13
  50. package/dist/providers/ModalContext/useModalContext.d.ts.map +0 -1
  51. package/dist/providers/ModalDataContext/ModalDataContext.d.ts.map +0 -1
  52. package/dist/providers/ModalDataContext/ModalDataContextProvider.d.ts +0 -7
  53. package/dist/providers/ModalDataContext/ModalDataContextProvider.d.ts.map +0 -1
  54. package/dist/providers/ModalDataContext/index.d.ts +0 -3
  55. package/dist/providers/ModalDataContext/index.d.ts.map +0 -1
  56. package/dist/providers/ModalDataContext/useModalDataContext.d.ts +0 -4
  57. package/dist/providers/ModalDataContext/useModalDataContext.d.ts.map +0 -1
@@ -1,9 +1,16 @@
1
+ import type { Fn } from '../@aileron/types';
1
2
  import type { Modal } from '../types';
2
- export declare const ModalManager: {
3
- readonly prerender: Modal[];
4
- clearPrerender(): void;
5
- open(modal: Modal): void;
6
- setupOpen(open: (modal: Modal) => void): void;
7
- anchor(name: string, prefix?: string): HTMLElement;
8
- };
3
+ export declare class ModalManager {
4
+ #private;
5
+ static anchor(options?: {
6
+ tag?: string;
7
+ prefix?: string;
8
+ root?: HTMLElement;
9
+ }): HTMLElement;
10
+ static get prerender(): Modal[];
11
+ static set openHandler(handler: Fn<[Modal], void>);
12
+ static get unanchored(): boolean;
13
+ static reset(): void;
14
+ static open(modal: Modal): void;
15
+ }
9
16
  //# sourceMappingURL=ModalManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModalManager.d.ts","sourceRoot":"","sources":["../../src/app/ModalManager.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAgBnD,eAAO,MAAM,YAAY;;;gBAOX,KAAK;oBAGD,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;iBAGzB,MAAM,oBAA6B,WAAW;CAW5D,CAAC"}
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,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;IAOZ,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK;CAGzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"Anchor.d.ts","sourceRoot":"","sources":["../../../src/components/Anchor/Anchor.tsx"],"names":[],"mappings":"AA0CA,eAAO,MAAM,MAAM,mIAAuC,CAAC"}
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":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,eAAO,MAAM,eAAe,gCAGzB,eAAe,mDAgDjB,CAAC"}
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":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,eAAO,MAAM,eAAe,gCAGzB,eAAe,mDAmDjB,CAAC"}
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;AAGtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,UAAU,eAAe,CAAC,CAAC;IACzB,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACpB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;CAC3C;AAED,eAAO,MAAM,UAAU,wCACpB,CAAC,uBAAwB,eAAe,CAAC,CAAC,CAAC,8CA2D7C,CAAC"}
1
+ {"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;AAGxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,UAAU,iBAAiB,CAAC,CAAC;IAC3B,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACtB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,SAAS,CAAC,CAAC;CACvD;AAED,eAAO,MAAM,YAAY,wCACtB,CAAC,uBAAwB,iBAAiB,CAAC,CAAC,CAAC,8CAkE/C,CAAC"}
1
+ {"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;AAGvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,UAAU,gBAAgB,CAAC,CAAC,EAAE,CAAC;IAC7B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC,CAAC;CACpE;AAED,eAAO,MAAM,WAAW,wCACrB,CAAC,EAAE,CAAC,uBAAuB,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,8CAyHnD,CAAC"}
1
+ {"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;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,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
+ {"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,SAAS,CAAC;AAKzC,eAAO,MAAM,mBAAmB,cACpB,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC,eACnC,MAAM,GAAG,MAAM,WAW5B,CAAC"}
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;AAMtD,eAAO,MAAM,eAAe,YACjB,SAAS,CAAC,IAAI,CAAC,YACd,QAAQ,GAAG,MAAM,SAuB5B,CAAC"}
1
+ {"version":3,"file":"useDestroyAfter.d.ts","sourceRoot":"","sources":["../../src/hooks/useDestroyAfter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;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=require("react/jsx-runtime"),n=require("react"),t=require("react-dom"),o=require("@winglet/react-utils"),r=require("@winglet/common-utils"),i=require("@emotion/css");const s={current:[]},a={current:e=>{s.current.push(e)}},l={current:null},c={get prerender(){return s.current},clearPrerender(){s.current=[]},open(e){a.current(e)},setupOpen(e){a.current=e},anchor(e,n="promise-modal"){if(l.current){const e=document.getElementById(l.current.id);if(e)return e}const t=document.createElement(e);return t.setAttribute("id",`${n}-${r.getRandomString(36)}`),document.body.appendChild(t),l.current=t,t}},u="300ms",d="rgba(0, 0, 0, 0.5)",m=n.createContext({context:r.EMPTY_OBJECT}),p=({context:t,children:o})=>{const i=n.useMemo((()=>({context:t||r.EMPTY_OBJECT})),[t]);return e.jsx(m.Provider,{value:i,children:o})},f=()=>n.useContext(m);function b(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const h=i.css("production"===process.env.NODE_ENV?{name:"u7uu4v",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;}"}:{name:"coymdj-background",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;};label:background;",toString:b}),C=i.css("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:b}),g=i.css("production"===process.env.NODE_ENV?{name:"1wnowod",styles:"display:flex;align-items:center;justify-content:center"}:{name:"xppew7-visible",styles:"display:flex;align-items:center;justify-content:center;label:visible;",toString:b}),y=({modalId:t,onChangeOrder:o})=>{const{BackgroundComponent:r}=me(),{context:s}=f(),{modal:a,onClose:l,onChange:c,onConfirm:u,onDestroy:d}=Q(t),m=n.useCallback((e=>{a&&a.closeOnBackdropClick&&a.visible&&l(),e.stopPropagation()}),[a,l]),p=n.useMemo((()=>a?.BackgroundComponent||r),[r,a]);return a?e.jsx("div",{className:i.cx(h,{[g]:a.manualDestroy?a.alive:a.visible,[C]:a.closeOnBackdropClick&&a.visible}),onClick:m,children:p&&e.jsx(p,{id:a.id,type:a.type,alive:a.alive,visible:a.visible,initiator:a.initiator,manualDestroy:a.manualDestroy,closeOnBackdropClick:a.closeOnBackdropClick,background:a.background,onChange:c,onConfirm:u,onClose:l,onDestroy:d,onChangeOrder:o,context:s})}):null};function v(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const k=i.css("production"===process.env.NODE_ENV?{name:"12g0hx0",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1"}:{name:"1hcczik-foreground",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1;label:foreground;",toString:v}),x=i.css("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:v}),j=i.css("production"===process.env.NODE_ENV?{name:"1fmljv2",styles:"display:flex!important;justify-content:center;align-items:center"}:{name:"1p4unab-visible",styles:"display:flex!important;justify-content:center;align-items:center;label:visible;",toString:v}),O=n.memo((({modal:t,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>t),[t]),{context:u}=f(),{onConfirm:d}=n.useMemo((()=>i),[i]),m=o.useHandle(d),{TitleComponent:p,SubtitleComponent:b,ContentComponent:h,FooterComponent:C}=me();return e.jsxs(n.Fragment,{children:[s&&(r.isString(s)?e.jsx(p,{context:u,children:s}):s),a&&(r.isString(a)?e.jsx(b,{context:u,children:a}):a),l&&(r.isString(l)?e.jsx(h,{context:u,children:l}):o.renderComponent(l,{onConfirm:m})),!1!==c&&("function"==typeof c?c({onConfirm:m,context:u}):e.jsx(C,{onConfirm:m,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm,context:u}))]})})),w=n.memo((({modal:t,handlers:i})=>{const{title:s,subtitle:a,content:l,footer:c}=n.useMemo((()=>t),[t]),{context:u}=f(),{onConfirm:d,onClose:m}=n.useMemo((()=>i),[i]),p=o.useHandle(d),b=o.useHandle(m),{TitleComponent:h,SubtitleComponent:C,ContentComponent:g,FooterComponent:y}=me();return e.jsxs(n.Fragment,{children:[s&&(r.isString(s)?e.jsx(h,{context:u,children:s}):s),a&&(r.isString(a)?e.jsx(C,{context:u,children:a}):a),l&&(r.isString(l)?e.jsx(g,{context:u,children:l}):o.renderComponent(l,{onConfirm:p,onCancel:b,context:u})),!1!==c&&("function"==typeof c?c({onConfirm:p,onCancel:b,context:u}):e.jsx(y,{onConfirm:p,onCancel:b,confirmLabel:c?.confirm,cancelLabel:c?.cancel,hideConfirm:c?.hideConfirm,hideCancel:c?.hideCancel,context:u}))]})})),D=n.memo((({modal:t,handlers:i})=>{const{Input:s,defaultValue:a,disabled:l,title:c,subtitle:u,content:d,footer:m}=n.useMemo((()=>({...t,Input:n.memo(o.withErrorBoundary(t.Input))})),[t]),{context:p}=f(),[b,h]=n.useState(a),{onChange:C,onClose:g,onConfirm:y}=n.useMemo((()=>i),[i]),v=o.useHandle(g),k=o.useHandle((e=>{const n=r.isFunction(e)?e(b):e;h(n),C(n)})),x=n.useCallback((()=>{setTimeout((()=>{y()}))}),[y]),j=n.useMemo((()=>!!b&&!!l?.(b)),[l,b]),{TitleComponent:O,SubtitleComponent:w,ContentComponent:D,FooterComponent:B}=me();return e.jsxs(n.Fragment,{children:[c&&(r.isString(c)?e.jsx(O,{context:p,children:c}):c),u&&(r.isString(u)?e.jsx(w,{context:p,children:u}):u),d&&(r.isString(d)?e.jsx(D,{context:p,children:d}):o.renderComponent(d,{onConfirm:x,onCancel:v,context:p})),s&&e.jsx(s,{defaultValue:a,value:b,onChange:k,onConfirm:x,onCancel:v,context:p}),!1!==m&&("function"==typeof m?m({value:b,disabled:j,onChange:k,onConfirm:x,onCancel:v,context:p}):e.jsx(B,{disabled:j,onConfirm:x,onCancel:v,confirmLabel:m?.confirm,cancelLabel:m?.cancel,hideConfirm:m?.hideConfirm,hideCancel:m?.hideCancel,context:p}))]})})),B=({modalId:t,onChangeOrder:o})=>{const{ForegroundComponent:r}=me(),{context:s}=f(),{modal:a,onChange:l,onConfirm:c,onClose:u,onDestroy:d}=Q(t),m=n.useMemo((()=>a?.ForegroundComponent||r),[r,a]);return a?e.jsx("div",{className:i.cx(k,{[j]:a.manualDestroy?a.alive:a.visible,[x]:a.visible}),children:e.jsxs(m,{id:a.id,type:a.type,alive:a.alive,visible:a.visible,initiator:a.initiator,manualDestroy:a.manualDestroy,closeOnBackdropClick:a.closeOnBackdropClick,background:a.background,onChange:l,onConfirm:c,onClose:u,onDestroy:d,onChangeOrder:o,context:s,children:["alert"===a.type&&e.jsx(O,{modal:a,handlers:{onConfirm:c}}),"confirm"===a.type&&e.jsx(w,{modal:a,handlers:{onConfirm:c,onClose:u}}),"prompt"===a.type&&e.jsx(D,{modal:a,handlers:{onChange:l,onConfirm:c,onClose:u}})]})}):null},F=e=>{const[n,t]=o.useTick();return o.useOnMount((()=>{if(e)return e.subscribe(t)})),n},P=i.css("production"===process.env.NODE_ENV?{name:"13dmkf4",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden"}:{name:"yjeu12-presenter",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden;label:presenter;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),{increment:E}=r.counterFactory(1),M=n.memo((({modalId:t})=>{const r=n.useRef(null),{modal:i}=Q(t);F(i);const s=o.useHandle((()=>{r.current&&(r.current.style.zIndex=`${E()}`)}));return e.jsxs("div",{ref:r,className:P,children:[e.jsx(y,{modalId:t,onChangeOrder:s}),e.jsx(B,{modalId:t,onChangeOrder:s})]})})),N=e=>e?.visible,S=(e=N,t=0)=>{const{modalIds:o,getModalNode:r}=K();return n.useMemo((()=>{let n=0;for(const t of o)e(r(t))&&n++;return n}),[r,o,t])};
1
+ "use strict";var e,n,t,o,r=require("react/jsx-runtime"),i=require("react"),s=require("react-dom"),a=require("@winglet/common-utils"),l=require("@winglet/react-utils"),c=require("@emotion/css");
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 u(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 d(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 m{static anchor(t){if(u(e,e,"f",n)){const t=document.getElementById(u(e,e,"f",n).id);if(t)return t}const{tag:o="div",prefix:r="promise-modal",root:i=document.body}=t||{},s=document.createElement(o);return s.setAttribute("id",`${r}-${a.getRandomString(36)}`),i.appendChild(s),d(e,e,s,"f",n),s}static get prerender(){return u(e,e,"f",t)}static set openHandler(n){d(e,e,n,"f",o),d(e,e,[],"f",t)}static get unanchored(){return!u(e,e,"f",n)}static reset(){d(e,e,null,"f",n),d(e,e,[],"f",t),d(e,e,(n=>u(e,e,"f",t).push(n)),"f",o)}static open(n){u(e,e,"f",o).call(e,n)}}function p(){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)."}e=m,n={value:null},t={value:[]},o={value:n=>u(e,e,"f",t).push(n)};const f=c.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:p}),b=c.css("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:p}),h=c.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:p}),C=({modalId:e,onChangeOrder:n})=>{const{BackgroundComponent:t}=Y(),{context:o}=ue(),{modal:s,onClose:a,onChange:l,onConfirm:u,onDestroy:d}=ae(e),m=i.useCallback((e=>{s&&s.closeOnBackdropClick&&s.visible&&a(),e.stopPropagation()}),[s,a]),p=i.useMemo((()=>s?.BackgroundComponent||t),[t,s]);return s?r.jsx("div",{className:c.cx(f,{[h]:s.manualDestroy?s.alive:s.visible,[b]:s.closeOnBackdropClick&&s.visible}),onClick:m,children:p&&r.jsx(p,{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:u,onClose:a,onDestroy:d,onChangeOrder:n,context:o})}):null};function g(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const v=c.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:g}),y=c.css("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:g}),k=c.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:g}),x=i.memo((({modal:e,handlers:n})=>{const{title:t,subtitle:o,content:s,footer:c}=i.useMemo((()=>e),[e]),{context:u}=ue(),{onConfirm:d}=i.useMemo((()=>n),[n]),m=l.useHandle(d),{TitleComponent:p,SubtitleComponent:f,ContentComponent:b,FooterComponent:h}=Y();return r.jsxs(i.Fragment,{children:[t&&(a.isString(t)?r.jsx(p,{context:u,children:t}):t),o&&(a.isString(o)?r.jsx(f,{context:u,children:o}):o),s&&(a.isString(s)?r.jsx(b,{context:u,children:s}):l.renderComponent(s,{onConfirm:m})),!1!==c&&("function"==typeof c?c({onConfirm:m,context:u}):r.jsx(h,{onConfirm:m,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm,context:u}))]})})),j=i.memo((({modal:e,handlers:n})=>{const{title:t,subtitle:o,content:s,footer:c}=i.useMemo((()=>e),[e]),{context:u}=ue(),{onConfirm:d,onClose:m}=i.useMemo((()=>n),[n]),p=l.useHandle(d),f=l.useHandle(m),{TitleComponent:b,SubtitleComponent:h,ContentComponent:C,FooterComponent:g}=Y();return r.jsxs(i.Fragment,{children:[t&&(a.isString(t)?r.jsx(b,{context:u,children:t}):t),o&&(a.isString(o)?r.jsx(h,{context:u,children:o}):o),s&&(a.isString(s)?r.jsx(C,{context:u,children:s}):l.renderComponent(s,{onConfirm:p,onCancel:f,context:u})),!1!==c&&("function"==typeof c?c({onConfirm:p,onCancel:f,context:u}):r.jsx(g,{onConfirm:p,onCancel:f,confirmLabel:c?.confirm,cancelLabel:c?.cancel,hideConfirm:c?.hideConfirm,hideCancel:c?.hideCancel,context:u}))]})})),w=i.memo((({modal:e,handlers:n})=>{const{Input:t,defaultValue:o,disabled:s,title:c,subtitle:u,content:d,footer:m}=i.useMemo((()=>({...e,Input:i.memo(l.withErrorBoundary(e.Input))})),[e]),{context:p}=ue(),[f,b]=i.useState(o),{onChange:h,onClose:C,onConfirm:g}=i.useMemo((()=>n),[n]),v=l.useHandle(C),y=l.useHandle((e=>{const n=a.isFunction(e)?e(f):e;b(n),h(n)})),k=i.useCallback((()=>{setTimeout((()=>{g()}))}),[g]),x=i.useMemo((()=>!!f&&!!s?.(f)),[s,f]),{TitleComponent:j,SubtitleComponent:w,ContentComponent:O,FooterComponent:D}=Y();return r.jsxs(i.Fragment,{children:[c&&(a.isString(c)?r.jsx(j,{context:p,children:c}):c),u&&(a.isString(u)?r.jsx(w,{context:p,children:u}):u),d&&(a.isString(d)?r.jsx(O,{context:p,children:d}):l.renderComponent(d,{onConfirm:k,onCancel:v,context:p})),t&&r.jsx(t,{defaultValue:o,value:f,onChange:y,onConfirm:k,onCancel:v,context:p}),!1!==m&&("function"==typeof m?m({value:f,disabled:x,onChange:y,onConfirm:k,onCancel:v,context:p}):r.jsx(D,{disabled:x,onConfirm:k,onCancel:v,confirmLabel:m?.confirm,cancelLabel:m?.cancel,hideConfirm:m?.hideConfirm,hideCancel:m?.hideCancel,context:p}))]})})),O=({modalId:e,onChangeOrder:n})=>{const{ForegroundComponent:t}=Y(),{context:o}=ue(),{modal:s,onChange:a,onConfirm:l,onClose:u,onDestroy:d}=ae(e),m=i.useMemo((()=>s?.ForegroundComponent||t),[t,s]);return s?r.jsx("div",{className:c.cx(v,{[k]:s.manualDestroy?s.alive:s.visible,[y]:s.visible}),children:r.jsxs(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:a,onConfirm:l,onClose:u,onDestroy:d,onChangeOrder:n,context:o,children:["alert"===s.type&&r.jsx(x,{modal:s,handlers:{onConfirm:l}}),"confirm"===s.type&&r.jsx(j,{modal:s,handlers:{onConfirm:l,onClose:u}}),"prompt"===s.type&&r.jsx(w,{modal:s,handlers:{onChange:a,onConfirm:l,onClose:u}})]})}):null},D=e=>{const[n,t]=l.useTick();return l.useOnMount((()=>{if(e)return e.subscribe(t)})),n},B=c.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:F}=a.counterFactory(1),M=i.memo((({modalId:e})=>{const n=i.useRef(null),{modal:t}=ae(e);D(t);const o=l.useHandle((()=>{n.current&&(n.current.style.zIndex=`${F()}`)}));return r.jsxs("div",{ref:n,className:B,children:[r.jsx(C,{modalId:e,onChangeOrder:o}),r.jsx(O,{modalId:e,onChangeOrder:o})]})})),P=e=>e?.visible,E=(e=P,n=0)=>{const{modalIds:t,getModalNode:o}=se();return i.useMemo((()=>{let n=0;for(const r of t)e(o(r))&&n++;return n}),[o,t,n])},S=c.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)."}}),N=e=>e?.visible&&e.dimmed,I=i.memo(l.withErrorBoundary((()=>{const[e,n]=l.useTick(),{modalIds:t,setUpdater:o}=se();i.useEffect((()=>{o(n)}),[o,n]);const s=U(),a=E(N,e);return r.jsx("div",{className:S,style:{transitionDuration:s.duration,backgroundColor:a?s.backdrop:"transparent"},children:t.map((e=>r.jsx(M,{modalId:e},e)))})}))),T=()=>{const[e,n]=i.useState(window.location.pathname);return i.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}};function V(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const H=c.css("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:V}),L=c.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:V}),q=({children:e})=>r.jsx("h2",{className:H,children:e}),z=({children:e})=>r.jsx("h3",{className:H,children:e}),A=({children:e})=>r.jsx("div",{className:H,children:e}),R=({confirmLabel:e,hideConfirm:n=!1,cancelLabel:t,hideCancel:o=!1,disabled:i,onConfirm:s,onCancel:a})=>r.jsxs("div",{children:[!n&&r.jsx("button",{onClick:s,disabled:i,children:e||"확인"}),!o&&"function"==typeof a&&r.jsx("button",{onClick:a,children:t||"취소"})]}),_=i.forwardRef((({id:e,onChangeOrder:n,children:t},o)=>{const s=E(),[a,l]=i.useMemo((()=>{const n=s>1;return[n?Math.floor(e/5)%3*100:0,n?e%5*35:0]}),[s,e]);return r.jsx("div",{ref:o,className:L,onClick:n,style:{marginBottom:`calc(25vh + ${a}px)`,marginLeft:`${a}px`,transform:`translate(${l}px, ${l}px)`},children:t})})),$=i.createContext({}),W=i.memo((({ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:s,FooterComponent:a,options:l,children:c})=>{const u=i.useMemo((()=>({BackgroundComponent:n,ForegroundComponent:e||_,TitleComponent:t||q,SubtitleComponent:o||z,ContentComponent:i.memo(s||A),FooterComponent:i.memo(a||R),options:{duration:"300ms",backdrop:"rgba(0, 0, 0, 0.5)",closeOnBackdropClick:!0,manualDestroy:!1,...l}})),[e,n,s,a,o,t,l]);return r.jsx($.Provider,{value:u,children:c})})),Y=()=>i.useContext($),U=()=>i.useContext($).options;var G,J,K,Q,X;class Z{get alive(){return u(this,G,"f")}get visible(){return u(this,J,"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}),G.set(this,void 0),J.set(this,void 0),K.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,d(this,G,!0,"f"),d(this,J,!0,"f"),d(this,K,l,"f")}subscribe(e){return u(this,Q,"f").push(e),()=>{d(this,Q,u(this,Q,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of u(this,Q,"f"))e()}resolve(e){u(this,K,"f").call(this,e)}onDestroy(){const e=!0===u(this,G,"f");d(this,G,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===u(this,J,"f");d(this,J,!0,"f"),e&&this.publish()}onHide(){const e=!0===u(this,J,"f");d(this,J,!1,"f"),e&&this.publish()}}G=new WeakMap,J=new WeakMap,K=new WeakMap,Q=new WeakMap;class ee extends Z{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 ne extends Z{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 te extends Z{constructor({id:e,initiator:n,type:t,title:o,subtitle:r,content:i,defaultValue:s,Input:a,disabled:l,returnOnCancel:c,footer:u,background:m,dimmed:p,manualDestroy:f,closeOnBackdropClick:b,resolve:h,ForegroundComponent:C,BackgroundComponent:g}){super({id:e,initiator:n,title:o,subtitle:r,background:m,dimmed:p,manualDestroy:f,closeOnBackdropClick:b,resolve:h,ForegroundComponent:C,BackgroundComponent:g}),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}),X.set(this,void 0),this.type=t,this.content=i,this.Input=a,this.defaultValue=s,d(this,X,s,"f"),this.disabled=l,this.returnOnCancel=c,this.footer=u}onChange(e){d(this,X,e,"f")}onConfirm(){this.resolve(u(this,X,"f")??null)}onClose(){this.returnOnCancel?this.resolve(u(this,X,"f")??null):this.resolve(null)}}X=new WeakMap;const oe=e=>{switch(e.type){case"alert":return new ee(e);case"confirm":return new ne(e);case"prompt":return new te(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},re=i.createContext({}),ie=i.memo((({pathname:e,children:n})=>{const t=i.useRef(new Map),[o,s]=i.useState([]),c=l.useReference(o),u=i.useRef(e),d=i.useRef(0),p=U(),f=i.useMemo((()=>a.convertMsFromDuration(p.duration)),[p]);l.useOnMountLayout((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=p;for(const o of m.prerender){const r=oe({...o,id:d.current++,initiator:u.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});t.current.set(r.id,r),s((e=>[...e,r.id]))}return m.openHandler=o=>{const r=oe({...o,id:d.current++,initiator:u.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});t.current.set(r.id,r),s((e=>[...e.filter((e=>{const n=!t.current.get(e)?.alive;return n&&t.current.delete(e),!n})),r.id]))},()=>{m.reset()}})),i.useLayoutEffect((()=>{for(const n of c.current){const o=t.current.get(n);o?.alive&&(o.initiator===e?o.onShow():o.onHide())}u.current=e}),[c,e]);const b=i.useCallback((e=>t.current.get(e)),[]),h=i.useCallback((e=>{const n=t.current.get(e);n&&(n.onDestroy(),C.current?.())}),[]),C=i.useRef(),g=i.useCallback((e=>{const n=t.current.get(e);n&&(n.onHide(),C.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),f))}),[f]),v=i.useCallback(((e,n)=>{const o=t.current.get(e);o&&"prompt"===o.type&&o.onChange(n)}),[]),y=i.useCallback((e=>{const n=t.current.get(e);n&&(n.onConfirm(),g(e))}),[g]),k=i.useCallback((e=>{const n=t.current.get(e);n&&(n.onClose(),g(e))}),[g]),x=i.useCallback((e=>({modal:b(e),onConfirm:()=>y(e),onClose:()=>k(e),onChange:n=>v(e,n),onDestroy:()=>h(e)})),[b,y,k,v,h]),j=i.useMemo((()=>({modalIds:o,getModalNode:b,onChange:v,onConfirm:y,onClose:k,onDestroy:h,getModal:x,setUpdater:e=>{C.current=e}})),[o,x,b,v,y,k,h]);return r.jsx(re.Provider,{value:j,children:n})})),se=()=>i.useContext(re),ae=e=>{const{getModal:n}=se();return i.useMemo((()=>n(e)),[e,n])},le=i.createContext({}),ce=({context:e,children:n})=>{const t=i.useMemo((()=>({context:e||{}})),[e]);return r.jsx(le.Provider,{value:t,children:n})},ue=()=>i.useContext(le);exports.ModalProvider=({ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:c,FooterComponent:u,options:d,context:p,usePathname:f,children:b})=>{const{pathname:h}=(f||T)(),[,C]=l.useTick(),g=i.useRef(m.unanchored?m.anchor():null);return l.useOnMount((()=>(g.current?C():a.printError("ModalProvider is already initialized",["ModalProvider can only be initialized once.","Nesting ModalProvider will be ignored..."],{info:"Something is wrong with the ModalProvider initialization..."}),()=>{g.current&&g.current.remove()}))),r.jsxs(i.Fragment,{children:[b,g.current&&s.createPortal(r.jsx(ce,{context:p,children:r.jsx(W,{ForegroundComponent:e,BackgroundComponent:n,TitleComponent:t,SubtitleComponent:o,ContentComponent:c,FooterComponent:u,options:d,children:r.jsx(ie,{pathname:h,children:r.jsx(I,{})})})}),g.current)]})},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,p)=>{try{m.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){p(e)}})),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,p)=>{try{m.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){p(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:p,BackgroundComponent:f})=>new Promise(((b,h)=>{try{m.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:c,manualDestroy:u,closeOnBackdropClick:d,ForegroundComponent:p,BackgroundComponent:f})}catch(e){h(e)}})),exports.useActiveModalCount=E,exports.useDestroyAfter=(e,n)=>{const{modal:t,onDestroy:o}=ae(e),r=D(t),s=i.useRef({modal:t,onDestroy:o,milliseconds:a.isString(n)?a.convertMsFromDuration(n):n});i.useEffect((()=>{const{modal:e,onDestroy:n,milliseconds:t}=s.current;if(!e||e.visible||!e.alive)return;const o=setTimeout((()=>{n()}),t);return()=>{o&&clearTimeout(o)}}),[r])},exports.useModalAnimation=(e,n)=>{const t=i.useRef(n);t.current=n,i.useLayoutEffect((()=>{if(!t.current)return;let n;return n=e?requestAnimationFrame((()=>t.current.onVisible?.())):requestAnimationFrame((()=>t.current.onHidden?.())),()=>{n&&cancelAnimationFrame(n)}}),[e])},exports.useModalBackdrop=()=>U().backdrop,exports.useModalDuration=()=>{const e=U();return{duration:e.duration,milliseconds:a.convertMsFromDuration(e.duration)}},exports.useModalOptions=U,exports.useSubscribeModal=D;
18
18
  //# sourceMappingURL=index.cjs.js.map