diff --git a/demo/package.json b/demo/package.json index 5e91c37..1f95496 100644 --- a/demo/package.json +++ b/demo/package.json @@ -13,7 +13,7 @@ "@types/luxon": "^3.3.7", "@types/node": "^20.10.5", "lightningcss": "^1.22.1", - "nuxt": "^3.8.2" + "nuxt": "^3.9.0" }, "dependencies": { "floating-vue": "2.0.0-beta.24", diff --git a/packages/notivue/core/createStore.ts b/packages/notivue/core/createStore.ts index e2b8879..5287ca0 100644 --- a/packages/notivue/core/createStore.ts +++ b/packages/notivue/core/createStore.ts @@ -1,4 +1,4 @@ -import { ref, shallowRef, computed, triggerRef, toRefs, reactive, nextTick } from 'vue' +import { ref, shallowRef, computed, triggerRef, toRefs, reactive, nextTick, ToRefs, Ref } from 'vue' import { mergeDeep, mergeNotificationOptions as mergeOptions } from './utils' import { getSlotContext } from '@/Notivue/utils' @@ -17,9 +17,12 @@ import type { ElementsSlice, TimeoutsSlice, AnimationsSlice, + NotivueConfigRequired, } from 'notivue' -export function createConfig(userConfig: NotivueConfig) { +export function createConfig( + userConfig: NotivueConfig +): ToRefs { const reactiveConfig = toRefs(reactive(mergeDeep(DEFAULT_CONFIG, userConfig))) return { @@ -106,21 +109,26 @@ export function createItems(config: ConfigSlice, queue: QueueSlice) { } } -export function createElements() { - type RootAttrs = Partial<{ class: string; onAnimationend: () => void }> - +export function createElements(): { + root: Ref + rootAttrs: Ref void }>> + setRootAttrs: (newAttrs: Partial<{ class: string; onAnimationend: () => void }>) => void + items: Ref + getSortedItems: () => HTMLElement[] + containers: Ref +} { return { - root: ref(null), - rootAttrs: shallowRef({}), - setRootAttrs(newAttrs: RootAttrs) { + root: ref(null), + rootAttrs: shallowRef({}), + setRootAttrs(newAttrs) { this.rootAttrs.value = newAttrs }, - items: ref([]), + items: ref([]), getSortedItems() { // This is a bit dirty, but it's better than cloning and reversing the array on every repositioning return this.items.value.sort((a, b) => +b.dataset.notivueId! - +a.dataset.notivueId!) }, - containers: ref([]), + containers: ref([]), } } diff --git a/packages/notivue/package.json b/packages/notivue/package.json index 0e53a8c..f04aea6 100644 --- a/packages/notivue/package.json +++ b/packages/notivue/package.json @@ -63,8 +63,8 @@ "watch": "rm -rf dist && concurrently \"vite build --watch\" \"pnpm build:css --watch\"" }, "devDependencies": { - "@nuxt/kit": "^3.8.2", - "@nuxt/schema": "^3.8.2", + "@nuxt/kit": "^3.9.0", + "@nuxt/schema": "^3.9.0", "@types/node": "^20.10.5", "@vitejs/plugin-vue": "4.4.0", "concurrently": "^8.2.2",