@pathscale/ui 0.0.108 → 0.0.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -13151,20 +13151,24 @@ const scheduleDismiss = (id, duration)=>{
13151
13151
  };
13152
13152
  const toastStore = {
13153
13153
  toasts,
13154
- addToast: (message, type = "info", duration = 8000)=>{
13154
+ addToast: (message, type = "info", durationOrOptions)=>{
13155
+ const hasOptions = void 0 !== durationOrOptions;
13156
+ const duration = "number" == typeof durationOrOptions ? durationOrOptions : durationOrOptions?.duration ?? ("error" !== type || hasOptions ? 8000 : 0);
13157
+ const persist = "number" == typeof durationOrOptions ? false : durationOrOptions?.persist ?? ("error" === type && !hasOptions);
13155
13158
  const id = `toast-${++toastCounter}`;
13156
13159
  const toast = {
13157
13160
  id,
13158
13161
  message,
13159
13162
  type,
13160
13163
  timestamp: Date.now(),
13161
- duration
13164
+ duration,
13165
+ persist
13162
13166
  };
13163
13167
  setToasts((prev)=>[
13164
13168
  ...prev,
13165
13169
  toast
13166
13170
  ]);
13167
- scheduleDismiss(id, duration);
13171
+ if (!persist) scheduleDismiss(id, duration);
13168
13172
  return id;
13169
13173
  },
13170
13174
  dismissToast: (id)=>{
@@ -13183,7 +13187,9 @@ const toastStore = {
13183
13187
  toastTimers.clear();
13184
13188
  setToasts([]);
13185
13189
  },
13186
- showError: (message)=>toastStore.addToast(message, "error", 10000),
13190
+ showError: (message)=>toastStore.addToast(message, "error", {
13191
+ persist: true
13192
+ }),
13187
13193
  showSuccess: (message)=>toastStore.addToast(message, "success", 6000),
13188
13194
  showWarning: (message)=>toastStore.addToast(message, "warning", 8000),
13189
13195
  showInfo: (message)=>toastStore.addToast(message, "info", 6000)
@@ -6,10 +6,14 @@ export interface ToastItem {
6
6
  timestamp: number;
7
7
  duration: number;
8
8
  isExiting?: boolean;
9
+ persist?: boolean;
9
10
  }
10
11
  export declare const toastStore: {
11
12
  toasts: import("solid-js").Accessor<ToastItem[]>;
12
- addToast: (message: string, type?: ToastType, duration?: number) => string;
13
+ addToast: (message: string, type?: ToastType, durationOrOptions?: number | {
14
+ duration?: number;
15
+ persist?: boolean;
16
+ }) => string;
13
17
  dismissToast: (id: string) => void;
14
18
  removeToast: (id: string) => void;
15
19
  clearAll: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pathscale/ui",
3
- "version": "0.0.108",
3
+ "version": "0.0.109",
4
4
  "author": "pathscale",
5
5
  "repository": {
6
6
  "type": "git",