From 643fb16a0087f6802c068accec3b6ccd1b4894b3 Mon Sep 17 00:00:00 2001 From: smastrom Date: Tue, 2 Jan 2024 18:41:26 +0100 Subject: [PATCH] release 2.1.1 - Add new type aliases - Align types of exports with type aliases mentioned in docs - Remove useless key on Notivue slot --- packages/notivue/Notivue/NotivueImpl.vue | 2 +- .../Notivue/composables/useNotivueStyles.ts | 4 ++-- packages/notivue/core/types.ts | 20 ++++++++++++++----- packages/notivue/core/useStore.ts | 6 +++--- packages/notivue/nuxt/module.json | 2 +- packages/notivue/package.json | 2 +- tests/config/update-config.test.ts | 8 ++++---- 7 files changed, 27 insertions(+), 17 deletions(-) diff --git a/packages/notivue/Notivue/NotivueImpl.vue b/packages/notivue/Notivue/NotivueImpl.vue index 3389360a..58e4fbe0 100644 --- a/packages/notivue/Notivue/NotivueImpl.vue +++ b/packages/notivue/Notivue/NotivueImpl.vue @@ -81,7 +81,7 @@ const dataAlign = computed(() => ({ :style="styles.container" > - + diff --git a/packages/notivue/Notivue/composables/useNotivueStyles.ts b/packages/notivue/Notivue/composables/useNotivueStyles.ts index aa68aa94..d6070ddf 100644 --- a/packages/notivue/Notivue/composables/useNotivueStyles.ts +++ b/packages/notivue/Notivue/composables/useNotivueStyles.ts @@ -73,8 +73,8 @@ export function useNotivueStyles() { position.value.endsWith('left') ? 'flex-start' : position.value.endsWith('right') - ? 'flex-end' - : 'center' + ? 'flex-end' + : 'center' })`, })) diff --git a/packages/notivue/core/types.ts b/packages/notivue/core/types.ts index 9cfd2ecd..3ef5c0c0 100644 --- a/packages/notivue/core/types.ts +++ b/packages/notivue/core/types.ts @@ -114,14 +114,18 @@ export interface PushProps { export interface PushSpecificOptions { skipQueue?: boolean ariaLiveOnly?: boolean - onAutoClear?: (item: NotivueSlot) => void - onManualClear?: (item: NotivueSlot) => void +} + +export interface PushCallbacks { + onAutoClear?: (item: NotivueItem) => void + onManualClear?: (item: NotivueItem) => void } /** Defined by the user when calling push() */ export type PushOptions = NotificationOptions & PushProps & - PushSpecificOptions + PushSpecificOptions & + PushCallbacks /** Added in background after calling push() */ export type InternalPushOptions = { id: string; type: NotificationType } @@ -133,7 +137,8 @@ export type StoreItem = DeepRequired & Required> & InternalPushOptions & InternalItemData & - PushSpecificOptions + PushSpecificOptions & + PushCallbacks /** Portion of the store item exposed to slot */ export type NotivueItem = Omit, keyof HiddenInternalItemData> @@ -195,13 +200,18 @@ export interface NotivueComputedEntries { queue: ComputedRef } -export type UseNotivue = ConfigSlice +// New v2.1.0 aliases + export type UseNotivueReturn = ConfigSlice export type NotivueNotificationOptions = NotificationOptions export type NotivuePosition = Position export type NotivueNotificationType = NotificationType +// New v2.1.1 aliases + +export type PushClearMethods = NotificationClearMethods + // Aliases prev 1.2.0 export type NotivueSlot = NotivueItem diff --git a/packages/notivue/core/useStore.ts b/packages/notivue/core/useStore.ts index bad2f31d..36c64e3d 100644 --- a/packages/notivue/core/useStore.ts +++ b/packages/notivue/core/useStore.ts @@ -7,7 +7,7 @@ import { DEFAULT_CONFIG } from './constants' import { getSlotContext } from '@/Notivue/utils' -import type { NotivueStore, ConfigSlice, NotivueComputedEntries, NotivueItem } from 'notivue' +import type { NotivueStore, UseNotivueReturn, NotivueComputedEntries, NotivueItem } from 'notivue' export function useStore() { return inject(notivueInjectionKey) as NotivueStore @@ -22,13 +22,13 @@ export function useStore() { * * @docs https://notivuedocs.netlify.app/api/use-notivue */ -export function useNotivue(): ConfigSlice { +export function useNotivue(): UseNotivueReturn { if (isSSR) { return { ...toRefs(reactive(DEFAULT_CONFIG)), isTopAlign: computed(() => true), update: () => {}, - } as ConfigSlice + } as UseNotivueReturn } return useStore().config diff --git a/packages/notivue/nuxt/module.json b/packages/notivue/nuxt/module.json index caf1f225..7903c398 100644 --- a/packages/notivue/nuxt/module.json +++ b/packages/notivue/nuxt/module.json @@ -1,5 +1,5 @@ { "name": "notivue/nuxt", "configKey": "notivue", - "version": "2.1.0" + "version": "2.1.1" } diff --git a/packages/notivue/package.json b/packages/notivue/package.json index 2f4f6704..62e626a0 100644 --- a/packages/notivue/package.json +++ b/packages/notivue/package.json @@ -1,6 +1,6 @@ { "name": "notivue", - "version": "2.1.0", + "version": "2.1.1", "private": false, "description": "Fully-featured toast notification system for Vue and Nuxt", "keywords": [ diff --git a/tests/config/update-config.test.ts b/tests/config/update-config.test.ts index dc6d3854..198e63fb 100644 --- a/tests/config/update-config.test.ts +++ b/tests/config/update-config.test.ts @@ -6,7 +6,7 @@ import { DEFAULT_NOTIFICATION_OPTIONS as defaultNot, } from '@/core/constants' -import type { ConfigSlice, NotivueConfig, NotivueConfigRequired } from 'notivue' +import type { UseNotivueReturn, NotivueConfig, NotivueConfigRequired } from 'notivue' type ConfigPairs = [K, NotivueConfig[K]] @@ -22,7 +22,7 @@ describe('Update method', () => { ['limit', Math.random() * 100], ] - const config = createConfig({}) as ConfigSlice + const config = createConfig({}) as UseNotivueReturn for (const [key, value] of newConf) { expect(config[key].value).not.toBe(value) @@ -59,7 +59,7 @@ describe('Update method', () => { 'promise-reject': { duration: Math.random() * 100 }, } - const config = createConfig({}) as ConfigSlice + const config = createConfig({}) as UseNotivueReturn config.update({ notifications: newConf }) @@ -89,7 +89,7 @@ describe('Update method', () => { }, } - const c = createConfig(userConf) as ConfigSlice + const c = createConfig(userConf) as UseNotivueReturn let prevConf = {} as NotivueConfigRequired