@lerx/promise-modal 0.0.24 → 0.0.26

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.
@@ -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/AbstractBaseNode.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"],"sourcesContent":["import { 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 { useModalDataContext } from '../providers';\n\nexport const useActiveModalCount = (tick: string | number = 0) => {\n const { modalIds, getModalNode } = useModalDataContext();\n return useMemo(() => {\n let count = 0;\n for (const id of modalIds) {\n if (getModalNode(id)?.visible) count++;\n }\n return count;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getModalNode, modalIds, tick]);\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 BaseNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;\n\nexport abstract class BaseNode<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\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 manualDestroy = false,\n closeOnBackdropClick = true,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: BaseNodeProps<T, B>) {\n this.id = id;\n this.initiator = initiator;\n this.title = title;\n this.subtitle = subtitle;\n this.background = background;\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 { BaseNode } from './AbstractBaseNode';\n\ntype AlertNodeProps<B> = AlertModal<B> & ManagedEntity;\n\nexport class AlertNode<B> extends BaseNode<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 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 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 { BaseNode } from './AbstractBaseNode';\n\ntype ConfirmNodeProps<B> = ConfirmModal<B> & ManagedEntity;\n\nexport class ConfirmNode<B> extends BaseNode<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 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 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 { BaseNode } from './AbstractBaseNode';\n\ntype PromptNodeProps<T, B> = PromptModal<T, B> & ManagedEntity;\n\nexport class PromptNode<T, B> extends BaseNode<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 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 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 { 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 [key, 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(key);\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\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\n useLayoutEffect(() => {\n let requestId: number;\n\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\n requestId = requestAnimationFrame(checkPathname);\n\n return () => {\n if (requestId) cancelAnimationFrame(requestId);\n };\n }, [pathname]);\n\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 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 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 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 closeOnBackdropClick?: boolean;\n manualDestroy?: 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 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 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 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 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 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"],"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","useActiveModalCount","modalIds","getModalNode","useModalDataContext","count","BaseNode","__classPrivateFieldGet","this","_BaseNode_alive","_BaseNode_visible","constructor","resolve","Object","defineProperty","set","_BaseNode_resolve","_BaseNode_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","Anchor","key","useEffect","dimmed","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"],"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,CAAO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AOC,sBCxBS,EACpB3I,eACAxB,QACAC,WACAC,UACAqB,QACAE,WACA4D,iBACA7H,aACA2C,SACAb,gBACAN,uBACAoD,sBACA/D,yBAEO,IAAI4L,SAAW,CAACjG,EAASkG,KAC9B,IACE3O,EAAaG,KAAK,CAChBgE,KAAM,SACNsE,QAAUW,GAAWX,EAAQW,GAC7B3E,QACAC,WACAC,UACAqB,QACAC,eACAC,WACA4D,iBACA7H,aACA2C,SACAb,gBACAN,uBACAoD,sBACA/D,wBAEF,MAAO8L,GACPD,EAAOC,+BCrDkB,CAC7BhM,EACA2H,KAEA,MAAM1K,MAAEA,EAAKuD,UAAEA,GAAcC,EAAST,GAChCoE,EAAOD,EAAkBlH,GAEzBgP,EAAYnH,EAAAA,OAAO,CACvB7H,QACAuD,YACA0L,aAAczJ,EAAQA,SAACkF,GACnBJ,EAA4BI,GAC5BA,IAGN6B,EAAAA,WAAU,KACR,MAAMvM,MAAEA,EAAKuD,UAAEA,EAAS0L,aAAEA,GAAiBD,EAAUlP,QACrD,IAAKE,GAASA,EAAM6C,UAAY7C,EAAMmE,MAAO,OAC7C,MAAM+K,EAAQpI,YAAW,KACvBvD,GAAW,GACV0L,GACH,MAAO,KACDC,GAAOC,aAAaD,EAAM,CAC/B,GACA,CAAC/H,GAAM,2BJlBoB,KAC9B,MAAMwF,SAAEA,GAAajB,KACrB,OAAOiB,CAAQ,2BAPe,KAC9B,MAAMjC,SAAEA,GAAagB,KACrB,MAAO,CAAEhB,WAAUuE,aAAc3E,EAA4BI,GAAW"}
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/AbstractBaseNode.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"],"sourcesContent":["import { 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 BaseNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;\n\nexport abstract class BaseNode<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 }: BaseNodeProps<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 { BaseNode } from './AbstractBaseNode';\n\ntype AlertNodeProps<B> = AlertModal<B> & ManagedEntity;\n\nexport class AlertNode<B> extends BaseNode<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 { BaseNode } from './AbstractBaseNode';\n\ntype ConfirmNodeProps<B> = ConfirmModal<B> & ManagedEntity;\n\nexport class ConfirmNode<B> extends BaseNode<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 { BaseNode } from './AbstractBaseNode';\n\ntype PromptNodeProps<T, B> = PromptModal<T, B> & ManagedEntity;\n\nexport class PromptNode<T, B> extends BaseNode<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\n useLayoutEffect(() => {\n let requestId: number;\n\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\n requestId = requestAnimationFrame(checkPathname);\n\n return () => {\n if (requestId) cancelAnimationFrame(requestId);\n };\n }, [pathname]);\n\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"],"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","BaseNode","__classPrivateFieldGet","this","_BaseNode_alive","_BaseNode_visible","constructor","dimmed","resolve","Object","defineProperty","set","_BaseNode_resolve","_BaseNode_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"],"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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MAAO,CAAEhB,WAAUsE,aAAc1E,EAA4BI,GAAW"}
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 p}from"react";import{createPortal as m}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:[]},E={current:e=>{N.current.push(e)}},F={current:null},I={get prerender(){return N.current},clearPrerender(){N.current=[]},open(e){E.current(e)},setupOpen(e){E.current=e},anchor(e,n="promise-modal"){if(F.current){const e=document.getElementById(F.current.id);if(e)return e}const t=document.createElement(e);return t.setAttribute("id",`${n}-${k(36)}`),document.body.appendChild(t),F.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:$}),L=j("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:$}),A=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:$}),W=({modalId:n,onChangeOrder:t})=>{const{BackgroundComponent:r}=Me(),{context:a}=_(),{modal:l,onClose:s,onChange:c,onConfirm:d,onDestroy:u}=Oe(n),p=i((e=>{l&&l.closeOnBackdropClick&&l.visible&&s(),e.stopPropagation()}),[l,s]),m=o((()=>l?.BackgroundComponent||r),[r,l]);return l?e("div",{className:P(z,{[A]:l.manualDestroy?l.alive:l.visible,[L]:l.closeOnBackdropClick&&l.visible}),onClick:p,children:m&&e(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:c,onConfirm:d,onClose:s,onDestroy:u,onChangeOrder:t,context:a})}):null};function Y(){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 U=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:Y}),q=j("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:Y}),H=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:Y}),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]),p=f(u),{TitleComponent:m,SubtitleComponent:h,ContentComponent:C,FooterComponent:g}=Me();return n(l,{children:[i&&(w(i)?e(m,{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:p})),!1!==c&&("function"==typeof c?c({onConfirm:p,context:d}):e(g,{onConfirm:p,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:p}=o((()=>r),[r]),m=f(u),h=f(p),{TitleComponent:C,SubtitleComponent:g,ContentComponent:v,FooterComponent:y}=Me();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:m,onCancel:h,context:d})),!1!==c&&("function"==typeof c?c({onConfirm:m,onCancel:h,context:d}):e(y,{onConfirm:m,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:p,subtitle:m,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]),E=o((()=>!!y&&!!u?.(y)),[u,y]),{TitleComponent:F,SubtitleComponent:I,ContentComponent:S,FooterComponent:V}=Me();return n(l,{children:[p&&(w(p)?e(F,{context:v,children:p}):p),m&&(w(m)?e(I,{context:v,children:m}):m),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:E,onChange:P,onConfirm:N,onCancel:j,context:v}):e(V,{disabled:E,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}=Me(),{context:a}=_(),{modal:l,onChange:s,onConfirm:c,onClose:d,onDestroy:u}=Oe(t),p=o((()=>l?.ForegroundComponent||i),[i,l]);return l?e("div",{className:P(U,{[H]:l.manualDestroy?l.alive:l.visible,[q]:l.visible}),children:n(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: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}=Oe(t);R(r);const i=f((()=>{o.current&&(o.current.style.zIndex=`${Z()}`)}));return n("div",{ref:o,className:X,children:[e(W,{modalId:t,onChangeOrder:i}),e(Q,{modalId:t,onChangeOrder:i})]})})),ne=(e=0)=>{const{modalIds:n,getModalNode:t}=ke();return o((()=>{let e=0;for(const o of n)t(o)?.visible&&e++;return e}),[t,n,e])},te=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})=>new Promise(((d,u)=>{try{I.open({type:"alert",subtype:e,resolve:()=>d(),title:n,subtitle:t,content:o,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})}catch(e){u(e)}})),oe=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})=>new Promise(((d,u)=>{try{I.open({type:"confirm",subtype:e,resolve:e=>d(e??!1),title:n,subtitle:t,content:o,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})}catch(e){u(e)}})),re=({defaultValue:e,title:n,subtitle:t,content:o,Input:r,disabled:i,returnOnCancel:a,background:l,footer:s,manualDestroy:c,closeOnBackdropClick:d,ForegroundComponent:u,BackgroundComponent:p})=>new Promise(((m,f)=>{try{I.open({type:"prompt",resolve:e=>m(e),title:n,subtitle:t,content:o,Input:r,defaultValue:e,disabled:i,returnOnCancel:a,background:l,footer:s,manualDestroy:c,closeOnBackdropClick:d,ForegroundComponent:u,BackgroundComponent:p})}catch(e){f(e)}}));
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:[]},E={current:e=>{N.current.push(e)}},F={current:null},I={get prerender(){return N.current},clearPrerender(){N.current=[]},open(e){E.current(e)},setupOpen(e){E.current=e},anchor(e,n="promise-modal"){if(F.current){const e=document.getElementById(F.current.id);if(e)return e}const t=document.createElement(e);return t.setAttribute("id",`${n}-${k(36)}`),document.body.appendChild(t),F.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:$}),L=j("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:$}),A=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:$}),W=({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,{[A]:l.manualDestroy?l.alive:l.visible,[L]: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 Y(){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 U=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:Y}),q=j("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:Y}),H=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:Y}),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]),E=o((()=>!!y&&!!u?.(y)),[u,y]),{TitleComponent:F,SubtitleComponent:I,ContentComponent:S,FooterComponent:V}=$e();return n(l,{children:[m&&(w(m)?e(F,{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:E,onChange:P,onConfirm:N,onCancel:j,context:v}):e(V,{disabled:E,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(U,{[H]:l.manualDestroy?l.alive:l.visible,[q]: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(W,{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)}}));
2
2
  /******************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -14,5 +14,5 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
16
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
17
- function ie(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 ae(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 le,se,ce,de,ue;"function"==typeof SuppressedError&&SuppressedError;class pe{get alive(){return ie(this,le,"f")}get visible(){return ie(this,se,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,background:r,manualDestroy:i=!1,closeOnBackdropClick:a=!0,resolve:l,ForegroundComponent:s,BackgroundComponent:c}){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"initiator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"title",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtitle",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"background",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualDestroy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"closeOnBackdropClick",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ForegroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BackgroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),le.set(this,void 0),se.set(this,void 0),ce.set(this,void 0),de.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.manualDestroy=i,this.closeOnBackdropClick=a,this.ForegroundComponent=s,this.BackgroundComponent=c,ae(this,le,!0,"f"),ae(this,se,!0,"f"),ae(this,ce,l,"f")}subscribe(e){return ie(this,de,"f").push(e),()=>{ae(this,de,ie(this,de,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of ie(this,de,"f"))e()}resolve(e){ie(this,ce,"f").call(this,e)}onDestroy(){const e=!0===ie(this,le,"f");ae(this,le,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===ie(this,se,"f");ae(this,se,!0,"f"),e&&this.publish()}onHide(){const e=!0===ie(this,se,"f");ae(this,se,!1,"f"),e&&this.publish()}}le=new WeakMap,se=new WeakMap,ce=new WeakMap,de=new WeakMap;class me extends pe{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:l,background:s,manualDestroy:c,closeOnBackdropClick:d,resolve:u,ForegroundComponent:p,BackgroundComponent:m}){super({id:e,initiator:n,title:r,subtitle:i,background:s,manualDestroy:c,closeOnBackdropClick:d,resolve:u,ForegroundComponent:p,BackgroundComponent:m}),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 fe extends pe{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:l,background:s,manualDestroy:c,closeOnBackdropClick:d,resolve:u,ForegroundComponent:p,BackgroundComponent:m}){super({id:e,initiator:n,title:r,subtitle:i,background:s,manualDestroy:c,closeOnBackdropClick:d,resolve:u,ForegroundComponent:p,BackgroundComponent:m}),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 be 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,manualDestroy:p,closeOnBackdropClick:m,resolve:f,ForegroundComponent:b,BackgroundComponent:h}){super({id:e,initiator:n,title:o,subtitle:r,background:u,manualDestroy:p,closeOnBackdropClick:m,resolve:f,ForegroundComponent:b,BackgroundComponent:h}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"Input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"returnOnCancel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),ue.set(this,void 0),this.type=t,this.content=i,this.Input=l,this.defaultValue=a,ae(this,ue,a,"f"),this.disabled=s,this.returnOnCancel=c,this.footer=d}onChange(e){ae(this,ue,e,"f")}onConfirm(){this.resolve(ie(this,ue,"f")??null)}onClose(){this.returnOnCancel?this.resolve(ie(this,ue,"f")??null):this.resolve(null)}}ue=new WeakMap;const he=e=>{switch(e.type){case"alert":return new me(e);case"confirm":return new fe(e);case"prompt":return new be(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},Ce=/^\s*(\d+)\s*(ms|s|m|h)\s*$/,ge=e=>{const[,n,t]=e.match(Ce)||[];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},ve=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})}),ye=a((({pathname:n,children:t})=>{const r=c(new Map),[a,l]=s([]),u=v(a),p=c(n),m=c(0),f=_e(),b=o((()=>ge(f.duration)),[f]);y((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=f;for(const t of I.prerender){const o=he({...t,id:m.current++,initiator:p.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=he({...t,id:m.current++,initiator:p.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())}p.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(ve.Provider,{value:B,children:t})})),ke=()=>r(ve),Oe=e=>{const{getModal:n}=ke();return o((()=>n(e)),[e,n])},we=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)."}}),xe=a(h((()=>{const[n,t]=C(),{modalIds:o,setUpdater:r}=ke();u((()=>{r(t)}),[r,t]);const{options:i}=Me(),a=ne(n);return e("div",{className:we,style:{transitionDuration:i.duration,backgroundColor:a?i.backdrop:"transparent"},children:o.map((n=>e(ee,{modalId:n},n)))})})));function De(){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 Be=j("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:De}),je=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:De}),Pe=({children:n})=>e("h2",{className:Be,children:n}),Ne=({children:n})=>e("h3",{className:Be,children:n}),Ee=({children:n})=>e("div",{className:Be,children:n}),Fe=({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||"취소"})]}),Ie=p((({id:n,onChangeOrder:t,children:r},i)=>{const a=ne(),[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:je,onClick:t,style:{marginBottom:`calc(25vh + ${l}px)`,marginLeft:`${l}px`,transform:`translate(${s}px, ${s}px)`},children:r})})),Se=()=>{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}},Ve=t({ForegroundComponent:Ie,TitleComponent:Pe,SubtitleComponent:Ne,ContentComponent:Ee,FooterComponent:Fe,options:{duration:S,backdrop:V,manualDestroy:!1,closeOnBackdropClick:!0}}),Te=a((({ForegroundComponent:t,BackgroundComponent:r,TitleComponent:i,SubtitleComponent:l,ContentComponent:s,FooterComponent:d,options:u,context:p,usePathname:f,children:b})=>{const{pathname:h}=(f||Se)(),[,v]=C(),y=c(null);g((()=>(y.current=I.anchor("div"),v(),()=>{y.current&&y.current.remove()})));const k=o((()=>({BackgroundComponent:r,ForegroundComponent:t||Ie,TitleComponent:i||Pe,SubtitleComponent:l||Ne,ContentComponent:a(s||Ee),FooterComponent:a(d||Fe),options:{duration:S,backdrop:V,closeOnBackdropClick:!0,manualDestroy:!1,...u}})),[t,r,s,d,l,i,u]);return n(Ve.Provider,{value:k,children:[b,y.current&&m(e(M,{context:p,children:e(ye,{pathname:h,children:e(xe,{})})}),y.current)]})})),Me=()=>r(Ve),_e=()=>{const{options:e}=r(Ve);return e},$e=()=>{const{duration:e}=_e();return{duration:e,milliseconds:ge(e)}},ze=()=>{const{backdrop:e}=_e();return e},Le=(e,n)=>{const{modal:t,onDestroy:o}=Oe(e),r=R(t),i=c({modal:t,onDestroy:o,milliseconds:w(n)?ge(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])};export{Te as ModalProvider,te as alert,oe as confirm,re as prompt,Le as useDestroyAfter,ze as useModalBackdrop,$e as useModalDuration,_e as useModalOptions,R as useSubscribeModal};
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}),Ee=({children:n})=>e("h2",{className:Pe,children:n}),Fe=({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:Ee,SubtitleComponent:Fe,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||Ee,SubtitleComponent:l||Fe,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},Le=()=>{const{duration:e}=ze();return{duration:e,milliseconds:ve(e)}},Ae=()=>{const{backdrop:e}=ze();return e},We=(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])};export{_e as ModalProvider,oe as alert,re as confirm,ie as prompt,We as useDestroyAfter,Ae as useModalBackdrop,Le as useModalDuration,ze as useModalOptions,R as useSubscribeModal};
18
18
  //# sourceMappingURL=index.esm.js.map