dialog: add dialog api & detailed controls config, fix outer click

This commit is contained in:
Elijah Duffy
2025-07-16 17:41:56 -07:00
parent 20c1a4fa89
commit ee922b49ee
3 changed files with 140 additions and 37 deletions

View File

@@ -29,7 +29,7 @@
TextStrikethrough,
TextUnderline
} from 'phosphor-svelte';
import type { ComboboxOption, Option } from '$lib';
import { ErrorMessage, type ComboboxOption, type Option } from '$lib';
import Tabs from '$lib/Tabs.svelte';
const comboboxOptions = [
@@ -408,9 +408,20 @@
bind:open={dialogOpen}
title="Dialog Title"
size="sm"
onsubmit={() => {
dialogOpen = false;
alert('Dialog submitted!');
controls={{
ok: {
action: (dialog) => {
dialog.close();
alert('Dialog submitted!');
}
}
}}
onopen={(dialog) => {
dialog.error(ErrorMessage.from('Example error message!'));
dialog.loading();
setTimeout(() => {
dialog.loaded();
}, 2000);
}}
>
<p>This is a dialog content area.</p>