@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.
Files changed (63) hide show
  1. package/dist/app/ModalManager.d.ts +15 -7
  2. package/dist/app/ModalManager.d.ts.map +1 -1
  3. package/dist/bootstrap/BootstrapProvider/BootstrapProvider.d.ts +11 -0
  4. package/dist/bootstrap/BootstrapProvider/BootstrapProvider.d.ts.map +1 -0
  5. package/dist/bootstrap/BootstrapProvider/index.d.ts +3 -0
  6. package/dist/bootstrap/BootstrapProvider/index.d.ts.map +1 -0
  7. package/dist/bootstrap/BootstrapProvider/type.d.ts +13 -0
  8. package/dist/bootstrap/BootstrapProvider/type.d.ts.map +1 -0
  9. package/dist/bootstrap/bootstrap.d.ts +12 -0
  10. package/dist/bootstrap/bootstrap.d.ts.map +1 -0
  11. package/dist/bootstrap/index.d.ts +3 -0
  12. package/dist/bootstrap/index.d.ts.map +1 -0
  13. package/dist/components/Anchor/Anchor.d.ts.map +1 -1
  14. package/dist/components/Background/Background.d.ts.map +1 -1
  15. package/dist/components/Foreground/Foreground.d.ts.map +1 -1
  16. package/dist/components/Foreground/components/AlertInner.d.ts.map +1 -1
  17. package/dist/components/Foreground/components/ConfirmInner.d.ts.map +1 -1
  18. package/dist/components/Foreground/components/PromptInner.d.ts.map +1 -1
  19. package/dist/core/handle/prompt.d.ts.map +1 -1
  20. package/dist/hooks/useActiveModalCount.d.ts.map +1 -1
  21. package/dist/hooks/useDestroyAfter.d.ts.map +1 -1
  22. package/dist/index.cjs.js +2 -2
  23. package/dist/index.cjs.js.map +1 -1
  24. package/dist/index.d.ts +2 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.esm.js +2 -3
  27. package/dist/index.esm.js.map +1 -1
  28. package/dist/providers/{ModalContext/ModalContext.d.ts → ConfigurationContext/ConfigurationContext.d.ts} +3 -3
  29. package/dist/providers/ConfigurationContext/ConfigurationContext.d.ts.map +1 -0
  30. package/dist/providers/{ModalContext/ModalContextProvider.d.ts → ConfigurationContext/ConfigurationContextProvider.d.ts} +4 -9
  31. package/dist/providers/ConfigurationContext/ConfigurationContextProvider.d.ts.map +1 -0
  32. package/dist/providers/ConfigurationContext/index.d.ts +3 -0
  33. package/dist/providers/ConfigurationContext/index.d.ts.map +1 -0
  34. package/dist/providers/ConfigurationContext/useConfigurationContext.d.ts +13 -0
  35. package/dist/providers/ConfigurationContext/useConfigurationContext.d.ts.map +1 -0
  36. package/dist/providers/{ModalDataContext/ModalDataContext.d.ts → ModalManagerContext/ModalManagerContext.d.ts} +3 -3
  37. package/dist/providers/ModalManagerContext/ModalManagerContext.d.ts.map +1 -0
  38. package/dist/providers/ModalManagerContext/ModalManagerContextProvider.d.ts +10 -0
  39. package/dist/providers/ModalManagerContext/ModalManagerContextProvider.d.ts.map +1 -0
  40. package/dist/providers/ModalManagerContext/index.d.ts +3 -0
  41. package/dist/providers/ModalManagerContext/index.d.ts.map +1 -0
  42. package/dist/providers/ModalManagerContext/useModalManagerContext.d.ts +4 -0
  43. package/dist/providers/ModalManagerContext/useModalManagerContext.d.ts.map +1 -0
  44. package/dist/providers/UserDefinedContext/UserDefinedContext.d.ts.map +1 -1
  45. package/dist/providers/UserDefinedContext/UserDefinedContextProvider.d.ts.map +1 -1
  46. package/dist/providers/index.d.ts +3 -2
  47. package/dist/providers/index.d.ts.map +1 -1
  48. package/package.json +3 -3
  49. package/dist/helpers/getMillisecondsFromDuration.d.ts +0 -2
  50. package/dist/helpers/getMillisecondsFromDuration.d.ts.map +0 -1
  51. package/dist/providers/ModalContext/ModalContext.d.ts.map +0 -1
  52. package/dist/providers/ModalContext/ModalContextProvider.d.ts.map +0 -1
  53. package/dist/providers/ModalContext/index.d.ts +0 -3
  54. package/dist/providers/ModalContext/index.d.ts.map +0 -1
  55. package/dist/providers/ModalContext/useModalContext.d.ts +0 -13
  56. package/dist/providers/ModalContext/useModalContext.d.ts.map +0 -1
  57. package/dist/providers/ModalDataContext/ModalDataContext.d.ts.map +0 -1
  58. package/dist/providers/ModalDataContext/ModalDataContextProvider.d.ts +0 -7
  59. package/dist/providers/ModalDataContext/ModalDataContextProvider.d.ts.map +0 -1
  60. package/dist/providers/ModalDataContext/index.d.ts +0 -3
  61. package/dist/providers/ModalDataContext/index.d.ts.map +0 -1
  62. package/dist/providers/ModalDataContext/useModalDataContext.d.ts +0 -4
  63. package/dist/providers/ModalDataContext/useModalDataContext.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/app/ModalManager.ts","../src/app/constant.ts","../src/providers/UserDefinedContext/UserDefinedContext.ts","../src/providers/UserDefinedContext/UserDefinedContextProvider.tsx","../src/providers/UserDefinedContext/useUserDefinedContext.ts","../src/components/Background/classNames.emotion.ts","../src/components/Background/Background.tsx","../src/components/Foreground/classNames.emotion.ts","../src/components/Foreground/components/AlertInner.tsx","../src/components/Foreground/components/ConfirmInner.tsx","../src/components/Foreground/components/PromptInner.tsx","../src/components/Foreground/Foreground.tsx","../src/hooks/useSubscribeModal.ts","../src/components/Presenter/classNames.emotion.ts","../src/components/Presenter/Presenter.tsx","../src/hooks/useActiveModalCount.ts","../src/core/node/ModalNode/AbstractNode.ts","../src/core/node/ModalNode/AlertNode.ts","../src/core/node/ModalNode/ConfirmNode.ts","../src/core/node/ModalNode/PromptNode.ts","../src/core/node/nodeFactory.ts","../src/helpers/getMillisecondsFromDuration.ts","../src/providers/ModalDataContext/ModalDataContext.ts","../src/providers/ModalDataContext/ModalDataContextProvider.tsx","../src/providers/ModalDataContext/useModalDataContext.ts","../src/components/Anchor/classNames.emotion.ts","../src/components/Anchor/Anchor.tsx","../src/components/FallbackComponents/classNames.emotion.ts","../src/components/FallbackComponents/FallbackTitle.tsx","../src/components/FallbackComponents/FallbackSubtitle.tsx","../src/components/FallbackComponents/FallbackContent.tsx","../src/components/FallbackComponents/FallbackFooter.tsx","../src/components/FallbackComponents/FallbackForegroundFrame.tsx","../src/hooks/useDefaultPathname.ts","../src/providers/ModalContext/ModalContext.ts","../src/providers/ModalContext/ModalContextProvider.tsx","../src/providers/ModalContext/useModalContext.ts","../src/core/handle/alert.ts","../src/core/handle/confirm.ts","../src/core/handle/prompt.ts","../src/hooks/useDestroyAfter.ts","../src/hooks/useModalAnimation.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\n\nimport { getRandomString } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { Modal } from '@/promise-modal/types';\n\nconst prerenderListRef: MutableRefObject<Modal[]> = {\n current: [],\n};\n\nconst openModalRef: MutableRefObject<Fn<[Modal], void>> = {\n current: (modal: Modal) => {\n prerenderListRef.current.push(modal);\n },\n};\n\nconst anchorRef: MutableRefObject<HTMLElement | null> = {\n current: null,\n};\n\nexport const ModalManager = {\n get prerender() {\n return prerenderListRef.current;\n },\n clearPrerender() {\n prerenderListRef.current = [];\n },\n open(modal: Modal) {\n openModalRef.current(modal);\n },\n setupOpen(open: (modal: Modal) => void) {\n openModalRef.current = open;\n },\n anchor(name: string, prefix = 'promise-modal'): HTMLElement {\n if (anchorRef.current) {\n const anchor = document.getElementById(anchorRef.current.id);\n if (anchor) return anchor;\n }\n const node = document.createElement(name);\n node.setAttribute('id', `${prefix}-${getRandomString(36)}`);\n document.body.appendChild(node);\n anchorRef.current = node;\n return node;\n },\n};\n","import type { Color, Duration } from '@aileron/types';\n\nexport const DEFAULT_ANIMATION_DURATION: Duration = '300ms';\n\nexport const DEFAULT_BACKDROP_COLOR: Color = 'rgba(0, 0, 0, 0.5)';\n","import { createContext } from 'react';\n\nimport { EMPTY_OBJECT } from '@winglet/common-utils';\n\nimport type { Dictionary } from '@aileron/types';\n\nexport interface UserDefinedContext {\n context: Dictionary;\n}\n\nexport const UserDefinedContext = createContext<UserDefinedContext>({\n context: EMPTY_OBJECT,\n});\n","import { PropsWithChildren, useMemo } from 'react';\n\nimport { EMPTY_OBJECT } from '@winglet/common-utils';\n\nimport type { Dictionary } from '@aileron/types';\n\nimport { UserDefinedContext } from './UserDefinedContext';\n\ninterface UserDefinedContextProviderProps {\n /** 사용자 정의 컨텍스트 */\n context?: Dictionary;\n}\n\nexport const UserDefinedContextProvider = ({\n context,\n children,\n}: PropsWithChildren<UserDefinedContextProviderProps>) => {\n const contextValue = useMemo(\n () => ({ context: context || EMPTY_OBJECT }),\n [context],\n );\n return (\n <UserDefinedContext.Provider value={contextValue}>\n {children}\n </UserDefinedContext.Provider>\n );\n};\n","import { useContext } from 'react';\n\nimport { UserDefinedContext } from './UserDefinedContext';\n\nexport const useUserDefinedContext = () => {\n return useContext(UserDefinedContext);\n};\n","import { css } from '@emotion/css';\n\nexport const background = css`\n display: none;\n position: fixed;\n inset: 0;\n z-index: -999;\n pointer-events: none;\n > * {\n pointer-events: none;\n }\n`;\n\nexport const active = css`\n pointer-events: all;\n`;\n\nexport const visible = css`\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n","import { type MouseEvent, useCallback, useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport { useUserDefinedContext } from '@/promise-modal/providers/UserDefinedContext';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, background, visible } from './classNames.emotion';\n\nexport const BackgroundFrame = ({\n modalId,\n onChangeOrder,\n}: ModalLayerProps) => {\n const { BackgroundComponent } = useModalContext();\n const { context: userDefinedContext } = useUserDefinedContext();\n const { modal, onClose, onChange, onConfirm, onDestroy } = useModal(modalId);\n\n const handleClose = useCallback(\n (event: MouseEvent) => {\n if (modal && modal.closeOnBackdropClick && modal.visible) onClose();\n event.stopPropagation();\n },\n [modal, onClose],\n );\n\n const Background = useMemo(\n () => modal?.BackgroundComponent || BackgroundComponent,\n [BackgroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(background, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.closeOnBackdropClick && modal.visible,\n })}\n onClick={handleClose}\n >\n {Background && (\n <Background\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n context={userDefinedContext}\n />\n )}\n </div>\n );\n};\n","import { css } from '@emotion/css';\n\nexport const foreground = css`\n pointer-events: none;\n display: none;\n position: fixed;\n inset: 0;\n z-index: 1;\n`;\n\nexport const active = css`\n > * {\n pointer-events: all;\n }\n`;\n\nexport const visible = css`\n display: flex !important;\n justify-content: center;\n align-items: center;\n`;\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { AlertNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport { useUserDefinedContext } from '@/promise-modal/providers/UserDefinedContext';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface AlertInnerProps<B> {\n modal: AlertNode<B>;\n handlers: Pick<ModalActions, 'onConfirm'>;\n}\n\nexport const AlertInner = memo(\n <B,>({ modal, handlers }: AlertInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { context: userDefinedContext } = useUserDefinedContext();\n const { onConfirm } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n confirmLabel={footer?.confirm}\n hideConfirm={footer?.hideConfirm}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { ConfirmNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport { useUserDefinedContext } from '@/promise-modal/providers/UserDefinedContext';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface ConfirmInnerProps<B> {\n modal: ConfirmNode<B>;\n handlers: Pick<ModalActions, 'onConfirm' | 'onClose'>;\n}\n\nexport const ConfirmInner = memo(\n <B,>({ modal, handlers }: ConfirmInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { context: userDefinedContext } = useUserDefinedContext();\n const { onConfirm, onClose } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n const handleClose = useHandle(onClose);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useCallback, useMemo, useState } from 'react';\n\nimport { isFunction, isString } from '@winglet/common-utils';\nimport {\n renderComponent,\n useHandle,\n withErrorBoundary,\n} from '@winglet/react-utils';\n\nimport type { PromptNode } from '@/promise-modal/core';\nimport { useModalContext } from '@/promise-modal/providers';\nimport { useUserDefinedContext } from '@/promise-modal/providers/UserDefinedContext';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface PromptInnerProps<T, B> {\n modal: PromptNode<T, B>;\n handlers: Pick<ModalActions, 'onChange' | 'onClose' | 'onConfirm'>;\n}\n\nexport const PromptInner = memo(\n <T, B>({ modal, handlers }: PromptInnerProps<T, B>) => {\n const {\n Input,\n defaultValue,\n disabled: checkDisabled,\n title,\n subtitle,\n content,\n footer,\n } = useMemo(\n () => ({\n ...modal,\n Input: memo(withErrorBoundary(modal.Input)),\n }),\n [modal],\n );\n\n const { context: userDefinedContext } = useUserDefinedContext();\n\n const [value, setValue] = useState<T | undefined>(defaultValue);\n\n const { onChange, onClose, onConfirm } = useMemo(\n () => handlers,\n [handlers],\n );\n\n const handleClose = useHandle(onClose);\n const handleChange = useHandle(\n (inputValue?: T | ((prevState: T | undefined) => T | undefined)) => {\n const input = isFunction(inputValue) ? inputValue(value) : inputValue;\n setValue(input);\n onChange(input);\n },\n );\n\n const handleConfirm = useCallback(() => {\n // NOTE: wait for the next tick to ensure the value is updated\n setTimeout(() => {\n onConfirm();\n });\n }, [onConfirm]);\n\n const disabled = useMemo(\n () => (value ? !!checkDisabled?.(value) : false),\n [checkDisabled, value],\n );\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useModalContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ))}\n\n {Input && (\n <Input\n defaultValue={defaultValue}\n value={value}\n onChange={handleChange}\n onConfirm={handleConfirm}\n onCancel={handleClose}\n context={userDefinedContext}\n />\n )}\n\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n value,\n disabled,\n onChange: handleChange,\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n disabled={disabled}\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport { useUserDefinedContext } from '@/promise-modal/providers/UserDefinedContext';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, foreground, visible } from './classNames.emotion';\nimport { AlertInner, ConfirmInner, PromptInner } from './components';\n\nexport const ForegroundFrame = ({\n modalId,\n onChangeOrder,\n}: ModalLayerProps) => {\n const { ForegroundComponent } = useModalContext();\n const { context: userDefinedContext } = useUserDefinedContext();\n\n const { modal, onChange, onConfirm, onClose, onDestroy } = useModal(modalId);\n\n const Foreground = useMemo(\n () => modal?.ForegroundComponent || ForegroundComponent,\n [ForegroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(foreground, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.visible,\n })}\n >\n <Foreground\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n context={userDefinedContext}\n >\n {modal.type === 'alert' && (\n <AlertInner modal={modal} handlers={{ onConfirm }} />\n )}\n {modal.type === 'confirm' && (\n <ConfirmInner modal={modal} handlers={{ onConfirm, onClose }} />\n )}\n {modal.type === 'prompt' && (\n <PromptInner\n modal={modal}\n handlers={{ onChange, onConfirm, onClose }}\n />\n )}\n </Foreground>\n </div>\n );\n};\n","import { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { ModalNode } from '@/promise-modal/core';\n\nexport const useSubscribeModal = (modal?: ModalNode) => {\n const [tick, update] = useTick();\n useOnMount(() => {\n if (!modal) return;\n const unsubscribe = modal.subscribe(update);\n return unsubscribe;\n });\n return tick;\n};\n","import { css } from '@emotion/css';\n\nexport const presenter = css`\n position: fixed;\n inset: 0;\n pointer-events: none;\n overflow: hidden;\n`;\n","import { memo, useRef } from 'react';\n\nimport { counterFactory } from '@winglet/common-utils';\nimport { useHandle } from '@winglet/react-utils';\n\nimport { Background } from '@/promise-modal/components/Background';\nimport { Foreground } from '@/promise-modal/components/Foreground';\nimport { useSubscribeModal } from '@/promise-modal/hooks/useSubscribeModal';\nimport { useModal } from '@/promise-modal/providers';\nimport type { ModalIdProps } from '@/promise-modal/types';\n\nimport { presenter } from './classNames.emotion';\n\nconst { increment } = counterFactory(1);\n\nexport const Presenter = memo(({ modalId }: ModalIdProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { modal } = useModal(modalId);\n useSubscribeModal(modal);\n const handleChangeOrder = useHandle(() => {\n if (ref.current) {\n ref.current.style.zIndex = `${increment()}`;\n }\n });\n return (\n <div ref={ref} className={presenter}>\n <Background modalId={modalId} onChangeOrder={handleChangeOrder} />\n <Foreground modalId={modalId} onChangeOrder={handleChangeOrder} />\n </div>\n );\n});\n","import { useMemo } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '../core';\nimport { useModalDataContext } from '../providers';\n\nconst defaultValidate = (modal?: ModalNode) => modal?.visible;\n\nexport const useActiveModalCount = (\n validate: Fn<[ModalNode?], boolean | undefined> = defaultValidate,\n refreshKey: string | number = 0,\n) => {\n const { modalIds, getModalNode } = useModalDataContext();\n return useMemo(() => {\n let count = 0;\n for (const id of modalIds) {\n if (validate(getModalNode(id))) count++;\n }\n return count;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getModalNode, modalIds, refreshKey]);\n};\n","import type { ReactNode } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type {\n BackgroundComponent,\n BaseModal,\n ForegroundComponent,\n ManagedEntity,\n ModalBackground,\n} from '@/promise-modal/types';\n\ntype AbstractNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;\n\nexport abstract class AbstractNode<T, B> {\n readonly id: number;\n readonly initiator: string;\n\n readonly title?: ReactNode;\n readonly subtitle?: ReactNode;\n readonly background?: ModalBackground<B>;\n\n readonly manualDestroy: boolean;\n readonly closeOnBackdropClick: boolean;\n readonly dimmed: boolean;\n\n readonly ForegroundComponent?: ForegroundComponent;\n readonly BackgroundComponent?: BackgroundComponent;\n\n #alive: boolean;\n get alive() {\n return this.#alive;\n }\n #visible: boolean;\n get visible() {\n return this.#visible;\n }\n\n #resolve: (result: T | null) => void;\n #listeners: Fn[] = [];\n\n constructor({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed = true,\n manualDestroy = false,\n closeOnBackdropClick = true,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AbstractNodeProps<T, B>) {\n this.id = id;\n this.initiator = initiator;\n this.title = title;\n this.subtitle = subtitle;\n this.background = background;\n\n this.dimmed = dimmed;\n this.manualDestroy = manualDestroy;\n this.closeOnBackdropClick = closeOnBackdropClick;\n\n this.ForegroundComponent = ForegroundComponent;\n this.BackgroundComponent = BackgroundComponent;\n\n this.#alive = true;\n this.#visible = true;\n this.#resolve = resolve;\n }\n\n subscribe(listener: Fn) {\n this.#listeners.push(listener);\n return () => {\n this.#listeners = this.#listeners.filter((l) => l !== listener);\n };\n }\n publish() {\n for (const listener of this.#listeners) listener();\n }\n protected resolve(result: T | null) {\n this.#resolve(result);\n }\n onDestroy() {\n const needPublish = this.#alive === true;\n this.#alive = false;\n if (this.manualDestroy && needPublish) this.publish();\n }\n onShow() {\n const needPublish = this.#visible === false;\n this.#visible = true;\n if (needPublish) this.publish();\n }\n onHide() {\n const needPublish = this.#visible === true;\n this.#visible = false;\n if (needPublish) this.publish();\n }\n abstract onClose(): void;\n abstract onConfirm(): void;\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n AlertContentProps,\n AlertFooterRender,\n AlertModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype AlertNodeProps<B> = AlertModal<B> & ManagedEntity;\n\nexport class AlertNode<B> extends AbstractNode<null, B> {\n readonly type: 'alert';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<AlertContentProps>;\n readonly footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AlertNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(null);\n }\n onConfirm() {\n this.resolve(null);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n ConfirmContentProps,\n ConfirmFooterRender,\n ConfirmModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype ConfirmNodeProps<B> = ConfirmModal<B> & ManagedEntity;\n\nexport class ConfirmNode<B> extends AbstractNode<boolean, B> {\n readonly type: 'confirm';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<ConfirmContentProps>;\n readonly footer?: ConfirmFooterRender | FooterOptions | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: ConfirmNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(false);\n }\n onConfirm() {\n this.resolve(true);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n FooterOptions,\n ManagedEntity,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n PromptModal,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype PromptNodeProps<T, B> = PromptModal<T, B> & ManagedEntity;\n\nexport class PromptNode<T, B> extends AbstractNode<T, B> {\n readonly type: 'prompt';\n readonly content?: ReactNode | ComponentType<PromptContentProps>;\n readonly defaultValue: T | undefined;\n readonly Input: (props: PromptInputProps<T>) => ReactNode;\n readonly disabled?: (value: T) => boolean;\n readonly returnOnCancel?: boolean;\n readonly footer?: PromptFooterRender<T> | FooterOptions | false;\n #value: T | undefined;\n\n constructor({\n id,\n initiator,\n type,\n title,\n subtitle,\n content,\n defaultValue,\n Input,\n disabled,\n returnOnCancel,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: PromptNodeProps<T, B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.content = content;\n this.Input = Input;\n this.defaultValue = defaultValue;\n this.#value = defaultValue;\n this.disabled = disabled;\n this.returnOnCancel = returnOnCancel;\n this.footer = footer;\n }\n\n onChange(value: T) {\n this.#value = value;\n }\n onConfirm() {\n this.resolve(this.#value ?? null);\n }\n onClose() {\n if (this.returnOnCancel) this.resolve(this.#value ?? null);\n else this.resolve(null);\n }\n}\n","import type { ManagedModal } from '@/promise-modal/types';\n\nimport { AlertNode, ConfirmNode, PromptNode } from './ModalNode';\n\nexport const nodeFactory = <T, B>(modal: ManagedModal<T, B>) => {\n switch (modal.type) {\n case 'alert':\n return new AlertNode<B>(modal);\n case 'confirm':\n return new ConfirmNode<B>(modal);\n case 'prompt':\n return new PromptNode<T, B>(modal);\n }\n // @ts-expect-error: This state is unreachable by design and should NEVER occur.\n throw new Error(`Unknown modal: ${modal.type}`, { modal });\n};\n","const DURATION_REGEX = /^\\s*(\\d+)\\s*(ms|s|m|h)\\s*$/;\n\nexport const getMillisecondsFromDuration = (input: string) => {\n const [, durationString, unit] = input.match(DURATION_REGEX) || [];\n if (!durationString || !unit) return 0;\n const duration = parseInt(durationString);\n if (unit === 'ms') return duration;\n if (unit === 's') return duration * 1000;\n if (unit === 'm') return duration * 60 * 1000;\n if (unit === 'h') return duration * 60 * 60 * 1000;\n else return 0;\n};\n","import { createContext } from 'react';\n\nimport { undefinedFunction } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport type { ModalActions, ModalHandlersWithId } from '@/promise-modal/types';\n\nexport interface ModalDataContextProps extends ModalHandlersWithId {\n modalIds: ModalNode['id'][];\n getModal: Fn<[id: ModalNode['id']], ModalActions>;\n getModalNode: Fn<[id: ModalNode['id']], ModalNode | undefined>;\n setUpdater: Fn<[updater: Fn]>;\n}\n\nexport const ModalDataContext = createContext<ModalDataContextProps>({\n modalIds: [],\n getModalNode: undefinedFunction,\n onChange: undefinedFunction,\n onConfirm: undefinedFunction,\n onClose: undefinedFunction,\n onDestroy: undefinedFunction,\n setUpdater: undefinedFunction,\n getModal: () => ({\n modal: undefined,\n onConfirm: undefinedFunction,\n onClose: undefinedFunction,\n onChange: undefinedFunction,\n onDestroy: undefinedFunction,\n }),\n});\n","import {\n type PropsWithChildren,\n memo,\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useOnMountLayout, useReference } from '@winglet/react-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport { type ModalNode, nodeFactory } from '@/promise-modal/core';\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\nimport { useModalOptions } from '@/promise-modal/providers';\nimport type { Modal } from '@/promise-modal/types';\n\nimport { ModalDataContext } from './ModalDataContext';\n\ninterface ModalDataContextProviderProps {\n pathname: string;\n}\n\nexport const ModalDataContextProvider = memo(\n ({\n pathname,\n children,\n }: PropsWithChildren<ModalDataContextProviderProps>) => {\n const modalDictionary = useRef<Map<ModalNode['id'], ModalNode>>(new Map());\n\n const [modalIds, setModalIds] = useState<ModalNode['id'][]>([]);\n const modalIdsRef = useReference(modalIds);\n\n const initiator = useRef(pathname);\n const modalIdSequence = useRef(0);\n\n const options = useModalOptions();\n\n const duration = useMemo(\n () => getMillisecondsFromDuration(options.duration),\n [options],\n );\n\n useOnMountLayout(() => {\n const { manualDestroy, closeOnBackdropClick } = options;\n\n for (const data of ModalManager.prerender) {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => [...ids, modal.id]);\n }\n\n ModalManager.setupOpen((data: Modal) => {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => {\n const aliveIds = ids.filter((id) => {\n const destroyed = !modalDictionary.current.get(id)?.alive;\n if (destroyed) modalDictionary.current.delete(id);\n return !destroyed;\n });\n return [...aliveIds, modal.id];\n });\n });\n ModalManager.clearPrerender();\n });\n\n useLayoutEffect(() => {\n for (const id of modalIdsRef.current) {\n const modal = modalDictionary.current.get(id);\n if (!modal?.alive) continue;\n if (modal.initiator === pathname) modal.onShow();\n else modal.onHide();\n }\n initiator.current = pathname;\n }, [modalIdsRef, pathname]);\n\n const getModalNode = useCallback((modalId: ModalNode['id']) => {\n return modalDictionary.current.get(modalId);\n }, []);\n\n const onDestroy = useCallback((modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onDestroy();\n updaterRef.current?.();\n }, []);\n\n const updaterRef = useRef<Fn>();\n const hideModal = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onHide();\n updaterRef.current?.();\n if (!modal.manualDestroy)\n setTimeout(() => {\n modal.onDestroy();\n }, duration);\n },\n [duration],\n );\n\n const onChange = useCallback((modalId: ModalNode['id'], value: any) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n if (modal.type === 'prompt') modal.onChange(value);\n }, []);\n\n const onConfirm = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onConfirm();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const onClose = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onClose();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const getModal = useCallback(\n (modalId: ModalNode['id']) => ({\n modal: getModalNode(modalId),\n onConfirm: () => onConfirm(modalId),\n onClose: () => onClose(modalId),\n onChange: (value: any) => onChange(modalId, value),\n onDestroy: () => onDestroy(modalId),\n }),\n [getModalNode, onConfirm, onClose, onChange, onDestroy],\n );\n\n const value = useMemo(() => {\n return {\n modalIds,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n getModal,\n setUpdater: (updater: Fn) => {\n updaterRef.current = updater;\n },\n };\n }, [\n modalIds,\n getModal,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n ]);\n\n return (\n <ModalDataContext.Provider value={value}>\n {children}\n </ModalDataContext.Provider>\n );\n },\n);\n","import { useContext, useMemo } from 'react';\n\nimport type { ManagedModal } from '@/promise-modal/types';\n\nimport { ModalDataContext } from './ModalDataContext';\n\nexport const useModalDataContext = () => useContext(ModalDataContext);\n\nexport const useModal = (id: ManagedModal['id']) => {\n const { getModal } = useModalDataContext();\n return useMemo(() => getModal(id), [id, getModal]);\n};\n","import { css } from '@emotion/css';\n\nexport const anchor = css`\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: 1000;\n transition: background-color ease-in-out;\n`;\n","import { memo, useEffect } from 'react';\n\nimport { useTick, withErrorBoundary } from '@winglet/react-utils';\n\nimport { Presenter } from '@/promise-modal/components/Presenter';\nimport type { ModalNode } from '@/promise-modal/core';\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport { useModalContext } from '@/promise-modal/providers';\nimport { useModalDataContext } from '@/promise-modal/providers/ModalDataContext';\n\nimport { anchor } from './classNames.emotion';\n\nconst AnchorInner = () => {\n const [refreshKey, update] = useTick();\n\n const { modalIds, setUpdater } = useModalDataContext();\n\n useEffect(() => {\n setUpdater(update);\n }, [setUpdater, update]);\n\n const { options } = useModalContext();\n\n const dimmed = useActiveModalCount(validateDimmable, refreshKey);\n\n return (\n <div\n className={anchor}\n style={{\n transitionDuration: options.duration,\n backgroundColor: dimmed ? options.backdrop : 'transparent',\n }}\n >\n {modalIds.map((id) => {\n return <Presenter key={id} modalId={id} />;\n })}\n </div>\n );\n};\n\nconst validateDimmable = (modal?: ModalNode) => modal?.visible && modal.dimmed;\n\nexport const Anchor = memo(withErrorBoundary(AnchorInner));\n","import { css } from '@emotion/css';\n\nexport const fallback = css`\n margin: unset;\n`;\n\nexport const frame = css`\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n background-color: white;\n padding: 20px 80px;\n gap: 10px;\n border: 1px solid black;\n`;\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackTitle = ({ children }: PropsWithChildren) => {\n return <h2 className={fallback}>{children}</h2>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackSubtitle = ({ children }: PropsWithChildren) => {\n return <h3 className={fallback}>{children}</h3>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackContent = ({ children }: PropsWithChildren) => {\n return <div className={fallback}>{children}</div>;\n};\n","import type { FooterComponentProps } from '@/promise-modal/types';\n\nexport const FallbackFooter = ({\n confirmLabel,\n hideConfirm = false,\n cancelLabel,\n hideCancel = false,\n disabled,\n onConfirm,\n onCancel,\n}: FooterComponentProps) => {\n return (\n <div>\n {!hideConfirm && (\n <button onClick={onConfirm} disabled={disabled}>\n {confirmLabel || '확인'}\n </button>\n )}\n\n {!hideCancel && typeof onCancel === 'function' && (\n <button onClick={onCancel}>{cancelLabel || '취소'}</button>\n )}\n </div>\n );\n};\n","import {\n type ForwardedRef,\n type PropsWithChildren,\n forwardRef,\n useMemo,\n} from 'react';\n\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport type { ModalFrameProps } from '@/promise-modal/types';\n\nimport { frame } from './classNames.emotion';\n\nconst MAX_MODAL_COUNT = 5;\nconst MAX_MODAL_LEVEL = 3;\n\nexport const FallbackForegroundFrame = forwardRef(\n (\n { id, onChangeOrder, children }: PropsWithChildren<ModalFrameProps>,\n ref: ForwardedRef<HTMLDivElement>,\n ) => {\n const activeCount = useActiveModalCount();\n const [level, offset] = useMemo(() => {\n const stacked = activeCount > 1;\n const level = stacked\n ? (Math.floor(id / MAX_MODAL_COUNT) % MAX_MODAL_LEVEL) * 100\n : 0;\n const offset = stacked ? (id % MAX_MODAL_COUNT) * 35 : 0;\n return [level, offset];\n }, [activeCount, id]);\n\n return (\n <div\n ref={ref}\n className={frame}\n onClick={onChangeOrder}\n style={{\n marginBottom: `calc(25vh + ${level}px)`,\n marginLeft: `${level}px`,\n transform: `translate(${offset}px, ${offset}px)`,\n }}\n >\n {children}\n </div>\n );\n },\n);\n","import { useLayoutEffect, useState } from 'react';\n\nexport const usePathname = () => {\n const [pathname, setPathname] = useState(window.location.pathname);\n useLayoutEffect(() => {\n let requestId: number;\n const checkPathname = () => {\n if (requestId) cancelAnimationFrame(requestId);\n if (pathname !== window.location.pathname) {\n setPathname(window.location.pathname);\n } else {\n requestId = requestAnimationFrame(checkPathname);\n }\n };\n requestId = requestAnimationFrame(checkPathname);\n return () => {\n if (requestId) cancelAnimationFrame(requestId);\n };\n }, [pathname]);\n return { pathname };\n};\n","import { type ComponentType, createContext } from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport type {\n BackgroundComponent,\n FooterComponentProps,\n ForegroundComponent,\n WrapperComponentProps,\n} from '@/promise-modal/types';\n\nexport interface ModalContextProps {\n ForegroundComponent: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n TitleComponent: ComponentType<WrapperComponentProps>;\n SubtitleComponent: ComponentType<WrapperComponentProps>;\n ContentComponent: ComponentType<WrapperComponentProps>;\n FooterComponent: ComponentType<FooterComponentProps>;\n options: {\n duration: Duration;\n backdrop: Color;\n manualDestroy: boolean;\n closeOnBackdropClick: boolean;\n };\n}\n\nexport const ModalContext = createContext<ModalContextProps>({\n ForegroundComponent: FallbackForegroundFrame,\n TitleComponent: FallbackTitle,\n SubtitleComponent: FallbackSubtitle,\n ContentComponent: FallbackContent,\n FooterComponent: FallbackFooter,\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n manualDestroy: false,\n closeOnBackdropClick: true,\n },\n});\n","import {\n type ComponentType,\n type PropsWithChildren,\n memo,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { Color, Dictionary, Duration } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport { Anchor } from '@/promise-modal/components/Anchor';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport { usePathname as useDefaultPathname } from '@/promise-modal/hooks/useDefaultPathname';\nimport type {\n FooterComponentProps,\n ModalFrameProps,\n WrapperComponentProps,\n} from '@/promise-modal/types';\n\nimport { ModalDataContextProvider } from '../ModalDataContext';\nimport { UserDefinedContextProvider } from '../UserDefinedContext';\nimport { ModalContext } from './ModalContext';\n\ninterface ModalContextProviderProps {\n BackgroundComponent?: ComponentType<ModalFrameProps>;\n ForegroundComponent?: ComponentType<ModalFrameProps>;\n TitleComponent?: ComponentType<WrapperComponentProps>;\n SubtitleComponent?: ComponentType<WrapperComponentProps>;\n ContentComponent?: ComponentType<WrapperComponentProps>;\n FooterComponent?: ComponentType<FooterComponentProps>;\n options?: {\n /** Modal transition time(ms, s) */\n duration?: Duration;\n /** Modal backdrop color */\n backdrop?: Color;\n /** Whether to destroy the modal manually */\n manualDestroy?: boolean;\n /** Whether to close the modal when the backdrop is clicked */\n closeOnBackdropClick?: boolean;\n };\n context?: Dictionary;\n usePathname?: () => { pathname: string };\n}\n\nexport const ModalContextProvider = memo(\n ({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n options,\n context,\n usePathname,\n children,\n }: PropsWithChildren<ModalContextProviderProps>) => {\n const { pathname } = (usePathname || useDefaultPathname)();\n const [, update] = useTick();\n const portalRef = useRef<HTMLElement | null>(null);\n\n useOnMount(() => {\n portalRef.current = ModalManager.anchor('div');\n update();\n return () => {\n if (portalRef.current) {\n portalRef.current.remove();\n }\n };\n });\n\n const value = useMemo(\n () => ({\n BackgroundComponent,\n ForegroundComponent: ForegroundComponent || FallbackForegroundFrame,\n TitleComponent: TitleComponent || FallbackTitle,\n SubtitleComponent: SubtitleComponent || FallbackSubtitle,\n ContentComponent: memo(ContentComponent || FallbackContent),\n FooterComponent: memo(FooterComponent || FallbackFooter),\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n closeOnBackdropClick: true,\n manualDestroy: false,\n ...options,\n } satisfies ModalContextProviderProps['options'],\n }),\n [\n ForegroundComponent,\n BackgroundComponent,\n ContentComponent,\n FooterComponent,\n SubtitleComponent,\n TitleComponent,\n options,\n ],\n );\n\n return (\n <ModalContext.Provider value={value}>\n {children}\n {portalRef.current &&\n createPortal(\n <UserDefinedContextProvider context={context}>\n <ModalDataContextProvider pathname={pathname}>\n <Anchor />\n </ModalDataContextProvider>\n </UserDefinedContextProvider>,\n portalRef.current,\n )}\n </ModalContext.Provider>\n );\n },\n);\n","import { useContext } from 'react';\n\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\n\nimport { ModalContext } from './ModalContext';\n\nexport const useModalContext = () => useContext(ModalContext);\n\nexport const useModalOptions = () => {\n const { options } = useContext(ModalContext);\n return options;\n};\n\nexport const useModalDuration = () => {\n const { duration } = useModalOptions();\n return { duration, milliseconds: getMillisecondsFromDuration(duration) };\n};\n\nexport const useModalBackdrop = () => {\n const { backdrop } = useModalOptions();\n return backdrop;\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n AlertContentProps,\n AlertFooterRender,\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface AlertProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<AlertContentProps>;\n background?: ModalBackground<B>;\n footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const alert = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: AlertProps<B>) => {\n return new Promise<void>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'alert',\n subtype,\n resolve: () => resolve(),\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n BackgroundComponent,\n ConfirmContentProps,\n ConfirmFooterRender,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface ConfirmProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<ConfirmContentProps>;\n background?: ModalBackground<B>;\n footer?: ConfirmFooterRender | FooterOptions | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const confirm = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: ConfirmProps<B>) => {\n return new Promise<boolean>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'confirm',\n subtype,\n resolve: (result) => resolve(result ?? false),\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n} from '@/promise-modal/types';\n\nimport { ModalManager } from '../../app/ModalManager';\n\ninterface PromptProps<T, B = any> {\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<PromptContentProps>;\n Input: (props: PromptInputProps<T>) => ReactNode;\n defaultValue?: T;\n disabled?: (value: T) => boolean;\n returnOnCancel?: boolean;\n background?: ModalBackground<B>;\n footer?: PromptFooterRender<T> | FooterOptions | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const prompt = <T, B = any>({\n defaultValue,\n title,\n subtitle,\n content,\n Input,\n disabled,\n returnOnCancel,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: PromptProps<T, B>) => {\n return new Promise<T>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'prompt',\n resolve: (result) => resolve(result as T),\n title,\n subtitle,\n content,\n Input,\n defaultValue,\n disabled,\n returnOnCancel,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import { useEffect, useRef } from 'react';\n\nimport { isString } from '@winglet/common-utils';\n\nimport type { Duration } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport { getMillisecondsFromDuration } from '@/promise-modal/helpers/getMillisecondsFromDuration';\n\nimport { useModal } from '../providers';\nimport { useSubscribeModal } from './useSubscribeModal';\n\nexport const useDestroyAfter = (\n modalId: ModalNode['id'],\n duration: Duration | number,\n) => {\n const { modal, onDestroy } = useModal(modalId);\n const tick = useSubscribeModal(modal);\n\n const reference = useRef({\n modal,\n onDestroy,\n milliseconds: isString(duration)\n ? getMillisecondsFromDuration(duration)\n : duration,\n });\n\n useEffect(() => {\n const { modal, onDestroy, milliseconds } = reference.current;\n if (!modal || modal.visible || !modal.alive) return;\n const timer = setTimeout(() => {\n onDestroy();\n }, milliseconds);\n return () => {\n if (timer) clearTimeout(timer);\n };\n }, [tick]);\n};\n","import { useLayoutEffect, useRef } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\ninterface ModalAnimationHandler {\n onVisible?: Fn;\n onHidden?: Fn;\n}\n\nexport const useModalAnimation = (\n visible: boolean,\n handler: ModalAnimationHandler,\n) => {\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n useLayoutEffect(() => {\n if (!handlerRef.current) return;\n let frame: ReturnType<typeof requestAnimationFrame>;\n if (visible)\n frame = requestAnimationFrame(() => handlerRef.current.onVisible?.());\n else frame = requestAnimationFrame(() => handlerRef.current.onHidden?.());\n return () => {\n if (frame) cancelAnimationFrame(frame);\n };\n }, [visible]);\n};\n"],"names":["prerenderListRef","current","openModalRef","modal","push","anchorRef","ModalManager","prerender","clearPrerender","open","setupOpen","anchor","name","prefix","document","getElementById","id","node","createElement","setAttribute","getRandomString","body","appendChild","DEFAULT_ANIMATION_DURATION","DEFAULT_BACKDROP_COLOR","UserDefinedContext","createContext","context","EMPTY_OBJECT","UserDefinedContextProvider","children","contextValue","useMemo","_jsx","jsx","Provider","value","useUserDefinedContext","useContext","background","css","process","env","NODE_ENV","styles","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","active","visible","BackgroundFrame","modalId","onChangeOrder","BackgroundComponent","useModalContext","userDefinedContext","onClose","onChange","onConfirm","onDestroy","useModal","handleClose","useCallback","event","closeOnBackdropClick","stopPropagation","Background","className","cx","visible$1","manualDestroy","alive","active$1","onClick","type","initiator","foreground","AlertInner","memo","handlers","title","subtitle","content","footer","handleConfirm","useHandle","TitleComponent","SubtitleComponent","ContentComponent","FooterComponent","_jsxs","Fragment","isString","renderComponent","confirmLabel","confirm","hideConfirm","ConfirmInner","onCancel","cancelLabel","cancel","hideCancel","PromptInner","Input","defaultValue","disabled","checkDisabled","withErrorBoundary","setValue","useState","handleChange","inputValue","input","isFunction","setTimeout","ForegroundFrame","ForegroundComponent","Foreground","useSubscribeModal","tick","update","useTick","useOnMount","subscribe","presenter","increment","counterFactory","Presenter","ref","useRef","handleChangeOrder","style","zIndex","defaultValidate","useActiveModalCount","validate","refreshKey","modalIds","getModalNode","useModalDataContext","count","AbstractNode","__classPrivateFieldGet","this","_AbstractNode_alive","_AbstractNode_visible","constructor","dimmed","resolve","Object","defineProperty","set","_AbstractNode_resolve","_AbstractNode_listeners","__classPrivateFieldSet","listener","filter","l","publish","result","call","needPublish","onShow","onHide","AlertNode","subtype","super","ConfirmNode","PromptNode","returnOnCancel","_PromptNode_value","nodeFactory","Error","DURATION_REGEX","getMillisecondsFromDuration","durationString","unit","match","duration","parseInt","ModalDataContext","undefinedFunction","setUpdater","getModal","undefined","ModalDataContextProvider","pathname","modalDictionary","Map","setModalIds","modalIdsRef","useReference","modalIdSequence","options","useModalOptions","useOnMountLayout","data","ids","destroyed","get","delete","useLayoutEffect","updaterRef","hideModal","updater","validateDimmable","Anchor","useEffect","transitionDuration","backgroundColor","backdrop","map","fallback","frame","FallbackTitle","FallbackSubtitle","FallbackContent","FallbackFooter","FallbackForegroundFrame","forwardRef","activeCount","level","offset","stacked","Math","floor","marginBottom","marginLeft","transform","usePathname","setPathname","window","location","requestId","checkPathname","cancelAnimationFrame","requestAnimationFrame","ModalContext","ModalContextProvider","useDefaultPathname","portalRef","remove","jsxs","createPortal","Promise","reject","error","reference","milliseconds","timer","clearTimeout","handler","handlerRef","onVisible","onHidden"],"mappings":"yLAQA,MAAMA,EAA8C,CAClDC,QAAS,IAGLC,EAAoD,CACxDD,QAAUE,IACRH,EAAiBC,QAAQG,KAAKD,EAAM,GAIlCE,EAAkD,CACtDJ,QAAS,MAGEK,EAAe,CAC1B,aAAIC,GACF,OAAOP,EAAiBC,OACzB,EACD,cAAAO,GACER,EAAiBC,QAAU,EAC5B,EACD,IAAAQ,CAAKN,GACHD,EAAaD,QAAQE,EACtB,EACD,SAAAO,CAAUD,GACRP,EAAaD,QAAUQ,CACxB,EACD,MAAAE,CAAOC,EAAcC,EAAS,iBAC5B,GAAIR,EAAUJ,QAAS,CACrB,MAAMU,EAASG,SAASC,eAAeV,EAAUJ,QAAQe,IACzD,GAAIL,EAAQ,OAAOA,EAErB,MAAMM,EAAOH,SAASI,cAAcN,GAIpC,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,CAACpK,GAAS,2BLNiB,KAC9B,MAAMiK,SAAEA,GAAahB,KACrB,OAAOgB,CAAQ,2BAPe,KAC9B,MAAMhC,SAAEA,GAAagB,KACrB,MAAO,CAAEhB,WAAUsE,aAAc1E,EAA4BI,GAAW"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/app/ModalManager.ts","../src/core/node/ModalNode/AbstractNode.ts","../src/core/node/ModalNode/AlertNode.ts","../src/core/node/ModalNode/ConfirmNode.ts","../src/core/node/ModalNode/PromptNode.ts","../src/core/node/nodeFactory.ts","../src/providers/ModalManagerContext/ModalManagerContext.ts","../src/providers/ModalManagerContext/ModalManagerContextProvider.tsx","../src/providers/ModalManagerContext/useModalManagerContext.ts","../src/components/FallbackComponents/classNames.emotion.ts","../src/components/FallbackComponents/FallbackTitle.tsx","../src/components/FallbackComponents/FallbackSubtitle.tsx","../src/components/FallbackComponents/FallbackContent.tsx","../src/components/FallbackComponents/FallbackFooter.tsx","../src/hooks/useActiveModalCount.ts","../src/components/FallbackComponents/FallbackForegroundFrame.tsx","../src/providers/ConfigurationContext/ConfigurationContext.ts","../src/providers/ConfigurationContext/ConfigurationContextProvider.tsx","../src/app/constant.ts","../src/providers/ConfigurationContext/useConfigurationContext.ts","../src/providers/UserDefinedContext/UserDefinedContext.ts","../src/providers/UserDefinedContext/UserDefinedContextProvider.tsx","../src/providers/UserDefinedContext/useUserDefinedContext.ts","../src/components/Background/classNames.emotion.ts","../src/components/Background/Background.tsx","../src/components/Foreground/classNames.emotion.ts","../src/components/Foreground/components/AlertInner.tsx","../src/components/Foreground/components/ConfirmInner.tsx","../src/components/Foreground/components/PromptInner.tsx","../src/components/Foreground/Foreground.tsx","../src/hooks/useSubscribeModal.ts","../src/components/Presenter/classNames.emotion.ts","../src/components/Presenter/Presenter.tsx","../src/components/Anchor/classNames.emotion.ts","../src/components/Anchor/Anchor.tsx","../src/bootstrap/bootstrap.tsx","../src/hooks/useDefaultPathname.ts","../src/bootstrap/BootstrapProvider/BootstrapProvider.tsx","../src/core/handle/alert.ts","../src/core/handle/confirm.ts","../src/core/handle/prompt.ts","../src/hooks/useDestroyAfter.ts","../src/hooks/useModalAnimation.ts"],"sourcesContent":["import { getRandomString } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { Modal } from '@/promise-modal/types';\n\nexport class ModalManager {\n static #active = false;\n static activate() {\n if (ModalManager.#active) return false;\n return (ModalManager.#active = true);\n }\n\n static #anchor: HTMLElement | null = null;\n static anchor(options?: {\n tag?: string;\n prefix?: string;\n root?: HTMLElement;\n }): HTMLElement {\n if (ModalManager.#anchor) {\n const anchor = document.getElementById(ModalManager.#anchor.id);\n if (anchor) return anchor;\n }\n const {\n tag = 'div',\n prefix = 'promise-modal',\n root = document.body,\n } = options || {};\n const node = document.createElement(tag);\n node.setAttribute('id', `${prefix}-${getRandomString(36)}`);\n root.appendChild(node);\n ModalManager.#anchor = node;\n return node;\n }\n\n static #prerenderList: Modal[] = [];\n static get prerender() {\n return ModalManager.#prerenderList;\n }\n\n static #openHandler: Fn<[Modal], void> = (modal: Modal) =>\n ModalManager.#prerenderList.push(modal);\n static set openHandler(handler: Fn<[Modal], void>) {\n ModalManager.#openHandler = handler;\n ModalManager.#prerenderList = [];\n }\n\n static get unanchored() {\n return !ModalManager.#anchor;\n }\n\n static reset() {\n ModalManager.#active = false;\n ModalManager.#anchor = null;\n ModalManager.#prerenderList = [];\n ModalManager.#openHandler = (modal: Modal) =>\n ModalManager.#prerenderList.push(modal);\n }\n\n static open(modal: Modal) {\n ModalManager.#openHandler(modal);\n }\n}\n","import type { ReactNode } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type {\n BackgroundComponent,\n BaseModal,\n ForegroundComponent,\n ManagedEntity,\n ModalBackground,\n} from '@/promise-modal/types';\n\ntype AbstractNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;\n\nexport abstract class AbstractNode<T, B> {\n readonly id: number;\n readonly initiator: string;\n\n readonly title?: ReactNode;\n readonly subtitle?: ReactNode;\n readonly background?: ModalBackground<B>;\n\n readonly manualDestroy: boolean;\n readonly closeOnBackdropClick: boolean;\n readonly dimmed: boolean;\n\n readonly ForegroundComponent?: ForegroundComponent;\n readonly BackgroundComponent?: BackgroundComponent;\n\n #alive: boolean;\n get alive() {\n return this.#alive;\n }\n #visible: boolean;\n get visible() {\n return this.#visible;\n }\n\n #resolve: (result: T | null) => void;\n #listeners: Fn[] = [];\n\n constructor({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed = true,\n manualDestroy = false,\n closeOnBackdropClick = true,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AbstractNodeProps<T, B>) {\n this.id = id;\n this.initiator = initiator;\n this.title = title;\n this.subtitle = subtitle;\n this.background = background;\n\n this.dimmed = dimmed;\n this.manualDestroy = manualDestroy;\n this.closeOnBackdropClick = closeOnBackdropClick;\n\n this.ForegroundComponent = ForegroundComponent;\n this.BackgroundComponent = BackgroundComponent;\n\n this.#alive = true;\n this.#visible = true;\n this.#resolve = resolve;\n }\n\n subscribe(listener: Fn) {\n this.#listeners.push(listener);\n return () => {\n this.#listeners = this.#listeners.filter((l) => l !== listener);\n };\n }\n publish() {\n for (const listener of this.#listeners) listener();\n }\n protected resolve(result: T | null) {\n this.#resolve(result);\n }\n onDestroy() {\n const needPublish = this.#alive === true;\n this.#alive = false;\n if (this.manualDestroy && needPublish) this.publish();\n }\n onShow() {\n const needPublish = this.#visible === false;\n this.#visible = true;\n if (needPublish) this.publish();\n }\n onHide() {\n const needPublish = this.#visible === true;\n this.#visible = false;\n if (needPublish) this.publish();\n }\n abstract onClose(): void;\n abstract onConfirm(): void;\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n AlertContentProps,\n AlertFooterRender,\n AlertModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype AlertNodeProps<B> = AlertModal<B> & ManagedEntity;\n\nexport class AlertNode<B> extends AbstractNode<null, B> {\n readonly type: 'alert';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<AlertContentProps>;\n readonly footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AlertNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(null);\n }\n onConfirm() {\n this.resolve(null);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n ConfirmContentProps,\n ConfirmFooterRender,\n ConfirmModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype ConfirmNodeProps<B> = ConfirmModal<B> & ManagedEntity;\n\nexport class ConfirmNode<B> extends AbstractNode<boolean, B> {\n readonly type: 'confirm';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<ConfirmContentProps>;\n readonly footer?: ConfirmFooterRender | FooterOptions | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: ConfirmNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(false);\n }\n onConfirm() {\n this.resolve(true);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n FooterOptions,\n ManagedEntity,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n PromptModal,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype PromptNodeProps<T, B> = PromptModal<T, B> & ManagedEntity;\n\nexport class PromptNode<T, B> extends AbstractNode<T, B> {\n readonly type: 'prompt';\n readonly content?: ReactNode | ComponentType<PromptContentProps>;\n readonly defaultValue: T | undefined;\n readonly Input: (props: PromptInputProps<T>) => ReactNode;\n readonly disabled?: (value: T) => boolean;\n readonly returnOnCancel?: boolean;\n readonly footer?: PromptFooterRender<T> | FooterOptions | false;\n #value: T | undefined;\n\n constructor({\n id,\n initiator,\n type,\n title,\n subtitle,\n content,\n defaultValue,\n Input,\n disabled,\n returnOnCancel,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: PromptNodeProps<T, B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.content = content;\n this.Input = Input;\n this.defaultValue = defaultValue;\n this.#value = defaultValue;\n this.disabled = disabled;\n this.returnOnCancel = returnOnCancel;\n this.footer = footer;\n }\n\n onChange(value: T) {\n this.#value = value;\n }\n onConfirm() {\n this.resolve(this.#value ?? null);\n }\n onClose() {\n if (this.returnOnCancel) this.resolve(this.#value ?? null);\n else this.resolve(null);\n }\n}\n","import type { ManagedModal } from '@/promise-modal/types';\n\nimport { AlertNode, ConfirmNode, PromptNode } from './ModalNode';\n\nexport const nodeFactory = <T, B>(modal: ManagedModal<T, B>) => {\n switch (modal.type) {\n case 'alert':\n return new AlertNode<B>(modal);\n case 'confirm':\n return new ConfirmNode<B>(modal);\n case 'prompt':\n return new PromptNode<T, B>(modal);\n }\n // @ts-expect-error: This state is unreachable by design and should NEVER occur.\n throw new Error(`Unknown modal: ${modal.type}`, { modal });\n};\n","import { createContext } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport type { ModalActions, ModalHandlersWithId } from '@/promise-modal/types';\n\nexport interface ModalManagerContextProps extends ModalHandlersWithId {\n modalIds: ModalNode['id'][];\n getModal: Fn<[id: ModalNode['id']], ModalActions>;\n getModalNode: Fn<[id: ModalNode['id']], ModalNode | undefined>;\n setUpdater: Fn<[updater: Fn]>;\n}\n\nexport const ModalManagerContext = createContext<ModalManagerContextProps>(\n {} as ModalManagerContextProps,\n);\n","import {\n type PropsWithChildren,\n memo,\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { convertMsFromDuration } from '@winglet/common-utils';\nimport { useOnMountLayout, useReference } from '@winglet/react-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport { type ModalNode, nodeFactory } from '@/promise-modal/core';\nimport { useConfigurationOptions } from '@/promise-modal/providers';\nimport type { Modal } from '@/promise-modal/types';\n\nimport { ModalManagerContext } from './ModalManagerContext';\n\ninterface ModalManagerContextProviderProps {\n usePathname: Fn<[], { pathname: string }>;\n}\n\nexport const ModalManagerContextProvider = memo(\n ({\n usePathname,\n children,\n }: PropsWithChildren<ModalManagerContextProviderProps>) => {\n const modalDictionary = useRef<Map<ModalNode['id'], ModalNode>>(new Map());\n\n const [modalIds, setModalIds] = useState<ModalNode['id'][]>([]);\n const modalIdsRef = useReference(modalIds);\n const { pathname } = usePathname();\n\n const initiator = useRef(pathname);\n const modalIdSequence = useRef(0);\n\n const options = useConfigurationOptions();\n\n const duration = useMemo(\n () => convertMsFromDuration(options.duration),\n [options],\n );\n\n useOnMountLayout(() => {\n const { manualDestroy, closeOnBackdropClick } = options;\n\n for (const data of ModalManager.prerender) {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => [...ids, modal.id]);\n }\n\n ModalManager.openHandler = (data: Modal) => {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => {\n const aliveIds = ids.filter((id) => {\n const destroyed = !modalDictionary.current.get(id)?.alive;\n if (destroyed) modalDictionary.current.delete(id);\n return !destroyed;\n });\n return [...aliveIds, modal.id];\n });\n };\n return () => {\n ModalManager.reset();\n };\n });\n\n useLayoutEffect(() => {\n for (const id of modalIdsRef.current) {\n const modal = modalDictionary.current.get(id);\n if (!modal?.alive) continue;\n if (modal.initiator === pathname) modal.onShow();\n else modal.onHide();\n }\n initiator.current = pathname;\n }, [modalIdsRef, pathname]);\n\n const getModalNode = useCallback((modalId: ModalNode['id']) => {\n return modalDictionary.current.get(modalId);\n }, []);\n\n const onDestroy = useCallback((modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onDestroy();\n updaterRef.current?.();\n }, []);\n\n const updaterRef = useRef<Fn>();\n const hideModal = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onHide();\n updaterRef.current?.();\n if (!modal.manualDestroy)\n setTimeout(() => {\n modal.onDestroy();\n }, duration);\n },\n [duration],\n );\n\n const onChange = useCallback((modalId: ModalNode['id'], value: any) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n if (modal.type === 'prompt') modal.onChange(value);\n }, []);\n\n const onConfirm = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onConfirm();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const onClose = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onClose();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const getModal = useCallback(\n (modalId: ModalNode['id']) => ({\n modal: getModalNode(modalId),\n onConfirm: () => onConfirm(modalId),\n onClose: () => onClose(modalId),\n onChange: (value: any) => onChange(modalId, value),\n onDestroy: () => onDestroy(modalId),\n }),\n [getModalNode, onConfirm, onClose, onChange, onDestroy],\n );\n\n const value = useMemo(() => {\n return {\n modalIds,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n getModal,\n setUpdater: (updater: Fn) => {\n updaterRef.current = updater;\n },\n };\n }, [\n modalIds,\n getModal,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n ]);\n\n return (\n <ModalManagerContext.Provider value={value}>\n {children}\n </ModalManagerContext.Provider>\n );\n },\n);\n","import { useContext, useMemo } from 'react';\n\nimport type { ManagedModal } from '@/promise-modal/types';\n\nimport { ModalManagerContext } from './ModalManagerContext';\n\nexport const useModalManagerContext = () => useContext(ModalManagerContext);\n\nexport const useModal = (id: ManagedModal['id']) => {\n const { getModal } = useModalManagerContext();\n return useMemo(() => getModal(id), [id, getModal]);\n};\n","import { css } from '@emotion/css';\n\nexport const fallback = css`\n margin: unset;\n`;\n\nexport const frame = css`\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n background-color: white;\n padding: 20px 80px;\n gap: 10px;\n border: 1px solid black;\n`;\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackTitle = ({ children }: PropsWithChildren) => {\n return <h2 className={fallback}>{children}</h2>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackSubtitle = ({ children }: PropsWithChildren) => {\n return <h3 className={fallback}>{children}</h3>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackContent = ({ children }: PropsWithChildren) => {\n return <div className={fallback}>{children}</div>;\n};\n","import type { FooterComponentProps } from '@/promise-modal/types';\n\nexport const FallbackFooter = ({\n confirmLabel,\n hideConfirm = false,\n cancelLabel,\n hideCancel = false,\n disabled,\n onConfirm,\n onCancel,\n}: FooterComponentProps) => {\n return (\n <div>\n {!hideConfirm && (\n <button onClick={onConfirm} disabled={disabled}>\n {confirmLabel || '확인'}\n </button>\n )}\n\n {!hideCancel && typeof onCancel === 'function' && (\n <button onClick={onCancel}>{cancelLabel || '취소'}</button>\n )}\n </div>\n );\n};\n","import { useMemo } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport { useModalManagerContext } from '@/promise-modal/providers';\n\nconst defaultValidate = (modal?: ModalNode) => modal?.visible;\n\nexport const useActiveModalCount = (\n validate: Fn<[ModalNode?], boolean | undefined> = defaultValidate,\n refreshKey: string | number = 0,\n) => {\n const { modalIds, getModalNode } = useModalManagerContext();\n return useMemo(() => {\n let count = 0;\n for (const id of modalIds) {\n if (validate(getModalNode(id))) count++;\n }\n return count;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getModalNode, modalIds, refreshKey]);\n};\n","import {\n type ForwardedRef,\n type PropsWithChildren,\n forwardRef,\n useMemo,\n} from 'react';\n\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport type { ModalFrameProps } from '@/promise-modal/types';\n\nimport { frame } from './classNames.emotion';\n\nconst MAX_MODAL_COUNT = 5;\nconst MAX_MODAL_LEVEL = 3;\n\nexport const FallbackForegroundFrame = forwardRef(\n (\n { id, onChangeOrder, children }: PropsWithChildren<ModalFrameProps>,\n ref: ForwardedRef<HTMLDivElement>,\n ) => {\n const activeCount = useActiveModalCount();\n const [level, offset] = useMemo(() => {\n const stacked = activeCount > 1;\n const level = stacked\n ? (Math.floor(id / MAX_MODAL_COUNT) % MAX_MODAL_LEVEL) * 100\n : 0;\n const offset = stacked ? (id % MAX_MODAL_COUNT) * 35 : 0;\n return [level, offset];\n }, [activeCount, id]);\n\n return (\n <div\n ref={ref}\n className={frame}\n onClick={onChangeOrder}\n style={{\n marginBottom: `calc(25vh + ${level}px)`,\n marginLeft: `${level}px`,\n transform: `translate(${offset}px, ${offset}px)`,\n }}\n >\n {children}\n </div>\n );\n },\n);\n","import { type ComponentType, createContext } from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport type {\n BackgroundComponent,\n FooterComponentProps,\n ForegroundComponent,\n WrapperComponentProps,\n} from '@/promise-modal/types';\n\nexport interface ConfigurationContextProps {\n ForegroundComponent: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n TitleComponent: ComponentType<WrapperComponentProps>;\n SubtitleComponent: ComponentType<WrapperComponentProps>;\n ContentComponent: ComponentType<WrapperComponentProps>;\n FooterComponent: ComponentType<FooterComponentProps>;\n options: {\n duration: Duration;\n backdrop: Color;\n manualDestroy: boolean;\n closeOnBackdropClick: boolean;\n };\n}\n\nexport const ConfigurationContext = createContext<ConfigurationContextProps>(\n {} as ConfigurationContextProps,\n);\n","import {\n type ComponentType,\n type PropsWithChildren,\n memo,\n useMemo,\n} from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport type {\n FooterComponentProps,\n ModalFrameProps,\n WrapperComponentProps,\n} from '@/promise-modal/types';\n\nimport { ConfigurationContext } from './ConfigurationContext';\n\nexport interface ConfigurationContextProviderProps {\n BackgroundComponent?: ComponentType<ModalFrameProps>;\n ForegroundComponent?: ComponentType<ModalFrameProps>;\n TitleComponent?: ComponentType<WrapperComponentProps>;\n SubtitleComponent?: ComponentType<WrapperComponentProps>;\n ContentComponent?: ComponentType<WrapperComponentProps>;\n FooterComponent?: ComponentType<FooterComponentProps>;\n options?: {\n /** Modal transition time(ms, s) */\n duration?: Duration;\n /** Modal backdrop color */\n backdrop?: Color;\n /** Whether to destroy the modal manually */\n manualDestroy?: boolean;\n /** Whether to close the modal when the backdrop is clicked */\n closeOnBackdropClick?: boolean;\n };\n}\n\nexport const ConfigurationContextProvider = memo(\n ({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n options,\n children,\n }: PropsWithChildren<ConfigurationContextProviderProps>) => {\n const value = useMemo(\n () => ({\n BackgroundComponent,\n ForegroundComponent: ForegroundComponent || FallbackForegroundFrame,\n TitleComponent: TitleComponent || FallbackTitle,\n SubtitleComponent: SubtitleComponent || FallbackSubtitle,\n ContentComponent: memo(ContentComponent || FallbackContent),\n FooterComponent: memo(FooterComponent || FallbackFooter),\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n closeOnBackdropClick: true,\n manualDestroy: false,\n ...options,\n } satisfies ConfigurationContextProviderProps['options'],\n }),\n [\n ForegroundComponent,\n BackgroundComponent,\n ContentComponent,\n FooterComponent,\n SubtitleComponent,\n TitleComponent,\n options,\n ],\n );\n return (\n <ConfigurationContext.Provider value={value}>\n {children}\n </ConfigurationContext.Provider>\n );\n },\n);\n","import type { Color, Duration } from '@aileron/types';\n\nexport const DEFAULT_ANIMATION_DURATION: Duration = '300ms';\n\nexport const DEFAULT_BACKDROP_COLOR: Color = 'rgba(0, 0, 0, 0.5)';\n","import { useContext } from 'react';\n\nimport { convertMsFromDuration } from '@winglet/common-utils';\n\nimport { ConfigurationContext } from './ConfigurationContext';\n\nexport const useConfigurationContext = () => useContext(ConfigurationContext);\n\nexport const useConfigurationOptions = () => {\n const context = useContext(ConfigurationContext);\n return context.options;\n};\n\nexport const useConfigurationDuration = () => {\n const context = useConfigurationOptions();\n return {\n duration: context.duration,\n milliseconds: convertMsFromDuration(context.duration),\n };\n};\n\nexport const useConfigurationBackdrop = () => {\n const context = useConfigurationOptions();\n return context.backdrop;\n};\n","import { createContext } from 'react';\n\nimport type { Dictionary } from '@aileron/types';\n\nexport interface UserDefinedContext {\n context: Dictionary;\n}\n\nexport const UserDefinedContext = createContext<UserDefinedContext>(\n {} as UserDefinedContext,\n);\n","import { PropsWithChildren, useMemo } from 'react';\n\nimport type { Dictionary } from '@aileron/types';\n\nimport { UserDefinedContext } from './UserDefinedContext';\n\ninterface UserDefinedContextProviderProps {\n /** 사용자 정의 컨텍스트 */\n context?: Dictionary;\n}\n\nexport const UserDefinedContextProvider = ({\n context,\n children,\n}: PropsWithChildren<UserDefinedContextProviderProps>) => {\n const contextValue = useMemo(() => ({ context: context || {} }), [context]);\n return (\n <UserDefinedContext.Provider value={contextValue}>\n {children}\n </UserDefinedContext.Provider>\n );\n};\n","import { useContext } from 'react';\n\nimport { UserDefinedContext } from './UserDefinedContext';\n\nexport const useUserDefinedContext = () => {\n return useContext(UserDefinedContext);\n};\n","import { css } from '@emotion/css';\n\nexport const background = css`\n display: none;\n position: fixed;\n inset: 0;\n z-index: -999;\n pointer-events: none;\n > * {\n pointer-events: none;\n }\n`;\n\nexport const active = css`\n pointer-events: all;\n`;\n\nexport const visible = css`\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n","import { type MouseEvent, useCallback, useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport {\n useConfigurationContext,\n useModal,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, background, visible } from './classNames.emotion';\n\nexport const BackgroundFrame = ({\n modalId,\n onChangeOrder,\n}: ModalLayerProps) => {\n const { BackgroundComponent } = useConfigurationContext();\n const { context: userDefinedContext } = useUserDefinedContext();\n const { modal, onClose, onChange, onConfirm, onDestroy } = useModal(modalId);\n\n const handleClose = useCallback(\n (event: MouseEvent) => {\n if (modal && modal.closeOnBackdropClick && modal.visible) onClose();\n event.stopPropagation();\n },\n [modal, onClose],\n );\n\n const Background = useMemo(\n () => modal?.BackgroundComponent || BackgroundComponent,\n [BackgroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(background, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.closeOnBackdropClick && modal.visible,\n })}\n onClick={handleClose}\n >\n {Background && (\n <Background\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n context={userDefinedContext}\n />\n )}\n </div>\n );\n};\n","import { css } from '@emotion/css';\n\nexport const foreground = css`\n pointer-events: none;\n display: none;\n position: fixed;\n inset: 0;\n z-index: 1;\n`;\n\nexport const active = css`\n > * {\n pointer-events: all;\n }\n`;\n\nexport const visible = css`\n display: flex !important;\n justify-content: center;\n align-items: center;\n`;\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { AlertNode } from '@/promise-modal/core';\nimport {\n useConfigurationContext,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface AlertInnerProps<B> {\n modal: AlertNode<B>;\n handlers: Pick<ModalActions, 'onConfirm'>;\n}\n\nexport const AlertInner = memo(\n <B,>({ modal, handlers }: AlertInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { context: userDefinedContext } = useUserDefinedContext();\n const { onConfirm } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useConfigurationContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n confirmLabel={footer?.confirm}\n hideConfirm={footer?.hideConfirm}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { ConfirmNode } from '@/promise-modal/core';\nimport {\n useConfigurationContext,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface ConfirmInnerProps<B> {\n modal: ConfirmNode<B>;\n handlers: Pick<ModalActions, 'onConfirm' | 'onClose'>;\n}\n\nexport const ConfirmInner = memo(\n <B,>({ modal, handlers }: ConfirmInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { context: userDefinedContext } = useUserDefinedContext();\n const { onConfirm, onClose } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n const handleClose = useHandle(onClose);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useConfigurationContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useCallback, useMemo, useState } from 'react';\n\nimport { isFunction, isString } from '@winglet/common-utils';\nimport {\n renderComponent,\n useHandle,\n withErrorBoundary,\n} from '@winglet/react-utils';\n\nimport type { PromptNode } from '@/promise-modal/core';\nimport {\n useConfigurationContext,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface PromptInnerProps<T, B> {\n modal: PromptNode<T, B>;\n handlers: Pick<ModalActions, 'onChange' | 'onClose' | 'onConfirm'>;\n}\n\nexport const PromptInner = memo(\n <T, B>({ modal, handlers }: PromptInnerProps<T, B>) => {\n const {\n Input,\n defaultValue,\n disabled: checkDisabled,\n title,\n subtitle,\n content,\n footer,\n } = useMemo(\n () => ({\n ...modal,\n Input: memo(withErrorBoundary(modal.Input)),\n }),\n [modal],\n );\n\n const { context: userDefinedContext } = useUserDefinedContext();\n\n const [value, setValue] = useState<T | undefined>(defaultValue);\n\n const { onChange, onClose, onConfirm } = useMemo(\n () => handlers,\n [handlers],\n );\n\n const handleClose = useHandle(onClose);\n const handleChange = useHandle(\n (inputValue?: T | ((prevState: T | undefined) => T | undefined)) => {\n const input = isFunction(inputValue) ? inputValue(value) : inputValue;\n setValue(input);\n onChange(input);\n },\n );\n\n const handleConfirm = useCallback(() => {\n // NOTE: wait for the next tick to ensure the value is updated\n setTimeout(() => {\n onConfirm();\n });\n }, [onConfirm]);\n\n const disabled = useMemo(\n () => (value ? !!checkDisabled?.(value) : false),\n [checkDisabled, value],\n );\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useConfigurationContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ))}\n\n {Input && (\n <Input\n defaultValue={defaultValue}\n value={value}\n onChange={handleChange}\n onConfirm={handleConfirm}\n onCancel={handleClose}\n context={userDefinedContext}\n />\n )}\n\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n value,\n disabled,\n onChange: handleChange,\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n disabled={disabled}\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport {\n useConfigurationContext,\n useModal,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, foreground, visible } from './classNames.emotion';\nimport { AlertInner, ConfirmInner, PromptInner } from './components';\n\nexport const ForegroundFrame = ({\n modalId,\n onChangeOrder,\n}: ModalLayerProps) => {\n const { ForegroundComponent } = useConfigurationContext();\n const { context: userDefinedContext } = useUserDefinedContext();\n\n const { modal, onChange, onConfirm, onClose, onDestroy } = useModal(modalId);\n\n const Foreground = useMemo(\n () => modal?.ForegroundComponent || ForegroundComponent,\n [ForegroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(foreground, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.visible,\n })}\n >\n <Foreground\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n context={userDefinedContext}\n >\n {modal.type === 'alert' && (\n <AlertInner modal={modal} handlers={{ onConfirm }} />\n )}\n {modal.type === 'confirm' && (\n <ConfirmInner modal={modal} handlers={{ onConfirm, onClose }} />\n )}\n {modal.type === 'prompt' && (\n <PromptInner\n modal={modal}\n handlers={{ onChange, onConfirm, onClose }}\n />\n )}\n </Foreground>\n </div>\n );\n};\n","import { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { ModalNode } from '@/promise-modal/core';\n\nexport const useSubscribeModal = (modal?: ModalNode) => {\n const [tick, update] = useTick();\n useOnMount(() => {\n if (!modal) return;\n const unsubscribe = modal.subscribe(update);\n return unsubscribe;\n });\n return tick;\n};\n","import { css } from '@emotion/css';\n\nexport const presenter = css`\n position: fixed;\n inset: 0;\n pointer-events: none;\n overflow: hidden;\n`;\n","import { memo, useRef } from 'react';\n\nimport { counterFactory } from '@winglet/common-utils';\nimport { useHandle } from '@winglet/react-utils';\n\nimport { Background } from '@/promise-modal/components/Background';\nimport { Foreground } from '@/promise-modal/components/Foreground';\nimport { useSubscribeModal } from '@/promise-modal/hooks/useSubscribeModal';\nimport { useModal } from '@/promise-modal/providers';\nimport type { ModalIdProps } from '@/promise-modal/types';\n\nimport { presenter } from './classNames.emotion';\n\nconst { increment } = counterFactory(1);\n\nexport const Presenter = memo(({ modalId }: ModalIdProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { modal } = useModal(modalId);\n useSubscribeModal(modal);\n const handleChangeOrder = useHandle(() => {\n if (ref.current) {\n ref.current.style.zIndex = `${increment()}`;\n }\n });\n return (\n <div ref={ref} className={presenter}>\n <Background modalId={modalId} onChangeOrder={handleChangeOrder} />\n <Foreground modalId={modalId} onChangeOrder={handleChangeOrder} />\n </div>\n );\n});\n","import { css } from '@emotion/css';\n\nexport const anchor = css`\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: 1000;\n transition: background-color ease-in-out;\n`;\n","import { memo, useEffect } from 'react';\n\nimport { useTick, withErrorBoundary } from '@winglet/react-utils';\n\nimport { Presenter } from '@/promise-modal/components/Presenter';\nimport type { ModalNode } from '@/promise-modal/core';\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport {\n useConfigurationOptions,\n useModalManagerContext,\n} from '@/promise-modal/providers';\n\nimport { anchor } from './classNames.emotion';\n\nconst AnchorInner = () => {\n const [refreshKey, update] = useTick();\n\n const { modalIds, setUpdater } = useModalManagerContext();\n\n useEffect(() => {\n setUpdater(update);\n }, [setUpdater, update]);\n\n const options = useConfigurationOptions();\n\n const dimmed = useActiveModalCount(validateDimmable, refreshKey);\n\n return (\n <div\n className={anchor}\n style={{\n transitionDuration: options.duration,\n backgroundColor: dimmed ? options.backdrop : 'transparent',\n }}\n >\n {modalIds.map((id) => {\n return <Presenter key={id} modalId={id} />;\n })}\n </div>\n );\n};\n\nconst validateDimmable = (modal?: ModalNode) => modal?.visible && modal.dimmed;\n\nexport const Anchor = memo(withErrorBoundary(AnchorInner));\n","import { createPortal } from 'react-dom';\n\nimport type { Dictionary, Fn } from '@aileron/types';\n\nimport { Anchor } from '@/promise-modal/components/Anchor';\nimport {\n ConfigurationContextProvider,\n type ConfigurationContextProviderProps,\n} from '@/promise-modal/providers/ConfigurationContext';\nimport { ModalManagerContextProvider } from '@/promise-modal/providers/ModalManagerContext';\nimport { UserDefinedContextProvider } from '@/promise-modal/providers/UserDefinedContext';\n\ninterface BootstrapProps extends ConfigurationContextProviderProps {\n usePathname: Fn<[], { pathname: string }>;\n context?: Dictionary;\n anchor: HTMLElement;\n}\n\nexport const bootstrap = ({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n usePathname,\n options,\n context,\n anchor,\n}: BootstrapProps) =>\n createPortal(\n <UserDefinedContextProvider context={context}>\n <ConfigurationContextProvider\n ForegroundComponent={ForegroundComponent}\n BackgroundComponent={BackgroundComponent}\n TitleComponent={TitleComponent}\n SubtitleComponent={SubtitleComponent}\n ContentComponent={ContentComponent}\n FooterComponent={FooterComponent}\n options={options}\n >\n <ModalManagerContextProvider usePathname={usePathname}>\n <Anchor />\n </ModalManagerContextProvider>\n </ConfigurationContextProvider>\n </UserDefinedContextProvider>,\n anchor,\n );\n","import { useLayoutEffect, useState } from 'react';\n\nexport const usePathname = () => {\n const [pathname, setPathname] = useState(window.location.pathname);\n useLayoutEffect(() => {\n let requestId: number;\n const checkPathname = () => {\n if (requestId) cancelAnimationFrame(requestId);\n if (pathname !== window.location.pathname) {\n setPathname(window.location.pathname);\n } else {\n requestId = requestAnimationFrame(checkPathname);\n }\n };\n requestId = requestAnimationFrame(checkPathname);\n return () => {\n if (requestId) cancelAnimationFrame(requestId);\n };\n }, [pathname]);\n return { pathname };\n};\n","import {\n Fragment,\n type PropsWithChildren,\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react';\n\nimport { printError } from '@winglet/common-utils';\nimport { useOnMount, useTick } from '@winglet/react-utils';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport { usePathname as useDefaultPathname } from '@/promise-modal/hooks/useDefaultPathname';\n\nimport { bootstrap } from '../bootstrap';\nimport type { BootstrapProviderHandle, BootstrapProviderProps } from './type';\n\nexport const BootstrapProvider = forwardRef<\n BootstrapProviderHandle,\n PropsWithChildren<BootstrapProviderProps>\n>(\n (\n {\n usePathname: useExternalPathname,\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n options,\n context,\n children,\n },\n handleRef,\n ) => {\n const usePathname = useMemo(\n () => useExternalPathname || useDefaultPathname,\n [useExternalPathname],\n );\n const permitted = useRef(ModalManager.activate());\n const anchorRef = useRef<HTMLElement | null>(null);\n const [, update] = useTick();\n\n const handleInitialize = useCallback(\n (root?: HTMLElement) => {\n if (permitted.current) {\n anchorRef.current = ModalManager.anchor({ root });\n update();\n } else\n printError(\n 'ModalProvider is already initialized',\n [\n 'ModalProvider can only be initialized once.',\n 'Nesting ModalProvider will be ignored...',\n ],\n {\n info: 'Something is wrong with the ModalProvider initialization...',\n },\n );\n },\n [update],\n );\n\n useImperativeHandle(\n handleRef,\n () => ({\n initialize: handleInitialize,\n }),\n [handleInitialize],\n );\n\n useOnMount(() => {\n /**\n * NOTE: `handleRef` being null indicates that no `ref` was provided.\n * In this case, the `ModalProvider`(=`BootstrapProvider`) is not receiving the `ref`,\n * so it should be initialized automatically.\n */\n if (handleRef === null) handleInitialize();\n return () => {\n if (anchorRef.current) anchorRef.current.remove();\n };\n });\n\n return (\n <Fragment>\n {children}\n {anchorRef.current &&\n bootstrap({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n usePathname,\n options,\n context,\n anchor: anchorRef.current,\n })}\n </Fragment>\n );\n },\n);\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n AlertContentProps,\n AlertFooterRender,\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface AlertProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<AlertContentProps>;\n background?: ModalBackground<B>;\n footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const alert = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: AlertProps<B>) => {\n return new Promise<void>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'alert',\n subtype,\n resolve: () => resolve(),\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n BackgroundComponent,\n ConfirmContentProps,\n ConfirmFooterRender,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface ConfirmProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<ConfirmContentProps>;\n background?: ModalBackground<B>;\n footer?: ConfirmFooterRender | FooterOptions | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const confirm = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: ConfirmProps<B>) => {\n return new Promise<boolean>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'confirm',\n subtype,\n resolve: (result) => resolve(result ?? false),\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n} from '@/promise-modal/types';\n\ninterface PromptProps<T, B = any> {\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<PromptContentProps>;\n Input: (props: PromptInputProps<T>) => ReactNode;\n defaultValue?: T;\n disabled?: (value: T) => boolean;\n returnOnCancel?: boolean;\n background?: ModalBackground<B>;\n footer?: PromptFooterRender<T> | FooterOptions | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const prompt = <T, B = any>({\n defaultValue,\n title,\n subtitle,\n content,\n Input,\n disabled,\n returnOnCancel,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: PromptProps<T, B>) => {\n return new Promise<T>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'prompt',\n resolve: (result) => resolve(result as T),\n title,\n subtitle,\n content,\n Input,\n defaultValue,\n disabled,\n returnOnCancel,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import { useEffect, useRef } from 'react';\n\nimport { convertMsFromDuration, isString } from '@winglet/common-utils';\n\nimport type { Duration } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport { useModal } from '@/promise-modal/providers';\n\nimport { useSubscribeModal } from './useSubscribeModal';\n\nexport const useDestroyAfter = (\n modalId: ModalNode['id'],\n duration: Duration | number,\n) => {\n const { modal, onDestroy } = useModal(modalId);\n const tick = useSubscribeModal(modal);\n\n const reference = useRef({\n modal,\n onDestroy,\n milliseconds: isString(duration)\n ? convertMsFromDuration(duration)\n : duration,\n });\n\n useEffect(() => {\n const { modal, onDestroy, milliseconds } = reference.current;\n if (!modal || modal.visible || !modal.alive) return;\n const timer = setTimeout(() => {\n onDestroy();\n }, milliseconds);\n return () => {\n if (timer) clearTimeout(timer);\n };\n }, [tick]);\n};\n","import { useLayoutEffect, useRef } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\ninterface ModalAnimationHandler {\n onVisible?: Fn;\n onHidden?: Fn;\n}\n\nexport const useModalAnimation = (\n visible: boolean,\n handler: ModalAnimationHandler,\n) => {\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n useLayoutEffect(() => {\n if (!handlerRef.current) return;\n let frame: ReturnType<typeof requestAnimationFrame>;\n if (visible)\n frame = requestAnimationFrame(() => handlerRef.current.onVisible?.());\n else frame = requestAnimationFrame(() => handlerRef.current.onHidden?.());\n return () => {\n if (frame) cancelAnimationFrame(frame);\n };\n }, [visible]);\n};\n"],"names":["ModalManager","activate","__classPrivateFieldGet","_a","_ModalManager_active","__classPrivateFieldSet","anchor","options","_ModalManager_anchor","document","getElementById","id","tag","prefix","root","body","node","createElement","setAttribute","getRandomString","appendChild","prerender","_ModalManager_prerenderList","openHandler","handler","_ModalManager_openHandler","unanchored","reset","modal","push","open","call","value","AbstractNode","alive","this","_AbstractNode_alive","visible","_AbstractNode_visible","constructor","initiator","title","subtitle","background","dimmed","manualDestroy","closeOnBackdropClick","resolve","ForegroundComponent","BackgroundComponent","Object","defineProperty","set","_AbstractNode_resolve","_AbstractNode_listeners","subscribe","listener","filter","l","publish","result","onDestroy","needPublish","onShow","onHide","AlertNode","type","subtype","content","footer","super","onClose","onConfirm","ConfirmNode","PromptNode","defaultValue","Input","disabled","returnOnCancel","_PromptNode_value","onChange","nodeFactory","Error","ModalManagerContext","createContext","ModalManagerContextProvider","memo","usePathname","children","modalDictionary","useRef","Map","modalIds","setModalIds","useState","modalIdsRef","useReference","pathname","modalIdSequence","useConfigurationOptions","duration","useMemo","convertMsFromDuration","useOnMountLayout","data","current","undefined","ids","destroyed","get","delete","useLayoutEffect","getModalNode","useCallback","modalId","updaterRef","hideModal","setTimeout","getModal","setUpdater","updater","_jsx","jsx","Provider","useModalManagerContext","useContext","useModal","fallback","css","process","env","NODE_ENV","name","styles","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","frame","FallbackTitle","className","FallbackSubtitle","FallbackContent","FallbackFooter","confirmLabel","hideConfirm","cancelLabel","hideCancel","onCancel","_jsxs","onClick","defaultValidate","useActiveModalCount","validate","refreshKey","count","FallbackForegroundFrame","forwardRef","onChangeOrder","ref","activeCount","level","offset","stacked","Math","floor","style","marginBottom","marginLeft","transform","ConfigurationContext","ConfigurationContextProvider","TitleComponent","SubtitleComponent","ContentComponent","FooterComponent","backdrop","useConfigurationContext","UserDefinedContext","UserDefinedContextProvider","context","contextValue","useUserDefinedContext","active","BackgroundFrame","userDefinedContext","handleClose","event","stopPropagation","Background","cx","visible$1","active$1","foreground","AlertInner","handlers","handleConfirm","useHandle","Fragment","isString","renderComponent","confirm","ConfirmInner","cancel","PromptInner","checkDisabled","withErrorBoundary","setValue","handleChange","inputValue","input","isFunction","ForegroundFrame","Foreground","useSubscribeModal","tick","update","useTick","useOnMount","presenter","increment","counterFactory","Presenter","handleChangeOrder","zIndex","validateDimmable","Anchor","useEffect","transitionDuration","backgroundColor","map","bootstrap","createPortal","setPathname","window","location","requestId","checkPathname","cancelAnimationFrame","requestAnimationFrame","BootstrapProvider","useExternalPathname","handleRef","useDefaultPathname","permitted","anchorRef","handleInitialize","printError","info","useImperativeHandle","initialize","remove","Promise","reject","error","reference","milliseconds","timer","clearTimeout","handlerRef","onVisible","onHidden"],"mappings":";;;;;;;;;;;;;;;;4sBAMaA,EAEX,eAAOC,GACL,OAAIC,EAAAC,EAAoBA,EAAA,IAAAC,IAChBC,EAAAF,KAAuB,EAAI,IAAAC,GAIrC,aAAOE,CAAOC,GAKZ,GAAIL,EAAAC,EAAoBA,EAAA,IAAAK,GAAE,CACxB,MAAMF,EAASG,SAASC,eAAeR,EAAAC,EAAoBA,EAAA,IAAAK,GAACG,IAC5D,GAAIL,EAAQ,OAAOA,EAErB,MAAMM,IACJA,EAAM,MAAKC,OACXA,EAAS,gBAAeC,KACxBA,EAAOL,SAASM,MACdR,GAAW,CAAE,EACXS,EAAOP,SAASQ,cAAcL,GAIpC,OAHAI,EAAKE,aAAa,KAAM,GAAGL,KAAUM,EAAeA,gBAAC,OACrDL,EAAKM,YAAYJ,GACjBX,EAAAF,EAAYA,EAAWa,EAAI,IAAAR,GACpBQ,EAIT,oBAAWK,GACT,OAAOnB,EAAAC,EAAYA,EAAA,IAAAmB,GAKrB,sBAAWC,CAAYC,GACrBnB,EAAAF,EAAYA,EAAgBqB,EAAO,IAAAC,GACnCpB,EAAAF,EAAYA,EAAkB,GAAE,IAAAmB,GAGlC,qBAAWI,GACT,OAAQxB,EAAAC,EAAYA,EAAA,IAAAK,GAGtB,YAAOmB,GACLtB,EAAAF,EAAYA,GAAW,EAAK,IAAAC,GAC5BC,EAAAF,EAAYA,EAAW,KAAI,IAAAK,GAC3BH,EAAAF,EAAYA,EAAkB,GAAE,IAAAmB,GAChCjB,EAAAF,EAA4BA,GAACyB,GAC3B1B,EAAAC,EAAYA,EAAA,IAAAmB,GAAgBO,KAAKD,WAGrC,WAAOE,CAAKF,GACV1B,EAAAC,EAAyBA,EAAA,IAAAsB,GAAAM,KAAzB5B,EAA0ByB,QArDrBxB,EAA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MI,EAAU/E,IAChB,MAAO,CACLC,SAAU8E,EAAQ9E,SAClB0J,aAAcxJ,EAAAA,sBAAsB4E,EAAQ9E,UAC7C"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { ModalContextProvider as ModalProvider, useModalOptions, useModalDuration, useModalBackdrop, } from './providers';
1
+ export { useConfigurationOptions as useModalOptions, useConfigurationDuration as useModalDuration, useConfigurationBackdrop as useModalBackdrop, } from './providers';
2
+ export { bootstrap, BootstrapProvider as ModalProvider, type BootstrapProviderHandle as ModalProviderHandle, type BootstrapProviderProps as ModalProviderProps, } from './bootstrap';
2
3
  export { useSubscribeModal } from './hooks/useSubscribeModal';
3
4
  export { useDestroyAfter } from './hooks/useDestroyAfter';
4
5
  export { useActiveModalCount } from './hooks/useActiveModalCount';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,IAAI,aAAa,EACrC,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,IAAI,eAAe,EAC1C,wBAAwB,IAAI,gBAAgB,EAC5C,wBAAwB,IAAI,gBAAgB,GAC7C,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,SAAS,EACT,iBAAiB,IAAI,aAAa,EAClC,KAAK,uBAAuB,IAAI,mBAAmB,EACnD,KAAK,sBAAsB,IAAI,kBAAkB,GAClD,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import{createContext as t,useMemo as o,useContext as r,useCallback as i,memo as a,Fragment as l,useState as s,useRef as c,useLayoutEffect as d,useEffect as u,forwardRef as m}from"react";import{createPortal as p}from"react-dom";import{useHandle as f,renderComponent as b,withErrorBoundary as h,useTick as C,useOnMount as g,useReference as v,useOnMountLayout as y}from"@winglet/react-utils";import{getRandomString as k,EMPTY_OBJECT as O,isString as w,isFunction as x,counterFactory as D,undefinedFunction as B}from"@winglet/common-utils";import{css as j,cx as P}from"@emotion/css";const N={current:[]},F={current:e=>{N.current.push(e)}},E={current:null},I={get prerender(){return N.current},clearPrerender(){N.current=[]},open(e){F.current(e)},setupOpen(e){F.current=e},anchor(e,n="promise-modal"){if(E.current){const e=document.getElementById(E.current.id);if(e)return e}const t=document.createElement(e);return t.setAttribute("id",`${n}-${k(36)}`),document.body.appendChild(t),E.current=t,t}},S="300ms",V="rgba(0, 0, 0, 0.5)",T=t({context:O}),M=({context:n,children:t})=>{const r=o((()=>({context:n||O})),[n]);return e(T.Provider,{value:r,children:t})},_=()=>r(T);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)."}const z=j("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:$}),A=j("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:$}),L=j("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:$}),q=({modalId:n,onChangeOrder:t})=>{const{BackgroundComponent:r}=$e(),{context:a}=_(),{modal:l,onClose:s,onChange:c,onConfirm:d,onDestroy:u}=we(n),m=i((e=>{l&&l.closeOnBackdropClick&&l.visible&&s(),e.stopPropagation()}),[l,s]),p=o((()=>l?.BackgroundComponent||r),[r,l]);return l?e("div",{className:P(z,{[L]:l.manualDestroy?l.alive:l.visible,[A]:l.closeOnBackdropClick&&l.visible}),onClick:m,children:p&&e(p,{id:l.id,type:l.type,alive:l.alive,visible:l.visible,initiator:l.initiator,manualDestroy:l.manualDestroy,closeOnBackdropClick:l.closeOnBackdropClick,background:l.background,onChange:c,onConfirm:d,onClose:s,onDestroy:u,onChangeOrder:t,context:a})}):null};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=j("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:W}),H=j("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:W}),U=j("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:W}),G=a((({modal:t,handlers:r})=>{const{title:i,subtitle:a,content:s,footer:c}=o((()=>t),[t]),{context:d}=_(),{onConfirm:u}=o((()=>r),[r]),m=f(u),{TitleComponent:p,SubtitleComponent:h,ContentComponent:C,FooterComponent:g}=$e();return n(l,{children:[i&&(w(i)?e(p,{context:d,children:i}):i),a&&(w(a)?e(h,{context:d,children:a}):a),s&&(w(s)?e(C,{context:d,children:s}):b(s,{onConfirm:m})),!1!==c&&("function"==typeof c?c({onConfirm:m,context:d}):e(g,{onConfirm:m,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm,context:d}))]})})),J=a((({modal:t,handlers:r})=>{const{title:i,subtitle:a,content:s,footer:c}=o((()=>t),[t]),{context:d}=_(),{onConfirm:u,onClose:m}=o((()=>r),[r]),p=f(u),h=f(m),{TitleComponent:C,SubtitleComponent:g,ContentComponent:v,FooterComponent:y}=$e();return n(l,{children:[i&&(w(i)?e(C,{context:d,children:i}):i),a&&(w(a)?e(g,{context:d,children:a}):a),s&&(w(s)?e(v,{context:d,children:s}):b(s,{onConfirm:p,onCancel:h,context:d})),!1!==c&&("function"==typeof c?c({onConfirm:p,onCancel:h,context:d}):e(y,{onConfirm:p,onCancel:h,confirmLabel:c?.confirm,cancelLabel:c?.cancel,hideConfirm:c?.hideConfirm,hideCancel:c?.hideCancel,context:d}))]})})),K=a((({modal:t,handlers:r})=>{const{Input:c,defaultValue:d,disabled:u,title:m,subtitle:p,content:C,footer:g}=o((()=>({...t,Input:a(h(t.Input))})),[t]),{context:v}=_(),[y,k]=s(d),{onChange:O,onClose:D,onConfirm:B}=o((()=>r),[r]),j=f(D),P=f((e=>{const n=x(e)?e(y):e;k(n),O(n)})),N=i((()=>{setTimeout((()=>{B()}))}),[B]),F=o((()=>!!y&&!!u?.(y)),[u,y]),{TitleComponent:E,SubtitleComponent:I,ContentComponent:S,FooterComponent:V}=$e();return n(l,{children:[m&&(w(m)?e(E,{context:v,children:m}):m),p&&(w(p)?e(I,{context:v,children:p}):p),C&&(w(C)?e(S,{context:v,children:C}):b(C,{onConfirm:N,onCancel:j,context:v})),c&&e(c,{defaultValue:d,value:y,onChange:P,onConfirm:N,onCancel:j,context:v}),!1!==g&&("function"==typeof g?g({value:y,disabled:F,onChange:P,onConfirm:N,onCancel:j,context:v}):e(V,{disabled:F,onConfirm:N,onCancel:j,confirmLabel:g?.confirm,cancelLabel:g?.cancel,hideConfirm:g?.hideConfirm,hideCancel:g?.hideCancel,context:v}))]})})),Q=({modalId:t,onChangeOrder:r})=>{const{ForegroundComponent:i}=$e(),{context:a}=_(),{modal:l,onChange:s,onConfirm:c,onClose:d,onDestroy:u}=we(t),m=o((()=>l?.ForegroundComponent||i),[i,l]);return l?e("div",{className:P(Y,{[U]:l.manualDestroy?l.alive:l.visible,[H]:l.visible}),children:n(m,{id:l.id,type:l.type,alive:l.alive,visible:l.visible,initiator:l.initiator,manualDestroy:l.manualDestroy,closeOnBackdropClick:l.closeOnBackdropClick,background:l.background,onChange:s,onConfirm:c,onClose:d,onDestroy:u,onChangeOrder:r,context:a,children:["alert"===l.type&&e(G,{modal:l,handlers:{onConfirm:c}}),"confirm"===l.type&&e(J,{modal:l,handlers:{onConfirm:c,onClose:d}}),"prompt"===l.type&&e(K,{modal:l,handlers:{onChange:s,onConfirm:c,onClose:d}})]})}):null},R=e=>{const[n,t]=C();return g((()=>{if(e)return e.subscribe(t)})),n},X=j("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:Z}=D(1),ee=a((({modalId:t})=>{const o=c(null),{modal:r}=we(t);R(r);const i=f((()=>{o.current&&(o.current.style.zIndex=`${Z()}`)}));return n("div",{ref:o,className:X,children:[e(q,{modalId:t,onChangeOrder:i}),e(Q,{modalId:t,onChangeOrder:i})]})})),ne=e=>e?.visible,te=(e=ne,n=0)=>{const{modalIds:t,getModalNode:r}=Oe();return o((()=>{let n=0;for(const o of t)e(r(o))&&n++;return n}),[r,t,n])},oe=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})=>new Promise(((u,m)=>{try{I.open({type:"alert",subtype:e,resolve:()=>u(),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})}catch(e){m(e)}})),re=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})=>new Promise(((u,m)=>{try{I.open({type:"confirm",subtype:e,resolve:e=>u(e??!1),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})}catch(e){m(e)}})),ie=({defaultValue:e,title:n,subtitle:t,content:o,Input:r,disabled:i,returnOnCancel:a,background:l,footer:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,ForegroundComponent:m,BackgroundComponent:p})=>new Promise(((f,b)=>{try{I.open({type:"prompt",resolve:e=>f(e),title:n,subtitle:t,content:o,Input:r,defaultValue:e,disabled:i,returnOnCancel:a,background:l,footer:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,ForegroundComponent:m,BackgroundComponent:p})}catch(e){b(e)}}));
1
+ import{jsx as e,jsxs as n}from"react/jsx-runtime";import{createContext as t,memo as o,useRef as r,useState as i,useMemo as a,useLayoutEffect as l,useCallback as s,useContext as c,forwardRef as d,Fragment as u,useEffect as m,useImperativeHandle as p}from"react";import{getRandomString as f,convertMsFromDuration as b,isString as h,isFunction as C,counterFactory as g,printError as v}from"@winglet/common-utils";import{useReference as y,useOnMountLayout as k,useHandle as w,renderComponent as x,withErrorBoundary as O,useTick as B,useOnMount as D}from"@winglet/react-utils";import{css as j,cx as P}from"@emotion/css";import{createPortal as F}from"react-dom";
2
2
  /******************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -13,6 +13,5 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
17
- function ae(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 le(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 se,ce,de,ue,me;"function"==typeof SuppressedError&&SuppressedError;class pe{get alive(){return ae(this,se,"f")}get visible(){return ae(this,ce,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,background:r,dimmed:i=!0,manualDestroy:a=!1,closeOnBackdropClick:l=!0,resolve:s,ForegroundComponent:c,BackgroundComponent:d}){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}),se.set(this,void 0),ce.set(this,void 0),de.set(this,void 0),ue.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.dimmed=i,this.manualDestroy=a,this.closeOnBackdropClick=l,this.ForegroundComponent=c,this.BackgroundComponent=d,le(this,se,!0,"f"),le(this,ce,!0,"f"),le(this,de,s,"f")}subscribe(e){return ae(this,ue,"f").push(e),()=>{le(this,ue,ae(this,ue,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of ae(this,ue,"f"))e()}resolve(e){ae(this,de,"f").call(this,e)}onDestroy(){const e=!0===ae(this,se,"f");le(this,se,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===ae(this,ce,"f");le(this,ce,!0,"f"),e&&this.publish()}onHide(){const e=!0===ae(this,ce,"f");le(this,ce,!1,"f"),e&&this.publish()}}se=new WeakMap,ce=new WeakMap,de=new WeakMap,ue=new WeakMap;class fe extends pe{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:l,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,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=a,this.footer=l}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class be extends pe{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:l,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,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=a,this.footer=l}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class he extends pe{constructor({id:e,initiator:n,type:t,title:o,subtitle:r,content:i,defaultValue:a,Input:l,disabled:s,returnOnCancel:c,footer:d,background:u,dimmed:m,manualDestroy:p,closeOnBackdropClick:f,resolve:b,ForegroundComponent:h,BackgroundComponent:C}){super({id:e,initiator:n,title:o,subtitle:r,background:u,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}),me.set(this,void 0),this.type=t,this.content=i,this.Input=l,this.defaultValue=a,le(this,me,a,"f"),this.disabled=s,this.returnOnCancel=c,this.footer=d}onChange(e){le(this,me,e,"f")}onConfirm(){this.resolve(ae(this,me,"f")??null)}onClose(){this.returnOnCancel?this.resolve(ae(this,me,"f")??null):this.resolve(null)}}me=new WeakMap;const Ce=e=>{switch(e.type){case"alert":return new fe(e);case"confirm":return new be(e);case"prompt":return new he(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},ge=/^\s*(\d+)\s*(ms|s|m|h)\s*$/,ve=e=>{const[,n,t]=e.match(ge)||[];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},ye=t({modalIds:[],getModalNode:B,onChange:B,onConfirm:B,onClose:B,onDestroy:B,setUpdater:B,getModal:()=>({modal:void 0,onConfirm:B,onClose:B,onChange:B,onDestroy:B})}),ke=a((({pathname:n,children:t})=>{const r=c(new Map),[a,l]=s([]),u=v(a),m=c(n),p=c(0),f=ze(),b=o((()=>ve(f.duration)),[f]);y((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=f;for(const t of I.prerender){const o=Ce({...t,id:p.current++,initiator:m.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});r.current.set(o.id,o),l((e=>[...e,o.id]))}I.setupOpen((t=>{const o=Ce({...t,id:p.current++,initiator:m.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});r.current.set(o.id,o),l((e=>[...e.filter((e=>{const n=!r.current.get(e)?.alive;return n&&r.current.delete(e),!n})),o.id]))})),I.clearPrerender()})),d((()=>{for(const e of u.current){const t=r.current.get(e);t?.alive&&(t.initiator===n?t.onShow():t.onHide())}m.current=n}),[u,n]);const h=i((e=>r.current.get(e)),[]),C=i((e=>{const n=r.current.get(e);n&&(n.onDestroy(),g.current?.())}),[]),g=c(),k=i((e=>{const n=r.current.get(e);n&&(n.onHide(),g.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),b))}),[b]),O=i(((e,n)=>{const t=r.current.get(e);t&&"prompt"===t.type&&t.onChange(n)}),[]),w=i((e=>{const n=r.current.get(e);n&&(n.onConfirm(),k(e))}),[k]),x=i((e=>{const n=r.current.get(e);n&&(n.onClose(),k(e))}),[k]),D=i((e=>({modal:h(e),onConfirm:()=>w(e),onClose:()=>x(e),onChange:n=>O(e,n),onDestroy:()=>C(e)})),[h,w,x,O,C]),B=o((()=>({modalIds:a,getModalNode:h,onChange:O,onConfirm:w,onClose:x,onDestroy:C,getModal:D,setUpdater:e=>{g.current=e}})),[a,D,h,O,w,x,C]);return e(ye.Provider,{value:B,children:t})})),Oe=()=>r(ye),we=e=>{const{getModal:n}=Oe();return o((()=>n(e)),[e,n])},xe=j("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)."}}),De=e=>e?.visible&&e.dimmed,Be=a(h((()=>{const[n,t]=C(),{modalIds:o,setUpdater:r}=Oe();u((()=>{r(t)}),[r,t]);const{options:i}=$e(),a=te(De,n);return e("div",{className:xe,style:{transitionDuration:i.duration,backgroundColor:a?i.backdrop:"transparent"},children:o.map((n=>e(ee,{modalId:n},n)))})})));function je(){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 Pe=j("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:je}),Ne=j("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:je}),Fe=({children:n})=>e("h2",{className:Pe,children:n}),Ee=({children:n})=>e("h3",{className:Pe,children:n}),Ie=({children:n})=>e("div",{className:Pe,children:n}),Se=({confirmLabel:t,hideConfirm:o=!1,cancelLabel:r,hideCancel:i=!1,disabled:a,onConfirm:l,onCancel:s})=>n("div",{children:[!o&&e("button",{onClick:l,disabled:a,children:t||"확인"}),!i&&"function"==typeof s&&e("button",{onClick:s,children:r||"취소"})]}),Ve=m((({id:n,onChangeOrder:t,children:r},i)=>{const a=te(),[l,s]=o((()=>{const e=a>1;return[e?Math.floor(n/5)%3*100:0,e?n%5*35:0]}),[a,n]);return e("div",{ref:i,className:Ne,onClick:t,style:{marginBottom:`calc(25vh + ${l}px)`,marginLeft:`${l}px`,transform:`translate(${s}px, ${s}px)`},children:r})})),Te=()=>{const[e,n]=s(window.location.pathname);return d((()=>{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}},Me=t({ForegroundComponent:Ve,TitleComponent:Fe,SubtitleComponent:Ee,ContentComponent:Ie,FooterComponent:Se,options:{duration:S,backdrop:V,manualDestroy:!1,closeOnBackdropClick:!0}}),_e=a((({ForegroundComponent:t,BackgroundComponent:r,TitleComponent:i,SubtitleComponent:l,ContentComponent:s,FooterComponent:d,options:u,context:m,usePathname:f,children:b})=>{const{pathname:h}=(f||Te)(),[,v]=C(),y=c(null);g((()=>(y.current=I.anchor("div"),v(),()=>{y.current&&y.current.remove()})));const k=o((()=>({BackgroundComponent:r,ForegroundComponent:t||Ve,TitleComponent:i||Fe,SubtitleComponent:l||Ee,ContentComponent:a(s||Ie),FooterComponent:a(d||Se),options:{duration:S,backdrop:V,closeOnBackdropClick:!0,manualDestroy:!1,...u}})),[t,r,s,d,l,i,u]);return n(Me.Provider,{value:k,children:[b,y.current&&p(e(M,{context:m,children:e(ke,{pathname:h,children:e(Be,{})})}),y.current)]})})),$e=()=>r(Me),ze=()=>{const{options:e}=r(Me);return e},Ae=()=>{const{duration:e}=ze();return{duration:e,milliseconds:ve(e)}},Le=()=>{const{backdrop:e}=ze();return e},qe=(e,n)=>{const{modal:t,onDestroy:o}=we(e),r=R(t),i=c({modal:t,onDestroy:o,milliseconds:w(n)?ve(n):n});u((()=>{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])},We=(e,n)=>{const t=c(n);t.current=n,d((()=>{if(!t.current)return;let n;return n=e?requestAnimationFrame((()=>t.current.onVisible?.())):requestAnimationFrame((()=>t.current.onHidden?.())),()=>{n&&cancelAnimationFrame(n)}}),[e])};export{_e as ModalProvider,oe as alert,re as confirm,ie as prompt,te as useActiveModalCount,qe as useDestroyAfter,We as useModalAnimation,Le as useModalBackdrop,Ae as useModalDuration,ze as useModalOptions,R as useSubscribeModal};
16
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */function N(e,n,t,o){if("a"===t&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!o:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?o:"a"===t?o.call(e):o?o.value:n.get(e)}function E(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 I,S,M,T,V;"function"==typeof SuppressedError&&SuppressedError;class z{static activate(){return!N(I,I,"f",S)&&E(I,I,!0,"f",S)}static anchor(e){if(N(I,I,"f",M)){const e=document.getElementById(N(I,I,"f",M).id);if(e)return e}const{tag:n="div",prefix:t="promise-modal",root:o=document.body}=e||{},r=document.createElement(n);return r.setAttribute("id",`${t}-${f(36)}`),o.appendChild(r),E(I,I,r,"f",M),r}static get prerender(){return N(I,I,"f",T)}static set openHandler(e){E(I,I,e,"f",V),E(I,I,[],"f",T)}static get unanchored(){return!N(I,I,"f",M)}static reset(){E(I,I,!1,"f",S),E(I,I,null,"f",M),E(I,I,[],"f",T),E(I,I,(e=>N(I,I,"f",T).push(e)),"f",V)}static open(e){N(I,I,"f",V).call(I,e)}}I=z,S={value:!1},M={value:null},T={value:[]},V={value:e=>N(I,I,"f",T).push(e)};const _=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})=>new Promise(((u,m)=>{try{z.open({type:"alert",subtype:e,resolve:()=>u(),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})}catch(e){m(e)}})),A=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})=>new Promise(((u,m)=>{try{z.open({type:"confirm",subtype:e,resolve:e=>u(e??!1),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})}catch(e){m(e)}})),L=({defaultValue:e,title:n,subtitle:t,content:o,Input:r,disabled:i,returnOnCancel:a,background:l,footer:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,ForegroundComponent:m,BackgroundComponent:p})=>new Promise(((f,b)=>{try{z.open({type:"prompt",resolve:e=>f(e),title:n,subtitle:t,content:o,Input:r,defaultValue:e,disabled:i,returnOnCancel:a,background:l,footer:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,ForegroundComponent:m,BackgroundComponent:p})}catch(e){b(e)}}));var $,H,q,W,Y;class U{get alive(){return N(this,$,"f")}get visible(){return N(this,H,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,background:r,dimmed:i=!0,manualDestroy:a=!1,closeOnBackdropClick:l=!0,resolve:s,ForegroundComponent:c,BackgroundComponent:d}){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}),$.set(this,void 0),H.set(this,void 0),q.set(this,void 0),W.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.dimmed=i,this.manualDestroy=a,this.closeOnBackdropClick=l,this.ForegroundComponent=c,this.BackgroundComponent=d,E(this,$,!0,"f"),E(this,H,!0,"f"),E(this,q,s,"f")}subscribe(e){return N(this,W,"f").push(e),()=>{E(this,W,N(this,W,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of N(this,W,"f"))e()}resolve(e){N(this,q,"f").call(this,e)}onDestroy(){const e=!0===N(this,$,"f");E(this,$,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===N(this,H,"f");E(this,H,!0,"f"),e&&this.publish()}onHide(){const e=!0===N(this,H,"f");E(this,H,!1,"f"),e&&this.publish()}}$=new WeakMap,H=new WeakMap,q=new WeakMap,W=new WeakMap;class G extends U{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:l,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,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=a,this.footer=l}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class J extends U{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:l,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,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=a,this.footer=l}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class K extends U{constructor({id:e,initiator:n,type:t,title:o,subtitle:r,content:i,defaultValue:a,Input:l,disabled:s,returnOnCancel:c,footer:d,background:u,dimmed:m,manualDestroy:p,closeOnBackdropClick:f,resolve:b,ForegroundComponent:h,BackgroundComponent:C}){super({id:e,initiator:n,title:o,subtitle:r,background:u,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}),Y.set(this,void 0),this.type=t,this.content=i,this.Input=l,this.defaultValue=a,E(this,Y,a,"f"),this.disabled=s,this.returnOnCancel=c,this.footer=d}onChange(e){E(this,Y,e,"f")}onConfirm(){this.resolve(N(this,Y,"f")??null)}onClose(){this.returnOnCancel?this.resolve(N(this,Y,"f")??null):this.resolve(null)}}Y=new WeakMap;const Q=e=>{switch(e.type){case"alert":return new G(e);case"confirm":return new J(e);case"prompt":return new K(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},R=t({}),X=o((({usePathname:n,children:t})=>{const o=r(new Map),[c,d]=i([]),u=y(c),{pathname:m}=n(),p=r(m),f=r(0),h=fe(),C=a((()=>b(h.duration)),[h]);k((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=h;for(const t of z.prerender){const r=Q({...t,id:f.current++,initiator:p.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});o.current.set(r.id,r),d((e=>[...e,r.id]))}return z.openHandler=t=>{const r=Q({...t,id:f.current++,initiator:p.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});o.current.set(r.id,r),d((e=>[...e.filter((e=>{const n=!o.current.get(e)?.alive;return n&&o.current.delete(e),!n})),r.id]))},()=>{z.reset()}})),l((()=>{for(const e of u.current){const n=o.current.get(e);n?.alive&&(n.initiator===m?n.onShow():n.onHide())}p.current=m}),[u,m]);const g=s((e=>o.current.get(e)),[]),v=s((e=>{const n=o.current.get(e);n&&(n.onDestroy(),w.current?.())}),[]),w=r(),x=s((e=>{const n=o.current.get(e);n&&(n.onHide(),w.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),C))}),[C]),O=s(((e,n)=>{const t=o.current.get(e);t&&"prompt"===t.type&&t.onChange(n)}),[]),B=s((e=>{const n=o.current.get(e);n&&(n.onConfirm(),x(e))}),[x]),D=s((e=>{const n=o.current.get(e);n&&(n.onClose(),x(e))}),[x]),j=s((e=>({modal:g(e),onConfirm:()=>B(e),onClose:()=>D(e),onChange:n=>O(e,n),onDestroy:()=>v(e)})),[g,B,D,O,v]),P=a((()=>({modalIds:c,getModalNode:g,onChange:O,onConfirm:B,onClose:D,onDestroy:v,getModal:j,setUpdater:e=>{w.current=e}})),[c,j,g,O,B,D,v]);return e(R.Provider,{value:P,children:t})})),Z=()=>c(R),ee=e=>{const{getModal:n}=Z();return a((()=>n(e)),[e,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=j("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:ne}),oe=j("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("h2",{className:te,children:n}),ie=({children:n})=>e("h3",{className:te,children:n}),ae=({children:n})=>e("div",{className:te,children:n}),le=({confirmLabel:t,hideConfirm:o=!1,cancelLabel:r,hideCancel:i=!1,disabled:a,onConfirm:l,onCancel:s})=>n("div",{children:[!o&&e("button",{onClick:l,disabled:a,children:t||"확인"}),!i&&"function"==typeof s&&e("button",{onClick:s,children:r||"취소"})]}),se=e=>e?.visible,ce=(e=se,n=0)=>{const{modalIds:t,getModalNode:o}=Z();return a((()=>{let n=0;for(const r of t)e(o(r))&&n++;return n}),[o,t,n])},de=d((({id:n,onChangeOrder:t,children:o},r)=>{const i=ce(),[l,s]=a((()=>{const e=i>1;return[e?Math.floor(n/5)%3*100:0,e?n%5*35:0]}),[i,n]);return e("div",{ref:r,className:oe,onClick:t,style:{marginBottom:`calc(25vh + ${l}px)`,marginLeft:`${l}px`,transform:`translate(${s}px, ${s}px)`},children:o})})),ue=t({}),me=o((({ForegroundComponent:n,BackgroundComponent:t,TitleComponent:r,SubtitleComponent:i,ContentComponent:l,FooterComponent:s,options:c,children:d})=>{const u=a((()=>({BackgroundComponent:t,ForegroundComponent:n||de,TitleComponent:r||re,SubtitleComponent:i||ie,ContentComponent:o(l||ae),FooterComponent:o(s||le),options:{duration:"300ms",backdrop:"rgba(0, 0, 0, 0.5)",closeOnBackdropClick:!0,manualDestroy:!1,...c}})),[n,t,l,s,i,r,c]);return e(ue.Provider,{value:u,children:d})})),pe=()=>c(ue),fe=()=>c(ue).options,be=()=>{const e=fe();return{duration:e.duration,milliseconds:b(e.duration)}},he=()=>fe().backdrop,Ce=t({}),ge=({context:n,children:t})=>{const o=a((()=>({context:n||{}})),[n]);return e(Ce.Provider,{value:o,children:t})},ve=()=>c(Ce);function ye(){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 ke=j("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:ye}),we=j("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:ye}),xe=j("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:ye}),Oe=({modalId:n,onChangeOrder:t})=>{const{BackgroundComponent:o}=pe(),{context:r}=ve(),{modal:i,onClose:l,onChange:c,onConfirm:d,onDestroy:u}=ee(n),m=s((e=>{i&&i.closeOnBackdropClick&&i.visible&&l(),e.stopPropagation()}),[i,l]),p=a((()=>i?.BackgroundComponent||o),[o,i]);return i?e("div",{className:P(ke,{[xe]:i.manualDestroy?i.alive:i.visible,[we]:i.closeOnBackdropClick&&i.visible}),onClick:m,children:p&&e(p,{id:i.id,type:i.type,alive:i.alive,visible:i.visible,initiator:i.initiator,manualDestroy:i.manualDestroy,closeOnBackdropClick:i.closeOnBackdropClick,background:i.background,onChange:c,onConfirm:d,onClose:l,onDestroy:u,onChangeOrder:t,context:r})}):null};function Be(){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 De=j("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:Be}),je=j("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:Be}),Pe=j("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:Be}),Fe=o((({modal:t,handlers:o})=>{const{title:r,subtitle:i,content:l,footer:s}=a((()=>t),[t]),{context:c}=ve(),{onConfirm:d}=a((()=>o),[o]),m=w(d),{TitleComponent:p,SubtitleComponent:f,ContentComponent:b,FooterComponent:C}=pe();return n(u,{children:[r&&(h(r)?e(p,{context:c,children:r}):r),i&&(h(i)?e(f,{context:c,children:i}):i),l&&(h(l)?e(b,{context:c,children:l}):x(l,{onConfirm:m})),!1!==s&&("function"==typeof s?s({onConfirm:m,context:c}):e(C,{onConfirm:m,confirmLabel:s?.confirm,hideConfirm:s?.hideConfirm,context:c}))]})})),Ne=o((({modal:t,handlers:o})=>{const{title:r,subtitle:i,content:l,footer:s}=a((()=>t),[t]),{context:c}=ve(),{onConfirm:d,onClose:m}=a((()=>o),[o]),p=w(d),f=w(m),{TitleComponent:b,SubtitleComponent:C,ContentComponent:g,FooterComponent:v}=pe();return n(u,{children:[r&&(h(r)?e(b,{context:c,children:r}):r),i&&(h(i)?e(C,{context:c,children:i}):i),l&&(h(l)?e(g,{context:c,children:l}):x(l,{onConfirm:p,onCancel:f,context:c})),!1!==s&&("function"==typeof s?s({onConfirm:p,onCancel:f,context:c}):e(v,{onConfirm:p,onCancel:f,confirmLabel:s?.confirm,cancelLabel:s?.cancel,hideConfirm:s?.hideConfirm,hideCancel:s?.hideCancel,context:c}))]})})),Ee=o((({modal:t,handlers:r})=>{const{Input:l,defaultValue:c,disabled:d,title:m,subtitle:p,content:f,footer:b}=a((()=>({...t,Input:o(O(t.Input))})),[t]),{context:g}=ve(),[v,y]=i(c),{onChange:k,onClose:B,onConfirm:D}=a((()=>r),[r]),j=w(B),P=w((e=>{const n=C(e)?e(v):e;y(n),k(n)})),F=s((()=>{setTimeout((()=>{D()}))}),[D]),N=a((()=>!!v&&!!d?.(v)),[d,v]),{TitleComponent:E,SubtitleComponent:I,ContentComponent:S,FooterComponent:M}=pe();return n(u,{children:[m&&(h(m)?e(E,{context:g,children:m}):m),p&&(h(p)?e(I,{context:g,children:p}):p),f&&(h(f)?e(S,{context:g,children:f}):x(f,{onConfirm:F,onCancel:j,context:g})),l&&e(l,{defaultValue:c,value:v,onChange:P,onConfirm:F,onCancel:j,context:g}),!1!==b&&("function"==typeof b?b({value:v,disabled:N,onChange:P,onConfirm:F,onCancel:j,context:g}):e(M,{disabled:N,onConfirm:F,onCancel:j,confirmLabel:b?.confirm,cancelLabel:b?.cancel,hideConfirm:b?.hideConfirm,hideCancel:b?.hideCancel,context:g}))]})})),Ie=({modalId:t,onChangeOrder:o})=>{const{ForegroundComponent:r}=pe(),{context:i}=ve(),{modal:l,onChange:s,onConfirm:c,onClose:d,onDestroy:u}=ee(t),m=a((()=>l?.ForegroundComponent||r),[r,l]);return l?e("div",{className:P(De,{[Pe]:l.manualDestroy?l.alive:l.visible,[je]:l.visible}),children:n(m,{id:l.id,type:l.type,alive:l.alive,visible:l.visible,initiator:l.initiator,manualDestroy:l.manualDestroy,closeOnBackdropClick:l.closeOnBackdropClick,background:l.background,onChange:s,onConfirm:c,onClose:d,onDestroy:u,onChangeOrder:o,context:i,children:["alert"===l.type&&e(Fe,{modal:l,handlers:{onConfirm:c}}),"confirm"===l.type&&e(Ne,{modal:l,handlers:{onConfirm:c,onClose:d}}),"prompt"===l.type&&e(Ee,{modal:l,handlers:{onChange:s,onConfirm:c,onClose:d}})]})}):null},Se=e=>{const[n,t]=B();return D((()=>{if(e)return e.subscribe(t)})),n},Me=j("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:Te}=g(1),Ve=o((({modalId:t})=>{const o=r(null),{modal:i}=ee(t);Se(i);const a=w((()=>{o.current&&(o.current.style.zIndex=`${Te()}`)}));return n("div",{ref:o,className:Me,children:[e(Oe,{modalId:t,onChangeOrder:a}),e(Ie,{modalId:t,onChangeOrder:a})]})})),ze=j("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)."}}),_e=e=>e?.visible&&e.dimmed,Ae=o(O((()=>{const[n,t]=B(),{modalIds:o,setUpdater:r}=Z();m((()=>{r(t)}),[r,t]);const i=fe(),a=ce(_e,n);return e("div",{className:ze,style:{transitionDuration:i.duration,backgroundColor:a?i.backdrop:"transparent"},children:o.map((n=>e(Ve,{modalId:n},n)))})}))),Le=({ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:a,usePathname:l,options:s,context:c,anchor:d})=>F(e(ge,{context:c,children:e(me,{ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:a,options:s,children:e(X,{usePathname:l,children:e(Ae,{})})})}),d),$e=()=>{const[e,n]=i(window.location.pathname);return l((()=>{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}},He=d((({usePathname:e,ForegroundComponent:t,BackgroundComponent:o,TitleComponent:i,SubtitleComponent:l,ContentComponent:c,FooterComponent:d,options:m,context:f,children:b},h)=>{const C=a((()=>e||$e),[e]),g=r(z.activate()),y=r(null),[,k]=B(),w=s((e=>{g.current?(y.current=z.anchor({root:e}),k()):v("ModalProvider is already initialized",["ModalProvider can only be initialized once.","Nesting ModalProvider will be ignored..."],{info:"Something is wrong with the ModalProvider initialization..."})}),[k]);return p(h,(()=>({initialize:w})),[w]),D((()=>(null===h&&w(),()=>{y.current&&y.current.remove()}))),n(u,{children:[b,y.current&&Le({ForegroundComponent:t,BackgroundComponent:o,TitleComponent:i,SubtitleComponent:l,ContentComponent:c,FooterComponent:d,usePathname:C,options:m,context:f,anchor:y.current})]})})),qe=(e,n)=>{const{modal:t,onDestroy:o}=ee(e),i=Se(t),a=r({modal:t,onDestroy:o,milliseconds:h(n)?b(n):n});m((()=>{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)}}),[i])},We=(e,n)=>{const t=r(n);t.current=n,l((()=>{if(!t.current)return;let n;return n=e?requestAnimationFrame((()=>t.current.onVisible?.())):requestAnimationFrame((()=>t.current.onHidden?.())),()=>{n&&cancelAnimationFrame(n)}}),[e])};export{He as ModalProvider,_ as alert,Le as bootstrap,A as confirm,L as prompt,ce as useActiveModalCount,qe as useDestroyAfter,We as useModalAnimation,he as useModalBackdrop,be as useModalDuration,fe as useModalOptions,Se as useSubscribeModal};
18
17
  //# sourceMappingURL=index.esm.js.map