@lerx/promise-modal 0.0.34 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/ModalManager.d.ts +1 -0
- package/dist/app/ModalManager.d.ts.map +1 -1
- package/dist/bootstrap/BootstrapProvider/BootstrapProvider.d.ts +11 -0
- package/dist/bootstrap/BootstrapProvider/BootstrapProvider.d.ts.map +1 -0
- package/dist/bootstrap/BootstrapProvider/index.d.ts +3 -0
- package/dist/bootstrap/BootstrapProvider/index.d.ts.map +1 -0
- package/dist/bootstrap/BootstrapProvider/type.d.ts +13 -0
- package/dist/bootstrap/BootstrapProvider/type.d.ts.map +1 -0
- package/dist/bootstrap/bootstrap.d.ts +12 -0
- package/dist/bootstrap/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap/index.d.ts +3 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/providers/ModalManagerContext/ModalManagerContextProvider.d.ts +5 -2
- package/dist/providers/ModalManagerContext/ModalManagerContextProvider.d.ts.map +1 -1
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/providers/Initializer/Initializer.d.ts +0 -12
- package/dist/providers/Initializer/Initializer.d.ts.map +0 -1
- package/dist/providers/Initializer/index.d.ts +0 -2
- package/dist/providers/Initializer/index.d.ts.map +0 -1
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/app/ModalManager.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/components/Anchor/classNames.emotion.ts","../src/components/Anchor/Anchor.tsx","../src/hooks/useDefaultPathname.ts","../src/components/FallbackComponents/classNames.emotion.ts","../src/components/FallbackComponents/FallbackTitle.tsx","../src/components/FallbackComponents/FallbackSubtitle.tsx","../src/components/FallbackComponents/FallbackContent.tsx","../src/components/FallbackComponents/FallbackFooter.tsx","../src/components/FallbackComponents/FallbackForegroundFrame.tsx","../src/providers/ConfigurationContext/ConfigurationContext.ts","../src/providers/ConfigurationContext/ConfigurationContextProvider.tsx","../src/app/constant.ts","../src/providers/ConfigurationContext/useConfigurationContext.ts","../src/core/node/ModalNode/AbstractNode.ts","../src/core/node/ModalNode/AlertNode.ts","../src/core/node/ModalNode/ConfirmNode.ts","../src/core/node/ModalNode/PromptNode.ts","../src/core/node/nodeFactory.ts","../src/providers/ModalManagerContext/ModalManagerContext.ts","../src/providers/ModalManagerContext/ModalManagerContextProvider.tsx","../src/providers/ModalManagerContext/useModalManagerContext.ts","../src/providers/UserDefinedContext/UserDefinedContext.ts","../src/providers/UserDefinedContext/UserDefinedContextProvider.tsx","../src/providers/UserDefinedContext/useUserDefinedContext.ts","../src/providers/Initializer/Initializer.tsx","../src/core/handle/alert.ts","../src/core/handle/confirm.ts","../src/core/handle/prompt.ts","../src/hooks/useDestroyAfter.ts","../src/hooks/useModalAnimation.ts"],"sourcesContent":["import { getRandomString } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { Modal } from '@/promise-modal/types';\n\nexport class ModalManager {\n static #anchor: HTMLElement | null = null;\n static anchor(options?: {\n tag?: string;\n prefix?: string;\n root?: HTMLElement;\n }): HTMLElement {\n if (ModalManager.#anchor) {\n const anchor = document.getElementById(ModalManager.#anchor.id);\n if (anchor) return anchor;\n }\n const {\n tag = 'div',\n prefix = 'promise-modal',\n root = document.body,\n } = options || {};\n const node = document.createElement(tag);\n node.setAttribute('id', `${prefix}-${getRandomString(36)}`);\n root.appendChild(node);\n ModalManager.#anchor = node;\n return node;\n }\n\n static #prerenderList: Modal[] = [];\n static get prerender() {\n return ModalManager.#prerenderList;\n }\n\n static #openHandler: Fn<[Modal], void> = (modal: Modal) =>\n ModalManager.#prerenderList.push(modal);\n static set openHandler(handler: Fn<[Modal], void>) {\n ModalManager.#openHandler = handler;\n ModalManager.#prerenderList = [];\n }\n\n static get unanchored() {\n return !ModalManager.#anchor;\n }\n\n static reset() {\n ModalManager.#anchor = null;\n ModalManager.#prerenderList = [];\n ModalManager.#openHandler = (modal: Modal) =>\n ModalManager.#prerenderList.push(modal);\n }\n\n static open(modal: Modal) {\n ModalManager.#openHandler(modal);\n }\n}\n","import { css } from '@emotion/css';\n\nexport const background = css`\n display: none;\n position: fixed;\n inset: 0;\n z-index: -999;\n pointer-events: none;\n > * {\n pointer-events: none;\n }\n`;\n\nexport const active = css`\n pointer-events: all;\n`;\n\nexport const visible = css`\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n","import { type MouseEvent, useCallback, useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport {\n useConfigurationContext,\n useModal,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, background, visible } from './classNames.emotion';\n\nexport const BackgroundFrame = ({\n modalId,\n onChangeOrder,\n}: ModalLayerProps) => {\n const { BackgroundComponent } = useConfigurationContext();\n const { context: userDefinedContext } = useUserDefinedContext();\n const { modal, onClose, onChange, onConfirm, onDestroy } = useModal(modalId);\n\n const handleClose = useCallback(\n (event: MouseEvent) => {\n if (modal && modal.closeOnBackdropClick && modal.visible) onClose();\n event.stopPropagation();\n },\n [modal, onClose],\n );\n\n const Background = useMemo(\n () => modal?.BackgroundComponent || BackgroundComponent,\n [BackgroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(background, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.closeOnBackdropClick && modal.visible,\n })}\n onClick={handleClose}\n >\n {Background && (\n <Background\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n context={userDefinedContext}\n />\n )}\n </div>\n );\n};\n","import { css } from '@emotion/css';\n\nexport const foreground = css`\n pointer-events: none;\n display: none;\n position: fixed;\n inset: 0;\n z-index: 1;\n`;\n\nexport const active = css`\n > * {\n pointer-events: all;\n }\n`;\n\nexport const visible = css`\n display: flex !important;\n justify-content: center;\n align-items: center;\n`;\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { AlertNode } from '@/promise-modal/core';\nimport {\n useConfigurationContext,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface AlertInnerProps<B> {\n modal: AlertNode<B>;\n handlers: Pick<ModalActions, 'onConfirm'>;\n}\n\nexport const AlertInner = memo(\n <B,>({ modal, handlers }: AlertInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { context: userDefinedContext } = useUserDefinedContext();\n const { onConfirm } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useConfigurationContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n confirmLabel={footer?.confirm}\n hideConfirm={footer?.hideConfirm}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { ConfirmNode } from '@/promise-modal/core';\nimport {\n useConfigurationContext,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface ConfirmInnerProps<B> {\n modal: ConfirmNode<B>;\n handlers: Pick<ModalActions, 'onConfirm' | 'onClose'>;\n}\n\nexport const ConfirmInner = memo(\n <B,>({ modal, handlers }: ConfirmInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { context: userDefinedContext } = useUserDefinedContext();\n const { onConfirm, onClose } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n const handleClose = useHandle(onClose);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useConfigurationContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useCallback, useMemo, useState } from 'react';\n\nimport { isFunction, isString } from '@winglet/common-utils';\nimport {\n renderComponent,\n useHandle,\n withErrorBoundary,\n} from '@winglet/react-utils';\n\nimport type { PromptNode } from '@/promise-modal/core';\nimport {\n useConfigurationContext,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface PromptInnerProps<T, B> {\n modal: PromptNode<T, B>;\n handlers: Pick<ModalActions, 'onChange' | 'onClose' | 'onConfirm'>;\n}\n\nexport const PromptInner = memo(\n <T, B>({ modal, handlers }: PromptInnerProps<T, B>) => {\n const {\n Input,\n defaultValue,\n disabled: checkDisabled,\n title,\n subtitle,\n content,\n footer,\n } = useMemo(\n () => ({\n ...modal,\n Input: memo(withErrorBoundary(modal.Input)),\n }),\n [modal],\n );\n\n const { context: userDefinedContext } = useUserDefinedContext();\n\n const [value, setValue] = useState<T | undefined>(defaultValue);\n\n const { onChange, onClose, onConfirm } = useMemo(\n () => handlers,\n [handlers],\n );\n\n const handleClose = useHandle(onClose);\n const handleChange = useHandle(\n (inputValue?: T | ((prevState: T | undefined) => T | undefined)) => {\n const input = isFunction(inputValue) ? inputValue(value) : inputValue;\n setValue(input);\n onChange(input);\n },\n );\n\n const handleConfirm = useCallback(() => {\n // NOTE: wait for the next tick to ensure the value is updated\n setTimeout(() => {\n onConfirm();\n });\n }, [onConfirm]);\n\n const disabled = useMemo(\n () => (value ? !!checkDisabled?.(value) : false),\n [checkDisabled, value],\n );\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useConfigurationContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ))}\n\n {Input && (\n <Input\n defaultValue={defaultValue}\n value={value}\n onChange={handleChange}\n onConfirm={handleConfirm}\n onCancel={handleClose}\n context={userDefinedContext}\n />\n )}\n\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n value,\n disabled,\n onChange: handleChange,\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n disabled={disabled}\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport {\n useConfigurationContext,\n useModal,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, foreground, visible } from './classNames.emotion';\nimport { AlertInner, ConfirmInner, PromptInner } from './components';\n\nexport const ForegroundFrame = ({\n modalId,\n onChangeOrder,\n}: ModalLayerProps) => {\n const { ForegroundComponent } = useConfigurationContext();\n const { context: userDefinedContext } = useUserDefinedContext();\n\n const { modal, onChange, onConfirm, onClose, onDestroy } = useModal(modalId);\n\n const Foreground = useMemo(\n () => modal?.ForegroundComponent || ForegroundComponent,\n [ForegroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(foreground, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.visible,\n })}\n >\n <Foreground\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n context={userDefinedContext}\n >\n {modal.type === 'alert' && (\n <AlertInner modal={modal} handlers={{ onConfirm }} />\n )}\n {modal.type === 'confirm' && (\n <ConfirmInner modal={modal} handlers={{ onConfirm, onClose }} />\n )}\n {modal.type === 'prompt' && (\n <PromptInner\n modal={modal}\n handlers={{ onChange, onConfirm, onClose }}\n />\n )}\n </Foreground>\n </div>\n );\n};\n","import { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { ModalNode } from '@/promise-modal/core';\n\nexport const useSubscribeModal = (modal?: ModalNode) => {\n const [tick, update] = useTick();\n useOnMount(() => {\n if (!modal) return;\n const unsubscribe = modal.subscribe(update);\n return unsubscribe;\n });\n return tick;\n};\n","import { css } from '@emotion/css';\n\nexport const presenter = css`\n position: fixed;\n inset: 0;\n pointer-events: none;\n overflow: hidden;\n`;\n","import { memo, useRef } from 'react';\n\nimport { counterFactory } from '@winglet/common-utils';\nimport { useHandle } from '@winglet/react-utils';\n\nimport { Background } from '@/promise-modal/components/Background';\nimport { Foreground } from '@/promise-modal/components/Foreground';\nimport { useSubscribeModal } from '@/promise-modal/hooks/useSubscribeModal';\nimport { useModal } from '@/promise-modal/providers';\nimport type { ModalIdProps } from '@/promise-modal/types';\n\nimport { presenter } from './classNames.emotion';\n\nconst { increment } = counterFactory(1);\n\nexport const Presenter = memo(({ modalId }: ModalIdProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { modal } = useModal(modalId);\n useSubscribeModal(modal);\n const handleChangeOrder = useHandle(() => {\n if (ref.current) {\n ref.current.style.zIndex = `${increment()}`;\n }\n });\n return (\n <div ref={ref} className={presenter}>\n <Background modalId={modalId} onChangeOrder={handleChangeOrder} />\n <Foreground modalId={modalId} onChangeOrder={handleChangeOrder} />\n </div>\n );\n});\n","import { useMemo } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport { useModalManagerContext } from '@/promise-modal/providers';\n\nconst defaultValidate = (modal?: ModalNode) => modal?.visible;\n\nexport const useActiveModalCount = (\n validate: Fn<[ModalNode?], boolean | undefined> = defaultValidate,\n refreshKey: string | number = 0,\n) => {\n const { modalIds, getModalNode } = useModalManagerContext();\n return useMemo(() => {\n let count = 0;\n for (const id of modalIds) {\n if (validate(getModalNode(id))) count++;\n }\n return count;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getModalNode, modalIds, refreshKey]);\n};\n","import { css } from '@emotion/css';\n\nexport const anchor = css`\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: 1000;\n transition: background-color ease-in-out;\n`;\n","import { memo, useEffect } from 'react';\n\nimport { useTick, withErrorBoundary } from '@winglet/react-utils';\n\nimport { Presenter } from '@/promise-modal/components/Presenter';\nimport type { ModalNode } from '@/promise-modal/core';\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport {\n useConfigurationOptions,\n useModalManagerContext,\n} from '@/promise-modal/providers';\n\nimport { anchor } from './classNames.emotion';\n\nconst AnchorInner = () => {\n const [refreshKey, update] = useTick();\n\n const { modalIds, setUpdater } = useModalManagerContext();\n\n useEffect(() => {\n setUpdater(update);\n }, [setUpdater, update]);\n\n const options = useConfigurationOptions();\n\n const dimmed = useActiveModalCount(validateDimmable, refreshKey);\n\n return (\n <div\n className={anchor}\n style={{\n transitionDuration: options.duration,\n backgroundColor: dimmed ? options.backdrop : 'transparent',\n }}\n >\n {modalIds.map((id) => {\n return <Presenter key={id} modalId={id} />;\n })}\n </div>\n );\n};\n\nconst validateDimmable = (modal?: ModalNode) => modal?.visible && modal.dimmed;\n\nexport const Anchor = memo(withErrorBoundary(AnchorInner));\n","import { useLayoutEffect, useState } from 'react';\n\nexport const usePathname = () => {\n const [pathname, setPathname] = useState(window.location.pathname);\n useLayoutEffect(() => {\n let requestId: number;\n const checkPathname = () => {\n if (requestId) cancelAnimationFrame(requestId);\n if (pathname !== window.location.pathname) {\n setPathname(window.location.pathname);\n } else {\n requestId = requestAnimationFrame(checkPathname);\n }\n };\n requestId = requestAnimationFrame(checkPathname);\n return () => {\n if (requestId) cancelAnimationFrame(requestId);\n };\n }, [pathname]);\n return { pathname };\n};\n","import { 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 { type ComponentType, createContext } from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport type {\n BackgroundComponent,\n FooterComponentProps,\n ForegroundComponent,\n WrapperComponentProps,\n} from '@/promise-modal/types';\n\nexport interface ConfigurationContextProps {\n ForegroundComponent: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n TitleComponent: ComponentType<WrapperComponentProps>;\n SubtitleComponent: ComponentType<WrapperComponentProps>;\n ContentComponent: ComponentType<WrapperComponentProps>;\n FooterComponent: ComponentType<FooterComponentProps>;\n options: {\n duration: Duration;\n backdrop: Color;\n manualDestroy: boolean;\n closeOnBackdropClick: boolean;\n };\n}\n\nexport const ConfigurationContext = createContext<ConfigurationContextProps>(\n {} as ConfigurationContextProps,\n);\n","import {\n type ComponentType,\n type PropsWithChildren,\n memo,\n useMemo,\n} from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport type {\n FooterComponentProps,\n ModalFrameProps,\n WrapperComponentProps,\n} from '@/promise-modal/types';\n\nimport { ConfigurationContext } from './ConfigurationContext';\n\nexport interface ConfigurationContextProviderProps {\n BackgroundComponent?: ComponentType<ModalFrameProps>;\n ForegroundComponent?: ComponentType<ModalFrameProps>;\n TitleComponent?: ComponentType<WrapperComponentProps>;\n SubtitleComponent?: ComponentType<WrapperComponentProps>;\n ContentComponent?: ComponentType<WrapperComponentProps>;\n FooterComponent?: ComponentType<FooterComponentProps>;\n options?: {\n /** Modal transition time(ms, s) */\n duration?: Duration;\n /** Modal backdrop color */\n backdrop?: Color;\n /** Whether to destroy the modal manually */\n manualDestroy?: boolean;\n /** Whether to close the modal when the backdrop is clicked */\n closeOnBackdropClick?: boolean;\n };\n}\n\nexport const ConfigurationContextProvider = memo(\n ({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n options,\n children,\n }: PropsWithChildren<ConfigurationContextProviderProps>) => {\n const value = useMemo(\n () => ({\n BackgroundComponent,\n ForegroundComponent: ForegroundComponent || FallbackForegroundFrame,\n TitleComponent: TitleComponent || FallbackTitle,\n SubtitleComponent: SubtitleComponent || FallbackSubtitle,\n ContentComponent: memo(ContentComponent || FallbackContent),\n FooterComponent: memo(FooterComponent || FallbackFooter),\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n closeOnBackdropClick: true,\n manualDestroy: false,\n ...options,\n } satisfies ConfigurationContextProviderProps['options'],\n }),\n [\n ForegroundComponent,\n BackgroundComponent,\n ContentComponent,\n FooterComponent,\n SubtitleComponent,\n TitleComponent,\n options,\n ],\n );\n return (\n <ConfigurationContext.Provider value={value}>\n {children}\n </ConfigurationContext.Provider>\n );\n },\n);\n","import type { Color, Duration } from '@aileron/types';\n\nexport const DEFAULT_ANIMATION_DURATION: Duration = '300ms';\n\nexport const DEFAULT_BACKDROP_COLOR: Color = 'rgba(0, 0, 0, 0.5)';\n","import { useContext } from 'react';\n\nimport { convertMsFromDuration } from '@winglet/common-utils';\n\nimport { ConfigurationContext } from './ConfigurationContext';\n\nexport const useConfigurationContext = () => useContext(ConfigurationContext);\n\nexport const useConfigurationOptions = () => {\n const context = useContext(ConfigurationContext);\n return context.options;\n};\n\nexport const useConfigurationDuration = () => {\n const context = useConfigurationOptions();\n return {\n duration: context.duration,\n milliseconds: convertMsFromDuration(context.duration),\n };\n};\n\nexport const useConfigurationBackdrop = () => {\n const context = useConfigurationOptions();\n return context.backdrop;\n};\n","import type { ReactNode } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type {\n BackgroundComponent,\n BaseModal,\n ForegroundComponent,\n ManagedEntity,\n ModalBackground,\n} from '@/promise-modal/types';\n\ntype AbstractNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;\n\nexport abstract class AbstractNode<T, B> {\n readonly id: number;\n readonly initiator: string;\n\n readonly title?: ReactNode;\n readonly subtitle?: ReactNode;\n readonly background?: ModalBackground<B>;\n\n readonly manualDestroy: boolean;\n readonly closeOnBackdropClick: boolean;\n readonly dimmed: boolean;\n\n readonly ForegroundComponent?: ForegroundComponent;\n readonly BackgroundComponent?: BackgroundComponent;\n\n #alive: boolean;\n get alive() {\n return this.#alive;\n }\n #visible: boolean;\n get visible() {\n return this.#visible;\n }\n\n #resolve: (result: T | null) => void;\n #listeners: Fn[] = [];\n\n constructor({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed = true,\n manualDestroy = false,\n closeOnBackdropClick = true,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AbstractNodeProps<T, B>) {\n this.id = id;\n this.initiator = initiator;\n this.title = title;\n this.subtitle = subtitle;\n this.background = background;\n\n this.dimmed = dimmed;\n this.manualDestroy = manualDestroy;\n this.closeOnBackdropClick = closeOnBackdropClick;\n\n this.ForegroundComponent = ForegroundComponent;\n this.BackgroundComponent = BackgroundComponent;\n\n this.#alive = true;\n this.#visible = true;\n this.#resolve = resolve;\n }\n\n subscribe(listener: Fn) {\n this.#listeners.push(listener);\n return () => {\n this.#listeners = this.#listeners.filter((l) => l !== listener);\n };\n }\n publish() {\n for (const listener of this.#listeners) listener();\n }\n protected resolve(result: T | null) {\n this.#resolve(result);\n }\n onDestroy() {\n const needPublish = this.#alive === true;\n this.#alive = false;\n if (this.manualDestroy && needPublish) this.publish();\n }\n onShow() {\n const needPublish = this.#visible === false;\n this.#visible = true;\n if (needPublish) this.publish();\n }\n onHide() {\n const needPublish = this.#visible === true;\n this.#visible = false;\n if (needPublish) this.publish();\n }\n abstract onClose(): void;\n abstract onConfirm(): void;\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n AlertContentProps,\n AlertFooterRender,\n AlertModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype AlertNodeProps<B> = AlertModal<B> & ManagedEntity;\n\nexport class AlertNode<B> extends AbstractNode<null, B> {\n readonly type: 'alert';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<AlertContentProps>;\n readonly footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AlertNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(null);\n }\n onConfirm() {\n this.resolve(null);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n ConfirmContentProps,\n ConfirmFooterRender,\n ConfirmModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype ConfirmNodeProps<B> = ConfirmModal<B> & ManagedEntity;\n\nexport class ConfirmNode<B> extends AbstractNode<boolean, B> {\n readonly type: 'confirm';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<ConfirmContentProps>;\n readonly footer?: ConfirmFooterRender | FooterOptions | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: ConfirmNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(false);\n }\n onConfirm() {\n this.resolve(true);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n FooterOptions,\n ManagedEntity,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n PromptModal,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype PromptNodeProps<T, B> = PromptModal<T, B> & ManagedEntity;\n\nexport class PromptNode<T, B> extends AbstractNode<T, B> {\n readonly type: 'prompt';\n readonly content?: ReactNode | ComponentType<PromptContentProps>;\n readonly defaultValue: T | undefined;\n readonly Input: (props: PromptInputProps<T>) => ReactNode;\n readonly disabled?: (value: T) => boolean;\n readonly returnOnCancel?: boolean;\n readonly footer?: PromptFooterRender<T> | FooterOptions | false;\n #value: T | undefined;\n\n constructor({\n id,\n initiator,\n type,\n title,\n subtitle,\n content,\n defaultValue,\n Input,\n disabled,\n returnOnCancel,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: PromptNodeProps<T, B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.content = content;\n this.Input = Input;\n this.defaultValue = defaultValue;\n this.#value = defaultValue;\n this.disabled = disabled;\n this.returnOnCancel = returnOnCancel;\n this.footer = footer;\n }\n\n onChange(value: T) {\n this.#value = value;\n }\n onConfirm() {\n this.resolve(this.#value ?? null);\n }\n onClose() {\n if (this.returnOnCancel) this.resolve(this.#value ?? null);\n else this.resolve(null);\n }\n}\n","import type { ManagedModal } from '@/promise-modal/types';\n\nimport { AlertNode, ConfirmNode, PromptNode } from './ModalNode';\n\nexport const nodeFactory = <T, B>(modal: ManagedModal<T, B>) => {\n switch (modal.type) {\n case 'alert':\n return new AlertNode<B>(modal);\n case 'confirm':\n return new ConfirmNode<B>(modal);\n case 'prompt':\n return new PromptNode<T, B>(modal);\n }\n // @ts-expect-error: This state is unreachable by design and should NEVER occur.\n throw new Error(`Unknown modal: ${modal.type}`, { modal });\n};\n","import { createContext } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport type { ModalActions, ModalHandlersWithId } from '@/promise-modal/types';\n\nexport interface ModalManagerContextProps extends ModalHandlersWithId {\n modalIds: ModalNode['id'][];\n getModal: Fn<[id: ModalNode['id']], ModalActions>;\n getModalNode: Fn<[id: ModalNode['id']], ModalNode | undefined>;\n setUpdater: Fn<[updater: Fn]>;\n}\n\nexport const ModalManagerContext = createContext<ModalManagerContextProps>(\n {} as ModalManagerContextProps,\n);\n","import {\n type PropsWithChildren,\n memo,\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { convertMsFromDuration } from '@winglet/common-utils';\nimport { useOnMountLayout, useReference } from '@winglet/react-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport { type ModalNode, nodeFactory } from '@/promise-modal/core';\nimport { useConfigurationOptions } from '@/promise-modal/providers';\nimport type { Modal } from '@/promise-modal/types';\n\nimport { ModalManagerContext } from './ModalManagerContext';\n\ninterface ModalManagerContextProviderProps {\n pathname: string;\n}\n\nexport const ModalManagerContextProvider = memo(\n ({\n pathname,\n children,\n }: PropsWithChildren<ModalManagerContextProviderProps>) => {\n const modalDictionary = useRef<Map<ModalNode['id'], ModalNode>>(new Map());\n\n const [modalIds, setModalIds] = useState<ModalNode['id'][]>([]);\n const modalIdsRef = useReference(modalIds);\n\n const initiator = useRef(pathname);\n const modalIdSequence = useRef(0);\n\n const options = useConfigurationOptions();\n\n const duration = useMemo(\n () => convertMsFromDuration(options.duration),\n [options],\n );\n\n useOnMountLayout(() => {\n const { manualDestroy, closeOnBackdropClick } = options;\n\n for (const data of ModalManager.prerender) {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => [...ids, modal.id]);\n }\n\n ModalManager.openHandler = (data: Modal) => {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => {\n const aliveIds = ids.filter((id) => {\n const destroyed = !modalDictionary.current.get(id)?.alive;\n if (destroyed) modalDictionary.current.delete(id);\n return !destroyed;\n });\n return [...aliveIds, modal.id];\n });\n };\n return () => {\n ModalManager.reset();\n };\n });\n\n useLayoutEffect(() => {\n for (const id of modalIdsRef.current) {\n const modal = modalDictionary.current.get(id);\n if (!modal?.alive) continue;\n if (modal.initiator === pathname) modal.onShow();\n else modal.onHide();\n }\n initiator.current = pathname;\n }, [modalIdsRef, pathname]);\n\n const getModalNode = useCallback((modalId: ModalNode['id']) => {\n return modalDictionary.current.get(modalId);\n }, []);\n\n const onDestroy = useCallback((modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onDestroy();\n updaterRef.current?.();\n }, []);\n\n const updaterRef = useRef<Fn>();\n const hideModal = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onHide();\n updaterRef.current?.();\n if (!modal.manualDestroy)\n setTimeout(() => {\n modal.onDestroy();\n }, duration);\n },\n [duration],\n );\n\n const onChange = useCallback((modalId: ModalNode['id'], value: any) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n if (modal.type === 'prompt') modal.onChange(value);\n }, []);\n\n const onConfirm = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onConfirm();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const onClose = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onClose();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const getModal = useCallback(\n (modalId: ModalNode['id']) => ({\n modal: getModalNode(modalId),\n onConfirm: () => onConfirm(modalId),\n onClose: () => onClose(modalId),\n onChange: (value: any) => onChange(modalId, value),\n onDestroy: () => onDestroy(modalId),\n }),\n [getModalNode, onConfirm, onClose, onChange, onDestroy],\n );\n\n const value = useMemo(() => {\n return {\n modalIds,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n getModal,\n setUpdater: (updater: Fn) => {\n updaterRef.current = updater;\n },\n };\n }, [\n modalIds,\n getModal,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n ]);\n\n return (\n <ModalManagerContext.Provider value={value}>\n {children}\n </ModalManagerContext.Provider>\n );\n },\n);\n","import { useContext, useMemo } from 'react';\n\nimport type { ManagedModal } from '@/promise-modal/types';\n\nimport { ModalManagerContext } from './ModalManagerContext';\n\nexport const useModalManagerContext = () => useContext(ModalManagerContext);\n\nexport const useModal = (id: ManagedModal['id']) => {\n const { getModal } = useModalManagerContext();\n return useMemo(() => getModal(id), [id, getModal]);\n};\n","import { createContext } from 'react';\n\nimport type { Dictionary } from '@aileron/types';\n\nexport interface UserDefinedContext {\n context: Dictionary;\n}\n\nexport const UserDefinedContext = createContext<UserDefinedContext>(\n {} as UserDefinedContext,\n);\n","import { PropsWithChildren, useMemo } from 'react';\n\nimport type { Dictionary } from '@aileron/types';\n\nimport { UserDefinedContext } from './UserDefinedContext';\n\ninterface UserDefinedContextProviderProps {\n /** 사용자 정의 컨텍스트 */\n context?: Dictionary;\n}\n\nexport const UserDefinedContextProvider = ({\n context,\n children,\n}: PropsWithChildren<UserDefinedContextProviderProps>) => {\n const contextValue = useMemo(() => ({ context: context || {} }), [context]);\n return (\n <UserDefinedContext.Provider value={contextValue}>\n {children}\n </UserDefinedContext.Provider>\n );\n};\n","import { useContext } from 'react';\n\nimport { UserDefinedContext } from './UserDefinedContext';\n\nexport const useUserDefinedContext = () => {\n return useContext(UserDefinedContext);\n};\n","import { Fragment, type PropsWithChildren, useRef } from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { printError } from '@winglet/common-utils';\nimport { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { Dictionary } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport { Anchor } from '@/promise-modal/components/Anchor';\nimport { usePathname as useDefaultPathname } from '@/promise-modal/hooks/useDefaultPathname';\n\nimport {\n ConfigurationContextProvider,\n type ConfigurationContextProviderProps,\n} from '../ConfigurationContext';\nimport { ModalManagerContextProvider } from '../ModalManagerContext';\nimport { UserDefinedContextProvider } from '../UserDefinedContext';\n\ninterface InitializerProps extends ConfigurationContextProviderProps {\n context?: Dictionary;\n usePathname?: () => { pathname: string };\n}\n\nexport const Initializer = ({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n options,\n context,\n usePathname,\n children,\n}: PropsWithChildren<InitializerProps>) => {\n const { pathname } = (usePathname || useDefaultPathname)();\n const [, update] = useTick();\n const portalRef = useRef<HTMLElement>(\n ModalManager.unanchored ? ModalManager.anchor() : null,\n );\n\n useOnMount(() => {\n if (portalRef.current) update();\n else\n printError(\n 'ModalProvider is already initialized',\n [\n 'ModalProvider can only be initialized once.',\n 'Nesting ModalProvider will be ignored...',\n ],\n {\n info: 'Something is wrong with the ModalProvider initialization...',\n },\n );\n return () => {\n if (portalRef.current) {\n portalRef.current.remove();\n }\n };\n });\n\n return (\n <Fragment>\n {children}\n {portalRef.current &&\n createPortal(\n <UserDefinedContextProvider context={context}>\n <ConfigurationContextProvider\n ForegroundComponent={ForegroundComponent}\n BackgroundComponent={BackgroundComponent}\n TitleComponent={TitleComponent}\n SubtitleComponent={SubtitleComponent}\n ContentComponent={ContentComponent}\n FooterComponent={FooterComponent}\n options={options}\n >\n <ModalManagerContextProvider pathname={pathname}>\n <Anchor />\n </ModalManagerContextProvider>\n </ConfigurationContextProvider>\n </UserDefinedContextProvider>,\n portalRef.current,\n )}\n </Fragment>\n );\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n AlertContentProps,\n AlertFooterRender,\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface AlertProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<AlertContentProps>;\n background?: ModalBackground<B>;\n footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const alert = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: AlertProps<B>) => {\n return new Promise<void>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'alert',\n subtype,\n resolve: () => resolve(),\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n BackgroundComponent,\n ConfirmContentProps,\n ConfirmFooterRender,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface ConfirmProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<ConfirmContentProps>;\n background?: ModalBackground<B>;\n footer?: ConfirmFooterRender | FooterOptions | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const confirm = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: ConfirmProps<B>) => {\n return new Promise<boolean>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'confirm',\n subtype,\n resolve: (result) => resolve(result ?? false),\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n} from '@/promise-modal/types';\n\ninterface PromptProps<T, B = any> {\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<PromptContentProps>;\n Input: (props: PromptInputProps<T>) => ReactNode;\n defaultValue?: T;\n disabled?: (value: T) => boolean;\n returnOnCancel?: boolean;\n background?: ModalBackground<B>;\n footer?: PromptFooterRender<T> | FooterOptions | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const prompt = <T, B = any>({\n defaultValue,\n title,\n subtitle,\n content,\n Input,\n disabled,\n returnOnCancel,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: PromptProps<T, B>) => {\n return new Promise<T>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'prompt',\n resolve: (result) => resolve(result as T),\n title,\n subtitle,\n content,\n Input,\n defaultValue,\n disabled,\n returnOnCancel,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import { useEffect, useRef } from 'react';\n\nimport { convertMsFromDuration, isString } from '@winglet/common-utils';\n\nimport type { Duration } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport { useModal } from '@/promise-modal/providers';\n\nimport { useSubscribeModal } from './useSubscribeModal';\n\nexport const useDestroyAfter = (\n modalId: ModalNode['id'],\n duration: Duration | number,\n) => {\n const { modal, onDestroy } = useModal(modalId);\n const tick = useSubscribeModal(modal);\n\n const reference = useRef({\n modal,\n onDestroy,\n milliseconds: isString(duration)\n ? convertMsFromDuration(duration)\n : duration,\n });\n\n useEffect(() => {\n const { modal, onDestroy, milliseconds } = reference.current;\n if (!modal || modal.visible || !modal.alive) return;\n const timer = setTimeout(() => {\n onDestroy();\n }, milliseconds);\n return () => {\n if (timer) clearTimeout(timer);\n };\n }, [tick]);\n};\n","import { useLayoutEffect, useRef } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\ninterface ModalAnimationHandler {\n onVisible?: Fn;\n onHidden?: Fn;\n}\n\nexport const useModalAnimation = (\n visible: boolean,\n handler: ModalAnimationHandler,\n) => {\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n useLayoutEffect(() => {\n if (!handlerRef.current) return;\n let frame: ReturnType<typeof requestAnimationFrame>;\n if (visible)\n frame = requestAnimationFrame(() => handlerRef.current.onVisible?.());\n else frame = requestAnimationFrame(() => handlerRef.current.onHidden?.());\n return () => {\n if (frame) cancelAnimationFrame(frame);\n };\n }, [visible]);\n};\n"],"names":["ModalManager","anchor","options","__classPrivateFieldGet","_a","_ModalManager_anchor","document","getElementById","id","tag","prefix","root","body","node","createElement","setAttribute","getRandomString","appendChild","__classPrivateFieldSet","prerender","_ModalManager_prerenderList","openHandler","handler","_ModalManager_openHandler","unanchored","reset","modal","push","open","call","value","background","css","process","env","NODE_ENV","name","styles","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","active","visible","BackgroundFrame","modalId","onChangeOrder","BackgroundComponent","useConfigurationContext","context","userDefinedContext","useUserDefinedContext","onClose","onChange","onConfirm","onDestroy","useModal","handleClose","useCallback","event","closeOnBackdropClick","stopPropagation","Background","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","setValue","useState","handleChange","inputValue","input","isFunction","setTimeout","ForegroundFrame","ForegroundComponent","Foreground","useSubscribeModal","tick","update","useTick","useOnMount","subscribe","presenter","increment","counterFactory","Presenter","ref","useRef","handleChangeOrder","current","style","zIndex","defaultValidate","useActiveModalCount","validate","refreshKey","modalIds","getModalNode","useModalManagerContext","count","validateDimmable","dimmed","Anchor","setUpdater","useEffect","useConfigurationOptions","transitionDuration","duration","backgroundColor","backdrop","map","usePathname","pathname","setPathname","window","location","useLayoutEffect","requestId","checkPathname","cancelAnimationFrame","requestAnimationFrame","fallback","frame","FallbackTitle","FallbackSubtitle","FallbackContent","FallbackFooter","FallbackForegroundFrame","forwardRef","activeCount","level","offset","stacked","Math","floor","marginBottom","marginLeft","transform","ConfigurationContext","createContext","ConfigurationContextProvider","Provider","useContext","AbstractNode","this","_AbstractNode_alive","_AbstractNode_visible","constructor","resolve","Object","defineProperty","set","_AbstractNode_resolve","_AbstractNode_listeners","listener","filter","l","publish","result","needPublish","onShow","onHide","AlertNode","subtype","super","ConfirmNode","PromptNode","returnOnCancel","_PromptNode_value","nodeFactory","Error","ModalManagerContext","ModalManagerContextProvider","modalDictionary","Map","setModalIds","modalIdsRef","useReference","modalIdSequence","convertMsFromDuration","useOnMountLayout","data","undefined","ids","destroyed","get","delete","updaterRef","hideModal","getModal","updater","UserDefinedContext","UserDefinedContextProvider","contextValue","useDefaultPathname","portalRef","printError","info","remove","createPortal","Promise","reject","error","reference","milliseconds","timer","clearTimeout","handlerRef","onVisible","onHidden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,GACA,CAAChI,GAAM,4BC1BqB,CAC/B5E,EACAnB,KAEA,MAAMiO,EAAaxH,EAAMA,OAACzG,GAC1BiO,EAAWtH,QAAU3G,EACrBsI,EAAAA,iBAAgB,KACd,IAAK2F,EAAWtH,QAAS,OACzB,IAAIiC,EAIJ,OAFEA,EADEzH,EACMuH,uBAAsB,IAAMuF,EAAWtH,QAAQuH,gBAC5CxF,uBAAsB,IAAMuF,EAAWtH,QAAQwH,eACrD,KACDvF,GAAOH,qBAAqBG,EAAM,CACvC,GACA,CAACzH,GAAS,2BjBHyB,IACtBwG,IACDI,kCAVuB,KACtC,MAAMtG,EAAUkG,IAChB,MAAO,CACLE,SAAUpG,EAAQoG,SAClBiG,aAAczB,EAAAA,sBAAsB5K,EAAQoG,UAC7C"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/app/ModalManager.ts","../src/core/node/ModalNode/AbstractNode.ts","../src/core/node/ModalNode/AlertNode.ts","../src/core/node/ModalNode/ConfirmNode.ts","../src/core/node/ModalNode/PromptNode.ts","../src/core/node/nodeFactory.ts","../src/providers/ModalManagerContext/ModalManagerContext.ts","../src/providers/ModalManagerContext/ModalManagerContextProvider.tsx","../src/providers/ModalManagerContext/useModalManagerContext.ts","../src/components/FallbackComponents/classNames.emotion.ts","../src/components/FallbackComponents/FallbackTitle.tsx","../src/components/FallbackComponents/FallbackSubtitle.tsx","../src/components/FallbackComponents/FallbackContent.tsx","../src/components/FallbackComponents/FallbackFooter.tsx","../src/hooks/useActiveModalCount.ts","../src/components/FallbackComponents/FallbackForegroundFrame.tsx","../src/providers/ConfigurationContext/ConfigurationContext.ts","../src/providers/ConfigurationContext/ConfigurationContextProvider.tsx","../src/app/constant.ts","../src/providers/ConfigurationContext/useConfigurationContext.ts","../src/providers/UserDefinedContext/UserDefinedContext.ts","../src/providers/UserDefinedContext/UserDefinedContextProvider.tsx","../src/providers/UserDefinedContext/useUserDefinedContext.ts","../src/components/Background/classNames.emotion.ts","../src/components/Background/Background.tsx","../src/components/Foreground/classNames.emotion.ts","../src/components/Foreground/components/AlertInner.tsx","../src/components/Foreground/components/ConfirmInner.tsx","../src/components/Foreground/components/PromptInner.tsx","../src/components/Foreground/Foreground.tsx","../src/hooks/useSubscribeModal.ts","../src/components/Presenter/classNames.emotion.ts","../src/components/Presenter/Presenter.tsx","../src/components/Anchor/classNames.emotion.ts","../src/components/Anchor/Anchor.tsx","../src/bootstrap/bootstrap.tsx","../src/hooks/useDefaultPathname.ts","../src/bootstrap/BootstrapProvider/BootstrapProvider.tsx","../src/core/handle/alert.ts","../src/core/handle/confirm.ts","../src/core/handle/prompt.ts","../src/hooks/useDestroyAfter.ts","../src/hooks/useModalAnimation.ts"],"sourcesContent":["import { getRandomString } from '@winglet/common-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { Modal } from '@/promise-modal/types';\n\nexport class ModalManager {\n static #active = false;\n static activate() {\n if (ModalManager.#active) return false;\n return (ModalManager.#active = true);\n }\n\n static #anchor: HTMLElement | null = null;\n static anchor(options?: {\n tag?: string;\n prefix?: string;\n root?: HTMLElement;\n }): HTMLElement {\n if (ModalManager.#anchor) {\n const anchor = document.getElementById(ModalManager.#anchor.id);\n if (anchor) return anchor;\n }\n const {\n tag = 'div',\n prefix = 'promise-modal',\n root = document.body,\n } = options || {};\n const node = document.createElement(tag);\n node.setAttribute('id', `${prefix}-${getRandomString(36)}`);\n root.appendChild(node);\n ModalManager.#anchor = node;\n return node;\n }\n\n static #prerenderList: Modal[] = [];\n static get prerender() {\n return ModalManager.#prerenderList;\n }\n\n static #openHandler: Fn<[Modal], void> = (modal: Modal) =>\n ModalManager.#prerenderList.push(modal);\n static set openHandler(handler: Fn<[Modal], void>) {\n ModalManager.#openHandler = handler;\n ModalManager.#prerenderList = [];\n }\n\n static get unanchored() {\n return !ModalManager.#anchor;\n }\n\n static reset() {\n ModalManager.#active = false;\n ModalManager.#anchor = null;\n ModalManager.#prerenderList = [];\n ModalManager.#openHandler = (modal: Modal) =>\n ModalManager.#prerenderList.push(modal);\n }\n\n static open(modal: Modal) {\n ModalManager.#openHandler(modal);\n }\n}\n","import type { ReactNode } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type {\n BackgroundComponent,\n BaseModal,\n ForegroundComponent,\n ManagedEntity,\n ModalBackground,\n} from '@/promise-modal/types';\n\ntype AbstractNodeProps<T, B> = BaseModal<T, B> & ManagedEntity;\n\nexport abstract class AbstractNode<T, B> {\n readonly id: number;\n readonly initiator: string;\n\n readonly title?: ReactNode;\n readonly subtitle?: ReactNode;\n readonly background?: ModalBackground<B>;\n\n readonly manualDestroy: boolean;\n readonly closeOnBackdropClick: boolean;\n readonly dimmed: boolean;\n\n readonly ForegroundComponent?: ForegroundComponent;\n readonly BackgroundComponent?: BackgroundComponent;\n\n #alive: boolean;\n get alive() {\n return this.#alive;\n }\n #visible: boolean;\n get visible() {\n return this.#visible;\n }\n\n #resolve: (result: T | null) => void;\n #listeners: Fn[] = [];\n\n constructor({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed = true,\n manualDestroy = false,\n closeOnBackdropClick = true,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AbstractNodeProps<T, B>) {\n this.id = id;\n this.initiator = initiator;\n this.title = title;\n this.subtitle = subtitle;\n this.background = background;\n\n this.dimmed = dimmed;\n this.manualDestroy = manualDestroy;\n this.closeOnBackdropClick = closeOnBackdropClick;\n\n this.ForegroundComponent = ForegroundComponent;\n this.BackgroundComponent = BackgroundComponent;\n\n this.#alive = true;\n this.#visible = true;\n this.#resolve = resolve;\n }\n\n subscribe(listener: Fn) {\n this.#listeners.push(listener);\n return () => {\n this.#listeners = this.#listeners.filter((l) => l !== listener);\n };\n }\n publish() {\n for (const listener of this.#listeners) listener();\n }\n protected resolve(result: T | null) {\n this.#resolve(result);\n }\n onDestroy() {\n const needPublish = this.#alive === true;\n this.#alive = false;\n if (this.manualDestroy && needPublish) this.publish();\n }\n onShow() {\n const needPublish = this.#visible === false;\n this.#visible = true;\n if (needPublish) this.publish();\n }\n onHide() {\n const needPublish = this.#visible === true;\n this.#visible = false;\n if (needPublish) this.publish();\n }\n abstract onClose(): void;\n abstract onConfirm(): void;\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n AlertContentProps,\n AlertFooterRender,\n AlertModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype AlertNodeProps<B> = AlertModal<B> & ManagedEntity;\n\nexport class AlertNode<B> extends AbstractNode<null, B> {\n readonly type: 'alert';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<AlertContentProps>;\n readonly footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: AlertNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(null);\n }\n onConfirm() {\n this.resolve(null);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n ConfirmContentProps,\n ConfirmFooterRender,\n ConfirmModal,\n FooterOptions,\n ManagedEntity,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype ConfirmNodeProps<B> = ConfirmModal<B> & ManagedEntity;\n\nexport class ConfirmNode<B> extends AbstractNode<boolean, B> {\n readonly type: 'confirm';\n readonly subtype?: 'info' | 'success' | 'warning' | 'error';\n readonly content?: ReactNode | ComponentType<ConfirmContentProps>;\n readonly footer?: ConfirmFooterRender | FooterOptions | false;\n\n constructor({\n id,\n initiator,\n type,\n subtype,\n title,\n subtitle,\n content,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: ConfirmNodeProps<B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.subtype = subtype;\n this.content = content;\n this.footer = footer;\n }\n onClose() {\n this.resolve(false);\n }\n onConfirm() {\n this.resolve(true);\n }\n}\n","import type { ComponentType, ReactNode } from 'react';\n\nimport type {\n FooterOptions,\n ManagedEntity,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n PromptModal,\n} from '@/promise-modal/types';\n\nimport { AbstractNode } from './AbstractNode';\n\ntype PromptNodeProps<T, B> = PromptModal<T, B> & ManagedEntity;\n\nexport class PromptNode<T, B> extends AbstractNode<T, B> {\n readonly type: 'prompt';\n readonly content?: ReactNode | ComponentType<PromptContentProps>;\n readonly defaultValue: T | undefined;\n readonly Input: (props: PromptInputProps<T>) => ReactNode;\n readonly disabled?: (value: T) => boolean;\n readonly returnOnCancel?: boolean;\n readonly footer?: PromptFooterRender<T> | FooterOptions | false;\n #value: T | undefined;\n\n constructor({\n id,\n initiator,\n type,\n title,\n subtitle,\n content,\n defaultValue,\n Input,\n disabled,\n returnOnCancel,\n footer,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n }: PromptNodeProps<T, B>) {\n super({\n id,\n initiator,\n title,\n subtitle,\n background,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n resolve,\n ForegroundComponent,\n BackgroundComponent,\n });\n this.type = type;\n this.content = content;\n this.Input = Input;\n this.defaultValue = defaultValue;\n this.#value = defaultValue;\n this.disabled = disabled;\n this.returnOnCancel = returnOnCancel;\n this.footer = footer;\n }\n\n onChange(value: T) {\n this.#value = value;\n }\n onConfirm() {\n this.resolve(this.#value ?? null);\n }\n onClose() {\n if (this.returnOnCancel) this.resolve(this.#value ?? null);\n else this.resolve(null);\n }\n}\n","import type { ManagedModal } from '@/promise-modal/types';\n\nimport { AlertNode, ConfirmNode, PromptNode } from './ModalNode';\n\nexport const nodeFactory = <T, B>(modal: ManagedModal<T, B>) => {\n switch (modal.type) {\n case 'alert':\n return new AlertNode<B>(modal);\n case 'confirm':\n return new ConfirmNode<B>(modal);\n case 'prompt':\n return new PromptNode<T, B>(modal);\n }\n // @ts-expect-error: This state is unreachable by design and should NEVER occur.\n throw new Error(`Unknown modal: ${modal.type}`, { modal });\n};\n","import { createContext } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport type { ModalActions, ModalHandlersWithId } from '@/promise-modal/types';\n\nexport interface ModalManagerContextProps extends ModalHandlersWithId {\n modalIds: ModalNode['id'][];\n getModal: Fn<[id: ModalNode['id']], ModalActions>;\n getModalNode: Fn<[id: ModalNode['id']], ModalNode | undefined>;\n setUpdater: Fn<[updater: Fn]>;\n}\n\nexport const ModalManagerContext = createContext<ModalManagerContextProps>(\n {} as ModalManagerContextProps,\n);\n","import {\n type PropsWithChildren,\n memo,\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { convertMsFromDuration } from '@winglet/common-utils';\nimport { useOnMountLayout, useReference } from '@winglet/react-utils';\n\nimport type { Fn } from '@aileron/types';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport { type ModalNode, nodeFactory } from '@/promise-modal/core';\nimport { useConfigurationOptions } from '@/promise-modal/providers';\nimport type { Modal } from '@/promise-modal/types';\n\nimport { ModalManagerContext } from './ModalManagerContext';\n\ninterface ModalManagerContextProviderProps {\n usePathname: Fn<[], { pathname: string }>;\n}\n\nexport const ModalManagerContextProvider = memo(\n ({\n usePathname,\n children,\n }: PropsWithChildren<ModalManagerContextProviderProps>) => {\n const modalDictionary = useRef<Map<ModalNode['id'], ModalNode>>(new Map());\n\n const [modalIds, setModalIds] = useState<ModalNode['id'][]>([]);\n const modalIdsRef = useReference(modalIds);\n const { pathname } = usePathname();\n\n const initiator = useRef(pathname);\n const modalIdSequence = useRef(0);\n\n const options = useConfigurationOptions();\n\n const duration = useMemo(\n () => convertMsFromDuration(options.duration),\n [options],\n );\n\n useOnMountLayout(() => {\n const { manualDestroy, closeOnBackdropClick } = options;\n\n for (const data of ModalManager.prerender) {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => [...ids, modal.id]);\n }\n\n ModalManager.openHandler = (data: Modal) => {\n const modal = nodeFactory({\n ...data,\n id: modalIdSequence.current++,\n initiator: initiator.current,\n manualDestroy:\n data.manualDestroy !== undefined\n ? data.manualDestroy\n : manualDestroy,\n closeOnBackdropClick:\n data.closeOnBackdropClick !== undefined\n ? data.closeOnBackdropClick\n : closeOnBackdropClick,\n });\n modalDictionary.current.set(modal.id, modal);\n setModalIds((ids) => {\n const aliveIds = ids.filter((id) => {\n const destroyed = !modalDictionary.current.get(id)?.alive;\n if (destroyed) modalDictionary.current.delete(id);\n return !destroyed;\n });\n return [...aliveIds, modal.id];\n });\n };\n return () => {\n ModalManager.reset();\n };\n });\n\n useLayoutEffect(() => {\n for (const id of modalIdsRef.current) {\n const modal = modalDictionary.current.get(id);\n if (!modal?.alive) continue;\n if (modal.initiator === pathname) modal.onShow();\n else modal.onHide();\n }\n initiator.current = pathname;\n }, [modalIdsRef, pathname]);\n\n const getModalNode = useCallback((modalId: ModalNode['id']) => {\n return modalDictionary.current.get(modalId);\n }, []);\n\n const onDestroy = useCallback((modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onDestroy();\n updaterRef.current?.();\n }, []);\n\n const updaterRef = useRef<Fn>();\n const hideModal = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onHide();\n updaterRef.current?.();\n if (!modal.manualDestroy)\n setTimeout(() => {\n modal.onDestroy();\n }, duration);\n },\n [duration],\n );\n\n const onChange = useCallback((modalId: ModalNode['id'], value: any) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n if (modal.type === 'prompt') modal.onChange(value);\n }, []);\n\n const onConfirm = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onConfirm();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const onClose = useCallback(\n (modalId: ModalNode['id']) => {\n const modal = modalDictionary.current.get(modalId);\n if (!modal) return;\n modal.onClose();\n hideModal(modalId);\n },\n [hideModal],\n );\n\n const getModal = useCallback(\n (modalId: ModalNode['id']) => ({\n modal: getModalNode(modalId),\n onConfirm: () => onConfirm(modalId),\n onClose: () => onClose(modalId),\n onChange: (value: any) => onChange(modalId, value),\n onDestroy: () => onDestroy(modalId),\n }),\n [getModalNode, onConfirm, onClose, onChange, onDestroy],\n );\n\n const value = useMemo(() => {\n return {\n modalIds,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n getModal,\n setUpdater: (updater: Fn) => {\n updaterRef.current = updater;\n },\n };\n }, [\n modalIds,\n getModal,\n getModalNode,\n onChange,\n onConfirm,\n onClose,\n onDestroy,\n ]);\n\n return (\n <ModalManagerContext.Provider value={value}>\n {children}\n </ModalManagerContext.Provider>\n );\n },\n);\n","import { useContext, useMemo } from 'react';\n\nimport type { ManagedModal } from '@/promise-modal/types';\n\nimport { ModalManagerContext } from './ModalManagerContext';\n\nexport const useModalManagerContext = () => useContext(ModalManagerContext);\n\nexport const useModal = (id: ManagedModal['id']) => {\n const { getModal } = useModalManagerContext();\n return useMemo(() => getModal(id), [id, getModal]);\n};\n","import { css } from '@emotion/css';\n\nexport const fallback = css`\n margin: unset;\n`;\n\nexport const frame = css`\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n background-color: white;\n padding: 20px 80px;\n gap: 10px;\n border: 1px solid black;\n`;\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackTitle = ({ children }: PropsWithChildren) => {\n return <h2 className={fallback}>{children}</h2>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackSubtitle = ({ children }: PropsWithChildren) => {\n return <h3 className={fallback}>{children}</h3>;\n};\n","import type { PropsWithChildren } from 'react';\n\nimport { fallback } from './classNames.emotion';\n\nexport const FallbackContent = ({ children }: PropsWithChildren) => {\n return <div className={fallback}>{children}</div>;\n};\n","import type { FooterComponentProps } from '@/promise-modal/types';\n\nexport const FallbackFooter = ({\n confirmLabel,\n hideConfirm = false,\n cancelLabel,\n hideCancel = false,\n disabled,\n onConfirm,\n onCancel,\n}: FooterComponentProps) => {\n return (\n <div>\n {!hideConfirm && (\n <button onClick={onConfirm} disabled={disabled}>\n {confirmLabel || '확인'}\n </button>\n )}\n\n {!hideCancel && typeof onCancel === 'function' && (\n <button onClick={onCancel}>{cancelLabel || '취소'}</button>\n )}\n </div>\n );\n};\n","import { useMemo } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport { useModalManagerContext } from '@/promise-modal/providers';\n\nconst defaultValidate = (modal?: ModalNode) => modal?.visible;\n\nexport const useActiveModalCount = (\n validate: Fn<[ModalNode?], boolean | undefined> = defaultValidate,\n refreshKey: string | number = 0,\n) => {\n const { modalIds, getModalNode } = useModalManagerContext();\n return useMemo(() => {\n let count = 0;\n for (const id of modalIds) {\n if (validate(getModalNode(id))) count++;\n }\n return count;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getModalNode, modalIds, refreshKey]);\n};\n","import {\n type ForwardedRef,\n type PropsWithChildren,\n forwardRef,\n useMemo,\n} from 'react';\n\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport type { ModalFrameProps } from '@/promise-modal/types';\n\nimport { frame } from './classNames.emotion';\n\nconst MAX_MODAL_COUNT = 5;\nconst MAX_MODAL_LEVEL = 3;\n\nexport const FallbackForegroundFrame = forwardRef(\n (\n { id, onChangeOrder, children }: PropsWithChildren<ModalFrameProps>,\n ref: ForwardedRef<HTMLDivElement>,\n ) => {\n const activeCount = useActiveModalCount();\n const [level, offset] = useMemo(() => {\n const stacked = activeCount > 1;\n const level = stacked\n ? (Math.floor(id / MAX_MODAL_COUNT) % MAX_MODAL_LEVEL) * 100\n : 0;\n const offset = stacked ? (id % MAX_MODAL_COUNT) * 35 : 0;\n return [level, offset];\n }, [activeCount, id]);\n\n return (\n <div\n ref={ref}\n className={frame}\n onClick={onChangeOrder}\n style={{\n marginBottom: `calc(25vh + ${level}px)`,\n marginLeft: `${level}px`,\n transform: `translate(${offset}px, ${offset}px)`,\n }}\n >\n {children}\n </div>\n );\n },\n);\n","import { type ComponentType, createContext } from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport type {\n BackgroundComponent,\n FooterComponentProps,\n ForegroundComponent,\n WrapperComponentProps,\n} from '@/promise-modal/types';\n\nexport interface ConfigurationContextProps {\n ForegroundComponent: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n TitleComponent: ComponentType<WrapperComponentProps>;\n SubtitleComponent: ComponentType<WrapperComponentProps>;\n ContentComponent: ComponentType<WrapperComponentProps>;\n FooterComponent: ComponentType<FooterComponentProps>;\n options: {\n duration: Duration;\n backdrop: Color;\n manualDestroy: boolean;\n closeOnBackdropClick: boolean;\n };\n}\n\nexport const ConfigurationContext = createContext<ConfigurationContextProps>(\n {} as ConfigurationContextProps,\n);\n","import {\n type ComponentType,\n type PropsWithChildren,\n memo,\n useMemo,\n} from 'react';\n\nimport type { Color, Duration } from '@aileron/types';\n\nimport {\n DEFAULT_ANIMATION_DURATION,\n DEFAULT_BACKDROP_COLOR,\n} from '@/promise-modal/app/constant';\nimport {\n FallbackContent,\n FallbackFooter,\n FallbackForegroundFrame,\n FallbackSubtitle,\n FallbackTitle,\n} from '@/promise-modal/components/FallbackComponents';\nimport type {\n FooterComponentProps,\n ModalFrameProps,\n WrapperComponentProps,\n} from '@/promise-modal/types';\n\nimport { ConfigurationContext } from './ConfigurationContext';\n\nexport interface ConfigurationContextProviderProps {\n BackgroundComponent?: ComponentType<ModalFrameProps>;\n ForegroundComponent?: ComponentType<ModalFrameProps>;\n TitleComponent?: ComponentType<WrapperComponentProps>;\n SubtitleComponent?: ComponentType<WrapperComponentProps>;\n ContentComponent?: ComponentType<WrapperComponentProps>;\n FooterComponent?: ComponentType<FooterComponentProps>;\n options?: {\n /** Modal transition time(ms, s) */\n duration?: Duration;\n /** Modal backdrop color */\n backdrop?: Color;\n /** Whether to destroy the modal manually */\n manualDestroy?: boolean;\n /** Whether to close the modal when the backdrop is clicked */\n closeOnBackdropClick?: boolean;\n };\n}\n\nexport const ConfigurationContextProvider = memo(\n ({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n options,\n children,\n }: PropsWithChildren<ConfigurationContextProviderProps>) => {\n const value = useMemo(\n () => ({\n BackgroundComponent,\n ForegroundComponent: ForegroundComponent || FallbackForegroundFrame,\n TitleComponent: TitleComponent || FallbackTitle,\n SubtitleComponent: SubtitleComponent || FallbackSubtitle,\n ContentComponent: memo(ContentComponent || FallbackContent),\n FooterComponent: memo(FooterComponent || FallbackFooter),\n options: {\n duration: DEFAULT_ANIMATION_DURATION,\n backdrop: DEFAULT_BACKDROP_COLOR,\n closeOnBackdropClick: true,\n manualDestroy: false,\n ...options,\n } satisfies ConfigurationContextProviderProps['options'],\n }),\n [\n ForegroundComponent,\n BackgroundComponent,\n ContentComponent,\n FooterComponent,\n SubtitleComponent,\n TitleComponent,\n options,\n ],\n );\n return (\n <ConfigurationContext.Provider value={value}>\n {children}\n </ConfigurationContext.Provider>\n );\n },\n);\n","import type { Color, Duration } from '@aileron/types';\n\nexport const DEFAULT_ANIMATION_DURATION: Duration = '300ms';\n\nexport const DEFAULT_BACKDROP_COLOR: Color = 'rgba(0, 0, 0, 0.5)';\n","import { useContext } from 'react';\n\nimport { convertMsFromDuration } from '@winglet/common-utils';\n\nimport { ConfigurationContext } from './ConfigurationContext';\n\nexport const useConfigurationContext = () => useContext(ConfigurationContext);\n\nexport const useConfigurationOptions = () => {\n const context = useContext(ConfigurationContext);\n return context.options;\n};\n\nexport const useConfigurationDuration = () => {\n const context = useConfigurationOptions();\n return {\n duration: context.duration,\n milliseconds: convertMsFromDuration(context.duration),\n };\n};\n\nexport const useConfigurationBackdrop = () => {\n const context = useConfigurationOptions();\n return context.backdrop;\n};\n","import { createContext } from 'react';\n\nimport type { Dictionary } from '@aileron/types';\n\nexport interface UserDefinedContext {\n context: Dictionary;\n}\n\nexport const UserDefinedContext = createContext<UserDefinedContext>(\n {} as UserDefinedContext,\n);\n","import { PropsWithChildren, useMemo } from 'react';\n\nimport type { Dictionary } from '@aileron/types';\n\nimport { UserDefinedContext } from './UserDefinedContext';\n\ninterface UserDefinedContextProviderProps {\n /** 사용자 정의 컨텍스트 */\n context?: Dictionary;\n}\n\nexport const UserDefinedContextProvider = ({\n context,\n children,\n}: PropsWithChildren<UserDefinedContextProviderProps>) => {\n const contextValue = useMemo(() => ({ context: context || {} }), [context]);\n return (\n <UserDefinedContext.Provider value={contextValue}>\n {children}\n </UserDefinedContext.Provider>\n );\n};\n","import { useContext } from 'react';\n\nimport { UserDefinedContext } from './UserDefinedContext';\n\nexport const useUserDefinedContext = () => {\n return useContext(UserDefinedContext);\n};\n","import { css } from '@emotion/css';\n\nexport const background = css`\n display: none;\n position: fixed;\n inset: 0;\n z-index: -999;\n pointer-events: none;\n > * {\n pointer-events: none;\n }\n`;\n\nexport const active = css`\n pointer-events: all;\n`;\n\nexport const visible = css`\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n","import { type MouseEvent, useCallback, useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport {\n useConfigurationContext,\n useModal,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, background, visible } from './classNames.emotion';\n\nexport const BackgroundFrame = ({\n modalId,\n onChangeOrder,\n}: ModalLayerProps) => {\n const { BackgroundComponent } = useConfigurationContext();\n const { context: userDefinedContext } = useUserDefinedContext();\n const { modal, onClose, onChange, onConfirm, onDestroy } = useModal(modalId);\n\n const handleClose = useCallback(\n (event: MouseEvent) => {\n if (modal && modal.closeOnBackdropClick && modal.visible) onClose();\n event.stopPropagation();\n },\n [modal, onClose],\n );\n\n const Background = useMemo(\n () => modal?.BackgroundComponent || BackgroundComponent,\n [BackgroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(background, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.closeOnBackdropClick && modal.visible,\n })}\n onClick={handleClose}\n >\n {Background && (\n <Background\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n context={userDefinedContext}\n />\n )}\n </div>\n );\n};\n","import { css } from '@emotion/css';\n\nexport const foreground = css`\n pointer-events: none;\n display: none;\n position: fixed;\n inset: 0;\n z-index: 1;\n`;\n\nexport const active = css`\n > * {\n pointer-events: all;\n }\n`;\n\nexport const visible = css`\n display: flex !important;\n justify-content: center;\n align-items: center;\n`;\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { AlertNode } from '@/promise-modal/core';\nimport {\n useConfigurationContext,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface AlertInnerProps<B> {\n modal: AlertNode<B>;\n handlers: Pick<ModalActions, 'onConfirm'>;\n}\n\nexport const AlertInner = memo(\n <B,>({ modal, handlers }: AlertInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { context: userDefinedContext } = useUserDefinedContext();\n const { onConfirm } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useConfigurationContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n confirmLabel={footer?.confirm}\n hideConfirm={footer?.hideConfirm}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useMemo } from 'react';\n\nimport { isString } from '@winglet/common-utils';\nimport { renderComponent, useHandle } from '@winglet/react-utils';\n\nimport type { ConfirmNode } from '@/promise-modal/core';\nimport {\n useConfigurationContext,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface ConfirmInnerProps<B> {\n modal: ConfirmNode<B>;\n handlers: Pick<ModalActions, 'onConfirm' | 'onClose'>;\n}\n\nexport const ConfirmInner = memo(\n <B,>({ modal, handlers }: ConfirmInnerProps<B>) => {\n const { title, subtitle, content, footer } = useMemo(() => modal, [modal]);\n const { context: userDefinedContext } = useUserDefinedContext();\n const { onConfirm, onClose } = useMemo(() => handlers, [handlers]);\n\n const handleConfirm = useHandle(onConfirm);\n const handleClose = useHandle(onClose);\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useConfigurationContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ))}\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { Fragment, memo, useCallback, useMemo, useState } from 'react';\n\nimport { isFunction, isString } from '@winglet/common-utils';\nimport {\n renderComponent,\n useHandle,\n withErrorBoundary,\n} from '@winglet/react-utils';\n\nimport type { PromptNode } from '@/promise-modal/core';\nimport {\n useConfigurationContext,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalActions } from '@/promise-modal/types';\n\ninterface PromptInnerProps<T, B> {\n modal: PromptNode<T, B>;\n handlers: Pick<ModalActions, 'onChange' | 'onClose' | 'onConfirm'>;\n}\n\nexport const PromptInner = memo(\n <T, B>({ modal, handlers }: PromptInnerProps<T, B>) => {\n const {\n Input,\n defaultValue,\n disabled: checkDisabled,\n title,\n subtitle,\n content,\n footer,\n } = useMemo(\n () => ({\n ...modal,\n Input: memo(withErrorBoundary(modal.Input)),\n }),\n [modal],\n );\n\n const { context: userDefinedContext } = useUserDefinedContext();\n\n const [value, setValue] = useState<T | undefined>(defaultValue);\n\n const { onChange, onClose, onConfirm } = useMemo(\n () => handlers,\n [handlers],\n );\n\n const handleClose = useHandle(onClose);\n const handleChange = useHandle(\n (inputValue?: T | ((prevState: T | undefined) => T | undefined)) => {\n const input = isFunction(inputValue) ? inputValue(value) : inputValue;\n setValue(input);\n onChange(input);\n },\n );\n\n const handleConfirm = useCallback(() => {\n // NOTE: wait for the next tick to ensure the value is updated\n setTimeout(() => {\n onConfirm();\n });\n }, [onConfirm]);\n\n const disabled = useMemo(\n () => (value ? !!checkDisabled?.(value) : false),\n [checkDisabled, value],\n );\n\n const {\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n } = useConfigurationContext();\n\n return (\n <Fragment>\n {title &&\n (isString(title) ? (\n <TitleComponent context={userDefinedContext}>\n {title}\n </TitleComponent>\n ) : (\n title\n ))}\n {subtitle &&\n (isString(subtitle) ? (\n <SubtitleComponent context={userDefinedContext}>\n {subtitle}\n </SubtitleComponent>\n ) : (\n subtitle\n ))}\n {content &&\n (isString(content) ? (\n <ContentComponent context={userDefinedContext}>\n {content}\n </ContentComponent>\n ) : (\n renderComponent(content, {\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ))}\n\n {Input && (\n <Input\n defaultValue={defaultValue}\n value={value}\n onChange={handleChange}\n onConfirm={handleConfirm}\n onCancel={handleClose}\n context={userDefinedContext}\n />\n )}\n\n {footer !== false &&\n (typeof footer === 'function' ? (\n footer({\n value,\n disabled,\n onChange: handleChange,\n onConfirm: handleConfirm,\n onCancel: handleClose,\n context: userDefinedContext,\n })\n ) : (\n <FooterComponent\n disabled={disabled}\n onConfirm={handleConfirm}\n onCancel={handleClose}\n confirmLabel={footer?.confirm}\n cancelLabel={footer?.cancel}\n hideConfirm={footer?.hideConfirm}\n hideCancel={footer?.hideCancel}\n context={userDefinedContext}\n />\n ))}\n </Fragment>\n );\n },\n);\n","import { useMemo } from 'react';\n\nimport { cx } from '@emotion/css';\n\nimport {\n useConfigurationContext,\n useModal,\n useUserDefinedContext,\n} from '@/promise-modal/providers';\nimport type { ModalLayerProps } from '@/promise-modal/types';\n\nimport { active, foreground, visible } from './classNames.emotion';\nimport { AlertInner, ConfirmInner, PromptInner } from './components';\n\nexport const ForegroundFrame = ({\n modalId,\n onChangeOrder,\n}: ModalLayerProps) => {\n const { ForegroundComponent } = useConfigurationContext();\n const { context: userDefinedContext } = useUserDefinedContext();\n\n const { modal, onChange, onConfirm, onClose, onDestroy } = useModal(modalId);\n\n const Foreground = useMemo(\n () => modal?.ForegroundComponent || ForegroundComponent,\n [ForegroundComponent, modal],\n );\n\n if (!modal) return null;\n\n return (\n <div\n className={cx(foreground, {\n [visible]: modal.manualDestroy ? modal.alive : modal.visible,\n [active]: modal.visible,\n })}\n >\n <Foreground\n id={modal.id}\n type={modal.type}\n alive={modal.alive}\n visible={modal.visible}\n initiator={modal.initiator}\n manualDestroy={modal.manualDestroy}\n closeOnBackdropClick={modal.closeOnBackdropClick}\n background={modal.background}\n onChange={onChange}\n onConfirm={onConfirm}\n onClose={onClose}\n onDestroy={onDestroy}\n onChangeOrder={onChangeOrder}\n context={userDefinedContext}\n >\n {modal.type === 'alert' && (\n <AlertInner modal={modal} handlers={{ onConfirm }} />\n )}\n {modal.type === 'confirm' && (\n <ConfirmInner modal={modal} handlers={{ onConfirm, onClose }} />\n )}\n {modal.type === 'prompt' && (\n <PromptInner\n modal={modal}\n handlers={{ onChange, onConfirm, onClose }}\n />\n )}\n </Foreground>\n </div>\n );\n};\n","import { useOnMount, useTick } from '@winglet/react-utils';\n\nimport type { ModalNode } from '@/promise-modal/core';\n\nexport const useSubscribeModal = (modal?: ModalNode) => {\n const [tick, update] = useTick();\n useOnMount(() => {\n if (!modal) return;\n const unsubscribe = modal.subscribe(update);\n return unsubscribe;\n });\n return tick;\n};\n","import { css } from '@emotion/css';\n\nexport const presenter = css`\n position: fixed;\n inset: 0;\n pointer-events: none;\n overflow: hidden;\n`;\n","import { memo, useRef } from 'react';\n\nimport { counterFactory } from '@winglet/common-utils';\nimport { useHandle } from '@winglet/react-utils';\n\nimport { Background } from '@/promise-modal/components/Background';\nimport { Foreground } from '@/promise-modal/components/Foreground';\nimport { useSubscribeModal } from '@/promise-modal/hooks/useSubscribeModal';\nimport { useModal } from '@/promise-modal/providers';\nimport type { ModalIdProps } from '@/promise-modal/types';\n\nimport { presenter } from './classNames.emotion';\n\nconst { increment } = counterFactory(1);\n\nexport const Presenter = memo(({ modalId }: ModalIdProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const { modal } = useModal(modalId);\n useSubscribeModal(modal);\n const handleChangeOrder = useHandle(() => {\n if (ref.current) {\n ref.current.style.zIndex = `${increment()}`;\n }\n });\n return (\n <div ref={ref} className={presenter}>\n <Background modalId={modalId} onChangeOrder={handleChangeOrder} />\n <Foreground modalId={modalId} onChangeOrder={handleChangeOrder} />\n </div>\n );\n});\n","import { css } from '@emotion/css';\n\nexport const anchor = css`\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: 1000;\n transition: background-color ease-in-out;\n`;\n","import { memo, useEffect } from 'react';\n\nimport { useTick, withErrorBoundary } from '@winglet/react-utils';\n\nimport { Presenter } from '@/promise-modal/components/Presenter';\nimport type { ModalNode } from '@/promise-modal/core';\nimport { useActiveModalCount } from '@/promise-modal/hooks/useActiveModalCount';\nimport {\n useConfigurationOptions,\n useModalManagerContext,\n} from '@/promise-modal/providers';\n\nimport { anchor } from './classNames.emotion';\n\nconst AnchorInner = () => {\n const [refreshKey, update] = useTick();\n\n const { modalIds, setUpdater } = useModalManagerContext();\n\n useEffect(() => {\n setUpdater(update);\n }, [setUpdater, update]);\n\n const options = useConfigurationOptions();\n\n const dimmed = useActiveModalCount(validateDimmable, refreshKey);\n\n return (\n <div\n className={anchor}\n style={{\n transitionDuration: options.duration,\n backgroundColor: dimmed ? options.backdrop : 'transparent',\n }}\n >\n {modalIds.map((id) => {\n return <Presenter key={id} modalId={id} />;\n })}\n </div>\n );\n};\n\nconst validateDimmable = (modal?: ModalNode) => modal?.visible && modal.dimmed;\n\nexport const Anchor = memo(withErrorBoundary(AnchorInner));\n","import { createPortal } from 'react-dom';\n\nimport type { Dictionary, Fn } from '@aileron/types';\n\nimport { Anchor } from '@/promise-modal/components/Anchor';\nimport {\n ConfigurationContextProvider,\n type ConfigurationContextProviderProps,\n} from '@/promise-modal/providers/ConfigurationContext';\nimport { ModalManagerContextProvider } from '@/promise-modal/providers/ModalManagerContext';\nimport { UserDefinedContextProvider } from '@/promise-modal/providers/UserDefinedContext';\n\ninterface BootstrapProps extends ConfigurationContextProviderProps {\n usePathname: Fn<[], { pathname: string }>;\n context?: Dictionary;\n anchor: HTMLElement;\n}\n\nexport const bootstrap = ({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n usePathname,\n options,\n context,\n anchor,\n}: BootstrapProps) =>\n createPortal(\n <UserDefinedContextProvider context={context}>\n <ConfigurationContextProvider\n ForegroundComponent={ForegroundComponent}\n BackgroundComponent={BackgroundComponent}\n TitleComponent={TitleComponent}\n SubtitleComponent={SubtitleComponent}\n ContentComponent={ContentComponent}\n FooterComponent={FooterComponent}\n options={options}\n >\n <ModalManagerContextProvider usePathname={usePathname}>\n <Anchor />\n </ModalManagerContextProvider>\n </ConfigurationContextProvider>\n </UserDefinedContextProvider>,\n anchor,\n );\n","import { useLayoutEffect, useState } from 'react';\n\nexport const usePathname = () => {\n const [pathname, setPathname] = useState(window.location.pathname);\n useLayoutEffect(() => {\n let requestId: number;\n const checkPathname = () => {\n if (requestId) cancelAnimationFrame(requestId);\n if (pathname !== window.location.pathname) {\n setPathname(window.location.pathname);\n } else {\n requestId = requestAnimationFrame(checkPathname);\n }\n };\n requestId = requestAnimationFrame(checkPathname);\n return () => {\n if (requestId) cancelAnimationFrame(requestId);\n };\n }, [pathname]);\n return { pathname };\n};\n","import {\n Fragment,\n type PropsWithChildren,\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react';\n\nimport { printError } from '@winglet/common-utils';\nimport { useOnMount, useTick } from '@winglet/react-utils';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport { usePathname as useDefaultPathname } from '@/promise-modal/hooks/useDefaultPathname';\n\nimport { bootstrap } from '../bootstrap';\nimport type { BootstrapProviderHandle, BootstrapProviderProps } from './type';\n\nexport const BootstrapProvider = forwardRef<\n BootstrapProviderHandle,\n PropsWithChildren<BootstrapProviderProps>\n>(\n (\n {\n usePathname: useExternalPathname,\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n options,\n context,\n children,\n },\n handleRef,\n ) => {\n const usePathname = useMemo(\n () => useExternalPathname || useDefaultPathname,\n [useExternalPathname],\n );\n const permitted = useRef(ModalManager.activate());\n const anchorRef = useRef<HTMLElement | null>(null);\n const [, update] = useTick();\n\n const handleInitialize = useCallback(\n (root?: HTMLElement) => {\n if (permitted.current) {\n anchorRef.current = ModalManager.anchor({ root });\n update();\n } else\n printError(\n 'ModalProvider is already initialized',\n [\n 'ModalProvider can only be initialized once.',\n 'Nesting ModalProvider will be ignored...',\n ],\n {\n info: 'Something is wrong with the ModalProvider initialization...',\n },\n );\n },\n [update],\n );\n\n useImperativeHandle(\n handleRef,\n () => ({\n initialize: handleInitialize,\n }),\n [handleInitialize],\n );\n\n useOnMount(() => {\n /**\n * NOTE: `handleRef` being null indicates that no `ref` was provided.\n * In this case, the `ModalProvider`(=`BootstrapProvider`) is not receiving the `ref`,\n * so it should be initialized automatically.\n */\n if (handleRef === null) handleInitialize();\n return () => {\n if (anchorRef.current) anchorRef.current.remove();\n };\n });\n\n return (\n <Fragment>\n {children}\n {anchorRef.current &&\n bootstrap({\n ForegroundComponent,\n BackgroundComponent,\n TitleComponent,\n SubtitleComponent,\n ContentComponent,\n FooterComponent,\n usePathname,\n options,\n context,\n anchor: anchorRef.current,\n })}\n </Fragment>\n );\n },\n);\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n AlertContentProps,\n AlertFooterRender,\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface AlertProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<AlertContentProps>;\n background?: ModalBackground<B>;\n footer?:\n | AlertFooterRender\n | Pick<FooterOptions, 'confirm' | 'hideConfirm'>\n | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const alert = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: AlertProps<B>) => {\n return new Promise<void>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'alert',\n subtype,\n resolve: () => resolve(),\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n BackgroundComponent,\n ConfirmContentProps,\n ConfirmFooterRender,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n} from '@/promise-modal/types';\n\ninterface ConfirmProps<B> {\n subtype?: 'info' | 'success' | 'warning' | 'error';\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<ConfirmContentProps>;\n background?: ModalBackground<B>;\n footer?: ConfirmFooterRender | FooterOptions | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const confirm = <B = any>({\n subtype,\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: ConfirmProps<B>) => {\n return new Promise<boolean>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'confirm',\n subtype,\n resolve: (result) => resolve(result ?? false),\n title,\n subtitle,\n content,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import type { ComponentType, ReactNode } from 'react';\n\nimport { ModalManager } from '@/promise-modal/app/ModalManager';\nimport type {\n BackgroundComponent,\n FooterOptions,\n ForegroundComponent,\n ModalBackground,\n PromptContentProps,\n PromptFooterRender,\n PromptInputProps,\n} from '@/promise-modal/types';\n\ninterface PromptProps<T, B = any> {\n title?: ReactNode;\n subtitle?: ReactNode;\n content?: ReactNode | ComponentType<PromptContentProps>;\n Input: (props: PromptInputProps<T>) => ReactNode;\n defaultValue?: T;\n disabled?: (value: T) => boolean;\n returnOnCancel?: boolean;\n background?: ModalBackground<B>;\n footer?: PromptFooterRender<T> | FooterOptions | false;\n dimmed?: boolean;\n manualDestroy?: boolean;\n closeOnBackdropClick?: boolean;\n ForegroundComponent?: ForegroundComponent;\n BackgroundComponent?: BackgroundComponent;\n}\n\nexport const prompt = <T, B = any>({\n defaultValue,\n title,\n subtitle,\n content,\n Input,\n disabled,\n returnOnCancel,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n}: PromptProps<T, B>) => {\n return new Promise<T>((resolve, reject) => {\n try {\n ModalManager.open({\n type: 'prompt',\n resolve: (result) => resolve(result as T),\n title,\n subtitle,\n content,\n Input,\n defaultValue,\n disabled,\n returnOnCancel,\n background,\n footer,\n dimmed,\n manualDestroy,\n closeOnBackdropClick,\n ForegroundComponent,\n BackgroundComponent,\n });\n } catch (error) {\n reject(error);\n }\n });\n};\n","import { useEffect, useRef } from 'react';\n\nimport { convertMsFromDuration, isString } from '@winglet/common-utils';\n\nimport type { Duration } from '@aileron/types';\n\nimport type { ModalNode } from '@/promise-modal/core';\nimport { useModal } from '@/promise-modal/providers';\n\nimport { useSubscribeModal } from './useSubscribeModal';\n\nexport const useDestroyAfter = (\n modalId: ModalNode['id'],\n duration: Duration | number,\n) => {\n const { modal, onDestroy } = useModal(modalId);\n const tick = useSubscribeModal(modal);\n\n const reference = useRef({\n modal,\n onDestroy,\n milliseconds: isString(duration)\n ? convertMsFromDuration(duration)\n : duration,\n });\n\n useEffect(() => {\n const { modal, onDestroy, milliseconds } = reference.current;\n if (!modal || modal.visible || !modal.alive) return;\n const timer = setTimeout(() => {\n onDestroy();\n }, milliseconds);\n return () => {\n if (timer) clearTimeout(timer);\n };\n }, [tick]);\n};\n","import { useLayoutEffect, useRef } from 'react';\n\nimport type { Fn } from '@aileron/types';\n\ninterface ModalAnimationHandler {\n onVisible?: Fn;\n onHidden?: Fn;\n}\n\nexport const useModalAnimation = (\n visible: boolean,\n handler: ModalAnimationHandler,\n) => {\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n useLayoutEffect(() => {\n if (!handlerRef.current) return;\n let frame: ReturnType<typeof requestAnimationFrame>;\n if (visible)\n frame = requestAnimationFrame(() => handlerRef.current.onVisible?.());\n else frame = requestAnimationFrame(() => handlerRef.current.onHidden?.());\n return () => {\n if (frame) cancelAnimationFrame(frame);\n };\n }, [visible]);\n};\n"],"names":["ModalManager","activate","__classPrivateFieldGet","_a","_ModalManager_active","__classPrivateFieldSet","anchor","options","_ModalManager_anchor","document","getElementById","id","tag","prefix","root","body","node","createElement","setAttribute","getRandomString","appendChild","prerender","_ModalManager_prerenderList","openHandler","handler","_ModalManager_openHandler","unanchored","reset","modal","push","open","call","value","AbstractNode","alive","this","_AbstractNode_alive","visible","_AbstractNode_visible","constructor","initiator","title","subtitle","background","dimmed","manualDestroy","closeOnBackdropClick","resolve","ForegroundComponent","BackgroundComponent","Object","defineProperty","set","_AbstractNode_resolve","_AbstractNode_listeners","subscribe","listener","filter","l","publish","result","onDestroy","needPublish","onShow","onHide","AlertNode","type","subtype","content","footer","super","onClose","onConfirm","ConfirmNode","PromptNode","defaultValue","Input","disabled","returnOnCancel","_PromptNode_value","onChange","nodeFactory","Error","ModalManagerContext","createContext","ModalManagerContextProvider","memo","usePathname","children","modalDictionary","useRef","Map","modalIds","setModalIds","useState","modalIdsRef","useReference","pathname","modalIdSequence","useConfigurationOptions","duration","useMemo","convertMsFromDuration","useOnMountLayout","data","current","undefined","ids","destroyed","get","delete","useLayoutEffect","getModalNode","useCallback","modalId","updaterRef","hideModal","setTimeout","getModal","setUpdater","updater","_jsx","jsx","Provider","useModalManagerContext","useContext","useModal","fallback","css","process","env","NODE_ENV","name","styles","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","frame","FallbackTitle","className","FallbackSubtitle","FallbackContent","FallbackFooter","confirmLabel","hideConfirm","cancelLabel","hideCancel","onCancel","_jsxs","onClick","defaultValidate","useActiveModalCount","validate","refreshKey","count","FallbackForegroundFrame","forwardRef","onChangeOrder","ref","activeCount","level","offset","stacked","Math","floor","style","marginBottom","marginLeft","transform","ConfigurationContext","ConfigurationContextProvider","TitleComponent","SubtitleComponent","ContentComponent","FooterComponent","backdrop","useConfigurationContext","UserDefinedContext","UserDefinedContextProvider","context","contextValue","useUserDefinedContext","active","BackgroundFrame","userDefinedContext","handleClose","event","stopPropagation","Background","cx","visible$1","active$1","foreground","AlertInner","handlers","handleConfirm","useHandle","Fragment","isString","renderComponent","confirm","ConfirmInner","cancel","PromptInner","checkDisabled","withErrorBoundary","setValue","handleChange","inputValue","input","isFunction","ForegroundFrame","Foreground","useSubscribeModal","tick","update","useTick","useOnMount","presenter","increment","counterFactory","Presenter","handleChangeOrder","zIndex","validateDimmable","Anchor","useEffect","transitionDuration","backgroundColor","map","bootstrap","createPortal","setPathname","window","location","requestId","checkPathname","cancelAnimationFrame","requestAnimationFrame","BootstrapProvider","useExternalPathname","handleRef","useDefaultPathname","permitted","anchorRef","handleInitialize","printError","info","useImperativeHandle","initialize","remove","Promise","reject","error","reference","milliseconds","timer","clearTimeout","handlerRef","onVisible","onHidden"],"mappings":";;;;;;;;;;;;;;;;4sBAMaA,EAEX,eAAOC,GACL,OAAIC,EAAAC,EAAoBA,EAAA,IAAAC,IAChBC,EAAAF,KAAuB,EAAI,IAAAC,GAIrC,aAAOE,CAAOC,GAKZ,GAAIL,EAAAC,EAAoBA,EAAA,IAAAK,GAAE,CACxB,MAAMF,EAASG,SAASC,eAAeR,EAAAC,EAAoBA,EAAA,IAAAK,GAACG,IAC5D,GAAIL,EAAQ,OAAOA,EAErB,MAAMM,IACJA,EAAM,MAAKC,OACXA,EAAS,gBAAeC,KACxBA,EAAOL,SAASM,MACdR,GAAW,CAAE,EACXS,EAAOP,SAASQ,cAAcL,GAIpC,OAHAI,EAAKE,aAAa,KAAM,GAAGL,KAAUM,EAAeA,gBAAC,OACrDL,EAAKM,YAAYJ,GACjBX,EAAAF,EAAYA,EAAWa,EAAI,IAAAR,GACpBQ,EAIT,oBAAWK,GACT,OAAOnB,EAAAC,EAAYA,EAAA,IAAAmB,GAKrB,sBAAWC,CAAYC,GACrBnB,EAAAF,EAAYA,EAAgBqB,EAAO,IAAAC,GACnCpB,EAAAF,EAAYA,EAAkB,GAAE,IAAAmB,GAGlC,qBAAWI,GACT,OAAQxB,EAAAC,EAAYA,EAAA,IAAAK,G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AMA,OAAClE,GAC1ByO,EAAWxJ,QAAUjF,EACrBuF,EAAAA,iBAAgB,KACd,IAAKkJ,EAAWxJ,QAAS,OACzB,IAAI+B,EAIJ,OAFEA,EADEnG,EACMwM,uBAAsB,IAAMoB,EAAWxJ,QAAQyJ,gBAC5CrB,uBAAsB,IAAMoB,EAAWxJ,QAAQ0J,eACrD,KACD3H,GAAOoG,qBAAqBpG,EAAM,CACvC,GACA,CAACnG,GAAS,2BvBHyB,IACtB8D,IACD2E,kCAVuB,KACtC,MAAMI,EAAU/E,IAChB,MAAO,CACLC,SAAU8E,EAAQ9E,SAClB0J,aAAcxJ,EAAAA,sBAAsB4E,EAAQ9E,UAC7C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { useConfigurationOptions as useModalOptions, useConfigurationDuration as useModalDuration, useConfigurationBackdrop as useModalBackdrop, } from './providers';
|
|
2
|
+
export { bootstrap, BootstrapProvider as ModalProvider, type BootstrapProviderHandle as ModalProviderHandle, type BootstrapProviderProps as ModalProviderProps, } from './bootstrap';
|
|
2
3
|
export { useSubscribeModal } from './hooks/useSubscribeModal';
|
|
3
4
|
export { useDestroyAfter } from './hooks/useDestroyAfter';
|
|
4
5
|
export { useActiveModalCount } from './hooks/useActiveModalCount';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,IAAI,eAAe,EAC1C,wBAAwB,IAAI,gBAAgB,EAC5C,wBAAwB,IAAI,gBAAgB,GAC7C,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,SAAS,EACT,iBAAiB,IAAI,aAAa,EAClC,KAAK,uBAAuB,IAAI,mBAAmB,EACnD,KAAK,sBAAsB,IAAI,kBAAkB,GAClD,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{
|
|
1
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{createContext as t,memo as o,useRef as r,useState as i,useMemo as a,useLayoutEffect as l,useCallback as s,useContext as c,forwardRef as d,Fragment as u,useEffect as m,useImperativeHandle as p}from"react";import{getRandomString as f,convertMsFromDuration as b,isString as h,isFunction as C,counterFactory as g,printError as v}from"@winglet/common-utils";import{useReference as y,useOnMountLayout as k,useHandle as w,renderComponent as x,withErrorBoundary as O,useTick as B,useOnMount as D}from"@winglet/react-utils";import{css as j,cx as P}from"@emotion/css";import{createPortal as F}from"react-dom";
|
|
2
2
|
/******************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -13,5 +13,5 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */function N(e,n,t,o){if("a"===t&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!o:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?o:"a"===t?o.call(e):o?o.value:n.get(e)}function F(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 E,I,S,M;"function"==typeof SuppressedError&&SuppressedError;class V{static anchor(e){if(N(E,E,"f",I)){const e=document.getElementById(N(E,E,"f",I).id);if(e)return e}const{tag:n="div",prefix:t="promise-modal",root:o=document.body}=e||{},r=document.createElement(n);return r.setAttribute("id",`${t}-${f(36)}`),o.appendChild(r),F(E,E,r,"f",I),r}static get prerender(){return N(E,E,"f",S)}static set openHandler(e){F(E,E,e,"f",M),F(E,E,[],"f",S)}static get unanchored(){return!N(E,E,"f",I)}static reset(){F(E,E,null,"f",I),F(E,E,[],"f",S),F(E,E,(e=>N(E,E,"f",S).push(e)),"f",M)}static open(e){N(E,E,"f",M).call(E,e)}}function T(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}E=V,I={value:null},S={value:[]},M={value:e=>N(E,E,"f",S).push(e)};const z=j("production"===process.env.NODE_ENV?{name:"u7uu4v",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;}"}:{name:"coymdj-background",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;};label:background;",toString:T}),_=j("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:T}),A=j("production"===process.env.NODE_ENV?{name:"1wnowod",styles:"display:flex;align-items:center;justify-content:center"}:{name:"xppew7-visible",styles:"display:flex;align-items:center;justify-content:center;label:visible;",toString:T}),L=({modalId:n,onChangeOrder:r})=>{const{BackgroundComponent:i}=be(),{context:a}=_e(),{modal:l,onClose:s,onChange:c,onConfirm:d,onDestroy:u}=Ve(n),m=t((e=>{l&&l.closeOnBackdropClick&&l.visible&&s(),e.stopPropagation()}),[l,s]),p=o((()=>l?.BackgroundComponent||i),[i,l]);return l?e("div",{className:P(z,{[A]:l.manualDestroy?l.alive:l.visible,[_]:l.closeOnBackdropClick&&l.visible}),onClick:m,children:p&&e(p,{id:l.id,type:l.type,alive:l.alive,visible:l.visible,initiator:l.initiator,manualDestroy:l.manualDestroy,closeOnBackdropClick:l.closeOnBackdropClick,background:l.background,onChange:c,onConfirm:d,onClose:s,onDestroy:u,onChangeOrder:r,context:a})}):null};function $(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const H=j("production"===process.env.NODE_ENV?{name:"12g0hx0",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1"}:{name:"1hcczik-foreground",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1;label:foreground;",toString:$}),q=j("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:$}),W=j("production"===process.env.NODE_ENV?{name:"1fmljv2",styles:"display:flex!important;justify-content:center;align-items:center"}:{name:"1p4unab-visible",styles:"display:flex!important;justify-content:center;align-items:center;label:visible;",toString:$}),Y=r((({modal:t,handlers:r})=>{const{title:a,subtitle:l,content:s,footer:c}=o((()=>t),[t]),{context:d}=_e(),{onConfirm:u}=o((()=>r),[r]),m=y(u),{TitleComponent:p,SubtitleComponent:f,ContentComponent:h,FooterComponent:C}=be();return n(i,{children:[a&&(b(a)?e(p,{context:d,children:a}):a),l&&(b(l)?e(f,{context:d,children:l}):l),s&&(b(s)?e(h,{context:d,children:s}):k(s,{onConfirm:m})),!1!==c&&("function"==typeof c?c({onConfirm:m,context:d}):e(C,{onConfirm:m,confirmLabel:c?.confirm,hideConfirm:c?.hideConfirm,context:d}))]})})),U=r((({modal:t,handlers:r})=>{const{title:a,subtitle:l,content:s,footer:c}=o((()=>t),[t]),{context:d}=_e(),{onConfirm:u,onClose:m}=o((()=>r),[r]),p=y(u),f=y(m),{TitleComponent:h,SubtitleComponent:C,ContentComponent:g,FooterComponent:v}=be();return n(i,{children:[a&&(b(a)?e(h,{context:d,children:a}):a),l&&(b(l)?e(C,{context:d,children:l}):l),s&&(b(s)?e(g,{context:d,children:s}):k(s,{onConfirm:p,onCancel:f,context:d})),!1!==c&&("function"==typeof c?c({onConfirm:p,onCancel:f,context:d}):e(v,{onConfirm:p,onCancel:f,confirmLabel:c?.confirm,cancelLabel:c?.cancel,hideConfirm:c?.hideConfirm,hideCancel:c?.hideCancel,context:d}))]})})),G=r((({modal:l,handlers:s})=>{const{Input:c,defaultValue:d,disabled:u,title:m,subtitle:p,content:f,footer:C}=o((()=>({...l,Input:r(w(l.Input))})),[l]),{context:g}=_e(),[v,O]=a(d),{onChange:x,onClose:D,onConfirm:B}=o((()=>s),[s]),j=y(D),P=y((e=>{const n=h(e)?e(v):e;O(n),x(n)})),N=t((()=>{setTimeout((()=>{B()}))}),[B]),F=o((()=>!!v&&!!u?.(v)),[u,v]),{TitleComponent:E,SubtitleComponent:I,ContentComponent:S,FooterComponent:M}=be();return n(i,{children:[m&&(b(m)?e(E,{context:g,children:m}):m),p&&(b(p)?e(I,{context:g,children:p}):p),f&&(b(f)?e(S,{context:g,children:f}):k(f,{onConfirm:N,onCancel:j,context:g})),c&&e(c,{defaultValue:d,value:v,onChange:P,onConfirm:N,onCancel:j,context:g}),!1!==C&&("function"==typeof C?C({value:v,disabled:F,onChange:P,onConfirm:N,onCancel:j,context:g}):e(M,{disabled:F,onConfirm:N,onCancel:j,confirmLabel:C?.confirm,cancelLabel:C?.cancel,hideConfirm:C?.hideConfirm,hideCancel:C?.hideCancel,context:g}))]})})),J=({modalId:t,onChangeOrder:r})=>{const{ForegroundComponent:i}=be(),{context:a}=_e(),{modal:l,onChange:s,onConfirm:c,onClose:d,onDestroy:u}=Ve(t),m=o((()=>l?.ForegroundComponent||i),[i,l]);return l?e("div",{className:P(H,{[W]:l.manualDestroy?l.alive:l.visible,[q]:l.visible}),children:n(m,{id:l.id,type:l.type,alive:l.alive,visible:l.visible,initiator:l.initiator,manualDestroy:l.manualDestroy,closeOnBackdropClick:l.closeOnBackdropClick,background:l.background,onChange:s,onConfirm:c,onClose:d,onDestroy:u,onChangeOrder:r,context:a,children:["alert"===l.type&&e(Y,{modal:l,handlers:{onConfirm:c}}),"confirm"===l.type&&e(U,{modal:l,handlers:{onConfirm:c,onClose:d}}),"prompt"===l.type&&e(G,{modal:l,handlers:{onChange:s,onConfirm:c,onClose:d}})]})}):null},K=e=>{const[n,t]=O();return x((()=>{if(e)return e.subscribe(t)})),n},Q=j("production"===process.env.NODE_ENV?{name:"13dmkf4",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden"}:{name:"yjeu12-presenter",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden;label:presenter;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),{increment:R}=C(1),X=r((({modalId:t})=>{const o=l(null),{modal:r}=Ve(t);K(r);const i=y((()=>{o.current&&(o.current.style.zIndex=`${R()}`)}));return n("div",{ref:o,className:Q,children:[e(L,{modalId:t,onChangeOrder:i}),e(J,{modalId:t,onChangeOrder:i})]})})),Z=e=>e?.visible,ee=(e=Z,n=0)=>{const{modalIds:t,getModalNode:r}=Me();return o((()=>{let n=0;for(const o of t)e(r(o))&&n++;return n}),[r,t,n])},ne=j("production"===process.env.NODE_ENV?{name:"2hpasy",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out"}:{name:"lhj8co-anchor",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out;label:anchor;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),te=e=>e?.visible&&e.dimmed,oe=r(w((()=>{const[n,t]=O(),{modalIds:o,setUpdater:r}=Me();s((()=>{r(t)}),[r,t]);const i=he(),a=ee(te,n);return e("div",{className:ne,style:{transitionDuration:i.duration,backgroundColor:a?i.backdrop:"transparent"},children:o.map((n=>e(X,{modalId:n},n)))})}))),re=()=>{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}};function ie(){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 ae=j("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:ie}),le=j("production"===process.env.NODE_ENV?{name:"1kuk3a3",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black"}:{name:"16dbbea-frame",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black;label:frame;",toString:ie}),se=({children:n})=>e("h2",{className:ae,children:n}),ce=({children:n})=>e("h3",{className:ae,children:n}),de=({children:n})=>e("div",{className:ae,children:n}),ue=({confirmLabel:t,hideConfirm:o=!1,cancelLabel:r,hideCancel:i=!1,disabled:a,onConfirm:l,onCancel:s})=>n("div",{children:[!o&&e("button",{onClick:l,disabled:a,children:t||"확인"}),!i&&"function"==typeof s&&e("button",{onClick:s,children:r||"취소"})]}),me=d((({id:n,onChangeOrder:t,children:r},i)=>{const a=ee(),[l,s]=o((()=>{const e=a>1;return[e?Math.floor(n/5)%3*100:0,e?n%5*35:0]}),[a,n]);return e("div",{ref:i,className:le,onClick:t,style:{marginBottom:`calc(25vh + ${l}px)`,marginLeft:`${l}px`,transform:`translate(${s}px, ${s}px)`},children:r})})),pe=u({}),fe=r((({ForegroundComponent:n,BackgroundComponent:t,TitleComponent:i,SubtitleComponent:a,ContentComponent:l,FooterComponent:s,options:c,children:d})=>{const u=o((()=>({BackgroundComponent:t,ForegroundComponent:n||me,TitleComponent:i||se,SubtitleComponent:a||ce,ContentComponent:r(l||de),FooterComponent:r(s||ue),options:{duration:"300ms",backdrop:"rgba(0, 0, 0, 0.5)",closeOnBackdropClick:!0,manualDestroy:!1,...c}})),[n,t,l,s,a,i,c]);return e(pe.Provider,{value:u,children:d})})),be=()=>m(pe),he=()=>m(pe).options,Ce=()=>{const e=he();return{duration:e.duration,milliseconds:g(e.duration)}},ge=()=>he().backdrop,ve=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})=>new Promise(((u,m)=>{try{V.open({type:"alert",subtype:e,resolve:()=>u(),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})}catch(e){m(e)}})),ye=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})=>new Promise(((u,m)=>{try{V.open({type:"confirm",subtype:e,resolve:e=>u(e??!1),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})}catch(e){m(e)}})),ke=({defaultValue:e,title:n,subtitle:t,content:o,Input:r,disabled:i,returnOnCancel:a,background:l,footer:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,ForegroundComponent:m,BackgroundComponent:p})=>new Promise(((f,b)=>{try{V.open({type:"prompt",resolve:e=>f(e),title:n,subtitle:t,content:o,Input:r,defaultValue:e,disabled:i,returnOnCancel:a,background:l,footer:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,ForegroundComponent:m,BackgroundComponent:p})}catch(e){b(e)}}));var we,Oe,xe,De,Be;class je{get alive(){return N(this,we,"f")}get visible(){return N(this,Oe,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,background:r,dimmed:i=!0,manualDestroy:a=!1,closeOnBackdropClick:l=!0,resolve:s,ForegroundComponent:c,BackgroundComponent:d}){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"initiator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"title",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtitle",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"background",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualDestroy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"closeOnBackdropClick",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dimmed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ForegroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BackgroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),we.set(this,void 0),Oe.set(this,void 0),xe.set(this,void 0),De.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.dimmed=i,this.manualDestroy=a,this.closeOnBackdropClick=l,this.ForegroundComponent=c,this.BackgroundComponent=d,F(this,we,!0,"f"),F(this,Oe,!0,"f"),F(this,xe,s,"f")}subscribe(e){return N(this,De,"f").push(e),()=>{F(this,De,N(this,De,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of N(this,De,"f"))e()}resolve(e){N(this,xe,"f").call(this,e)}onDestroy(){const e=!0===N(this,we,"f");F(this,we,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===N(this,Oe,"f");F(this,Oe,!0,"f"),e&&this.publish()}onHide(){const e=!0===N(this,Oe,"f");F(this,Oe,!1,"f"),e&&this.publish()}}we=new WeakMap,Oe=new WeakMap,xe=new WeakMap,De=new WeakMap;class Pe extends je{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:l,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=a,this.footer=l}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class Ne extends je{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:l,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=a,this.footer=l}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class Fe extends je{constructor({id:e,initiator:n,type:t,title:o,subtitle:r,content:i,defaultValue:a,Input:l,disabled:s,returnOnCancel:c,footer:d,background:u,dimmed:m,manualDestroy:p,closeOnBackdropClick:f,resolve:b,ForegroundComponent:h,BackgroundComponent:C}){super({id:e,initiator:n,title:o,subtitle:r,background:u,dimmed:m,manualDestroy:p,closeOnBackdropClick:f,resolve:b,ForegroundComponent:h,BackgroundComponent:C}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"Input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"returnOnCancel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Be.set(this,void 0),this.type=t,this.content=i,this.Input=l,this.defaultValue=a,F(this,Be,a,"f"),this.disabled=s,this.returnOnCancel=c,this.footer=d}onChange(e){F(this,Be,e,"f")}onConfirm(){this.resolve(N(this,Be,"f")??null)}onClose(){this.returnOnCancel?this.resolve(N(this,Be,"f")??null):this.resolve(null)}}Be=new WeakMap;const Ee=e=>{switch(e.type){case"alert":return new Pe(e);case"confirm":return new Ne(e);case"prompt":return new Fe(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},Ie=u({}),Se=r((({pathname:n,children:r})=>{const i=l(new Map),[s,d]=a([]),u=D(s),m=l(n),p=l(0),f=he(),b=o((()=>g(f.duration)),[f]);B((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=f;for(const t of V.prerender){const o=Ee({...t,id:p.current++,initiator:m.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]))}return V.openHandler=t=>{const o=Ee({...t,id:p.current++,initiator:m.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]))},()=>{V.reset()}})),c((()=>{for(const e of u.current){const t=i.current.get(e);t?.alive&&(t.initiator===n?t.onShow():t.onHide())}m.current=n}),[u,n]);const h=t((e=>i.current.get(e)),[]),C=t((e=>{const n=i.current.get(e);n&&(n.onDestroy(),v.current?.())}),[]),v=l(),y=t((e=>{const n=i.current.get(e);n&&(n.onHide(),v.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),b))}),[b]),k=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(),y(e))}),[y]),O=t((e=>{const n=i.current.get(e);n&&(n.onClose(),y(e))}),[y]),x=t((e=>({modal:h(e),onConfirm:()=>w(e),onClose:()=>O(e),onChange:n=>k(e,n),onDestroy:()=>C(e)})),[h,w,O,k,C]),j=o((()=>({modalIds:s,getModalNode:h,onChange:k,onConfirm:w,onClose:O,onDestroy:C,getModal:x,setUpdater:e=>{v.current=e}})),[s,x,h,k,w,O,C]);return e(Ie.Provider,{value:j,children:r})})),Me=()=>m(Ie),Ve=e=>{const{getModal:n}=Me();return o((()=>n(e)),[e,n])},Te=u({}),ze=({context:n,children:t})=>{const r=o((()=>({context:n||{}})),[n]);return e(Te.Provider,{value:r,children:t})},_e=()=>m(Te),Ae=({ForegroundComponent:t,BackgroundComponent:o,TitleComponent:r,SubtitleComponent:a,ContentComponent:s,FooterComponent:c,options:d,context:u,usePathname:m,children:f})=>{const{pathname:b}=(m||re)(),[,h]=O(),C=l(V.unanchored?V.anchor():null);return x((()=>(C.current?h():v("ModalProvider is already initialized",["ModalProvider can only be initialized once.","Nesting ModalProvider will be ignored..."],{info:"Something is wrong with the ModalProvider initialization..."}),()=>{C.current&&C.current.remove()}))),n(i,{children:[f,C.current&&p(e(ze,{context:u,children:e(fe,{ForegroundComponent:t,BackgroundComponent:o,TitleComponent:r,SubtitleComponent:a,ContentComponent:s,FooterComponent:c,options:d,children:e(Se,{pathname:b,children:e(oe,{})})})}),C.current)]})},Le=(e,n)=>{const{modal:t,onDestroy:o}=Ve(e),r=K(t),i=l({modal:t,onDestroy:o,milliseconds:b(n)?g(n):n});s((()=>{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])},$e=(e,n)=>{const t=l(n);t.current=n,c((()=>{if(!t.current)return;let n;return n=e?requestAnimationFrame((()=>t.current.onVisible?.())):requestAnimationFrame((()=>t.current.onHidden?.())),()=>{n&&cancelAnimationFrame(n)}}),[e])};export{Ae as ModalProvider,ve as alert,ye as confirm,ke as prompt,ee as useActiveModalCount,Le as useDestroyAfter,$e as useModalAnimation,ge as useModalBackdrop,Ce as useModalDuration,he as useModalOptions,K as useSubscribeModal};
|
|
16
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */function N(e,n,t,o){if("a"===t&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!o:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?o:"a"===t?o.call(e):o?o.value:n.get(e)}function E(e,n,t,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof n?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,t):r?r.value=t:n.set(e,t),t}var I,S,M,T,V;"function"==typeof SuppressedError&&SuppressedError;class z{static activate(){return!N(I,I,"f",S)&&E(I,I,!0,"f",S)}static anchor(e){if(N(I,I,"f",M)){const e=document.getElementById(N(I,I,"f",M).id);if(e)return e}const{tag:n="div",prefix:t="promise-modal",root:o=document.body}=e||{},r=document.createElement(n);return r.setAttribute("id",`${t}-${f(36)}`),o.appendChild(r),E(I,I,r,"f",M),r}static get prerender(){return N(I,I,"f",T)}static set openHandler(e){E(I,I,e,"f",V),E(I,I,[],"f",T)}static get unanchored(){return!N(I,I,"f",M)}static reset(){E(I,I,!1,"f",S),E(I,I,null,"f",M),E(I,I,[],"f",T),E(I,I,(e=>N(I,I,"f",T).push(e)),"f",V)}static open(e){N(I,I,"f",V).call(I,e)}}I=z,S={value:!1},M={value:null},T={value:[]},V={value:e=>N(I,I,"f",T).push(e)};const _=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})=>new Promise(((u,m)=>{try{z.open({type:"alert",subtype:e,resolve:()=>u(),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})}catch(e){m(e)}})),A=({subtype:e,title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})=>new Promise(((u,m)=>{try{z.open({type:"confirm",subtype:e,resolve:e=>u(e??!1),title:n,subtitle:t,content:o,background:r,footer:i,dimmed:a,manualDestroy:l,closeOnBackdropClick:s,ForegroundComponent:c,BackgroundComponent:d})}catch(e){m(e)}})),L=({defaultValue:e,title:n,subtitle:t,content:o,Input:r,disabled:i,returnOnCancel:a,background:l,footer:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,ForegroundComponent:m,BackgroundComponent:p})=>new Promise(((f,b)=>{try{z.open({type:"prompt",resolve:e=>f(e),title:n,subtitle:t,content:o,Input:r,defaultValue:e,disabled:i,returnOnCancel:a,background:l,footer:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,ForegroundComponent:m,BackgroundComponent:p})}catch(e){b(e)}}));var $,H,q,W,Y;class U{get alive(){return N(this,$,"f")}get visible(){return N(this,H,"f")}constructor({id:e,initiator:n,title:t,subtitle:o,background:r,dimmed:i=!0,manualDestroy:a=!1,closeOnBackdropClick:l=!0,resolve:s,ForegroundComponent:c,BackgroundComponent:d}){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"initiator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"title",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtitle",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"background",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualDestroy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"closeOnBackdropClick",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dimmed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ForegroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BackgroundComponent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),$.set(this,void 0),H.set(this,void 0),q.set(this,void 0),W.set(this,[]),this.id=e,this.initiator=n,this.title=t,this.subtitle=o,this.background=r,this.dimmed=i,this.manualDestroy=a,this.closeOnBackdropClick=l,this.ForegroundComponent=c,this.BackgroundComponent=d,E(this,$,!0,"f"),E(this,H,!0,"f"),E(this,q,s,"f")}subscribe(e){return N(this,W,"f").push(e),()=>{E(this,W,N(this,W,"f").filter((n=>n!==e)),"f")}}publish(){for(const e of N(this,W,"f"))e()}resolve(e){N(this,q,"f").call(this,e)}onDestroy(){const e=!0===N(this,$,"f");E(this,$,!1,"f"),this.manualDestroy&&e&&this.publish()}onShow(){const e=!1===N(this,H,"f");E(this,H,!0,"f"),e&&this.publish()}onHide(){const e=!0===N(this,H,"f");E(this,H,!1,"f"),e&&this.publish()}}$=new WeakMap,H=new WeakMap,q=new WeakMap,W=new WeakMap;class G extends U{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:l,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=a,this.footer=l}onClose(){this.resolve(null)}onConfirm(){this.resolve(null)}}class J extends U{constructor({id:e,initiator:n,type:t,subtype:o,title:r,subtitle:i,content:a,footer:l,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}){super({id:e,initiator:n,title:r,subtitle:i,background:s,dimmed:c,manualDestroy:d,closeOnBackdropClick:u,resolve:m,ForegroundComponent:p,BackgroundComponent:f}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"subtype",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.type=t,this.subtype=o,this.content=a,this.footer=l}onClose(){this.resolve(!1)}onConfirm(){this.resolve(!0)}}class K extends U{constructor({id:e,initiator:n,type:t,title:o,subtitle:r,content:i,defaultValue:a,Input:l,disabled:s,returnOnCancel:c,footer:d,background:u,dimmed:m,manualDestroy:p,closeOnBackdropClick:f,resolve:b,ForegroundComponent:h,BackgroundComponent:C}){super({id:e,initiator:n,title:o,subtitle:r,background:u,dimmed:m,manualDestroy:p,closeOnBackdropClick:f,resolve:b,ForegroundComponent:h,BackgroundComponent:C}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"Input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"returnOnCancel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Y.set(this,void 0),this.type=t,this.content=i,this.Input=l,this.defaultValue=a,E(this,Y,a,"f"),this.disabled=s,this.returnOnCancel=c,this.footer=d}onChange(e){E(this,Y,e,"f")}onConfirm(){this.resolve(N(this,Y,"f")??null)}onClose(){this.returnOnCancel?this.resolve(N(this,Y,"f")??null):this.resolve(null)}}Y=new WeakMap;const Q=e=>{switch(e.type){case"alert":return new G(e);case"confirm":return new J(e);case"prompt":return new K(e)}throw new Error(`Unknown modal: ${e.type}`,{modal:e})},R=t({}),X=o((({usePathname:n,children:t})=>{const o=r(new Map),[c,d]=i([]),u=y(c),{pathname:m}=n(),p=r(m),f=r(0),h=fe(),C=a((()=>b(h.duration)),[h]);k((()=>{const{manualDestroy:e,closeOnBackdropClick:n}=h;for(const t of z.prerender){const r=Q({...t,id:f.current++,initiator:p.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});o.current.set(r.id,r),d((e=>[...e,r.id]))}return z.openHandler=t=>{const r=Q({...t,id:f.current++,initiator:p.current,manualDestroy:void 0!==t.manualDestroy?t.manualDestroy:e,closeOnBackdropClick:void 0!==t.closeOnBackdropClick?t.closeOnBackdropClick:n});o.current.set(r.id,r),d((e=>[...e.filter((e=>{const n=!o.current.get(e)?.alive;return n&&o.current.delete(e),!n})),r.id]))},()=>{z.reset()}})),l((()=>{for(const e of u.current){const n=o.current.get(e);n?.alive&&(n.initiator===m?n.onShow():n.onHide())}p.current=m}),[u,m]);const g=s((e=>o.current.get(e)),[]),v=s((e=>{const n=o.current.get(e);n&&(n.onDestroy(),w.current?.())}),[]),w=r(),x=s((e=>{const n=o.current.get(e);n&&(n.onHide(),w.current?.(),n.manualDestroy||setTimeout((()=>{n.onDestroy()}),C))}),[C]),O=s(((e,n)=>{const t=o.current.get(e);t&&"prompt"===t.type&&t.onChange(n)}),[]),B=s((e=>{const n=o.current.get(e);n&&(n.onConfirm(),x(e))}),[x]),D=s((e=>{const n=o.current.get(e);n&&(n.onClose(),x(e))}),[x]),j=s((e=>({modal:g(e),onConfirm:()=>B(e),onClose:()=>D(e),onChange:n=>O(e,n),onDestroy:()=>v(e)})),[g,B,D,O,v]),P=a((()=>({modalIds:c,getModalNode:g,onChange:O,onConfirm:B,onClose:D,onDestroy:v,getModal:j,setUpdater:e=>{w.current=e}})),[c,j,g,O,B,D,v]);return e(R.Provider,{value:P,children:t})})),Z=()=>c(R),ee=e=>{const{getModal:n}=Z();return a((()=>n(e)),[e,n])};function ne(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const te=j("production"===process.env.NODE_ENV?{name:"131j9g2",styles:"margin:unset"}:{name:"1w3kbco-fallback",styles:"margin:unset;label:fallback;",toString:ne}),oe=j("production"===process.env.NODE_ENV?{name:"1kuk3a3",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black"}:{name:"16dbbea-frame",styles:"display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:white;padding:20px 80px;gap:10px;border:1px solid black;label:frame;",toString:ne}),re=({children:n})=>e("h2",{className:te,children:n}),ie=({children:n})=>e("h3",{className:te,children:n}),ae=({children:n})=>e("div",{className:te,children:n}),le=({confirmLabel:t,hideConfirm:o=!1,cancelLabel:r,hideCancel:i=!1,disabled:a,onConfirm:l,onCancel:s})=>n("div",{children:[!o&&e("button",{onClick:l,disabled:a,children:t||"확인"}),!i&&"function"==typeof s&&e("button",{onClick:s,children:r||"취소"})]}),se=e=>e?.visible,ce=(e=se,n=0)=>{const{modalIds:t,getModalNode:o}=Z();return a((()=>{let n=0;for(const r of t)e(o(r))&&n++;return n}),[o,t,n])},de=d((({id:n,onChangeOrder:t,children:o},r)=>{const i=ce(),[l,s]=a((()=>{const e=i>1;return[e?Math.floor(n/5)%3*100:0,e?n%5*35:0]}),[i,n]);return e("div",{ref:r,className:oe,onClick:t,style:{marginBottom:`calc(25vh + ${l}px)`,marginLeft:`${l}px`,transform:`translate(${s}px, ${s}px)`},children:o})})),ue=t({}),me=o((({ForegroundComponent:n,BackgroundComponent:t,TitleComponent:r,SubtitleComponent:i,ContentComponent:l,FooterComponent:s,options:c,children:d})=>{const u=a((()=>({BackgroundComponent:t,ForegroundComponent:n||de,TitleComponent:r||re,SubtitleComponent:i||ie,ContentComponent:o(l||ae),FooterComponent:o(s||le),options:{duration:"300ms",backdrop:"rgba(0, 0, 0, 0.5)",closeOnBackdropClick:!0,manualDestroy:!1,...c}})),[n,t,l,s,i,r,c]);return e(ue.Provider,{value:u,children:d})})),pe=()=>c(ue),fe=()=>c(ue).options,be=()=>{const e=fe();return{duration:e.duration,milliseconds:b(e.duration)}},he=()=>fe().backdrop,Ce=t({}),ge=({context:n,children:t})=>{const o=a((()=>({context:n||{}})),[n]);return e(Ce.Provider,{value:o,children:t})},ve=()=>c(Ce);function ye(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const ke=j("production"===process.env.NODE_ENV?{name:"u7uu4v",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;}"}:{name:"coymdj-background",styles:"display:none;position:fixed;inset:0;z-index:-999;pointer-events:none;>*{pointer-events:none;};label:background;",toString:ye}),we=j("production"===process.env.NODE_ENV?{name:"n07k1x",styles:"pointer-events:all"}:{name:"1hektcs-active",styles:"pointer-events:all;label:active;",toString:ye}),xe=j("production"===process.env.NODE_ENV?{name:"1wnowod",styles:"display:flex;align-items:center;justify-content:center"}:{name:"xppew7-visible",styles:"display:flex;align-items:center;justify-content:center;label:visible;",toString:ye}),Oe=({modalId:n,onChangeOrder:t})=>{const{BackgroundComponent:o}=pe(),{context:r}=ve(),{modal:i,onClose:l,onChange:c,onConfirm:d,onDestroy:u}=ee(n),m=s((e=>{i&&i.closeOnBackdropClick&&i.visible&&l(),e.stopPropagation()}),[i,l]),p=a((()=>i?.BackgroundComponent||o),[o,i]);return i?e("div",{className:P(ke,{[xe]:i.manualDestroy?i.alive:i.visible,[we]:i.closeOnBackdropClick&&i.visible}),onClick:m,children:p&&e(p,{id:i.id,type:i.type,alive:i.alive,visible:i.visible,initiator:i.initiator,manualDestroy:i.manualDestroy,closeOnBackdropClick:i.closeOnBackdropClick,background:i.background,onChange:c,onConfirm:d,onClose:l,onDestroy:u,onChangeOrder:t,context:r})}):null};function Be(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const De=j("production"===process.env.NODE_ENV?{name:"12g0hx0",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1"}:{name:"1hcczik-foreground",styles:"pointer-events:none;display:none;position:fixed;inset:0;z-index:1;label:foreground;",toString:Be}),je=j("production"===process.env.NODE_ENV?{name:"1g95xyq",styles:">*{pointer-events:all;}"}:{name:"123csva-active",styles:">*{pointer-events:all;};label:active;",toString:Be}),Pe=j("production"===process.env.NODE_ENV?{name:"1fmljv2",styles:"display:flex!important;justify-content:center;align-items:center"}:{name:"1p4unab-visible",styles:"display:flex!important;justify-content:center;align-items:center;label:visible;",toString:Be}),Fe=o((({modal:t,handlers:o})=>{const{title:r,subtitle:i,content:l,footer:s}=a((()=>t),[t]),{context:c}=ve(),{onConfirm:d}=a((()=>o),[o]),m=w(d),{TitleComponent:p,SubtitleComponent:f,ContentComponent:b,FooterComponent:C}=pe();return n(u,{children:[r&&(h(r)?e(p,{context:c,children:r}):r),i&&(h(i)?e(f,{context:c,children:i}):i),l&&(h(l)?e(b,{context:c,children:l}):x(l,{onConfirm:m})),!1!==s&&("function"==typeof s?s({onConfirm:m,context:c}):e(C,{onConfirm:m,confirmLabel:s?.confirm,hideConfirm:s?.hideConfirm,context:c}))]})})),Ne=o((({modal:t,handlers:o})=>{const{title:r,subtitle:i,content:l,footer:s}=a((()=>t),[t]),{context:c}=ve(),{onConfirm:d,onClose:m}=a((()=>o),[o]),p=w(d),f=w(m),{TitleComponent:b,SubtitleComponent:C,ContentComponent:g,FooterComponent:v}=pe();return n(u,{children:[r&&(h(r)?e(b,{context:c,children:r}):r),i&&(h(i)?e(C,{context:c,children:i}):i),l&&(h(l)?e(g,{context:c,children:l}):x(l,{onConfirm:p,onCancel:f,context:c})),!1!==s&&("function"==typeof s?s({onConfirm:p,onCancel:f,context:c}):e(v,{onConfirm:p,onCancel:f,confirmLabel:s?.confirm,cancelLabel:s?.cancel,hideConfirm:s?.hideConfirm,hideCancel:s?.hideCancel,context:c}))]})})),Ee=o((({modal:t,handlers:r})=>{const{Input:l,defaultValue:c,disabled:d,title:m,subtitle:p,content:f,footer:b}=a((()=>({...t,Input:o(O(t.Input))})),[t]),{context:g}=ve(),[v,y]=i(c),{onChange:k,onClose:B,onConfirm:D}=a((()=>r),[r]),j=w(B),P=w((e=>{const n=C(e)?e(v):e;y(n),k(n)})),F=s((()=>{setTimeout((()=>{D()}))}),[D]),N=a((()=>!!v&&!!d?.(v)),[d,v]),{TitleComponent:E,SubtitleComponent:I,ContentComponent:S,FooterComponent:M}=pe();return n(u,{children:[m&&(h(m)?e(E,{context:g,children:m}):m),p&&(h(p)?e(I,{context:g,children:p}):p),f&&(h(f)?e(S,{context:g,children:f}):x(f,{onConfirm:F,onCancel:j,context:g})),l&&e(l,{defaultValue:c,value:v,onChange:P,onConfirm:F,onCancel:j,context:g}),!1!==b&&("function"==typeof b?b({value:v,disabled:N,onChange:P,onConfirm:F,onCancel:j,context:g}):e(M,{disabled:N,onConfirm:F,onCancel:j,confirmLabel:b?.confirm,cancelLabel:b?.cancel,hideConfirm:b?.hideConfirm,hideCancel:b?.hideCancel,context:g}))]})})),Ie=({modalId:t,onChangeOrder:o})=>{const{ForegroundComponent:r}=pe(),{context:i}=ve(),{modal:l,onChange:s,onConfirm:c,onClose:d,onDestroy:u}=ee(t),m=a((()=>l?.ForegroundComponent||r),[r,l]);return l?e("div",{className:P(De,{[Pe]:l.manualDestroy?l.alive:l.visible,[je]:l.visible}),children:n(m,{id:l.id,type:l.type,alive:l.alive,visible:l.visible,initiator:l.initiator,manualDestroy:l.manualDestroy,closeOnBackdropClick:l.closeOnBackdropClick,background:l.background,onChange:s,onConfirm:c,onClose:d,onDestroy:u,onChangeOrder:o,context:i,children:["alert"===l.type&&e(Fe,{modal:l,handlers:{onConfirm:c}}),"confirm"===l.type&&e(Ne,{modal:l,handlers:{onConfirm:c,onClose:d}}),"prompt"===l.type&&e(Ee,{modal:l,handlers:{onChange:s,onConfirm:c,onClose:d}})]})}):null},Se=e=>{const[n,t]=B();return D((()=>{if(e)return e.subscribe(t)})),n},Me=j("production"===process.env.NODE_ENV?{name:"13dmkf4",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden"}:{name:"yjeu12-presenter",styles:"position:fixed;inset:0;pointer-events:none;overflow:hidden;label:presenter;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),{increment:Te}=g(1),Ve=o((({modalId:t})=>{const o=r(null),{modal:i}=ee(t);Se(i);const a=w((()=>{o.current&&(o.current.style.zIndex=`${Te()}`)}));return n("div",{ref:o,className:Me,children:[e(Oe,{modalId:t,onChangeOrder:a}),e(Ie,{modalId:t,onChangeOrder:a})]})})),ze=j("production"===process.env.NODE_ENV?{name:"2hpasy",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out"}:{name:"lhj8co-anchor",styles:"display:flex;align-items:center;justify-content:center;position:fixed;inset:0;pointer-events:none;z-index:1000;transition:background-color ease-in-out;label:anchor;",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),_e=e=>e?.visible&&e.dimmed,Ae=o(O((()=>{const[n,t]=B(),{modalIds:o,setUpdater:r}=Z();m((()=>{r(t)}),[r,t]);const i=fe(),a=ce(_e,n);return e("div",{className:ze,style:{transitionDuration:i.duration,backgroundColor:a?i.backdrop:"transparent"},children:o.map((n=>e(Ve,{modalId:n},n)))})}))),Le=({ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:a,usePathname:l,options:s,context:c,anchor:d})=>F(e(ge,{context:c,children:e(me,{ForegroundComponent:n,BackgroundComponent:t,TitleComponent:o,SubtitleComponent:r,ContentComponent:i,FooterComponent:a,options:s,children:e(X,{usePathname:l,children:e(Ae,{})})})}),d),$e=()=>{const[e,n]=i(window.location.pathname);return l((()=>{let t;const o=()=>{t&&cancelAnimationFrame(t),e!==window.location.pathname?n(window.location.pathname):t=requestAnimationFrame(o)};return t=requestAnimationFrame(o),()=>{t&&cancelAnimationFrame(t)}}),[e]),{pathname:e}},He=d((({usePathname:e,ForegroundComponent:t,BackgroundComponent:o,TitleComponent:i,SubtitleComponent:l,ContentComponent:c,FooterComponent:d,options:m,context:f,children:b},h)=>{const C=a((()=>e||$e),[e]),g=r(z.activate()),y=r(null),[,k]=B(),w=s((e=>{g.current?(y.current=z.anchor({root:e}),k()):v("ModalProvider is already initialized",["ModalProvider can only be initialized once.","Nesting ModalProvider will be ignored..."],{info:"Something is wrong with the ModalProvider initialization..."})}),[k]);return p(h,(()=>({initialize:w})),[w]),D((()=>(null===h&&w(),()=>{y.current&&y.current.remove()}))),n(u,{children:[b,y.current&&Le({ForegroundComponent:t,BackgroundComponent:o,TitleComponent:i,SubtitleComponent:l,ContentComponent:c,FooterComponent:d,usePathname:C,options:m,context:f,anchor:y.current})]})})),qe=(e,n)=>{const{modal:t,onDestroy:o}=ee(e),i=Se(t),a=r({modal:t,onDestroy:o,milliseconds:h(n)?b(n):n});m((()=>{const{modal:e,onDestroy:n,milliseconds:t}=a.current;if(!e||e.visible||!e.alive)return;const o=setTimeout((()=>{n()}),t);return()=>{o&&clearTimeout(o)}}),[i])},We=(e,n)=>{const t=r(n);t.current=n,l((()=>{if(!t.current)return;let n;return n=e?requestAnimationFrame((()=>t.current.onVisible?.())):requestAnimationFrame((()=>t.current.onHidden?.())),()=>{n&&cancelAnimationFrame(n)}}),[e])};export{He as ModalProvider,_ as alert,Le as bootstrap,A as confirm,L as prompt,ce as useActiveModalCount,qe as useDestroyAfter,We as useModalAnimation,he as useModalBackdrop,be as useModalDuration,fe as useModalOptions,Se as useSubscribeModal};
|
|
17
17
|
//# sourceMappingURL=index.esm.js.map
|