tfy-web-components 0.0.19 → 0.0.21
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/README.md +65 -4
- package/dist/..d.ts +46 -0
- package/dist/Accordion.d.ts +8 -9
- package/dist/Alert.d.ts +73 -0
- package/dist/AudioPlayer.d.ts +10 -0
- package/dist/Avatar.d.ts +19 -0
- package/dist/Badge.d.ts +2 -1
- package/dist/CopyField.d.ts +1 -0
- package/dist/CustomDrawer.d.ts +8 -1
- package/dist/DropdownMenu.d.ts +25 -0
- package/dist/IconButton.d.ts +4 -2
- package/dist/ImagesPreview.d.ts +12 -0
- package/dist/Input-CnGhA18d.js +74283 -0
- package/dist/Input-CnGhA18d.js.map +1 -0
- package/dist/Markdown.d.ts +103 -0
- package/dist/Modal.d.ts +12 -0
- package/dist/MonacoEditorCore-xfpJ6z-E.js +113 -0
- package/dist/MonacoEditorCore-xfpJ6z-E.js.map +1 -0
- package/dist/OpenUiFenceBlock-CsVY6kwA.js +20 -0
- package/dist/OpenUiFenceBlock-CsVY6kwA.js.map +1 -0
- package/dist/OutlinedRadio.d.ts +9 -0
- package/dist/RootFontSizeContext-7vgn7Y_k.js +22 -0
- package/dist/RootFontSizeContext-7vgn7Y_k.js.map +1 -0
- package/dist/SimpleCodeEditor.d.ts +63 -0
- package/dist/Skeleton.d.ts +7 -0
- package/dist/ThumbsFeedback.d.ts +18 -0
- package/dist/ToggleButton.d.ts +42 -0
- package/dist/UserMessage.d.ts +15 -0
- package/dist/UserMessageEdit.d.ts +16 -0
- package/dist/_commonjsHelpers-DWwsNxpa.js +9 -0
- package/dist/_commonjsHelpers-DWwsNxpa.js.map +1 -0
- package/dist/agent-chat.d.ts +222 -0
- package/dist/classNames-Dy-RXSjS.js +9 -0
- package/dist/{classNames-CC5emYUV.js.map → classNames-Dy-RXSjS.js.map} +1 -1
- package/dist/components/atoms/Accordion.d.ts +5 -6
- package/dist/components/atoms/Accordion.es.js +9 -7
- package/dist/components/atoms/Accordion.es.js.map +1 -1
- package/dist/components/atoms/AudioPlayer.d.ts +6 -0
- package/dist/components/atoms/AudioPlayer.es.js +1424 -0
- package/dist/components/atoms/AudioPlayer.es.js.map +1 -0
- package/dist/components/atoms/Avatar.d.ts +10 -0
- package/dist/components/atoms/Avatar.es.js +62 -0
- package/dist/components/atoms/Avatar.es.js.map +1 -0
- package/dist/components/atoms/Badge.d.ts +2 -1
- package/dist/components/atoms/Badge.es.js +9 -1
- package/dist/components/atoms/Badge.es.js.map +1 -1
- package/dist/components/atoms/Button.es.js +2 -2
- package/dist/components/atoms/IconButton.d.ts +4 -2
- package/dist/components/atoms/IconButton.es.js +23 -7
- package/dist/components/atoms/IconButton.es.js.map +1 -1
- package/dist/components/atoms/IconProvider.es.js +28 -2
- package/dist/components/atoms/IconProvider.es.js.map +1 -1
- package/dist/components/atoms/Modal.d.ts +8 -0
- package/dist/components/atoms/Modal.es.js +19 -0
- package/dist/components/atoms/Modal.es.js.map +1 -0
- package/dist/components/atoms/OutlinedRadio.d.ts +5 -0
- package/dist/components/atoms/OutlinedRadio.es.js +29 -0
- package/dist/components/atoms/OutlinedRadio.es.js.map +1 -0
- package/dist/components/atoms/Skeleton.d.ts +4 -0
- package/dist/components/atoms/Skeleton.es.js +9 -0
- package/dist/components/atoms/Skeleton.es.js.map +1 -0
- package/dist/components/atoms/Spinner.es.js +1 -1
- package/dist/components/atoms/Switch.es.js +1 -18
- package/dist/components/atoms/Switch.es.js.map +1 -1
- package/dist/components/atoms/TabButton.es.js +1 -1
- package/dist/components/atoms/TabPanel.es.js +1 -1
- package/dist/components/atoms/Tooltip.es.js +1 -1
- package/dist/components/molecules/Alert.d.ts +26 -0
- package/dist/components/molecules/Alert.es.js +135 -0
- package/dist/components/molecules/Alert.es.js.map +1 -0
- package/dist/components/molecules/CopyField.d.ts +1 -0
- package/dist/components/molecules/CopyField.es.js +12 -74192
- package/dist/components/molecules/CopyField.es.js.map +1 -1
- package/dist/components/molecules/CustomDrawer.d.ts +8 -1
- package/dist/components/molecules/CustomDrawer.es.js +118 -48
- package/dist/components/molecules/CustomDrawer.es.js.map +1 -1
- package/dist/components/molecules/Dialog.es.js +2570 -1519
- package/dist/components/molecules/Dialog.es.js.map +1 -1
- package/dist/components/molecules/DropdownMenu.d.ts +18 -0
- package/dist/components/molecules/DropdownMenu.es.js +104 -0
- package/dist/components/molecules/DropdownMenu.es.js.map +1 -0
- package/dist/components/molecules/ImagesPreview.d.ts +8 -0
- package/dist/components/molecules/ImagesPreview.es.js +186 -0
- package/dist/components/molecules/ImagesPreview.es.js.map +1 -0
- package/dist/components/molecules/Input.es.js +2 -2
- package/dist/components/molecules/Markdown.d.ts +1 -0
- package/dist/components/molecules/Markdown.es.js +345 -0
- package/dist/components/molecules/Markdown.es.js.map +1 -0
- package/dist/components/molecules/Notify.es.js +6 -1023
- package/dist/components/molecules/Notify.es.js.map +1 -1
- package/dist/components/molecules/SimpleCodeEditor.d.ts +56 -0
- package/dist/components/molecules/SimpleCodeEditor.es.js +784 -0
- package/dist/components/molecules/SimpleCodeEditor.es.js.map +1 -0
- package/dist/components/molecules/ThumbsFeedback.d.ts +13 -0
- package/dist/components/molecules/ThumbsFeedback.es.js +98 -0
- package/dist/components/molecules/ThumbsFeedback.es.js.map +1 -0
- package/dist/components/molecules/ToggleButton.d.ts +37 -0
- package/dist/components/molecules/ToggleButton.es.js +72 -0
- package/dist/components/molecules/ToggleButton.es.js.map +1 -0
- package/dist/components/molecules/agent-chat/UserMessage.d.ts +11 -0
- package/dist/components/molecules/agent-chat/UserMessage.es.js +40 -0
- package/dist/components/molecules/agent-chat/UserMessage.es.js.map +1 -0
- package/dist/components/molecules/agent-chat/UserMessageEdit.d.ts +12 -0
- package/dist/components/molecules/agent-chat/UserMessageEdit.es.js +33 -0
- package/dist/components/molecules/agent-chat/UserMessageEdit.es.js.map +1 -0
- package/dist/components/molecules/agent-chat.d.ts +1 -0
- package/dist/components/molecules/agent-chat.es.js +935 -0
- package/dist/components/molecules/agent-chat.es.js.map +1 -0
- package/dist/components/theme/theme.d.ts +1 -0
- package/dist/components/theme/theme.es.js +12 -1
- package/dist/components/theme/theme.es.js.map +1 -1
- package/dist/components/theme/useTheme.d.ts +7 -0
- package/dist/components/theme/useTheme.es.js +35 -20
- package/dist/components/theme/useTheme.es.js.map +1 -1
- package/dist/components/theme/utils.es.js +1 -1
- package/dist/index.es.js +12 -4
- package/dist/index.es.js.map +1 -1
- package/dist/{isTypedArray-CoDTnA8U.js → isTypedArray-CLAk7Q1f.js} +30 -30
- package/dist/isTypedArray-CLAk7Q1f.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/tailwindPreset.d.ts +140 -0
- package/dist/tailwindPreset.es.js +100 -0
- package/dist/tailwindPreset.es.js.map +1 -0
- package/dist/theme.css +163 -0
- package/dist/theme.d.ts +2 -0
- package/dist/useTheme.d.ts +7 -0
- package/package.json +49 -3
- package/dist/_commonjsHelpers-CcAunmGO.js +0 -34
- package/dist/_commonjsHelpers-CcAunmGO.js.map +0 -1
- package/dist/classNames-CC5emYUV.js +0 -9
- package/dist/isTypedArray-CoDTnA8U.js.map +0 -1
|
@@ -1,1038 +1,21 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { render } from "react-dom";
|
|
2
|
+
import { toast } from "react-toastify";
|
|
4
3
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
5
|
-
import { T as Toast
|
|
6
|
-
function r(e) {
|
|
7
|
-
var t, f, n = "";
|
|
8
|
-
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
9
|
-
else if ("object" == typeof e) if (Array.isArray(e)) for (t = 0; t < e.length; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
10
|
-
else for (t in e) e[t] && (n && (n += " "), n += t);
|
|
11
|
-
return n;
|
|
12
|
-
}
|
|
13
|
-
function clsx() {
|
|
14
|
-
for (var e, t, f = 0, n = ""; f < arguments.length; ) (e = arguments[f++]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
15
|
-
return n;
|
|
16
|
-
}
|
|
17
|
-
function _extends() {
|
|
18
|
-
_extends = Object.assign || function(target) {
|
|
19
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
20
|
-
var source = arguments[i];
|
|
21
|
-
for (var key in source) {
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
23
|
-
target[key] = source[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return target;
|
|
28
|
-
};
|
|
29
|
-
return _extends.apply(this, arguments);
|
|
30
|
-
}
|
|
31
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
32
|
-
if (source == null) return {};
|
|
33
|
-
var target = {};
|
|
34
|
-
var sourceKeys = Object.keys(source);
|
|
35
|
-
var key, i;
|
|
36
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
37
|
-
key = sourceKeys[i];
|
|
38
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
39
|
-
target[key] = source[key];
|
|
40
|
-
}
|
|
41
|
-
return target;
|
|
42
|
-
}
|
|
43
|
-
function isNum(v) {
|
|
44
|
-
return typeof v === "number" && !isNaN(v);
|
|
45
|
-
}
|
|
46
|
-
function isBool(v) {
|
|
47
|
-
return typeof v === "boolean";
|
|
48
|
-
}
|
|
49
|
-
function isStr(v) {
|
|
50
|
-
return typeof v === "string";
|
|
51
|
-
}
|
|
52
|
-
function isFn(v) {
|
|
53
|
-
return typeof v === "function";
|
|
54
|
-
}
|
|
55
|
-
function parseClassName(v) {
|
|
56
|
-
return isStr(v) || isFn(v) ? v : null;
|
|
57
|
-
}
|
|
58
|
-
function isToastIdValid(toastId) {
|
|
59
|
-
return toastId === 0 || toastId;
|
|
60
|
-
}
|
|
61
|
-
function getAutoCloseDelay(toastAutoClose, containerAutoClose) {
|
|
62
|
-
return toastAutoClose === false || isNum(toastAutoClose) && toastAutoClose > 0 ? toastAutoClose : containerAutoClose;
|
|
63
|
-
}
|
|
64
|
-
var canUseDom = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
65
|
-
function canBeRendered(content) {
|
|
66
|
-
return isValidElement(content) || isStr(content) || isFn(content) || isNum(content);
|
|
67
|
-
}
|
|
68
|
-
var POSITION = {
|
|
69
|
-
TOP_LEFT: "top-left",
|
|
70
|
-
TOP_RIGHT: "top-right",
|
|
71
|
-
TOP_CENTER: "top-center",
|
|
72
|
-
BOTTOM_LEFT: "bottom-left",
|
|
73
|
-
BOTTOM_RIGHT: "bottom-right",
|
|
74
|
-
BOTTOM_CENTER: "bottom-center"
|
|
75
|
-
};
|
|
76
|
-
var TYPE = {
|
|
77
|
-
INFO: "info",
|
|
78
|
-
SUCCESS: "success",
|
|
79
|
-
WARNING: "warning",
|
|
80
|
-
ERROR: "error",
|
|
81
|
-
DEFAULT: "default"
|
|
82
|
-
};
|
|
83
|
-
function collapseToast(node, done, duration) {
|
|
84
|
-
if (duration === void 0) {
|
|
85
|
-
duration = 300;
|
|
86
|
-
}
|
|
87
|
-
var scrollHeight = node.scrollHeight, style = node.style;
|
|
88
|
-
requestAnimationFrame(function() {
|
|
89
|
-
style.minHeight = "initial";
|
|
90
|
-
style.height = scrollHeight + "px";
|
|
91
|
-
style.transition = "all " + duration + "ms";
|
|
92
|
-
requestAnimationFrame(function() {
|
|
93
|
-
style.height = "0";
|
|
94
|
-
style.padding = "0";
|
|
95
|
-
style.margin = "0";
|
|
96
|
-
setTimeout(done, duration);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
function cssTransition(_ref) {
|
|
101
|
-
var enter = _ref.enter, exit = _ref.exit, _ref$appendPosition = _ref.appendPosition, appendPosition = _ref$appendPosition === void 0 ? false : _ref$appendPosition, _ref$collapse = _ref.collapse, collapse = _ref$collapse === void 0 ? true : _ref$collapse, _ref$collapseDuration = _ref.collapseDuration, collapseDuration = _ref$collapseDuration === void 0 ? 300 : _ref$collapseDuration;
|
|
102
|
-
return function ToastTransition(_ref2) {
|
|
103
|
-
var children = _ref2.children, position = _ref2.position, preventExitTransition = _ref2.preventExitTransition, done = _ref2.done, nodeRef = _ref2.nodeRef, isIn = _ref2.isIn;
|
|
104
|
-
var enterClassName = appendPosition ? enter + "--" + position : enter;
|
|
105
|
-
var exitClassName = appendPosition ? exit + "--" + position : exit;
|
|
106
|
-
var baseClassName = useRef();
|
|
107
|
-
var animationStep = useRef(
|
|
108
|
-
0
|
|
109
|
-
/* Enter */
|
|
110
|
-
);
|
|
111
|
-
useLayoutEffect(function() {
|
|
112
|
-
onEnter();
|
|
113
|
-
}, []);
|
|
114
|
-
useEffect(function() {
|
|
115
|
-
if (!isIn) preventExitTransition ? onExited() : onExit();
|
|
116
|
-
}, [isIn]);
|
|
117
|
-
function onEnter() {
|
|
118
|
-
var node = nodeRef.current;
|
|
119
|
-
baseClassName.current = node.className;
|
|
120
|
-
node.className += " " + enterClassName;
|
|
121
|
-
node.addEventListener("animationend", onEntered);
|
|
122
|
-
node.addEventListener("animationcancel", onEntered);
|
|
123
|
-
}
|
|
124
|
-
function onEntered(e) {
|
|
125
|
-
if (e.target !== nodeRef.current) return;
|
|
126
|
-
var node = nodeRef.current;
|
|
127
|
-
node.dispatchEvent(new Event(
|
|
128
|
-
"d"
|
|
129
|
-
/* ENTRANCE_ANIMATION_END */
|
|
130
|
-
));
|
|
131
|
-
node.removeEventListener("animationend", onEntered);
|
|
132
|
-
node.removeEventListener("animationcancel", onEntered);
|
|
133
|
-
if (animationStep.current === 0) {
|
|
134
|
-
node.className = baseClassName.current;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
function onExit() {
|
|
138
|
-
animationStep.current = 1;
|
|
139
|
-
var node = nodeRef.current;
|
|
140
|
-
node.className += " " + exitClassName;
|
|
141
|
-
node.addEventListener("animationend", onExited);
|
|
142
|
-
}
|
|
143
|
-
function onExited() {
|
|
144
|
-
var node = nodeRef.current;
|
|
145
|
-
node.removeEventListener("animationend", onExited);
|
|
146
|
-
collapse ? collapseToast(node, done, collapseDuration) : done();
|
|
147
|
-
}
|
|
148
|
-
return React__default.createElement(React__default.Fragment, null, children);
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
var eventManager = {
|
|
152
|
-
list: /* @__PURE__ */ new Map(),
|
|
153
|
-
emitQueue: /* @__PURE__ */ new Map(),
|
|
154
|
-
on: function on(event, callback) {
|
|
155
|
-
this.list.has(event) || this.list.set(event, []);
|
|
156
|
-
this.list.get(event).push(callback);
|
|
157
|
-
return this;
|
|
158
|
-
},
|
|
159
|
-
off: function off(event, callback) {
|
|
160
|
-
if (callback) {
|
|
161
|
-
var cb = this.list.get(event).filter(function(cb2) {
|
|
162
|
-
return cb2 !== callback;
|
|
163
|
-
});
|
|
164
|
-
this.list.set(event, cb);
|
|
165
|
-
return this;
|
|
166
|
-
}
|
|
167
|
-
this.list["delete"](event);
|
|
168
|
-
return this;
|
|
169
|
-
},
|
|
170
|
-
cancelEmit: function cancelEmit(event) {
|
|
171
|
-
var timers = this.emitQueue.get(event);
|
|
172
|
-
if (timers) {
|
|
173
|
-
timers.forEach(clearTimeout);
|
|
174
|
-
this.emitQueue["delete"](event);
|
|
175
|
-
}
|
|
176
|
-
return this;
|
|
177
|
-
},
|
|
178
|
-
/**
|
|
179
|
-
* Enqueue the event at the end of the call stack
|
|
180
|
-
* Doing so let the user call toast as follow:
|
|
181
|
-
* toast('1')
|
|
182
|
-
* toast('2')
|
|
183
|
-
* toast('3')
|
|
184
|
-
* Without setTimemout the code above will not work
|
|
185
|
-
*/
|
|
186
|
-
emit: function emit(event) {
|
|
187
|
-
var _this = this;
|
|
188
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
189
|
-
args[_key - 1] = arguments[_key];
|
|
190
|
-
}
|
|
191
|
-
this.list.has(event) && this.list.get(event).forEach(function(callback) {
|
|
192
|
-
var timer = setTimeout(function() {
|
|
193
|
-
callback.apply(void 0, args);
|
|
194
|
-
}, 0);
|
|
195
|
-
_this.emitQueue.has(event) || _this.emitQueue.set(event, []);
|
|
196
|
-
_this.emitQueue.get(event).push(timer);
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
var _excluded = ["delay", "staleId"];
|
|
201
|
-
function useToastContainer(props) {
|
|
202
|
-
var _useReducer = useReducer(function(x) {
|
|
203
|
-
return x + 1;
|
|
204
|
-
}, 0), forceUpdate = _useReducer[1];
|
|
205
|
-
var _useState = useState([]), toastIds = _useState[0], setToastIds = _useState[1];
|
|
206
|
-
var containerRef = useRef(null);
|
|
207
|
-
var toastToRender = useRef(/* @__PURE__ */ new Map()).current;
|
|
208
|
-
var isToastActive = function isToastActive2(id) {
|
|
209
|
-
return toastIds.indexOf(id) !== -1;
|
|
210
|
-
};
|
|
211
|
-
var instance = useRef({
|
|
212
|
-
toastKey: 1,
|
|
213
|
-
displayedToast: 0,
|
|
214
|
-
count: 0,
|
|
215
|
-
queue: [],
|
|
216
|
-
props,
|
|
217
|
-
containerId: null,
|
|
218
|
-
isToastActive,
|
|
219
|
-
getToast: function getToast2(id) {
|
|
220
|
-
return toastToRender.get(id);
|
|
221
|
-
}
|
|
222
|
-
}).current;
|
|
223
|
-
useEffect(function() {
|
|
224
|
-
instance.containerId = props.containerId;
|
|
225
|
-
eventManager.cancelEmit(
|
|
226
|
-
3
|
|
227
|
-
/* WillUnmount */
|
|
228
|
-
).on(
|
|
229
|
-
0,
|
|
230
|
-
buildToast
|
|
231
|
-
).on(
|
|
232
|
-
1,
|
|
233
|
-
function(toastId) {
|
|
234
|
-
return containerRef.current && removeToast(toastId);
|
|
235
|
-
}
|
|
236
|
-
).on(
|
|
237
|
-
5,
|
|
238
|
-
clearWaitingQueue
|
|
239
|
-
).emit(
|
|
240
|
-
2,
|
|
241
|
-
instance
|
|
242
|
-
);
|
|
243
|
-
return function() {
|
|
244
|
-
return eventManager.emit(
|
|
245
|
-
3,
|
|
246
|
-
instance
|
|
247
|
-
);
|
|
248
|
-
};
|
|
249
|
-
}, []);
|
|
250
|
-
useEffect(function() {
|
|
251
|
-
instance.isToastActive = isToastActive;
|
|
252
|
-
instance.displayedToast = toastIds.length;
|
|
253
|
-
eventManager.emit(
|
|
254
|
-
4,
|
|
255
|
-
toastIds.length,
|
|
256
|
-
props.containerId
|
|
257
|
-
);
|
|
258
|
-
}, [toastIds]);
|
|
259
|
-
useEffect(function() {
|
|
260
|
-
instance.props = props;
|
|
261
|
-
});
|
|
262
|
-
function clearWaitingQueue(_ref) {
|
|
263
|
-
var containerId = _ref.containerId;
|
|
264
|
-
var limit = instance.props.limit;
|
|
265
|
-
if (limit && (!containerId || instance.containerId === containerId)) {
|
|
266
|
-
instance.count -= instance.queue.length;
|
|
267
|
-
instance.queue = [];
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
function removeToast(toastId) {
|
|
271
|
-
setToastIds(function(state) {
|
|
272
|
-
return isToastIdValid(toastId) ? state.filter(function(id) {
|
|
273
|
-
return id !== toastId;
|
|
274
|
-
}) : [];
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
function dequeueToast() {
|
|
278
|
-
var _instance$queue$shift = instance.queue.shift(), toastContent = _instance$queue$shift.toastContent, toastProps = _instance$queue$shift.toastProps, staleId = _instance$queue$shift.staleId;
|
|
279
|
-
appendToast(toastContent, toastProps, staleId);
|
|
280
|
-
}
|
|
281
|
-
function isNotValid(options) {
|
|
282
|
-
return !containerRef.current || instance.props.enableMultiContainer && options.containerId !== instance.props.containerId || toastToRender.has(options.toastId) && options.updateId == null;
|
|
283
|
-
}
|
|
284
|
-
function buildToast(content, _ref2) {
|
|
285
|
-
var delay = _ref2.delay, staleId = _ref2.staleId, options = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
286
|
-
if (!canBeRendered(content) || isNotValid(options)) return;
|
|
287
|
-
var toastId = options.toastId, updateId = options.updateId, data = options.data;
|
|
288
|
-
var props2 = instance.props;
|
|
289
|
-
var closeToast = function closeToast2() {
|
|
290
|
-
return removeToast(toastId);
|
|
291
|
-
};
|
|
292
|
-
var isNotAnUpdate = updateId == null;
|
|
293
|
-
if (isNotAnUpdate) instance.count++;
|
|
294
|
-
var toastProps = {
|
|
295
|
-
toastId,
|
|
296
|
-
updateId,
|
|
297
|
-
isLoading: options.isLoading,
|
|
298
|
-
theme: options.theme || props2.theme,
|
|
299
|
-
icon: options.icon != null ? options.icon : props2.icon,
|
|
300
|
-
isIn: false,
|
|
301
|
-
key: options.key || instance.toastKey++,
|
|
302
|
-
type: options.type,
|
|
303
|
-
closeToast,
|
|
304
|
-
closeButton: options.closeButton,
|
|
305
|
-
rtl: props2.rtl,
|
|
306
|
-
position: options.position || props2.position,
|
|
307
|
-
transition: options.transition || props2.transition,
|
|
308
|
-
className: parseClassName(options.className || props2.toastClassName),
|
|
309
|
-
bodyClassName: parseClassName(options.bodyClassName || props2.bodyClassName),
|
|
310
|
-
style: options.style || props2.toastStyle,
|
|
311
|
-
bodyStyle: options.bodyStyle || props2.bodyStyle,
|
|
312
|
-
onClick: options.onClick || props2.onClick,
|
|
313
|
-
pauseOnHover: isBool(options.pauseOnHover) ? options.pauseOnHover : props2.pauseOnHover,
|
|
314
|
-
pauseOnFocusLoss: isBool(options.pauseOnFocusLoss) ? options.pauseOnFocusLoss : props2.pauseOnFocusLoss,
|
|
315
|
-
draggable: isBool(options.draggable) ? options.draggable : props2.draggable,
|
|
316
|
-
draggablePercent: options.draggablePercent || props2.draggablePercent,
|
|
317
|
-
draggableDirection: options.draggableDirection || props2.draggableDirection,
|
|
318
|
-
closeOnClick: isBool(options.closeOnClick) ? options.closeOnClick : props2.closeOnClick,
|
|
319
|
-
progressClassName: parseClassName(options.progressClassName || props2.progressClassName),
|
|
320
|
-
progressStyle: options.progressStyle || props2.progressStyle,
|
|
321
|
-
autoClose: options.isLoading ? false : getAutoCloseDelay(options.autoClose, props2.autoClose),
|
|
322
|
-
hideProgressBar: isBool(options.hideProgressBar) ? options.hideProgressBar : props2.hideProgressBar,
|
|
323
|
-
progress: options.progress,
|
|
324
|
-
role: options.role || props2.role,
|
|
325
|
-
deleteToast: function deleteToast() {
|
|
326
|
-
toastToRender["delete"](toastId);
|
|
327
|
-
var queueLen = instance.queue.length;
|
|
328
|
-
instance.count = isToastIdValid(toastId) ? instance.count - 1 : instance.count - instance.displayedToast;
|
|
329
|
-
if (instance.count < 0) instance.count = 0;
|
|
330
|
-
if (queueLen > 0) {
|
|
331
|
-
var freeSlot = isToastIdValid(toastId) ? 1 : instance.props.limit;
|
|
332
|
-
if (queueLen === 1 || freeSlot === 1) {
|
|
333
|
-
instance.displayedToast++;
|
|
334
|
-
dequeueToast();
|
|
335
|
-
} else {
|
|
336
|
-
var toDequeue = freeSlot > queueLen ? queueLen : freeSlot;
|
|
337
|
-
instance.displayedToast = toDequeue;
|
|
338
|
-
for (var i = 0; i < toDequeue; i++) {
|
|
339
|
-
dequeueToast();
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
} else {
|
|
343
|
-
forceUpdate();
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
if (isFn(options.onOpen)) toastProps.onOpen = options.onOpen;
|
|
348
|
-
if (isFn(options.onClose)) toastProps.onClose = options.onClose;
|
|
349
|
-
toastProps.closeButton = props2.closeButton;
|
|
350
|
-
if (options.closeButton === false || canBeRendered(options.closeButton)) {
|
|
351
|
-
toastProps.closeButton = options.closeButton;
|
|
352
|
-
} else if (options.closeButton === true) {
|
|
353
|
-
toastProps.closeButton = canBeRendered(props2.closeButton) ? props2.closeButton : true;
|
|
354
|
-
}
|
|
355
|
-
var toastContent = content;
|
|
356
|
-
if (isValidElement(content) && !isStr(content.type)) {
|
|
357
|
-
toastContent = cloneElement(content, {
|
|
358
|
-
closeToast,
|
|
359
|
-
toastProps,
|
|
360
|
-
data
|
|
361
|
-
});
|
|
362
|
-
} else if (isFn(content)) {
|
|
363
|
-
toastContent = content({
|
|
364
|
-
closeToast,
|
|
365
|
-
toastProps,
|
|
366
|
-
data
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
if (props2.limit && props2.limit > 0 && instance.count > props2.limit && isNotAnUpdate) {
|
|
370
|
-
instance.queue.push({
|
|
371
|
-
toastContent,
|
|
372
|
-
toastProps,
|
|
373
|
-
staleId
|
|
374
|
-
});
|
|
375
|
-
} else if (isNum(delay) && delay > 0) {
|
|
376
|
-
setTimeout(function() {
|
|
377
|
-
appendToast(toastContent, toastProps, staleId);
|
|
378
|
-
}, delay);
|
|
379
|
-
} else {
|
|
380
|
-
appendToast(toastContent, toastProps, staleId);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
function appendToast(content, toastProps, staleId) {
|
|
384
|
-
var toastId = toastProps.toastId;
|
|
385
|
-
if (staleId) toastToRender["delete"](staleId);
|
|
386
|
-
toastToRender.set(toastId, {
|
|
387
|
-
content,
|
|
388
|
-
props: toastProps
|
|
389
|
-
});
|
|
390
|
-
setToastIds(function(state) {
|
|
391
|
-
return [].concat(state, [toastId]).filter(function(id) {
|
|
392
|
-
return id !== staleId;
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
function getToastToRender(cb) {
|
|
397
|
-
var toRender = /* @__PURE__ */ new Map();
|
|
398
|
-
var collection = Array.from(toastToRender.values());
|
|
399
|
-
if (props.newestOnTop) collection.reverse();
|
|
400
|
-
collection.forEach(function(toast2) {
|
|
401
|
-
var position = toast2.props.position;
|
|
402
|
-
toRender.has(position) || toRender.set(position, []);
|
|
403
|
-
toRender.get(position).push(toast2);
|
|
404
|
-
});
|
|
405
|
-
return Array.from(toRender, function(p) {
|
|
406
|
-
return cb(p[0], p[1]);
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
return {
|
|
410
|
-
getToastToRender,
|
|
411
|
-
containerRef,
|
|
412
|
-
isToastActive
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
function getX(e) {
|
|
416
|
-
return e.targetTouches && e.targetTouches.length >= 1 ? e.targetTouches[0].clientX : e.clientX;
|
|
417
|
-
}
|
|
418
|
-
function getY(e) {
|
|
419
|
-
return e.targetTouches && e.targetTouches.length >= 1 ? e.targetTouches[0].clientY : e.clientY;
|
|
420
|
-
}
|
|
421
|
-
function useToast(props) {
|
|
422
|
-
var _useState = useState(false), isRunning = _useState[0], setIsRunning = _useState[1];
|
|
423
|
-
var _useState2 = useState(false), preventExitTransition = _useState2[0], setPreventExitTransition = _useState2[1];
|
|
424
|
-
var toastRef = useRef(null);
|
|
425
|
-
var drag = useRef({
|
|
426
|
-
start: 0,
|
|
427
|
-
x: 0,
|
|
428
|
-
y: 0,
|
|
429
|
-
delta: 0,
|
|
430
|
-
removalDistance: 0,
|
|
431
|
-
canCloseOnClick: true,
|
|
432
|
-
canDrag: false,
|
|
433
|
-
boundingRect: null,
|
|
434
|
-
didMove: false
|
|
435
|
-
}).current;
|
|
436
|
-
var syncProps = useRef(props);
|
|
437
|
-
var autoClose = props.autoClose, pauseOnHover = props.pauseOnHover, closeToast = props.closeToast, onClick = props.onClick, closeOnClick = props.closeOnClick;
|
|
438
|
-
useEffect(function() {
|
|
439
|
-
syncProps.current = props;
|
|
440
|
-
});
|
|
441
|
-
useEffect(function() {
|
|
442
|
-
if (toastRef.current) toastRef.current.addEventListener(
|
|
443
|
-
"d",
|
|
444
|
-
playToast,
|
|
445
|
-
{
|
|
446
|
-
once: true
|
|
447
|
-
}
|
|
448
|
-
);
|
|
449
|
-
if (isFn(props.onOpen)) props.onOpen(isValidElement(props.children) && props.children.props);
|
|
450
|
-
return function() {
|
|
451
|
-
var props2 = syncProps.current;
|
|
452
|
-
if (isFn(props2.onClose)) props2.onClose(isValidElement(props2.children) && props2.children.props);
|
|
453
|
-
};
|
|
454
|
-
}, []);
|
|
455
|
-
useEffect(function() {
|
|
456
|
-
props.pauseOnFocusLoss && bindFocusEvents();
|
|
457
|
-
return function() {
|
|
458
|
-
props.pauseOnFocusLoss && unbindFocusEvents();
|
|
459
|
-
};
|
|
460
|
-
}, [props.pauseOnFocusLoss]);
|
|
461
|
-
function onDragStart(e) {
|
|
462
|
-
if (props.draggable) {
|
|
463
|
-
bindDragEvents();
|
|
464
|
-
var toast2 = toastRef.current;
|
|
465
|
-
drag.canCloseOnClick = true;
|
|
466
|
-
drag.canDrag = true;
|
|
467
|
-
drag.boundingRect = toast2.getBoundingClientRect();
|
|
468
|
-
toast2.style.transition = "";
|
|
469
|
-
drag.x = getX(e.nativeEvent);
|
|
470
|
-
drag.y = getY(e.nativeEvent);
|
|
471
|
-
if (props.draggableDirection === "x") {
|
|
472
|
-
drag.start = drag.x;
|
|
473
|
-
drag.removalDistance = toast2.offsetWidth * (props.draggablePercent / 100);
|
|
474
|
-
} else {
|
|
475
|
-
drag.start = drag.y;
|
|
476
|
-
drag.removalDistance = toast2.offsetHeight * (props.draggablePercent === 80 ? props.draggablePercent * 1.5 : props.draggablePercent / 100);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
function onDragTransitionEnd() {
|
|
481
|
-
if (drag.boundingRect) {
|
|
482
|
-
var _drag$boundingRect = drag.boundingRect, top = _drag$boundingRect.top, bottom = _drag$boundingRect.bottom, left = _drag$boundingRect.left, right = _drag$boundingRect.right;
|
|
483
|
-
if (props.pauseOnHover && drag.x >= left && drag.x <= right && drag.y >= top && drag.y <= bottom) {
|
|
484
|
-
pauseToast();
|
|
485
|
-
} else {
|
|
486
|
-
playToast();
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
function playToast() {
|
|
491
|
-
setIsRunning(true);
|
|
492
|
-
}
|
|
493
|
-
function pauseToast() {
|
|
494
|
-
setIsRunning(false);
|
|
495
|
-
}
|
|
496
|
-
function bindFocusEvents() {
|
|
497
|
-
if (!document.hasFocus()) pauseToast();
|
|
498
|
-
window.addEventListener("focus", playToast);
|
|
499
|
-
window.addEventListener("blur", pauseToast);
|
|
500
|
-
}
|
|
501
|
-
function unbindFocusEvents() {
|
|
502
|
-
window.removeEventListener("focus", playToast);
|
|
503
|
-
window.removeEventListener("blur", pauseToast);
|
|
504
|
-
}
|
|
505
|
-
function bindDragEvents() {
|
|
506
|
-
drag.didMove = false;
|
|
507
|
-
document.addEventListener("mousemove", onDragMove);
|
|
508
|
-
document.addEventListener("mouseup", onDragEnd);
|
|
509
|
-
document.addEventListener("touchmove", onDragMove);
|
|
510
|
-
document.addEventListener("touchend", onDragEnd);
|
|
511
|
-
}
|
|
512
|
-
function unbindDragEvents() {
|
|
513
|
-
document.removeEventListener("mousemove", onDragMove);
|
|
514
|
-
document.removeEventListener("mouseup", onDragEnd);
|
|
515
|
-
document.removeEventListener("touchmove", onDragMove);
|
|
516
|
-
document.removeEventListener("touchend", onDragEnd);
|
|
517
|
-
}
|
|
518
|
-
function onDragMove(e) {
|
|
519
|
-
var toast2 = toastRef.current;
|
|
520
|
-
if (drag.canDrag && toast2) {
|
|
521
|
-
drag.didMove = true;
|
|
522
|
-
if (isRunning) pauseToast();
|
|
523
|
-
drag.x = getX(e);
|
|
524
|
-
drag.y = getY(e);
|
|
525
|
-
if (props.draggableDirection === "x") {
|
|
526
|
-
drag.delta = drag.x - drag.start;
|
|
527
|
-
} else {
|
|
528
|
-
drag.delta = drag.y - drag.start;
|
|
529
|
-
}
|
|
530
|
-
if (drag.start !== drag.x) drag.canCloseOnClick = false;
|
|
531
|
-
toast2.style.transform = "translate" + props.draggableDirection + "(" + drag.delta + "px)";
|
|
532
|
-
toast2.style.opacity = "" + (1 - Math.abs(drag.delta / drag.removalDistance));
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
function onDragEnd() {
|
|
536
|
-
unbindDragEvents();
|
|
537
|
-
var toast2 = toastRef.current;
|
|
538
|
-
if (drag.canDrag && drag.didMove && toast2) {
|
|
539
|
-
drag.canDrag = false;
|
|
540
|
-
if (Math.abs(drag.delta) > drag.removalDistance) {
|
|
541
|
-
setPreventExitTransition(true);
|
|
542
|
-
props.closeToast();
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
toast2.style.transition = "transform 0.2s, opacity 0.2s";
|
|
546
|
-
toast2.style.transform = "translate" + props.draggableDirection + "(0)";
|
|
547
|
-
toast2.style.opacity = "1";
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
var eventHandlers = {
|
|
551
|
-
onMouseDown: onDragStart,
|
|
552
|
-
onTouchStart: onDragStart,
|
|
553
|
-
onMouseUp: onDragTransitionEnd,
|
|
554
|
-
onTouchEnd: onDragTransitionEnd
|
|
555
|
-
};
|
|
556
|
-
if (autoClose && pauseOnHover) {
|
|
557
|
-
eventHandlers.onMouseEnter = pauseToast;
|
|
558
|
-
eventHandlers.onMouseLeave = playToast;
|
|
559
|
-
}
|
|
560
|
-
if (closeOnClick) {
|
|
561
|
-
eventHandlers.onClick = function(e) {
|
|
562
|
-
onClick && onClick(e);
|
|
563
|
-
drag.canCloseOnClick && closeToast();
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
return {
|
|
567
|
-
playToast,
|
|
568
|
-
pauseToast,
|
|
569
|
-
isRunning,
|
|
570
|
-
preventExitTransition,
|
|
571
|
-
toastRef,
|
|
572
|
-
eventHandlers
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
function CloseButton(_ref) {
|
|
576
|
-
var closeToast = _ref.closeToast, theme = _ref.theme, _ref$ariaLabel = _ref.ariaLabel, ariaLabel = _ref$ariaLabel === void 0 ? "close" : _ref$ariaLabel;
|
|
577
|
-
return createElement("button", {
|
|
578
|
-
className: "Toastify__close-button Toastify__close-button--" + theme,
|
|
579
|
-
type: "button",
|
|
580
|
-
onClick: function onClick(e) {
|
|
581
|
-
e.stopPropagation();
|
|
582
|
-
closeToast(e);
|
|
583
|
-
},
|
|
584
|
-
"aria-label": ariaLabel
|
|
585
|
-
}, createElement("svg", {
|
|
586
|
-
"aria-hidden": "true",
|
|
587
|
-
viewBox: "0 0 14 16"
|
|
588
|
-
}, createElement("path", {
|
|
589
|
-
fillRule: "evenodd",
|
|
590
|
-
d: "M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"
|
|
591
|
-
})));
|
|
592
|
-
}
|
|
593
|
-
function ProgressBar(_ref) {
|
|
594
|
-
var _cx, _animationEvent;
|
|
595
|
-
var delay = _ref.delay, isRunning = _ref.isRunning, closeToast = _ref.closeToast, type = _ref.type, hide = _ref.hide, className = _ref.className, userStyle = _ref.style, controlledProgress = _ref.controlledProgress, progress = _ref.progress, rtl = _ref.rtl, isIn = _ref.isIn, theme = _ref.theme;
|
|
596
|
-
var style = _extends({}, userStyle, {
|
|
597
|
-
animationDuration: delay + "ms",
|
|
598
|
-
animationPlayState: isRunning ? "running" : "paused",
|
|
599
|
-
opacity: hide ? 0 : 1
|
|
600
|
-
});
|
|
601
|
-
if (controlledProgress) style.transform = "scaleX(" + progress + ")";
|
|
602
|
-
var defaultClassName = clsx("Toastify__progress-bar", controlledProgress ? "Toastify__progress-bar--controlled" : "Toastify__progress-bar--animated", "Toastify__progress-bar-theme--" + theme, "Toastify__progress-bar--" + type, (_cx = {}, _cx["Toastify__progress-bar--rtl"] = rtl, _cx));
|
|
603
|
-
var classNames = isFn(className) ? className({
|
|
604
|
-
rtl,
|
|
605
|
-
type,
|
|
606
|
-
defaultClassName
|
|
607
|
-
}) : clsx(defaultClassName, className);
|
|
608
|
-
var animationEvent = (_animationEvent = {}, _animationEvent[controlledProgress && progress >= 1 ? "onTransitionEnd" : "onAnimationEnd"] = controlledProgress && progress < 1 ? null : function() {
|
|
609
|
-
isIn && closeToast();
|
|
610
|
-
}, _animationEvent);
|
|
611
|
-
return createElement("div", Object.assign({
|
|
612
|
-
role: "progressbar",
|
|
613
|
-
"aria-hidden": hide ? "true" : "false",
|
|
614
|
-
"aria-label": "notification timer",
|
|
615
|
-
className: classNames,
|
|
616
|
-
style
|
|
617
|
-
}, animationEvent));
|
|
618
|
-
}
|
|
619
|
-
ProgressBar.defaultProps = {
|
|
620
|
-
type: TYPE.DEFAULT,
|
|
621
|
-
hide: false
|
|
622
|
-
};
|
|
623
|
-
var _excluded$1 = ["theme", "type"];
|
|
624
|
-
var Svg = function Svg2(_ref) {
|
|
625
|
-
var theme = _ref.theme, type = _ref.type, rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
626
|
-
return createElement("svg", Object.assign({
|
|
627
|
-
viewBox: "0 0 24 24",
|
|
628
|
-
width: "100%",
|
|
629
|
-
height: "100%",
|
|
630
|
-
fill: theme === "colored" ? "currentColor" : "var(--toastify-icon-color-" + type + ")"
|
|
631
|
-
}, rest));
|
|
632
|
-
};
|
|
633
|
-
function Warning(props) {
|
|
634
|
-
return createElement(Svg, Object.assign({}, props), createElement("path", {
|
|
635
|
-
d: "M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"
|
|
636
|
-
}));
|
|
637
|
-
}
|
|
638
|
-
function Info(props) {
|
|
639
|
-
return createElement(Svg, Object.assign({}, props), createElement("path", {
|
|
640
|
-
d: "M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"
|
|
641
|
-
}));
|
|
642
|
-
}
|
|
643
|
-
function Success(props) {
|
|
644
|
-
return createElement(Svg, Object.assign({}, props), createElement("path", {
|
|
645
|
-
d: "M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"
|
|
646
|
-
}));
|
|
647
|
-
}
|
|
648
|
-
function Error(props) {
|
|
649
|
-
return createElement(Svg, Object.assign({}, props), createElement("path", {
|
|
650
|
-
d: "M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"
|
|
651
|
-
}));
|
|
652
|
-
}
|
|
653
|
-
function Spinner() {
|
|
654
|
-
return createElement("div", {
|
|
655
|
-
className: "Toastify__spinner"
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
var Icons = {
|
|
659
|
-
info: Info,
|
|
660
|
-
warning: Warning,
|
|
661
|
-
success: Success,
|
|
662
|
-
error: Error,
|
|
663
|
-
spinner: Spinner
|
|
664
|
-
};
|
|
665
|
-
var Toast = function Toast2(props) {
|
|
666
|
-
var _cx, _cx2;
|
|
667
|
-
var _useToast = useToast(props), isRunning = _useToast.isRunning, preventExitTransition = _useToast.preventExitTransition, toastRef = _useToast.toastRef, eventHandlers = _useToast.eventHandlers;
|
|
668
|
-
var closeButton = props.closeButton, children = props.children, autoClose = props.autoClose, onClick = props.onClick, type = props.type, hideProgressBar = props.hideProgressBar, closeToast = props.closeToast, Transition = props.transition, position = props.position, className = props.className, style = props.style, bodyClassName = props.bodyClassName, bodyStyle = props.bodyStyle, progressClassName = props.progressClassName, progressStyle = props.progressStyle, updateId = props.updateId, role = props.role, progress = props.progress, rtl = props.rtl, toastId = props.toastId, deleteToast = props.deleteToast, isIn = props.isIn, isLoading = props.isLoading, icon = props.icon, theme = props.theme;
|
|
669
|
-
var defaultClassName = clsx("Toastify__toast", "Toastify__toast-theme--" + theme, "Toastify__toast--" + type, (_cx = {}, _cx["Toastify__toast--rtl"] = rtl, _cx));
|
|
670
|
-
var cssClasses = isFn(className) ? className({
|
|
671
|
-
rtl,
|
|
672
|
-
position,
|
|
673
|
-
type,
|
|
674
|
-
defaultClassName
|
|
675
|
-
}) : clsx(defaultClassName, className);
|
|
676
|
-
var isProgressControlled = !!progress;
|
|
677
|
-
var maybeIcon = Icons[type];
|
|
678
|
-
var iconProps = {
|
|
679
|
-
theme,
|
|
680
|
-
type
|
|
681
|
-
};
|
|
682
|
-
var Icon = maybeIcon && maybeIcon(iconProps);
|
|
683
|
-
if (icon === false) {
|
|
684
|
-
Icon = void 0;
|
|
685
|
-
} else if (isFn(icon)) {
|
|
686
|
-
Icon = icon(iconProps);
|
|
687
|
-
} else if (isValidElement(icon)) {
|
|
688
|
-
Icon = cloneElement(icon, iconProps);
|
|
689
|
-
} else if (isStr(icon)) {
|
|
690
|
-
Icon = icon;
|
|
691
|
-
} else if (isLoading) {
|
|
692
|
-
Icon = Icons.spinner();
|
|
693
|
-
}
|
|
694
|
-
function renderCloseButton(closeButton2) {
|
|
695
|
-
if (!closeButton2) return;
|
|
696
|
-
var props2 = {
|
|
697
|
-
closeToast,
|
|
698
|
-
type,
|
|
699
|
-
theme
|
|
700
|
-
};
|
|
701
|
-
if (isFn(closeButton2)) return closeButton2(props2);
|
|
702
|
-
if (isValidElement(closeButton2)) return cloneElement(closeButton2, props2);
|
|
703
|
-
}
|
|
704
|
-
return createElement(Transition, {
|
|
705
|
-
isIn,
|
|
706
|
-
done: deleteToast,
|
|
707
|
-
position,
|
|
708
|
-
preventExitTransition,
|
|
709
|
-
nodeRef: toastRef
|
|
710
|
-
}, createElement("div", Object.assign({
|
|
711
|
-
id: toastId,
|
|
712
|
-
onClick,
|
|
713
|
-
className: cssClasses
|
|
714
|
-
}, eventHandlers, {
|
|
715
|
-
style,
|
|
716
|
-
ref: toastRef
|
|
717
|
-
}), createElement("div", Object.assign({}, isIn && {
|
|
718
|
-
role
|
|
719
|
-
}, {
|
|
720
|
-
className: isFn(bodyClassName) ? bodyClassName({
|
|
721
|
-
type
|
|
722
|
-
}) : clsx("Toastify__toast-body", bodyClassName),
|
|
723
|
-
style: bodyStyle
|
|
724
|
-
}), Icon && createElement("div", {
|
|
725
|
-
className: clsx("Toastify__toast-icon", (_cx2 = {}, _cx2["Toastify--animate-icon Toastify__zoom-enter"] = !isLoading, _cx2))
|
|
726
|
-
}, Icon), createElement("div", null, children)), renderCloseButton(closeButton), (autoClose || isProgressControlled) && createElement(ProgressBar, Object.assign({}, updateId && !isProgressControlled ? {
|
|
727
|
-
key: "pb-" + updateId
|
|
728
|
-
} : {}, {
|
|
729
|
-
rtl,
|
|
730
|
-
theme,
|
|
731
|
-
delay: autoClose,
|
|
732
|
-
isRunning,
|
|
733
|
-
isIn,
|
|
734
|
-
closeToast,
|
|
735
|
-
hide: hideProgressBar,
|
|
736
|
-
type,
|
|
737
|
-
style: progressStyle,
|
|
738
|
-
className: progressClassName,
|
|
739
|
-
controlledProgress: isProgressControlled,
|
|
740
|
-
progress
|
|
741
|
-
}))));
|
|
742
|
-
};
|
|
743
|
-
var Bounce = /* @__PURE__ */ cssTransition({
|
|
744
|
-
enter: "Toastify--animate Toastify__bounce-enter",
|
|
745
|
-
exit: "Toastify--animate Toastify__bounce-exit",
|
|
746
|
-
appendPosition: true
|
|
747
|
-
});
|
|
748
|
-
var ToastContainer = function ToastContainer2(props) {
|
|
749
|
-
var _useToastContainer = useToastContainer(props), getToastToRender = _useToastContainer.getToastToRender, containerRef = _useToastContainer.containerRef, isToastActive = _useToastContainer.isToastActive;
|
|
750
|
-
var className = props.className, style = props.style, rtl = props.rtl, containerId = props.containerId;
|
|
751
|
-
function getClassName(position) {
|
|
752
|
-
var _cx;
|
|
753
|
-
var defaultClassName = clsx("Toastify__toast-container", "Toastify__toast-container--" + position, (_cx = {}, _cx["Toastify__toast-container--rtl"] = rtl, _cx));
|
|
754
|
-
return isFn(className) ? className({
|
|
755
|
-
position,
|
|
756
|
-
rtl,
|
|
757
|
-
defaultClassName
|
|
758
|
-
}) : clsx(defaultClassName, parseClassName(className));
|
|
759
|
-
}
|
|
760
|
-
return createElement("div", {
|
|
761
|
-
ref: containerRef,
|
|
762
|
-
className: "Toastify",
|
|
763
|
-
id: containerId
|
|
764
|
-
}, getToastToRender(function(position, toastList) {
|
|
765
|
-
var containerStyle = !toastList.length ? _extends({}, style, {
|
|
766
|
-
pointerEvents: "none"
|
|
767
|
-
}) : _extends({}, style);
|
|
768
|
-
return createElement("div", {
|
|
769
|
-
className: getClassName(position),
|
|
770
|
-
style: containerStyle,
|
|
771
|
-
key: "container-" + position
|
|
772
|
-
}, toastList.map(function(_ref) {
|
|
773
|
-
var content = _ref.content, toastProps = _ref.props;
|
|
774
|
-
return createElement(Toast, Object.assign({}, toastProps, {
|
|
775
|
-
isIn: isToastActive(toastProps.toastId),
|
|
776
|
-
key: "toast-" + toastProps.key,
|
|
777
|
-
closeButton: toastProps.closeButton === true ? CloseButton : toastProps.closeButton
|
|
778
|
-
}), content);
|
|
779
|
-
}));
|
|
780
|
-
}));
|
|
781
|
-
};
|
|
782
|
-
ToastContainer.defaultProps = {
|
|
783
|
-
position: POSITION.TOP_RIGHT,
|
|
784
|
-
transition: Bounce,
|
|
785
|
-
rtl: false,
|
|
786
|
-
autoClose: 5e3,
|
|
787
|
-
hideProgressBar: false,
|
|
788
|
-
closeButton: CloseButton,
|
|
789
|
-
pauseOnHover: true,
|
|
790
|
-
pauseOnFocusLoss: true,
|
|
791
|
-
closeOnClick: true,
|
|
792
|
-
newestOnTop: false,
|
|
793
|
-
draggable: true,
|
|
794
|
-
draggablePercent: 80,
|
|
795
|
-
draggableDirection: "x",
|
|
796
|
-
role: "alert",
|
|
797
|
-
theme: "light"
|
|
798
|
-
};
|
|
799
|
-
var containers = /* @__PURE__ */ new Map();
|
|
800
|
-
var latestInstance;
|
|
801
|
-
var containerDomNode;
|
|
802
|
-
var containerConfig;
|
|
803
|
-
var queue = [];
|
|
804
|
-
var lazy = false;
|
|
805
|
-
function getToast(toastId, _ref) {
|
|
806
|
-
var containerId = _ref.containerId;
|
|
807
|
-
var container = containers.get(containerId || latestInstance);
|
|
808
|
-
if (!container) return null;
|
|
809
|
-
return container.getToast(toastId);
|
|
810
|
-
}
|
|
811
|
-
function generateToastId() {
|
|
812
|
-
return Math.random().toString(36).substring(2, 9);
|
|
813
|
-
}
|
|
814
|
-
function getToastId(options) {
|
|
815
|
-
if (options && (isStr(options.toastId) || isNum(options.toastId))) {
|
|
816
|
-
return options.toastId;
|
|
817
|
-
}
|
|
818
|
-
return generateToastId();
|
|
819
|
-
}
|
|
820
|
-
function dispatchToast(content, options) {
|
|
821
|
-
if (containers.size > 0) {
|
|
822
|
-
eventManager.emit(
|
|
823
|
-
0,
|
|
824
|
-
content,
|
|
825
|
-
options
|
|
826
|
-
);
|
|
827
|
-
} else {
|
|
828
|
-
queue.push({
|
|
829
|
-
content,
|
|
830
|
-
options
|
|
831
|
-
});
|
|
832
|
-
if (lazy && canUseDom) {
|
|
833
|
-
lazy = false;
|
|
834
|
-
containerDomNode = document.createElement("div");
|
|
835
|
-
document.body.appendChild(containerDomNode);
|
|
836
|
-
render(createElement(ToastContainer, Object.assign({}, containerConfig)), containerDomNode);
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
return options.toastId;
|
|
840
|
-
}
|
|
841
|
-
function mergeOptions(type, options) {
|
|
842
|
-
return _extends({}, options, {
|
|
843
|
-
type: options && options.type || type,
|
|
844
|
-
toastId: getToastId(options)
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
function createToastByType(type) {
|
|
848
|
-
return function(content, options) {
|
|
849
|
-
return dispatchToast(content, mergeOptions(type, options));
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
function toast(content, options) {
|
|
853
|
-
return dispatchToast(content, mergeOptions(TYPE.DEFAULT, options));
|
|
854
|
-
}
|
|
855
|
-
toast.loading = function(content, options) {
|
|
856
|
-
return dispatchToast(content, mergeOptions(TYPE.DEFAULT, _extends({
|
|
857
|
-
isLoading: true,
|
|
858
|
-
autoClose: false,
|
|
859
|
-
closeOnClick: false,
|
|
860
|
-
closeButton: false,
|
|
861
|
-
draggable: false
|
|
862
|
-
}, options)));
|
|
863
|
-
};
|
|
864
|
-
function handlePromise(promise, _ref2, options) {
|
|
865
|
-
var pending = _ref2.pending, error = _ref2.error, success = _ref2.success;
|
|
866
|
-
var id;
|
|
867
|
-
if (pending) {
|
|
868
|
-
id = isStr(pending) ? toast.loading(pending, options) : toast.loading(pending.render, _extends({}, options, pending));
|
|
869
|
-
}
|
|
870
|
-
var resetParams = {
|
|
871
|
-
isLoading: null,
|
|
872
|
-
autoClose: null,
|
|
873
|
-
closeOnClick: null,
|
|
874
|
-
closeButton: null,
|
|
875
|
-
draggable: null
|
|
876
|
-
};
|
|
877
|
-
var resolver = function resolver2(type, input, result) {
|
|
878
|
-
if (input == null) {
|
|
879
|
-
toast.dismiss(id);
|
|
880
|
-
return;
|
|
881
|
-
}
|
|
882
|
-
var baseParams = _extends({
|
|
883
|
-
type
|
|
884
|
-
}, resetParams, options, {
|
|
885
|
-
data: result
|
|
886
|
-
});
|
|
887
|
-
var params = isStr(input) ? {
|
|
888
|
-
render: input
|
|
889
|
-
} : input;
|
|
890
|
-
if (id) {
|
|
891
|
-
toast.update(id, _extends({}, baseParams, params));
|
|
892
|
-
} else {
|
|
893
|
-
toast(params.render, _extends({}, baseParams, params));
|
|
894
|
-
}
|
|
895
|
-
return result;
|
|
896
|
-
};
|
|
897
|
-
var p = isFn(promise) ? promise() : promise;
|
|
898
|
-
p.then(function(result) {
|
|
899
|
-
return resolver("success", success, result);
|
|
900
|
-
})["catch"](function(err) {
|
|
901
|
-
return resolver("error", error, err);
|
|
902
|
-
});
|
|
903
|
-
return p;
|
|
904
|
-
}
|
|
905
|
-
toast.promise = handlePromise;
|
|
906
|
-
toast.success = /* @__PURE__ */ createToastByType(TYPE.SUCCESS);
|
|
907
|
-
toast.info = /* @__PURE__ */ createToastByType(TYPE.INFO);
|
|
908
|
-
toast.error = /* @__PURE__ */ createToastByType(TYPE.ERROR);
|
|
909
|
-
toast.warning = /* @__PURE__ */ createToastByType(TYPE.WARNING);
|
|
910
|
-
toast.warn = toast.warning;
|
|
911
|
-
toast.dark = function(content, options) {
|
|
912
|
-
return dispatchToast(content, mergeOptions(TYPE.DEFAULT, _extends({
|
|
913
|
-
theme: "dark"
|
|
914
|
-
}, options)));
|
|
915
|
-
};
|
|
916
|
-
toast.dismiss = function(id) {
|
|
917
|
-
return eventManager.emit(
|
|
918
|
-
1,
|
|
919
|
-
id
|
|
920
|
-
);
|
|
921
|
-
};
|
|
922
|
-
toast.clearWaitingQueue = function(params) {
|
|
923
|
-
if (params === void 0) {
|
|
924
|
-
params = {};
|
|
925
|
-
}
|
|
926
|
-
return eventManager.emit(
|
|
927
|
-
5,
|
|
928
|
-
params
|
|
929
|
-
);
|
|
930
|
-
};
|
|
931
|
-
toast.isActive = function(id) {
|
|
932
|
-
var isToastActive = false;
|
|
933
|
-
containers.forEach(function(container) {
|
|
934
|
-
if (container.isToastActive && container.isToastActive(id)) {
|
|
935
|
-
isToastActive = true;
|
|
936
|
-
}
|
|
937
|
-
});
|
|
938
|
-
return isToastActive;
|
|
939
|
-
};
|
|
940
|
-
toast.update = function(toastId, options) {
|
|
941
|
-
if (options === void 0) {
|
|
942
|
-
options = {};
|
|
943
|
-
}
|
|
944
|
-
setTimeout(function() {
|
|
945
|
-
var toast2 = getToast(toastId, options);
|
|
946
|
-
if (toast2) {
|
|
947
|
-
var oldOptions = toast2.props, oldContent = toast2.content;
|
|
948
|
-
var nextOptions = _extends({}, oldOptions, options, {
|
|
949
|
-
toastId: options.toastId || toastId,
|
|
950
|
-
updateId: generateToastId()
|
|
951
|
-
});
|
|
952
|
-
if (nextOptions.toastId !== toastId) nextOptions.staleId = toastId;
|
|
953
|
-
var content = nextOptions.render || oldContent;
|
|
954
|
-
delete nextOptions.render;
|
|
955
|
-
dispatchToast(content, nextOptions);
|
|
956
|
-
}
|
|
957
|
-
}, 0);
|
|
958
|
-
};
|
|
959
|
-
toast.done = function(id) {
|
|
960
|
-
toast.update(id, {
|
|
961
|
-
progress: 1
|
|
962
|
-
});
|
|
963
|
-
};
|
|
964
|
-
toast.onChange = function(callback) {
|
|
965
|
-
if (isFn(callback)) {
|
|
966
|
-
eventManager.on(
|
|
967
|
-
4,
|
|
968
|
-
callback
|
|
969
|
-
);
|
|
970
|
-
}
|
|
971
|
-
return function() {
|
|
972
|
-
isFn(callback) && eventManager.off(
|
|
973
|
-
4,
|
|
974
|
-
callback
|
|
975
|
-
);
|
|
976
|
-
};
|
|
977
|
-
};
|
|
978
|
-
toast.configure = function(config) {
|
|
979
|
-
if (config === void 0) {
|
|
980
|
-
config = {};
|
|
981
|
-
}
|
|
982
|
-
lazy = true;
|
|
983
|
-
containerConfig = config;
|
|
984
|
-
};
|
|
985
|
-
toast.POSITION = POSITION;
|
|
986
|
-
toast.TYPE = TYPE;
|
|
987
|
-
eventManager.on(
|
|
988
|
-
2,
|
|
989
|
-
function(containerInstance) {
|
|
990
|
-
latestInstance = containerInstance.containerId || containerInstance;
|
|
991
|
-
containers.set(latestInstance, containerInstance);
|
|
992
|
-
queue.forEach(function(item) {
|
|
993
|
-
eventManager.emit(
|
|
994
|
-
0,
|
|
995
|
-
item.content,
|
|
996
|
-
item.options
|
|
997
|
-
);
|
|
998
|
-
});
|
|
999
|
-
queue = [];
|
|
1000
|
-
}
|
|
1001
|
-
).on(
|
|
1002
|
-
3,
|
|
1003
|
-
function(containerInstance) {
|
|
1004
|
-
containers["delete"](containerInstance.containerId || containerInstance);
|
|
1005
|
-
if (containers.size === 0) {
|
|
1006
|
-
eventManager.off(
|
|
1007
|
-
0
|
|
1008
|
-
/* Show */
|
|
1009
|
-
).off(
|
|
1010
|
-
1
|
|
1011
|
-
/* Clear */
|
|
1012
|
-
).off(
|
|
1013
|
-
5
|
|
1014
|
-
/* ClearWaitingQueue */
|
|
1015
|
-
);
|
|
1016
|
-
}
|
|
1017
|
-
if (canUseDom && containerDomNode) {
|
|
1018
|
-
document.body.removeChild(containerDomNode);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
);
|
|
4
|
+
import { T as Toast, t as toDataTestId } from "../../Notification-BT4CZ69U.js";
|
|
1022
5
|
function notify(type, title, message, toastId, dataTestPrefix) {
|
|
1023
6
|
let icon;
|
|
1024
7
|
switch (type) {
|
|
1025
8
|
case "info":
|
|
1026
9
|
icon = /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: "info", className: "text-purple-600 text-2xl mr-4 mt-0.5" });
|
|
1027
10
|
toast.info(
|
|
1028
|
-
/* @__PURE__ */ jsx(Toast
|
|
11
|
+
/* @__PURE__ */ jsx(Toast, { title, msg: message, icon, dataTestPrefix: toDataTestId("info", dataTestPrefix) }),
|
|
1029
12
|
{ toastId }
|
|
1030
13
|
);
|
|
1031
14
|
break;
|
|
1032
15
|
case "success":
|
|
1033
16
|
icon = /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: "check", className: "text-blue-600 text-2xl mr-4 mt-0.5" });
|
|
1034
17
|
toast.success(
|
|
1035
|
-
/* @__PURE__ */ jsx(Toast
|
|
18
|
+
/* @__PURE__ */ jsx(Toast, { title, msg: message, icon, dataTestPrefix: toDataTestId("success", dataTestPrefix) }),
|
|
1036
19
|
{
|
|
1037
20
|
toastId
|
|
1038
21
|
}
|
|
@@ -1041,14 +24,14 @@ function notify(type, title, message, toastId, dataTestPrefix) {
|
|
|
1041
24
|
case "error":
|
|
1042
25
|
icon = /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: "close", className: "text-red-600 text-2xl mr-4 mt-0.5" });
|
|
1043
26
|
toast.error(
|
|
1044
|
-
/* @__PURE__ */ jsx(Toast
|
|
27
|
+
/* @__PURE__ */ jsx(Toast, { title, msg: message, icon, dataTestPrefix: toDataTestId("error", dataTestPrefix) }),
|
|
1045
28
|
{
|
|
1046
29
|
toastId
|
|
1047
30
|
}
|
|
1048
31
|
);
|
|
1049
32
|
break;
|
|
1050
33
|
default:
|
|
1051
|
-
toast(/* @__PURE__ */ jsx(Toast
|
|
34
|
+
toast(/* @__PURE__ */ jsx(Toast, { title, msg: message, icon, dataTestPrefix }), { toastId });
|
|
1052
35
|
break;
|
|
1053
36
|
}
|
|
1054
37
|
}
|