Skip to content

Commit 451d7c0

Browse files
committed
feat: migrate components in select to runes
1 parent a82d923 commit 451d7c0

20 files changed

+424
-263
lines changed

MIGRATING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This doc contains information that will help you migrate your code from an older
1212
- Slots must be migrated to snippets.
1313
- The deprecated "MDC" events have been removed. All event names should be migrated to the corresponding "SMUI" event names.
1414
- The "Fixation" theme now uses Tahoma as its large header font.
15+
- Select no longer defaults the value to an empty string, meaning you must either set the value given to it to an empty string or provide a key function that returns an empty string for an undefined value.
1516

1617
## Changes
1718

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ Svelte 5 Runes mode is being migrated to slowly. This is the todo list of compon
175175
- [x] Notched Outline
176176
- [x] Radio Button
177177
- [ ] Segmented Button
178-
- [ ] Select Menu
179-
- [ ] Select Helper Text
180-
- [ ] Select Icon
178+
- [x] Select Menu
179+
- [x] Select Helper Text
180+
- [x] Select Icon
181181
- [x] Slider
182182
- [x] Switch
183183
- [x] Text Field

packages/select/src/HelperFragment.svelte

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/select/src/Option.svelte

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,54 @@
1-
<svelte:options runes={false} />
1+
<svelte:options runes />
22

33
<Item
44
bind:this={element}
55
{use}
66
data-value={value}
77
{value}
88
{selected}
9-
{...$$restProps}><slot /></Item
9+
{...restProps}>{@render children?.()}</Item
1010
>
1111

1212
<script lang="ts">
13-
import type { ComponentProps } from 'svelte';
13+
import type { ComponentProps, Snippet } from 'svelte';
1414
import { onMount, onDestroy, getContext, setContext } from 'svelte';
1515
import type { Writable } from 'svelte/store';
1616
import type { ActionArray } from '@smui/common/internal';
1717
import { Item } from '@smui/list';
1818
1919
type OwnProps = {
20+
/**
21+
* An array of Action or [Action, ActionProps] to be applied to the element.
22+
*/
2023
use?: ActionArray;
24+
/**
25+
* A space separated list of CSS classes.
26+
*/
2127
class?: string;
28+
/**
29+
* The value of the input.
30+
*/
2231
value?: any;
23-
};
24-
type $$Props = OwnProps & Omit<ComponentProps<typeof Item>, keyof OwnProps>;
2532
26-
export let use: ActionArray = [];
27-
const className = '';
28-
export { className as class };
29-
export let value: any = '';
33+
children?: Snippet;
34+
};
35+
let {
36+
use = [],
37+
class: className = '',
38+
value = '',
39+
children,
40+
...restProps
41+
}: OwnProps & Omit<ComponentProps<typeof Item>, keyof OwnProps> = $props();
3042
3143
let element: Item;
3244
const selectedText = getContext<Writable<string>>('SMUI:select:selectedText');
3345
const selectedValue = getContext<SvelteStore<any>>('SMUI:select:value');
3446
3547
setContext('SMUI:list:item:role', 'option');
3648
37-
$: selected = value != null && value !== '' && $selectedValue === value;
49+
const selected = $derived(
50+
value != null && value !== '' && $selectedValue === value,
51+
);
3852
3953
onMount(setSelectedText);
4054

0 commit comments

Comments
 (0)