d9-toast 1.4.25 → 1.4.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Icons.js +7 -9
- package/dist/ToastContext.js +7 -14
- package/package.json +1 -1
- package/dist/assets/sounds/toast.m4a +0 -0
package/dist/Icons.js
CHANGED
|
@@ -6,18 +6,16 @@ var Icons = function Icons(_ref) {
|
|
|
6
6
|
success: /*#__PURE__*/_jsx("svg", {
|
|
7
7
|
xmlns: "http://www.w3.org/2000/svg",
|
|
8
8
|
viewBox: "0 0 24 24",
|
|
9
|
-
width: "
|
|
10
|
-
height: "
|
|
9
|
+
width: "1.5em",
|
|
10
|
+
height: "1.5em",
|
|
11
11
|
className: className,
|
|
12
12
|
style: {
|
|
13
13
|
backgroundColor: "transparent",
|
|
14
|
-
fontSize: "22px",
|
|
15
14
|
flexShrink: 0
|
|
16
15
|
},
|
|
17
16
|
children: /*#__PURE__*/_jsx("path", {
|
|
18
17
|
fill: "currentColor",
|
|
19
|
-
|
|
20
|
-
d: "M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10s-4.477 10-10 10m-1.177-7.86l-2.765-2.767L7 12.431l3.119 3.121a1 1 0 0 0 1.414 0l5.952-5.95l-1.062-1.062z"
|
|
18
|
+
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2M9.29 16.29L5.7 12.7a.996.996 0 1 1 1.41-1.41L10 14.17l6.88-6.88a.996.996 0 1 1 1.41 1.41l-7.59 7.59a.996.996 0 0 1-1.41 0"
|
|
21
19
|
})
|
|
22
20
|
}),
|
|
23
21
|
error: /*#__PURE__*/_jsx("svg", {
|
|
@@ -32,8 +30,8 @@ var Icons = function Icons(_ref) {
|
|
|
32
30
|
flexShrink: 0
|
|
33
31
|
},
|
|
34
32
|
children: /*#__PURE__*/_jsx("path", {
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
fill: "currentColor",
|
|
34
|
+
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2m0 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1m1 4h-2v-2h2z"
|
|
37
35
|
})
|
|
38
36
|
}),
|
|
39
37
|
info: /*#__PURE__*/_jsx("svg", {
|
|
@@ -49,7 +47,7 @@ var Icons = function Icons(_ref) {
|
|
|
49
47
|
},
|
|
50
48
|
children: /*#__PURE__*/_jsx("path", {
|
|
51
49
|
fill: "currentColor",
|
|
52
|
-
d: "M12
|
|
50
|
+
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2m0 15c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1m1-8h-2V7h2z"
|
|
53
51
|
})
|
|
54
52
|
}),
|
|
55
53
|
warning: /*#__PURE__*/_jsx("svg", {
|
|
@@ -65,7 +63,7 @@ var Icons = function Icons(_ref) {
|
|
|
65
63
|
},
|
|
66
64
|
children: /*#__PURE__*/_jsx("path", {
|
|
67
65
|
fill: "currentColor",
|
|
68
|
-
d: "
|
|
66
|
+
d: "M4.47 21h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0L2.74 18c-.77 1.33.19 3 1.73 3M12 14c-.55 0-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1m1 4h-2v-2h2z"
|
|
69
67
|
})
|
|
70
68
|
}),
|
|
71
69
|
loading: /*#__PURE__*/_jsx("svg", {
|
package/dist/ToastContext.js
CHANGED
|
@@ -16,15 +16,15 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
16
16
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
17
17
|
import React, { createContext, useCallback, useContext, useRef, useState } from "react";
|
|
18
18
|
import Toast from "./Toast";
|
|
19
|
-
import mySound from "./assets/sounds/toast.m4a";
|
|
20
19
|
import "./toast.css";
|
|
21
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
export var DEFAULT_TOAST_SOUND = "https://cdn.jsdelivr.net/gh/psathul073/d9-toast-assets@main/toast.m4a";
|
|
22
22
|
var ToastContext = /*#__PURE__*/createContext();
|
|
23
23
|
export var useToast = function useToast() {
|
|
24
24
|
return useContext(ToastContext);
|
|
25
25
|
};
|
|
26
26
|
var audioSettings = {
|
|
27
|
-
audioFile:
|
|
27
|
+
audioFile: DEFAULT_TOAST_SOUND,
|
|
28
28
|
volume: 0.8,
|
|
29
29
|
enabled: true,
|
|
30
30
|
cooldown: 500
|
|
@@ -41,10 +41,8 @@ export var ToastProvider = function ToastProvider(_ref) {
|
|
|
41
41
|
var playAudio = useCallback(function (_ref2) {
|
|
42
42
|
var audioFile = _ref2.audioFile,
|
|
43
43
|
_ref2$volume = _ref2.volume,
|
|
44
|
-
volume = _ref2$volume === void 0 ? 0.
|
|
45
|
-
|
|
46
|
-
enabled = _ref2$enabled === void 0 ? true : _ref2$enabled;
|
|
47
|
-
if (!enabled || !audioFile) return;
|
|
44
|
+
volume = _ref2$volume === void 0 ? 0.8 : _ref2$volume;
|
|
45
|
+
if (!audioFile || typeof window === "undefined") return;
|
|
48
46
|
try {
|
|
49
47
|
var audio = new Audio(audioFile);
|
|
50
48
|
audio.volume = volume;
|
|
@@ -56,12 +54,9 @@ export var ToastProvider = function ToastProvider(_ref) {
|
|
|
56
54
|
|
|
57
55
|
// Generate unique ID safely
|
|
58
56
|
var generateId = function generateId() {
|
|
59
|
-
return Date.now() + Math.random();
|
|
57
|
+
return typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : Date.now().toString() + Math.random().toString(36);
|
|
60
58
|
};
|
|
61
59
|
|
|
62
|
-
// Positions.
|
|
63
|
-
// const positions = [
|
|
64
|
-
|
|
65
60
|
// Show toast..
|
|
66
61
|
var showToast = useCallback(function (toast) {
|
|
67
62
|
var _toast$audio$enabled, _toast$audio, _toast$audio$volume, _toast$audio2, _toast$audio$audioFil, _toast$audio3, _toast$audio$cooldown, _toast$audio4;
|
|
@@ -117,10 +112,8 @@ export var ToastProvider = function ToastProvider(_ref) {
|
|
|
117
112
|
|
|
118
113
|
// Remove all toast.
|
|
119
114
|
var removeToastAll = useCallback(function () {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
}, [toasts.length]);
|
|
115
|
+
setToasts([]);
|
|
116
|
+
}, []);
|
|
124
117
|
|
|
125
118
|
// Group toasts by there positions..
|
|
126
119
|
var groupedToasts = toasts.reduce(function (acc, toast) {
|
package/package.json
CHANGED
|
Binary file
|