Skip to content

Commit 1bf0e30

Browse files
committed
initialization stuff
1 parent d620463 commit 1bf0e30

24 files changed

+1070
-785
lines changed

.prettierignore

+24
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,27 @@ CHANGELOG.md
2121

2222
vite.config.js.timestamp-*
2323
vite.config.ts.timestamp-*
24+
25+
.DS_Store
26+
node_modules
27+
**/build
28+
**/.svelte-kit
29+
.env
30+
.env.*
31+
!.env.example
32+
33+
# Ignore files for PNPM, NPM and YARN
34+
pnpm-lock.yaml
35+
package-lock.json
36+
yarn.lock
37+
**/.changeset/
38+
.prettierrc
39+
package.json
40+
.vercel
41+
.contentlayer
42+
**/dist
43+
44+
CHANGELOG.md
45+
46+
vite.config.js.timestamp-*
47+
vite.config.ts.timestamp-*

.prettierignore copy

-23
This file was deleted.

.prettierrc

-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@
1414
}
1515
}
1616
],
17-
"tailwindConfig": "./sites/docs/tailwind.config.js",
1817
"tailwindFunctions": ["clsx", "cn", "tv"]
1918
}

.prettierrc copy

-19
This file was deleted.

packages/vaul-svelte/package.json

+27-21
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,41 @@
2424
"!dist/**/*.spec.*"
2525
],
2626
"peerDependencies": {
27-
"svelte": "^4.0.0 || ^5.0.0-next.1"
27+
"svelte": "5.0.0-next.1"
2828
},
2929
"devDependencies": {
30-
"@sveltejs/kit": "^2.0.0",
31-
"@sveltejs/package": "^2.0.0",
32-
"@sveltejs/vite-plugin-svelte": "^3.0.1",
33-
"@testing-library/dom": "^9.3.3",
34-
"@testing-library/svelte": "^4.0.5",
30+
"@sveltejs/kit": "^2.5.18",
31+
"@sveltejs/package": "^2.3.2",
32+
"@sveltejs/vite-plugin-svelte": "^3.1.1",
33+
"@testing-library/dom": "^10.3.1",
34+
"@testing-library/jest-dom": "^6.4.6",
35+
"@testing-library/svelte": "^5.2.1",
3536
"@testing-library/user-event": "^14.5.2",
36-
"@types/node": "^20.10.5",
37+
"@types/jest-axe": "^3.5.9",
38+
"@types/node": "^20.14.10",
39+
"@types/resize-observer-browser": "^0.1.11",
40+
"@types/testing-library__jest-dom": "^5.14.9",
3741
"autoprefixer": "^10.4.16",
38-
"clsx": "^2.1.0",
39-
"jsdom": "^23.0.1",
40-
"postcss": "^8.4.32",
41-
"postcss-load-config": "^5.0.2",
42-
"publint": "^0.1.9",
43-
"svelte": "^4.2.7",
44-
"svelte-check": "^3.6.0",
45-
"tailwindcss": "^3.3.6",
46-
"tslib": "^2.4.1",
47-
"typescript": "^5.0.0",
48-
"vite": "^5.0.3",
49-
"vitest": "^1.0.0",
42+
"jsdom": "^24.1.0",
43+
"publint": "^0.2.8",
44+
"svelte": "5.0.0-next.208",
45+
"svelte-check": "^3.8.4",
46+
"tslib": "^2.6.3",
47+
"typescript": "^5.5.4",
48+
"vite": "^5.3.3",
49+
"vitest": "^2.0.2",
5050
"vitest-dom": "^0.1.1"
5151
},
5252
"svelte": "./dist/index.js",
5353
"types": "./dist/index.d.ts",
5454
"type": "module",
5555
"dependencies": {
56-
"bits-ui": "https://pkg.pr.new/huntabyte/bits-ui/bits-ui@8cd05f0"
57-
}
56+
"bits-ui": "https://pkg.pr.new/huntabyte/bits-ui/bits-ui@8cd05f0",
57+
"svelte-toolbelt": "^0.3.0"
58+
},
59+
"engines": {
60+
"pnpm": ">=8.7.0",
61+
"node": ">=18"
62+
},
63+
"packageManager": "[email protected]"
5864
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import type { ReadableBoxedValues, WithRefProps, WritableBoxedValues } from "svelte-toolbelt";
2+
3+
const CLOSE_THRESHOLD = 0.25;
4+
const SCROLL_LOCK_TIMEOUT = 100;
5+
const BORDER_RADIUS = 8;
6+
const NESTED_DISPLACEMENT = 16;
7+
const WINDOW_TOP_OFFSET = 26;
8+
const DRAG_CLASS = "vaul-dragging";
9+
10+
export type DrawerDirection = "left" | "right" | "top" | "bottom";
11+
12+
export type OnDragEvent = PointerEvent | TouchEvent;
13+
export type OnDrag = (event: OnDragEvent, percentageDragged: number) => void;
14+
export type OnReleaseEvent = PointerEvent | MouseEvent | TouchEvent;
15+
export type OnRelease = (event: OnReleaseEvent, open: boolean) => void;
16+
17+
type DrawerRootStateProps = ReadableBoxedValues<{
18+
closeThreshold: number;
19+
shouldScaleBackground: boolean;
20+
scrollLockTimeout: number;
21+
snapPoints: (string | number)[] | undefined;
22+
fadeFromIndex: number | undefined;
23+
fixed: boolean;
24+
dismissible: boolean;
25+
direction: DrawerDirection;
26+
onDrag: OnDrag;
27+
onRelease: OnRelease;
28+
nested: boolean;
29+
onClose: () => void;
30+
activeSnapPoint: number | string | null | undefined;
31+
}> &
32+
WritableBoxedValues<{
33+
open: boolean;
34+
}>;
35+
36+
class DrawerRootState {
37+
open: DrawerRootStateProps["open"];
38+
closeThreshold: DrawerRootStateProps["closeThreshold"];
39+
shouldScaleBackground: DrawerRootStateProps["shouldScaleBackground"];
40+
scrollLockTimeout: DrawerRootStateProps["scrollLockTimeout"];
41+
snapPoints: DrawerRootStateProps["snapPoints"];
42+
fadeFromIndex: DrawerRootStateProps["fadeFromIndex"];
43+
fixed: DrawerRootStateProps["fixed"];
44+
dismissible: DrawerRootStateProps["dismissible"];
45+
direction: DrawerRootStateProps["direction"];
46+
onDrag: DrawerRootStateProps["onDrag"];
47+
onRelease: DrawerRootStateProps["onRelease"];
48+
nested: DrawerRootStateProps["nested"];
49+
onClose: DrawerRootStateProps["onClose"];
50+
activeSnapPoint: DrawerRootStateProps["activeSnapPoint"];
51+
triggerNode = $state<HTMLElement | null>(null);
52+
overlayNode = $state<HTMLElement | null>(null);
53+
54+
hasBeenOpened = $state(false);
55+
openTime = $state<Date | null>(null);
56+
keyboardIsOpen = $state(false);
57+
drawerNode = $state<HTMLElement | null>(null);
58+
drawerId = $state<string | null>(null);
59+
isDragging = false;
60+
dragStartTime: Date | null = null;
61+
isClosing = false;
62+
pointerStart = 0;
63+
dragEndTime: Date | null = null;
64+
lastTimeDragPrevented: Date | null = null;
65+
isAllowedToDrag = false;
66+
drawerHeight = 0;
67+
previousDiffFromInitial = 0;
68+
initialDrawerHeight = 0;
69+
nestedOpenChangeTimer: ReturnType<typeof setTimeout> | null = null;
70+
71+
constructor(props: DrawerRootStateProps) {
72+
this.open = props.open;
73+
this.closeThreshold = props.closeThreshold;
74+
this.shouldScaleBackground = props.shouldScaleBackground;
75+
this.scrollLockTimeout = props.scrollLockTimeout;
76+
this.snapPoints = props.snapPoints;
77+
this.fadeFromIndex = props.fadeFromIndex;
78+
this.fixed = props.fixed;
79+
this.dismissible = props.dismissible;
80+
this.direction = props.direction;
81+
this.onDrag = props.onDrag;
82+
this.onRelease = props.onRelease;
83+
this.nested = props.nested;
84+
this.onClose = props.onClose;
85+
this.activeSnapPoint = props.activeSnapPoint;
86+
}
87+
}

packages/vaul-svelte/src/lib/vaul/components/content.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Dialog as DialogPrimitive } from "bits-ui";
33
import { getCtx } from "../ctx.js";
44
import type { ContentProps } from "./types.js";
5-
import Visible from "./visible.svelte";
5+
import Visible from "./visible.svelte.js";
66
77
type $$Props = ContentProps;
88
type $$Events = DialogPrimitive.ContentEvents;

packages/vaul-svelte/src/lib/vaul/components/root.svelte

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script lang="ts">
22
import { Dialog as DialogPrimitive } from "bits-ui";
3+
import { get } from "svelte/store";
34
import { setCtx } from "../ctx.js";
45
import type { Props } from "./types.js";
5-
import { get } from "svelte/store";
66
77
type $$Props = Props;
88
@@ -63,7 +63,6 @@
6363
},
6464
closeThreshold,
6565
scrollLockTimeout,
66-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6766
snapPoints: snapPoints as any,
6867
fadeFromIndex,
6968
nested,
@@ -178,11 +177,15 @@
178177
transform: translate3d(0, var(--snap-point-height, 0), 0);
179178
}
180179
181-
:global([data-vaul-drawer][data-vaul-drawer-visible="true"][data-vaul-drawer-direction="left"]) {
180+
:global(
181+
[data-vaul-drawer][data-vaul-drawer-visible="true"][data-vaul-drawer-direction="left"]
182+
) {
182183
transform: translate3d(var(--snap-point-height, 0), 0, 0);
183184
}
184185
185-
:global([data-vaul-drawer][data-vaul-drawer-visible="true"][data-vaul-drawer-direction="right"]) {
186+
:global(
187+
[data-vaul-drawer][data-vaul-drawer-visible="true"][data-vaul-drawer-direction="right"]
188+
) {
186189
transform: translate3d(var(--snap-point-height, 0), 0, 0);
187190
}
188191

packages/vaul-svelte/src/lib/vaul/components/trigger-wrapper.svelte

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// if someone uses `asChild` to modify it. Since it's only exposed as a slot prop
44
// we need something in between the `<DialogPrimitive.Trigger>` and the slot
55
6-
import type { Builder } from "$lib/internal/types.js";
76
import { getCtx } from "../ctx.js";
7+
import type { Builder } from "$lib/internal/types.js";
88
99
export let meltBuilder: Builder;
1010
@@ -16,10 +16,10 @@
1616
1717
// We're wrapping the melt action so we can set the triggerRef
1818
// even if a user is using `asChild`
19-
const wrappedAction = (node: HTMLElement) => {
19+
function wrappedAction(node: HTMLElement) {
2020
triggerRef.set(node as HTMLButtonElement);
2121
return action(node);
22-
};
22+
}
2323
2424
$: Object.assign(rest, {
2525
action: wrappedAction,

packages/vaul-svelte/src/lib/vaul/components/trigger.svelte

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<script lang="ts">
22
import { Dialog as DialogPrimitive } from "bits-ui";
3-
import TriggerWrapper from "./trigger-wrapper.svelte";
43
import { getCtx } from "../ctx.js";
4+
import TriggerWrapper from "./trigger-wrapper.svelte";
55
66
type $$Props = DialogPrimitive.TriggerProps;
7-
type $$Events = DialogPrimitive.TriggerEvents;
87
98
const {
109
refs: { triggerRef },

packages/vaul-svelte/src/lib/vaul/ctx.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { getOptionUpdater } from "$lib/internal/helpers/options.js";
2-
import { createVaul, type CreateVaulProps } from "$lib/internal/vaul.js";
31
import { getContext, setContext } from "svelte";
2+
import { getOptionUpdater } from "$lib/internal/helpers/options.js";
3+
import { type CreateVaulProps, createVaul } from "$lib/internal/vaul.js";
44

55
const VAUL_ROOT = Symbol("VAUL_ROOT");
66

playwright.config.ts

-12
This file was deleted.

0 commit comments

Comments
 (0)