@rodrigodagostino/svelte-draggable-drawer 0.1.0 → 0.2.0
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/dist/components/Drawer.svelte +121 -0
- package/dist/components/Drawer.svelte.d.ts +7 -0
- package/dist/components/DrawerBackdrop.svelte +56 -0
- package/dist/components/DrawerBackdrop.svelte.d.ts +7 -0
- package/dist/components/DrawerContent.svelte +80 -0
- package/dist/components/DrawerContent.svelte.d.ts +7 -0
- package/dist/components/DrawerContentHandle.svelte +51 -0
- package/dist/components/DrawerContentHandle.svelte.d.ts +7 -0
- package/dist/exports.d.ts +5 -5
- package/dist/exports.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/states/drawer.svelte.d.ts +13 -0
- package/dist/states/drawer.svelte.js +17 -0
- package/dist/states/index.d.ts +1 -0
- package/dist/states/index.js +1 -0
- package/dist/styles.css +1 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.js +0 -2
- package/dist/types/props.d.ts +15 -1
- package/dist/types/states.d.ts +20 -1
- package/package.json +28 -25
- package/dist/components/DraggableDrawer.svelte +0 -103
- package/dist/components/DraggableDrawer.svelte.d.ts +0 -21
- package/dist/components/DraggableDrawerBackdrop.svelte +0 -41
- package/dist/components/DraggableDrawerBackdrop.svelte.d.ts +0 -16
- package/dist/components/DraggableDrawerContent.svelte +0 -57
- package/dist/components/DraggableDrawerContent.svelte.d.ts +0 -18
- package/dist/components/DraggableDrawerHandle.svelte +0 -25
- package/dist/components/DraggableDrawerHandle.svelte.d.ts +0 -18
- package/dist/stores/coordinates.d.ts +0 -25
- package/dist/stores/coordinates.js +0 -19
- package/dist/stores/elements.d.ts +0 -7
- package/dist/stores/elements.js +0 -19
- package/dist/stores/index.d.ts +0 -7
- package/dist/stores/index.js +0 -14
- package/dist/stores/props.d.ts +0 -3
- package/dist/stores/props.js +0 -7
- package/dist/stores/states.d.ts +0 -3
- package/dist/stores/states.js +0 -7
- package/dist/types/coordinates.d.ts +0 -14
- package/dist/types/coordinates.js +0 -1
- package/dist/types/elements.d.ts +0 -5
- package/dist/types/elements.js +0 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { setDrawerRootState } from '../states/index.js';
|
|
3
|
+
import type { DrawerRootProps } from '../types/props.js';
|
|
4
|
+
let {
|
|
5
|
+
ref = $bindable(null),
|
|
6
|
+
isOpen = $bindable(false),
|
|
7
|
+
children,
|
|
8
|
+
...restProps
|
|
9
|
+
}: DrawerRootProps & { class?: string } = $props();
|
|
10
|
+
|
|
11
|
+
const rootState = setDrawerRootState();
|
|
12
|
+
|
|
13
|
+
$effect(() => {
|
|
14
|
+
rootState.props = {
|
|
15
|
+
ref,
|
|
16
|
+
isOpen,
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
$effect(() => {
|
|
21
|
+
isOpen = rootState.props.isOpen || false;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const classes = $derived(['sdd-root', restProps.class]);
|
|
25
|
+
let pointerId: PointerEvent['pointerId'] | null = null;
|
|
26
|
+
|
|
27
|
+
const TOP_THRESHOLD = 2 / 5;
|
|
28
|
+
const BOTTOM_THRESHOLD = 3 / 5;
|
|
29
|
+
|
|
30
|
+
let transitionTimeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
31
|
+
|
|
32
|
+
function handlePointerDown(e: PointerEvent) {
|
|
33
|
+
const target = e.target as HTMLElement;
|
|
34
|
+
if (!rootState.handle || !target.closest('[data-role="handle"]') || !rootState.content) return;
|
|
35
|
+
|
|
36
|
+
pointerId = e.pointerId;
|
|
37
|
+
rootState.handle.setPointerCapture(pointerId);
|
|
38
|
+
rootState.pointer = { x: e.clientX, y: e.clientY };
|
|
39
|
+
rootState.pointerOrigin = { x: e.clientX, y: e.clientY };
|
|
40
|
+
rootState.contentOrigin = rootState.content.getBoundingClientRect();
|
|
41
|
+
rootState.dragState = 'drag-start';
|
|
42
|
+
|
|
43
|
+
rootState.handle.addEventListener('pointermove', handlePointerMove);
|
|
44
|
+
rootState.handle.addEventListener(
|
|
45
|
+
'pointerup',
|
|
46
|
+
() => {
|
|
47
|
+
rootState.handle?.removeEventListener('pointermove', handlePointerMove);
|
|
48
|
+
handlePointerUp();
|
|
49
|
+
},
|
|
50
|
+
{ once: true }
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function handlePointerMove({ clientX, clientY }: PointerEvent) {
|
|
55
|
+
if (!rootState.content || !rootState.pointerOrigin) return;
|
|
56
|
+
|
|
57
|
+
rootState.dragState = 'drag';
|
|
58
|
+
|
|
59
|
+
rootState.pointer = { x: clientX, y: clientY };
|
|
60
|
+
rootState.props.isOpen =
|
|
61
|
+
rootState.pointerOrigin.y > window.innerHeight / 2
|
|
62
|
+
? clientY < window.innerHeight * BOTTOM_THRESHOLD
|
|
63
|
+
: clientY < window.innerHeight * TOP_THRESHOLD;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function handlePointerUp() {
|
|
67
|
+
if (!rootState.pointerOrigin || !rootState.content) return;
|
|
68
|
+
|
|
69
|
+
rootState.dragState = 'drop';
|
|
70
|
+
|
|
71
|
+
function handleTransitionEnd({ propertyName }: TransitionEvent) {
|
|
72
|
+
if (propertyName === 'transform') {
|
|
73
|
+
handlePointerAndKeyboardDragEnd();
|
|
74
|
+
rootState.content?.removeEventListener('transitionend', handleTransitionEnd);
|
|
75
|
+
if (transitionTimeoutId) {
|
|
76
|
+
clearTimeout(transitionTimeoutId);
|
|
77
|
+
transitionTimeoutId = null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
rootState.content?.addEventListener('transitionend', handleTransitionEnd);
|
|
83
|
+
// Ensure the drag operation completes even if `transitionend` doesn’t fire.
|
|
84
|
+
transitionTimeoutId = setTimeout(() => {
|
|
85
|
+
handlePointerAndKeyboardDragEnd();
|
|
86
|
+
rootState.content?.removeEventListener('transitionend', handleTransitionEnd);
|
|
87
|
+
transitionTimeoutId = null;
|
|
88
|
+
}, 400 + 100);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function handlePointerAndKeyboardDragEnd() {
|
|
92
|
+
if (pointerId) rootState.content?.releasePointerCapture(pointerId);
|
|
93
|
+
rootState.pointerOrigin = null;
|
|
94
|
+
rootState.contentOrigin = null;
|
|
95
|
+
rootState.dragState = 'idle';
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<div class={classes} data-drag-state={rootState.dragState} onpointerdown={handlePointerDown}>
|
|
100
|
+
{@render children?.()}
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<style>
|
|
104
|
+
.sdd-root {
|
|
105
|
+
position: fixed;
|
|
106
|
+
inset: 0;
|
|
107
|
+
pointer-events: none;
|
|
108
|
+
z-index: 9999;
|
|
109
|
+
|
|
110
|
+
&:not(:has(.sdd-content-handle)),
|
|
111
|
+
& :global(.sdd-content-handle) {
|
|
112
|
+
touch-action: none;
|
|
113
|
+
cursor: grab;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&[data-drag-state*='drag'],
|
|
117
|
+
&[data-drag-state*='drag'] :global(.sdd-content-handle) {
|
|
118
|
+
cursor: grabbing;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
</style>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DrawerRootProps } from '../types/props.js';
|
|
2
|
+
type $$ComponentProps = DrawerRootProps & {
|
|
3
|
+
class?: string;
|
|
4
|
+
};
|
|
5
|
+
declare const Drawer: import("svelte").Component<$$ComponentProps, {}, "ref" | "isOpen">;
|
|
6
|
+
type Drawer = ReturnType<typeof Drawer>;
|
|
7
|
+
export default Drawer;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getDrawerRootState } from '../states/drawer.svelte.js';
|
|
3
|
+
import type { DrawerBackdropProps as BackdropProps } from '../types/props.js';
|
|
4
|
+
|
|
5
|
+
let { ref = $bindable(null), ...restProps }: BackdropProps & { class?: string } = $props();
|
|
6
|
+
|
|
7
|
+
let offsetHeight: number = $state(0);
|
|
8
|
+
|
|
9
|
+
const rootState = getDrawerRootState();
|
|
10
|
+
|
|
11
|
+
const classes = $derived(['sdd-backdrop', restProps.class]);
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
+
function getStyleOpacity(...args: unknown[]) {
|
|
15
|
+
if (rootState.dragState === 'drag' && rootState.pointer) {
|
|
16
|
+
return (rootState.pointer.y / offsetHeight / 2 - 0.5) * -1;
|
|
17
|
+
}
|
|
18
|
+
if (rootState.props.isOpen) return 0.5;
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
|
+
function getStyleTransition(...args: unknown[]) {
|
|
24
|
+
if (rootState.dragState !== 'drag-start' && rootState.dragState !== 'drag')
|
|
25
|
+
return 'opacity 240ms';
|
|
26
|
+
return 'none';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const styleOpacity = $derived(
|
|
30
|
+
getStyleOpacity(rootState.pointer, rootState.dragState, rootState.props.isOpen)
|
|
31
|
+
);
|
|
32
|
+
const styleTransition = $derived(getStyleTransition(rootState.dragState));
|
|
33
|
+
|
|
34
|
+
const handleClick = () => {
|
|
35
|
+
rootState.props.isOpen = false;
|
|
36
|
+
};
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<div
|
|
40
|
+
bind:this={ref}
|
|
41
|
+
bind:offsetHeight
|
|
42
|
+
class={classes}
|
|
43
|
+
style:opacity={styleOpacity}
|
|
44
|
+
style:transition={styleTransition}
|
|
45
|
+
style:pointer-events={rootState.props.isOpen ? 'auto' : 'none'}
|
|
46
|
+
aria-hidden="true"
|
|
47
|
+
onclick={handleClick}
|
|
48
|
+
></div>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
.sdd-backdrop {
|
|
52
|
+
position: fixed;
|
|
53
|
+
inset: 0;
|
|
54
|
+
z-index: 0;
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DrawerBackdropProps as BackdropProps } from '../types/props.js';
|
|
2
|
+
type $$ComponentProps = BackdropProps & {
|
|
3
|
+
class?: string;
|
|
4
|
+
};
|
|
5
|
+
declare const DrawerBackdrop: import("svelte").Component<$$ComponentProps, {}, "ref">;
|
|
6
|
+
type DrawerBackdrop = ReturnType<typeof DrawerBackdrop>;
|
|
7
|
+
export default DrawerBackdrop;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getDrawerRootState } from '../states/drawer.svelte.js';
|
|
3
|
+
import type { DrawerContentProps as ContentProps } from '../types/props.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
children,
|
|
8
|
+
...restProps
|
|
9
|
+
}: ContentProps & { class?: string } = $props();
|
|
10
|
+
|
|
11
|
+
const rootState = getDrawerRootState();
|
|
12
|
+
|
|
13
|
+
$effect(() => {
|
|
14
|
+
rootState.content = ref;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const classes = $derived(['sdd-content', restProps.class]);
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
+
function getStyleTransform(...args: unknown[]) {
|
|
21
|
+
if (rootState.dragState === 'drag') {
|
|
22
|
+
if (!rootState.pointer || !rootState.pointerOrigin || !rootState.contentOrigin) return 'none';
|
|
23
|
+
// Prevent the drawer from being dragged above the top of the screen or below the bottom.
|
|
24
|
+
const y =
|
|
25
|
+
rootState.pointerOrigin.y > window.innerHeight / 2
|
|
26
|
+
? rootState.pointer.y > rootState.pointerOrigin.y
|
|
27
|
+
? rootState.pointerOrigin.y
|
|
28
|
+
: rootState.pointer.y
|
|
29
|
+
: rootState.pointer.y < rootState.pointerOrigin.y
|
|
30
|
+
? rootState.pointerOrigin.y
|
|
31
|
+
: rootState.pointer.y;
|
|
32
|
+
// Set the position of the content relative to the pointer.
|
|
33
|
+
const offset = rootState.contentOrigin.y - rootState.pointerOrigin.y;
|
|
34
|
+
|
|
35
|
+
return `translate3d(0, ${y + offset}px, 0)`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (rootState.props.isOpen)
|
|
39
|
+
return `translate3d(0, calc(0% + ${rootState.handle?.getBoundingClientRect().height || 24}px), 0)`;
|
|
40
|
+
|
|
41
|
+
return `translate3d(0, calc(100% - ${rootState.handle?.getBoundingClientRect().height || 48}px), 0)`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const styleTransform = $derived(
|
|
45
|
+
getStyleTransform(rootState.pointer, rootState.dragState, rootState.props.isOpen)
|
|
46
|
+
);
|
|
47
|
+
const styleTransition = $derived(
|
|
48
|
+
rootState.dragState !== 'drag-start' && rootState.dragState !== 'drag'
|
|
49
|
+
? `transform 400ms cubic-bezier(0.32, 0.72, 0, 1)`
|
|
50
|
+
: 'none'
|
|
51
|
+
);
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<div
|
|
55
|
+
bind:this={ref}
|
|
56
|
+
class={classes}
|
|
57
|
+
style:transform={styleTransform}
|
|
58
|
+
style:transition={styleTransition}
|
|
59
|
+
>
|
|
60
|
+
{@render children?.()}
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<style>
|
|
64
|
+
.sdd-content {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
width: calc(100% - 2rem);
|
|
68
|
+
height: 100%;
|
|
69
|
+
margin-inline: auto;
|
|
70
|
+
pointer-events: auto;
|
|
71
|
+
position: relative;
|
|
72
|
+
z-index: 1;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@media (min-width: 48em) {
|
|
76
|
+
.sdd-content {
|
|
77
|
+
width: calc(100% - 2.5rem);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DrawerContentProps as ContentProps } from '../types/props.js';
|
|
2
|
+
type $$ComponentProps = ContentProps & {
|
|
3
|
+
class?: string;
|
|
4
|
+
};
|
|
5
|
+
declare const DrawerContent: import("svelte").Component<$$ComponentProps, {}, "ref">;
|
|
6
|
+
type DrawerContent = ReturnType<typeof DrawerContent>;
|
|
7
|
+
export default DrawerContent;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getDrawerRootState } from '../states/drawer.svelte.js';
|
|
3
|
+
import type { DrawerContentHandleProps as ContentHandleProps } from '../types/props.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
children,
|
|
8
|
+
...restProps
|
|
9
|
+
}: ContentHandleProps & { class?: string } = $props();
|
|
10
|
+
|
|
11
|
+
const rootState = getDrawerRootState();
|
|
12
|
+
|
|
13
|
+
$effect(() => {
|
|
14
|
+
rootState.handle = ref;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const classes = $derived(['sdd-content-handle', restProps.class]);
|
|
18
|
+
|
|
19
|
+
const handleKeyUp = ({ key }: KeyboardEvent) => {
|
|
20
|
+
if (key === 'Enter' || key === ' ') {
|
|
21
|
+
rootState.props.isOpen = !rootState.props.isOpen;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<button bind:this={ref} class={classes} data-role="handle" onkeyup={handleKeyUp}>
|
|
27
|
+
{#if children}
|
|
28
|
+
{@render children()}
|
|
29
|
+
{:else}
|
|
30
|
+
<span class="sr-only">Handle</span>
|
|
31
|
+
{/if}
|
|
32
|
+
</button>
|
|
33
|
+
|
|
34
|
+
<style>
|
|
35
|
+
.sdd-content-handle {
|
|
36
|
+
margin-inline: auto;
|
|
37
|
+
user-select: none;
|
|
38
|
+
|
|
39
|
+
.sr-only {
|
|
40
|
+
position: absolute;
|
|
41
|
+
width: 1px;
|
|
42
|
+
height: 1px;
|
|
43
|
+
padding: 0;
|
|
44
|
+
margin: -1px;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
clip: rect(0, 0, 0, 0);
|
|
47
|
+
white-space: nowrap;
|
|
48
|
+
border-width: 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
</style>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DrawerContentHandleProps as ContentHandleProps } from '../types/props.js';
|
|
2
|
+
type $$ComponentProps = ContentHandleProps & {
|
|
3
|
+
class?: string;
|
|
4
|
+
};
|
|
5
|
+
declare const DrawerContentHandle: import("svelte").Component<$$ComponentProps, {}, "ref">;
|
|
6
|
+
type DrawerContentHandle = ReturnType<typeof DrawerContentHandle>;
|
|
7
|
+
export default DrawerContentHandle;
|
package/dist/exports.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { default as Root } from './components/
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as Backdrop } from './components/
|
|
5
|
-
export type {
|
|
1
|
+
export { default as Root } from './components/Drawer.svelte';
|
|
2
|
+
export { default as Content } from './components/DrawerContent.svelte';
|
|
3
|
+
export { default as ContentHandle } from './components/DrawerContentHandle.svelte';
|
|
4
|
+
export { default as Backdrop } from './components/DrawerBackdrop.svelte';
|
|
5
|
+
export type { DrawerRootProps as RootProps } from './types/index.js';
|
package/dist/exports.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as Root } from './components/
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as Backdrop } from './components/
|
|
1
|
+
export { default as Root } from './components/Drawer.svelte';
|
|
2
|
+
export { default as Content } from './components/DrawerContent.svelte';
|
|
3
|
+
export { default as ContentHandle } from './components/DrawerContentHandle.svelte';
|
|
4
|
+
export { default as Backdrop } from './components/DrawerBackdrop.svelte';
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * as
|
|
1
|
+
export * as Drawer from './exports.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * as
|
|
1
|
+
export * as Drawer from './exports.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DrawerRootStateContext as Context } from '../types/index.js';
|
|
2
|
+
declare class DrawerRootState {
|
|
3
|
+
props: Context['props'];
|
|
4
|
+
dragState: Context['dragState'];
|
|
5
|
+
content: Context['content'];
|
|
6
|
+
handle: Context['handle'];
|
|
7
|
+
pointer: Context['pointer'];
|
|
8
|
+
pointerOrigin: Context['pointerOrigin'];
|
|
9
|
+
contentOrigin: Context['contentOrigin'];
|
|
10
|
+
}
|
|
11
|
+
export declare function setDrawerRootState(): DrawerRootState;
|
|
12
|
+
export declare function getDrawerRootState(): DrawerRootState;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
class DrawerRootState {
|
|
3
|
+
props = $state({});
|
|
4
|
+
dragState = $state('idle');
|
|
5
|
+
content = $state(null);
|
|
6
|
+
handle = $state(null);
|
|
7
|
+
pointer = $state.raw(null);
|
|
8
|
+
pointerOrigin = $state.raw(null);
|
|
9
|
+
contentOrigin = $state.raw(null);
|
|
10
|
+
}
|
|
11
|
+
const KEY = Symbol('Drawer.RootState');
|
|
12
|
+
export function setDrawerRootState() {
|
|
13
|
+
return setContext(KEY, new DrawerRootState());
|
|
14
|
+
}
|
|
15
|
+
export function getDrawerRootState() {
|
|
16
|
+
return getContext(KEY);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './drawer.svelte.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./drawer.svelte.js";
|
package/dist/styles.css
CHANGED
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
package/dist/types/props.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface DrawerRootProps {
|
|
3
|
+
ref?: HTMLDivElement | null;
|
|
2
4
|
isOpen?: boolean;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
}
|
|
7
|
+
export interface DrawerContentProps {
|
|
8
|
+
ref?: HTMLDivElement | null;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
}
|
|
11
|
+
export interface DrawerContentHandleProps {
|
|
12
|
+
ref?: HTMLButtonElement | null;
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
}
|
|
15
|
+
export interface DrawerBackdropProps {
|
|
16
|
+
ref?: HTMLDivElement | null;
|
|
3
17
|
}
|
package/dist/types/states.d.ts
CHANGED
|
@@ -1 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DrawerRootProps as RootProps } from './props.js';
|
|
2
|
+
export interface DrawerRootStateContext {
|
|
3
|
+
ref: HTMLUListElement | null;
|
|
4
|
+
props: RootProps;
|
|
5
|
+
dragState: 'idle' | 'drag-start' | 'drag' | 'drop';
|
|
6
|
+
content: HTMLDivElement | null;
|
|
7
|
+
handle: HTMLButtonElement | null;
|
|
8
|
+
pointer: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
} | null;
|
|
12
|
+
pointerOrigin: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
} | null;
|
|
16
|
+
contentOrigin: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
} | null;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rodrigodagostino/svelte-draggable-drawer",
|
|
3
|
-
"
|
|
3
|
+
"description": "Create accessible, draggable drawers in Svelte, with keyboard, mouse, and touch support.",
|
|
4
|
+
"version": "0.2.0",
|
|
4
5
|
"author": "Rodrigo D’Agostino <rodrigo.dagostino@proton.me>",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"draggable",
|
|
7
8
|
"drawer",
|
|
8
9
|
"drag",
|
|
9
|
-
"
|
|
10
|
-
"dnd",
|
|
10
|
+
"touch",
|
|
11
11
|
"accessible",
|
|
12
|
+
"a11y",
|
|
12
13
|
"svelte",
|
|
13
|
-
"sveltekit"
|
|
14
|
+
"sveltekit",
|
|
15
|
+
"component"
|
|
14
16
|
],
|
|
15
17
|
"license": "MIT",
|
|
16
18
|
"type": "module",
|
|
@@ -20,15 +22,22 @@
|
|
|
20
22
|
},
|
|
21
23
|
"scripts": {
|
|
22
24
|
"dev": "vite dev",
|
|
23
|
-
"build": "vite build && npm run
|
|
25
|
+
"build": "vite build && npm run prepack",
|
|
24
26
|
"preview": "vite preview",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
+
"prepare": "svelte-kit sync || echo ''",
|
|
28
|
+
"prepack": "svelte-kit sync && svelte-package && publint",
|
|
27
29
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
28
30
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
29
31
|
"lint": "prettier --check . && eslint .",
|
|
30
32
|
"format": "prettier --write ."
|
|
31
33
|
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"!dist/**/*.test.*",
|
|
37
|
+
"!dist/**/*.spec.*"
|
|
38
|
+
],
|
|
39
|
+
"svelte": "./dist/index.js",
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
32
41
|
"exports": {
|
|
33
42
|
".": {
|
|
34
43
|
"types": "./dist/index.d.ts",
|
|
@@ -38,35 +47,29 @@
|
|
|
38
47
|
"import": "./dist/*.css"
|
|
39
48
|
}
|
|
40
49
|
},
|
|
41
|
-
"files": [
|
|
42
|
-
"dist",
|
|
43
|
-
"!dist/**/*.test.*",
|
|
44
|
-
"!dist/**/*.spec.*"
|
|
45
|
-
],
|
|
46
50
|
"peerDependencies": {
|
|
47
|
-
"svelte": "^
|
|
51
|
+
"svelte": "^5.0.0"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
54
|
+
"@eslint/js": "10.0.1",
|
|
55
|
+
"@fontsource/jetbrains-mono": "5.2.8",
|
|
56
|
+
"@fontsource/rubik": "5.2.8",
|
|
50
57
|
"@sveltejs/adapter-auto": "7.0.1",
|
|
51
58
|
"@sveltejs/kit": "2.69.1",
|
|
52
59
|
"@sveltejs/package": "2.5.8",
|
|
53
|
-
"@sveltejs/vite-plugin-svelte": "
|
|
54
|
-
"@types/
|
|
55
|
-
"
|
|
56
|
-
"eslint": "
|
|
57
|
-
"eslint-config-prettier": "9.1.2",
|
|
58
|
-
"eslint-plugin-prettier": "5.5.6",
|
|
60
|
+
"@sveltejs/vite-plugin-svelte": "7.1.2",
|
|
61
|
+
"@types/node": "^22",
|
|
62
|
+
"eslint": "10.6.0",
|
|
63
|
+
"eslint-config-prettier": "10.1.8",
|
|
59
64
|
"eslint-plugin-svelte": "3.20.0",
|
|
60
65
|
"globals": "17.7.0",
|
|
61
66
|
"prettier": "3.9.4",
|
|
62
|
-
"prettier-plugin-svelte": "
|
|
67
|
+
"prettier-plugin-svelte": "4.1.1",
|
|
63
68
|
"publint": "0.3.21",
|
|
64
|
-
"svelte": "
|
|
69
|
+
"svelte": "5.56.4",
|
|
65
70
|
"svelte-check": "4.7.1",
|
|
66
71
|
"typescript": "6.0.3",
|
|
67
72
|
"typescript-eslint": "8.62.1",
|
|
68
|
-
"vite": "
|
|
69
|
-
}
|
|
70
|
-
"svelte": "./dist/index.js",
|
|
71
|
-
"types": "./dist/index.d.ts"
|
|
73
|
+
"vite": "8.1.3"
|
|
74
|
+
}
|
|
72
75
|
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
<script>import { onDestroy } from "svelte";
|
|
2
|
-
import {
|
|
3
|
-
setContent,
|
|
4
|
-
setContentOrigin,
|
|
5
|
-
setDragState,
|
|
6
|
-
setHandle,
|
|
7
|
-
setPointer,
|
|
8
|
-
setPointerOrigin,
|
|
9
|
-
setRootProps
|
|
10
|
-
} from "../stores/index.js";
|
|
11
|
-
export let isOpen = false;
|
|
12
|
-
const rootProps = setRootProps({ isOpen });
|
|
13
|
-
$: $rootProps = { isOpen };
|
|
14
|
-
const unsubscribe = rootProps.subscribe((value) => {
|
|
15
|
-
isOpen = value.isOpen;
|
|
16
|
-
});
|
|
17
|
-
onDestroy(unsubscribe);
|
|
18
|
-
let pointerId = null;
|
|
19
|
-
const pointer = setPointer(null);
|
|
20
|
-
const pointerOrigin = setPointerOrigin(null);
|
|
21
|
-
const content = setContent(null);
|
|
22
|
-
const contentOrigin = setContentOrigin(null);
|
|
23
|
-
const handle = setHandle(null);
|
|
24
|
-
const dragState = setDragState("idle");
|
|
25
|
-
const TOP_THRESHOLD = 2 / 5;
|
|
26
|
-
const BOTTOM_THRESHOLD = 3 / 5;
|
|
27
|
-
let transitionTimeoutId = null;
|
|
28
|
-
function handlePointerDown(e) {
|
|
29
|
-
const target = e.target;
|
|
30
|
-
if (!$handle || !target.closest('[data-role="handle"]') || !$content) return;
|
|
31
|
-
pointerId = e.pointerId;
|
|
32
|
-
$handle.setPointerCapture(pointerId);
|
|
33
|
-
$pointer = { x: e.clientX, y: e.clientY };
|
|
34
|
-
$pointerOrigin = { x: e.clientX, y: e.clientY };
|
|
35
|
-
$contentOrigin = $content.getBoundingClientRect();
|
|
36
|
-
$dragState = "drag-start";
|
|
37
|
-
$handle.addEventListener("pointermove", handlePointerMove);
|
|
38
|
-
$handle.addEventListener(
|
|
39
|
-
"pointerup",
|
|
40
|
-
() => {
|
|
41
|
-
$handle.removeEventListener("pointermove", handlePointerMove);
|
|
42
|
-
handlePointerUp();
|
|
43
|
-
},
|
|
44
|
-
{ once: true }
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
async function handlePointerMove({ clientX, clientY }) {
|
|
48
|
-
if (!$content || !$pointerOrigin) return;
|
|
49
|
-
$dragState = "drag";
|
|
50
|
-
$pointer = { x: clientX, y: clientY };
|
|
51
|
-
$rootProps.isOpen = $pointerOrigin.y > window.innerHeight / 2 ? clientY < window.innerHeight * BOTTOM_THRESHOLD : clientY < window.innerHeight * TOP_THRESHOLD;
|
|
52
|
-
}
|
|
53
|
-
function handlePointerUp() {
|
|
54
|
-
if (!$pointerOrigin || !$content) return;
|
|
55
|
-
$dragState = "drop";
|
|
56
|
-
function handleTransitionEnd({ propertyName }) {
|
|
57
|
-
if (propertyName === "transform") {
|
|
58
|
-
handlePointerAndKeyboardDragEnd();
|
|
59
|
-
$content?.removeEventListener("transitionend", handleTransitionEnd);
|
|
60
|
-
if (transitionTimeoutId) {
|
|
61
|
-
clearTimeout(transitionTimeoutId);
|
|
62
|
-
transitionTimeoutId = null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
$content?.addEventListener("transitionend", handleTransitionEnd);
|
|
67
|
-
transitionTimeoutId = setTimeout(() => {
|
|
68
|
-
handlePointerAndKeyboardDragEnd();
|
|
69
|
-
$content?.removeEventListener("transitionend", handleTransitionEnd);
|
|
70
|
-
transitionTimeoutId = null;
|
|
71
|
-
}, 400 + 100);
|
|
72
|
-
}
|
|
73
|
-
async function handlePointerAndKeyboardDragEnd() {
|
|
74
|
-
if (pointerId) $content?.releasePointerCapture(pointerId);
|
|
75
|
-
$pointerOrigin = null;
|
|
76
|
-
$contentOrigin = null;
|
|
77
|
-
$dragState = "idle";
|
|
78
|
-
}
|
|
79
|
-
</script>
|
|
80
|
-
|
|
81
|
-
<div class="sdd-root" data-drag-state={$dragState} on:pointerdown={handlePointerDown}>
|
|
82
|
-
<slot />
|
|
83
|
-
</div>
|
|
84
|
-
|
|
85
|
-
<style>
|
|
86
|
-
.sdd-root {
|
|
87
|
-
position: fixed;
|
|
88
|
-
inset: 0;
|
|
89
|
-
pointer-events: none;
|
|
90
|
-
z-index: 9999;
|
|
91
|
-
|
|
92
|
-
&:not(:has([data-role='handle'])),
|
|
93
|
-
& [data-role='handle'] {
|
|
94
|
-
touch-action: none;
|
|
95
|
-
cursor: grab;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
&[data-drag-state*='drag'],
|
|
99
|
-
&[data-drag-state*='drag'] [data-role='handle'] {
|
|
100
|
-
cursor: grabbing;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
</style>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { RootProps } from '../exports.js';
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
isOpen?: RootProps["isOpen"];
|
|
6
|
-
};
|
|
7
|
-
events: {
|
|
8
|
-
[evt: string]: CustomEvent<any>;
|
|
9
|
-
};
|
|
10
|
-
slots: {
|
|
11
|
-
default: {};
|
|
12
|
-
};
|
|
13
|
-
exports?: {} | undefined;
|
|
14
|
-
bindings?: string | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type DraggableDrawerProps = typeof __propDef.props;
|
|
17
|
-
export type DraggableDrawerEvents = typeof __propDef.events;
|
|
18
|
-
export type DraggableDrawerSlots = typeof __propDef.slots;
|
|
19
|
-
export default class DraggableDrawer extends SvelteComponent<DraggableDrawerProps, DraggableDrawerEvents, DraggableDrawerSlots> {
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<script>import { getPointer, getRootProps } from "../stores/index.js";
|
|
2
|
-
import { getDragState } from "../stores/states.js";
|
|
3
|
-
let offsetHeight;
|
|
4
|
-
const rootProps = getRootProps();
|
|
5
|
-
const pointer = getPointer();
|
|
6
|
-
const dragState = getDragState();
|
|
7
|
-
function getStyleOpacity(...args) {
|
|
8
|
-
if ($dragState === "drag" && $pointer) {
|
|
9
|
-
return ($pointer.y / offsetHeight / 2 - 0.5) * -1;
|
|
10
|
-
}
|
|
11
|
-
if ($rootProps.isOpen) return 0.5;
|
|
12
|
-
return 0;
|
|
13
|
-
}
|
|
14
|
-
function getStyleTransition(...args) {
|
|
15
|
-
if ($dragState !== "drag-start" && $dragState !== "drag") return "opacity 240ms";
|
|
16
|
-
return "none";
|
|
17
|
-
}
|
|
18
|
-
$: styleOpacity = getStyleOpacity($pointer, $dragState, $rootProps.isOpen);
|
|
19
|
-
$: styleTransition = getStyleTransition($dragState);
|
|
20
|
-
const handleClick = () => {
|
|
21
|
-
$rootProps.isOpen = false;
|
|
22
|
-
};
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<div
|
|
26
|
-
bind:offsetHeight
|
|
27
|
-
class="sdd-backdrop"
|
|
28
|
-
style:opacity={styleOpacity}
|
|
29
|
-
style:transition={styleTransition}
|
|
30
|
-
style:pointer-events={$rootProps.isOpen ? 'auto' : 'none'}
|
|
31
|
-
aria-hidden="true"
|
|
32
|
-
on:click={handleClick}
|
|
33
|
-
></div>
|
|
34
|
-
|
|
35
|
-
<style>
|
|
36
|
-
.sdd-backdrop {
|
|
37
|
-
position: fixed;
|
|
38
|
-
inset: 0;
|
|
39
|
-
z-index: 0;
|
|
40
|
-
}
|
|
41
|
-
</style>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: Record<string, never>;
|
|
4
|
-
events: {
|
|
5
|
-
[evt: string]: CustomEvent<any>;
|
|
6
|
-
};
|
|
7
|
-
slots: {};
|
|
8
|
-
exports?: {} | undefined;
|
|
9
|
-
bindings?: string | undefined;
|
|
10
|
-
};
|
|
11
|
-
export type DraggableDrawerBackdropProps = typeof __propDef.props;
|
|
12
|
-
export type DraggableDrawerBackdropEvents = typeof __propDef.events;
|
|
13
|
-
export type DraggableDrawerBackdropSlots = typeof __propDef.slots;
|
|
14
|
-
export default class DraggableDrawerBackdrop extends SvelteComponent<DraggableDrawerBackdropProps, DraggableDrawerBackdropEvents, DraggableDrawerBackdropSlots> {
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<script>import { onMount } from "svelte";
|
|
2
|
-
import { getContentOrigin, getPointer, getPointerOrigin } from "../stores/coordinates.js";
|
|
3
|
-
import { getContent, getHandle, getRootProps } from "../stores/index.js";
|
|
4
|
-
import { getDragState } from "../stores/states.js";
|
|
5
|
-
let contentRef;
|
|
6
|
-
const content = getContent();
|
|
7
|
-
const handle = getHandle();
|
|
8
|
-
$: handleRect = $handle?.getBoundingClientRect();
|
|
9
|
-
const rootProps = getRootProps();
|
|
10
|
-
const pointer = getPointer();
|
|
11
|
-
const pointerOrigin = getPointerOrigin();
|
|
12
|
-
const contentOrigin = getContentOrigin();
|
|
13
|
-
const dragState = getDragState();
|
|
14
|
-
onMount(() => {
|
|
15
|
-
$content = contentRef;
|
|
16
|
-
});
|
|
17
|
-
function getStyleTransform(...args) {
|
|
18
|
-
if ($dragState === "drag") {
|
|
19
|
-
if (!$pointer || !$pointerOrigin || !$contentOrigin) return "none";
|
|
20
|
-
const y = $pointerOrigin.y > window.innerHeight / 2 ? $pointer.y > $pointerOrigin.y ? $pointerOrigin.y : $pointer.y : $pointer.y < $pointerOrigin.y ? $pointerOrigin.y : $pointer.y;
|
|
21
|
-
const offset = $contentOrigin.y - $pointerOrigin.y;
|
|
22
|
-
return `translate3d(0, ${y + offset}px, 0)`;
|
|
23
|
-
}
|
|
24
|
-
if ($rootProps.isOpen) return `translate3d(0, calc(0% + ${handleRect?.height || 24}px), 0)`;
|
|
25
|
-
return `translate3d(0, calc(100% - ${handleRect?.height || 48}px), 0)`;
|
|
26
|
-
}
|
|
27
|
-
$: styleTransform = getStyleTransform($pointer, $dragState, $rootProps.isOpen);
|
|
28
|
-
$: styleTransition = $dragState !== "drag-start" && $dragState !== "drag" ? `transform 400ms cubic-bezier(0.32, 0.72, 0, 1)` : "none";
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<div
|
|
32
|
-
bind:this={contentRef}
|
|
33
|
-
class="sdd-content"
|
|
34
|
-
style:transform={styleTransform}
|
|
35
|
-
style:transition={styleTransition}
|
|
36
|
-
>
|
|
37
|
-
<slot />
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
<style>
|
|
41
|
-
.sdd-content {
|
|
42
|
-
display: flex;
|
|
43
|
-
flex-direction: column;
|
|
44
|
-
width: calc(100% - 2rem);
|
|
45
|
-
height: 100%;
|
|
46
|
-
margin-inline: auto;
|
|
47
|
-
pointer-events: auto;
|
|
48
|
-
position: relative;
|
|
49
|
-
z-index: 1;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@media (min-width: 48em) {
|
|
53
|
-
.sdd-content {
|
|
54
|
-
width: calc(100% - 2.5rem);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
</style>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: Record<string, never>;
|
|
4
|
-
events: {
|
|
5
|
-
[evt: string]: CustomEvent<any>;
|
|
6
|
-
};
|
|
7
|
-
slots: {
|
|
8
|
-
default: {};
|
|
9
|
-
};
|
|
10
|
-
exports?: {} | undefined;
|
|
11
|
-
bindings?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
export type DraggableDrawerContentProps = typeof __propDef.props;
|
|
14
|
-
export type DraggableDrawerContentEvents = typeof __propDef.events;
|
|
15
|
-
export type DraggableDrawerContentSlots = typeof __propDef.slots;
|
|
16
|
-
export default class DraggableDrawerContent extends SvelteComponent<DraggableDrawerContentProps, DraggableDrawerContentEvents, DraggableDrawerContentSlots> {
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<script>import { onMount } from "svelte";
|
|
2
|
-
import { getHandle, getRootProps } from "../stores/index.js";
|
|
3
|
-
let handleRef;
|
|
4
|
-
const handle = getHandle();
|
|
5
|
-
const rootProps = getRootProps();
|
|
6
|
-
onMount(() => {
|
|
7
|
-
$handle = handleRef;
|
|
8
|
-
});
|
|
9
|
-
const handleKeyUp = ({ key }) => {
|
|
10
|
-
if (key === "Enter" || key === " ") {
|
|
11
|
-
$rootProps.isOpen = !$rootProps.isOpen;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<button bind:this={handleRef} class="sdd-handle" data-role="handle" on:keyup={handleKeyUp}>
|
|
17
|
-
<slot />
|
|
18
|
-
</button>
|
|
19
|
-
|
|
20
|
-
<style>
|
|
21
|
-
.sdd-handle {
|
|
22
|
-
margin-inline: auto;
|
|
23
|
-
user-select: none;
|
|
24
|
-
}
|
|
25
|
-
</style>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: Record<string, never>;
|
|
4
|
-
events: {
|
|
5
|
-
[evt: string]: CustomEvent<any>;
|
|
6
|
-
};
|
|
7
|
-
slots: {
|
|
8
|
-
default: {};
|
|
9
|
-
};
|
|
10
|
-
exports?: {} | undefined;
|
|
11
|
-
bindings?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
export type DraggableDrawerHandleProps = typeof __propDef.props;
|
|
14
|
-
export type DraggableDrawerHandleEvents = typeof __propDef.events;
|
|
15
|
-
export type DraggableDrawerHandleSlots = typeof __propDef.slots;
|
|
16
|
-
export default class DraggableDrawerHandle extends SvelteComponent<DraggableDrawerHandleProps, DraggableDrawerHandleEvents, DraggableDrawerHandleSlots> {
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { DraggableDrawerCoordinates as Coordinates } from '../types/index.js';
|
|
2
|
-
export declare function setPointer(context: Coordinates['pointer']): import("svelte/store").Writable<{
|
|
3
|
-
x: number;
|
|
4
|
-
y: number;
|
|
5
|
-
} | null>;
|
|
6
|
-
export declare function getPointer(): import("svelte/store").Writable<{
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
} | null>;
|
|
10
|
-
export declare function setPointerOrigin(context: Coordinates['pointerOrigin']): import("svelte/store").Writable<{
|
|
11
|
-
x: number;
|
|
12
|
-
y: number;
|
|
13
|
-
} | null>;
|
|
14
|
-
export declare function getPointerOrigin(): import("svelte/store").Writable<{
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
} | null>;
|
|
18
|
-
export declare function setContentOrigin(context: Coordinates['contentOrigin']): import("svelte/store").Writable<{
|
|
19
|
-
x: number;
|
|
20
|
-
y: number;
|
|
21
|
-
} | null>;
|
|
22
|
-
export declare function getContentOrigin(): import("svelte/store").Writable<{
|
|
23
|
-
x: number;
|
|
24
|
-
y: number;
|
|
25
|
-
} | null>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getWritableContext, setWritableContext } from './index.js';
|
|
2
|
-
export function setPointer(context) {
|
|
3
|
-
return setWritableContext('pointer', context);
|
|
4
|
-
}
|
|
5
|
-
export function getPointer() {
|
|
6
|
-
return getWritableContext('pointer');
|
|
7
|
-
}
|
|
8
|
-
export function setPointerOrigin(context) {
|
|
9
|
-
return setWritableContext('pointerOrigin', context);
|
|
10
|
-
}
|
|
11
|
-
export function getPointerOrigin() {
|
|
12
|
-
return getWritableContext('pointerOrigin');
|
|
13
|
-
}
|
|
14
|
-
export function setContentOrigin(context) {
|
|
15
|
-
return setWritableContext('contentOrigin', context);
|
|
16
|
-
}
|
|
17
|
-
export function getContentOrigin() {
|
|
18
|
-
return getWritableContext('contentOrigin');
|
|
19
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { DraggableDrawerElements as Elements } from '../types/index.js';
|
|
2
|
-
export declare function setRoot(context: Elements['root']): import("svelte/store").Writable<HTMLDivElement | null>;
|
|
3
|
-
export declare function getRoot(): import("svelte/store").Writable<HTMLDivElement | null>;
|
|
4
|
-
export declare function setContent(context: Elements['content']): import("svelte/store").Writable<HTMLDivElement | null>;
|
|
5
|
-
export declare function getContent(): import("svelte/store").Writable<HTMLDivElement | null>;
|
|
6
|
-
export declare function setHandle(context: Elements['handle']): import("svelte/store").Writable<HTMLButtonElement | null>;
|
|
7
|
-
export declare function getHandle(): import("svelte/store").Writable<HTMLButtonElement | null>;
|
package/dist/stores/elements.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getWritableContext, setWritableContext } from './index.js';
|
|
2
|
-
export function setRoot(context) {
|
|
3
|
-
return setWritableContext('root', context);
|
|
4
|
-
}
|
|
5
|
-
export function getRoot() {
|
|
6
|
-
return getWritableContext('root');
|
|
7
|
-
}
|
|
8
|
-
export function setContent(context) {
|
|
9
|
-
return setWritableContext('content', context);
|
|
10
|
-
}
|
|
11
|
-
export function getContent() {
|
|
12
|
-
return getWritableContext('content');
|
|
13
|
-
}
|
|
14
|
-
export function setHandle(context) {
|
|
15
|
-
return setWritableContext('handle', context);
|
|
16
|
-
}
|
|
17
|
-
export function getHandle() {
|
|
18
|
-
return getWritableContext('handle');
|
|
19
|
-
}
|
package/dist/stores/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './coordinates.js';
|
|
2
|
-
export * from './elements.js';
|
|
3
|
-
export * from './props.js';
|
|
4
|
-
export * from './states.js';
|
|
5
|
-
import { type Writable } from 'svelte/store';
|
|
6
|
-
export declare function setWritableContext<T>(key: string, context: T): Writable<T>;
|
|
7
|
-
export declare function getWritableContext<T>(key: string): Writable<T>;
|
package/dist/stores/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from './coordinates.js';
|
|
2
|
-
export * from './elements.js';
|
|
3
|
-
export * from './props.js';
|
|
4
|
-
export * from './states.js';
|
|
5
|
-
import { getContext, setContext } from 'svelte';
|
|
6
|
-
import { writable } from 'svelte/store';
|
|
7
|
-
export function setWritableContext(key, context) {
|
|
8
|
-
const uniqueKey = Symbol.for(key);
|
|
9
|
-
return setContext(uniqueKey, writable(context));
|
|
10
|
-
}
|
|
11
|
-
export function getWritableContext(key) {
|
|
12
|
-
const uniqueKey = Symbol.for(key);
|
|
13
|
-
return getContext(uniqueKey);
|
|
14
|
-
}
|
package/dist/stores/props.d.ts
DELETED
package/dist/stores/props.js
DELETED
package/dist/stores/states.d.ts
DELETED
package/dist/stores/states.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/elements.d.ts
DELETED
package/dist/types/elements.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|