@rivinia/modal 0.4.0 → 0.5.1
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/README.md +111 -1
- package/fesm2022/rivinia-modal-ui.mjs +1003 -0
- package/fesm2022/rivinia-modal-ui.mjs.map +1 -0
- package/package.json +6 -1
- package/types/rivinia-modal-ui.d.ts +332 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rivinia-modal-ui.mjs","names":[],"sources":["../../../projects/modal/ui/src/lib/modal-scroll-lock.ts","../../../projects/modal/ui/src/lib/modal-dialog.ts","../../../projects/modal/ui/src/lib/modal-host.ts"],"sourcesContent":["import { DOCUMENT, Service, inject } from '@angular/core';\n\n/**\n * Reference-counted background scroll lock. Multiple overlays share one lock:\n * closing one modal never unlocks the page while another still needs it.\n * Restores the exact previous `overflow` value (never blanks app-owned\n * styles). All DOM access happens inside methods — never at module\n * evaluation — and every method is a no-op without a document (SSR).\n */\n@Service()\nexport class RiviniaModalScrollLock {\n private readonly _doc = inject(DOCUMENT, { optional: true });\n private _locks = 0;\n private _previousOverflow: string | null = null;\n\n /** Number of active locks (diagnostics/tests). */\n get active(): number {\n return this._locks;\n }\n\n acquire(): void {\n const doc = this.document;\n if (!doc) return;\n this._locks += 1;\n if (this._locks > 1) return;\n const body = doc.body;\n this._previousOverflow = body.style.overflow || null;\n body.style.overflow = 'hidden';\n // Reserve the scrollbar gutter where supported so content does not jump.\n // Overlay scrollbars ignore it; that is documented, not promised.\n doc.documentElement.style.setProperty('scrollbar-gutter', 'stable');\n }\n\n release(): void {\n const doc = this.document;\n if (!doc || this._locks === 0) {\n this._locks = 0;\n return;\n }\n this._locks -= 1;\n if (this._locks > 0) return;\n const body = doc.body;\n if (this._previousOverflow === null) body.style.removeProperty('overflow');\n else body.style.overflow = this._previousOverflow;\n this._previousOverflow = null;\n doc.documentElement.style.removeProperty('scrollbar-gutter');\n }\n\n private get document(): Document | null {\n try {\n return this._doc ?? (typeof document === 'undefined' ? null : document);\n } catch {\n return null;\n }\n }\n}\n","import {\n Component,\n Directive,\n DOCUMENT,\n ElementRef,\n ViewEncapsulation,\n computed,\n contentChild,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n viewChild,\n} from '@angular/core';\nimport { RiviniaModalScrollLock } from './modal-scroll-lock';\nimport type {\n RiviniaModalAnimation,\n RiviniaModalBackdrop,\n RiviniaModalPosition,\n RiviniaModalSize,\n} from './ui-types';\n\nconst EXIT_FALLBACK_MS = 200;\n\n/**\n * Marker for custom header content. Put it on the element carrying\n * `rv-modal-header` — its presence (not just the attribute) tells the\n * dialog to hide the default title + close button:\n *\n * ```html\n * <div rv-modal-header rvModalHeader>My header</div>\n * ```\n */\n@Directive({ selector: '[rvModalHeader]', standalone: true })\nexport class RvModalHeader {}\n\n/**\n * Marker for custom footer content. Put it on the element carrying\n * `rv-modal-footer`. Without it the footer region never renders.\n */\n@Directive({ selector: '[rvModalFooter]', standalone: true })\nexport class RvModalFooter {}\n\n/**\n * Ready-made modal dialog on the native `<dialog>` element (top layer,\n * `::backdrop`, inert background, Escape `cancel` event — all platform\n * behavior, zero overlay dependencies).\n *\n * UI-only by design: it owns its own `open` state and never imports the\n * headless controller. Pair it with `@rivinia/modal` through\n * {@link RiviniaModalHost} (or your own adapter) when you want managed\n * lifecycle, guards and typed results.\n *\n * Projection: `[rv-modal-header]` replaces the default header (title +\n * close button); default `<ng-content>` is the body; `[rv-modal-footer]`\n * is optional and renders nothing when absent.\n */\n@Component({\n selector: 'rv-modal-dialog',\n standalone: true,\n // Unencapsulated like rv-menu: custom projected headers/footers belong to\n // the consumer's template, which emulated selectors cannot reach. Every\n // rule is scoped under `.rv-modal`, so nothing leaks.\n encapsulation: ViewEncapsulation.None,\n template: `\n <dialog\n #dialog\n tabindex=\"-1\"\n class=\"rv-modal\"\n [attr.data-size]=\"size()\"\n [attr.data-position]=\"position()\"\n [attr.data-animation]=\"animation()\"\n [attr.data-state]=\"state()\"\n [attr.aria-label]=\"computedLabel()\"\n [attr.aria-labelledby]=\"title() && !ariaLabel() ? titleId : null\"\n [attr.aria-describedby]=\"description() ? descriptionId : null\"\n (cancel)=\"onCancel($event)\"\n (click)=\"onBackdropClick($event)\"\n (keydown)=\"onKeydown($event)\"\n >\n @if (hasCustomHeader()) {\n <div class=\"rv-modal-header rv-modal-header-custom\">\n <ng-content select=\"[rv-modal-header]\"></ng-content>\n </div>\n } @else if (title() || showCloseButton()) {\n <div class=\"rv-modal-header\">\n <div class=\"rv-modal-heading\">\n @if (title()) {\n <h2 class=\"rv-modal-title\" [id]=\"titleId\">{{ title() }}</h2>\n }\n @if (description()) {\n <p class=\"rv-modal-description\" [id]=\"descriptionId\">{{ description() }}</p>\n }\n </div>\n @if (showCloseButton()) {\n <button\n type=\"button\"\n class=\"rv-modal-close\"\n (click)=\"onCloseButton()\"\n aria-label=\"Close dialog\"\n >\n <span aria-hidden=\"true\">×</span>\n </button>\n }\n </div>\n }\n <div class=\"rv-modal-body\">\n <ng-content></ng-content>\n </div>\n @if (hasCustomFooter()) {\n <div class=\"rv-modal-footer\">\n <ng-content select=\"[rv-modal-footer]\"></ng-content>\n </div>\n }\n </dialog>\n `,\n styles: [\n `\n .rv-modal {\n color-scheme: light dark;\n --rv-modal-bg: #ffffff;\n --rv-modal-fg: #111111;\n --rv-modal-muted: #555555;\n --rv-modal-border: #e0e0e0;\n --rv-modal-radius: 12px;\n --rv-modal-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);\n --rv-modal-backdrop: rgba(0, 0, 0, 0.5);\n --rv-modal-pad: 20px;\n --rv-modal-gap: 12px;\n --rv-modal-width-sm: 24rem;\n --rv-modal-width-md: 32rem;\n --rv-modal-width-lg: 48rem;\n --rv-modal-width-xl: 64rem;\n --rv-modal-max-height: min(86dvh, 100%);\n --rv-modal-duration: 150ms;\n --rv-modal-duration-in: var(--rv-modal-duration);\n --rv-modal-duration-out: 120ms;\n --rv-modal-easing: ease-out;\n --rv-modal-easing-in: var(--rv-modal-easing);\n --rv-modal-easing-out: ease-in;\n --rv-modal-radius-sheet: 20px;\n --rv-modal-width-panel: 24rem;\n padding: 0;\n border: 1px solid var(--rv-modal-border);\n border-radius: var(--rv-modal-radius);\n background: var(--rv-modal-bg);\n color: var(--rv-modal-fg);\n box-shadow: var(--rv-modal-shadow);\n max-height: var(--rv-modal-max-height);\n width: var(--rv-modal-width-md);\n max-width: calc(100dvw - 2rem);\n }\n @media (prefers-color-scheme: dark) {\n .rv-modal {\n --rv-modal-bg: #161616;\n --rv-modal-fg: #f2f2f2;\n --rv-modal-muted: #a8a8a8;\n --rv-modal-border: #333333;\n --rv-modal-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);\n }\n }\n .rv-modal::backdrop {\n background: var(--rv-modal-backdrop);\n }\n .rv-modal[data-size='sm'] {\n width: var(--rv-modal-width-sm);\n }\n .rv-modal[data-size='lg'] {\n width: var(--rv-modal-width-lg);\n }\n .rv-modal[data-size='xl'] {\n width: var(--rv-modal-width-xl);\n }\n .rv-modal[data-size='full'] {\n width: calc(100dvw - 2rem);\n }\n .rv-modal[data-size='auto'] {\n width: auto;\n }\n .rv-modal[data-position='top'] {\n margin-block-start: 8dvh;\n }\n .rv-modal[data-position='bottom'] {\n margin-block-start: auto;\n margin-block-end: 8dvh;\n }\n .rv-modal[data-position='top-start'],\n .rv-modal[data-position='center-start'] {\n margin-inline-start: 1rem;\n margin-inline-end: auto;\n }\n .rv-modal[data-position='top-end'],\n .rv-modal[data-position='center-end'] {\n margin-inline-start: auto;\n margin-inline-end: 1rem;\n }\n .rv-modal[data-position='bottom-start'] {\n margin-block-start: auto;\n margin-inline-start: 1rem;\n }\n .rv-modal[data-position='bottom-end'] {\n margin-block-start: auto;\n margin-inline-end: 1rem;\n }\n .rv-modal[data-position='fullscreen'] {\n inset: 0;\n width: 100dvw;\n height: 100dvh;\n height: 100dvh;\n max-width: none;\n max-height: none;\n border-radius: 0;\n }\n .rv-modal[data-position='side-start'],\n .rv-modal[data-position='side-end'] {\n height: 100dvh;\n max-height: none;\n width: var(--rv-modal-width-panel);\n margin-block: 0;\n }\n .rv-modal[data-position='side-start'] {\n margin-inline-start: 0;\n margin-inline-end: auto;\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n }\n .rv-modal[data-position='side-end'] {\n margin-inline-start: auto;\n margin-inline-end: 0;\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n }\n @media (max-width: 640px) {\n .rv-modal[data-position='center'],\n .rv-modal[data-position='top'],\n .rv-modal[data-position='bottom'],\n .rv-modal[data-position='bottom-start'],\n .rv-modal[data-position='bottom-end'] {\n margin-block-start: auto;\n margin-block-end: 0;\n margin-inline: 0;\n width: 100dvw;\n max-width: none;\n border-end-end-radius: 0;\n border-end-start-radius: 0;\n border-start-start-radius: var(--rv-modal-radius-sheet);\n border-start-end-radius: var(--rv-modal-radius-sheet);\n }\n .rv-modal[data-position='center'][data-state='open'],\n .rv-modal[data-position='top'][data-state='open'],\n .rv-modal[data-position='bottom'][data-state='open'],\n .rv-modal[data-position='bottom-start'][data-state='open'],\n .rv-modal[data-position='bottom-end'][data-state='open'] {\n animation-name: rv-modal-in-bottom;\n }\n }\n .rv-modal[data-animation]:not([data-animation='none'])[data-state='open'] {\n animation: var(--rv-modal-animation-in, rv-modal-in) var(--rv-modal-duration-in)\n var(--rv-modal-easing-in);\n }\n .rv-modal[data-animation='scale'][data-state='open'] {\n --rv-modal-animation-in: rv-modal-in-scale;\n }\n .rv-modal[data-animation='slide-top'][data-state='open'] {\n --rv-modal-animation-in: rv-modal-in-top;\n }\n .rv-modal[data-animation='slide-bottom'][data-state='open'] {\n --rv-modal-animation-in: rv-modal-in-bottom;\n }\n .rv-modal[data-animation='slide-start'][data-state='open'] {\n --rv-modal-animation-in: rv-modal-in-start;\n }\n .rv-modal[data-animation='slide-end'][data-state='open'] {\n --rv-modal-animation-in: rv-modal-in-end;\n }\n [dir='rtl'] .rv-modal[data-animation='slide-start'][data-state='open'] {\n --rv-modal-animation-in: rv-modal-in-end;\n }\n [dir='rtl'] .rv-modal[data-animation='slide-end'][data-state='open'] {\n --rv-modal-animation-in: rv-modal-in-start;\n }\n .rv-modal[data-state='closing'] {\n animation: rv-modal-out var(--rv-modal-duration-out) var(--rv-modal-easing-out) forwards;\n }\n @keyframes rv-modal-in {\n from {\n opacity: 0;\n }\n }\n @keyframes rv-modal-in-scale {\n from {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n }\n @keyframes rv-modal-in-top {\n from {\n opacity: 0;\n transform: translateY(-24px);\n }\n }\n @keyframes rv-modal-in-bottom {\n from {\n opacity: 0;\n transform: translateY(24px);\n }\n }\n @keyframes rv-modal-in-start {\n from {\n opacity: 0;\n transform: translateX(-24px);\n }\n }\n @keyframes rv-modal-in-end {\n from {\n opacity: 0;\n transform: translateX(24px);\n }\n }\n @keyframes rv-modal-out {\n to {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .rv-modal[data-animation] {\n animation: none;\n }\n }\n .rv-modal-header {\n display: flex;\n align-items: flex-start;\n gap: var(--rv-modal-gap);\n padding: var(--rv-modal-pad) var(--rv-modal-pad) 0;\n }\n .rv-modal-header-custom > :first-child {\n flex: 1;\n min-width: 0;\n }\n .rv-modal-heading:empty {\n display: none;\n }\n .rv-modal-title {\n margin: 0;\n font-size: 1.125rem;\n flex: 1;\n }\n .rv-modal-heading {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n .rv-modal-description {\n margin: 0;\n font-size: 0.875rem;\n color: var(--rv-modal-muted);\n }\n .rv-modal-close {\n margin-inline-start: auto;\n flex: none;\n border: 1px solid var(--rv-modal-border);\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font-size: 1.25rem;\n line-height: 1;\n padding: 4px 10px;\n cursor: pointer;\n }\n .rv-modal-close:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 2px;\n }\n .rv-modal-body {\n padding: var(--rv-modal-pad);\n overflow: auto;\n max-height: inherit;\n }\n .rv-modal-footer {\n display: flex;\n gap: var(--rv-modal-gap);\n justify-content: flex-end;\n padding: 0 var(--rv-modal-pad) var(--rv-modal-pad);\n }\n .rv-modal-footer:empty {\n display: none;\n }\n `,\n ],\n})\nexport class RiviniaModalDialog {\n /** Two-way open state. UI-only mode owns this; the host drives it in managed mode. */\n readonly open = model<boolean>(false);\n\n readonly title = input<string>('');\n /**\n * Supporting text under the title (shadcn-style description). Rendered in\n * the default header only, and wired as the dialog's `aria-describedby`\n * for free accessible naming. Empty = no description element at all.\n */\n readonly description = input<string>('');\n /** Explicit accessible name. When set, `aria-label` wins over the title reference. */\n readonly ariaLabel = input<string>('');\n readonly size = input<RiviniaModalSize>('md');\n readonly position = input<RiviniaModalPosition>('center');\n readonly animation = input<RiviniaModalAnimation>('scale');\n readonly closeOnEscape = input<boolean>(true);\n readonly backdrop = input<RiviniaModalBackdrop>('close');\n readonly showCloseButton = input<boolean>(true);\n /**\n * Managed mode (for {@link RiviniaModalHost}): UI intents (X button,\n * Escape, backdrop) emit `dismissRequested` INSTEAD of dismissing, so the\n * manager runs guards first and settles results. Drive the exit with the\n * `closing` input; acknowledge teardown with `exitDone`.\n * UI-only mode (`false`, default) dismisses locally.\n */\n readonly managed = input<boolean>(false);\n /**\n * Managed-mode exit trigger. Set `true` when the manager reports this\n * instance `closing`: the dialog plays its exit animation, then emits\n * `exitDone` (call `confirmClosed()` there). Ignored in UI-only mode.\n */\n readonly closing = input<boolean>(false);\n\n /** Settled with a value (primary/confirm actions call `close(value)`). */\n readonly confirmed = output<unknown>();\n /** Settled without a value (X button, backdrop, Escape, `dismiss()`). */\n readonly dismissed = output<string | undefined>();\n /** Explicit cancellation (`cancel()`). Kept distinct from dismissal. */\n readonly cancelled = output<string | undefined>();\n /**\n * Managed-mode intent (X button / Escape / backdrop). Emitted INSTEAD of\n * dismissing — the host routes it to the manager first. Never emitted in\n * UI-only mode.\n */\n readonly dismissRequested = output<'button' | 'escape' | 'backdrop'>();\n /** Managed-mode exit completion. Acknowledge with `confirmClosed()`. */\n readonly exitDone = output<void>();\n\n private readonly dialog = viewChild<ElementRef<HTMLDialogElement>>('dialog');\n private readonly headerSlot = contentChild(RvModalHeader);\n private readonly footerSlot = contentChild(RvModalFooter);\n private readonly doc = inject(DOCUMENT, { optional: true });\n private readonly scrollLock = inject(RiviniaModalScrollLock, { optional: true });\n private readonly titleId = `rv-modal-${++dialogSeq}`;\n private readonly descriptionId = `rv-modal-desc-${dialogSeq}`;\n private readonly phase = signal<'closed' | 'open' | 'closing'>('closed');\n private readonly invoker: { current: Element | null } = { current: null };\n private exitTimer: ReturnType<typeof setTimeout> | null = null;\n\n /** Template state for animation styling. Never rendered open on the server. */\n readonly state = computed(() => this.phase());\n readonly hasCustomHeader = computed(() => this.headerSlot() !== undefined);\n readonly hasCustomFooter = computed(() => this.footerSlot() !== undefined);\n readonly computedLabel = computed(() => this.ariaLabel() || null);\n\n constructor() {\n effect(() => {\n if (this.open()) this.show();\n // External close acts only while fully open: during 'closing' the\n // exit animation owns teardown (its timer finalizes). This guard is\n // what keeps `finish()` from cutting the animation via `open.set(false)`.\n else if (this.phase() === 'open') this.hide();\n });\n effect(() => {\n // Managed exit: the manager moved this instance to `closing`.\n if (this.managed() && this.closing() && this.phase() === 'open') {\n this.playExit(() => this.exitDone.emit());\n }\n });\n }\n\n /** Confirm with a value. No-op while closing/closed. */\n confirm(value?: unknown): boolean {\n if (this.phase() !== 'open') return false;\n this.finish('confirmed', value);\n return true;\n }\n\n /** Backwards-compatible close: confirms when given a value, dismisses otherwise. */\n close(value?: unknown): boolean {\n return value === undefined ? this.dismiss() : this.confirm(value);\n }\n\n /** Dismiss without a value (X button, backdrop, Escape route here). */\n dismiss(reason?: string): boolean {\n if (this.phase() !== 'open') return false;\n this.finish('dismissed', undefined, reason);\n return true;\n }\n\n /** Explicit cancellation. */\n cancel(reason?: string): boolean {\n if (this.phase() !== 'open') return false;\n this.finish('cancelled', undefined, reason);\n return true;\n }\n\n protected onCloseButton(): void {\n if (this.managed()) {\n if (this.phase() === 'open') this.dismissRequested.emit('button');\n return;\n }\n this.dismiss('close-button');\n }\n\n protected onCancel(event: Event): void {\n if (!this.closeOnEscape()) {\n event.preventDefault();\n return;\n }\n // Native `cancel` already closed nothing yet — route through our pipeline\n // so scroll-lock, focus restore and outputs stay consistent.\n event.preventDefault();\n if (this.managed()) {\n if (this.phase() === 'open') this.dismissRequested.emit('escape');\n return;\n }\n this.dismiss('escape');\n }\n\n protected onBackdropClick(event: MouseEvent): void {\n const el = this.dialog()?.nativeElement;\n if (!el || event.target !== el) return; // inside clicks never count\n if (this.backdrop() !== 'close') return;\n if (this.managed()) {\n if (this.phase() === 'open') this.dismissRequested.emit('backdrop');\n return;\n }\n this.dismiss('backdrop');\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n if (event.key !== 'Tab') return;\n const el = this.dialog()?.nativeElement;\n if (!el) return;\n const items = focusables(el);\n if (items.length === 0) {\n event.preventDefault();\n return;\n }\n const first = items[0];\n const last = items[items.length - 1];\n const active = (this.doc ?? document).activeElement;\n if (event.shiftKey && (active === first || !el.contains(active))) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first.focus();\n }\n }\n\n private get live(): boolean {\n return typeof window !== 'undefined' && !!this.doc;\n }\n\n private show(): void {\n if (!this.live) return; // SSR: stay closed until client hydration opens us\n const el = this.dialog()?.nativeElement;\n if (!el || this.phase() !== 'closed') return;\n try {\n this.invoker.current = this.doc?.activeElement ?? null;\n } catch {\n this.invoker.current = null;\n }\n this.scrollLock?.acquire();\n this.phase.set('open');\n if (!el.open) {\n try {\n el.showModal();\n } catch {\n // Already open (e.g. double effect run): continue — state is ours.\n }\n }\n focusFirst(el, this.showCloseButton());\n }\n\n private hide(): void {\n if (this.phase() === 'closed') return;\n this.teardown(false);\n }\n\n private finish(\n kind: 'confirmed' | 'dismissed' | 'cancelled',\n value?: unknown,\n reason?: string,\n ): void {\n this.teardown(true);\n if (kind === 'confirmed') this.confirmed.emit(value);\n else if (kind === 'dismissed') this.dismissed.emit(reason);\n else this.cancelled.emit(reason);\n if (this.open()) this.open.set(false);\n }\n\n private teardown(animate: boolean): void {\n if (!animate) {\n if (this.exitTimer) {\n clearTimeout(this.exitTimer);\n this.exitTimer = null;\n }\n this.finalize(this.dialog()?.nativeElement ?? null);\n return;\n }\n this.playExit(() => {});\n }\n\n /** Plays the exit animation (when warranted), then runs `done`. Idempotent. */\n private playExit(done: () => void): void {\n if (this.phase() !== 'open') {\n done();\n return;\n }\n if (this.exitTimer) {\n clearTimeout(this.exitTimer);\n this.exitTimer = null;\n }\n const el = this.dialog()?.nativeElement ?? null;\n const animated = this.animation() !== 'none' && this.prefersMotion() && !!el?.open;\n this.phase.set(animated ? 'closing' : 'closed');\n if (!animated) {\n this.finalize(el);\n done();\n return;\n }\n // Honor consumer-overridden durations instead of a fixed fallback, so a\n // longer `--rv-modal-duration-out` is never cut short.\n this.exitTimer = setTimeout(() => {\n this.finalize(el);\n done();\n }, this.exitDurationMs(el));\n }\n\n private exitDurationMs(el: HTMLDialogElement | null): number {\n try {\n const raw = el ? getComputedStyle(el).animationDuration : '';\n const seconds = raw\n .split(',')\n .map((part) => parseFloat(part))\n .filter((n) => Number.isFinite(n));\n if (seconds.length > 0) return Math.max(0, Math.max(...seconds) * 1000) + 50;\n } catch {\n // Non-CSS environments (tests): fall through to the fallback.\n }\n return EXIT_FALLBACK_MS;\n }\n\n private finalize(el: HTMLDialogElement | null): void {\n this.exitTimer = null;\n try {\n el?.close();\n } catch {\n // Already closed natively — ours to reconcile, not to throw.\n }\n this.phase.set('closed');\n this.scrollLock?.release();\n const invoker = this.invoker.current as HTMLElement | null;\n this.invoker.current = null;\n try {\n invoker?.focus?.();\n } catch {\n // Invoker gone (navigated away) — nothing to restore to.\n }\n }\n\n private prefersMotion(): boolean {\n try {\n return (\n typeof window !== 'undefined' &&\n !window.matchMedia('(prefers-reduced-motion: reduce)').matches\n );\n } catch {\n return true;\n }\n }\n}\n\nlet dialogSeq = 0;\n\nfunction focusables(root: HTMLElement): HTMLElement[] {\n // No visibility filtering on purpose: jsdom reports zero rects (unit\n // tests), and `disabled` is already excluded by the selector. Hidden\n // focusables inside a visible dialog are a consumer edge, not ours.\n const selector =\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), ' +\n 'textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n return Array.from(root.querySelectorAll<HTMLElement>(selector));\n}\n\nfunction focusFirst(dialog: HTMLDialogElement, closeVisible: boolean): void {\n try {\n const auto = dialog.querySelector<HTMLElement>('[autofocus]');\n if (auto) {\n auto.focus({ preventScroll: true });\n return;\n }\n // Atlassian rule: no close button → focus the title; otherwise the\n // dialog itself (its tabindex=\"-1\" makes it focusable).\n if (!closeVisible) {\n const title = dialog.querySelector<HTMLElement>('.rv-modal-title');\n if (title) {\n title.setAttribute('tabindex', '-1');\n title.focus({ preventScroll: true });\n return;\n }\n }\n dialog.focus({ preventScroll: true });\n } catch {\n // Focus is best-effort (e.g. during teardown races).\n }\n}\n","import { Component, Injector, computed, input } from '@angular/core';\nimport type { Signal } from '@angular/core';\nimport { NgComponentOutlet, NgTemplateOutlet } from '@angular/common';\nimport { RIVINIA_MODAL_CONTEXT } from '@rivinia/modal';\nimport type {\n ModalContext,\n ModalDismissOrigin,\n ModalInstance,\n ModalTemplateContext,\n} from '@rivinia/modal';\nimport { RiviniaModalDialog } from './modal-dialog';\nimport type { RiviniaModalSize } from './ui-types';\n\n/**\n * Managed adapter: renders every `visible()` instance of the headless\n * `RiviniaModal` inside a {@link RiviniaModalDialog} and routes all UI\n * intents through the manager first (guards run; results settle in Core —\n * the single source of truth). The dialog never settles anything itself in\n * this mode; listen to `ModalHandle.result`, not dialog outputs.\n *\n * Exit coordination: when Core reports an instance `closing`, the dialog\n * plays its exit animation and the host acknowledges with `confirmClosed()`\n * (idempotent — safe if `closingTimeout` auto-finalized first). Match\n * `closingTimeout` to the animation duration so exits stay visible.\n *\n * Title resolution: `titleOf` per instance (default: `metadata.title` →\n * `ref` → `''`). Content descriptors render as-is: templates via\n * `ngTemplateOutlet` with `{$implicit: data, modal}`, components via\n * `NgComponentOutlet` with `inputs` + a per-instance\n * `RIVINIA_MODAL_CONTEXT` injector (the lab-proven pattern).\n *\n * The manager arrives via `[modal]` input (D06 input-composition: the UI\n * entry never instantiates Core itself, so UI-only consumers pay nothing).\n * The input is typed as {@link RiviniaModalHostManager} — the structural\n * slice the host actually drives — so the full manager (or a test double)\n * satisfies it from any module realm:\n *\n * ```html\n * <rv-modal-host [modal]=\"injectRiviniaModal()\" />\n * ```\n */\nexport interface RiviniaModalHostManager {\n readonly visible: Signal<readonly ModalInstance<unknown>[]>;\n requestDismiss(id: string, origin: ModalDismissOrigin): Promise<boolean>;\n confirmClosed(id: string): boolean;\n close(id: string, value?: unknown): boolean;\n dismiss(id: string, reason?: string): boolean;\n}\n\n@Component({\n selector: 'rv-modal-host',\n standalone: true,\n imports: [RiviniaModalDialog, NgComponentOutlet, NgTemplateOutlet],\n template: `\n @for (instance of visible(); track instance.id) {\n <rv-modal-dialog\n [open]=\"true\"\n [managed]=\"true\"\n [closing]=\"instance.status === 'closing'\"\n [title]=\"titleOfInstance(instance)\"\n [size]=\"size()\"\n [showCloseButton]=\"showCloseButton()\"\n [closeOnEscape]=\"instance.dismiss.closeOnEscape ?? true\"\n [backdrop]=\"instance.dismiss.backdrop ?? 'close'\"\n (dismissRequested)=\"onIntent(instance.id, $event)\"\n (exitDone)=\"onExitDone(instance.id)\"\n >\n @if (instance.content.kind === 'template') {\n <ng-container\n *ngTemplateOutlet=\"instance.content.template; context: templateContext(instance)\"\n ></ng-container>\n } @else {\n <ng-container\n *ngComponentOutlet=\"\n instance.content.component;\n inputs: instance.content.inputs;\n injector: contextInjector(instance)\n \"\n ></ng-container>\n }\n </rv-modal-dialog>\n }\n `,\n})\nexport class RiviniaModalHost {\n /**\n * The headless manager to render. Typed as {@link RiviniaModalHostManager}\n * (structural) — pass `injectRiviniaModal()` from your app code.\n */\n readonly modal = input.required<RiviniaModalHostManager>();\n\n /** Dialog size for every managed instance. @default 'md' */\n readonly size = input<RiviniaModalSize>('md');\n /** Render the header close button on every managed instance. @default true */\n readonly showCloseButton = input<boolean>(true);\n /** Resolve a title per instance. Default: `metadata.title` → `ref` → `''`. */\n readonly titleOf = input<(instance: ModalInstance<unknown>) => string | undefined>();\n\n protected readonly visible = computed(() => this.modal().visible());\n\n protected titleOfInstance(instance: ModalInstance<unknown>): string {\n try {\n const custom = this.titleOf()?.(instance);\n if (custom !== undefined) return custom;\n } catch {\n // A throwing resolver must never break rendering — fall through.\n }\n const meta = instance.metadata?.['title'];\n if (typeof meta === 'string' && meta.length > 0) return meta;\n return instance.ref ?? '';\n }\n\n protected templateContext(instance: ModalInstance<unknown>): ModalTemplateContext<unknown> {\n return { $implicit: instance.data, modal: this.modalContext(instance) };\n }\n\n protected contextInjector(instance: ModalInstance<unknown>): Injector {\n const modal = this.modal();\n return Injector.create({\n providers: [\n {\n provide: RIVINIA_MODAL_CONTEXT,\n useValue: {\n id: instance.id,\n data: instance.data,\n parentId: instance.parentId,\n close: (result?: unknown) => modal.close(instance.id, result),\n dismiss: (reason?: string) => modal.dismiss(instance.id, reason),\n } satisfies ModalContext<unknown>,\n },\n ],\n });\n }\n\n protected async onIntent(id: string, origin: 'button' | 'escape' | 'backdrop'): Promise<void> {\n try {\n await this.modal().requestDismiss(id, origin);\n } catch {\n // requestDismiss never rejects (deny-safe by contract) — defensive only.\n }\n // Granted → status flips to `closing` → dialog exit → `exitDone`.\n // Denied → nothing moves; the dialog never left `open`. No manual toggle.\n }\n\n protected onExitDone(id: string): void {\n this.modal().confirmClosed(id);\n }\n\n private modalContext(instance: ModalInstance<unknown>): ModalContext<unknown> {\n const modal = this.modal();\n const id = instance.id;\n return {\n id,\n data: instance.data,\n parentId: instance.parentId,\n close: (result?: unknown) => modal.close(id, result),\n dismiss: (re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{
|
|
2
2
|
"name": "@rivinia/modal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Headless modal manager for Angular: stack/queue strategies, typed results, guards, ownership.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
+
"@angular/common": "^22.0.0",
|
|
14
15
|
"@angular/core": "^22.0.0"
|
|
15
16
|
},
|
|
16
17
|
"sideEffects": false,
|
|
@@ -24,6 +25,10 @@
|
|
|
24
25
|
".": {
|
|
25
26
|
"types": "./types/rivinia-modal.d.ts",
|
|
26
27
|
"default": "./fesm2022/rivinia-modal.mjs"
|
|
28
|
+
},
|
|
29
|
+
"./ui": {
|
|
30
|
+
"types": "./types/rivinia-modal-ui.d.ts",
|
|
31
|
+
"default": "./fesm2022/rivinia-modal-ui.mjs"
|
|
27
32
|
}
|
|
28
33
|
},
|
|
29
34
|
"type": "module",
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Injector, Signal } from "@angular/core";
|
|
3
|
+
import { ModalDismissOrigin, ModalInstance, ModalTemplateContext } from "@rivinia/modal";
|
|
4
|
+
/**
|
|
5
|
+
* Responsive size presets. Dimensions are ceilings, not mandates: every
|
|
6
|
+
* preset is a CSS custom property (`--rv-modal-width-*`) the consumer can
|
|
7
|
+
* override without touching library source. `auto` sizes to content.
|
|
8
|
+
*/
|
|
9
|
+
type RiviniaModalSize = 'sm' | 'md' | 'lg' | 'xl' | 'full' | 'auto';
|
|
10
|
+
/**
|
|
11
|
+
* Placement in the viewport. `start`/`end` are logical (RTL-aware).
|
|
12
|
+
* `fullscreen` covers the viewport (safe-area aware). `side-start` /
|
|
13
|
+
* `side-end` dock a full-height panel to the inline edge. Implemented with
|
|
14
|
+
* plain CSS on the native `<dialog>` — no positioning engine.
|
|
15
|
+
*
|
|
16
|
+
* Responsive sheet mapping (built in, no input needed): viewports narrower
|
|
17
|
+
* than 640px render `center`, `top`, `bottom` and the bottom corners as a
|
|
18
|
+
* bottom sheet (anchored, top-only radius, slide-from-bottom entrance).
|
|
19
|
+
* `fullscreen` and the side panels keep their shape on small screens.
|
|
20
|
+
*/
|
|
21
|
+
type RiviniaModalPosition = 'center' | 'top' | 'bottom' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'center-start' | 'center-end' | 'side-start' | 'side-end' | 'fullscreen';
|
|
22
|
+
/** Entrance/exit animation preset. `none` disables motion entirely. */
|
|
23
|
+
type RiviniaModalAnimation = 'fade' | 'scale' | 'slide-top' | 'slide-bottom' | 'slide-start' | 'slide-end' | 'none';
|
|
24
|
+
/** Backdrop click policy (mirrors the headless `ModalDismissPolicy`). */
|
|
25
|
+
type RiviniaModalBackdrop = 'close' | 'static' | 'disabled';
|
|
26
|
+
/**
|
|
27
|
+
* Visual + interaction options for {@link RiviniaModalDialog}. Independent
|
|
28
|
+
* knobs only — no `disableClose` bundle (Escape, backdrop and the close
|
|
29
|
+
* button stay separately configurable, like the headless policy).
|
|
30
|
+
*/
|
|
31
|
+
interface RiviniaModalUiOptions {
|
|
32
|
+
/** @default 'md' */
|
|
33
|
+
readonly size?: RiviniaModalSize;
|
|
34
|
+
/** @default 'center' */
|
|
35
|
+
readonly position?: RiviniaModalPosition;
|
|
36
|
+
/** @default 'scale' */
|
|
37
|
+
readonly animation?: RiviniaModalAnimation;
|
|
38
|
+
/** Escape requests dismissal via the configured path. @default true */
|
|
39
|
+
readonly closeOnEscape?: boolean;
|
|
40
|
+
/** Backdrop click behavior. @default 'close' */
|
|
41
|
+
readonly backdrop?: RiviniaModalBackdrop;
|
|
42
|
+
/** Render the header close button. @default true */
|
|
43
|
+
readonly showCloseButton?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Marker for custom header content. Put it on the element carrying
|
|
47
|
+
* `rv-modal-header` — its presence (not just the attribute) tells the
|
|
48
|
+
* dialog to hide the default title + close button:
|
|
49
|
+
*
|
|
50
|
+
* ```html
|
|
51
|
+
* <div rv-modal-header rvModalHeader>My header</div>
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare class RvModalHeader {
|
|
55
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RvModalHeader, never>;
|
|
56
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<RvModalHeader, "[rvModalHeader]", never, {}, {}, never, never, true, never>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Marker for custom footer content. Put it on the element carrying
|
|
60
|
+
* `rv-modal-footer`. Without it the footer region never renders.
|
|
61
|
+
*/
|
|
62
|
+
export declare class RvModalFooter {
|
|
63
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RvModalFooter, never>;
|
|
64
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<RvModalFooter, "[rvModalFooter]", never, {}, {}, never, never, true, never>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Ready-made modal dialog on the native `<dialog>` element (top layer,
|
|
68
|
+
* `::backdrop`, inert background, Escape `cancel` event — all platform
|
|
69
|
+
* behavior, zero overlay dependencies).
|
|
70
|
+
*
|
|
71
|
+
* UI-only by design: it owns its own `open` state and never imports the
|
|
72
|
+
* headless controller. Pair it with `@rivinia/modal` through
|
|
73
|
+
* {@link RiviniaModalHost} (or your own adapter) when you want managed
|
|
74
|
+
* lifecycle, guards and typed results.
|
|
75
|
+
*
|
|
76
|
+
* Projection: `[rv-modal-header]` replaces the default header (title +
|
|
77
|
+
* close button); default `<ng-content>` is the body; `[rv-modal-footer]`
|
|
78
|
+
* is optional and renders nothing when absent.
|
|
79
|
+
*/
|
|
80
|
+
export declare class RiviniaModalDialog {
|
|
81
|
+
/** Two-way open state. UI-only mode owns this; the host drives it in managed mode. */
|
|
82
|
+
readonly open: import("@angular/core").ModelSignal<boolean>;
|
|
83
|
+
readonly title: import("@angular/core").InputSignal<string>;
|
|
84
|
+
/**
|
|
85
|
+
* Supporting text under the title (shadcn-style description). Rendered in
|
|
86
|
+
* the default header only, and wired as the dialog's `aria-describedby`
|
|
87
|
+
* for free accessible naming. Empty = no description element at all.
|
|
88
|
+
*/
|
|
89
|
+
readonly description: import("@angular/core").InputSignal<string>;
|
|
90
|
+
/** Explicit accessible name. When set, `aria-label` wins over the title reference. */
|
|
91
|
+
readonly ariaLabel: import("@angular/core").InputSignal<string>;
|
|
92
|
+
readonly size: import("@angular/core").InputSignal<RiviniaModalSize>;
|
|
93
|
+
readonly position: import("@angular/core").InputSignal<RiviniaModalPosition>;
|
|
94
|
+
readonly animation: import("@angular/core").InputSignal<RiviniaModalAnimation>;
|
|
95
|
+
readonly closeOnEscape: import("@angular/core").InputSignal<boolean>;
|
|
96
|
+
readonly backdrop: import("@angular/core").InputSignal<RiviniaModalBackdrop>;
|
|
97
|
+
readonly showCloseButton: import("@angular/core").InputSignal<boolean>;
|
|
98
|
+
/**
|
|
99
|
+
* Managed mode (for {@link RiviniaModalHost}): UI intents (X button,
|
|
100
|
+
* Escape, backdrop) emit `dismissRequested` INSTEAD of dismissing, so the
|
|
101
|
+
* manager runs guards first and settles results. Drive the exit with the
|
|
102
|
+
* `closing` input; acknowledge teardown with `exitDone`.
|
|
103
|
+
* UI-only mode (`false`, default) dismisses locally.
|
|
104
|
+
*/
|
|
105
|
+
readonly managed: import("@angular/core").InputSignal<boolean>;
|
|
106
|
+
/**
|
|
107
|
+
* Managed-mode exit trigger. Set `true` when the manager reports this
|
|
108
|
+
* instance `closing`: the dialog plays its exit animation, then emits
|
|
109
|
+
* `exitDone` (call `confirmClosed()` there). Ignored in UI-only mode.
|
|
110
|
+
*/
|
|
111
|
+
readonly closing: import("@angular/core").InputSignal<boolean>;
|
|
112
|
+
/** Settled with a value (primary/confirm actions call `close(value)`). */
|
|
113
|
+
readonly confirmed: import("@angular/core").OutputEmitterRef<unknown>;
|
|
114
|
+
/** Settled without a value (X button, backdrop, Escape, `dismiss()`). */
|
|
115
|
+
readonly dismissed: import("@angular/core").OutputEmitterRef<string | undefined>;
|
|
116
|
+
/** Explicit cancellation (`cancel()`). Kept distinct from dismissal. */
|
|
117
|
+
readonly cancelled: import("@angular/core").OutputEmitterRef<string | undefined>;
|
|
118
|
+
/**
|
|
119
|
+
* Managed-mode intent (X button / Escape / backdrop). Emitted INSTEAD of
|
|
120
|
+
* dismissing — the host routes it to the manager first. Never emitted in
|
|
121
|
+
* UI-only mode.
|
|
122
|
+
*/
|
|
123
|
+
readonly dismissRequested: import("@angular/core").OutputEmitterRef<"button" | "escape" | "backdrop">;
|
|
124
|
+
/** Managed-mode exit completion. Acknowledge with `confirmClosed()`. */
|
|
125
|
+
readonly exitDone: import("@angular/core").OutputEmitterRef<void>;
|
|
126
|
+
private readonly dialog;
|
|
127
|
+
private readonly headerSlot;
|
|
128
|
+
private readonly footerSlot;
|
|
129
|
+
private readonly doc;
|
|
130
|
+
private readonly scrollLock;
|
|
131
|
+
private readonly titleId;
|
|
132
|
+
private readonly descriptionId;
|
|
133
|
+
private readonly phase;
|
|
134
|
+
private readonly invoker;
|
|
135
|
+
private exitTimer;
|
|
136
|
+
/** Template state for animation styling. Never rendered open on the server. */
|
|
137
|
+
readonly state: import("@angular/core").Signal<"closed" | "open" | "closing">;
|
|
138
|
+
readonly hasCustomHeader: import("@angular/core").Signal<boolean>;
|
|
139
|
+
readonly hasCustomFooter: import("@angular/core").Signal<boolean>;
|
|
140
|
+
readonly computedLabel: import("@angular/core").Signal<string | null>;
|
|
141
|
+
constructor();
|
|
142
|
+
/** Confirm with a value. No-op while closing/closed. */
|
|
143
|
+
confirm(value?: unknown): boolean;
|
|
144
|
+
/** Backwards-compatible close: confirms when given a value, dismisses otherwise. */
|
|
145
|
+
close(value?: unknown): boolean;
|
|
146
|
+
/** Dismiss without a value (X button, backdrop, Escape route here). */
|
|
147
|
+
dismiss(reason?: string): boolean;
|
|
148
|
+
/** Explicit cancellation. */
|
|
149
|
+
cancel(reason?: string): boolean;
|
|
150
|
+
protected onCloseButton(): void;
|
|
151
|
+
protected onCancel(event: Event): void;
|
|
152
|
+
protected onBackdropClick(event: MouseEvent): void;
|
|
153
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
154
|
+
private get live();
|
|
155
|
+
private show;
|
|
156
|
+
private hide;
|
|
157
|
+
private finish;
|
|
158
|
+
private teardown;
|
|
159
|
+
/** Plays the exit animation (when warranted), then runs `done`. Idempotent. */
|
|
160
|
+
private playExit;
|
|
161
|
+
private exitDurationMs;
|
|
162
|
+
private finalize;
|
|
163
|
+
private prefersMotion;
|
|
164
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RiviniaModalDialog, never>;
|
|
165
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<RiviniaModalDialog, "rv-modal-dialog", never, {
|
|
166
|
+
"open": {
|
|
167
|
+
"alias": "open";
|
|
168
|
+
"required": false;
|
|
169
|
+
"isSignal": true;
|
|
170
|
+
};
|
|
171
|
+
"title": {
|
|
172
|
+
"alias": "title";
|
|
173
|
+
"required": false;
|
|
174
|
+
"isSignal": true;
|
|
175
|
+
};
|
|
176
|
+
"description": {
|
|
177
|
+
"alias": "description";
|
|
178
|
+
"required": false;
|
|
179
|
+
"isSignal": true;
|
|
180
|
+
};
|
|
181
|
+
"ariaLabel": {
|
|
182
|
+
"alias": "ariaLabel";
|
|
183
|
+
"required": false;
|
|
184
|
+
"isSignal": true;
|
|
185
|
+
};
|
|
186
|
+
"size": {
|
|
187
|
+
"alias": "size";
|
|
188
|
+
"required": false;
|
|
189
|
+
"isSignal": true;
|
|
190
|
+
};
|
|
191
|
+
"position": {
|
|
192
|
+
"alias": "position";
|
|
193
|
+
"required": false;
|
|
194
|
+
"isSignal": true;
|
|
195
|
+
};
|
|
196
|
+
"animation": {
|
|
197
|
+
"alias": "animation";
|
|
198
|
+
"required": false;
|
|
199
|
+
"isSignal": true;
|
|
200
|
+
};
|
|
201
|
+
"closeOnEscape": {
|
|
202
|
+
"alias": "closeOnEscape";
|
|
203
|
+
"required": false;
|
|
204
|
+
"isSignal": true;
|
|
205
|
+
};
|
|
206
|
+
"backdrop": {
|
|
207
|
+
"alias": "backdrop";
|
|
208
|
+
"required": false;
|
|
209
|
+
"isSignal": true;
|
|
210
|
+
};
|
|
211
|
+
"showCloseButton": {
|
|
212
|
+
"alias": "showCloseButton";
|
|
213
|
+
"required": false;
|
|
214
|
+
"isSignal": true;
|
|
215
|
+
};
|
|
216
|
+
"managed": {
|
|
217
|
+
"alias": "managed";
|
|
218
|
+
"required": false;
|
|
219
|
+
"isSignal": true;
|
|
220
|
+
};
|
|
221
|
+
"closing": {
|
|
222
|
+
"alias": "closing";
|
|
223
|
+
"required": false;
|
|
224
|
+
"isSignal": true;
|
|
225
|
+
};
|
|
226
|
+
}, {
|
|
227
|
+
"open": "openChange";
|
|
228
|
+
"confirmed": "confirmed";
|
|
229
|
+
"dismissed": "dismissed";
|
|
230
|
+
"cancelled": "cancelled";
|
|
231
|
+
"dismissRequested": "dismissRequested";
|
|
232
|
+
"exitDone": "exitDone";
|
|
233
|
+
}, ["headerSlot", "footerSlot"], ["[rv-modal-header]", "*", "[rv-modal-footer]"], true, never>;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Managed adapter: renders every `visible()` instance of the headless
|
|
237
|
+
* `RiviniaModal` inside a {@link RiviniaModalDialog} and routes all UI
|
|
238
|
+
* intents through the manager first (guards run; results settle in Core —
|
|
239
|
+
* the single source of truth). The dialog never settles anything itself in
|
|
240
|
+
* this mode; listen to `ModalHandle.result`, not dialog outputs.
|
|
241
|
+
*
|
|
242
|
+
* Exit coordination: when Core reports an instance `closing`, the dialog
|
|
243
|
+
* plays its exit animation and the host acknowledges with `confirmClosed()`
|
|
244
|
+
* (idempotent — safe if `closingTimeout` auto-finalized first). Match
|
|
245
|
+
* `closingTimeout` to the animation duration so exits stay visible.
|
|
246
|
+
*
|
|
247
|
+
* Title resolution: `titleOf` per instance (default: `metadata.title` →
|
|
248
|
+
* `ref` → `''`). Content descriptors render as-is: templates via
|
|
249
|
+
* `ngTemplateOutlet` with `{$implicit: data, modal}`, components via
|
|
250
|
+
* `NgComponentOutlet` with `inputs` + a per-instance
|
|
251
|
+
* `RIVINIA_MODAL_CONTEXT` injector (the lab-proven pattern).
|
|
252
|
+
*
|
|
253
|
+
* The manager arrives via `[modal]` input (D06 input-composition: the UI
|
|
254
|
+
* entry never instantiates Core itself, so UI-only consumers pay nothing).
|
|
255
|
+
* The input is typed as {@link RiviniaModalHostManager} — the structural
|
|
256
|
+
* slice the host actually drives — so the full manager (or a test double)
|
|
257
|
+
* satisfies it from any module realm:
|
|
258
|
+
*
|
|
259
|
+
* ```html
|
|
260
|
+
* <rv-modal-host [modal]="injectRiviniaModal()" />
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
interface RiviniaModalHostManager {
|
|
264
|
+
readonly visible: Signal<readonly ModalInstance<unknown>[]>;
|
|
265
|
+
requestDismiss(id: string, origin: ModalDismissOrigin): Promise<boolean>;
|
|
266
|
+
confirmClosed(id: string): boolean;
|
|
267
|
+
close(id: string, value?: unknown): boolean;
|
|
268
|
+
dismiss(id: string, reason?: string): boolean;
|
|
269
|
+
}
|
|
270
|
+
export declare class RiviniaModalHost {
|
|
271
|
+
/**
|
|
272
|
+
* The headless manager to render. Typed as {@link RiviniaModalHostManager}
|
|
273
|
+
* (structural) — pass `injectRiviniaModal()` from your app code.
|
|
274
|
+
*/
|
|
275
|
+
readonly modal: import("@angular/core").InputSignal<RiviniaModalHostManager>;
|
|
276
|
+
/** Dialog size for every managed instance. @default 'md' */
|
|
277
|
+
readonly size: import("@angular/core").InputSignal<RiviniaModalSize>;
|
|
278
|
+
/** Render the header close button on every managed instance. @default true */
|
|
279
|
+
readonly showCloseButton: import("@angular/core").InputSignal<boolean>;
|
|
280
|
+
/** Resolve a title per instance. Default: `metadata.title` → `ref` → `''`. */
|
|
281
|
+
readonly titleOf: import("@angular/core").InputSignal<((instance: ModalInstance<unknown>) => string | undefined) | undefined>;
|
|
282
|
+
protected readonly visible: Signal<readonly ModalInstance<unknown>[]>;
|
|
283
|
+
protected titleOfInstance(instance: ModalInstance<unknown>): string;
|
|
284
|
+
protected templateContext(instance: ModalInstance<unknown>): ModalTemplateContext<unknown>;
|
|
285
|
+
protected contextInjector(instance: ModalInstance<unknown>): Injector;
|
|
286
|
+
protected onIntent(id: string, origin: 'button' | 'escape' | 'backdrop'): Promise<void>;
|
|
287
|
+
protected onExitDone(id: string): void;
|
|
288
|
+
private modalContext;
|
|
289
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RiviniaModalHost, never>;
|
|
290
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<RiviniaModalHost, "rv-modal-host", never, {
|
|
291
|
+
"modal": {
|
|
292
|
+
"alias": "modal";
|
|
293
|
+
"required": true;
|
|
294
|
+
"isSignal": true;
|
|
295
|
+
};
|
|
296
|
+
"size": {
|
|
297
|
+
"alias": "size";
|
|
298
|
+
"required": false;
|
|
299
|
+
"isSignal": true;
|
|
300
|
+
};
|
|
301
|
+
"showCloseButton": {
|
|
302
|
+
"alias": "showCloseButton";
|
|
303
|
+
"required": false;
|
|
304
|
+
"isSignal": true;
|
|
305
|
+
};
|
|
306
|
+
"titleOf": {
|
|
307
|
+
"alias": "titleOf";
|
|
308
|
+
"required": false;
|
|
309
|
+
"isSignal": true;
|
|
310
|
+
};
|
|
311
|
+
}, {}, never, never, true, never>;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Reference-counted background scroll lock. Multiple overlays share one lock:
|
|
315
|
+
* closing one modal never unlocks the page while another still needs it.
|
|
316
|
+
* Restores the exact previous `overflow` value (never blanks app-owned
|
|
317
|
+
* styles). All DOM access happens inside methods — never at module
|
|
318
|
+
* evaluation — and every method is a no-op without a document (SSR).
|
|
319
|
+
*/
|
|
320
|
+
export declare class RiviniaModalScrollLock {
|
|
321
|
+
private readonly _doc;
|
|
322
|
+
private _locks;
|
|
323
|
+
private _previousOverflow;
|
|
324
|
+
/** Number of active locks (diagnostics/tests). */
|
|
325
|
+
get active(): number;
|
|
326
|
+
acquire(): void;
|
|
327
|
+
release(): void;
|
|
328
|
+
private get document();
|
|
329
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RiviniaModalScrollLock, never>;
|
|
330
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
331
|
+
}
|
|
332
|
+
export type { RiviniaModalAnimation, RiviniaModalBackdrop, RiviniaModalHostManager, RiviniaModalPosition, RiviniaModalSize, RiviniaModalUiOptions };
|