-
-
Notifications
You must be signed in to change notification settings - Fork 279
Expand file tree
/
Copy path_Selection.svelte
More file actions
63 lines (58 loc) · 1.56 KB
/
_Selection.svelte
File metadata and controls
63 lines (58 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<Dialog
bind:open
selection
aria-labelledby="list-selection-title"
aria-describedby="list-selection-content"
onSMUIDialogClosed={closeHandler}
>
<Title id="list-selection-title">Dialog Title</Title>
<Content id="list-selection-content">
<List radioList>
<Item use={[InitialFocus]}>
<Graphic>
<Radio bind:group={selection} value="Radishes" />
</Graphic>
<Text>Radishes</Text>
</Item>
<Item>
<Graphic>
<Radio bind:group={selection} value="Turnips" />
</Graphic>
<Text>Turnips</Text>
</Item>
<Item>
<Graphic>
<Radio bind:group={selection} value="Broccoli" />
</Graphic>
<Text>Broccoli</Text>
</Item>
</List>
</Content>
<Actions>
<Button>
<Label>Cancel</Label>
</Button>
<Button action="accept">
<Label>Accept</Label>
</Button>
</Actions>
</Dialog>
<Button onclick={() => (open = true)}>
<Label>Open Dialog</Label>
</Button>
<pre class="status">Selected: {selected}</pre>
<script lang="ts">
import Dialog, { Title, Content, Actions, InitialFocus } from '@smui/dialog';
import Button, { Label } from '@smui/button';
import List, { Item, Graphic, Text } from '@smui/list';
import Radio from '@smui/radio';
let open = $state(false);
let selection = $state('Radishes');
let selected = $state('Nothing yet.');
function closeHandler(e: CustomEvent<{ action: string }>) {
if (e.detail.action === 'accept') {
selected = selection;
}
selection = 'Radishes';
}
</script>