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 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: "1em",
10
- height: "1em",
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
- fillRule: "evenodd",
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
- d: "M16.707 2.293A.996.996 0 0 0 16 2H8a.996.996 0 0 0-.707.293l-5 5A.996.996 0 0 0 2 8v8c0 .266.105.52.293.707l5 5A.996.996 0 0 0 8 22h8c.266 0 .52-.105.707-.293l5-5A.996.996 0 0 0 22 16V8a.996.996 0 0 0-.293-.707l-5-5zM13 17h-2v-2h2v2zm0-4h-2V7h2v6z",
36
- fill: "currentColor"
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 2c5.523 0 10 4.477 10 10a10 10 0 0 1-19.995.324L2 12l.004-.28C2.152 6.327 6.57 2 12 2m0 9h-1l-.117.007a1 1 0 0 0 0 1.986L11 13v3l.007.117a1 1 0 0 0 .876.876L12 17h1l.117-.007a1 1 0 0 0 .876-.876L14 16l-.007-.117a1 1 0 0 0-.764-.857l-.112-.02L13 15v-3l-.007-.117a1 1 0 0 0-.876-.876zm.01-3l-.127.007a1 1 0 0 0 0 1.986L12 10l.127-.007a1 1 0 0 0 0-1.986z"
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: "m21.171 15.398l-5.912-9.854C14.483 4.251 13.296 3.511 12 3.511s-2.483.74-3.259 2.031l-5.912 9.856c-.786 1.309-.872 2.705-.235 3.83C3.23 20.354 4.472 21 6 21h12c1.528 0 2.77-.646 3.406-1.771s.551-2.521-.235-3.831M12 17.549c-.854 0-1.55-.695-1.55-1.549c0-.855.695-1.551 1.55-1.551s1.55.696 1.55 1.551c0 .854-.696 1.549-1.55 1.549m1.633-7.424c-.011.031-1.401 3.468-1.401 3.468c-.038.094-.13.156-.231.156s-.193-.062-.231-.156l-1.391-3.438a1.8 1.8 0 0 1-.129-.655c0-.965.785-1.75 1.75-1.75a1.752 1.752 0 0 1 1.633 2.375"
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", {
@@ -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: mySound,
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.6 : _ref2$volume,
45
- _ref2$enabled = _ref2.enabled,
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
- if (toasts.length > 0) {
121
- setToasts([]);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "d9-toast",
3
- "version": "1.4.25",
3
+ "version": "1.4.27",
4
4
  "description": "Customizable toast notifications for React",
5
5
  "homepage": "https://codesandbox.io/embed/cqkyzm?view=preview",
6
6
  "repository": {
Binary file