import '../nui-heading/nui-heading.js'; import '../nui-icon/nui-icon.js'; import { html, nothing, type TemplateResult } from 'lit'; import type { NuiType } from '../../types/nui-type.js'; import type { DialogPosition } from './types.js'; export interface NuiDialogViewState { visible: boolean; header: string; footer: string; modal: boolean; closable: boolean; dismissableMask: boolean; position: DialogPosition; width: string; dialogClass: string; nuiType: NuiType; hasHeaderSlot: boolean; hasFooterSlot: boolean; } export interface DialogRenderHandlers { onDialogClick: (event: Event) => void; onDialogClose: (event: Event) => void; onDialogCancel: (event: Event) => void; onCloseClick: (event: Event) => void; onHeaderSlotChange: (event: Event) => void; onFooterSlotChange: (event: Event) => void; } export function getDialogClass(dialogClass: string): string { return ['nui-dialog', dialogClass].filter(Boolean).join(' '); } function shouldShowHeader(state: NuiDialogViewState): boolean { return Boolean(state.header || state.hasHeaderSlot || state.closable); } function shouldShowFooter(state: NuiDialogViewState): boolean { return Boolean(state.footer || state.hasFooterSlot); } export function renderDialog( state: NuiDialogViewState, handlers: DialogRenderHandlers, ): TemplateResult { const showHeader = shouldShowHeader(state); const showFooter = shouldShowFooter(state); return html`
event.stopPropagation()}>
${ state.header ? html` ` : nothing }
${ state.closable ? html` ` : nothing }
`; }