@samline/notify 1.0.2 → 2.0.0
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/{LICENSE → LICENSE.md} +2 -2
- package/README.md +27 -163
- package/dist/_runtime.d.mts +87 -0
- package/dist/_runtime.d.ts +87 -0
- package/dist/_runtime.js +97 -0
- package/dist/_runtime.mjs +83 -0
- package/dist/browser/assets-client-B-VVPPYQ.js +114 -0
- package/dist/browser/assets-client-CUzxHubR.mjs +108 -0
- package/dist/browser/index-client-BBOQyMFk.mjs +173 -0
- package/dist/browser/index-client-Czb7hTpD.js +181 -0
- package/dist/browser/index.d.mts +134 -0
- package/dist/browser/index.d.ts +134 -0
- package/dist/browser/index.js +34 -0
- package/dist/browser/index.mjs +26 -0
- package/dist/browser/render-client-CjcQoukB.js +981 -0
- package/dist/browser/render-client-bGRSTd-L.mjs +974 -0
- package/dist/core/index.d.mts +68 -0
- package/dist/core/index.d.ts +68 -0
- package/dist/core/index.js +1 -0
- package/dist/core/index.mjs +1 -0
- package/dist/index.d.mts +131 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +1240 -0
- package/dist/index.mjs +1228 -0
- package/dist/react/index.d.mts +158 -0
- package/dist/react/index.d.ts +158 -0
- package/dist/react/index.js +1116 -0
- package/dist/react/index.mjs +1107 -0
- package/dist/styles.css +589 -422
- package/dist/svelte/assets-client-B-VVPPYQ.js +114 -0
- package/dist/svelte/assets-client-CUzxHubR.mjs +108 -0
- package/dist/svelte/index-client-DbXbWMIe.js +177 -0
- package/dist/svelte/index-client-Dj_WfPK9.mjs +170 -0
- package/dist/svelte/index.d.mts +14 -0
- package/dist/svelte/index.d.ts +14 -0
- package/dist/svelte/index.js +43 -0
- package/dist/svelte/index.mjs +36 -0
- package/dist/svelte/render-client-CjcQoukB.js +981 -0
- package/dist/svelte/render-client-bGRSTd-L.mjs +974 -0
- package/dist/vue/assets-client-B-VVPPYQ.js +114 -0
- package/dist/vue/assets-client-CUzxHubR.mjs +108 -0
- package/dist/vue/index-client-DbXbWMIe.js +177 -0
- package/dist/vue/index-client-Dj_WfPK9.mjs +170 -0
- package/dist/vue/index.d.mts +50 -0
- package/dist/vue/index.d.ts +50 -0
- package/dist/vue/index.js +110 -0
- package/dist/vue/index.mjs +104 -0
- package/dist/vue/render-client-CjcQoukB.js +981 -0
- package/dist/vue/render-client-bGRSTd-L.mjs +974 -0
- package/package.json +140 -95
- package/dist/browser-notify.js +0 -68
- package/dist/cc-2Yt7NqMX.mjs +0 -21
- package/dist/cc-B6peeNak.mjs +0 -33
- package/dist/cc-BWuAzFJ6.js +0 -12
- package/dist/cc-CaBHsjUt.js +0 -34
- package/dist/cc-DGff5sSY.js +0 -21
- package/dist/cc-he3fHS3P.mjs +0 -12
- package/dist/notify.d.mts +0 -48
- package/dist/notify.d.mts.map +0 -1
- package/dist/notify.d.ts +0 -48
- package/dist/notify.d.ts.map +0 -1
- package/dist/notify.js +0 -206
- package/dist/notify.mjs +0 -202
- package/dist/react-notify-12s--2JK5UjB.mjs +0 -1244
- package/dist/react-notify-12s-Kv2M6zlv.js +0 -1247
- package/dist/react.d.mts +0 -70
- package/dist/react.d.mts.map +0 -1
- package/dist/react.d.ts +0 -70
- package/dist/react.d.ts.map +0 -1
- package/dist/react.js +0 -19
- package/dist/react.mjs +0 -10
- package/dist/render-notify-toasts.js +0 -213
- package/dist/svelte.d.mts +0 -49
- package/dist/svelte.d.mts.map +0 -1
- package/dist/svelte.d.ts +0 -49
- package/dist/svelte.d.ts.map +0 -1
- package/dist/svelte.js +0 -284
- package/dist/svelte.mjs +0 -280
- package/dist/vue.d.mts +0 -107
- package/dist/vue.d.mts.map +0 -1
- package/dist/vue.d.ts +0 -107
- package/dist/vue.d.ts.map +0 -1
- package/dist/vue.js +0 -2215
- package/dist/vue.mjs +0 -2211
package/dist/react.d.mts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
type NotifyState = "success" | "loading" | "error" | "warning" | "info" | "action";
|
|
5
|
-
interface NotifyStyles {
|
|
6
|
-
title?: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
badge?: string;
|
|
9
|
-
button?: string;
|
|
10
|
-
}
|
|
11
|
-
interface NotifyButton {
|
|
12
|
-
title: string;
|
|
13
|
-
onClick: () => void;
|
|
14
|
-
}
|
|
15
|
-
declare const NOTIFY_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
|
|
16
|
-
type NotifyPosition = (typeof NOTIFY_POSITIONS)[number];
|
|
17
|
-
interface NotifyOptions {
|
|
18
|
-
title?: string;
|
|
19
|
-
description?: string;
|
|
20
|
-
type?: NotifyState;
|
|
21
|
-
position?: NotifyPosition;
|
|
22
|
-
duration?: number | null;
|
|
23
|
-
icon?: any;
|
|
24
|
-
styles?: NotifyStyles;
|
|
25
|
-
fill?: string;
|
|
26
|
-
roundness?: number;
|
|
27
|
-
autopilot?: boolean | {
|
|
28
|
-
expand?: number;
|
|
29
|
-
collapse?: number;
|
|
30
|
-
};
|
|
31
|
-
button?: NotifyButton;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type NotifyOffsetValue = number | string;
|
|
35
|
-
type NotifyOffsetConfig = Partial<Record<"top" | "right" | "bottom" | "left", NotifyOffsetValue>>;
|
|
36
|
-
interface NotifyToasterProps {
|
|
37
|
-
children?: ReactNode;
|
|
38
|
-
position?: NotifyPosition;
|
|
39
|
-
offset?: NotifyOffsetValue | NotifyOffsetConfig;
|
|
40
|
-
options?: Partial<NotifyOptions>;
|
|
41
|
-
theme?: "light" | "dark" | "system";
|
|
42
|
-
}
|
|
43
|
-
interface NotifyPromiseOptions<T = unknown> {
|
|
44
|
-
loading: NotifyOptions;
|
|
45
|
-
success: NotifyOptions | ((data: T) => NotifyOptions);
|
|
46
|
-
error: NotifyOptions | ((err: unknown) => NotifyOptions);
|
|
47
|
-
action?: NotifyOptions | ((data: T) => NotifyOptions);
|
|
48
|
-
position?: NotifyPosition;
|
|
49
|
-
}
|
|
50
|
-
declare const notify: {
|
|
51
|
-
show: (opts: NotifyOptions) => string;
|
|
52
|
-
success: (opts: NotifyOptions) => string;
|
|
53
|
-
error: (opts: NotifyOptions) => string;
|
|
54
|
-
warning: (opts: NotifyOptions) => string;
|
|
55
|
-
info: (opts: NotifyOptions) => string;
|
|
56
|
-
action: (opts: NotifyOptions) => string;
|
|
57
|
-
promise: <T>(promise: Promise<T> | (() => Promise<T>), opts: NotifyPromiseOptions<T>) => Promise<T>;
|
|
58
|
-
dismiss: (id: string) => void;
|
|
59
|
-
clear: (position?: NotifyPosition) => void;
|
|
60
|
-
};
|
|
61
|
-
declare function showNotifyToast(options: NotifyOptions): string;
|
|
62
|
-
declare function Toaster({ children, position, offset, options, theme, }: NotifyToasterProps): react_jsx_runtime.JSX.Element;
|
|
63
|
-
|
|
64
|
-
declare function renderNotifyToasts(options?: {
|
|
65
|
-
position?: NotifyPosition;
|
|
66
|
-
}): () => boolean;
|
|
67
|
-
|
|
68
|
-
export { Toaster, notify, renderNotifyToasts, showNotifyToast };
|
|
69
|
-
export type { NotifyButton, NotifyOptions, NotifyPosition, NotifyState, NotifyStyles };
|
|
70
|
-
//# sourceMappingURL=react.d.mts.map
|
package/dist/react.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.mts","sources":["../src/types.ts","../src/toast.tsx","../src/render-notify-toasts.ts"],"mappings":";;;AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;ACzBA,KAAK,iBAAiB;AACtB,KAAK,kBAAkB,GAAG,OAAO,CAAC,MAAM,sCAAsC,iBAAiB;AAC/F,UAAU,kBAAkB;AAC5B,eAAe,SAAS;AACxB,eAAe,cAAc;AAC7B,aAAa,iBAAiB,GAAG,kBAAkB;AACnD,cAAc,OAAO,CAAC,aAAa;AACnC;AACA;AACA,UAAU,oBAAoB;AAC9B,aAAa,aAAa;AAC1B,aAAa,aAAa,iBAAiB,aAAa;AACxD,WAAW,aAAa,sBAAsB,aAAa;AAC3D,aAAa,aAAa,iBAAiB,aAAa;AACxD,eAAe,cAAc;AAC7B;AACA,cAAc,MAAM;AACpB,iBAAiB,aAAa;AAC9B,oBAAoB,aAAa;AACjC,kBAAkB,aAAa;AAC/B,oBAAoB,aAAa;AACjC,iBAAiB,aAAa;AAC9B,mBAAmB,aAAa;AAChC,0BAA0B,OAAO,aAAa,OAAO,YAAY,oBAAoB,QAAQ,OAAO;AACpG;AACA,uBAAuB,cAAc;AACrC;AACA,iBAAiB,eAAe,UAAU,aAAa;AACvD,iBAAiB,OAAO,kDAAkD,kBAAkB,GAAG,iBAAiB,CAAC,GAAG,CAAC,OAAO;;AC9B5H,iBAAiB,kBAAkB;AACnC,eAAe,cAAc;AAC7B;;;;","names":[]}
|
package/dist/react.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
type NotifyState = "success" | "loading" | "error" | "warning" | "info" | "action";
|
|
5
|
-
interface NotifyStyles {
|
|
6
|
-
title?: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
badge?: string;
|
|
9
|
-
button?: string;
|
|
10
|
-
}
|
|
11
|
-
interface NotifyButton {
|
|
12
|
-
title: string;
|
|
13
|
-
onClick: () => void;
|
|
14
|
-
}
|
|
15
|
-
declare const NOTIFY_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
|
|
16
|
-
type NotifyPosition = (typeof NOTIFY_POSITIONS)[number];
|
|
17
|
-
interface NotifyOptions {
|
|
18
|
-
title?: string;
|
|
19
|
-
description?: string;
|
|
20
|
-
type?: NotifyState;
|
|
21
|
-
position?: NotifyPosition;
|
|
22
|
-
duration?: number | null;
|
|
23
|
-
icon?: any;
|
|
24
|
-
styles?: NotifyStyles;
|
|
25
|
-
fill?: string;
|
|
26
|
-
roundness?: number;
|
|
27
|
-
autopilot?: boolean | {
|
|
28
|
-
expand?: number;
|
|
29
|
-
collapse?: number;
|
|
30
|
-
};
|
|
31
|
-
button?: NotifyButton;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type NotifyOffsetValue = number | string;
|
|
35
|
-
type NotifyOffsetConfig = Partial<Record<"top" | "right" | "bottom" | "left", NotifyOffsetValue>>;
|
|
36
|
-
interface NotifyToasterProps {
|
|
37
|
-
children?: ReactNode;
|
|
38
|
-
position?: NotifyPosition;
|
|
39
|
-
offset?: NotifyOffsetValue | NotifyOffsetConfig;
|
|
40
|
-
options?: Partial<NotifyOptions>;
|
|
41
|
-
theme?: "light" | "dark" | "system";
|
|
42
|
-
}
|
|
43
|
-
interface NotifyPromiseOptions<T = unknown> {
|
|
44
|
-
loading: NotifyOptions;
|
|
45
|
-
success: NotifyOptions | ((data: T) => NotifyOptions);
|
|
46
|
-
error: NotifyOptions | ((err: unknown) => NotifyOptions);
|
|
47
|
-
action?: NotifyOptions | ((data: T) => NotifyOptions);
|
|
48
|
-
position?: NotifyPosition;
|
|
49
|
-
}
|
|
50
|
-
declare const notify: {
|
|
51
|
-
show: (opts: NotifyOptions) => string;
|
|
52
|
-
success: (opts: NotifyOptions) => string;
|
|
53
|
-
error: (opts: NotifyOptions) => string;
|
|
54
|
-
warning: (opts: NotifyOptions) => string;
|
|
55
|
-
info: (opts: NotifyOptions) => string;
|
|
56
|
-
action: (opts: NotifyOptions) => string;
|
|
57
|
-
promise: <T>(promise: Promise<T> | (() => Promise<T>), opts: NotifyPromiseOptions<T>) => Promise<T>;
|
|
58
|
-
dismiss: (id: string) => void;
|
|
59
|
-
clear: (position?: NotifyPosition) => void;
|
|
60
|
-
};
|
|
61
|
-
declare function showNotifyToast(options: NotifyOptions): string;
|
|
62
|
-
declare function Toaster({ children, position, offset, options, theme, }: NotifyToasterProps): react_jsx_runtime.JSX.Element;
|
|
63
|
-
|
|
64
|
-
declare function renderNotifyToasts(options?: {
|
|
65
|
-
position?: NotifyPosition;
|
|
66
|
-
}): () => boolean;
|
|
67
|
-
|
|
68
|
-
export { Toaster, notify, renderNotifyToasts, showNotifyToast };
|
|
69
|
-
export type { NotifyButton, NotifyOptions, NotifyPosition, NotifyState, NotifyStyles };
|
|
70
|
-
//# sourceMappingURL=react.d.ts.map
|
package/dist/react.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sources":["../src/types.ts","../src/toast.tsx","../src/render-notify-toasts.ts"],"mappings":";;;AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;ACzBA,KAAK,iBAAiB;AACtB,KAAK,kBAAkB,GAAG,OAAO,CAAC,MAAM,sCAAsC,iBAAiB;AAC/F,UAAU,kBAAkB;AAC5B,eAAe,SAAS;AACxB,eAAe,cAAc;AAC7B,aAAa,iBAAiB,GAAG,kBAAkB;AACnD,cAAc,OAAO,CAAC,aAAa;AACnC;AACA;AACA,UAAU,oBAAoB;AAC9B,aAAa,aAAa;AAC1B,aAAa,aAAa,iBAAiB,aAAa;AACxD,WAAW,aAAa,sBAAsB,aAAa;AAC3D,aAAa,aAAa,iBAAiB,aAAa;AACxD,eAAe,cAAc;AAC7B;AACA,cAAc,MAAM;AACpB,iBAAiB,aAAa;AAC9B,oBAAoB,aAAa;AACjC,kBAAkB,aAAa;AAC/B,oBAAoB,aAAa;AACjC,iBAAiB,aAAa;AAC9B,mBAAmB,aAAa;AAChC,0BAA0B,OAAO,aAAa,OAAO,YAAY,oBAAoB,QAAQ,OAAO;AACpG;AACA,uBAAuB,cAAc;AACrC;AACA,iBAAiB,eAAe,UAAU,aAAa;AACvD,iBAAiB,OAAO,kDAAkD,kBAAkB,GAAG,iBAAiB,CAAC,GAAG,CAAC,OAAO;;AC9B5H,iBAAiB,kBAAkB;AACnC,eAAe,cAAc;AAC7B;;;;","names":[]}
|
package/dist/react.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
function __insertCSS(code) {
|
|
2
|
-
if (!code || typeof document == 'undefined') return
|
|
3
|
-
let head = document.head || document.getElementsByTagName('head')[0]
|
|
4
|
-
let style = document.createElement('style')
|
|
5
|
-
style.type = 'text/css'
|
|
6
|
-
head.appendChild(style)
|
|
7
|
-
;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
|
-
var reactNotify12s = require('./react-notify-12s-Kv2M6zlv.js');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.Toaster = reactNotify12s.Toaster;
|
|
17
|
-
exports.notify = reactNotify12s.notify;
|
|
18
|
-
exports.renderNotifyToasts = reactNotify12s.renderNotifyToasts;
|
|
19
|
-
exports.showNotifyToast = reactNotify12s.showNotifyToast;
|
package/dist/react.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
function __insertCSS(code) {
|
|
2
|
-
if (!code || typeof document == 'undefined') return
|
|
3
|
-
let head = document.head || document.getElementsByTagName('head')[0]
|
|
4
|
-
let style = document.createElement('style')
|
|
5
|
-
style.type = 'text/css'
|
|
6
|
-
head.appendChild(style)
|
|
7
|
-
;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { T as Toaster, n as notify, r as renderNotifyToasts, s as showNotifyToast } from './react-notify-12s--2JK5UjB.mjs';
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
function __accessProp(key) {
|
|
7
|
-
return this[key];
|
|
8
|
-
}
|
|
9
|
-
var __toCommonJS = (from) => {
|
|
10
|
-
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
11
|
-
if (entry)
|
|
12
|
-
return entry;
|
|
13
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (var key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(entry, key))
|
|
17
|
-
__defProp(entry, key, {
|
|
18
|
-
get: __accessProp.bind(from, key),
|
|
19
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
__moduleCache.set(from, entry);
|
|
23
|
-
return entry;
|
|
24
|
-
};
|
|
25
|
-
var __moduleCache;
|
|
26
|
-
var __returnValue = (v) => v;
|
|
27
|
-
function __exportSetter(name, newValue) {
|
|
28
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
29
|
-
}
|
|
30
|
-
var __export = (target, all) => {
|
|
31
|
-
for (var name in all)
|
|
32
|
-
__defProp(target, name, {
|
|
33
|
-
get: all[name],
|
|
34
|
-
enumerable: true,
|
|
35
|
-
configurable: true,
|
|
36
|
-
set: __exportSetter.bind(all, name)
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// src/render-notify-toasts.ts
|
|
41
|
-
var exports_render_notify_toasts = {};
|
|
42
|
-
__export(exports_render_notify_toasts, {
|
|
43
|
-
renderNotifyToasts: () => renderNotifyToasts
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// src/core/notify-core.ts
|
|
47
|
-
class NotifyCore {
|
|
48
|
-
toasts = [];
|
|
49
|
-
listeners = new Set;
|
|
50
|
-
position = "top-right";
|
|
51
|
-
options = undefined;
|
|
52
|
-
idCounter = 0;
|
|
53
|
-
generateId() {
|
|
54
|
-
return `${++this.idCounter}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
55
|
-
}
|
|
56
|
-
subscribe(fn) {
|
|
57
|
-
this.listeners.add(fn);
|
|
58
|
-
fn(this.toasts);
|
|
59
|
-
return () => this.listeners.delete(fn);
|
|
60
|
-
}
|
|
61
|
-
emit() {
|
|
62
|
-
for (const fn of this.listeners)
|
|
63
|
-
fn(this.toasts);
|
|
64
|
-
}
|
|
65
|
-
update(fn) {
|
|
66
|
-
this.toasts = fn(this.toasts);
|
|
67
|
-
this.emit();
|
|
68
|
-
}
|
|
69
|
-
dismiss(id) {
|
|
70
|
-
const item = this.toasts.find((t) => t.id === id);
|
|
71
|
-
if (!item || item.exiting)
|
|
72
|
-
return;
|
|
73
|
-
this.update((prev) => prev.map((t) => t.id === id ? { ...t, exiting: true } : t));
|
|
74
|
-
setTimeout(() => this.update((prev) => prev.filter((t) => t.id !== id)), 600);
|
|
75
|
-
}
|
|
76
|
-
show(opts) {
|
|
77
|
-
const id = opts.title ? `notify-${opts.title}` : "notify-default";
|
|
78
|
-
const prevItem = this.toasts.find((t) => t.id === id);
|
|
79
|
-
const instanceId = prevItem?.instanceId ?? this.generateId();
|
|
80
|
-
const state = opts.type ?? prevItem?.type ?? "success";
|
|
81
|
-
const item = {
|
|
82
|
-
...prevItem,
|
|
83
|
-
...opts,
|
|
84
|
-
id,
|
|
85
|
-
instanceId,
|
|
86
|
-
type: state
|
|
87
|
-
};
|
|
88
|
-
this.update((prev) => {
|
|
89
|
-
const filtered = prev.filter((t) => t.id !== id);
|
|
90
|
-
return [...filtered, item];
|
|
91
|
-
});
|
|
92
|
-
return id;
|
|
93
|
-
}
|
|
94
|
-
getToasts() {
|
|
95
|
-
return this.toasts;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
var notifyCore = new NotifyCore;
|
|
99
|
-
|
|
100
|
-
// src/render-notify-toasts.ts
|
|
101
|
-
var ICONS = {
|
|
102
|
-
success: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>',
|
|
103
|
-
error: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',
|
|
104
|
-
warning: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',
|
|
105
|
-
info: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="m4.93 4.93 4.24 4.24"/><path d="m14.83 9.17 4.24-4.24"/><path d="m14.83 14.83 4.24 4.24"/><path d="m9.17 14.83-4.24 4.24"/><circle cx="12" cy="12" r="4"/></svg>',
|
|
106
|
-
loading: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" data-notify-icon="spin" aria-hidden="true"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',
|
|
107
|
-
action: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>'
|
|
108
|
-
};
|
|
109
|
-
var EXIT_MS = 600;
|
|
110
|
-
function capitalize(s) {
|
|
111
|
-
return s ? s.charAt(0).toUpperCase() + s.slice(1) : "";
|
|
112
|
-
}
|
|
113
|
-
var viewport = null;
|
|
114
|
-
var toastEls = new Map;
|
|
115
|
-
function getOrCreateViewport(position) {
|
|
116
|
-
if (!viewport) {
|
|
117
|
-
viewport = document.createElement("div");
|
|
118
|
-
viewport.setAttribute("data-notify-viewport", "");
|
|
119
|
-
viewport.setAttribute("data-position", position);
|
|
120
|
-
viewport.setAttribute("data-theme", "light");
|
|
121
|
-
document.body.appendChild(viewport);
|
|
122
|
-
}
|
|
123
|
-
return viewport;
|
|
124
|
-
}
|
|
125
|
-
function buildToastEl(toast) {
|
|
126
|
-
const state = toast.type || "success";
|
|
127
|
-
const btn = document.createElement("button");
|
|
128
|
-
btn.type = "button";
|
|
129
|
-
btn.setAttribute("data-notify-toast", "");
|
|
130
|
-
btn.setAttribute("data-state", state);
|
|
131
|
-
btn.setAttribute("data-ready", "false");
|
|
132
|
-
btn.setAttribute("data-exiting", "false");
|
|
133
|
-
const card = document.createElement("div");
|
|
134
|
-
card.setAttribute("data-notify-card", "");
|
|
135
|
-
const header = document.createElement("div");
|
|
136
|
-
header.setAttribute("data-notify-header", "");
|
|
137
|
-
const badge = document.createElement("div");
|
|
138
|
-
badge.setAttribute("data-notify-badge", "");
|
|
139
|
-
badge.setAttribute("data-state", state);
|
|
140
|
-
badge.innerHTML = ICONS[state] || ICONS.success;
|
|
141
|
-
const titleEl = document.createElement("span");
|
|
142
|
-
titleEl.setAttribute("data-notify-title", "");
|
|
143
|
-
titleEl.setAttribute("data-state", state);
|
|
144
|
-
titleEl.textContent = toast.title || capitalize(state);
|
|
145
|
-
header.appendChild(badge);
|
|
146
|
-
header.appendChild(titleEl);
|
|
147
|
-
card.appendChild(header);
|
|
148
|
-
if (toast.description || toast.button) {
|
|
149
|
-
const content = document.createElement("div");
|
|
150
|
-
content.setAttribute("data-notify-content", "");
|
|
151
|
-
content.setAttribute("data-visible", "true");
|
|
152
|
-
if (toast.description) {
|
|
153
|
-
const desc = document.createElement("div");
|
|
154
|
-
desc.setAttribute("data-notify-description", "");
|
|
155
|
-
desc.textContent = toast.description;
|
|
156
|
-
content.appendChild(desc);
|
|
157
|
-
}
|
|
158
|
-
if (toast.button) {
|
|
159
|
-
const actionBtn = document.createElement("button");
|
|
160
|
-
actionBtn.setAttribute("data-notify-button", "");
|
|
161
|
-
actionBtn.setAttribute("data-state", state);
|
|
162
|
-
actionBtn.textContent = toast.button.title;
|
|
163
|
-
actionBtn.addEventListener("click", (e) => {
|
|
164
|
-
e.stopPropagation();
|
|
165
|
-
toast.button?.onClick();
|
|
166
|
-
notifyCore.dismiss(toast.id);
|
|
167
|
-
});
|
|
168
|
-
content.appendChild(actionBtn);
|
|
169
|
-
}
|
|
170
|
-
card.appendChild(content);
|
|
171
|
-
}
|
|
172
|
-
btn.appendChild(card);
|
|
173
|
-
btn.addEventListener("click", () => notifyCore.dismiss(toast.id));
|
|
174
|
-
requestAnimationFrame(() => {
|
|
175
|
-
requestAnimationFrame(() => {
|
|
176
|
-
btn.setAttribute("data-ready", "true");
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
return btn;
|
|
180
|
-
}
|
|
181
|
-
function updateToastEl(el, toast) {
|
|
182
|
-
const state = toast.type || "success";
|
|
183
|
-
el.setAttribute("data-state", state);
|
|
184
|
-
if (toast.exiting) {
|
|
185
|
-
el.setAttribute("data-exiting", "true");
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function renderNotifyToasts(options = {}) {
|
|
189
|
-
const position = options.position ?? "top-right";
|
|
190
|
-
const vp = getOrCreateViewport(position);
|
|
191
|
-
return notifyCore.subscribe((toasts) => {
|
|
192
|
-
const liveIds = new Set(toasts.map((t) => t.id));
|
|
193
|
-
for (const [id, el] of toastEls) {
|
|
194
|
-
if (!liveIds.has(id)) {
|
|
195
|
-
el.setAttribute("data-exiting", "true");
|
|
196
|
-
setTimeout(() => {
|
|
197
|
-
el.remove();
|
|
198
|
-
toastEls.delete(id);
|
|
199
|
-
}, EXIT_MS);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
for (const toast of toasts) {
|
|
203
|
-
if (toastEls.has(toast.id)) {
|
|
204
|
-
updateToastEl(toastEls.get(toast.id), toast);
|
|
205
|
-
} else {
|
|
206
|
-
const el = buildToastEl(toast);
|
|
207
|
-
toastEls.set(toast.id, el);
|
|
208
|
-
vp.appendChild(el);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
})();
|
package/dist/svelte.d.mts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as svelte_store from 'svelte/store';
|
|
2
|
-
|
|
3
|
-
type NotifyState = "success" | "loading" | "error" | "warning" | "info" | "action";
|
|
4
|
-
interface NotifyStyles {
|
|
5
|
-
title?: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
badge?: string;
|
|
8
|
-
button?: string;
|
|
9
|
-
}
|
|
10
|
-
interface NotifyButton {
|
|
11
|
-
title: string;
|
|
12
|
-
onClick: () => void;
|
|
13
|
-
}
|
|
14
|
-
declare const NOTIFY_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
|
|
15
|
-
type NotifyPosition = (typeof NOTIFY_POSITIONS)[number];
|
|
16
|
-
interface NotifyOptions {
|
|
17
|
-
title?: string;
|
|
18
|
-
description?: string;
|
|
19
|
-
type?: NotifyState;
|
|
20
|
-
position?: NotifyPosition;
|
|
21
|
-
duration?: number | null;
|
|
22
|
-
icon?: any;
|
|
23
|
-
styles?: NotifyStyles;
|
|
24
|
-
fill?: string;
|
|
25
|
-
roundness?: number;
|
|
26
|
-
autopilot?: boolean | {
|
|
27
|
-
expand?: number;
|
|
28
|
-
collapse?: number;
|
|
29
|
-
};
|
|
30
|
-
button?: NotifyButton;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface NotifyItem extends NotifyOptions {
|
|
34
|
-
id: string;
|
|
35
|
-
instanceId: string;
|
|
36
|
-
exiting?: boolean;
|
|
37
|
-
autoExpandDelayMs?: number;
|
|
38
|
-
autoCollapseDelayMs?: number;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare const notifyToasts: svelte_store.Writable<NotifyItem[]>;
|
|
42
|
-
declare function showNotifyToast(options: NotifyOptions): string;
|
|
43
|
-
|
|
44
|
-
declare function renderNotifyToasts(options?: {
|
|
45
|
-
position?: NotifyPosition;
|
|
46
|
-
}): () => boolean;
|
|
47
|
-
|
|
48
|
-
export { notifyToasts, renderNotifyToasts, showNotifyToast };
|
|
49
|
-
//# sourceMappingURL=svelte.d.mts.map
|
package/dist/svelte.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"svelte.d.mts","sources":["../src/types.ts","../src/core/notify-core.ts","../src/svelte-notify.ts","../src/render-notify-toasts.ts"],"mappings":";;AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;AC1BA,UAAU,UAAU,SAAS,aAAa;AAC1C;AACA;AACA;AACA;AACA;AACA;;ACLA,cAAc,YAAY,EAAE,YAAY,CAAC,QAAQ,CAACA,UAA6B;AAC/E,iBAAiB,eAAe,UAAU,aAAa;;ACHvD,iBAAiB,kBAAkB;AACnC,eAAe,cAAc;AAC7B;;;;","names":["__core_notify_core.NotifyItem"]}
|
package/dist/svelte.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as svelte_store from 'svelte/store';
|
|
2
|
-
|
|
3
|
-
type NotifyState = "success" | "loading" | "error" | "warning" | "info" | "action";
|
|
4
|
-
interface NotifyStyles {
|
|
5
|
-
title?: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
badge?: string;
|
|
8
|
-
button?: string;
|
|
9
|
-
}
|
|
10
|
-
interface NotifyButton {
|
|
11
|
-
title: string;
|
|
12
|
-
onClick: () => void;
|
|
13
|
-
}
|
|
14
|
-
declare const NOTIFY_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
|
|
15
|
-
type NotifyPosition = (typeof NOTIFY_POSITIONS)[number];
|
|
16
|
-
interface NotifyOptions {
|
|
17
|
-
title?: string;
|
|
18
|
-
description?: string;
|
|
19
|
-
type?: NotifyState;
|
|
20
|
-
position?: NotifyPosition;
|
|
21
|
-
duration?: number | null;
|
|
22
|
-
icon?: any;
|
|
23
|
-
styles?: NotifyStyles;
|
|
24
|
-
fill?: string;
|
|
25
|
-
roundness?: number;
|
|
26
|
-
autopilot?: boolean | {
|
|
27
|
-
expand?: number;
|
|
28
|
-
collapse?: number;
|
|
29
|
-
};
|
|
30
|
-
button?: NotifyButton;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface NotifyItem extends NotifyOptions {
|
|
34
|
-
id: string;
|
|
35
|
-
instanceId: string;
|
|
36
|
-
exiting?: boolean;
|
|
37
|
-
autoExpandDelayMs?: number;
|
|
38
|
-
autoCollapseDelayMs?: number;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare const notifyToasts: svelte_store.Writable<NotifyItem[]>;
|
|
42
|
-
declare function showNotifyToast(options: NotifyOptions): string;
|
|
43
|
-
|
|
44
|
-
declare function renderNotifyToasts(options?: {
|
|
45
|
-
position?: NotifyPosition;
|
|
46
|
-
}): () => boolean;
|
|
47
|
-
|
|
48
|
-
export { notifyToasts, renderNotifyToasts, showNotifyToast };
|
|
49
|
-
//# sourceMappingURL=svelte.d.ts.map
|
package/dist/svelte.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"svelte.d.ts","sources":["../src/types.ts","../src/core/notify-core.ts","../src/svelte-notify.ts","../src/render-notify-toasts.ts"],"mappings":";;AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;AC1BA,UAAU,UAAU,SAAS,aAAa;AAC1C;AACA;AACA;AACA;AACA;AACA;;ACLA,cAAc,YAAY,EAAE,YAAY,CAAC,QAAQ,CAACA,UAA6B;AAC/E,iBAAiB,eAAe,UAAU,aAAa;;ACHvD,iBAAiB,kBAAkB;AACnC,eAAe,cAAc;AAC7B;;;;","names":["__core_notify_core.NotifyItem"]}
|