Skip to content

Commit c8097d4

Browse files
fix: define props override issue
1 parent 4145b25 commit c8097d4

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

playground/app.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default defineAppConfig({
22
toaster: {
3-
maxToasts: 5
3+
maxToasts: 10
44
}
55
})

playground/app.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function showCustomToast() {
2222
transition: {
2323
name: 'fadeOut'
2424
},
25+
maxToasts: 5,
2526
theme: {
2627
containerId: 'nt-container-bottom-right',
2728
containerClass: [

src/runtime/create.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { type App, h, render } from 'vue'
22
import { defu } from 'defu'
33

44
import type { NinjaToasterTheme } from '../theme'
5-
import type { NinjaToasterProps } from '../props'
5+
import type { NinjaToasterBaseProps, NinjaToasterProps } from '../props'
66
import type { NinjaToasterRenderQueue } from './queue'
77
import { type NinjaToastEventBus, createEventBus } from './events'
88
import NinjaToaster from './components/NinjaToaster'
99

10-
import { useAppConfig, useNuxtApp, useRuntimeConfig } from '#imports'
10+
import { useAppConfig, useNuxtApp } from '#imports'
1111

1212
function createElement() {
1313
if (process.server) {
@@ -43,24 +43,26 @@ export interface NinjaToasterShow {
4343
}
4444

4545
export function createNinjaToaster(
46-
createOptions: Omit<NinjaToasterProps, 'content'> = {}
46+
createProps: Omit<NinjaToasterProps, 'content'> = {}
4747
) {
4848
const events = createEventBus()
4949
const queues: Map<string, NinjaToasterRenderQueue> = new Map()
5050

5151
function show(options: NinjaToasterProps | string | number) {
52-
const appConfigProps = (useAppConfig() as any).toaster as NinjaToasterProps
52+
const appConfigProps: NinjaToasterBaseProps = (useAppConfig() as any)
53+
.toaster
5354
const app = useNuxtApp().vueApp
5455
const userProps =
5556
typeof options === 'string' ||
5657
typeof options === 'number' ||
5758
typeof options === 'function'
5859
? { content: options }
5960
: options
61+
6062
const props: NinjaToasterProps = defu(
61-
appConfigProps,
62-
createOptions,
63-
userProps
63+
userProps,
64+
createProps,
65+
appConfigProps
6466
)
6567

6668
return new Promise<NinjaToasterShow>((resolve) => {

0 commit comments

Comments
 (0)