Skip to content

Commit 7e11707

Browse files
authored
Pass ids as slot props to components with managed ids (#147)
1 parent 8c2e35f commit 7e11707

File tree

10 files changed

+32
-23
lines changed

10 files changed

+32
-23
lines changed

.changeset/gorgeous-beans-draw.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"bits-ui": patch
3+
---
4+
5+
Pass ids as slot props to components with managed ids

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"types": "./dist/index.d.ts",
8787
"type": "module",
8888
"dependencies": {
89-
"@melt-ui/svelte": "0.57.0",
89+
"@melt-ui/svelte": "0.57.1",
9090
"nanoid": "^5.0.2"
9191
},
9292
"peerDependencies": {

pnpm-lock.yaml

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/bits/context-menu/components/ContextMenu.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
2121
const {
2222
states: { open: localOpen },
23-
updateOption
23+
updateOption,
24+
ids
2425
} = setCtx({
2526
closeOnOutsideClick,
2627
closeOnEscape,
@@ -60,4 +61,4 @@
6061
$: updateOption("typeahead", typeahead);
6162
</script>
6263

63-
<slot />
64+
<slot {ids} />

src/lib/bits/context-menu/components/ContextMenuSub.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
export let disabled: $$Props["disabled"] = undefined;
88
export let arrowSize: $$Props["arrowSize"] = undefined;
99
10-
const { updateOption } = setSubMenuCtx({
10+
const { updateOption, ids } = setSubMenuCtx({
1111
positioning,
1212
disabled,
1313
arrowSize
@@ -18,4 +18,4 @@
1818
$: updateOption("arrowSize", arrowSize);
1919
</script>
2020

21-
<slot />
21+
<slot subIds={ids} />

src/lib/bits/dropdown-menu/components/DropdownMenu.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
2121
const {
2222
states: { open: localOpen },
23-
updateOption
23+
updateOption,
24+
ids
2425
} = setCtx({
2526
closeOnOutsideClick,
2627
closeOnEscape,
@@ -59,4 +60,4 @@
5960
$: updateOption("typeahead", typeahead);
6061
</script>
6162

62-
<slot />
63+
<slot {ids} />

src/lib/bits/dropdown-menu/components/DropdownMenuSub.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
export let disabled: $$Props["disabled"] = undefined;
88
export let arrowSize: $$Props["arrowSize"] = undefined;
99
10-
const { updateOption } = setSubMenuCtx({
10+
const { updateOption, ids } = setSubMenuCtx({
1111
positioning,
1212
disabled,
1313
arrowSize
@@ -18,4 +18,4 @@
1818
$: updateOption("arrowSize", arrowSize);
1919
</script>
2020

21-
<slot />
21+
<slot subIds={ids} />

src/lib/bits/menubar/components/Menubar.svelte

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
1212
const {
1313
elements: { menubar },
14-
updateOption
14+
updateOption,
15+
ids
1516
} = setCtx({ loop, closeOnEscape });
1617
1718
$: updateOption("loop", loop);
@@ -21,9 +22,9 @@
2122
</script>
2223

2324
{#if asChild}
24-
<slot {builder} {attrs} />
25+
<slot {builder} {attrs} {ids} />
2526
{:else}
2627
<div use:melt={builder} {...$$restProps} {...attrs}>
27-
<slot {builder} {attrs} />
28+
<slot {builder} {attrs} {ids} />
2829
</div>
2930
{/if}

src/lib/bits/menubar/components/MenubarMenu.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
2020
const {
2121
states: { open: localOpen },
22-
updateOption
22+
updateOption,
23+
ids
2324
} = setMenuCtx({
2425
closeOnOutsideClick,
2526
closeOnEscape,
@@ -55,4 +56,4 @@
5556
$: updateOption("typeahead", typeahead);
5657
</script>
5758

58-
<slot />
59+
<slot menuIds={ids} />

src/lib/bits/menubar/components/MenubarSub.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
export let disabled: $$Props["disabled"] = undefined;
88
export let arrowSize: $$Props["arrowSize"] = undefined;
99
10-
const { updateOption } = setSubMenuCtx({
10+
const { updateOption, ids } = setSubMenuCtx({
1111
positioning,
1212
disabled,
1313
arrowSize
@@ -18,4 +18,4 @@
1818
$: updateOption("arrowSize", arrowSize);
1919
</script>
2020

21-
<slot />
21+
<slot subIds={ids} />

0 commit comments

Comments
 (0)