Skip to content

Commit

Permalink
pass ids as slot props to builders
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Oct 27, 2023
1 parent 8c2e35f commit 7223bfb
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"types": "./dist/index.d.ts",
"type": "module",
"dependencies": {
"@melt-ui/svelte": "0.57.0",
"@melt-ui/svelte": "0.57.1",
"nanoid": "^5.0.2"
},
"peerDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/lib/bits/context-menu/components/ContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
const {
states: { open: localOpen },
updateOption
updateOption,
ids
} = setCtx({
closeOnOutsideClick,
closeOnEscape,
Expand Down Expand Up @@ -60,4 +61,4 @@
$: updateOption("typeahead", typeahead);
</script>

<slot />
<slot {ids} />
4 changes: 2 additions & 2 deletions src/lib/bits/context-menu/components/ContextMenuSub.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export let disabled: $$Props["disabled"] = undefined;
export let arrowSize: $$Props["arrowSize"] = undefined;
const { updateOption } = setSubMenuCtx({
const { updateOption, ids } = setSubMenuCtx({
positioning,
disabled,
arrowSize
Expand All @@ -18,4 +18,4 @@
$: updateOption("arrowSize", arrowSize);
</script>

<slot />
<slot subIds={ids} />
5 changes: 3 additions & 2 deletions src/lib/bits/dropdown-menu/components/DropdownMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
const {
states: { open: localOpen },
updateOption
updateOption,
ids
} = setCtx({
closeOnOutsideClick,
closeOnEscape,
Expand Down Expand Up @@ -59,4 +60,4 @@
$: updateOption("typeahead", typeahead);
</script>

<slot />
<slot {ids} />
4 changes: 2 additions & 2 deletions src/lib/bits/dropdown-menu/components/DropdownMenuSub.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export let disabled: $$Props["disabled"] = undefined;
export let arrowSize: $$Props["arrowSize"] = undefined;
const { updateOption } = setSubMenuCtx({
const { updateOption, ids } = setSubMenuCtx({
positioning,
disabled,
arrowSize
Expand All @@ -18,4 +18,4 @@
$: updateOption("arrowSize", arrowSize);
</script>

<slot />
<slot subIds={ids} />
7 changes: 4 additions & 3 deletions src/lib/bits/menubar/components/Menubar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
const {
elements: { menubar },
updateOption
updateOption,
ids
} = setCtx({ loop, closeOnEscape });
$: updateOption("loop", loop);
Expand All @@ -21,9 +22,9 @@
</script>

{#if asChild}
<slot {builder} {attrs} />
<slot {builder} {attrs} {ids} />
{:else}
<div use:melt={builder} {...$$restProps} {...attrs}>
<slot {builder} {attrs} />
<slot {builder} {attrs} {ids} />
</div>
{/if}
5 changes: 3 additions & 2 deletions src/lib/bits/menubar/components/MenubarMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
const {
states: { open: localOpen },
updateOption
updateOption,
ids
} = setMenuCtx({
closeOnOutsideClick,
closeOnEscape,
Expand Down Expand Up @@ -55,4 +56,4 @@
$: updateOption("typeahead", typeahead);
</script>

<slot />
<slot menuIds={ids} />
4 changes: 2 additions & 2 deletions src/lib/bits/menubar/components/MenubarSub.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export let disabled: $$Props["disabled"] = undefined;
export let arrowSize: $$Props["arrowSize"] = undefined;
const { updateOption } = setSubMenuCtx({
const { updateOption, ids } = setSubMenuCtx({
positioning,
disabled,
arrowSize
Expand All @@ -18,4 +18,4 @@
$: updateOption("arrowSize", arrowSize);
</script>

<slot />
<slot subIds={ids} />

0 comments on commit 7223bfb

Please sign in to comment.