-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
129 changed files
with
3,960 additions
and
796 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
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
34 changes: 34 additions & 0 deletions
34
packages/bits-ui/src/lib/bits/alert-dialog/components/alert-dialog-action.svelte
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,34 @@ | ||
<script lang="ts"> | ||
import { box } from "svelte-toolbelt"; | ||
import type { ActionProps } from "../index.js"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
import { useId } from "$lib/internal/useId.js"; | ||
import { useDialogClose } from "$lib/bits/dialog/dialog.svelte.js"; | ||
let { | ||
children, | ||
child, | ||
id = useId(), | ||
ref = $bindable(null), | ||
...restProps | ||
}: ActionProps = $props(); | ||
const closeState = useDialogClose({ | ||
variant: box.with(() => "action"), | ||
id: box.with(() => id), | ||
ref: box.with( | ||
() => ref, | ||
(v) => (ref = v) | ||
), | ||
}); | ||
const mergedProps = $derived(mergeProps(restProps, closeState.props)); | ||
</script> | ||
|
||
{#if child} | ||
{@render child({ props: mergedProps })} | ||
{:else} | ||
<button {...mergedProps}> | ||
{@render children?.()} | ||
</button> | ||
{/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
30 changes: 30 additions & 0 deletions
30
packages/bits-ui/src/lib/bits/alert-dialog/components/alert-dialog.svelte
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 { box } from "svelte-toolbelt"; | ||
import type { RootProps } from "../index.js"; | ||
import { noop } from "$lib/internal/callbacks.js"; | ||
import { useDialogRoot } from "$lib/bits/dialog/dialog.svelte.js"; | ||
let { | ||
open = $bindable(false), | ||
onOpenChange = noop, | ||
controlledOpen = false, | ||
children, | ||
}: RootProps = $props(); | ||
useDialogRoot({ | ||
variant: box.with(() => "alert-dialog"), | ||
open: box.with( | ||
() => open, | ||
(v) => { | ||
if (controlledOpen) { | ||
onOpenChange(v); | ||
} else { | ||
open = v; | ||
onOpenChange(v); | ||
} | ||
} | ||
), | ||
}); | ||
</script> | ||
|
||
{@render children?.()} |
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
46 changes: 46 additions & 0 deletions
46
packages/bits-ui/src/lib/bits/context-menu/components/context-menu.svelte
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,46 @@ | ||
<script lang="ts"> | ||
import { box } from "svelte-toolbelt"; | ||
import type { RootProps } from "../index.js"; | ||
import { FloatingLayer } from "$lib/bits/utilities/floating-layer/index.js"; | ||
import { noop } from "$lib/internal/callbacks.js"; | ||
import { useMenuMenu, useMenuRoot } from "$lib/bits/menu/menu.svelte.js"; | ||
let { | ||
open = $bindable(false), | ||
dir = "ltr", | ||
onOpenChange = noop, | ||
controlledOpen = false, | ||
children, | ||
}: RootProps = $props(); | ||
const root = useMenuRoot({ | ||
variant: box.with(() => "context-menu"), | ||
dir: box.with(() => dir), | ||
onClose: () => { | ||
if (controlledOpen) { | ||
onOpenChange(false); | ||
} else { | ||
open = false; | ||
onOpenChange?.(false); | ||
} | ||
}, | ||
}); | ||
useMenuMenu(root, { | ||
open: box.with( | ||
() => open, | ||
(v) => { | ||
if (controlledOpen) { | ||
onOpenChange(v); | ||
} else { | ||
open = v; | ||
onOpenChange(v); | ||
} | ||
} | ||
), | ||
}); | ||
</script> | ||
|
||
<FloatingLayer.Root> | ||
{@render children?.()} | ||
</FloatingLayer.Root> |
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
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
Oops, something went wrong.