dialog: pass state to snippet overrides
This commit is contained in:
@@ -112,9 +112,9 @@
|
||||
/** Bindable open state of the dialog */
|
||||
open?: boolean;
|
||||
/** Title of the dialog */
|
||||
title: string | Snippet;
|
||||
title: string | Snippet<[state: DialogState]>;
|
||||
/** Description of the dialog, optionally rendered below the title */
|
||||
description?: string | Snippet;
|
||||
description?: string | Snippet<[state: DialogState]>;
|
||||
/** Size of the dialog (default: 'sm') */
|
||||
size?: 'sm' | 'md' | 'lg' | 'max';
|
||||
/** Additional classes for the dialog */
|
||||
@@ -122,7 +122,7 @@
|
||||
/** Content of the dialog */
|
||||
children?: Snippet;
|
||||
/** Bottom controls for the dialog */
|
||||
controls?: Snippet | DialogControls;
|
||||
controls?: Snippet<[state: DialogState]> | DialogControls;
|
||||
/** Sets bottom alignment of controls (default: end) */
|
||||
controlsAlign?: 'start' | 'center' | 'end';
|
||||
/** Top-right close control */
|
||||
@@ -342,7 +342,9 @@
|
||||
controlsAlign === 'end' && 'justify-end'
|
||||
]}
|
||||
>
|
||||
{#if controls && typeof controls === 'function'}{@render controls()}{:else if controls?.flip}
|
||||
{#if controls && typeof controls === 'function'}{@render controls(
|
||||
getState()
|
||||
)}{:else if controls?.flip}
|
||||
{#if controls.ok !== null}
|
||||
{@render dialogOkButton(getState(), controls.ok)}
|
||||
{/if}
|
||||
@@ -417,10 +419,10 @@
|
||||
</button>
|
||||
{/snippet}
|
||||
|
||||
{#snippet stringOrSnippet(val: string | Snippet)}
|
||||
{#snippet stringOrSnippet(val: string | Snippet<[state: DialogState]>)}
|
||||
{#if typeof val === 'string'}
|
||||
{val}
|
||||
{:else}
|
||||
{@render val()}
|
||||
{@render val(getState())}
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
Reference in New Issue
Block a user