@lerx/promise-modal 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Background/Background.d.ts.map +1 -1
- package/dist/components/Foreground/Foreground.d.ts.map +1 -1
- package/dist/core/handle/alert.d.ts +4 -2
- package/dist/core/handle/alert.d.ts.map +1 -1
- package/dist/core/handle/confirm.d.ts +4 -2
- package/dist/core/handle/confirm.d.ts.map +1 -1
- package/dist/core/handle/prompt.d.ts +4 -2
- package/dist/core/handle/prompt.d.ts.map +1 -1
- package/dist/core/node/ModalNode/AbstractBaseNode.d.ts +4 -2
- package/dist/core/node/ModalNode/AbstractBaseNode.d.ts.map +1 -1
- package/dist/core/node/ModalNode/AlertNode.d.ts +1 -1
- package/dist/core/node/ModalNode/AlertNode.d.ts.map +1 -1
- package/dist/core/node/ModalNode/ConfirmNode.d.ts +1 -1
- package/dist/core/node/ModalNode/ConfirmNode.d.ts.map +1 -1
- package/dist/core/node/ModalNode/PromptNode.d.ts +1 -1
- package/dist/core/node/ModalNode/PromptNode.d.ts.map +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/providers/ModalContext/ModalContext.d.ts +3 -3
- package/dist/providers/ModalContext/ModalContext.d.ts.map +1 -1
- package/dist/types/base.d.ts +6 -1
- package/dist/types/base.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/app/ModalManager.ts","../src/app/constant.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 { 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 } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, background, visible } from './classNames.emotion';\n\nexport const Background = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { BackgroundComponent } = useModalContext();\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 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 {BackgroundComponent && (\n <BackgroundComponent\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 />\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 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 { 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) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({ onConfirm: handleConfirm })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n confirmLabel={footer?.confirm}\n hideConfirm={footer?.hideConfirm}\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 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 { 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) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\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 />\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 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 [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) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n\n {Input && (\n <Input\n defaultValue={defaultValue}\n value={value}\n onChange={handleChange}\n onConfirm={handleConfirm}\n />\n )}\n\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n onChange: handleChange,\n value,\n disabled,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n disabled={disabled}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { cx } from '@emotion/css';\n\nimport { useModal, useModalContext } from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, foreground, visible } from './classNames.emotion';\nimport { AlertInner, ConfirmInner, PromptInner } from './components';\n\nexport const Foreground = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { ForegroundComponent } = useModalContext();\n\n const { modal, onChange, onConfirm, onClose, onDestroy } = useModal(modalId);\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 <ForegroundComponent\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 >\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 </ForegroundComponent>\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 { 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\nlet zIndex = 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 = `${zIndex++}`;\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 BaseModal,\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 #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 }: 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.#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 }: AlertNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\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 }: ConfirmNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\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 }: PromptNodeProps<T, B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\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 {\n type ComponentType,\n type PropsWithChildren,\n createContext,\n} from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport type {\n FooterComponentProps,\n ModalFrameProps,\n} from '@/promise-modal/types';\n\nexport interface ModalContextProps {\n ForegroundComponent: ComponentType<PropsWithChildren<ModalFrameProps>>;\n BackgroundComponent?: ComponentType<ModalFrameProps>;\n TitleComponent: ComponentType<PropsWithChildren>;\n SubtitleComponent: ComponentType<PropsWithChildren>;\n ContentComponent: ComponentType<PropsWithChildren>;\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, 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} from '@/promise-modal/types';\n\nimport { ModalDataContextProvider } from '../ModalDataContext';\nimport { ModalContext } from './ModalContext';\n\ninterface ModalContextProviderProps {\n BackgroundComponent?: ComponentType<ModalFrameProps>;\n ForegroundComponent?: ComponentType<ModalFrameProps>;\n TitleComponent?: ComponentType<PropsWithChildren>;\n SubtitleComponent?: ComponentType<PropsWithChildren>;\n ContentComponent?: ComponentType<PropsWithChildren>;\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 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 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 <ModalDataContextProvider pathname={pathname}>\n <Anchor />\n </ModalDataContextProvider>,\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 FooterOptions,\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}\n\nexport const alert = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\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 });\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 ConfirmContentProps,\n ConfirmFooterRender,\n FooterOptions,\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}\n\nexport const confirm = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\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 });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n FooterOptions,\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}\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}: 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: ({ defaultValue, onChange, onConfirm }: PromptInputProps<T>) =>\n Input({\n defaultValue,\n onChange,\n onConfirm,\n }),\n defaultValue,\n disabled,\n returnOnCancel,\n background,\n footer,\n manualDestroy,\n closeOnBackdropClick,\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","background","css","process","env","NODE_ENV","styles","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","active","visible","Background","modalId","onChangeOrder","BackgroundComponent","useModalContext","onClose","onChange","onConfirm","onDestroy","useModal","handleClose","useCallback","event","closeOnBackdropClick","stopPropagation","_jsx","jsx","className","cx","visible$1","manualDestroy","alive","active$1","onClick","children","type","initiator","foreground","AlertInner","memo","handlers","title","subtitle","content","footer","useMemo","handleConfirm","useHandle","TitleComponent","SubtitleComponent","ContentComponent","FooterComponent","_jsxs","Fragment","isString","renderComponent","confirmLabel","confirm","hideConfirm","ConfirmInner","onCancel","cancelLabel","cancel","hideCancel","PromptInner","Input","defaultValue","disabled","checkDisabled","withErrorBoundary","value","setValue","useState","handleChange","inputValue","input","isFunction","setTimeout","Foreground","ForegroundComponent","useSubscribeModal","tick","update","useTick","useOnMount","subscribe","presenter","zIndex","Presenter","ref","useRef","handleChangeOrder","style","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","createContext","undefinedFunction","setUpdater","getModal","undefined","ModalDataContextProvider","pathname","modalDictionary","Map","setModalIds","modalIdsRef","useReference","modalIdSequence","options","useModalOptions","useOnMountLayout","data","ids","destroyed","get","delete","useLayoutEffect","updaterRef","hideModal","updater","Provider","useContext","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,CAAOC,EAAcC,EAAS,iBAC5B,GAAIR,EAAUJ,QAAS,CACrB,MAAMU,EAASG,SAASC,eAAeV,EAAUJ,QAAQe,IACzD,GAAIL,EAAQ,OAAOA,EAErB,MAAMM,EAAOH,SAASI,cAAcN,GAIpC,OAHAK,EAAKE,aAAa,KAAM,GAAGN,KAAUO,EAAeA,gBAAC,OACrDN,SAASO,KAAKC,YAAYL,GAC1BZ,EAAUJ,QAAUgB,EACbA,CACR,GC3CUM,EAAuC,QAEvCC,EAAgC,0QCFtC,MAAMC,EAAaC,EAAAA,IAAG,eAAAC,QAAAC,IAAAC,SAAA,CAAAjB,KAAA,SAAAkB,OAAA,iGAAA,CAAAlB,KAAA,oBAAAkB,OAAA,kHAAAC,SAAAC,I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U,KACR,MAAM5L,MAAEA,EAAKwC,UAAEA,EAAS8L,aAAEA,GAAiBD,EAAUvO,QACrD,IAAKE,GAASA,EAAM+B,UAAY/B,EAAMqD,MAAO,OAC7C,MAAMkL,EAAQpI,YAAW,KACvB3D,GAAW,GACV8L,GACH,MAAO,KACDC,GAAOC,aAAaD,EAAM,CAC/B,GACA,CAAChI,GAAM,2BJlBoB,KAC9B,MAAMyF,SAAEA,GAAanB,KACrB,OAAOmB,CAAQ,2BAPe,KAC9B,MAAMpC,SAAEA,GAAaiB,KACrB,MAAO,CAAEjB,WAAU0E,aAAc9E,EAA4BI,GAAW"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/app/ModalManager.ts","../src/app/constant.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 { 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 type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, background, visible } from './classNames.emotion';\n\nexport const Background = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { BackgroundComponent } = useModalContext();\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 />\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 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 { 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) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({ onConfirm: handleConfirm })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n confirmLabel={footer?.confirm}\n hideConfirm={footer?.hideConfirm}\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 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 { 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) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\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 />\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 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 [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) ? <TitleComponent>{title}</TitleComponent> : title)}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent>{subtitle}</SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent>{content}</ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n })\n ))}\n\n {Input && (\n <Input\n defaultValue={defaultValue}\n value={value}\n onChange={handleChange}\n onConfirm={handleConfirm}\n />\n )}\n\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n onChange: handleChange,\n value,\n disabled,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n disabled={disabled}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\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 type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, foreground, visible } from './classNames.emotion';\nimport { AlertInner, ConfirmInner, PromptInner } from './components';\n\nexport const Foreground = ({ modalId, onChangeOrder }: ModalLayerProps) => {\n const { ForegroundComponent } = useModalContext();\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 >\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 { 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\nlet zIndex = 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 = `${zIndex++}`;\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 {\n type ComponentType,\n type PropsWithChildren,\n createContext,\n} from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport type {\n BackgroundComponent,\n FooterComponentProps,\n ForegroundComponent,\n} from '@/promise-modal/types';\n\nexport interface ModalContextProps {\n ForegroundComponent: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n TitleComponent: ComponentType<PropsWithChildren>;\n SubtitleComponent: ComponentType<PropsWithChildren>;\n ContentComponent: ComponentType<PropsWithChildren>;\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, 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} from '@/promise-modal/types';\n\nimport { ModalDataContextProvider } from '../ModalDataContext';\nimport { ModalContext } from './ModalContext';\n\ninterface ModalContextProviderProps {\n BackgroundComponent?: ComponentType<ModalFrameProps>;\n ForegroundComponent?: ComponentType<ModalFrameProps>;\n TitleComponent?: ComponentType<PropsWithChildren>;\n SubtitleComponent?: ComponentType<PropsWithChildren>;\n ContentComponent?: ComponentType<PropsWithChildren>;\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 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 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 <ModalDataContextProvider pathname={pathname}>\n <Anchor />\n </ModalDataContextProvider>,\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: ({ defaultValue, onChange, onConfirm }: PromptInputProps<T>) =>\n Input({\n defaultValue,\n onChange,\n onConfirm,\n }),\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","background","css","process","env","NODE_ENV","styles","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","active","visible","Background","modalId","onChangeOrder","BackgroundComponent","useModalContext","onClose","onChange","onConfirm","onDestroy","useModal","handleClose","useCallback","event","closeOnBackdropClick","stopPropagation","useMemo","_jsx","jsx","className","cx","visible$1","manualDestroy","alive","active$1","onClick","children","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","value","setValue","useState","handleChange","inputValue","input","isFunction","setTimeout","Foreground","ForegroundComponent","useSubscribeModal","tick","update","useTick","useOnMount","subscribe","presenter","zIndex","Presenter","ref","useRef","handleChangeOrder","style","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","createContext","undefinedFunction","setUpdater","getModal","undefined","ModalDataContextProvider","pathname","modalDictionary","Map","setModalIds","modalIdsRef","useReference","modalIdSequence","options","useModalOptions","useOnMountLayout","data","ids","destroyed","get","delete","useLayoutEffect","updaterRef","hideModal","updater","Provider","useContext","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,CAAOC,EAAcC,EAAS,iBAC5B,GAAIR,EAAUJ,QAAS,CACrB,MAAMU,EAASG,SAASC,eAAeV,EAAUJ,QAAQe,IACzD,GAAIL,EAAQ,OAAOA,EAErB,MAAMM,EAAOH,SAASI,cAAcN,GAIpC,OAHAK,EAAKE,aAAa,KAAM,GAAGN,KAAUO,EA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esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useCallback as
|
|
1
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useCallback as o,useMemo as t,memo as r,Fragment as i,useState as a,useRef as l,createContext as s,useLayoutEffect as c,useContext 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 y,useOnMountLayout as v}from"@winglet/react-utils";import{getRandomString as k,isString as O,isFunction as w,undefinedFunction as D}from"@winglet/common-utils";import{css as B,cx as x}from"@emotion/css";const j={current:[]},P={current:e=>{j.current.push(e)}},N={current:null},E={get prerender(){return j.current},clearPrerender(){j.current=[]},open(e){P.current(e)},setupOpen(e){P.current=e},anchor(e,n="promise-modal"){if(N.current){const e=document.getElementById(N.current.id);if(e)return e}const o=document.createElement(e);return o.setAttribute("id",`${n}-${k(36)}`),document.body.appendChild(o),N.current=o,o}},F="300ms",I="rgba(0, 0, 0, 0.5)";function S(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const V=B("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:S}),T=B("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:S}),M=B("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:S}),_=({modalId:n,onChangeOrder:r})=>{const{BackgroundComponent:i}=Fe(),{modal:a,onClose:l,onChange:s,onConfirm:c,onDestroy:d}=Ce(n),u=o((e=>{a&&a.closeOnBackdropClick&&a.visible&&l(),e.stopPropagation()}),[a,l]),p=t((()=>a?.BackgroundComponent||i),[i,a]);return a?e("div",{className:x(V,{[M]:a.manualDestroy?a.alive:a.visible,[T]:a.closeOnBackdropClick&&a.visible}),onClick:u,children:p&&e(p,{id:a.id,type:a.type,alive:a.alive,visible:a.visible,initiator:a.initiator,manualDestroy:a.manualDestroy,closeOnBackdropClick:a.closeOnBackdropClick,background:a.background,onChange:s,onConfirm:c,onClose:l,onDestroy:d,onChangeOrder:r})}):null};function z(){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 L=B("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:z}),$=B("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:z}),A=B("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:z}),W=r((({modal:o,handlers:r})=>{const{title:a,subtitle:l,content:s,footer:c}=t((()=>o),[o]),{onConfirm:d}=t((()=>r),[r]),u=f(d),{TitleComponent:p,SubtitleComponent:m,ContentComponent:h,FooterComponent:C}=Fe();return n(i,{children:[a&&(O(a)?e(p,{children:a}):a),l&&(O(l)?e(m,{children:l}):l),s&&(O(s)?e(h,{children:s}):b(s,{onConfirm:u})),!1!==c&&("function"==typeof c?c({onConfirm:u}):e(C,{onConfirm:u,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm}))]})})),Y=r((({modal:o,handlers:r})=>{const{title:a,subtitle:l,content:s,footer:c}=t((()=>o),[o]),{onConfirm:d,onClose:u}=t((()=>r),[r]),p=f(d),m=f(u),{TitleComponent:h,SubtitleComponent:C,ContentComponent:g,FooterComponent:y}=Fe();return n(i,{children:[a&&(O(a)?e(h,{children:a}):a),l&&(O(l)?e(C,{children:l}):l),s&&(O(s)?e(g,{children:s}):b(s,{onConfirm:p,onCancel:m})),!1!==c&&("function"==typeof c?c({onConfirm:p,onCancel:m}):e(y,{onConfirm:p,onCancel:m,confirmLabel:c?.confirm,cancelLabel:c?.cancel,hideConfirm:c?.hideConfirm,hideCancel:c?.hideCancel}))]})})),U=r((({modal:l,handlers:s})=>{const{Input:c,defaultValue:d,disabled:u,title:p,subtitle:m,content:C,footer:g}=t((()=>({...l,Input:r(h(l.Input))})),[l]),[y,v]=a(d),{onChange:k,onClose:D,onConfirm:B}=t((()=>s),[s]),x=f(D),j=f((e=>{const n=w(e)?e(y):e;v(n),k(n)})),P=o((()=>{setTimeout((()=>{B()}))}),[B]),N=t((()=>!!y&&!!u?.(y)),[u,y]),{TitleComponent:E,SubtitleComponent:F,ContentComponent:I,FooterComponent:S}=Fe();return n(i,{children:[p&&(O(p)?e(E,{children:p}):p),m&&(O(m)?e(F,{children:m}):m),C&&(O(C)?e(I,{children:C}):b(C,{onConfirm:P,onCancel:x})),c&&e(c,{defaultValue:d,value:y,onChange:j,onConfirm:P}),!1!==g&&("function"==typeof g?g({onConfirm:P,onCancel:x,onChange:j,value:y,disabled:N}):e(S,{onConfirm:P,onCancel:x,disabled:N,confirmLabel:g?.confirm,cancelLabel:g?.cancel,hideConfirm:g?.hideConfirm,hideCancel:g?.hideCancel}))]})})),q=({modalId:o,onChangeOrder:r})=>{const{ForegroundComponent:i}=Fe(),{modal:a,onChange:l,onConfirm:s,onClose:c,onDestroy:d}=Ce(o),u=t((()=>a?.ForegroundComponent||i),[i,a]);return a?e("div",{className:x(L,{[A]:a.manualDestroy?a.alive:a.visible,[$]:a.visible}),children:n(u,{id:a.id,type:a.type,alive:a.alive,visible:a.visible,initiator:a.initiator,manualDestroy:a.manualDestroy,closeOnBackdropClick:a.closeOnBackdropClick,background:a.background,onChange:l,onConfirm:s,onClose:c,onDestroy:d,onChangeOrder:r,children:["alert"===a.type&&e(W,{modal:a,handlers:{onConfirm:s}}),"confirm"===a.type&&e(Y,{modal:a,handlers:{onConfirm:s,onClose:c}}),"prompt"===a.type&&e(U,{modal:a,handlers:{onChange:l,onConfirm:s,onClose:c}})]})}):null},H=e=>{const[n,o]=C();return g((()=>{if(e)return e.subscribe(o)})),n},G=B("production"===process.env.NODE_ENV?{name:"13dmkf4",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden"}:{name:"yjeu12-presenter",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden;label:presenter;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}});let J=1;const K=r((({modalId:o})=>{const t=l(null),{modal:r}=Ce(o);H(r);const i=f((()=>{t.current&&(t.current.style.zIndex=""+J++)}));return n("div",{ref:t,className:G,children:[e(_,{modalId:o,onChangeOrder:i}),e(q,{modalId:o,onChangeOrder:i})]})})),Q=(e=0)=>{const{modalIds:n,getModalNode:o}=he();return t((()=>{let e=0;for(const t of n)o(t)?.visible&&e++;return e}),[o,n,e])},R=({subtype:e,title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})=>new Promise(((d,u)=>{try{E.open({type:"alert",subtype:e,resolve:()=>d(),title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})}catch(e){u(e)}})),X=({subtype:e,title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})=>new Promise(((d,u)=>{try{E.open({type:"confirm",subtype:e,resolve:e=>d(e??!1),title:n,subtitle:o,content:t,background:r,footer:i,manualDestroy:a,closeOnBackdropClick:l,ForegroundComponent:s,BackgroundComponent:c})}catch(e){u(e)}})),Z=({defaultValue:e,title:n,subtitle:o,content:t,Input:r,disabled:i,returnOnCancel:a,background:l,footer:s,manualDestroy:c,closeOnBackdropClick:d,ForegroundComponent:u,BackgroundComponent:p})=>new Promise(((m,f)=>{try{E.open({type:"prompt",resolve:e=>m(e),title:n,subtitle:o,content:t,Input:({defaultValue:e,onChange:n,onConfirm:o})=>r({defaultValue:e,onChange:n,onConfirm:o}),defaultValue:e,disabled:i,returnOnCancel:a,background:l,footer:s,manualDestroy:c,closeOnBackdropClick:d,ForegroundComponent:u,BackgroundComponent:p})}catch(e){f(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 ee(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 ne(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 te,oe,re,ie,ae;"function"==typeof SuppressedError&&SuppressedError;class se{get alive(){return ee(this,te,"f")}get visible(){return ee(this,oe,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,background:r,manualDestroy:i=!1,closeOnBackdropClick:a=!0,resolve:s}){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}),te.set(this,void 0),oe.set(this,void 0),re.set(this,void 0),ie.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.manualDestroy=i,this.closeOnBackdropClick=a,ne(this,te,!0,"f"),ne(this,oe,!0,"f"),ne(this,re,s,"f")}subscribe(e){return ee(this,ie,"f").push(e),()=>{ne(this,ie,ee(this,ie,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of ee(this,ie,"f"))e()}resolve(e){ee(this,re,"f").call(this,e)}onDestroy(){const e=!0===ee(this,te,"f");ne(this,te,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===ee(this,oe,"f");ne(this,oe,!0,"f"),e&&this.publish()}onHide(){const e=!0===ee(this,oe,"f");ne(this,oe,!1,"f"),e&&this.publish()}}te=new WeakMap,oe=new WeakMap,re=new WeakMap,ie=new WeakMap;class le extends se{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:s,background:l,manualDestroy:c,closeOnBackdropClick:d,resolve:u}){super({id:e,initiator:n,title:r,subtitle:i,background:l,manualDestroy:c,closeOnBackdropClick:d,resolve:u}),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=s}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class ce extends se{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:s,background:l,manualDestroy:c,closeOnBackdropClick:d,resolve:u}){super({id:e,initiator:n,title:r,subtitle:i,background:l,manualDestroy:c,closeOnBackdropClick:d,resolve:u}),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=s}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class de extends se{constructor({id:e,initiator:n,type:t,title:o,subtitle:r,content:i,defaultValue:a,Input:s,disabled:l,returnOnCancel:c,footer:d,background:u,manualDestroy:p,closeOnBackdropClick:m,resolve:f}){super({id:e,initiator:n,title:o,subtitle:r,background:u,manualDestroy:p,closeOnBackdropClick:m,resolve:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"Input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"returnOnCancel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),ae.set(this,void 0),this.type=t,this.content=i,this.Input=s,this.defaultValue=a,ne(this,ae,a,"f"),this.disabled=l,this.returnOnCancel=c,this.footer=d}onChange(e){ne(this,ae,e,"f")}onConfirm(){this.resolve(ee(this,ae,"f")??null)}onClose(){this.returnOnCancel?this.resolve(ee(this,ae,"f")??null):this.resolve(null)}}ae=new WeakMap;const ue=e=>{switch(e.type){case"alert":return new le(e);case"confirm":return new ce(e);case"prompt":return new de(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},pe=/^\s*(\d+)\s*(ms|s|m|h)\s*$/,me=e=>{const[,n,t]=e.match(pe)||[];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},fe=l({modalIds:[],getModalNode:D,onChange:D,onConfirm:D,onClose:D,onDestroy:D,setUpdater:D,getModal:()=>({modal:void 0,onConfirm:D,onClose:D,onChange:D,onDestroy:D})}),be=o((({pathname:n,children:o})=>{const i=s(new Map),[l,d]=a([]),u=C(l),p=s(n),m=s(0),f=Se(),b=r((()=>me(f.duration)),[f]);g((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=f;for(const t of E.prerender){const o=ue({...t,id:m.current++,initiator:p.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});i.current.set(o.id,o),d((e=>[...e,o.id]))}E.setupOpen((t=>{const o=ue({...t,id:m.current++,initiator:p.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});i.current.set(o.id,o),d((e=>[...e.filter((e=>{const n=!i.current.get(e)?.alive;return n&&i.current.delete(e),!n})),o.id]))})),E.clearPrerender()})),c((()=>{for(const e of u.current){const t=i.current.get(e);t?.alive&&(t.initiator===n?t.onShow():t.onHide())}p.current=n}),[u,n]);const h=t((e=>i.current.get(e)),[]),y=t((e=>{const n=i.current.get(e);n&&(n.onDestroy(),v.current?.())}),[]),v=s(),k=t((e=>{const n=i.current.get(e);n&&(n.onHide(),v.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),b))}),[b]),O=t(((e,n)=>{const t=i.current.get(e);t&&"prompt"===t.type&&t.onChange(n)}),[]),w=t((e=>{const n=i.current.get(e);n&&(n.onConfirm(),k(e))}),[k]),D=t((e=>{const n=i.current.get(e);n&&(n.onClose(),k(e))}),[k]),x=t((e=>({modal:h(e),onConfirm:()=>w(e),onClose:()=>D(e),onChange:n=>O(e,n),onDestroy:()=>y(e)})),[h,w,D,O,y]),j=r((()=>({modalIds:l,getModalNode:h,onChange:O,onConfirm:w,onClose:D,onDestroy:y,getModal:x,setUpdater:e=>{v.current=e}})),[l,x,h,O,w,D,y]);return e(fe.Provider,{value:j,children:o})})),he=()=>d(fe),ye=e=>{const{getModal:n}=he();return r((()=>n(e)),[e,n])},ve=x("production"===process.env.NODE_ENV?{name:"2hpasy",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out"}:{name:"lhj8co-anchor",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out;label:anchor;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),Ce=o(h((()=>{const[n,t]=y(),{modalIds:o,setUpdater:r}=he();u((()=>{r(t)}),[r,t]);const{options:i}=Ie(),a=Q(n);return e("div",{className:ve,style:{transitionDuration:i.duration,backgroundColor:a?i.backdrop:"transparent"},children:o.map((n=>e(K,{modalId:n},n)))})})));function ge(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const ke=x("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:ge}),Oe=x("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:ge}),we=({children:n})=>e("h2",{className:ke,children:n}),De=({children:n})=>e("h3",{className:ke,children:n}),xe=({children:n})=>e("div",{className:ke,children:n}),je=({confirmLabel:t,hideConfirm:o=!1,cancelLabel:r,hideCancel:i=!1,disabled:a,onConfirm:s,onCancel:l})=>n("div",{children:[!o&&e("button",{onClick:s,disabled:a,children:t||"확인"}),!i&&"function"==typeof l&&e("button",{onClick:l,children:r||"취소"})]}),Ne=p((({id:n,onChangeOrder:t,children:o},i)=>{const a=Q(),[s,l]=r((()=>{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:Oe,onClick:t,style:{marginBottom:`calc(25vh + ${s}px)`,marginLeft:`${s}px`,transform:`translate(${l}px, ${l}px)`},children:o})})),Be=()=>{const[e,n]=a(window.location.pathname);return c((()=>{let t;const o=()=>{t&&cancelAnimationFrame(t),e!==window.location.pathname?n(window.location.pathname):t=requestAnimationFrame(o)};return t=requestAnimationFrame(o),()=>{t&&cancelAnimationFrame(t)}}),[e]),{pathname:e}},Pe=l({ForegroundComponent:Ne,TitleComponent:we,SubtitleComponent:De,ContentComponent:xe,FooterComponent:je,options:{duration:I,backdrop:S,manualDestroy:!1,closeOnBackdropClick:!0}}),Ee=o((({ForegroundComponent:t,BackgroundComponent:i,TitleComponent:a,SubtitleComponent:l,ContentComponent:c,FooterComponent:d,options:u,usePathname:p,children:f})=>{const{pathname:b}=(p||Be)(),[,h]=y(),C=s(null);v((()=>(C.current=E.anchor("div"),h(),()=>{C.current&&C.current.remove()})));const g=r((()=>({BackgroundComponent:i,ForegroundComponent:t||Ne,TitleComponent:a||we,SubtitleComponent:l||De,ContentComponent:o(c||xe),FooterComponent:o(d||je),options:{duration:I,backdrop:S,closeOnBackdropClick:!0,manualDestroy:!1,...u}})),[t,i,c,d,l,a,u]);return n(Pe.Provider,{value:g,children:[f,C.current&&m(e(be,{pathname:b,children:e(Ce,{})}),C.current)]})})),Ie=()=>d(Pe),Se=()=>{const{options:e}=d(Pe);return e},Ve=()=>{const{duration:e}=Se();return{duration:e,milliseconds:me(e)}},Te=()=>{const{backdrop:e}=Se();return e},Fe=(e,n)=>{const{modal:t,onDestroy:o}=ye(e),r=H(t),i=s({modal:t,onDestroy:o,milliseconds:O(n)?me(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{Ee as ModalProvider,R as alert,X as confirm,Z as prompt,Fe as useDestroyAfter,Te as useModalBackdrop,Ve as useModalDuration,Se as useModalOptions,H as useSubscribeModal};
|
|
17
|
+
function ee(e,n,o,t){if("a"===o&&!t)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!t:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?t:"a"===o?t.call(e):t?t.value:n.get(e)}function ne(e,n,o,t,r){if("m"===t)throw new TypeError("Private method is not writable");if("a"===t&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof n?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===t?r.call(e,o):r?r.value=o:n.set(e,o),o}var oe,te,re,ie,ae;"function"==typeof SuppressedError&&SuppressedError;class le{get alive(){return ee(this,oe,"f")}get visible(){return ee(this,te,"f")}constructor({id:e,initiator:n,title:o,subtitle:t,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}),oe.set(this,void 0),te.set(this,void 0),re.set(this,void 0),ie.set(this,[]),this.id=e,this.initiator=n,this.title=o,this.subtitle=t,this.background=r,this.manualDestroy=i,this.closeOnBackdropClick=a,this.ForegroundComponent=s,this.BackgroundComponent=c,ne(this,oe,!0,"f"),ne(this,te,!0,"f"),ne(this,re,l,"f")}subscribe(e){return ee(this,ie,"f").push(e),()=>{ne(this,ie,ee(this,ie,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of ee(this,ie,"f"))e()}resolve(e){ee(this,re,"f").call(this,e)}onDestroy(){const e=!0===ee(this,oe,"f");ne(this,oe,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===ee(this,te,"f");ne(this,te,!0,"f"),e&&this.publish()}onHide(){const e=!0===ee(this,te,"f");ne(this,te,!1,"f"),e&&this.publish()}}oe=new WeakMap,te=new WeakMap,re=new WeakMap,ie=new WeakMap;class se extends le{constructor({id:e,initiator:n,type:o,subtype:t,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=o,this.subtype=t,this.content=a,this.footer=l}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class ce extends le{constructor({id:e,initiator:n,type:o,subtype:t,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=o,this.subtype=t,this.content=a,this.footer=l}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class de extends le{constructor({id:e,initiator:n,type:o,title:t,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:t,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}),ae.set(this,void 0),this.type=o,this.content=i,this.Input=l,this.defaultValue=a,ne(this,ae,a,"f"),this.disabled=s,this.returnOnCancel=c,this.footer=d}onChange(e){ne(this,ae,e,"f")}onConfirm(){this.resolve(ee(this,ae,"f")??null)}onClose(){this.returnOnCancel?this.resolve(ee(this,ae,"f")??null):this.resolve(null)}}ae=new WeakMap;const ue=e=>{switch(e.type){case"alert":return new se(e);case"confirm":return new ce(e);case"prompt":return new de(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},pe=/^\s*(\d+)\s*(ms|s|m|h)\s*$/,me=e=>{const[,n,o]=e.match(pe)||[];if(!n||!o)return 0;const t=parseInt(n);return"ms"===o?t:"s"===o?1e3*t:"m"===o?60*t*1e3:"h"===o?60*t*60*1e3:0},fe=s({modalIds:[],getModalNode:D,onChange:D,onConfirm:D,onClose:D,onDestroy:D,setUpdater:D,getModal:()=>({modal:void 0,onConfirm:D,onClose:D,onChange:D,onDestroy:D})}),be=r((({pathname:n,children:r})=>{const i=l(new Map),[s,d]=a([]),u=y(s),p=l(n),m=l(0),f=Ie(),b=t((()=>me(f.duration)),[f]);v((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=f;for(const o of E.prerender){const t=ue({...o,id:m.current++,initiator:p.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});i.current.set(t.id,t),d((e=>[...e,t.id]))}E.setupOpen((o=>{const t=ue({...o,id:m.current++,initiator:p.current,manualDestroy:void 0!==o.manualDestroy?o.manualDestroy:e,closeOnBackdropClick:void 0!==o.closeOnBackdropClick?o.closeOnBackdropClick:n});i.current.set(t.id,t),d((e=>[...e.filter((e=>{const n=!i.current.get(e)?.alive;return n&&i.current.delete(e),!n})),t.id]))})),E.clearPrerender()})),c((()=>{for(const e of u.current){const o=i.current.get(e);o?.alive&&(o.initiator===n?o.onShow():o.onHide())}p.current=n}),[u,n]);const h=o((e=>i.current.get(e)),[]),C=o((e=>{const n=i.current.get(e);n&&(n.onDestroy(),g.current?.())}),[]),g=l(),k=o((e=>{const n=i.current.get(e);n&&(n.onHide(),g.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),b))}),[b]),O=o(((e,n)=>{const o=i.current.get(e);o&&"prompt"===o.type&&o.onChange(n)}),[]),w=o((e=>{const n=i.current.get(e);n&&(n.onConfirm(),k(e))}),[k]),D=o((e=>{const n=i.current.get(e);n&&(n.onClose(),k(e))}),[k]),B=o((e=>({modal:h(e),onConfirm:()=>w(e),onClose:()=>D(e),onChange:n=>O(e,n),onDestroy:()=>C(e)})),[h,w,D,O,C]),x=t((()=>({modalIds:s,getModalNode:h,onChange:O,onConfirm:w,onClose:D,onDestroy:C,getModal:B,setUpdater:e=>{g.current=e}})),[s,B,h,O,w,D,C]);return e(fe.Provider,{value:x,children:r})})),he=()=>d(fe),Ce=e=>{const{getModal:n}=he();return t((()=>n(e)),[e,n])},ge=B("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)."}}),ye=r(h((()=>{const[n,o]=C(),{modalIds:t,setUpdater:r}=he();u((()=>{r(o)}),[r,o]);const{options:i}=Fe(),a=Q(n);return e("div",{className:ge,style:{transitionDuration:i.duration,backgroundColor:a?i.backdrop:"transparent"},children:t.map((n=>e(K,{modalId:n},n)))})})));function ve(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const ke=B("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:ve}),Oe=B("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:ve}),we=({children:n})=>e("h2",{className:ke,children:n}),De=({children:n})=>e("h3",{className:ke,children:n}),Be=({children:n})=>e("div",{className:ke,children:n}),xe=({confirmLabel:o,hideConfirm:t=!1,cancelLabel:r,hideCancel:i=!1,disabled:a,onConfirm:l,onCancel:s})=>n("div",{children:[!t&&e("button",{onClick:l,disabled:a,children:o||"확인"}),!i&&"function"==typeof s&&e("button",{onClick:s,children:r||"취소"})]}),je=p((({id:n,onChangeOrder:o,children:r},i)=>{const a=Q(),[l,s]=t((()=>{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:Oe,onClick:o,style:{marginBottom:`calc(25vh + ${l}px)`,marginLeft:`${l}px`,transform:`translate(${s}px, ${s}px)`},children:r})})),Pe=()=>{const[e,n]=a(window.location.pathname);return c((()=>{let o;const t=()=>{o&&cancelAnimationFrame(o),e!==window.location.pathname?n(window.location.pathname):o=requestAnimationFrame(t)};return o=requestAnimationFrame(t),()=>{o&&cancelAnimationFrame(o)}}),[e]),{pathname:e}},Ne=s({ForegroundComponent:je,TitleComponent:we,SubtitleComponent:De,ContentComponent:Be,FooterComponent:xe,options:{duration:F,backdrop:I,manualDestroy:!1,closeOnBackdropClick:!0}}),Ee=r((({ForegroundComponent:o,BackgroundComponent:i,TitleComponent:a,SubtitleComponent:s,ContentComponent:c,FooterComponent:d,options:u,usePathname:p,children:f})=>{const{pathname:b}=(p||Pe)(),[,h]=C(),y=l(null);g((()=>(y.current=E.anchor("div"),h(),()=>{y.current&&y.current.remove()})));const v=t((()=>({BackgroundComponent:i,ForegroundComponent:o||je,TitleComponent:a||we,SubtitleComponent:s||De,ContentComponent:r(c||Be),FooterComponent:r(d||xe),options:{duration:F,backdrop:I,closeOnBackdropClick:!0,manualDestroy:!1,...u}})),[o,i,c,d,s,a,u]);return n(Ne.Provider,{value:v,children:[f,y.current&&m(e(be,{pathname:b,children:e(ye,{})}),y.current)]})})),Fe=()=>d(Ne),Ie=()=>{const{options:e}=d(Ne);return e},Se=()=>{const{duration:e}=Ie();return{duration:e,milliseconds:me(e)}},Ve=()=>{const{backdrop:e}=Ie();return e},Te=(e,n)=>{const{modal:o,onDestroy:t}=Ce(e),r=H(o),i=l({modal:o,onDestroy:t,milliseconds:O(n)?me(n):n});u((()=>{const{modal:e,onDestroy:n,milliseconds:o}=i.current;if(!e||e.visible||!e.alive)return;const t=setTimeout((()=>{n()}),o);return()=>{t&&clearTimeout(t)}}),[r])};export{Ee as ModalProvider,R as alert,X as confirm,Z as prompt,Te as useDestroyAfter,Ve as useModalBackdrop,Se as useModalDuration,Ie as useModalOptions,H as useSubscribeModal};
|
|
18
18
|
//# sourceMappingURL=index.esm.js.map
|