From b2209ed68de5354026d21c56d01de71d87d026df Mon Sep 17 00:00:00 2001 From: Anbraten <6918444+anbraten@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:00:40 +0100 Subject: [PATCH] rm old sample --- .../vue-formkit-schema-wizard/CHANGELOG.md | 29 - packages/vue-formkit-schema-wizard/README.md | 45 -- .../vue-formkit-schema-wizard/package.json | 63 -- .../src/DrawerContent.vue | 69 -- .../src/DrawerOverlay.vue | 21 - .../src/DrawerRoot.vue | 135 ---- .../src/DrawerRootNested.vue | 40 -- .../src/constants.ts | 6 - .../vue-formkit-schema-wizard/src/context.ts | 39 -- .../vue-formkit-schema-wizard/src/controls.ts | 622 ------------------ .../vue-formkit-schema-wizard/src/helpers.ts | 75 --- .../vue-formkit-schema-wizard/src/index.ts | 33 - .../vue-formkit-schema-wizard/src/types.ts | 4 - .../src/usePositionFixed.ts | 102 --- .../src/useSnapPoints.ts | 250 ------- .../tsconfig.app.json | 13 - .../tsconfig.build.json | 23 - .../vue-formkit-schema-wizard/tsconfig.json | 14 - .../tsconfig.node.json | 17 - .../tsconfig.vitest.json | 9 - .../vue-formkit-schema-wizard/vite.config.ts | 47 -- .../vitest.config.ts | 14 - 22 files changed, 1670 deletions(-) delete mode 100644 packages/vue-formkit-schema-wizard/CHANGELOG.md delete mode 100644 packages/vue-formkit-schema-wizard/README.md delete mode 100644 packages/vue-formkit-schema-wizard/package.json delete mode 100644 packages/vue-formkit-schema-wizard/src/DrawerContent.vue delete mode 100644 packages/vue-formkit-schema-wizard/src/DrawerOverlay.vue delete mode 100644 packages/vue-formkit-schema-wizard/src/DrawerRoot.vue delete mode 100644 packages/vue-formkit-schema-wizard/src/DrawerRootNested.vue delete mode 100644 packages/vue-formkit-schema-wizard/src/constants.ts delete mode 100644 packages/vue-formkit-schema-wizard/src/context.ts delete mode 100644 packages/vue-formkit-schema-wizard/src/controls.ts delete mode 100644 packages/vue-formkit-schema-wizard/src/helpers.ts delete mode 100644 packages/vue-formkit-schema-wizard/src/index.ts delete mode 100644 packages/vue-formkit-schema-wizard/src/types.ts delete mode 100644 packages/vue-formkit-schema-wizard/src/usePositionFixed.ts delete mode 100644 packages/vue-formkit-schema-wizard/src/useSnapPoints.ts delete mode 100644 packages/vue-formkit-schema-wizard/tsconfig.app.json delete mode 100644 packages/vue-formkit-schema-wizard/tsconfig.build.json delete mode 100644 packages/vue-formkit-schema-wizard/tsconfig.json delete mode 100644 packages/vue-formkit-schema-wizard/tsconfig.node.json delete mode 100644 packages/vue-formkit-schema-wizard/tsconfig.vitest.json delete mode 100644 packages/vue-formkit-schema-wizard/vite.config.ts delete mode 100644 packages/vue-formkit-schema-wizard/vitest.config.ts diff --git a/packages/vue-formkit-schema-wizard/CHANGELOG.md b/packages/vue-formkit-schema-wizard/CHANGELOG.md deleted file mode 100644 index 780549d..0000000 --- a/packages/vue-formkit-schema-wizard/CHANGELOG.md +++ /dev/null @@ -1,29 +0,0 @@ -# vaul-vue - -## 0.1.0 - -### Minor Changes - -- 6e40283: General DX improvements to bring package inline with Vue standards - -### Patch Changes - -- 771f420: Add readme from root to package release - -## 0.0.3 - -### Patch Changes - -- a176aec: Initial public release - -## 0.0.2 - -### Patch Changes - -- 39b749b: Add publish step for package - -## 0.0.1 - -### Patch Changes - -- 4c95197: Initial MVP of Vaul implementation in Vue diff --git a/packages/vue-formkit-schema-wizard/README.md b/packages/vue-formkit-schema-wizard/README.md deleted file mode 100644 index 0ec3724..0000000 --- a/packages/vue-formkit-schema-wizard/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# Vaul Vue - -Vaul Vue is an unstyled drawer component for Vue that can be used as a Dialog replacement on tablet and mobile devices. -It uses [Radix Vue's Dialog primitive](https://www.radix-vue.com/components/dialog.html) under the hood and is a feature complete port of [Emil Kowalski's Vaul library](https://github.com/emilkowalski/vaul) (built for React). - -## Installation - -```bash -pnpm add vaul-vue -``` - -```bash -npm install vaul-vue -``` - -```bash -yarn add vaul-vue -``` - -## Usage - -```vue - - - -``` - -## Credits - -All credits go to these open-source works and resources - -- Major credits go to [Emil Kowalski](https://emilkowal.ski/) for the original [Vaul library](https://github.com/emilkowalski/vaul). -- [Radix Vue](https://www.radix-vue.com/) for the Dialog primitive used under the hood. diff --git a/packages/vue-formkit-schema-wizard/package.json b/packages/vue-formkit-schema-wizard/package.json deleted file mode 100644 index 3820f74..0000000 --- a/packages/vue-formkit-schema-wizard/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@geprog/vue-formkit-schema-wizard", - "type": "module", - "version": "0.1.0", - "repository": "https://github.com/geprog/vue-form-schema-wizard", - "keywords": [ - "vue", - "vue3", - "drawer", - "dialog", - "modal", - "headless" - ], - "exports": { - ".": { - "import": "./dist/index.js", - "require": "./dist/index.umd.cjs" - } - }, - "main": "./dist/index.umd.cjs", - "module": "./dist/index.js", - "types": "./dist/index.d.ts", - "files": [ - "README.md", - "dist" - ], - "scripts": { - "dev": "vite", - "build": "run-p type-check \"build-only {@}\" --", - "preview": "vite preview", - "test:unit": "vitest", - "build-only": "vite build", - "type-check": "vue-tsc --build --force", - "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", - "format": "prettier --write src/", - "release": "pnpm run build-only" - }, - "dependencies": { - "@vueuse/core": "^10.8.0", - "radix-vue": "^1.4.9", - "vue": "^3.4.5" - }, - "devDependencies": { - "@rushstack/eslint-patch": "^1.3.3", - "@tsconfig/node18": "^18.2.2", - "@types/jsdom": "^21.1.6", - "@types/node": "^18.19.3", - "@vitejs/plugin-vue": "^4.5.2", - "@vue/eslint-config-typescript": "^12.0.0", - "@vue/test-utils": "^2.4.3", - "@vue/tsconfig": "^0.5.0", - "eslint": "^8.49.0", - "eslint-plugin-vue": "^9.17.0", - "jsdom": "^23.0.1", - "npm-run-all2": "^6.1.1", - "typescript": "~5.3.0", - "vite": "^5.0.10", - "vite-plugin-css-injected-by-js": "^3.3.1", - "vite-plugin-dts": "^3.7.0", - "vitest": "^1.0.4", - "vue-tsc": "^1.8.25" - } -} diff --git a/packages/vue-formkit-schema-wizard/src/DrawerContent.vue b/packages/vue-formkit-schema-wizard/src/DrawerContent.vue deleted file mode 100644 index 112cfea..0000000 --- a/packages/vue-formkit-schema-wizard/src/DrawerContent.vue +++ /dev/null @@ -1,69 +0,0 @@ - - - diff --git a/packages/vue-formkit-schema-wizard/src/DrawerOverlay.vue b/packages/vue-formkit-schema-wizard/src/DrawerOverlay.vue deleted file mode 100644 index f994b2c..0000000 --- a/packages/vue-formkit-schema-wizard/src/DrawerOverlay.vue +++ /dev/null @@ -1,21 +0,0 @@ - - - - - diff --git a/packages/vue-formkit-schema-wizard/src/DrawerRoot.vue b/packages/vue-formkit-schema-wizard/src/DrawerRoot.vue deleted file mode 100644 index 76481d0..0000000 --- a/packages/vue-formkit-schema-wizard/src/DrawerRoot.vue +++ /dev/null @@ -1,135 +0,0 @@ - - - - - diff --git a/packages/vue-formkit-schema-wizard/src/DrawerRootNested.vue b/packages/vue-formkit-schema-wizard/src/DrawerRootNested.vue deleted file mode 100644 index 0d1a50e..0000000 --- a/packages/vue-formkit-schema-wizard/src/DrawerRootNested.vue +++ /dev/null @@ -1,40 +0,0 @@ - - - diff --git a/packages/vue-formkit-schema-wizard/src/constants.ts b/packages/vue-formkit-schema-wizard/src/constants.ts deleted file mode 100644 index 4bb2081..0000000 --- a/packages/vue-formkit-schema-wizard/src/constants.ts +++ /dev/null @@ -1,6 +0,0 @@ -export const TRANSITIONS = { - DURATION: 0.5, - EASE: [0.32, 0.72, 0, 1], -} - -export const VELOCITY_THRESHOLD = 0.4 diff --git a/packages/vue-formkit-schema-wizard/src/context.ts b/packages/vue-formkit-schema-wizard/src/context.ts deleted file mode 100644 index a9efbf0..0000000 --- a/packages/vue-formkit-schema-wizard/src/context.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type { ComponentPublicInstance, Ref } from 'vue' -import { createContext } from 'radix-vue' - -export interface DrawerRootContext { - isOpen: Ref - modal: Ref - hasBeenOpened: Ref - isVisible: Ref - drawerRef: Ref - overlayRef: Ref - isDragging: Ref - dragStartTime: Ref - isAllowedToDrag: Ref - snapPoints: Ref<(number | string)[] | undefined> - keyboardIsOpen: Ref - activeSnapPoint: Ref - pointerStartY: Ref - dismissible: Ref - drawerHeightRef: Ref - snapPointsOffset: Ref - onPress: (event: PointerEvent) => void - onDrag: (event: PointerEvent) => void - onRelease: (event: PointerEvent) => void - closeDrawer: () => void - shouldFade: Ref - fadeFromIndex: Ref - shouldScaleBackground: Ref - onNestedDrag: (percentageDragged: number) => void - onNestedRelease: (o: boolean) => void - onNestedOpenChange: (o: boolean) => void - emitClose: () => void - emitDrag: (percentageDragged: number) => void - emitRelease: (open: boolean) => void - emitOpenChange: (o: boolean) => void - nested: Ref -} - -export const [injectDrawerRootContext, provideDrawerRootContext] - = createContext('DrawerRoot') diff --git a/packages/vue-formkit-schema-wizard/src/controls.ts b/packages/vue-formkit-schema-wizard/src/controls.ts deleted file mode 100644 index b4030b5..0000000 --- a/packages/vue-formkit-schema-wizard/src/controls.ts +++ /dev/null @@ -1,622 +0,0 @@ -import { computed, ref, watch } from 'vue' -import type { ComponentPublicInstance, Ref } from 'vue' -import { dampenValue, getTranslateY, reset, set } from './helpers' -import { TRANSITIONS, VELOCITY_THRESHOLD } from './constants' -import { useSnapPoints } from './useSnapPoints' -import { usePositionFixed } from './usePositionFixed' -import type { DrawerRootContext } from './context' - -export const CLOSE_THRESHOLD = 0.25 - -export const SCROLL_LOCK_TIMEOUT = 100 - -export const BORDER_RADIUS = 8 - -export const NESTED_DISPLACEMENT = 16 - -export const WINDOW_TOP_OFFSET = 26 - -export const DRAG_CLASS = 'vaul-dragging' - -export interface WithFadeFromProps { - snapPoints: (number | string)[] - fadeFromIndex: number -} - -export interface WithoutFadeFromProps { - snapPoints?: (number | string)[] - fadeFromIndex?: never -} - -export type DrawerRootProps = { - activeSnapPoint?: number | string | null - closeThreshold?: number - shouldScaleBackground?: boolean - scrollLockTimeout?: number - fixed?: boolean - dismissible?: boolean - modal?: boolean - open?: boolean - defaultOpen?: boolean - nested?: boolean -} & (WithFadeFromProps | WithoutFadeFromProps) - -export interface UseDrawerProps { - open: Ref - snapPoints: Ref<(number | string)[] | undefined> - dismissible: Ref - nested: Ref - fixed: Ref - modal: Ref - shouldScaleBackground: Ref - activeSnapPoint: Ref - fadeFromIndex: Ref - closeThreshold: Ref - scrollLockTimeout: Ref -} - -export interface DrawerRootEmits { - (e: 'drag', percentageDragged: number): void - (e: 'release', open: boolean): void - (e: 'close'): void - (e: 'update:open', open: boolean): void - (e: 'update:activeSnapPoint', val: string | number): void -} - -export interface DialogEmitHandlers { - emitDrag: (percentageDragged: number) => void - emitRelease: (open: boolean) => void - emitClose: () => void - emitOpenChange: (open: boolean) => void -} - -export interface Drawer { - isOpen: Ref - hasBeenOpened: Ref - isVisible: Ref - drawerRef: Ref - overlayRef: Ref - isDragging: Ref - dragStartTime: Ref - isAllowedToDrag: Ref - snapPoints: Ref<(number | string)[] | undefined> - activeSnapPoint: Ref - pointerStartY: Ref - dismissible: Ref - drawerHeightRef: Ref - snapPointsOffset: Ref - onPress: (event: PointerEvent) => void - onDrag: (event: PointerEvent) => void - onRelease: (event: PointerEvent) => void - closeDrawer: () => void -} - -function usePropOrDefaultRef(prop: Ref | undefined, defaultRef: Ref): Ref { - return prop && !!prop.value ? (prop as Ref) : defaultRef -} - -export function useDrawer(props: UseDrawerProps & DialogEmitHandlers): DrawerRootContext { - const { - emitDrag, - emitRelease, - emitClose, - emitOpenChange, - open: isOpen, - dismissible, - nested, - fixed, - modal, - shouldScaleBackground, - scrollLockTimeout, - closeThreshold, - activeSnapPoint, - fadeFromIndex, - } = props - - const hasBeenOpened = ref(false) - const isVisible = ref(false) - const isDragging = ref(false) - const justReleased = ref(false) - - const overlayRef = ref(null) - - const openTime = ref(null) - const dragStartTime = ref(null) - const dragEndTime = ref(null) - const lastTimeDragPrevented = ref(null) - const isAllowedToDrag = ref(true) - - const nestedOpenChangeTimer = ref(null) - - const pointerStartY = ref(0) - const keyboardIsOpen = ref(false) - - const previousDiffFromInitial = ref(0) - - const drawerRef = ref(null) - const initialDrawerHeight = ref(0) - const drawerHeightRef = computed(() => drawerRef.value?.$el.getBoundingClientRect().height || 0) - - const snapPoints = usePropOrDefaultRef( - props.snapPoints, - ref<(number | string)[] | undefined>(undefined), - ) - - // const onCloseProp = ref<(() => void) | undefined>(undefined) - // const onOpenChangeProp = ref<((open: boolean) => void) | undefined>(undefined) - // const onDragProp = ref<((event: PointerEvent, percentageDragged: number) => void) | undefined>( - // undefined - // ) - // const onReleaseProp = ref<((event: PointerEvent, open: boolean) => void) | undefined>(undefined) - - // const fadeFromIndex = ref( - // props.fadeFromIndex ?? (snapPoints.value && snapPoints.value.length - 1) - // ) - - const { - activeSnapPointIndex, - onRelease: onReleaseSnapPoints, - snapPointsOffset, - onDrag: onDragSnapPoints, - shouldFade, - getPercentageDragged: getSnapPointsPercentageDragged, - } = useSnapPoints({ - snapPoints, - activeSnapPoint, - drawerRef, - fadeFromIndex, - overlayRef, - onSnapPointChange, - }) - - function onSnapPointChange(activeSnapPointIndex: number, snapPointsOffset: number[]) { - // Change openTime ref when we reach the last snap point to prevent dragging for 500ms incase it's scrollable. - if (snapPoints.value && activeSnapPointIndex === snapPointsOffset.length - 1) - openTime.value = new Date() - } - - const { restorePositionSetting } = usePositionFixed({ - isOpen, - modal, - nested, - hasBeenOpened, - }) - - function getScale() { - return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth - } - - function shouldDrag(el: EventTarget | null, isDraggingDown: boolean) { - if (!el) - return false - let element = el as HTMLElement - const highlightedText = window.getSelection()?.toString() - const swipeAmount = drawerRef.value ? getTranslateY(drawerRef.value.$el) : null - const date = new Date() - - // Allow scrolling when animating - if (openTime.value && date.getTime() - openTime.value.getTime() < 500) - return false - - if (swipeAmount && swipeAmount > 0) - return true - - // Don't drag if there's highlighted text - if (highlightedText && highlightedText.length > 0) - return false - - // Disallow dragging if drawer was scrolled within `scrollLockTimeout` - if ( - lastTimeDragPrevented.value - && date.getTime() - lastTimeDragPrevented.value.getTime() < scrollLockTimeout.value - && swipeAmount === 0 - ) { - lastTimeDragPrevented.value = date - return false - } - - if (isDraggingDown) { - lastTimeDragPrevented.value = date - - // We are dragging down so we should allow scrolling - return false - } - - // Keep climbing up the DOM tree as long as there's a parent - while (element) { - // Check if the element is scrollable - if (element.scrollHeight > element.clientHeight) { - if (element.scrollTop !== 0) { - lastTimeDragPrevented.value = new Date() - - // The element is scrollable and not scrolled to the top, so don't drag - return false - } - - if (element.getAttribute('role') === 'dialog') - return true - } - - // Move up to the parent element - element = element.parentNode as HTMLElement - } - - // No scrollable parents not scrolled to the top found, so drag - return true - } - - function onPress(event: PointerEvent) { - if (!dismissible.value && !snapPoints.value) - return - if (drawerRef.value && !drawerRef.value.$el.contains(event.target as Node)) - return - isDragging.value = true - dragStartTime.value = new Date() - - // iOS doesn't trigger mouseUp after scrolling so we need to listen to touched in order to disallow dragging - // if (isIOS()) { - // window.addEventListener('touchend', () => (isAllowedToDrag.value = false), { once: true }); - // } - // Ensure we maintain correct pointer capture even when going outside of the drawer - ; (event.target as HTMLElement).setPointerCapture(event.pointerId) - pointerStartY.value = event.screenY - } - - function onDrag(event: PointerEvent) { - // We need to know how much of the drawer has been dragged in percentages so that we can transform background accordingly - if (isDragging.value) { - const draggedDistance = pointerStartY.value - event.screenY - const isDraggingDown = draggedDistance > 0 - - // Disallow dragging down to close when first snap point is the active one and dismissible prop is set to false. - if (snapPoints.value && activeSnapPointIndex.value === 0 && !dismissible.value) - return - - if (!isAllowedToDrag.value && !shouldDrag(event.target, isDraggingDown)) - return - drawerRef?.value?.$el.classList.add(DRAG_CLASS) - // If shouldDrag gave true once after pressing down on the drawer, we set isAllowedToDrag to true and it will remain true until we let go, there's no reason to disable dragging mid way, ever, and that's the solution to it - isAllowedToDrag.value = true - set(drawerRef.value?.$el, { - transition: 'none', - }) - - set(overlayRef.value?.$el, { - transition: 'none', - }) - - if (snapPoints.value) - onDragSnapPoints({ draggedDistance }) - - // Run this only if snapPoints are not defined or if we are at the last snap point (highest one) - if (isDraggingDown && !snapPoints.value) { - const dampenedDraggedDistance = dampenValue(draggedDistance) - - set(drawerRef.value?.$el, { - transform: `translate3d(0, ${Math.min(dampenedDraggedDistance * -1, 0)}px, 0)`, - }) - return - } - - // We need to capture last time when drag with scroll was triggered and have a timeout between - const absDraggedDistance = Math.abs(draggedDistance) - const wrapper = document.querySelector('[vaul-drawer-wrapper]') - - let percentageDragged = absDraggedDistance / drawerHeightRef.value - const snapPointPercentageDragged = getSnapPointsPercentageDragged( - absDraggedDistance, - isDraggingDown, - ) - - if (snapPointPercentageDragged !== null) - percentageDragged = snapPointPercentageDragged - - const opacityValue = 1 - percentageDragged - - if ( - shouldFade.value - || (fadeFromIndex.value && activeSnapPointIndex.value === fadeFromIndex.value - 1) - ) { - emitDrag(percentageDragged) - - set( - overlayRef.value?.$el, - { - opacity: `${opacityValue}`, - transition: 'none', - }, - true, - ) - } - - if (wrapper && overlayRef.value && shouldScaleBackground.value) { - // Calculate percentageDragged as a fraction (0 to 1) - const scaleValue = Math.min(getScale() + percentageDragged * (1 - getScale()), 1) - const borderRadiusValue = 8 - percentageDragged * 8 - - const translateYValue = Math.max(0, 14 - percentageDragged * 14) - - set( - wrapper, - { - borderRadius: `${borderRadiusValue}px`, - transform: `scale(${scaleValue}) translate3d(0, ${translateYValue}px, 0)`, - transition: 'none', - }, - true, - ) - } - - if (!snapPoints.value) { - set(drawerRef.value?.$el, { - transform: `translate3d(0, ${absDraggedDistance}px, 0)`, - }) - } - } - } - - function resetDrawer() { - if (!drawerRef.value) - return - const wrapper = document.querySelector('[vaul-drawer-wrapper]') - const currentSwipeAmount = getTranslateY(drawerRef.value.$el) - - set(drawerRef.value.$el, { - transform: 'translate3d(0, 0, 0)', - transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - }) - - set(overlayRef.value?.$el, { - transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - opacity: '1', - }) - - // Don't reset background if swiped upwards - if (shouldScaleBackground.value && currentSwipeAmount && currentSwipeAmount > 0 && isOpen) { - set( - wrapper, - { - borderRadius: `${BORDER_RADIUS}px`, - overflow: 'hidden', - transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`, - transformOrigin: 'top', - transitionProperty: 'transform, border-radius', - transitionDuration: `${TRANSITIONS.DURATION}s`, - transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - }, - true, - ) - } - } - - function closeDrawer() { - if (!drawerRef.value) - return - - // emitClose() - set(drawerRef.value.$el, { - transform: `translate3d(0, 100%, 0)`, - transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - }) - - set(overlayRef.value?.$el, { - opacity: '0', - transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - }) - - scaleBackground(false) - restorePositionSetting() - - isVisible.value = false - window.setTimeout(() => { - emitOpenChange(false) - // isOpen.value = false - }, 300) - - window.setTimeout(() => { - if (snapPoints.value) - activeSnapPoint.value = snapPoints.value[0] - }, TRANSITIONS.DURATION * 1000) // seconds to ms - } - - function onRelease(event: PointerEvent) { - if (!isDragging.value || !drawerRef.value) - return - // TODO use-prevent-scroll - // if (isAllowedToDrag.value && isInput(event.target as HTMLElement)) { - // // If we were just dragging, prevent focusing on inputs etc. on release - // (event.target as HTMLInputElement).blur(); - // } - drawerRef.value.$el.classList.remove(DRAG_CLASS) - isAllowedToDrag.value = false - isDragging.value = false - dragEndTime.value = new Date() - const swipeAmount = getTranslateY(drawerRef.value.$el) - - if (!shouldDrag(event.target, false) || !swipeAmount || Number.isNaN(swipeAmount)) - return - - if (dragStartTime.value === null) - return - - const timeTaken = dragEndTime.value.getTime() - dragStartTime.value.getTime() - const distMoved = pointerStartY.value - event.screenY - const velocity = Math.abs(distMoved) / timeTaken - - if (velocity > 0.05) { - // `justReleased` is needed to prevent the drawer from focusing on an input when the drag ends, as it's not the intent most of the time. - justReleased.value = true - - window.setTimeout(() => { - justReleased.value = false - }, 200) - } - - if (snapPoints.value) { - onReleaseSnapPoints({ - draggedDistance: distMoved, - closeDrawer, - velocity, - dismissible: dismissible.value, - }) - emitRelease(true) - return - } - - // Moved upwards, don't do anything - if (distMoved > 0) { - resetDrawer() - emitRelease(true) - return - } - - if (velocity > VELOCITY_THRESHOLD) { - closeDrawer() - emitRelease(false) - return - } - - const visibleDrawerHeight = Math.min( - drawerRef.value.$el.getBoundingClientRect().height ?? 0, - window.innerHeight, - ) - - if (swipeAmount >= visibleDrawerHeight * closeThreshold.value) { - closeDrawer() - emitRelease(false) - return - } - - emitRelease(true) - resetDrawer() - } - - watch(isOpen, (open) => { - if (open) { - openTime.value = new Date() - scaleBackground(true) - } - emitOpenChange(open) - }) - - function scaleBackground(open: boolean) { - const wrapper = document.querySelector('[vaul-drawer-wrapper]') - if (!wrapper || !shouldScaleBackground.value) - return - - if (open) { - set( - document.body, - { - background: 'black', - }, - true, - ) - - set(wrapper, { - borderRadius: `${BORDER_RADIUS}px`, - overflow: 'hidden', - transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`, - transformOrigin: 'top', - transitionProperty: 'transform, border-radius', - transitionDuration: `${TRANSITIONS.DURATION}s`, - transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - }) - } - else { - // Exit - reset(wrapper, 'overflow') - reset(wrapper, 'transform') - reset(wrapper, 'borderRadius') - set(wrapper, { - transitionProperty: 'transform, border-radius', - transitionDuration: `${TRANSITIONS.DURATION}s`, - transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - }) - } - } - - function onNestedOpenChange(o: boolean) { - const scale = o ? (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth : 1 - const y = o ? -NESTED_DISPLACEMENT : 0 - - if (nestedOpenChangeTimer.value) - window.clearTimeout(nestedOpenChangeTimer.value) - - set(drawerRef.value?.$el, { - transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - transform: `scale(${scale}) translate3d(0, ${y}px, 0)`, - }) - - if (!o && drawerRef.value?.$el) { - nestedOpenChangeTimer.value = window.setTimeout(() => { - set(drawerRef.value?.$el, { - transition: 'none', - transform: `translate3d(0, ${getTranslateY(drawerRef.value?.$el as HTMLElement)}px, 0)`, - }) - }, 500) - } - } - - function onNestedDrag(percentageDragged: number) { - if (percentageDragged < 0) - return - - const initialScale = (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth - const newScale = initialScale + percentageDragged * (1 - initialScale) - const newY = -NESTED_DISPLACEMENT + percentageDragged * NESTED_DISPLACEMENT - - set(drawerRef.value?.$el, { - transform: `scale(${newScale}) translate3d(0, ${newY}px, 0)`, - transition: 'none', - }) - } - - function onNestedRelease(o: boolean) { - const scale = o ? (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth : 1 - const y = o ? -NESTED_DISPLACEMENT : 0 - - if (o) { - set(drawerRef.value?.$el, { - transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join( - ',', - )})`, - transform: `scale(${scale}) translate3d(0, ${y}px, 0)`, - }) - } - } - - return { - isOpen, - modal, - keyboardIsOpen, - hasBeenOpened, - isVisible, - drawerRef, - drawerHeightRef, - overlayRef, - isDragging, - dragStartTime, - isAllowedToDrag, - snapPoints, - activeSnapPoint, - pointerStartY, - dismissible, - snapPointsOffset, - shouldFade, - fadeFromIndex, - shouldScaleBackground, - onPress, - onDrag, - onRelease, - closeDrawer, - onNestedDrag, - onNestedRelease, - onNestedOpenChange, - emitClose, - emitDrag, - emitRelease, - emitOpenChange, - nested, - } -} diff --git a/packages/vue-formkit-schema-wizard/src/helpers.ts b/packages/vue-formkit-schema-wizard/src/helpers.ts deleted file mode 100644 index e9147c2..0000000 --- a/packages/vue-formkit-schema-wizard/src/helpers.ts +++ /dev/null @@ -1,75 +0,0 @@ -interface Style { - [key: string]: string -} - -const cache = new WeakMap() - -export function isInView(el: HTMLElement): boolean { - const rect = el.getBoundingClientRect() - - if (!window.visualViewport) - return false - - return ( - rect.top >= 0 - && rect.left >= 0 - // Need + 40 for safari detection - && rect.bottom <= window.visualViewport.height - 40 - && rect.right <= window.visualViewport.width - ) -} - -export function set(el?: Element | HTMLElement | null, styles?: Style, ignoreCache = false) { - if (!el || !(el instanceof HTMLElement) || !styles) - return - const originalStyles: Style = {} - - Object.entries(styles).forEach(([key, value]: [string, string]) => { - if (key.startsWith('--')) { - el.style.setProperty(key, value) - return - } - - originalStyles[key] = (el.style as any)[key]; - (el.style as any)[key] = value - }) - - if (ignoreCache) - return - - cache.set(el, originalStyles) -} - -export function reset(el: Element | HTMLElement | null, prop?: string) { - if (!el || !(el instanceof HTMLElement)) - return - const originalStyles = cache.get(el) - - if (!originalStyles) - return - - if (prop) { - ; (el.style as any)[prop] = originalStyles[prop] - } - else { - Object.entries(originalStyles).forEach(([key, value]) => { - ; (el.style as any)[key] = value - }) - } -} - -export function getTranslateY(element: HTMLElement): number | null { - const style = window.getComputedStyle(element) - const transform - // @ts-expect-error some custom style only exist in certain browser - = style.transform || style.webkitTransform || style.mozTransform - let mat = transform.match(/^matrix3d\((.+)\)$/) - if (mat) - return Number.parseFloat(mat[1].split(', ')[13]) - mat = transform.match(/^matrix\((.+)\)$/) - return mat ? Number.parseFloat(mat[1].split(', ')[5]) : null -} - -export function dampenValue(v: number) { - return 8 * (Math.log(v + 1) - 2) -} diff --git a/packages/vue-formkit-schema-wizard/src/index.ts b/packages/vue-formkit-schema-wizard/src/index.ts deleted file mode 100644 index 3d57325..0000000 --- a/packages/vue-formkit-schema-wizard/src/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -import DrawerRoot from './DrawerRoot.vue' -import DrawerRootNested from './DrawerRootNested.vue' -import DrawerOverlay from './DrawerOverlay.vue' -import DrawerContent from './DrawerContent.vue' - -export type { - DrawerRootEmits, - DrawerRootProps, -} from './controls' - -export { - DrawerRoot, - DrawerRootNested, - DrawerOverlay, - DrawerContent, -} - -export { - DialogClose as DrawerClose, - type DialogCloseProps as DrawerCloseProps, - - DialogDescription as DrawerDescription, - type DialogDescriptionProps as DrawerDescriptionProps, - - DialogPortal as DrawerPortal, - type DialogPortalProps as DrawerPortalProps, - - DialogTitle as DrawerTitle, - type DialogTitleProps as DrawerTitleProps, - - DialogTrigger as DrawerTrigger, - type DialogTriggerProps as DrawerTriggerProps, -} from 'radix-vue' diff --git a/packages/vue-formkit-schema-wizard/src/types.ts b/packages/vue-formkit-schema-wizard/src/types.ts deleted file mode 100644 index a7ea572..0000000 --- a/packages/vue-formkit-schema-wizard/src/types.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface SnapPoint { - fraction: number - height: number -} diff --git a/packages/vue-formkit-schema-wizard/src/usePositionFixed.ts b/packages/vue-formkit-schema-wizard/src/usePositionFixed.ts deleted file mode 100644 index 004fc0a..0000000 --- a/packages/vue-formkit-schema-wizard/src/usePositionFixed.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { type Ref, onMounted, onUnmounted, ref, watch } from 'vue' - -interface BodyPosition { - position: string - top: string - left: string - height: string -} - -interface PositionFixedOptions { - isOpen: Ref - modal: Ref - nested: Ref - hasBeenOpened: Ref -} - -let previousBodyPosition: BodyPosition | null = null - -export function usePositionFixed(options: PositionFixedOptions) { - const { isOpen, modal, nested, hasBeenOpened } = options - const activeUrl = ref(typeof window !== 'undefined' ? window.location.href : '') - const scrollPos = ref(0) - - function setPositionFixed(): void { - if (previousBodyPosition === null && isOpen.value) { - previousBodyPosition = { - position: document.body.style.position, - top: document.body.style.top, - left: document.body.style.left, - height: document.body.style.height, - } - - const { scrollX, innerHeight } = window - - document.body.style.position = 'fixed' - document.body.style.top = `-${scrollPos.value}px` - document.body.style.left = `-${scrollX}px` - document.body.style.right = '0px' - document.body.style.height = 'auto' - - setTimeout(() => { - requestAnimationFrame(() => { - const bottomBarHeight = innerHeight - window.innerHeight - if (bottomBarHeight && scrollPos.value >= innerHeight) - document.body.style.top = `-${scrollPos.value + bottomBarHeight}px` - }) - }, 300) - } - } - - function restorePositionSetting(): void { - if (previousBodyPosition !== null) { - const y = -Number.parseInt(document.body.style.top, 10) - const x = -Number.parseInt(document.body.style.left, 10) - - Object.assign(document.body.style, previousBodyPosition) - - requestAnimationFrame(() => { - if (activeUrl.value !== window.location.href) { - activeUrl.value = window.location.href - return - } - - window.scrollTo(x, y) - }) - - previousBodyPosition = null - } - } - - onMounted(() => { - function onScroll() { - scrollPos.value = window.scrollY - } - - onScroll() - window.addEventListener('scroll', onScroll) - - onUnmounted(() => { - window.removeEventListener('scroll', onScroll) - }) - }) - - watch([isOpen, hasBeenOpened, activeUrl], () => { - if (nested.value || !hasBeenOpened.value) - return - if (isOpen.value) { - setPositionFixed() - - if (!modal) { - setTimeout(() => { - restorePositionSetting() - }, 500) - } - } - else { - restorePositionSetting() - } - }) - - return { restorePositionSetting } -} diff --git a/packages/vue-formkit-schema-wizard/src/useSnapPoints.ts b/packages/vue-formkit-schema-wizard/src/useSnapPoints.ts deleted file mode 100644 index 37baaee..0000000 --- a/packages/vue-formkit-schema-wizard/src/useSnapPoints.ts +++ /dev/null @@ -1,250 +0,0 @@ -import { type ComponentPublicInstance, type Ref, computed, nextTick, watch } from 'vue' -import { set } from './helpers' -import { TRANSITIONS, VELOCITY_THRESHOLD } from './constants' - -interface useSnapPointsProps { - activeSnapPoint: Ref - snapPoints: Ref<(number | string)[] | undefined> - fadeFromIndex: Ref - drawerRef: Ref - overlayRef: Ref - onSnapPointChange: (activeSnapPointIndex: number, snapPointsOffset: number[]) => void -} - -export function useSnapPoints({ - activeSnapPoint, - snapPoints, - drawerRef, - overlayRef, - fadeFromIndex, - onSnapPointChange, -}: useSnapPointsProps) { - const isLastSnapPoint = computed( - () => - (snapPoints.value - && activeSnapPoint.value === snapPoints.value[snapPoints.value.length - 1]) - ?? null, - ) - - const shouldFade = computed( - () => - (snapPoints.value - && snapPoints.value.length > 0 - && (fadeFromIndex?.value || fadeFromIndex?.value === 0) - && !Number.isNaN(fadeFromIndex?.value) - && snapPoints.value[fadeFromIndex?.value ?? -1] === activeSnapPoint.value) - || !snapPoints.value, - ) - - const activeSnapPointIndex = computed( - () => snapPoints.value?.findIndex(snapPoint => snapPoint === activeSnapPoint.value) ?? null, - ) - - const snapPointsOffset = computed( - () => - snapPoints.value?.map((snapPoint) => { - const hasWindow = typeof window !== 'undefined' - const isPx = typeof snapPoint === 'string' - let snapPointAsNumber = 0 - - if (isPx) - snapPointAsNumber = Number.parseInt(snapPoint, 10) - - const height = isPx ? snapPointAsNumber : hasWindow ? snapPoint * window.innerHeight : 0 - - if (hasWindow) - return window.innerHeight - height - - return height - }) ?? [], - ) - - const activeSnapPointOffset = computed(() => - activeSnapPointIndex.value !== null - ? snapPointsOffset.value?.[activeSnapPointIndex.value] - : null, - ) - - const snapToPoint = (height: number) => { - const newSnapPointIndex - = snapPointsOffset.value?.findIndex(snapPointHeight => snapPointHeight === height) ?? null - - // nextTick to allow el to be mounted before setting it. - nextTick(() => { - onSnapPointChange(newSnapPointIndex, snapPointsOffset.value) - set(drawerRef.value?.$el, { - transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - transform: `translate3d(0, ${height}px, 0)`, - }) - }) - - if ( - snapPointsOffset.value - && newSnapPointIndex !== snapPointsOffset.value.length - 1 - && newSnapPointIndex !== fadeFromIndex?.value - ) { - set(overlayRef.value?.$el, { - transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - opacity: '0', - }) - } - else { - set(overlayRef.value?.$el, { - transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - opacity: '1', - }) - } - - activeSnapPoint.value - = newSnapPointIndex !== null ? snapPoints.value?.[newSnapPointIndex] ?? null : null - } - - watch( - [activeSnapPoint, snapPointsOffset, snapPoints], - () => { - if (activeSnapPoint.value) { - const newIndex - = snapPoints.value?.findIndex(snapPoint => snapPoint === activeSnapPoint.value) ?? -1 - - if ( - snapPointsOffset.value - && newIndex !== -1 - && typeof snapPointsOffset.value[newIndex] === 'number' - ) - snapToPoint(snapPointsOffset.value[newIndex]) - } - }, - { - immediate: true, // if you want to run the effect immediately as well - }, - ) - - function onRelease({ - draggedDistance, - closeDrawer, - velocity, - dismissible, - }: { - draggedDistance: number - closeDrawer: () => void - velocity: number - dismissible: boolean - }) { - if (fadeFromIndex === undefined) - return - - const currentPosition = (activeSnapPointOffset.value ?? 0) - draggedDistance - const isOverlaySnapPoint = activeSnapPointIndex.value === (fadeFromIndex.value ?? 0) - 1 - const isFirst = activeSnapPointIndex.value === 0 - const hasDraggedUp = draggedDistance > 0 - - if (isOverlaySnapPoint) { - set(overlayRef.value?.$el, { - transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`, - }) - } - - if (velocity > 2 && !hasDraggedUp) { - if (dismissible) - closeDrawer() - else snapToPoint(snapPointsOffset.value[0]) // snap to initial point - return - } - - if (velocity > 2 && hasDraggedUp && snapPointsOffset && snapPoints.value) { - snapToPoint(snapPointsOffset.value[snapPoints.value.length - 1] as number) - return - } - - // Find the closest snap point to the current position - const closestSnapPoint = snapPointsOffset.value?.reduce((prev, curr) => { - if (typeof prev !== 'number' || typeof curr !== 'number') - return prev - - return Math.abs(curr - currentPosition) < Math.abs(prev - currentPosition) ? curr : prev - }) - - if (velocity > VELOCITY_THRESHOLD && Math.abs(draggedDistance) < window.innerHeight * 0.4) { - const dragDirection = hasDraggedUp ? 1 : -1 // 1 = up, -1 = down - - // Don't do anything if we swipe upwards while being on the last snap point - if (dragDirection > 0 && isLastSnapPoint) { - snapToPoint(snapPointsOffset.value[(snapPoints.value?.length ?? 0) - 1]) - return - } - - if (isFirst && dragDirection < 0 && dismissible) - closeDrawer() - - if (activeSnapPointIndex.value === null) - return - - snapToPoint(snapPointsOffset.value[activeSnapPointIndex.value + dragDirection]) - return - } - - snapToPoint(closestSnapPoint) - } - - function onDrag({ draggedDistance }: { draggedDistance: number }) { - if (activeSnapPointOffset.value === null) - return - const newYValue = activeSnapPointOffset.value - draggedDistance - - set(drawerRef.value?.$el, { - transform: `translate3d(0, ${newYValue}px, 0)`, - }) - } - - function getPercentageDragged(absDraggedDistance: number, isDraggingDown: boolean) { - if ( - !snapPoints - || typeof activeSnapPointIndex.value !== 'number' - || !snapPointsOffset.value - || fadeFromIndex === undefined - ) - return null - - // If this is true we are dragging to a snap point that is supposed to have an overlay - const isOverlaySnapPoint = activeSnapPointIndex.value === (fadeFromIndex.value ?? 0) - 1 - const isOverlaySnapPointOrHigher = activeSnapPointIndex.value >= (fadeFromIndex.value ?? 0) - - if (isOverlaySnapPointOrHigher && isDraggingDown) - return 0 - - // Don't animate, but still use this one if we are dragging away from the overlaySnapPoint - if (isOverlaySnapPoint && !isDraggingDown) - return 1 - if (!shouldFade.value && !isOverlaySnapPoint) - return null - - // Either fadeFrom index or the one before - const targetSnapPointIndex = isOverlaySnapPoint - ? activeSnapPointIndex.value + 1 - : activeSnapPointIndex.value - 1 - - // Get the distance from overlaySnapPoint to the one before or vice-versa to calculate the opacity percentage accordingly - const snapPointDistance = isOverlaySnapPoint - ? snapPointsOffset.value[targetSnapPointIndex] - - snapPointsOffset.value[targetSnapPointIndex - 1] - : snapPointsOffset.value[targetSnapPointIndex + 1] - - snapPointsOffset.value[targetSnapPointIndex] - - const percentageDragged = absDraggedDistance / Math.abs(snapPointDistance) - - if (isOverlaySnapPoint) - return 1 - percentageDragged - else - return percentageDragged - } - - return { - isLastSnapPoint, - shouldFade, - getPercentageDragged, - activeSnapPointIndex, - onRelease, - onDrag, - snapPointsOffset, - } -} diff --git a/packages/vue-formkit-schema-wizard/tsconfig.app.json b/packages/vue-formkit-schema-wizard/tsconfig.app.json deleted file mode 100644 index 8790474..0000000 --- a/packages/vue-formkit-schema-wizard/tsconfig.app.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "@vue/tsconfig/tsconfig.dom.json", - "compilerOptions": { - "composite": true, - "baseUrl": "../..", - "paths": { - "@/*": ["./src/*"] - }, - "noEmit": true - }, - "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], - "exclude": ["src/**/__tests__/*"] -} diff --git a/packages/vue-formkit-schema-wizard/tsconfig.build.json b/packages/vue-formkit-schema-wizard/tsconfig.build.json deleted file mode 100644 index f621465..0000000 --- a/packages/vue-formkit-schema-wizard/tsconfig.build.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "extends": "@vue/tsconfig/tsconfig.app.json", - "compilerOptions": { - "target": "esnext", - "jsx": "preserve", - "lib": ["esnext", "dom"], - "baseUrl": ".", - "module": "esnext", - "moduleResolution": "node", - "paths": { - "@/*": ["src/*"] - }, - "resolveJsonModule": true, - "strict": true, - "declaration": false, - "outDir": "dist", - "sourceMap": true, - "esModuleInterop": true, - "skipLibCheck": true - }, - "include": ["env.d.ts", "src/**/*", "src/**/*.ts", "src/**/*.vue"], - "exclude": ["src/**/*.test.ts", "src/**/*.spec.ts"] -} diff --git a/packages/vue-formkit-schema-wizard/tsconfig.json b/packages/vue-formkit-schema-wizard/tsconfig.json deleted file mode 100644 index e44f9a1..0000000 --- a/packages/vue-formkit-schema-wizard/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "references": [ - { - "path": "./tsconfig.node.json" - }, - { - "path": "./tsconfig.app.json" - }, - { - "path": "./tsconfig.vitest.json" - } - ], - "files": [] -} diff --git a/packages/vue-formkit-schema-wizard/tsconfig.node.json b/packages/vue-formkit-schema-wizard/tsconfig.node.json deleted file mode 100644 index 9ec53da..0000000 --- a/packages/vue-formkit-schema-wizard/tsconfig.node.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "@tsconfig/node18/tsconfig.json", - "compilerOptions": { - "composite": true, - "module": "ESNext", - "moduleResolution": "Bundler", - "types": ["node"], - "noEmit": true - }, - "include": [ - "vite.config.*", - "vitest.config.*", - "cypress.config.*", - "nightwatch.conf.*", - "playwright.config.*" - ] -} diff --git a/packages/vue-formkit-schema-wizard/tsconfig.vitest.json b/packages/vue-formkit-schema-wizard/tsconfig.vitest.json deleted file mode 100644 index 3e0c090..0000000 --- a/packages/vue-formkit-schema-wizard/tsconfig.vitest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.app.json", - "compilerOptions": { - "composite": true, - "lib": [], - "types": ["node", "jsdom"] - }, - "exclude": [] -} diff --git a/packages/vue-formkit-schema-wizard/vite.config.ts b/packages/vue-formkit-schema-wizard/vite.config.ts deleted file mode 100644 index abaf694..0000000 --- a/packages/vue-formkit-schema-wizard/vite.config.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { resolve } from 'node:path' -import { defineConfig } from 'vite' -import vue from '@vitejs/plugin-vue' -import dts from 'vite-plugin-dts' -import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js' - -// https://vitejs.dev/config/ -export default defineConfig({ - plugins: [ - vue(), - cssInjectedByJsPlugin(), - dts({ - tsconfigPath: 'tsconfig.build.json', - cleanVueFileName: true, - }), - ], - resolve: { - alias: { - '@': resolve(__dirname, 'src'), - }, - }, - build: { - lib: { - name: 'vaul-vue', - fileName: 'index', - entry: resolve(__dirname, 'src/index.ts'), - }, - outDir: 'dist', - rollupOptions: { - // make sure to externalize deps that shouldn't be bundled - // into your library (Vue) - external: ['vue'], - output: { - // Provide global variables to use in the UMD build - // for externalized deps - globals: { - vue: 'Vue', - }, - assetFileNames: (chunkInfo) => { - if (chunkInfo.name === 'style.css') - return 'index.css' - return chunkInfo.name as string - }, - }, - }, - }, -}) diff --git a/packages/vue-formkit-schema-wizard/vitest.config.ts b/packages/vue-formkit-schema-wizard/vitest.config.ts deleted file mode 100644 index f3f568b..0000000 --- a/packages/vue-formkit-schema-wizard/vitest.config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { fileURLToPath } from 'node:url' -import { configDefaults, defineConfig, mergeConfig } from 'vitest/config' -import viteConfig from './vite.config' - -export default mergeConfig( - viteConfig, - defineConfig({ - test: { - environment: 'jsdom', - exclude: [...configDefaults.exclude, 'e2e/*'], - root: fileURLToPath(new URL('./', import.meta.url)), - }, - }), -)