solid-toast
Advanced tools
Comparing version 0.3.5 to 0.4.0
@@ -327,12 +327,14 @@ 'use strict'; | ||
const createToastCreator = type => (message, options = {}) => { | ||
const existingToast = store.toasts.find(t => t.id === options.id); | ||
const toast = createToast(message, type, { ...existingToast, | ||
duration: undefined, | ||
...options | ||
return solidJs.createRoot(() => { | ||
const existingToast = store.toasts.find(t => t.id === options.id); | ||
const toast = createToast(message, type, { ...existingToast, | ||
duration: undefined, | ||
...options | ||
}); | ||
dispatch({ | ||
type: exports.ActionType.UPSERT_TOAST, | ||
toast | ||
}); | ||
return toast.id; | ||
}); | ||
dispatch({ | ||
type: exports.ActionType.UPSERT_TOAST, | ||
toast | ||
}); | ||
return toast.id; | ||
}; | ||
@@ -342,2 +344,3 @@ | ||
solidJs.untrack(() => toast$1); | ||
toast$1.error = createToastCreator('error'); | ||
@@ -344,0 +347,0 @@ toast$1.success = createToastCreator('success'); |
@@ -1,2 +0,2 @@ | ||
import { createSignal, createEffect, onCleanup, For, Switch, Match, createMemo, onMount } from 'solid-js'; | ||
import { createSignal, untrack, createRoot, createEffect, onCleanup, For, Switch, Match, createMemo, onMount } from 'solid-js'; | ||
import { createStore, produce } from 'solid-js/store'; | ||
@@ -323,12 +323,14 @@ import { insert, createComponent, effect, style, className, template, mergeProps, spread, memo, setAttribute } from 'solid-js/web'; | ||
const createToastCreator = type => (message, options = {}) => { | ||
const existingToast = store.toasts.find(t => t.id === options.id); | ||
const toast = createToast(message, type, { ...existingToast, | ||
duration: undefined, | ||
...options | ||
return createRoot(() => { | ||
const existingToast = store.toasts.find(t => t.id === options.id); | ||
const toast = createToast(message, type, { ...existingToast, | ||
duration: undefined, | ||
...options | ||
}); | ||
dispatch({ | ||
type: ActionType.UPSERT_TOAST, | ||
toast | ||
}); | ||
return toast.id; | ||
}); | ||
dispatch({ | ||
type: ActionType.UPSERT_TOAST, | ||
toast | ||
}); | ||
return toast.id; | ||
}; | ||
@@ -338,2 +340,3 @@ | ||
untrack(() => toast$1); | ||
toast$1.error = createToastCreator('error'); | ||
@@ -340,0 +343,0 @@ toast$1.success = createToastCreator('success'); |
@@ -1,2 +0,2 @@ | ||
import { createSignal } from 'solid-js'; | ||
import { createRoot, createSignal, untrack } from 'solid-js'; | ||
import { ActionType } from '../types'; | ||
@@ -28,8 +28,11 @@ import { defaultToasterOptions, defaultToastOptions, defaultTimeouts } from './defaults'; | ||
const createToastCreator = (type) => (message, options = {}) => { | ||
const existingToast = store.toasts.find((t) => t.id === options.id); | ||
const toast = createToast(message, type, { ...existingToast, duration: undefined, ...options }); | ||
dispatch({ type: ActionType.UPSERT_TOAST, toast }); | ||
return toast.id; | ||
return createRoot(() => { | ||
const existingToast = store.toasts.find((t) => t.id === options.id); | ||
const toast = createToast(message, type, { ...existingToast, duration: undefined, ...options }); | ||
dispatch({ type: ActionType.UPSERT_TOAST, toast }); | ||
return toast.id; | ||
}); | ||
}; | ||
const toast = (message, opts) => createToastCreator('blank')(message, opts); | ||
const test = untrack(() => toast); | ||
toast.error = createToastCreator('error'); | ||
@@ -36,0 +39,0 @@ toast.success = createToastCreator('success'); |
{ | ||
"name": "solid-toast", | ||
"version": "0.3.5", | ||
"version": "0.4.0", | ||
"description": "Customizable Toast Notifications for SolidJS", | ||
@@ -47,4 +47,4 @@ "main": "dist/cjs/index.js", | ||
"devDependencies": { | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@types/node": "^17.0.35", | ||
"@rollup/plugin-babel": "^6.0.0", | ||
"@types/node": "^18.7.16", | ||
"prettier": "^2.7.1", | ||
@@ -51,0 +51,0 @@ "rollup": "^2.75.7", |
@@ -1,2 +0,2 @@ | ||
import { createSignal } from 'solid-js'; | ||
import { createRoot, createSignal, untrack } from 'solid-js'; | ||
import { ToasterProps, Message, ToastType, ToastOptions, Toast, ToastHandler, ActionType } from '../types'; | ||
@@ -35,9 +35,12 @@ import { defaultToasterOptions, defaultToastOptions, defaultTimeouts } from './defaults'; | ||
(message: Message, options: ToastOptions = {}) => { | ||
const existingToast = store.toasts.find((t) => t.id === options.id) as Toast; | ||
const toast = createToast(message, type, { ...existingToast, duration: undefined, ...options }); | ||
dispatch({ type: ActionType.UPSERT_TOAST, toast }); | ||
return toast.id; | ||
return createRoot(() => { | ||
const existingToast = store.toasts.find((t) => t.id === options.id) as Toast; | ||
const toast = createToast(message, type, { ...existingToast, duration: undefined, ...options }); | ||
dispatch({ type: ActionType.UPSERT_TOAST, toast }); | ||
return toast.id; | ||
}); | ||
}; | ||
const toast = (message: Message, opts?: ToastOptions) => createToastCreator('blank')(message, opts); | ||
const test = untrack(() => toast); | ||
@@ -44,0 +47,0 @@ toast.error = createToastCreator('error'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
203350
2770