@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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
function __insertCSS(code) {
|
|
3
|
+
if (!code || typeof document == 'undefined') return
|
|
4
|
+
let head = document.head || document.getElementsByTagName('head')[0]
|
|
5
|
+
let style = document.createElement('style')
|
|
6
|
+
style.type = 'text/css'
|
|
7
|
+
head.appendChild(style)
|
|
8
|
+
;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var React = require('react');
|
|
12
|
+
|
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
16
|
+
|
|
17
|
+
const getAsset = (type)=>{
|
|
18
|
+
switch(type){
|
|
19
|
+
case 'success':
|
|
20
|
+
return SuccessIcon;
|
|
21
|
+
case 'info':
|
|
22
|
+
return InfoIcon;
|
|
23
|
+
case 'warning':
|
|
24
|
+
return WarningIcon;
|
|
25
|
+
case 'error':
|
|
26
|
+
return ErrorIcon;
|
|
27
|
+
default:
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const bars = Array(12).fill(0);
|
|
32
|
+
const Loader = ({ visible, className })=>{
|
|
33
|
+
return /*#__PURE__*/ React__default.default.createElement("div", {
|
|
34
|
+
className: [
|
|
35
|
+
'notify-loading-wrapper',
|
|
36
|
+
className
|
|
37
|
+
].filter(Boolean).join(' '),
|
|
38
|
+
"data-visible": visible
|
|
39
|
+
}, /*#__PURE__*/ React__default.default.createElement("div", {
|
|
40
|
+
className: "notify-spinner"
|
|
41
|
+
}, bars.map((_, i)=>/*#__PURE__*/ React__default.default.createElement("div", {
|
|
42
|
+
className: "notify-loading-bar",
|
|
43
|
+
key: `spinner-bar-${i}`
|
|
44
|
+
}))));
|
|
45
|
+
};
|
|
46
|
+
const SuccessIcon = /*#__PURE__*/ React__default.default.createElement("svg", {
|
|
47
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
48
|
+
viewBox: "0 0 20 20",
|
|
49
|
+
fill: "currentColor",
|
|
50
|
+
height: "20",
|
|
51
|
+
width: "20"
|
|
52
|
+
}, /*#__PURE__*/ React__default.default.createElement("path", {
|
|
53
|
+
fillRule: "evenodd",
|
|
54
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
55
|
+
clipRule: "evenodd"
|
|
56
|
+
}));
|
|
57
|
+
const WarningIcon = /*#__PURE__*/ React__default.default.createElement("svg", {
|
|
58
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
59
|
+
viewBox: "0 0 24 24",
|
|
60
|
+
fill: "currentColor",
|
|
61
|
+
height: "20",
|
|
62
|
+
width: "20"
|
|
63
|
+
}, /*#__PURE__*/ React__default.default.createElement("path", {
|
|
64
|
+
fillRule: "evenodd",
|
|
65
|
+
d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
|
|
66
|
+
clipRule: "evenodd"
|
|
67
|
+
}));
|
|
68
|
+
const InfoIcon = /*#__PURE__*/ React__default.default.createElement("svg", {
|
|
69
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
70
|
+
viewBox: "0 0 20 20",
|
|
71
|
+
fill: "currentColor",
|
|
72
|
+
height: "20",
|
|
73
|
+
width: "20"
|
|
74
|
+
}, /*#__PURE__*/ React__default.default.createElement("path", {
|
|
75
|
+
fillRule: "evenodd",
|
|
76
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
77
|
+
clipRule: "evenodd"
|
|
78
|
+
}));
|
|
79
|
+
const ErrorIcon = /*#__PURE__*/ React__default.default.createElement("svg", {
|
|
80
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
81
|
+
viewBox: "0 0 20 20",
|
|
82
|
+
fill: "currentColor",
|
|
83
|
+
height: "20",
|
|
84
|
+
width: "20"
|
|
85
|
+
}, /*#__PURE__*/ React__default.default.createElement("path", {
|
|
86
|
+
fillRule: "evenodd",
|
|
87
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
|
|
88
|
+
clipRule: "evenodd"
|
|
89
|
+
}));
|
|
90
|
+
const CloseIcon = /*#__PURE__*/ React__default.default.createElement("svg", {
|
|
91
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
92
|
+
width: "12",
|
|
93
|
+
height: "12",
|
|
94
|
+
viewBox: "0 0 24 24",
|
|
95
|
+
fill: "none",
|
|
96
|
+
stroke: "currentColor",
|
|
97
|
+
strokeWidth: "1.5",
|
|
98
|
+
strokeLinecap: "round",
|
|
99
|
+
strokeLinejoin: "round"
|
|
100
|
+
}, /*#__PURE__*/ React__default.default.createElement("line", {
|
|
101
|
+
x1: "18",
|
|
102
|
+
y1: "6",
|
|
103
|
+
x2: "6",
|
|
104
|
+
y2: "18"
|
|
105
|
+
}), /*#__PURE__*/ React__default.default.createElement("line", {
|
|
106
|
+
x1: "6",
|
|
107
|
+
y1: "6",
|
|
108
|
+
x2: "18",
|
|
109
|
+
y2: "18"
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
exports.CloseIcon = CloseIcon;
|
|
113
|
+
exports.Loader = Loader;
|
|
114
|
+
exports.getAsset = getAsset;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
function __insertCSS(code) {
|
|
3
|
+
if (!code || typeof document == 'undefined') return
|
|
4
|
+
let head = document.head || document.getElementsByTagName('head')[0]
|
|
5
|
+
let style = document.createElement('style')
|
|
6
|
+
style.type = 'text/css'
|
|
7
|
+
head.appendChild(style)
|
|
8
|
+
;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
|
|
13
|
+
const getAsset = (type)=>{
|
|
14
|
+
switch(type){
|
|
15
|
+
case 'success':
|
|
16
|
+
return SuccessIcon;
|
|
17
|
+
case 'info':
|
|
18
|
+
return InfoIcon;
|
|
19
|
+
case 'warning':
|
|
20
|
+
return WarningIcon;
|
|
21
|
+
case 'error':
|
|
22
|
+
return ErrorIcon;
|
|
23
|
+
default:
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const bars = Array(12).fill(0);
|
|
28
|
+
const Loader = ({ visible, className })=>{
|
|
29
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
30
|
+
className: [
|
|
31
|
+
'notify-loading-wrapper',
|
|
32
|
+
className
|
|
33
|
+
].filter(Boolean).join(' '),
|
|
34
|
+
"data-visible": visible
|
|
35
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
36
|
+
className: "notify-spinner"
|
|
37
|
+
}, bars.map((_, i)=>/*#__PURE__*/ React.createElement("div", {
|
|
38
|
+
className: "notify-loading-bar",
|
|
39
|
+
key: `spinner-bar-${i}`
|
|
40
|
+
}))));
|
|
41
|
+
};
|
|
42
|
+
const SuccessIcon = /*#__PURE__*/ React.createElement("svg", {
|
|
43
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
44
|
+
viewBox: "0 0 20 20",
|
|
45
|
+
fill: "currentColor",
|
|
46
|
+
height: "20",
|
|
47
|
+
width: "20"
|
|
48
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
49
|
+
fillRule: "evenodd",
|
|
50
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
51
|
+
clipRule: "evenodd"
|
|
52
|
+
}));
|
|
53
|
+
const WarningIcon = /*#__PURE__*/ React.createElement("svg", {
|
|
54
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
55
|
+
viewBox: "0 0 24 24",
|
|
56
|
+
fill: "currentColor",
|
|
57
|
+
height: "20",
|
|
58
|
+
width: "20"
|
|
59
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
60
|
+
fillRule: "evenodd",
|
|
61
|
+
d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
|
|
62
|
+
clipRule: "evenodd"
|
|
63
|
+
}));
|
|
64
|
+
const InfoIcon = /*#__PURE__*/ React.createElement("svg", {
|
|
65
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
66
|
+
viewBox: "0 0 20 20",
|
|
67
|
+
fill: "currentColor",
|
|
68
|
+
height: "20",
|
|
69
|
+
width: "20"
|
|
70
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
71
|
+
fillRule: "evenodd",
|
|
72
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
73
|
+
clipRule: "evenodd"
|
|
74
|
+
}));
|
|
75
|
+
const ErrorIcon = /*#__PURE__*/ React.createElement("svg", {
|
|
76
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
77
|
+
viewBox: "0 0 20 20",
|
|
78
|
+
fill: "currentColor",
|
|
79
|
+
height: "20",
|
|
80
|
+
width: "20"
|
|
81
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
82
|
+
fillRule: "evenodd",
|
|
83
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
|
|
84
|
+
clipRule: "evenodd"
|
|
85
|
+
}));
|
|
86
|
+
const CloseIcon = /*#__PURE__*/ React.createElement("svg", {
|
|
87
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
88
|
+
width: "12",
|
|
89
|
+
height: "12",
|
|
90
|
+
viewBox: "0 0 24 24",
|
|
91
|
+
fill: "none",
|
|
92
|
+
stroke: "currentColor",
|
|
93
|
+
strokeWidth: "1.5",
|
|
94
|
+
strokeLinecap: "round",
|
|
95
|
+
strokeLinejoin: "round"
|
|
96
|
+
}, /*#__PURE__*/ React.createElement("line", {
|
|
97
|
+
x1: "18",
|
|
98
|
+
y1: "6",
|
|
99
|
+
x2: "6",
|
|
100
|
+
y2: "18"
|
|
101
|
+
}), /*#__PURE__*/ React.createElement("line", {
|
|
102
|
+
x1: "6",
|
|
103
|
+
y1: "6",
|
|
104
|
+
x2: "18",
|
|
105
|
+
y2: "18"
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
export { CloseIcon as C, Loader as L, getAsset as g };
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
function __insertCSS(code) {
|
|
3
|
+
if (!code || typeof document == 'undefined') return
|
|
4
|
+
let head = document.head || document.getElementsByTagName('head')[0]
|
|
5
|
+
let style = document.createElement('style')
|
|
6
|
+
style.type = 'text/css'
|
|
7
|
+
head.appendChild(style)
|
|
8
|
+
;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { createRoot } from 'react-dom/client';
|
|
13
|
+
import { t as toast$1, c as canUseDOM, T as Toaster } from './render-client-bGRSTd-L.mjs';
|
|
14
|
+
|
|
15
|
+
let vanillaToasterRoot = null;
|
|
16
|
+
let vanillaToasterElement = null;
|
|
17
|
+
let vanillaToasterOptions = {};
|
|
18
|
+
function toReactAction(action) {
|
|
19
|
+
if (!action) return undefined;
|
|
20
|
+
return {
|
|
21
|
+
label: action.label,
|
|
22
|
+
onClick: (event)=>{
|
|
23
|
+
action.onClick?.(event);
|
|
24
|
+
if (action.closeOnClick === false) {
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function normalizeToastOptions(options) {
|
|
31
|
+
if (!options) return undefined;
|
|
32
|
+
return {
|
|
33
|
+
...options,
|
|
34
|
+
action: toReactAction(options.action),
|
|
35
|
+
cancel: toReactAction(options.cancel)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function normalizePromiseValue(value) {
|
|
39
|
+
if (typeof value !== 'function') {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
return async (data)=>value(data);
|
|
43
|
+
}
|
|
44
|
+
function normalizePromiseData(data) {
|
|
45
|
+
if (!data) return undefined;
|
|
46
|
+
const { loading, success, error, description, finally: finallyCallback, ...rest } = data;
|
|
47
|
+
return {
|
|
48
|
+
...normalizeToastOptions(rest),
|
|
49
|
+
loading: loading,
|
|
50
|
+
success: normalizePromiseValue(success),
|
|
51
|
+
error: normalizePromiseValue(error),
|
|
52
|
+
description: description,
|
|
53
|
+
finally: finallyCallback
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function getVanillaContainer() {
|
|
57
|
+
if (!canUseDOM()) return null;
|
|
58
|
+
if (vanillaToasterElement?.isConnected) {
|
|
59
|
+
return vanillaToasterElement;
|
|
60
|
+
}
|
|
61
|
+
const existing = document.querySelector('[data-notify-vanilla-root]');
|
|
62
|
+
if (existing) {
|
|
63
|
+
vanillaToasterElement = existing;
|
|
64
|
+
return existing;
|
|
65
|
+
}
|
|
66
|
+
const element = document.createElement('div');
|
|
67
|
+
element.dataset.notifyVanillaRoot = '';
|
|
68
|
+
document.body.appendChild(element);
|
|
69
|
+
vanillaToasterElement = element;
|
|
70
|
+
return element;
|
|
71
|
+
}
|
|
72
|
+
function renderVanillaToaster() {
|
|
73
|
+
const container = getVanillaContainer();
|
|
74
|
+
if (!container) return null;
|
|
75
|
+
if (!vanillaToasterRoot) {
|
|
76
|
+
vanillaToasterRoot = createRoot(container);
|
|
77
|
+
}
|
|
78
|
+
vanillaToasterRoot.render(/*#__PURE__*/ React.createElement(Toaster, vanillaToasterOptions));
|
|
79
|
+
return container;
|
|
80
|
+
}
|
|
81
|
+
function buildVanillaController(element) {
|
|
82
|
+
return {
|
|
83
|
+
element,
|
|
84
|
+
options: vanillaToasterOptions,
|
|
85
|
+
update (options = {}) {
|
|
86
|
+
vanillaToasterOptions = {
|
|
87
|
+
...vanillaToasterOptions,
|
|
88
|
+
...options
|
|
89
|
+
};
|
|
90
|
+
renderVanillaToaster();
|
|
91
|
+
return buildVanillaController(element);
|
|
92
|
+
},
|
|
93
|
+
destroy () {
|
|
94
|
+
destroyToaster();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function ensureVanillaToaster() {
|
|
99
|
+
const container = renderVanillaToaster();
|
|
100
|
+
return container ? buildVanillaController(container) : null;
|
|
101
|
+
}
|
|
102
|
+
function createToaster(options = {}) {
|
|
103
|
+
vanillaToasterOptions = {
|
|
104
|
+
...vanillaToasterOptions,
|
|
105
|
+
...options
|
|
106
|
+
};
|
|
107
|
+
return ensureVanillaToaster();
|
|
108
|
+
}
|
|
109
|
+
function configureToaster(options = {}) {
|
|
110
|
+
return createToaster(options);
|
|
111
|
+
}
|
|
112
|
+
function getToaster() {
|
|
113
|
+
if (!vanillaToasterElement || !vanillaToasterRoot) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return buildVanillaController(vanillaToasterElement);
|
|
117
|
+
}
|
|
118
|
+
function destroyToaster() {
|
|
119
|
+
vanillaToasterRoot?.unmount();
|
|
120
|
+
vanillaToasterRoot = null;
|
|
121
|
+
if (vanillaToasterElement?.parentNode) {
|
|
122
|
+
vanillaToasterElement.parentNode.removeChild(vanillaToasterElement);
|
|
123
|
+
}
|
|
124
|
+
vanillaToasterElement = null;
|
|
125
|
+
}
|
|
126
|
+
function ensureVanillaRendererMounted() {
|
|
127
|
+
if (!canUseDOM()) return;
|
|
128
|
+
ensureVanillaToaster();
|
|
129
|
+
}
|
|
130
|
+
const toast = Object.assign((message, data)=>{
|
|
131
|
+
ensureVanillaRendererMounted();
|
|
132
|
+
return toast$1(message, normalizeToastOptions(data));
|
|
133
|
+
}, {
|
|
134
|
+
success (message, data) {
|
|
135
|
+
ensureVanillaRendererMounted();
|
|
136
|
+
return toast$1.success(message, normalizeToastOptions(data));
|
|
137
|
+
},
|
|
138
|
+
info (message, data) {
|
|
139
|
+
ensureVanillaRendererMounted();
|
|
140
|
+
return toast$1.info(message, normalizeToastOptions(data));
|
|
141
|
+
},
|
|
142
|
+
warning (message, data) {
|
|
143
|
+
ensureVanillaRendererMounted();
|
|
144
|
+
return toast$1.warning(message, normalizeToastOptions(data));
|
|
145
|
+
},
|
|
146
|
+
error (message, data) {
|
|
147
|
+
ensureVanillaRendererMounted();
|
|
148
|
+
return toast$1.error(message, normalizeToastOptions(data));
|
|
149
|
+
},
|
|
150
|
+
loading (message, data) {
|
|
151
|
+
ensureVanillaRendererMounted();
|
|
152
|
+
return toast$1.loading(message, normalizeToastOptions(data));
|
|
153
|
+
},
|
|
154
|
+
message (message, data) {
|
|
155
|
+
ensureVanillaRendererMounted();
|
|
156
|
+
return toast$1.message(message, normalizeToastOptions(data));
|
|
157
|
+
},
|
|
158
|
+
promise (promise, data) {
|
|
159
|
+
ensureVanillaRendererMounted();
|
|
160
|
+
return toast$1.promise(promise, normalizePromiseData(data));
|
|
161
|
+
},
|
|
162
|
+
dismiss (id) {
|
|
163
|
+
return toast$1.dismiss(id);
|
|
164
|
+
},
|
|
165
|
+
getHistory () {
|
|
166
|
+
return toast$1.getHistory();
|
|
167
|
+
},
|
|
168
|
+
getToasts () {
|
|
169
|
+
return toast$1.getToasts();
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
export { createToaster as a, configureToaster as c, destroyToaster as d, getToaster as g, toast as t };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
function __insertCSS(code) {
|
|
3
|
+
if (!code || typeof document == 'undefined') return
|
|
4
|
+
let head = document.head || document.getElementsByTagName('head')[0]
|
|
5
|
+
let style = document.createElement('style')
|
|
6
|
+
style.type = 'text/css'
|
|
7
|
+
head.appendChild(style)
|
|
8
|
+
;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var React = require('react');
|
|
12
|
+
var client = require('react-dom/client');
|
|
13
|
+
var renderClient = require('./render-client-CjcQoukB.js');
|
|
14
|
+
|
|
15
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
|
|
17
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
18
|
+
|
|
19
|
+
let vanillaToasterRoot = null;
|
|
20
|
+
let vanillaToasterElement = null;
|
|
21
|
+
let vanillaToasterOptions = {};
|
|
22
|
+
function toReactAction(action) {
|
|
23
|
+
if (!action) return undefined;
|
|
24
|
+
return {
|
|
25
|
+
label: action.label,
|
|
26
|
+
onClick: (event)=>{
|
|
27
|
+
action.onClick?.(event);
|
|
28
|
+
if (action.closeOnClick === false) {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function normalizeToastOptions(options) {
|
|
35
|
+
if (!options) return undefined;
|
|
36
|
+
return {
|
|
37
|
+
...options,
|
|
38
|
+
action: toReactAction(options.action),
|
|
39
|
+
cancel: toReactAction(options.cancel)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function normalizePromiseValue(value) {
|
|
43
|
+
if (typeof value !== 'function') {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
return async (data)=>value(data);
|
|
47
|
+
}
|
|
48
|
+
function normalizePromiseData(data) {
|
|
49
|
+
if (!data) return undefined;
|
|
50
|
+
const { loading, success, error, description, finally: finallyCallback, ...rest } = data;
|
|
51
|
+
return {
|
|
52
|
+
...normalizeToastOptions(rest),
|
|
53
|
+
loading: loading,
|
|
54
|
+
success: normalizePromiseValue(success),
|
|
55
|
+
error: normalizePromiseValue(error),
|
|
56
|
+
description: description,
|
|
57
|
+
finally: finallyCallback
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function getVanillaContainer() {
|
|
61
|
+
if (!renderClient.canUseDOM()) return null;
|
|
62
|
+
if (vanillaToasterElement?.isConnected) {
|
|
63
|
+
return vanillaToasterElement;
|
|
64
|
+
}
|
|
65
|
+
const existing = document.querySelector('[data-notify-vanilla-root]');
|
|
66
|
+
if (existing) {
|
|
67
|
+
vanillaToasterElement = existing;
|
|
68
|
+
return existing;
|
|
69
|
+
}
|
|
70
|
+
const element = document.createElement('div');
|
|
71
|
+
element.dataset.notifyVanillaRoot = '';
|
|
72
|
+
document.body.appendChild(element);
|
|
73
|
+
vanillaToasterElement = element;
|
|
74
|
+
return element;
|
|
75
|
+
}
|
|
76
|
+
function renderVanillaToaster() {
|
|
77
|
+
const container = getVanillaContainer();
|
|
78
|
+
if (!container) return null;
|
|
79
|
+
if (!vanillaToasterRoot) {
|
|
80
|
+
vanillaToasterRoot = client.createRoot(container);
|
|
81
|
+
}
|
|
82
|
+
vanillaToasterRoot.render(/*#__PURE__*/ React__default.default.createElement(renderClient.Toaster, vanillaToasterOptions));
|
|
83
|
+
return container;
|
|
84
|
+
}
|
|
85
|
+
function buildVanillaController(element) {
|
|
86
|
+
return {
|
|
87
|
+
element,
|
|
88
|
+
options: vanillaToasterOptions,
|
|
89
|
+
update (options = {}) {
|
|
90
|
+
vanillaToasterOptions = {
|
|
91
|
+
...vanillaToasterOptions,
|
|
92
|
+
...options
|
|
93
|
+
};
|
|
94
|
+
renderVanillaToaster();
|
|
95
|
+
return buildVanillaController(element);
|
|
96
|
+
},
|
|
97
|
+
destroy () {
|
|
98
|
+
destroyToaster();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function ensureVanillaToaster() {
|
|
103
|
+
const container = renderVanillaToaster();
|
|
104
|
+
return container ? buildVanillaController(container) : null;
|
|
105
|
+
}
|
|
106
|
+
function createToaster(options = {}) {
|
|
107
|
+
vanillaToasterOptions = {
|
|
108
|
+
...vanillaToasterOptions,
|
|
109
|
+
...options
|
|
110
|
+
};
|
|
111
|
+
return ensureVanillaToaster();
|
|
112
|
+
}
|
|
113
|
+
function configureToaster(options = {}) {
|
|
114
|
+
return createToaster(options);
|
|
115
|
+
}
|
|
116
|
+
function getToaster() {
|
|
117
|
+
if (!vanillaToasterElement || !vanillaToasterRoot) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return buildVanillaController(vanillaToasterElement);
|
|
121
|
+
}
|
|
122
|
+
function destroyToaster() {
|
|
123
|
+
vanillaToasterRoot?.unmount();
|
|
124
|
+
vanillaToasterRoot = null;
|
|
125
|
+
if (vanillaToasterElement?.parentNode) {
|
|
126
|
+
vanillaToasterElement.parentNode.removeChild(vanillaToasterElement);
|
|
127
|
+
}
|
|
128
|
+
vanillaToasterElement = null;
|
|
129
|
+
}
|
|
130
|
+
function ensureVanillaRendererMounted() {
|
|
131
|
+
if (!renderClient.canUseDOM()) return;
|
|
132
|
+
ensureVanillaToaster();
|
|
133
|
+
}
|
|
134
|
+
const toast = Object.assign((message, data)=>{
|
|
135
|
+
ensureVanillaRendererMounted();
|
|
136
|
+
return renderClient.toast(message, normalizeToastOptions(data));
|
|
137
|
+
}, {
|
|
138
|
+
success (message, data) {
|
|
139
|
+
ensureVanillaRendererMounted();
|
|
140
|
+
return renderClient.toast.success(message, normalizeToastOptions(data));
|
|
141
|
+
},
|
|
142
|
+
info (message, data) {
|
|
143
|
+
ensureVanillaRendererMounted();
|
|
144
|
+
return renderClient.toast.info(message, normalizeToastOptions(data));
|
|
145
|
+
},
|
|
146
|
+
warning (message, data) {
|
|
147
|
+
ensureVanillaRendererMounted();
|
|
148
|
+
return renderClient.toast.warning(message, normalizeToastOptions(data));
|
|
149
|
+
},
|
|
150
|
+
error (message, data) {
|
|
151
|
+
ensureVanillaRendererMounted();
|
|
152
|
+
return renderClient.toast.error(message, normalizeToastOptions(data));
|
|
153
|
+
},
|
|
154
|
+
loading (message, data) {
|
|
155
|
+
ensureVanillaRendererMounted();
|
|
156
|
+
return renderClient.toast.loading(message, normalizeToastOptions(data));
|
|
157
|
+
},
|
|
158
|
+
message (message, data) {
|
|
159
|
+
ensureVanillaRendererMounted();
|
|
160
|
+
return renderClient.toast.message(message, normalizeToastOptions(data));
|
|
161
|
+
},
|
|
162
|
+
promise (promise, data) {
|
|
163
|
+
ensureVanillaRendererMounted();
|
|
164
|
+
return renderClient.toast.promise(promise, normalizePromiseData(data));
|
|
165
|
+
},
|
|
166
|
+
dismiss (id) {
|
|
167
|
+
return renderClient.toast.dismiss(id);
|
|
168
|
+
},
|
|
169
|
+
getHistory () {
|
|
170
|
+
return renderClient.toast.getHistory();
|
|
171
|
+
},
|
|
172
|
+
getToasts () {
|
|
173
|
+
return renderClient.toast.getToasts();
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
exports.configureToaster = configureToaster;
|
|
178
|
+
exports.createToaster = createToaster;
|
|
179
|
+
exports.destroyToaster = destroyToaster;
|
|
180
|
+
exports.getToaster = getToaster;
|
|
181
|
+
exports.toast = toast;
|