Skip to content

Commit

Permalink
release 2.1.1
Browse files Browse the repository at this point in the history
- Add new type aliases
- Align types of exports with type aliases mentioned in docs
- Remove useless key on Notivue slot
  • Loading branch information
smastrom committed Jan 2, 2024
1 parent fc297b7 commit 643fb16
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/notivue/Notivue/NotivueImpl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const dataAlign = computed(() => ({
:style="styles.container"
>
<!-- Notification -->
<slot v-bind="getSlotContext(item)" :key="item.id" />
<slot v-bind="getSlotContext(item)" />
</div>
</li>
</ol>
Expand Down
4 changes: 2 additions & 2 deletions packages/notivue/Notivue/composables/useNotivueStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export function useNotivueStyles() {
position.value.endsWith('left')
? 'flex-start'
: position.value.endsWith('right')
? 'flex-end'
: 'center'
? 'flex-end'
: 'center'
})`,
}))

Expand Down
20 changes: 15 additions & 5 deletions packages/notivue/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,18 @@ export interface PushProps<T extends Obj = Obj> {
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<T extends Obj = Obj> = NotificationOptions &
PushProps<T> &
PushSpecificOptions
PushSpecificOptions &
PushCallbacks

/** Added in background after calling push() */
export type InternalPushOptions = { id: string; type: NotificationType }
Expand All @@ -133,7 +137,8 @@ export type StoreItem<T extends Obj = Obj> = DeepRequired<NotificationOptions> &
Required<PushProps<T>> &
InternalPushOptions &
InternalItemData &
PushSpecificOptions
PushSpecificOptions &
PushCallbacks

/** Portion of the store item exposed to slot */
export type NotivueItem<T extends Obj = Obj> = Omit<StoreItem<T>, keyof HiddenInternalItemData>
Expand Down Expand Up @@ -195,13 +200,18 @@ export interface NotivueComputedEntries {
queue: ComputedRef<NotivueItem[]>
}

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
Expand Down
6 changes: 3 additions & 3 deletions packages/notivue/core/useStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/notivue/nuxt/module.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "notivue/nuxt",
"configKey": "notivue",
"version": "2.1.0"
"version": "2.1.1"
}
2 changes: 1 addition & 1 deletion packages/notivue/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
8 changes: 4 additions & 4 deletions tests/config/update-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 extends keyof NotivueConfig> = [K, NotivueConfig[K]]

Expand All @@ -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)
Expand Down Expand Up @@ -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 })

Expand Down Expand Up @@ -89,7 +89,7 @@ describe('Update method', () => {
},
}

const c = createConfig(userConf) as ConfigSlice
const c = createConfig(userConf) as UseNotivueReturn

let prevConf = {} as NotivueConfigRequired

Expand Down

0 comments on commit 643fb16

Please sign in to comment.