@@ -4,10 +4,10 @@ import { MissingComponentInCustomPush, NotFoundVariantConfig } from './errors.js
44import { Notification } from './notification.svelte.js' ;
55
66/**
7- * @template {Record<string, import('svelte').SvelteComponent >} [VariantMap={}]
7+ * @template {Record<string, import('svelte').Component >} [VariantMap={}]
88 */
99export class NotificationController {
10- /** @type {Record<string, import('./types.js ').NotificationVariantConfig<any, any, any>> } */
10+ /** @type {Record<string, import('./types.d.ts ').NotificationVariantConfig<any, any, any>> } */
1111 #variantConfigMap = { } ;
1212 #counter = 0 ;
1313
@@ -19,7 +19,7 @@ export class NotificationController {
1919 notifications = $state ( [ ] ) ;
2020
2121 /**
22- * @type {Required<import('./types.js ').NotificationCommonConfig<any, any, any>> }
22+ * @type {Required<import('./types.d.ts ').NotificationCommonConfig<any, any, any>> }
2323 */
2424 // eslint-disable-next-line no-undef
2525 config = $state ( {
@@ -32,7 +32,7 @@ export class NotificationController {
3232 * register the element to render a notification into
3333 * @param {HTMLElement } node
3434 * @param {Notification<any> } notification
35- * @returns {import('./types.js ').NotificationPortalActionReturn }
35+ * @returns {import('./types.d.ts ').NotificationPortalActionReturn }
3636 */
3737 render : ( node , notification ) => {
3838 mount ( notification . config . component , {
@@ -48,8 +48,8 @@ export class NotificationController {
4848 } ;
4949
5050 /**
51- * @param {Record<keyof VariantMap, import('./types.js ').NotificationVariantConfig<any, any, any>> } variantConfigMap
52- * @param {import('./types.js ').NotificationCommonConfig<any, any, any> } [init]
51+ * @param {Record<keyof VariantMap, import('./types.d.ts ').NotificationVariantConfig<any, any, any>> } variantConfigMap
52+ * @param {import('./types.d.ts ').NotificationCommonConfig<any, any, any> } [init]
5353 */
5454 constructor ( variantConfigMap , init ) {
5555 if ( init ?. id ) this . config . id = init . id ;
@@ -60,36 +60,36 @@ export class NotificationController {
6060
6161 /**
6262 * @template {Extract<keyof VariantMap, string>} Variant
63- * @template {VariantMap[Variant]} [Component =VariantMap[Variant]]
64- * @template [Resolved=undefined|Awaited<import('svelte').ComponentProps<Component >['notification']['resolution']>]
63+ * @template {VariantMap[Variant]} [UserComponent =VariantMap[Variant]]
64+ * @template [Resolved=undefined|Awaited<import('svelte').ComponentProps<UserComponent >['notification']['resolution']>]
6565 * @overload
6666 * @param {Variant } variant
67- * @param {import('./types.js ').NotificationByVariantPushConfig<Resolved, Variant, Component > } [config]
67+ * @param {import('./types.d.ts ').NotificationByVariantPushConfig<Resolved, Variant, UserComponent > } [config]
6868 * @returns {Notification<Resolved> }
6969 */
7070 /**
71- * @template {import('svelte').SvelteComponent} Component
72- * @template [Resolved=undefined|Awaited<import('svelte').ComponentProps<Component >['notification']['resolution']>]
71+ * @template {import('svelte').Component} UserComponent
72+ * @template [Resolved=undefined|Awaited<import('svelte').ComponentProps<UserComponent >['notification']['resolution']>]
7373 * @overload
7474 * @param {'custom' } variant
75- * @param {import('./types.js ').NotificationCustomPushConfig<Resolved, Component > } config
75+ * @param {import('./types.d.ts ').NotificationCustomPushConfig<Resolved, UserComponent > } config
7676 * @returns {Notification<Resolved> }
7777 */
7878 /**
7979 * @param {string } variant
80- * @param {import('./types.js ').NotificationByVariantPushConfig<any, string, import('svelte').SvelteComponent<any>> | import('./types.js ').NotificationCustomPushConfig<any, import('svelte').SvelteComponent<any> > } [config]
80+ * @param {import('./types.d.ts ').NotificationByVariantPushConfig<any, string, import('svelte').Component> | import('./types.d.ts ').NotificationCustomPushConfig<any, import('svelte').Component > } [config]
8181 * @returns {Notification<any> }
8282 */
8383 push ( variant , config ) {
8484 // STEP 1: resolve instance config, merge with common config and variant config, if any
85- /** @type {import('./types.js ').NotificationInstanceConfig<any, any, any> } */
85+ /** @type {import('./types.d.ts ').NotificationInstanceConfig<any, any, any> } */
8686 let instanceConfig ;
87- /** @type {NonNullable<import('./types.js ').NotificationCommonConfig<Resolved, string, import('svelte').SvelteComponent<any> >['id']> } */
87+ /** @type {NonNullable<import('./types.d.ts ').NotificationCommonConfig<Resolved, string, import('svelte').Component >['id']> } */
8888 let idResolver ;
8989
9090 if ( variant === 'custom' ) {
9191 const rConfig =
92- /** @type {import('./types.js ').NotificationCustomPushConfig<any, any> } */ (
92+ /** @type {import('./types.d.ts ').NotificationCustomPushConfig<any, any> } */ (
9393 config
9494 ) ;
9595 if ( ! rConfig || ! rConfig . component ) {
@@ -158,12 +158,12 @@ export class NotificationController {
158158 */
159159 /**
160160 * @overload
161- * @param {import('./types.js ').NotificationPopVerboseInput } [config]
161+ * @param {import('./types.d.ts ').NotificationPopVerboseInput } [config]
162162 * @returns {void }
163163 */
164164 /**
165165 *
166- * @param {string | import('./types.js ').NotificationPopVerboseInput } [config]
166+ * @param {string | import('./types.d.ts ').NotificationPopVerboseInput } [config]
167167 * @param {any } [resolved]
168168 * @returns {void }
169169 */
@@ -192,4 +192,24 @@ export class NotificationController {
192192 this . notifications = this . notifications . filter ( ( n ) => n . config . id !== pushed . config . id ) ;
193193 }
194194 }
195+
196+ /**
197+ * pause a notification, if it has a timeout
198+ * @param {string } id
199+ * @returns {void }
200+ */
201+ pause ( id ) {
202+ const pushed = this . notifications . find ( ( n ) => n . config . id === id ) ;
203+ return pushed ?. pause ( ) ;
204+ }
205+
206+ /**
207+ * resume a notification, if it has been paused
208+ * @param {string } id
209+ * @returns {void }
210+ */
211+ resume ( id ) {
212+ const pushed = this . notifications . find ( ( n ) => n . config . id === id ) ;
213+ return pushed ?. resume ( ) ;
214+ }
195215}
0 commit comments