d9-toast 1.4.29 → 1.4.31

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.
@@ -20,14 +20,20 @@ import React, { createContext, useCallback, useContext, useRef, useState } from
20
20
  import Toast from "./Toast";
21
21
  import "./toast.css";
22
22
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
- export var DEFAULT_TOAST_SOUND = "https://cdn.jsdelivr.net/gh/psathul073/d9-toast-assets@main/toast.m4a";
23
+ var sounds = {
24
+ "default": "https://cdn.jsdelivr.net/gh/psathul073/d9-toast-assets@main/default.mp3",
25
+ success: "https://cdn.jsdelivr.net/gh/psathul073/d9-toast-assets@main/success.mp3",
26
+ warning: "https://cdn.jsdelivr.net/gh/psathul073/d9-toast-assets@main/warning.mp3",
27
+ error: "https://cdn.jsdelivr.net/gh/psathul073/d9-toast-assets@main/errors.mp3",
28
+ info: "https://cdn.jsdelivr.net/gh/psathul073/d9-toast-assets@main/info.mp3"
29
+ };
24
30
  var ToastContext = /*#__PURE__*/createContext();
25
31
  export var useToast = function useToast() {
26
32
  return useContext(ToastContext);
27
33
  };
28
34
  var audioSettings = {
29
- audioFile: DEFAULT_TOAST_SOUND,
30
- volume: 0.8,
35
+ audioFile: sounds["default"],
36
+ volume: 0.6,
31
37
  enabled: true,
32
38
  cooldown: 500
33
39
  };
@@ -43,7 +49,7 @@ export var ToastProvider = function ToastProvider(_ref) {
43
49
  var playAudio = useCallback(function (_ref2) {
44
50
  var audioFile = _ref2.audioFile,
45
51
  _ref2$volume = _ref2.volume,
46
- volume = _ref2$volume === void 0 ? 0.8 : _ref2$volume;
52
+ volume = _ref2$volume === void 0 ? 0.6 : _ref2$volume;
47
53
  if (!audioFile || typeof window === "undefined") return;
48
54
  try {
49
55
  var audio = new Audio(audioFile);
@@ -128,6 +134,7 @@ export var ToastProvider = function ToastProvider(_ref) {
128
134
  }, {});
129
135
  return /*#__PURE__*/_jsxs(ToastContext.Provider, {
130
136
  value: {
137
+ sounds: sounds,
131
138
  showToast: showToast,
132
139
  removeToast: removeToast,
133
140
  removeToastAll: removeToastAll
@@ -23,6 +23,15 @@ declare module "d9-toast" {
23
23
  | "center-top"
24
24
  | "center-bottom";
25
25
 
26
+ /** Available toast sounds */
27
+ export interface ToastSounds {
28
+ default: string;
29
+ success: string;
30
+ warning: string;
31
+ error: string;
32
+ info: string;
33
+ }
34
+
26
35
  /** Single button/action displayed inside a toast */
27
36
  export interface ToastAction {
28
37
  /** Text label for the action button */
@@ -84,6 +93,8 @@ declare module "d9-toast" {
84
93
 
85
94
  /** Context value shape */
86
95
  export interface ToastContextValue {
96
+ /** Default toast sounds */
97
+ sounds: ToastSounds,
87
98
  /** Show a toast with given options and return toast id */
88
99
  showToast: (toast: ToastOptions) => number;
89
100
  /** Remove a toast by ID */
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
- import "./toast.css"; // default styles
2
- export { ToastProvider, useToast } from "./ToastContext";
1
+ export { ToastProvider, useToast } from "./ToastContext.js";
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "d9-toast",
3
- "version": "1.4.29",
3
+ "version": "1.4.31",
4
4
  "description": "Customizable toast notifications for React",
5
5
  "homepage": "https://codesandbox.io/embed/cqkyzm?view=preview",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/psathul073/d9-toast.git"
8
+ "url": "git+https://github.com/psathul073/d9-toast.git"
9
9
  },
10
10
  "bugs": {
11
11
  "url": "https://github.com/psathul073/d9-toast/issues"