@johly/vaul-svelte 1.0.0-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +10 -0
- package/README.md +58 -0
- package/dist/components/drawer/drawer-content.svelte +60 -0
- package/dist/components/drawer/drawer-content.svelte.d.ts +5 -0
- package/dist/components/drawer/drawer-handle.svelte +31 -0
- package/dist/components/drawer/drawer-handle.svelte.d.ts +4 -0
- package/dist/components/drawer/drawer-nested.svelte +37 -0
- package/dist/components/drawer/drawer-nested.svelte.d.ts +3 -0
- package/dist/components/drawer/drawer-overlay.svelte +32 -0
- package/dist/components/drawer/drawer-overlay.svelte.d.ts +5 -0
- package/dist/components/drawer/drawer-portal.svelte +10 -0
- package/dist/components/drawer/drawer-portal.svelte.d.ts +3 -0
- package/dist/components/drawer/drawer.svelte +383 -0
- package/dist/components/drawer/drawer.svelte.d.ts +3 -0
- package/dist/components/drawer/index.d.ts +12 -0
- package/dist/components/drawer/index.js +11 -0
- package/dist/components/drawer/types.d.ts +126 -0
- package/dist/components/drawer/types.js +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/utils/mounted.svelte +12 -0
- package/dist/components/utils/mounted.svelte.d.ts +6 -0
- package/dist/context.d.ts +42 -0
- package/dist/context.js +2 -0
- package/dist/helpers.d.ts +16 -0
- package/dist/helpers.js +95 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/internal/browser.d.ts +8 -0
- package/dist/internal/browser.js +30 -0
- package/dist/internal/constants.d.ts +11 -0
- package/dist/internal/constants.js +11 -0
- package/dist/internal/noop.d.ts +1 -0
- package/dist/internal/noop.js +3 -0
- package/dist/internal/use-id.d.ts +4 -0
- package/dist/internal/use-id.js +8 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.js +1 -0
- package/dist/use-drawer-content.svelte.js +187 -0
- package/dist/use-drawer-handle.svelte.d.ts +18 -0
- package/dist/use-drawer-handle.svelte.js +83 -0
- package/dist/use-drawer-overlay.svelte.d.ts +15 -0
- package/dist/use-drawer-overlay.svelte.js +40 -0
- package/dist/use-drawer-root.svelte.js +575 -0
- package/dist/use-position-fixed.svelte.d.ts +20 -0
- package/dist/use-position-fixed.svelte.js +114 -0
- package/dist/use-prevent-scroll.svelte.d.ts +15 -0
- package/dist/use-prevent-scroll.svelte.js +235 -0
- package/dist/use-scale-background.svelte.d.ts +1 -0
- package/dist/use-scale-background.svelte.js +57 -0
- package/dist/use-snap-points.svelte.d.ts +34 -0
- package/dist/use-snap-points.svelte.js +260 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Hunter Johnston
|
|
4
|
+
Copyright (c) 2023 Emil Kowalski
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# create-svelte
|
|
2
|
+
|
|
3
|
+
Everything you need to build a Svelte library, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
|
|
4
|
+
|
|
5
|
+
Read more about creating a library [in the docs](https://kit.svelte.dev/docs/packaging).
|
|
6
|
+
|
|
7
|
+
## Creating a project
|
|
8
|
+
|
|
9
|
+
If you're seeing this, you've probably already done this step. Congrats!
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# create a new project in the current directory
|
|
13
|
+
npm create svelte@latest
|
|
14
|
+
|
|
15
|
+
# create a new project in my-app
|
|
16
|
+
npm create svelte@latest my-app
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Developing
|
|
20
|
+
|
|
21
|
+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm run dev
|
|
25
|
+
|
|
26
|
+
# or start the server and open the app in a new browser tab
|
|
27
|
+
npm run dev -- --open
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
|
|
31
|
+
|
|
32
|
+
## Building
|
|
33
|
+
|
|
34
|
+
To build your library:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm run package
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
To create a production version of your showcase app:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm run build
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can preview the production build with `npm run preview`.
|
|
47
|
+
|
|
48
|
+
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|
|
49
|
+
|
|
50
|
+
## Publishing
|
|
51
|
+
|
|
52
|
+
Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
|
|
53
|
+
|
|
54
|
+
To publish your library to [npm](https://www.npmjs.com):
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm publish
|
|
58
|
+
```
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Dialog as DialogPrimitive, type WithoutChildrenOrChild } from "bits-ui";
|
|
3
|
+
import { type WithChildren, box, mergeProps } from "svelte-toolbelt";
|
|
4
|
+
import type { ContentProps } from "./index.js";
|
|
5
|
+
import { noop } from "../../internal/noop.js";
|
|
6
|
+
import { useId } from "../../internal/use-id.js";
|
|
7
|
+
import { useDrawerContent } from "../../use-drawer-content.svelte.js";
|
|
8
|
+
import Mounted from "../utils/mounted.svelte";
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
id = useId(),
|
|
12
|
+
ref = $bindable(null),
|
|
13
|
+
onOpenAutoFocus = noop,
|
|
14
|
+
onInteractOutside = noop,
|
|
15
|
+
onFocusOutside = noop,
|
|
16
|
+
oncontextmenu = noop,
|
|
17
|
+
onpointerdown = noop,
|
|
18
|
+
onpointerup = noop,
|
|
19
|
+
onpointerout = noop,
|
|
20
|
+
onpointermove = noop,
|
|
21
|
+
children,
|
|
22
|
+
...restProps
|
|
23
|
+
}: WithChildren<WithoutChildrenOrChild<ContentProps>> = $props();
|
|
24
|
+
|
|
25
|
+
const contentState = useDrawerContent({
|
|
26
|
+
id: box.with(() => id),
|
|
27
|
+
ref: box.with(
|
|
28
|
+
() => ref,
|
|
29
|
+
(v) => (ref = v)
|
|
30
|
+
),
|
|
31
|
+
oncontextmenu: box.with(() => oncontextmenu ?? noop),
|
|
32
|
+
onInteractOutside: box.with(() => onInteractOutside),
|
|
33
|
+
onpointerdown: box.with(() => onpointerdown ?? noop),
|
|
34
|
+
onpointermove: box.with(() => onpointermove ?? noop),
|
|
35
|
+
onpointerout: box.with(() => onpointerout ?? noop),
|
|
36
|
+
onpointerup: box.with(() => onpointerup ?? noop),
|
|
37
|
+
onOpenAutoFocus: box.with(() => onOpenAutoFocus),
|
|
38
|
+
onFocusOutside: box.with(() => onFocusOutside),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const snapPointsOffset = $state.snapshot(contentState.ctx.snapPointsOffset);
|
|
42
|
+
|
|
43
|
+
const styleProp = $derived(
|
|
44
|
+
snapPointsOffset && snapPointsOffset.length > 0
|
|
45
|
+
? {
|
|
46
|
+
"--snap-point-height": `${snapPointsOffset[contentState.ctx.activeSnapPointIndex ?? 0]}px`,
|
|
47
|
+
}
|
|
48
|
+
: {}
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const mergedProps = $derived(
|
|
52
|
+
mergeProps(restProps, contentState.props, { style: styleProp })
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
) as any;
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<DialogPrimitive.Content {...mergedProps}>
|
|
58
|
+
{@render children?.()}
|
|
59
|
+
<Mounted onMounted={contentState.setMounted} />
|
|
60
|
+
</DialogPrimitive.Content>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type WithChildren } from "svelte-toolbelt";
|
|
2
|
+
import type { ContentProps } from "./index.js";
|
|
3
|
+
declare const DrawerContent: import("svelte").Component<WithChildren<Omit<ContentProps, "children">>, {}, "ref">;
|
|
4
|
+
type DrawerContent = ReturnType<typeof DrawerContent>;
|
|
5
|
+
export default DrawerContent;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { box, mergeProps } from "svelte-toolbelt";
|
|
3
|
+
import type { HandleProps } from "./index.js";
|
|
4
|
+
import { useId } from "../../internal/use-id.js";
|
|
5
|
+
import { useDrawerHandle } from "../../use-drawer-handle.svelte.js";
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
id = useId(),
|
|
9
|
+
ref = $bindable(null),
|
|
10
|
+
preventCycle = false,
|
|
11
|
+
children,
|
|
12
|
+
...restProps
|
|
13
|
+
}: HandleProps = $props();
|
|
14
|
+
|
|
15
|
+
const handleState = useDrawerHandle({
|
|
16
|
+
id: box.with(() => id),
|
|
17
|
+
ref: box.with(
|
|
18
|
+
() => ref,
|
|
19
|
+
(v) => (ref = v)
|
|
20
|
+
),
|
|
21
|
+
preventCycle: box.with(() => preventCycle),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const mergedProps = $derived(mergeProps(restProps, handleState.props));
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<div {...mergedProps}>
|
|
28
|
+
<span data-vaul-handle-hitarea="" aria-hidden="true">
|
|
29
|
+
{@render children?.()}
|
|
30
|
+
</span>
|
|
31
|
+
</div>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import DrawerRoot from "./drawer.svelte";
|
|
3
|
+
import type { RootProps } from "./index.js";
|
|
4
|
+
import { noop } from "../../internal/noop.js";
|
|
5
|
+
import { DrawerContext } from "../../context.js";
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
open = $bindable(false),
|
|
9
|
+
activeSnapPoint = $bindable(null),
|
|
10
|
+
onOpenChange = noop,
|
|
11
|
+
onDrag = noop,
|
|
12
|
+
...restProps
|
|
13
|
+
}: Omit<RootProps, "nested" | "onRelease" | "onClose"> = $props();
|
|
14
|
+
|
|
15
|
+
const rootState = DrawerContext.get();
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
const rest = $derived(restProps) as any;
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<DrawerRoot
|
|
21
|
+
bind:activeSnapPoint
|
|
22
|
+
bind:open
|
|
23
|
+
nested
|
|
24
|
+
onClose={() => rootState.onNestedOpenChange(false)}
|
|
25
|
+
onDrag={(e, p) => {
|
|
26
|
+
rootState.onNestedDrag(e, p);
|
|
27
|
+
onDrag(e, p);
|
|
28
|
+
}}
|
|
29
|
+
onOpenChange={(o) => {
|
|
30
|
+
if (o) {
|
|
31
|
+
rootState.onNestedOpenChange(o);
|
|
32
|
+
}
|
|
33
|
+
onOpenChange(o);
|
|
34
|
+
}}
|
|
35
|
+
onRelease={rootState.onNestedRelease}
|
|
36
|
+
{...rest}
|
|
37
|
+
/>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Dialog as DialogPrimitive, type WithoutChildrenOrChild } from "bits-ui";
|
|
3
|
+
import { type WithChildren, box, mergeProps } from "svelte-toolbelt";
|
|
4
|
+
import type { OverlayProps } from "./index.js";
|
|
5
|
+
import { useId } from "../../internal/use-id.js";
|
|
6
|
+
import { useDrawerOverlay } from "../../use-drawer-overlay.svelte.js";
|
|
7
|
+
import Mounted from "../utils/mounted.svelte";
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
id = useId(),
|
|
11
|
+
ref = $bindable(null),
|
|
12
|
+
children,
|
|
13
|
+
...restProps
|
|
14
|
+
}: WithChildren<WithoutChildrenOrChild<OverlayProps>> = $props();
|
|
15
|
+
|
|
16
|
+
const overlayState = useDrawerOverlay({
|
|
17
|
+
id: box.with(() => id),
|
|
18
|
+
ref: box.with(
|
|
19
|
+
() => ref,
|
|
20
|
+
(v) => (ref = v)
|
|
21
|
+
),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const mergedProps = $derived(mergeProps(restProps, overlayState.props));
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
{#if overlayState.shouldRender}
|
|
28
|
+
<DialogPrimitive.Overlay {...mergedProps}>
|
|
29
|
+
<Mounted onMounted={overlayState.setMounted} />
|
|
30
|
+
{@render children?.()}
|
|
31
|
+
</DialogPrimitive.Overlay>
|
|
32
|
+
{/if}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type WithChildren } from "svelte-toolbelt";
|
|
2
|
+
import type { OverlayProps } from "./index.js";
|
|
3
|
+
declare const DrawerOverlay: import("svelte").Component<WithChildren<Omit<OverlayProps, "children">>, {}, "ref">;
|
|
4
|
+
type DrawerOverlay = ReturnType<typeof DrawerOverlay>;
|
|
5
|
+
export default DrawerOverlay;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Dialog } from "bits-ui";
|
|
3
|
+
import { DrawerContext } from "../../context.js";
|
|
4
|
+
|
|
5
|
+
const ctx = DrawerContext.get();
|
|
6
|
+
|
|
7
|
+
let { to = ctx.container.current ?? undefined, ...restProps }: Dialog.PortalProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Dialog.Portal {to} {...restProps} />
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Dialog as DialogPrimitive } from "bits-ui";
|
|
3
|
+
import { box } from "svelte-toolbelt";
|
|
4
|
+
import type { RootProps } from "./index.js";
|
|
5
|
+
import { noop } from "../../internal/noop.js";
|
|
6
|
+
import { CLOSE_THRESHOLD, SCROLL_LOCK_TIMEOUT } from "../../internal/constants.js";
|
|
7
|
+
import { useDrawerRoot } from "../../use-drawer-root.svelte.js";
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
open = $bindable(false),
|
|
11
|
+
onOpenChange = noop,
|
|
12
|
+
onDrag = noop,
|
|
13
|
+
onRelease = noop,
|
|
14
|
+
snapPoints,
|
|
15
|
+
shouldScaleBackground = false,
|
|
16
|
+
setBackgroundColorOnScale = true,
|
|
17
|
+
closeThreshold = CLOSE_THRESHOLD,
|
|
18
|
+
scrollLockTimeout = SCROLL_LOCK_TIMEOUT,
|
|
19
|
+
dismissible = true,
|
|
20
|
+
handleOnly = false,
|
|
21
|
+
fadeFromIndex = snapPoints && snapPoints.length - 1,
|
|
22
|
+
activeSnapPoint = $bindable(null),
|
|
23
|
+
onActiveSnapPointChange = noop,
|
|
24
|
+
fixed = false,
|
|
25
|
+
modal = true,
|
|
26
|
+
onClose = noop,
|
|
27
|
+
nested = false,
|
|
28
|
+
noBodyStyles = false,
|
|
29
|
+
direction = "bottom",
|
|
30
|
+
snapToSequentialPoint = false,
|
|
31
|
+
preventScrollRestoration = false,
|
|
32
|
+
repositionInputs = true,
|
|
33
|
+
onAnimationEnd = noop,
|
|
34
|
+
container = null,
|
|
35
|
+
autoFocus = false,
|
|
36
|
+
disablePreventScroll = true,
|
|
37
|
+
...restProps
|
|
38
|
+
}: RootProps = $props();
|
|
39
|
+
|
|
40
|
+
const rootState = useDrawerRoot({
|
|
41
|
+
open: box.with(
|
|
42
|
+
() => open,
|
|
43
|
+
(o) => {
|
|
44
|
+
open = o;
|
|
45
|
+
rootState.handleOpenChange(o);
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
closeThreshold: box.with(() => closeThreshold),
|
|
49
|
+
scrollLockTimeout: box.with(() => scrollLockTimeout),
|
|
50
|
+
snapPoints: box.with(() => snapPoints),
|
|
51
|
+
fadeFromIndex: box.with(() => fadeFromIndex),
|
|
52
|
+
nested: box.with(() => nested),
|
|
53
|
+
shouldScaleBackground: box.with(() => shouldScaleBackground),
|
|
54
|
+
activeSnapPoint: box.with(
|
|
55
|
+
() => activeSnapPoint,
|
|
56
|
+
(v) => {
|
|
57
|
+
activeSnapPoint = v;
|
|
58
|
+
onActiveSnapPointChange(v);
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
onRelease: box.with(() => onRelease),
|
|
62
|
+
onDrag: box.with(() => onDrag),
|
|
63
|
+
onClose: box.with(() => onClose),
|
|
64
|
+
dismissible: box.with(() => dismissible),
|
|
65
|
+
direction: box.with(() => direction),
|
|
66
|
+
fixed: box.with(() => fixed),
|
|
67
|
+
modal: box.with(() => modal),
|
|
68
|
+
handleOnly: box.with(() => handleOnly),
|
|
69
|
+
noBodyStyles: box.with(() => noBodyStyles),
|
|
70
|
+
preventScrollRestoration: box.with(() => preventScrollRestoration),
|
|
71
|
+
setBackgroundColorOnScale: box.with(() => setBackgroundColorOnScale),
|
|
72
|
+
repositionInputs: box.with(() => repositionInputs),
|
|
73
|
+
autoFocus: box.with(() => autoFocus),
|
|
74
|
+
snapToSequentialPoint: box.with(() => snapToSequentialPoint),
|
|
75
|
+
container: box.with(() => container),
|
|
76
|
+
disablePreventScroll: box.with(() => disablePreventScroll),
|
|
77
|
+
onOpenChange: box.with(() => onOpenChange),
|
|
78
|
+
onAnimationEnd: box.with(() => onAnimationEnd),
|
|
79
|
+
});
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<DialogPrimitive.Root
|
|
83
|
+
bind:open={
|
|
84
|
+
() => rootState.open.current,
|
|
85
|
+
(o) => {
|
|
86
|
+
rootState.onDialogOpenChange(o);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
{...restProps}
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
<style global>
|
|
93
|
+
:global([data-vaul-drawer]) {
|
|
94
|
+
touch-action: none;
|
|
95
|
+
will-change: transform;
|
|
96
|
+
transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
|
|
97
|
+
animation-duration: 0.5s;
|
|
98
|
+
animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
:global(
|
|
102
|
+
[data-vaul-drawer][data-vaul-snap-points="false"][data-vaul-drawer-direction="bottom"][data-state="open"]
|
|
103
|
+
) {
|
|
104
|
+
animation-name: slideFromBottom;
|
|
105
|
+
}
|
|
106
|
+
:global(
|
|
107
|
+
[data-vaul-drawer][data-vaul-snap-points="false"][data-vaul-drawer-direction="bottom"][data-state="closed"]
|
|
108
|
+
) {
|
|
109
|
+
animation-name: slideToBottom;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
:global(
|
|
113
|
+
[data-vaul-drawer][data-vaul-snap-points="false"][data-vaul-drawer-direction="top"][data-state="open"]
|
|
114
|
+
) {
|
|
115
|
+
animation-name: slideFromTop;
|
|
116
|
+
}
|
|
117
|
+
:global(
|
|
118
|
+
[data-vaul-drawer][data-vaul-snap-points="false"][data-vaul-drawer-direction="top"][data-state="closed"]
|
|
119
|
+
) {
|
|
120
|
+
animation-name: slideToTop;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
:global(
|
|
124
|
+
[data-vaul-drawer][data-vaul-snap-points="false"][data-vaul-drawer-direction="left"][data-state="open"]
|
|
125
|
+
) {
|
|
126
|
+
animation-name: slideFromLeft;
|
|
127
|
+
}
|
|
128
|
+
:global(
|
|
129
|
+
[data-vaul-drawer][data-vaul-snap-points="false"][data-vaul-drawer-direction="left"][data-state="closed"]
|
|
130
|
+
) {
|
|
131
|
+
animation-name: slideToLeft;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
:global(
|
|
135
|
+
[data-vaul-drawer][data-vaul-snap-points="false"][data-vaul-drawer-direction="right"][data-state="open"]
|
|
136
|
+
) {
|
|
137
|
+
animation-name: slideFromRight;
|
|
138
|
+
}
|
|
139
|
+
:global(
|
|
140
|
+
[data-vaul-drawer][data-vaul-snap-points="false"][data-vaul-drawer-direction="right"][data-state="closed"]
|
|
141
|
+
) {
|
|
142
|
+
animation-name: slideToRight;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:global([data-vaul-drawer][data-vaul-snap-points="true"][data-vaul-drawer-direction="bottom"]) {
|
|
146
|
+
transform: translate3d(0, var(--initial-transform, 100%), 0);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
:global([data-vaul-drawer][data-vaul-snap-points="true"][data-vaul-drawer-direction="top"]) {
|
|
150
|
+
transform: translate3d(0, calc(var(--initial-transform, 100%) * -1), 0);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
:global([data-vaul-drawer][data-vaul-snap-points="true"][data-vaul-drawer-direction="left"]) {
|
|
154
|
+
transform: translate3d(calc(var(--initial-transform, 100%) * -1), 0, 0);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
:global([data-vaul-drawer][data-vaul-snap-points="true"][data-vaul-drawer-direction="right"]) {
|
|
158
|
+
transform: translate3d(var(--initial-transform, 100%), 0, 0);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
:global(
|
|
162
|
+
[data-vaul-drawer][data-vaul-delayed-snap-points="true"][data-vaul-drawer-direction="top"]
|
|
163
|
+
) {
|
|
164
|
+
transform: translate3d(0, var(--snap-point-height, 0), 0);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
:global(
|
|
168
|
+
[data-vaul-drawer][data-vaul-delayed-snap-points="true"][data-vaul-drawer-direction="bottom"]
|
|
169
|
+
) {
|
|
170
|
+
transform: translate3d(0, var(--snap-point-height, 0), 0);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
:global(
|
|
174
|
+
[data-vaul-drawer][data-vaul-delayed-snap-points="true"][data-vaul-drawer-direction="left"]
|
|
175
|
+
) {
|
|
176
|
+
transform: translate3d(var(--snap-point-height, 0), 0, 0);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
:global(
|
|
180
|
+
[data-vaul-drawer][data-vaul-delayed-snap-points="true"][data-vaul-drawer-direction="right"]
|
|
181
|
+
) {
|
|
182
|
+
transform: translate3d(var(--snap-point-height, 0), 0, 0);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
:global([data-vaul-overlay][data-vaul-snap-points="false"]) {
|
|
186
|
+
animation-duration: 0.5s;
|
|
187
|
+
animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
|
|
188
|
+
}
|
|
189
|
+
:global([data-vaul-overlay][data-vaul-snap-points="false"][data-state="open"]) {
|
|
190
|
+
animation-name: fadeIn;
|
|
191
|
+
}
|
|
192
|
+
:global([data-vaul-overlay][data-state="closed"]) {
|
|
193
|
+
animation-name: fadeOut;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
:global([data-vaul-animate="false"]) {
|
|
197
|
+
animation: none !important;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
:global([data-vaul-overlay][data-vaul-snap-points="true"]) {
|
|
201
|
+
opacity: 0;
|
|
202
|
+
transition: opacity 0.5s cubic-bezier(0.32, 0.72, 0, 1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
:global([data-vaul-overlay][data-vaul-snap-points="true"]) {
|
|
206
|
+
opacity: 1;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
:global([data-vaul-drawer]:not([data-vaul-custom-container="true"])::after) {
|
|
210
|
+
content: "";
|
|
211
|
+
position: absolute;
|
|
212
|
+
background: inherit;
|
|
213
|
+
background-color: inherit;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
:global([data-vaul-drawer][data-vaul-drawer-direction="top"]::after) {
|
|
217
|
+
top: initial;
|
|
218
|
+
bottom: 100%;
|
|
219
|
+
left: 0;
|
|
220
|
+
right: 0;
|
|
221
|
+
height: 200%;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
:global([data-vaul-drawer][data-vaul-drawer-direction="bottom"]::after) {
|
|
225
|
+
top: 100%;
|
|
226
|
+
bottom: initial;
|
|
227
|
+
left: 0;
|
|
228
|
+
right: 0;
|
|
229
|
+
height: 200%;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
:global([data-vaul-drawer][data-vaul-drawer-direction="left"]::after) {
|
|
233
|
+
left: initial;
|
|
234
|
+
right: 100%;
|
|
235
|
+
top: 0;
|
|
236
|
+
bottom: 0;
|
|
237
|
+
width: 200%;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
:global([data-vaul-drawer][data-vaul-drawer-direction="right"]::after) {
|
|
241
|
+
left: 100%;
|
|
242
|
+
right: initial;
|
|
243
|
+
top: 0;
|
|
244
|
+
bottom: 0;
|
|
245
|
+
width: 200%;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
:global(
|
|
249
|
+
[data-vaul-overlay][data-vaul-snap-points="true"]:not(
|
|
250
|
+
[data-vaul-snap-points-overlay="true"]
|
|
251
|
+
):not([data-state="closed"])
|
|
252
|
+
) {
|
|
253
|
+
opacity: 0;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
:global([data-vaul-overlay][data-vaul-snap-points-overlay="true"]) {
|
|
257
|
+
opacity: 1;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
:global([data-vaul-handle]) {
|
|
261
|
+
display: block;
|
|
262
|
+
position: relative;
|
|
263
|
+
opacity: 0.7;
|
|
264
|
+
background: #e2e2e4;
|
|
265
|
+
margin-left: auto;
|
|
266
|
+
margin-right: auto;
|
|
267
|
+
height: 5px;
|
|
268
|
+
width: 32px;
|
|
269
|
+
border-radius: 1rem;
|
|
270
|
+
touch-action: pan-y;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
:global([data-vaul-handle]:hover, [data-vaul-handle]:active) {
|
|
274
|
+
opacity: 1;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
:global([data-vaul-handle-hitarea]) {
|
|
278
|
+
position: absolute;
|
|
279
|
+
left: 50%;
|
|
280
|
+
top: 50%;
|
|
281
|
+
transform: translate(-50%, -50%);
|
|
282
|
+
width: max(100%, 2.75rem); /* 44px */
|
|
283
|
+
height: max(100%, 2.75rem); /* 44px */
|
|
284
|
+
touch-action: inherit;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/* This will allow us to not animate via animation, but still benefit from delaying unmount via Radix. */
|
|
288
|
+
|
|
289
|
+
@keyframes -global-fake-animation {
|
|
290
|
+
from {
|
|
291
|
+
}
|
|
292
|
+
to {
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
@keyframes -global-fadeIn {
|
|
297
|
+
from {
|
|
298
|
+
opacity: 0;
|
|
299
|
+
}
|
|
300
|
+
to {
|
|
301
|
+
opacity: 1;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
@keyframes -global-fadeOut {
|
|
306
|
+
to {
|
|
307
|
+
opacity: 0;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
@keyframes -global-slideFromBottom {
|
|
312
|
+
from {
|
|
313
|
+
transform: translate3d(0, var(--initial-transform, 100%), 0);
|
|
314
|
+
}
|
|
315
|
+
to {
|
|
316
|
+
transform: translate3d(0, 0, 0);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
@keyframes -global-slideToBottom {
|
|
321
|
+
to {
|
|
322
|
+
transform: translate3d(0, var(--initial-transform, 100%), 0);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
@keyframes -global-slideFromTop {
|
|
327
|
+
from {
|
|
328
|
+
transform: translate3d(0, calc(var(--initial-transform, 100%) * -1), 0);
|
|
329
|
+
}
|
|
330
|
+
to {
|
|
331
|
+
transform: translate3d(0, 0, 0);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@keyframes -global-slideToTop {
|
|
336
|
+
to {
|
|
337
|
+
transform: translate3d(0, calc(var(--initial-transform, 100%) * -1), 0);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
@keyframes -global-slideFromLeft {
|
|
342
|
+
from {
|
|
343
|
+
transform: translate3d(calc(var(--initial-transform, 100%) * -1), 0, 0);
|
|
344
|
+
}
|
|
345
|
+
to {
|
|
346
|
+
transform: translate3d(0, 0, 0);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
@keyframes -global-slideToLeft {
|
|
351
|
+
to {
|
|
352
|
+
transform: translate3d(calc(var(--initial-transform, 100%) * -1), 0, 0);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
@keyframes -global-slideFromRight {
|
|
357
|
+
from {
|
|
358
|
+
transform: translate3d(var(--initial-transform, 100%), 0, 0);
|
|
359
|
+
}
|
|
360
|
+
to {
|
|
361
|
+
transform: translate3d(0, 0, 0);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
@keyframes -global-slideToRight {
|
|
366
|
+
to {
|
|
367
|
+
transform: translate3d(var(--initial-transform, 100%), 0, 0);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
@media (hover: hover) and (pointer: fine) {
|
|
372
|
+
:global([data-vaul-drawer]) {
|
|
373
|
+
user-select: none !important;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
@media (pointer: fine) {
|
|
378
|
+
:global([data-vaul-handle-hitarea]) {
|
|
379
|
+
width: 100%;
|
|
380
|
+
height: 100%;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dialog as DrawerPrimitive } from "bits-ui";
|
|
2
|
+
export { default as Root } from "./drawer.svelte";
|
|
3
|
+
export { default as Content } from "./drawer-content.svelte";
|
|
4
|
+
export { default as Overlay } from "./drawer-overlay.svelte";
|
|
5
|
+
export { default as NestedRoot } from "./drawer-nested.svelte";
|
|
6
|
+
export { default as Handle } from "./drawer-handle.svelte";
|
|
7
|
+
export { default as Portal } from "./drawer-portal.svelte";
|
|
8
|
+
export declare const Trigger: typeof DrawerPrimitive.Trigger;
|
|
9
|
+
export declare const Title: typeof DrawerPrimitive.Title;
|
|
10
|
+
export declare const Description: typeof DrawerPrimitive.Description;
|
|
11
|
+
export declare const Close: typeof DrawerPrimitive.Close;
|
|
12
|
+
export type { DrawerRootProps as RootProps, DrawerContentProps as ContentProps, DrawerOverlayProps as OverlayProps, DrawerRootProps as NestedRootProps, DrawerHandleProps as HandleProps, DrawerTitleProps as TitleProps, DrawerDescriptionProps as DescriptionProps, DrawerCloseProps as CloseProps, DrawerPortalProps as PortalProps, DrawerTriggerProps as TriggerProps, } from "./types.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Dialog as DrawerPrimitive } from "bits-ui";
|
|
2
|
+
export { default as Root } from "./drawer.svelte";
|
|
3
|
+
export { default as Content } from "./drawer-content.svelte";
|
|
4
|
+
export { default as Overlay } from "./drawer-overlay.svelte";
|
|
5
|
+
export { default as NestedRoot } from "./drawer-nested.svelte";
|
|
6
|
+
export { default as Handle } from "./drawer-handle.svelte";
|
|
7
|
+
export { default as Portal } from "./drawer-portal.svelte";
|
|
8
|
+
export const Trigger = DrawerPrimitive.Trigger;
|
|
9
|
+
export const Title = DrawerPrimitive.Title;
|
|
10
|
+
export const Description = DrawerPrimitive.Description;
|
|
11
|
+
export const Close = DrawerPrimitive.Close;
|