-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
134 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"vaul-svelte": patch | ||
--- | ||
|
||
fix: closing and focus restoration issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,6 @@ | |
"types": "./dist/index.d.ts", | ||
"type": "module", | ||
"dependencies": { | ||
"bits-ui": "^0.13.0" | ||
"bits-ui": "^0.13.3" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script lang="ts"> | ||
import { Dialog as DialogPrimitive } from 'bits-ui'; | ||
import type { CloseProps } from './types.js'; | ||
import { getCtx } from '../ctx.js'; | ||
type $$Props = CloseProps; | ||
export let el: $$Props['el'] = undefined; | ||
const { | ||
methods: { closeDrawer } | ||
} = getCtx(); | ||
</script> | ||
|
||
<DialogPrimitive.Close | ||
bind:el | ||
on:click={(e) => { | ||
e.preventDefault(); | ||
closeDrawer(); | ||
}} | ||
on:keydown={(e) => { | ||
if (e.detail.originalEvent.key === 'Enter' || e.detail.originalEvent.key === ' ') { | ||
e.preventDefault(); | ||
closeDrawer(true); | ||
} | ||
}} | ||
{...$$restProps} | ||
> | ||
<slot /> | ||
</DialogPrimitive.Close> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script lang="ts"> | ||
// This is kinda weird but we need to be able to pass the builder down somehow | ||
// if someone uses `asChild` to modify it. Since it's only exposed as a slot prop | ||
// we need something in between the `<DialogPrimitive.Trigger>` and the slot | ||
import type { Builder } from '$lib/internal/types.js'; | ||
import { getCtx } from '../ctx.js'; | ||
export let meltBuilder: Builder; | ||
const { | ||
refs: { triggerRef } | ||
} = getCtx(); | ||
$: ({ action, ...rest } = meltBuilder); | ||
// We're wrapping the melt action so we can set the triggerRef | ||
// even if a user is using `asChild` | ||
const wrappedAction = (node: HTMLElement) => { | ||
triggerRef.set(node as HTMLButtonElement); | ||
return action(node); | ||
}; | ||
$: Object.assign(rest, { | ||
action: wrappedAction | ||
}); | ||
</script> | ||
|
||
<slot newBuilder={rest} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script lang="ts"> | ||
import { Dialog as DialogPrimitive } from 'bits-ui'; | ||
import TriggerWrapper from './trigger-wrapper.svelte'; | ||
import { getCtx } from '../ctx.js'; | ||
type $$Props = DialogPrimitive.TriggerProps; | ||
type $$Events = DialogPrimitive.TriggerEvents; | ||
const { | ||
refs: { triggerRef } | ||
} = getCtx(); | ||
export let el: HTMLButtonElement | undefined = undefined; | ||
export let asChild: boolean = false; | ||
$: if (el) { | ||
triggerRef.set(el); | ||
} | ||
</script> | ||
|
||
{#if asChild} | ||
<DialogPrimitive.Trigger {asChild} let:builder on:click on:keydown bind:el {...$$restProps}> | ||
<TriggerWrapper meltBuilder={builder} let:newBuilder> | ||
<slot builder={newBuilder} /> | ||
</TriggerWrapper> | ||
</DialogPrimitive.Trigger> | ||
{:else} | ||
<DialogPrimitive.Trigger let:builder on:click on:keydown bind:el {...$$restProps}> | ||
<slot {builder} /> | ||
</DialogPrimitive.Trigger> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters