@fluentui/react-toast 9.2.0 → 9.2.1

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.
Files changed (210) hide show
  1. package/CHANGELOG.json +70 -1
  2. package/CHANGELOG.md +20 -2
  3. package/lib/components/AriaLive/AriaLive.js.map +1 -1
  4. package/lib/components/AriaLive/renderAriaLive.js +7 -2
  5. package/lib/components/AriaLive/renderAriaLive.js.map +1 -1
  6. package/lib/components/AriaLive/useAriaLive.js +6 -4
  7. package/lib/components/AriaLive/useAriaLive.js.map +1 -1
  8. package/lib/components/Timer/Timer.js +1 -1
  9. package/lib/components/Timer/Timer.js.map +1 -1
  10. package/lib/components/Toast/Toast.js.map +1 -1
  11. package/lib/components/Toast/renderToast.js +5 -4
  12. package/lib/components/Toast/renderToast.js.map +1 -1
  13. package/lib/components/Toast/useToast.js.map +1 -1
  14. package/lib/components/Toast/useToastContextValues.js +1 -1
  15. package/lib/components/Toast/useToastContextValues.js.map +1 -1
  16. package/lib/components/ToastBody/ToastBody.js.map +1 -1
  17. package/lib/components/ToastBody/renderToastBody.js +7 -2
  18. package/lib/components/ToastBody/renderToastBody.js.map +1 -1
  19. package/lib/components/ToastBody/useToastBody.js +1 -1
  20. package/lib/components/ToastBody/useToastBody.js.map +1 -1
  21. package/lib/components/ToastContainer/ToastContainer.js.map +1 -1
  22. package/lib/components/ToastContainer/renderToastContainer.js +12 -7
  23. package/lib/components/ToastContainer/renderToastContainer.js.map +1 -1
  24. package/lib/components/ToastContainer/useToastContainer.js +15 -15
  25. package/lib/components/ToastContainer/useToastContainer.js.map +1 -1
  26. package/lib/components/ToastContainer/useToastContainerContextValues.js +1 -1
  27. package/lib/components/ToastContainer/useToastContainerContextValues.js.map +1 -1
  28. package/lib/components/ToastFooter/ToastFooter.js.map +1 -1
  29. package/lib/components/ToastFooter/renderToastFooter.js +2 -2
  30. package/lib/components/ToastFooter/renderToastFooter.js.map +1 -1
  31. package/lib/components/ToastFooter/useToastFooter.js.map +1 -1
  32. package/lib/components/ToastTitle/ToastTitle.js.map +1 -1
  33. package/lib/components/ToastTitle/renderToastTitle.js +8 -2
  34. package/lib/components/ToastTitle/renderToastTitle.js.map +1 -1
  35. package/lib/components/ToastTitle/useToastTitle.js +1 -1
  36. package/lib/components/ToastTitle/useToastTitle.js.map +1 -1
  37. package/lib/components/ToastTitle/useToastTitleStyles.styles.js.map +1 -1
  38. package/lib/components/ToastTrigger/ToastTrigger.js.map +1 -1
  39. package/lib/components/ToastTrigger/useToastTrigger.js +8 -7
  40. package/lib/components/ToastTrigger/useToastTrigger.js.map +1 -1
  41. package/lib/components/Toaster/Toaster.js.map +1 -1
  42. package/lib/components/Toaster/renderToaster.js +18 -7
  43. package/lib/components/Toaster/renderToaster.js.map +1 -1
  44. package/lib/components/Toaster/useToastAnnounce.js.map +1 -1
  45. package/lib/components/Toaster/useToaster.js +6 -6
  46. package/lib/components/Toaster/useToaster.js.map +1 -1
  47. package/lib/components/Toaster/useToasterFocusManagement.js +2 -2
  48. package/lib/components/Toaster/useToasterFocusManagement.js.map +1 -1
  49. package/lib/contexts/toastContainerContext.js.map +1 -1
  50. package/lib/state/useToastController.js +3 -2
  51. package/lib/state/useToastController.js.map +1 -1
  52. package/lib/state/useToaster.js +15 -11
  53. package/lib/state/useToaster.js.map +1 -1
  54. package/lib/state/vanilla/createToaster.js +7 -7
  55. package/lib/state/vanilla/createToaster.js.map +1 -1
  56. package/lib/state/vanilla/dismissAllToasts.js.map +1 -1
  57. package/lib/state/vanilla/dismissToast.js.map +1 -1
  58. package/lib/state/vanilla/dispatchToast.js.map +1 -1
  59. package/lib/state/vanilla/getPositionStyles.js +1 -1
  60. package/lib/state/vanilla/getPositionStyles.js.map +1 -1
  61. package/lib/state/vanilla/pauseToast.js.map +1 -1
  62. package/lib/state/vanilla/playToast.js.map +1 -1
  63. package/lib/state/vanilla/updateToast.js.map +1 -1
  64. package/lib-commonjs/AriaLive.js +2 -2
  65. package/lib-commonjs/AriaLive.js.map +1 -1
  66. package/lib-commonjs/Toast.js +2 -2
  67. package/lib-commonjs/Toast.js.map +1 -1
  68. package/lib-commonjs/ToastBody.js +2 -2
  69. package/lib-commonjs/ToastBody.js.map +1 -1
  70. package/lib-commonjs/ToastContainer.js +2 -2
  71. package/lib-commonjs/ToastContainer.js.map +1 -1
  72. package/lib-commonjs/ToastFooter.js +2 -2
  73. package/lib-commonjs/ToastFooter.js.map +1 -1
  74. package/lib-commonjs/ToastTitle.js +2 -2
  75. package/lib-commonjs/ToastTitle.js.map +1 -1
  76. package/lib-commonjs/ToastTrigger.js +2 -2
  77. package/lib-commonjs/ToastTrigger.js.map +1 -1
  78. package/lib-commonjs/Toaster.js +2 -2
  79. package/lib-commonjs/Toaster.js.map +1 -1
  80. package/lib-commonjs/components/AriaLive/AriaLive.js +7 -5
  81. package/lib-commonjs/components/AriaLive/AriaLive.js.map +1 -1
  82. package/lib-commonjs/components/AriaLive/AriaLive.types.js +2 -2
  83. package/lib-commonjs/components/AriaLive/AriaLive.types.js.map +1 -1
  84. package/lib-commonjs/components/AriaLive/index.js +6 -6
  85. package/lib-commonjs/components/AriaLive/index.js.map +1 -1
  86. package/lib-commonjs/components/AriaLive/renderAriaLive.js +13 -6
  87. package/lib-commonjs/components/AriaLive/renderAriaLive.js.map +1 -1
  88. package/lib-commonjs/components/AriaLive/useAriaLive.js +16 -12
  89. package/lib-commonjs/components/AriaLive/useAriaLive.js.map +1 -1
  90. package/lib-commonjs/components/AriaLive/useAriaLiveStyles.styles.js +7 -3
  91. package/lib-commonjs/components/AriaLive/useAriaLiveStyles.styles.js.map +1 -1
  92. package/lib-commonjs/components/Timer/Timer.js +8 -6
  93. package/lib-commonjs/components/Timer/Timer.js.map +1 -1
  94. package/lib-commonjs/components/Timer/index.js +2 -2
  95. package/lib-commonjs/components/Timer/index.js.map +1 -1
  96. package/lib-commonjs/components/Timer/useTimerStyles.styles.js +4 -2
  97. package/lib-commonjs/components/Timer/useTimerStyles.styles.js.map +1 -1
  98. package/lib-commonjs/components/Toast/Toast.js +7 -5
  99. package/lib-commonjs/components/Toast/Toast.js.map +1 -1
  100. package/lib-commonjs/components/Toast/index.js +6 -6
  101. package/lib-commonjs/components/Toast/index.js.map +1 -1
  102. package/lib-commonjs/components/Toast/renderToast.js +12 -9
  103. package/lib-commonjs/components/Toast/renderToast.js.map +1 -1
  104. package/lib-commonjs/components/Toast/useToast.js +7 -5
  105. package/lib-commonjs/components/Toast/useToast.js.map +1 -1
  106. package/lib-commonjs/components/Toast/useToastContextValues.js +4 -2
  107. package/lib-commonjs/components/Toast/useToastContextValues.js.map +1 -1
  108. package/lib-commonjs/components/Toast/useToastStyles.styles.js +8 -4
  109. package/lib-commonjs/components/Toast/useToastStyles.styles.js.map +1 -1
  110. package/lib-commonjs/components/ToastBody/ToastBody.js +7 -5
  111. package/lib-commonjs/components/ToastBody/ToastBody.js.map +1 -1
  112. package/lib-commonjs/components/ToastBody/index.js +6 -6
  113. package/lib-commonjs/components/ToastBody/index.js.map +1 -1
  114. package/lib-commonjs/components/ToastBody/renderToastBody.js +13 -6
  115. package/lib-commonjs/components/ToastBody/renderToastBody.js.map +1 -1
  116. package/lib-commonjs/components/ToastBody/useToastBody.js +11 -9
  117. package/lib-commonjs/components/ToastBody/useToastBody.js.map +1 -1
  118. package/lib-commonjs/components/ToastBody/useToastBodyStyles.styles.js +9 -5
  119. package/lib-commonjs/components/ToastBody/useToastBodyStyles.styles.js.map +1 -1
  120. package/lib-commonjs/components/ToastContainer/ToastContainer.js +7 -5
  121. package/lib-commonjs/components/ToastContainer/ToastContainer.js.map +1 -1
  122. package/lib-commonjs/components/ToastContainer/ToastContainer.types.js +2 -2
  123. package/lib-commonjs/components/ToastContainer/ToastContainer.types.js.map +1 -1
  124. package/lib-commonjs/components/ToastContainer/index.js +7 -7
  125. package/lib-commonjs/components/ToastContainer/index.js.map +1 -1
  126. package/lib-commonjs/components/ToastContainer/renderToastContainer.js +19 -12
  127. package/lib-commonjs/components/ToastContainer/renderToastContainer.js.map +1 -1
  128. package/lib-commonjs/components/ToastContainer/useToastContainer.js +42 -40
  129. package/lib-commonjs/components/ToastContainer/useToastContainer.js.map +1 -1
  130. package/lib-commonjs/components/ToastContainer/useToastContainerContextValues.js +6 -4
  131. package/lib-commonjs/components/ToastContainer/useToastContainerContextValues.js.map +1 -1
  132. package/lib-commonjs/components/ToastContainer/useToastContainerStyles.styles.js +8 -4
  133. package/lib-commonjs/components/ToastContainer/useToastContainerStyles.styles.js.map +1 -1
  134. package/lib-commonjs/components/ToastFooter/ToastFooter.js +7 -5
  135. package/lib-commonjs/components/ToastFooter/ToastFooter.js.map +1 -1
  136. package/lib-commonjs/components/ToastFooter/index.js +6 -6
  137. package/lib-commonjs/components/ToastFooter/index.js.map +1 -1
  138. package/lib-commonjs/components/ToastFooter/renderToastFooter.js +8 -6
  139. package/lib-commonjs/components/ToastFooter/renderToastFooter.js.map +1 -1
  140. package/lib-commonjs/components/ToastFooter/useToastFooter.js +7 -5
  141. package/lib-commonjs/components/ToastFooter/useToastFooter.js.map +1 -1
  142. package/lib-commonjs/components/ToastFooter/useToastFooterStyles.styles.js +7 -3
  143. package/lib-commonjs/components/ToastFooter/useToastFooterStyles.styles.js.map +1 -1
  144. package/lib-commonjs/components/ToastTitle/ToastTitle.js +7 -5
  145. package/lib-commonjs/components/ToastTitle/ToastTitle.js.map +1 -1
  146. package/lib-commonjs/components/ToastTitle/index.js +6 -6
  147. package/lib-commonjs/components/ToastTitle/index.js.map +1 -1
  148. package/lib-commonjs/components/ToastTitle/renderToastTitle.js +14 -6
  149. package/lib-commonjs/components/ToastTitle/renderToastTitle.js.map +1 -1
  150. package/lib-commonjs/components/ToastTitle/useToastTitle.js +17 -15
  151. package/lib-commonjs/components/ToastTitle/useToastTitle.js.map +1 -1
  152. package/lib-commonjs/components/ToastTitle/useToastTitleStyles.styles.js +13 -9
  153. package/lib-commonjs/components/ToastTitle/useToastTitleStyles.styles.js.map +1 -1
  154. package/lib-commonjs/components/ToastTrigger/ToastTrigger.js +5 -3
  155. package/lib-commonjs/components/ToastTrigger/ToastTrigger.js.map +1 -1
  156. package/lib-commonjs/components/ToastTrigger/ToastTrigger.types.js +2 -2
  157. package/lib-commonjs/components/ToastTrigger/ToastTrigger.types.js.map +1 -1
  158. package/lib-commonjs/components/ToastTrigger/index.js +5 -5
  159. package/lib-commonjs/components/ToastTrigger/index.js.map +1 -1
  160. package/lib-commonjs/components/ToastTrigger/renderToastTrigger.js +3 -1
  161. package/lib-commonjs/components/ToastTrigger/renderToastTrigger.js.map +1 -1
  162. package/lib-commonjs/components/ToastTrigger/useToastTrigger.js +18 -15
  163. package/lib-commonjs/components/ToastTrigger/useToastTrigger.js.map +1 -1
  164. package/lib-commonjs/components/Toaster/Toaster.js +7 -5
  165. package/lib-commonjs/components/Toaster/Toaster.js.map +1 -1
  166. package/lib-commonjs/components/Toaster/index.js +6 -6
  167. package/lib-commonjs/components/Toaster/index.js.map +1 -1
  168. package/lib-commonjs/components/Toaster/renderToaster.js +26 -13
  169. package/lib-commonjs/components/Toaster/renderToaster.js.map +1 -1
  170. package/lib-commonjs/components/Toaster/useToastAnnounce.js +8 -6
  171. package/lib-commonjs/components/Toaster/useToastAnnounce.js.map +1 -1
  172. package/lib-commonjs/components/Toaster/useToaster.js +24 -22
  173. package/lib-commonjs/components/Toaster/useToaster.js.map +1 -1
  174. package/lib-commonjs/components/Toaster/useToasterFocusManagement.js +19 -17
  175. package/lib-commonjs/components/Toaster/useToasterFocusManagement.js.map +1 -1
  176. package/lib-commonjs/components/Toaster/useToasterStyles.styles.js +7 -3
  177. package/lib-commonjs/components/Toaster/useToasterStyles.styles.js.map +1 -1
  178. package/lib-commonjs/contexts/toastContainerContext.js +8 -4
  179. package/lib-commonjs/contexts/toastContainerContext.js.map +1 -1
  180. package/lib-commonjs/index.js +93 -35
  181. package/lib-commonjs/index.js.map +1 -1
  182. package/lib-commonjs/state/constants.js +6 -2
  183. package/lib-commonjs/state/constants.js.map +1 -1
  184. package/lib-commonjs/state/index.js +10 -6
  185. package/lib-commonjs/state/index.js.map +1 -1
  186. package/lib-commonjs/state/types.js +2 -2
  187. package/lib-commonjs/state/types.js.map +1 -1
  188. package/lib-commonjs/state/useToastController.js +9 -6
  189. package/lib-commonjs/state/useToastController.js.map +1 -1
  190. package/lib-commonjs/state/useToaster.js +26 -20
  191. package/lib-commonjs/state/useToaster.js.map +1 -1
  192. package/lib-commonjs/state/vanilla/createToaster.js +14 -12
  193. package/lib-commonjs/state/vanilla/createToaster.js.map +1 -1
  194. package/lib-commonjs/state/vanilla/dismissAllToasts.js +3 -1
  195. package/lib-commonjs/state/vanilla/dismissAllToasts.js.map +1 -1
  196. package/lib-commonjs/state/vanilla/dismissToast.js +3 -1
  197. package/lib-commonjs/state/vanilla/dismissToast.js.map +1 -1
  198. package/lib-commonjs/state/vanilla/dispatchToast.js +3 -1
  199. package/lib-commonjs/state/vanilla/dispatchToast.js.map +1 -1
  200. package/lib-commonjs/state/vanilla/getPositionStyles.js +4 -2
  201. package/lib-commonjs/state/vanilla/getPositionStyles.js.map +1 -1
  202. package/lib-commonjs/state/vanilla/index.js +9 -9
  203. package/lib-commonjs/state/vanilla/index.js.map +1 -1
  204. package/lib-commonjs/state/vanilla/pauseToast.js +3 -1
  205. package/lib-commonjs/state/vanilla/pauseToast.js.map +1 -1
  206. package/lib-commonjs/state/vanilla/playToast.js +3 -1
  207. package/lib-commonjs/state/vanilla/playToast.js.map +1 -1
  208. package/lib-commonjs/state/vanilla/updateToast.js +3 -1
  209. package/lib-commonjs/state/vanilla/updateToast.js.map +1 -1
  210. package/package.json +14 -14
@@ -4,49 +4,53 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useToaster", {
6
6
  enumerable: true,
7
- get: ()=>useToaster
7
+ get: function() {
8
+ return useToaster;
9
+ }
8
10
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
- const _reactUtilities = require("@fluentui/react-utilities");
12
- const _reactSharedContexts = require("@fluentui/react-shared-contexts");
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _reactutilities = require("@fluentui/react-utilities");
14
+ const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
13
15
  const _vanilla = require("./vanilla");
14
16
  const _constants = require("./constants");
15
17
  function useToaster(options = {}) {
16
- const forceUpdate = (0, _reactUtilities.useForceUpdate)();
17
- const { toasterId: userToasterId , shortcuts } = options;
18
+ const forceUpdate = (0, _reactutilities.useForceUpdate)();
19
+ const { toasterId: userToasterId, shortcuts } = options;
18
20
  // Currently the toaster options can never be changed at runtime
19
21
  const [toaster] = _react.useState(()=>(0, _vanilla.createToaster)(options));
20
- const { targetDocument } = (0, _reactSharedContexts.useFluent_unstable)();
22
+ const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
21
23
  const lastActiveElementRef = _react.useRef(null);
22
- const isCorrectToaster = (0, _reactUtilities.useEventCallback)((toasterId)=>{
24
+ const isCorrectToaster = (0, _reactutilities.useEventCallback)((toasterId)=>{
23
25
  return toasterId === userToasterId;
24
26
  });
25
- const isFocusShortcut = (0, _reactUtilities.useEventCallback)((e)=>{
26
- if (shortcuts === null || shortcuts === void 0 ? void 0 : shortcuts.focus) {
27
+ const isFocusShortcut = (0, _reactutilities.useEventCallback)((e)=>{
28
+ var _shortcuts;
29
+ if ((_shortcuts = shortcuts) === null || _shortcuts === void 0 ? void 0 : _shortcuts.focus) {
27
30
  return shortcuts.focus(e);
28
31
  }
29
32
  });
30
33
  const pauseAllToasts = _react.useCallback(()=>{
31
34
  toaster.visibleToasts.forEach((toastId)=>{
32
- var _toast_imperativeRef_current;
35
+ var _toast_imperativeRef_current, _toast;
33
36
  const toast = toaster.toasts.get(toastId);
34
- (_toast_imperativeRef_current = toast === null || toast === void 0 ? void 0 : toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.pause();
37
+ (_toast = toast) === null || _toast === void 0 ? void 0 : (_toast_imperativeRef_current = _toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.pause();
35
38
  });
36
39
  }, [
37
40
  toaster
38
41
  ]);
39
42
  const playAllToasts = _react.useCallback(()=>{
40
43
  toaster.visibleToasts.forEach((toastId)=>{
41
- var _toast_imperativeRef_current;
44
+ var _toast_imperativeRef_current, _toast;
42
45
  const toast = toaster.toasts.get(toastId);
43
- (_toast_imperativeRef_current = toast === null || toast === void 0 ? void 0 : toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.play();
46
+ (_toast = toast) === null || _toast === void 0 ? void 0 : (_toast_imperativeRef_current = _toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.play();
44
47
  });
45
48
  }, [
46
49
  toaster
47
50
  ]);
48
51
  const getMostRecentVisibleToast = _react.useCallback(()=>{
49
52
  return Array.from(toaster.visibleToasts).reduce((cur, next)=>{
53
+ var _toast;
50
54
  const toast = toaster.toasts.get(next);
51
55
  if (!toast) {
52
56
  return cur;
@@ -54,7 +58,7 @@ function useToaster(options = {}) {
54
58
  if (!cur) {
55
59
  return toast;
56
60
  }
57
- if (cur.order < (toast === null || toast === void 0 ? void 0 : toast.order)) {
61
+ if (cur.order < ((_toast = toast) === null || _toast === void 0 ? void 0 : _toast.order)) {
58
62
  return toast;
59
63
  }
60
64
  return cur;
@@ -63,8 +67,9 @@ function useToaster(options = {}) {
63
67
  toaster
64
68
  ]);
65
69
  const tryRestoreFocus = _react.useCallback(()=>{
70
+ var _mostRecentToast;
66
71
  const mostRecentToast = getMostRecentVisibleToast();
67
- if (mostRecentToast === null || mostRecentToast === void 0 ? void 0 : mostRecentToast.imperativeRef.current) {
72
+ if ((_mostRecentToast = mostRecentToast) === null || _mostRecentToast === void 0 ? void 0 : _mostRecentToast.imperativeRef.current) {
68
73
  mostRecentToast.imperativeRef.current.focus();
69
74
  } else {
70
75
  var _lastActiveElementRef_current;
@@ -76,8 +81,9 @@ function useToaster(options = {}) {
76
81
  ]);
77
82
  const closeAllToasts = _react.useCallback(()=>{
78
83
  toaster.visibleToasts.forEach((toastId)=>{
84
+ var _toast;
79
85
  const toast = toaster.toasts.get(toastId);
80
- toast === null || toast === void 0 ? void 0 : toast.close();
86
+ (_toast = toast) === null || _toast === void 0 ? void 0 : _toast.close();
81
87
  });
82
88
  tryRestoreFocus();
83
89
  }, [
@@ -137,7 +143,7 @@ function useToaster(options = {}) {
137
143
  const mostRecentToast = getMostRecentVisibleToast();
138
144
  if (mostRecentToast) {
139
145
  var _mostRecentToast_imperativeRef_current;
140
- lastActiveElementRef.current = (0, _reactUtilities.isHTMLElement)(targetDocument.activeElement) ? targetDocument.activeElement : null;
146
+ lastActiveElementRef.current = (0, _reactutilities.isHTMLElement)(targetDocument.activeElement) ? targetDocument.activeElement : null;
141
147
  (_mostRecentToast_imperativeRef_current = mostRecentToast.imperativeRef.current) === null || _mostRecentToast_imperativeRef_current === void 0 ? void 0 : _mostRecentToast_imperativeRef_current.focus();
142
148
  }
143
149
  }
@@ -168,7 +174,7 @@ function useToaster(options = {}) {
168
174
  const toRender = new Map();
169
175
  const toasts = Array.from(toaster.toasts.values());
170
176
  toasts.forEach((toast)=>{
171
- const { position } = toast;
177
+ const { position } = toast;
172
178
  toRender.has(position) || toRender.set(position, []);
173
179
  if (position.startsWith('bottom')) {
174
180
  toRender.get(position).push(toast);
@@ -1 +1 @@
1
- {"version":3,"sources":["useToaster.js"],"sourcesContent":["import * as React from 'react';\nimport { isHTMLElement, useEventCallback, useForceUpdate } from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createToaster } from './vanilla';\nimport { EVENTS } from './constants';\nexport function useToaster(options = {}) {\n const forceUpdate = useForceUpdate();\n const { toasterId: userToasterId , shortcuts } = options;\n // Currently the toaster options can never be changed at runtime\n const [toaster] = React.useState(()=>createToaster(options));\n const { targetDocument } = useFluent();\n const lastActiveElementRef = React.useRef(null);\n const isCorrectToaster = useEventCallback((toasterId)=>{\n return toasterId === userToasterId;\n });\n const isFocusShortcut = useEventCallback((e)=>{\n if (shortcuts === null || shortcuts === void 0 ? void 0 : shortcuts.focus) {\n return shortcuts.focus(e);\n }\n });\n const pauseAllToasts = React.useCallback(()=>{\n toaster.visibleToasts.forEach((toastId)=>{\n var _toast_imperativeRef_current;\n const toast = toaster.toasts.get(toastId);\n (_toast_imperativeRef_current = toast === null || toast === void 0 ? void 0 : toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.pause();\n });\n }, [\n toaster\n ]);\n const playAllToasts = React.useCallback(()=>{\n toaster.visibleToasts.forEach((toastId)=>{\n var _toast_imperativeRef_current;\n const toast = toaster.toasts.get(toastId);\n (_toast_imperativeRef_current = toast === null || toast === void 0 ? void 0 : toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.play();\n });\n }, [\n toaster\n ]);\n const getMostRecentVisibleToast = React.useCallback(()=>{\n return Array.from(toaster.visibleToasts).reduce((cur, next)=>{\n const toast = toaster.toasts.get(next);\n if (!toast) {\n return cur;\n }\n if (!cur) {\n return toast;\n }\n if (cur.order < (toast === null || toast === void 0 ? void 0 : toast.order)) {\n return toast;\n }\n return cur;\n }, undefined);\n }, [\n toaster\n ]);\n const tryRestoreFocus = React.useCallback(()=>{\n const mostRecentToast = getMostRecentVisibleToast();\n if (mostRecentToast === null || mostRecentToast === void 0 ? void 0 : mostRecentToast.imperativeRef.current) {\n mostRecentToast.imperativeRef.current.focus();\n } else {\n var _lastActiveElementRef_current;\n (_lastActiveElementRef_current = lastActiveElementRef.current) === null || _lastActiveElementRef_current === void 0 ? void 0 : _lastActiveElementRef_current.focus();\n lastActiveElementRef.current = null;\n }\n }, [\n getMostRecentVisibleToast\n ]);\n const closeAllToasts = React.useCallback(()=>{\n toaster.visibleToasts.forEach((toastId)=>{\n const toast = toaster.toasts.get(toastId);\n toast === null || toast === void 0 ? void 0 : toast.close();\n });\n tryRestoreFocus();\n }, [\n toaster,\n tryRestoreFocus\n ]);\n React.useEffect(()=>{\n if (!targetDocument) {\n return;\n }\n const addToastListener = (eventType, callback)=>{\n const listener = (e)=>{\n if (!isCorrectToaster(e.detail.toasterId)) {\n return;\n }\n callback(e);\n forceUpdate();\n };\n targetDocument.addEventListener(eventType, listener);\n return ()=>targetDocument.removeEventListener(eventType, listener);\n };\n const buildToast = (e)=>{\n toaster.buildToast(e.detail, forceUpdate);\n };\n const dismissToast = (e)=>{\n toaster.dismissToast(e.detail.toastId);\n };\n const updateToast = (e)=>{\n toaster.updateToast(e.detail);\n };\n const dismissAllToasts = (e)=>{\n toaster.dismissAllToasts();\n };\n const pauseToast = (e)=>{\n const toast = toaster.toasts.get(e.detail.toastId);\n if (toast) {\n var _toast_imperativeRef_current;\n (_toast_imperativeRef_current = toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.pause();\n }\n };\n const playToast = (e)=>{\n const toast = toaster.toasts.get(e.detail.toastId);\n if (toast) {\n var _toast_imperativeRef_current;\n (_toast_imperativeRef_current = toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.play();\n }\n };\n const cleanupBuildListener = addToastListener(EVENTS.show, buildToast);\n const cleanupUpdateListener = addToastListener(EVENTS.update, updateToast);\n const cleanupDismissListener = addToastListener(EVENTS.dismiss, dismissToast);\n const cleanupDismissAllListener = addToastListener(EVENTS.dismissAll, dismissAllToasts);\n const cleanupPauseListener = addToastListener(EVENTS.pause, pauseToast);\n const cleanupPlayListener = addToastListener(EVENTS.play, playToast);\n const focusShortcutListener = (e)=>{\n if (isFocusShortcut(e)) {\n pauseAllToasts();\n const mostRecentToast = getMostRecentVisibleToast();\n if (mostRecentToast) {\n var _mostRecentToast_imperativeRef_current;\n lastActiveElementRef.current = isHTMLElement(targetDocument.activeElement) ? targetDocument.activeElement : null;\n (_mostRecentToast_imperativeRef_current = mostRecentToast.imperativeRef.current) === null || _mostRecentToast_imperativeRef_current === void 0 ? void 0 : _mostRecentToast_imperativeRef_current.focus();\n }\n }\n };\n targetDocument.addEventListener('keydown', focusShortcutListener);\n return ()=>{\n cleanupBuildListener();\n cleanupDismissAllListener();\n cleanupUpdateListener();\n cleanupDismissListener();\n cleanupPauseListener();\n cleanupPlayListener();\n targetDocument.removeEventListener('keydown', focusShortcutListener);\n };\n }, [\n toaster,\n forceUpdate,\n targetDocument,\n isCorrectToaster,\n pauseAllToasts,\n getMostRecentVisibleToast,\n isFocusShortcut\n ]);\n const toastsToRender = (()=>{\n if (!toaster) {\n return new Map();\n }\n const toRender = new Map();\n const toasts = Array.from(toaster.toasts.values());\n toasts.forEach((toast)=>{\n const { position } = toast;\n toRender.has(position) || toRender.set(position, []);\n if (position.startsWith('bottom')) {\n toRender.get(position).push(toast);\n } else {\n toRender.get(position).unshift(toast);\n }\n });\n return toRender;\n })();\n return {\n isToastVisible: toaster.isToastVisible,\n toastsToRender,\n pauseAllToasts,\n playAllToasts,\n tryRestoreFocus,\n closeAllToasts\n };\n}\n"],"names":["useToaster","options","forceUpdate","useForceUpdate","toasterId","userToasterId","shortcuts","toaster","React","useState","createToaster","targetDocument","useFluent","lastActiveElementRef","useRef","isCorrectToaster","useEventCallback","isFocusShortcut","e","focus","pauseAllToasts","useCallback","visibleToasts","forEach","toastId","_toast_imperativeRef_current","toast","toasts","get","imperativeRef","current","pause","playAllToasts","play","getMostRecentVisibleToast","Array","from","reduce","cur","next","order","undefined","tryRestoreFocus","mostRecentToast","_lastActiveElementRef_current","closeAllToasts","close","useEffect","addToastListener","eventType","callback","listener","detail","addEventListener","removeEventListener","buildToast","dismissToast","updateToast","dismissAllToasts","pauseToast","playToast","cleanupBuildListener","EVENTS","show","cleanupUpdateListener","update","cleanupDismissListener","dismiss","cleanupDismissAllListener","dismissAll","cleanupPauseListener","cleanupPlayListener","focusShortcutListener","_mostRecentToast_imperativeRef_current","isHTMLElement","activeElement","toastsToRender","Map","toRender","values","position","has","set","startsWith","push","unshift","isToastVisible"],"mappings":";;;;+BAKgBA;;aAAAA;;;6DALO;gCACyC;qCAChB;yBAClB;2BACP;AAChB,SAASA,WAAWC,UAAU,CAAC,CAAC,EAAE;IACrC,MAAMC,cAAcC,IAAAA,8BAAc;IAClC,MAAM,EAAEC,WAAWC,cAAa,EAAGC,UAAS,EAAG,GAAGL;IAClD,gEAAgE;IAChE,MAAM,CAACM,QAAQ,GAAGC,OAAMC,QAAQ,CAAC,IAAIC,IAAAA,sBAAa,EAACT;IACnD,MAAM,EAAEU,eAAc,EAAG,GAAGC,IAAAA,uCAAS;IACrC,MAAMC,uBAAuBL,OAAMM,MAAM,CAAC,IAAI;IAC9C,MAAMC,mBAAmBC,IAAAA,gCAAgB,EAAC,CAACZ,YAAY;QACnD,OAAOA,cAAcC;IACzB;IACA,MAAMY,kBAAkBD,IAAAA,gCAAgB,EAAC,CAACE,IAAI;QAC1C,IAAIZ,cAAc,IAAI,IAAIA,cAAc,KAAK,IAAI,KAAK,IAAIA,UAAUa,KAAK,EAAE;YACvE,OAAOb,UAAUa,KAAK,CAACD;QAC3B,CAAC;IACL;IACA,MAAME,iBAAiBZ,OAAMa,WAAW,CAAC,IAAI;QACzCd,QAAQe,aAAa,CAACC,OAAO,CAAC,CAACC,UAAU;YACrC,IAAIC;YACJ,MAAMC,QAAQnB,QAAQoB,MAAM,CAACC,GAAG,CAACJ;YAChCC,CAAAA,+BAA+BC,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAMG,aAAa,CAACC,OAAO,AAAD,MAAO,IAAI,IAAIL,iCAAiC,KAAK,IAAI,KAAK,IAAIA,6BAA6BM,KAAK,EAAE;QA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B;QAC3C,OAAO,IAAI;YACPX;YACAO;YACAJ;YACAE;YACAI;YACAC;YACA5D,eAAe2C,mBAAmB,CAAC,WAAWkB;QAClD;IACJ,GAAG;QACCjE;QACAL;QACAS;QACAI;QACAK;QACAc;QACAjB;KACH;IACD,MAAM2D,iBAAiB,AAAC,CAAA,IAAI;QACxB,IAAI,CAACrE,SAAS;YACV,OAAO,IAAIsE;QACf,CAAC;QACD,MAAMC,WAAW,IAAID;QACrB,MAAMlD,SAASQ,MAAMC,IAAI,CAAC7B,QAAQoB,MAAM,CAACoD,MAAM;QAC/CpD,OAAOJ,OAAO,CAAC,CAACG,QAAQ;YACpB,MAAM,EAAEsD,SAAQ,EAAG,GAAGtD;YACtBoD,SAASG,GAAG,CAACD,aAAaF,SAASI,GAAG,CAACF,UAAU,EAAE;YACnD,IAAIA,SAASG,UAAU,CAAC,WAAW;gBAC/BL,SAASlD,GAAG,CAACoD,UAAUI,IAAI,CAAC1D;YAChC,OAAO;gBACHoD,SAASlD,GAAG,CAACoD,UAAUK,OAAO,CAAC3D;YACnC,CAAC;QACL;QACA,OAAOoD;IACX,CAAA;IACA,OAAO;QACHQ,gBAAgB/E,QAAQ+E,cAAc;QACtCV;QACAxD;QACAY;QACAU;QACAG;IACJ;AACJ"}
1
+ {"version":3,"sources":["useToaster.js"],"sourcesContent":["import * as React from 'react';\nimport { isHTMLElement, useEventCallback, useForceUpdate } from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createToaster } from './vanilla';\nimport { EVENTS } from './constants';\nexport function useToaster(options = {}) {\n const forceUpdate = useForceUpdate();\n const { toasterId: userToasterId, shortcuts } = options;\n // Currently the toaster options can never be changed at runtime\n const [toaster] = React.useState(()=>createToaster(options));\n const { targetDocument } = useFluent();\n const lastActiveElementRef = React.useRef(null);\n const isCorrectToaster = useEventCallback((toasterId)=>{\n return toasterId === userToasterId;\n });\n const isFocusShortcut = useEventCallback((e)=>{\n var _shortcuts;\n if ((_shortcuts = shortcuts) === null || _shortcuts === void 0 ? void 0 : _shortcuts.focus) {\n return shortcuts.focus(e);\n }\n });\n const pauseAllToasts = React.useCallback(()=>{\n toaster.visibleToasts.forEach((toastId)=>{\n var _toast_imperativeRef_current, _toast;\n const toast = toaster.toasts.get(toastId);\n (_toast = toast) === null || _toast === void 0 ? void 0 : (_toast_imperativeRef_current = _toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.pause();\n });\n }, [\n toaster\n ]);\n const playAllToasts = React.useCallback(()=>{\n toaster.visibleToasts.forEach((toastId)=>{\n var _toast_imperativeRef_current, _toast;\n const toast = toaster.toasts.get(toastId);\n (_toast = toast) === null || _toast === void 0 ? void 0 : (_toast_imperativeRef_current = _toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.play();\n });\n }, [\n toaster\n ]);\n const getMostRecentVisibleToast = React.useCallback(()=>{\n return Array.from(toaster.visibleToasts).reduce((cur, next)=>{\n var _toast;\n const toast = toaster.toasts.get(next);\n if (!toast) {\n return cur;\n }\n if (!cur) {\n return toast;\n }\n if (cur.order < ((_toast = toast) === null || _toast === void 0 ? void 0 : _toast.order)) {\n return toast;\n }\n return cur;\n }, undefined);\n }, [\n toaster\n ]);\n const tryRestoreFocus = React.useCallback(()=>{\n var _mostRecentToast;\n const mostRecentToast = getMostRecentVisibleToast();\n if ((_mostRecentToast = mostRecentToast) === null || _mostRecentToast === void 0 ? void 0 : _mostRecentToast.imperativeRef.current) {\n mostRecentToast.imperativeRef.current.focus();\n } else {\n var _lastActiveElementRef_current;\n (_lastActiveElementRef_current = lastActiveElementRef.current) === null || _lastActiveElementRef_current === void 0 ? void 0 : _lastActiveElementRef_current.focus();\n lastActiveElementRef.current = null;\n }\n }, [\n getMostRecentVisibleToast\n ]);\n const closeAllToasts = React.useCallback(()=>{\n toaster.visibleToasts.forEach((toastId)=>{\n var _toast;\n const toast = toaster.toasts.get(toastId);\n (_toast = toast) === null || _toast === void 0 ? void 0 : _toast.close();\n });\n tryRestoreFocus();\n }, [\n toaster,\n tryRestoreFocus\n ]);\n React.useEffect(()=>{\n if (!targetDocument) {\n return;\n }\n const addToastListener = (eventType, callback)=>{\n const listener = (e)=>{\n if (!isCorrectToaster(e.detail.toasterId)) {\n return;\n }\n callback(e);\n forceUpdate();\n };\n targetDocument.addEventListener(eventType, listener);\n return ()=>targetDocument.removeEventListener(eventType, listener);\n };\n const buildToast = (e)=>{\n toaster.buildToast(e.detail, forceUpdate);\n };\n const dismissToast = (e)=>{\n toaster.dismissToast(e.detail.toastId);\n };\n const updateToast = (e)=>{\n toaster.updateToast(e.detail);\n };\n const dismissAllToasts = (e)=>{\n toaster.dismissAllToasts();\n };\n const pauseToast = (e)=>{\n const toast = toaster.toasts.get(e.detail.toastId);\n if (toast) {\n var _toast_imperativeRef_current;\n (_toast_imperativeRef_current = toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.pause();\n }\n };\n const playToast = (e)=>{\n const toast = toaster.toasts.get(e.detail.toastId);\n if (toast) {\n var _toast_imperativeRef_current;\n (_toast_imperativeRef_current = toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.play();\n }\n };\n const cleanupBuildListener = addToastListener(EVENTS.show, buildToast);\n const cleanupUpdateListener = addToastListener(EVENTS.update, updateToast);\n const cleanupDismissListener = addToastListener(EVENTS.dismiss, dismissToast);\n const cleanupDismissAllListener = addToastListener(EVENTS.dismissAll, dismissAllToasts);\n const cleanupPauseListener = addToastListener(EVENTS.pause, pauseToast);\n const cleanupPlayListener = addToastListener(EVENTS.play, playToast);\n const focusShortcutListener = (e)=>{\n if (isFocusShortcut(e)) {\n pauseAllToasts();\n const mostRecentToast = getMostRecentVisibleToast();\n if (mostRecentToast) {\n var _mostRecentToast_imperativeRef_current;\n lastActiveElementRef.current = isHTMLElement(targetDocument.activeElement) ? targetDocument.activeElement : null;\n (_mostRecentToast_imperativeRef_current = mostRecentToast.imperativeRef.current) === null || _mostRecentToast_imperativeRef_current === void 0 ? void 0 : _mostRecentToast_imperativeRef_current.focus();\n }\n }\n };\n targetDocument.addEventListener('keydown', focusShortcutListener);\n return ()=>{\n cleanupBuildListener();\n cleanupDismissAllListener();\n cleanupUpdateListener();\n cleanupDismissListener();\n cleanupPauseListener();\n cleanupPlayListener();\n targetDocument.removeEventListener('keydown', focusShortcutListener);\n };\n }, [\n toaster,\n forceUpdate,\n targetDocument,\n isCorrectToaster,\n pauseAllToasts,\n getMostRecentVisibleToast,\n isFocusShortcut\n ]);\n const toastsToRender = (()=>{\n if (!toaster) {\n return new Map();\n }\n const toRender = new Map();\n const toasts = Array.from(toaster.toasts.values());\n toasts.forEach((toast)=>{\n const { position } = toast;\n toRender.has(position) || toRender.set(position, []);\n if (position.startsWith('bottom')) {\n toRender.get(position).push(toast);\n } else {\n toRender.get(position).unshift(toast);\n }\n });\n return toRender;\n })();\n return {\n isToastVisible: toaster.isToastVisible,\n toastsToRender,\n pauseAllToasts,\n playAllToasts,\n tryRestoreFocus,\n closeAllToasts\n };\n}\n"],"names":["useToaster","options","forceUpdate","useForceUpdate","toasterId","userToasterId","shortcuts","toaster","React","useState","createToaster","targetDocument","useFluent","lastActiveElementRef","useRef","isCorrectToaster","useEventCallback","isFocusShortcut","e","_shortcuts","focus","pauseAllToasts","useCallback","visibleToasts","forEach","toastId","_toast_imperativeRef_current","_toast","toast","toasts","get","imperativeRef","current","pause","playAllToasts","play","getMostRecentVisibleToast","Array","from","reduce","cur","next","order","undefined","tryRestoreFocus","_mostRecentToast","mostRecentToast","_lastActiveElementRef_current","closeAllToasts","close","useEffect","addToastListener","eventType","callback","listener","detail","addEventListener","removeEventListener","buildToast","dismissToast","updateToast","dismissAllToasts","pauseToast","playToast","cleanupBuildListener","EVENTS","show","cleanupUpdateListener","update","cleanupDismissListener","dismiss","cleanupDismissAllListener","dismissAll","cleanupPauseListener","cleanupPlayListener","focusShortcutListener","_mostRecentToast_imperativeRef_current","isHTMLElement","activeElement","toastsToRender","Map","toRender","values","position","has","set","startsWith","push","unshift","isToastVisible"],"mappings":";;;;+BAKgBA;;;eAAAA;;;;iEALO;gCACyC;qCAChB;yBAClB;2BACP;AAChB,SAASA,WAAWC,UAAU,CAAC,CAAC;IACnC,MAAMC,cAAcC,IAAAA,8BAAc;IAClC,MAAM,EAAEC,WAAWC,aAAa,EAAEC,SAAS,EAAE,GAAGL;IAChD,gEAAgE;IAChE,MAAM,CAACM,QAAQ,GAAGC,OAAMC,QAAQ,CAAC,IAAIC,IAAAA,sBAAa,EAACT;IACnD,MAAM,EAAEU,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,uBAAuBL,OAAMM,MAAM,CAAC;IAC1C,MAAMC,mBAAmBC,IAAAA,gCAAgB,EAAC,CAACZ;QACvC,OAAOA,cAAcC;IACzB;IACA,MAAMY,kBAAkBD,IAAAA,gCAAgB,EAAC,CAACE;QACtC,IAAIC;QACJ,IAAI,AAACA,CAAAA,aAAab,SAAQ,MAAO,QAAQa,eAAe,KAAK,IAAI,KAAK,IAAIA,WAAWC,KAAK,EAAE;YACxF,OAAOd,UAAUc,KAAK,CAACF;QAC3B;IACJ;IACA,MAAMG,iBAAiBb,OAAMc,WAAW,CAAC;QACrCf,QAAQgB,aAAa,CAACC,OAAO,CAAC,CAACC;YAC3B,IAAIC,8BAA8BC;YAClC,MAAMC,QAAQrB,QAAQsB,MAAM,CAACC,GAAG,CAACL;YAChCE,CAAAA,SAASC,KAAI,MAAO,QAAQD,WAAW,KAAK,IAAI,KAAK,IAAI,AAACD,CAAAA,+BAA+BC,OAAOI,aAAa,CAACC,OAAO,AAAD,MAAO,QAAQN,iCAAiC,KAAK,IAAI,KAAK,IAAIA,6BAA6BO,KAAK;QAC7N;IACJ,GAAG;QACC1B;KACH;IACD,MAAM2B,gBAAgB1B,OAAMc,WAAW,CAAC;QACpCf,QAAQgB,a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I,CAACxE,SAAS;YACV,OAAO,IAAIyE;QACf;QACA,MAAMC,WAAW,IAAID;QACrB,MAAMnD,SAASQ,MAAMC,IAAI,CAAC/B,QAAQsB,MAAM,CAACqD,MAAM;QAC/CrD,OAAOL,OAAO,CAAC,CAACI;YACZ,MAAM,EAAEuD,QAAQ,EAAE,GAAGvD;YACrBqD,SAASG,GAAG,CAACD,aAAaF,SAASI,GAAG,CAACF,UAAU,EAAE;YACnD,IAAIA,SAASG,UAAU,CAAC,WAAW;gBAC/BL,SAASnD,GAAG,CAACqD,UAAUI,IAAI,CAAC3D;YAChC,OAAO;gBACHqD,SAASnD,GAAG,CAACqD,UAAUK,OAAO,CAAC5D;YACnC;QACJ;QACA,OAAOqD;IACX,CAAA;IACA,OAAO;QACHQ,gBAAgBlF,QAAQkF,cAAc;QACtCV;QACA1D;QACAa;QACAU;QACAI;IACJ;AACJ"}
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "createToaster", {
6
6
  enumerable: true,
7
- get: ()=>createToaster
7
+ get: function() {
8
+ return createToaster;
9
+ }
8
10
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
- const _reactUtilities = require("@fluentui/react-utilities");
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _reactutilities = require("@fluentui/react-utilities");
12
14
  function assignDefined(a, b) {
13
15
  // This cast is required, as Object.entries will return string as key which is not indexable
14
16
  for (const [key, prop] of Object.entries(b)){
@@ -29,10 +31,10 @@ const defaulToastOptions = {
29
31
  // Multiple toasts can be dispatched in a single tick, use counter to prevent collisions
30
32
  let counter = 0;
31
33
  function createToaster(options) {
32
- const { limit =Number.POSITIVE_INFINITY } = options;
34
+ const { limit = Number.POSITIVE_INFINITY } = options;
33
35
  const visibleToasts = new Set();
34
36
  const toasts = new Map();
35
- const queue = (0, _reactUtilities.createPriorityQueue)((ta, tb)=>{
37
+ const queue = (0, _reactutilities.createPriorityQueue)((ta, tb)=>{
36
38
  const a = toasts.get(ta);
37
39
  const b = toasts.get(tb);
38
40
  if (!a || !b) {
@@ -49,7 +51,7 @@ function createToaster(options) {
49
51
  /**
50
52
  * Updates an existing toast with any available option
51
53
  */ const updateToast = (toastOptions)=>{
52
- const { toastId } = toastOptions;
54
+ const { toastId } = toastOptions;
53
55
  const toastToUpdate = toasts.get(toastId);
54
56
  if (!toastToUpdate) {
55
57
  return;
@@ -72,20 +74,20 @@ function createToaster(options) {
72
74
  * @param toastOptions user configured options
73
75
  * @param onUpdate Some toast methods can result in UI changes (i.e. close) use this to dispatch callbacks
74
76
  */ const buildToast = (toastOptions, onUpdate)=>{
75
- var _toast_onStatusChange;
76
- const { toastId , content , toasterId } = toastOptions;
77
+ var _toast_onStatusChange, _toast;
78
+ const { toastId, content, toasterId } = toastOptions;
77
79
  if (toasts.has(toastId)) {
78
80
  return;
79
81
  }
80
82
  const close = ()=>{
81
- var _toast_onStatusChange;
83
+ var _toast_onStatusChange, _toast;
82
84
  const toast = toasts.get(toastId);
83
85
  if (!toast) {
84
86
  return;
85
87
  }
86
88
  visibleToasts.delete(toastId);
87
89
  onUpdate();
88
- (_toast_onStatusChange = toast.onStatusChange) === null || _toast_onStatusChange === void 0 ? void 0 : _toast_onStatusChange.call(toast, null, {
90
+ (_toast_onStatusChange = (_toast = toast).onStatusChange) === null || _toast_onStatusChange === void 0 ? void 0 : _toast_onStatusChange.call(_toast, null, {
89
91
  status: 'dismissed',
90
92
  ...toast
91
93
  });
@@ -120,7 +122,7 @@ function createToaster(options) {
120
122
  assignDefined(toast, options);
121
123
  assignDefined(toast, toastOptions);
122
124
  toasts.set(toastId, toast);
123
- (_toast_onStatusChange = toast.onStatusChange) === null || _toast_onStatusChange === void 0 ? void 0 : _toast_onStatusChange.call(toast, null, {
125
+ (_toast_onStatusChange = (_toast = toast).onStatusChange) === null || _toast_onStatusChange === void 0 ? void 0 : _toast_onStatusChange.call(_toast, null, {
124
126
  status: 'queued',
125
127
  ...toast
126
128
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["createToaster.js"],"sourcesContent":["import * as React from 'react';\nimport { createPriorityQueue } from '@fluentui/react-utilities';\nfunction assignDefined(a, b) {\n // This cast is required, as Object.entries will return string as key which is not indexable\n for (const [key, prop] of Object.entries(b)){\n // eslint-disable-next-line eqeqeq\n if (prop != undefined) {\n a[key] = prop;\n }\n }\n}\nconst defaulToastOptions = {\n onStatusChange: undefined,\n priority: 0,\n pauseOnHover: false,\n pauseOnWindowBlur: false,\n position: 'bottom-end',\n timeout: 3000\n};\n// Multiple toasts can be dispatched in a single tick, use counter to prevent collisions\nlet counter = 0;\n/**\n * Toast are managed outside of the react lifecycle because they can be\n * dispatched imperatively. Therefore the state of toast visibility can't\n * really be managed properly by a declarative lifecycle.\n */ export function createToaster(options) {\n const { limit =Number.POSITIVE_INFINITY } = options;\n const visibleToasts = new Set();\n const toasts = new Map();\n const queue = createPriorityQueue((ta, tb)=>{\n const a = toasts.get(ta);\n const b = toasts.get(tb);\n if (!a || !b) {\n return 0;\n }\n if (a.priority === b.priority) {\n return a.order - b.order;\n }\n return a.priority - b.priority;\n });\n const isToastVisible = (toastId)=>{\n return visibleToasts.has(toastId);\n };\n /**\n * Updates an existing toast with any available option\n */ const updateToast = (toastOptions)=>{\n const { toastId } = toastOptions;\n const toastToUpdate = toasts.get(toastId);\n if (!toastToUpdate) {\n return;\n }\n Object.assign(toastToUpdate, toastOptions);\n toastToUpdate.updateId++;\n };\n /**\n * Dismisses a toast with a specific id\n */ const dismissToast = (toastId)=>{\n visibleToasts.delete(toastId);\n };\n /**\n * Dismisses all toasts and clears the queue\n */ const dismissAllToasts = ()=>{\n visibleToasts.clear();\n queue.clear();\n };\n /**\n * @param toastOptions user configured options\n * @param onUpdate Some toast methods can result in UI changes (i.e. close) use this to dispatch callbacks\n */ const buildToast = (toastOptions, onUpdate)=>{\n var _toast_onStatusChange;\n const { toastId , content , toasterId } = toastOptions;\n if (toasts.has(toastId)) {\n return;\n }\n const close = ()=>{\n var _toast_onStatusChange;\n const toast = toasts.get(toastId);\n if (!toast) {\n return;\n }\n visibleToasts.delete(toastId);\n onUpdate();\n (_toast_onStatusChange = toast.onStatusChange) === null || _toast_onStatusChange === void 0 ? void 0 : _toast_onStatusChange.call(toast, null, {\n status: 'dismissed',\n ...toast\n });\n };\n const remove = ()=>{\n const toast = toasts.get(toastId);\n if (!toast) {\n return;\n }\n toasts.delete(toastId);\n if (visibleToasts.size < limit && queue.peek()) {\n const nextToast = toasts.get(queue.dequeue());\n if (!nextToast) {\n return;\n }\n visibleToasts.add(nextToast.toastId);\n }\n onUpdate();\n };\n const toast = {\n ...defaulToastOptions,\n close,\n remove,\n toastId,\n content,\n updateId: 0,\n toasterId,\n order: counter++,\n data: {},\n imperativeRef: React.createRef()\n };\n assignDefined(toast, options);\n assignDefined(toast, toastOptions);\n toasts.set(toastId, toast);\n (_toast_onStatusChange = toast.onStatusChange) === null || _toast_onStatusChange === void 0 ? void 0 : _toast_onStatusChange.call(toast, null, {\n status: 'queued',\n ...toast\n });\n if (visibleToasts.size >= limit) {\n queue.enqueue(toastId);\n } else {\n visibleToasts.add(toastId);\n }\n };\n return {\n buildToast,\n dismissAllToasts,\n dismissToast,\n isToastVisible,\n updateToast,\n visibleToasts,\n toasts\n };\n}\n"],"names":["createToaster","assignDefined","a","b","key","prop","Object","entries","undefined","defaulToastOptions","onStatusChange","priority","pauseOnHover","pauseOnWindowBlur","position","timeout","counter","options","limit","Number","POSITIVE_INFINITY","visibleToasts","Set","toasts","Map","queue","createPriorityQueue","ta","tb","get","order","isToastVisible","toastId","has","updateToast","toastOptions","toastToUpdate","assign","updateId","dismissToast","delete","dismissAllToasts","clear","buildToast","onUpdate","_toast_onStatusChange","content","toasterId","close","toast","call","status","remove","size","peek","nextToast","dequ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AAOd;YACP0C,MAAM,CAAC;YACPC,6BAAeC,OAAMC,SAAS;QAClC;QACA5D,cAAcgD,OAAOhC;QACrBhB,cAAcgD,OAAOd;QACrBZ,OAAOuC,GAAG,CAAC9B,SAASiB;QACnBJ,CAAAA,wBAAwBI,MAAMvC,cAAc,AAAD,MAAO,IAAI,IAAImC,0BAA0B,KAAK,IAAI,KAAK,IAAIA,sBAAsBK,IAAI,CAACD,OAAO,IAAI,EAAE;YAC3IE,QAAQ;YACR,GAAGF,KAAK;QACZ,EAAE;QACF,IAAI5B,cAAcgC,IAAI,IAAInC,OAAO;YAC7BO,MAAMsC,OAAO,CAAC/B;QAClB,OAAO;YACHX,cAAcoC,GAAG,CAACzB;QACtB,CAAC;IACL;IACA,OAAO;QACHW;QACAF;QACAF;QACAR;QACAG;QACAb;QACAE;IACJ;AACJ"}
1
+ {"version":3,"sources":["createToaster.js"],"sourcesContent":["import * as React from 'react';\nimport { createPriorityQueue } from '@fluentui/react-utilities';\nfunction assignDefined(a, b) {\n // This cast is required, as Object.entries will return string as key which is not indexable\n for (const [key, prop] of Object.entries(b)){\n // eslint-disable-next-line eqeqeq\n if (prop != undefined) {\n a[key] = prop;\n }\n }\n}\nconst defaulToastOptions = {\n onStatusChange: undefined,\n priority: 0,\n pauseOnHover: false,\n pauseOnWindowBlur: false,\n position: 'bottom-end',\n timeout: 3000\n};\n// Multiple toasts can be dispatched in a single tick, use counter to prevent collisions\nlet counter = 0;\n/**\n * Toast are managed outside of the react lifecycle because they can be\n * dispatched imperatively. Therefore the state of toast visibility can't\n * really be managed properly by a declarative lifecycle.\n */ export function createToaster(options) {\n const { limit = Number.POSITIVE_INFINITY } = options;\n const visibleToasts = new Set();\n const toasts = new Map();\n const queue = createPriorityQueue((ta, tb)=>{\n const a = toasts.get(ta);\n const b = toasts.get(tb);\n if (!a || !b) {\n return 0;\n }\n if (a.priority === b.priority) {\n return a.order - b.order;\n }\n return a.priority - b.priority;\n });\n const isToastVisible = (toastId)=>{\n return visibleToasts.has(toastId);\n };\n /**\n * Updates an existing toast with any available option\n */ const updateToast = (toastOptions)=>{\n const { toastId } = toastOptions;\n const toastToUpdate = toasts.get(toastId);\n if (!toastToUpdate) {\n return;\n }\n Object.assign(toastToUpdate, toastOptions);\n toastToUpdate.updateId++;\n };\n /**\n * Dismisses a toast with a specific id\n */ const dismissToast = (toastId)=>{\n visibleToasts.delete(toastId);\n };\n /**\n * Dismisses all toasts and clears the queue\n */ const dismissAllToasts = ()=>{\n visibleToasts.clear();\n queue.clear();\n };\n /**\n * @param toastOptions user configured options\n * @param onUpdate Some toast methods can result in UI changes (i.e. close) use this to dispatch callbacks\n */ const buildToast = (toastOptions, onUpdate)=>{\n var _toast_onStatusChange, _toast;\n const { toastId, content, toasterId } = toastOptions;\n if (toasts.has(toastId)) {\n return;\n }\n const close = ()=>{\n var _toast_onStatusChange, _toast;\n const toast = toasts.get(toastId);\n if (!toast) {\n return;\n }\n visibleToasts.delete(toastId);\n onUpdate();\n (_toast_onStatusChange = (_toast = toast).onStatusChange) === null || _toast_onStatusChange === void 0 ? void 0 : _toast_onStatusChange.call(_toast, null, {\n status: 'dismissed',\n ...toast\n });\n };\n const remove = ()=>{\n const toast = toasts.get(toastId);\n if (!toast) {\n return;\n }\n toasts.delete(toastId);\n if (visibleToasts.size < limit && queue.peek()) {\n const nextToast = toasts.get(queue.dequeue());\n if (!nextToast) {\n return;\n }\n visibleToasts.add(nextToast.toastId);\n }\n onUpdate();\n };\n const toast = {\n ...defaulToastOptions,\n close,\n remove,\n toastId,\n content,\n updateId: 0,\n toasterId,\n order: counter++,\n data: {},\n imperativeRef: React.createRef()\n };\n assignDefined(toast, options);\n assignDefined(toast, toastOptions);\n toasts.set(toastId, toast);\n (_toast_onStatusChange = (_toast = toast).onStatusChange) === null || _toast_onStatusChange === void 0 ? void 0 : _toast_onStatusChange.call(_toast, null, {\n status: 'queued',\n ...toast\n });\n if (visibleToasts.size >= limit) {\n queue.enqueue(toastId);\n } else {\n visibleToasts.add(toastId);\n }\n };\n return {\n buildToast,\n dismissAllToasts,\n dismissToast,\n isToastVisible,\n updateToast,\n visibleToasts,\n toasts\n };\n}\n"],"names":["createToaster","assignDefined","a","b","key","prop","Object","entries","undefined","defaulToastOptions","onStatusChange","priority","pauseOnHover","pauseOnWindowBlur","position","timeout","counter","options","limit","Number","POSITIVE_INFINITY","visibleToasts","Set","toasts","Map","queue","createPriorityQueue","ta","tb","get","order","isToastVisible","toastId","has","updateToast","toastOptions","toastToUpdate","assign","updateId","dismissToast","delete","dismissAllToasts","clear","buildToast","onUpdate","_toast_onStatusChange","_toast","content","toasterId","close","toast","call","status","remove","size","peek","nextToast","dequeue","add","data","imperativeRef","React","createRef","set","enqueue"],"mappings":";;;;+BAyBoBA;;;eAAAA;;;;iEAzBG;gCACa;AACpC,SAASC,cAAcC,CAAC,EAAEC,CAAC;IACvB,4FAA4F;IAC5F,KAAK,MAAM,CAACC,KAAKC,KAAK,IAAIC,OAAOC,OAAO,CAACJ,GAAG;QACxC,kCAAkC;QAClC,IAAIE,QAAQG,WAAW;YACnBN,CAAC,CAACE,IAAI,GAAGC;QACb;IACJ;AACJ;AACA,MAAMI,qBAAqB;IACvBC,gBAAgBF;IAChBG,UAAU;IACVC,cAAc;IACdC,mBAAmB;IACnBC,UAAU;IACVC,SAAS;AACb;AACA,wFAAwF;AACxF,IAAIC,UAAU;AAKH,SAAShB,cAAciB,OAAO;IACrC,MAAM,EAAEC,QAAQC,OAAOC,iBAAiB,EAAE,GAAGH;IAC7C,MAAMI,gBAAgB,IAAIC;IAC1B,MAAMC,SAAS,IAAIC;IACnB,MAAMC,QAAQC,IAAAA,mCAAmB,EAAC,CAACC,IAAIC;QACnC,MAAM1B,IAAIqB,OAAOM,GAAG,CAACF;QACrB,MAAMxB,IAAIoB,OAAOM,GAAG,CAACD;QACrB,IAAI,CAAC1B,KAAK,CAACC,GAAG;YACV,OAAO;QACX;QACA,IAAID,EAAES,QAAQ,KAAKR,EAAEQ,QAAQ,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IX,cAAciC,IAAI,GAAGpC,SAASO,MAAM8B,IAAI,IAAI;gBAC5C,MAAMC,YAAYjC,OAAOM,GAAG,CAACJ,MAAMgC,OAAO;gBAC1C,IAAI,CAACD,WAAW;oBACZ;gBACJ;gBACAnC,cAAcqC,GAAG,CAACF,UAAUxB,OAAO;YACvC;YACAY;QACJ;QACA,MAAMM,QAAQ;YACV,GAAGzC,kBAAkB;YACrBwC;YACAI;YACArB;YACAe;YACAT,UAAU;YACVU;YACAlB,OAAOd;YACP2C,MAAM,CAAC;YACPC,6BAAeC,OAAMC,SAAS;QAClC;QACA7D,cAAciD,OAAOjC;QACrBhB,cAAciD,OAAOf;QACrBZ,OAAOwC,GAAG,CAAC/B,SAASkB;QACnBL,CAAAA,wBAAwB,AAACC,CAAAA,SAASI,KAAI,EAAGxC,cAAc,AAAD,MAAO,QAAQmC,0BAA0B,KAAK,IAAI,KAAK,IAAIA,sBAAsBM,IAAI,CAACL,QAAQ,MAAM;YACvJM,QAAQ;YACR,GAAGF,KAAK;QACZ;QACA,IAAI7B,cAAciC,IAAI,IAAIpC,OAAO;YAC7BO,MAAMuC,OAAO,CAAChC;QAClB,OAAO;YACHX,cAAcqC,GAAG,CAAC1B;QACtB;IACJ;IACA,OAAO;QACHW;QACAF;QACAF;QACAR;QACAG;QACAb;QACAE;IACJ;AACJ"}
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "dismissAllToasts", {
6
6
  enumerable: true,
7
- get: ()=>dismissAllToasts
7
+ get: function() {
8
+ return dismissAllToasts;
9
+ }
8
10
  });
9
11
  const _constants = require("../constants");
10
12
  function dismissAllToasts(toasterId = undefined, targetDocument) {
@@ -1 +1 @@
1
- {"version":3,"sources":["dismissAllToasts.js"],"sourcesContent":["import { EVENTS } from '../constants';\nexport function dismissAllToasts(toasterId = undefined, targetDocument) {\n const event = new CustomEvent(EVENTS.dismissAll, {\n bubbles: false,\n cancelable: false,\n detail: {\n toasterId\n }\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["dismissAllToasts","toasterId","undefined","targetDocument","event","CustomEvent","EVENTS","dismissAll","bubbles","cancelable","detail","dispatchEvent"],"mappings":";;;;+BACgBA;;aAAAA;;2BADO;AAChB,SAASA,iBAAiBC,YAAYC,SAAS,EAAEC,cAAc,EAAE;IACpE,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,UAAU,EAAE;QAC7CC,SAAS,KAAK;QACdC,YAAY,KAAK;QACjBC,QAAQ;YACJT;QACJ;IACJ;IACAE,eAAeQ,aAAa,CAACP;AACjC"}
1
+ {"version":3,"sources":["dismissAllToasts.js"],"sourcesContent":["import { EVENTS } from '../constants';\nexport function dismissAllToasts(toasterId = undefined, targetDocument) {\n const event = new CustomEvent(EVENTS.dismissAll, {\n bubbles: false,\n cancelable: false,\n detail: {\n toasterId\n }\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["dismissAllToasts","toasterId","undefined","targetDocument","event","CustomEvent","EVENTS","dismissAll","bubbles","cancelable","detail","dispatchEvent"],"mappings":";;;;+BACgBA;;;eAAAA;;;2BADO;AAChB,SAASA,iBAAiBC,YAAYC,SAAS,EAAEC,cAAc;IAClE,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,UAAU,EAAE;QAC7CC,SAAS;QACTC,YAAY;QACZC,QAAQ;YACJT;QACJ;IACJ;IACAE,eAAeQ,aAAa,CAACP;AACjC"}
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "dismissToast", {
6
6
  enumerable: true,
7
- get: ()=>dismissToast
7
+ get: function() {
8
+ return dismissToast;
9
+ }
8
10
  });
9
11
  const _constants = require("../constants");
10
12
  function dismissToast(toastId, toasterId = undefined, targetDocument) {
@@ -1 +1 @@
1
- {"version":3,"sources":["dismissToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nexport function dismissToast(toastId, toasterId = undefined, targetDocument) {\n const event = new CustomEvent(EVENTS.dismiss, {\n bubbles: false,\n cancelable: false,\n detail: {\n toastId,\n toasterId\n }\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["dismissToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","EVENTS","dismiss","bubbles","cancelable","detail","dispatchEvent"],"mappings":";;;;+BACgBA;;aAAAA;;2BADO;AAChB,SAASA,aAAaC,OAAO,EAAEC,YAAYC,SAAS,EAAEC,cAAc,EAAE;IACzE,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,OAAO,EAAE;QAC1CC,SAAS,KAAK;QACdC,YAAY,KAAK;QACjBC,QAAQ;YACJV;YACAC;QACJ;IACJ;IACAE,eAAeQ,aAAa,CAACP;AACjC"}
1
+ {"version":3,"sources":["dismissToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nexport function dismissToast(toastId, toasterId = undefined, targetDocument) {\n const event = new CustomEvent(EVENTS.dismiss, {\n bubbles: false,\n cancelable: false,\n detail: {\n toastId,\n toasterId\n }\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["dismissToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","EVENTS","dismiss","bubbles","cancelable","detail","dispatchEvent"],"mappings":";;;;+BACgBA;;;eAAAA;;;2BADO;AAChB,SAASA,aAAaC,OAAO,EAAEC,YAAYC,SAAS,EAAEC,cAAc;IACvE,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,OAAO,EAAE;QAC1CC,SAAS;QACTC,YAAY;QACZC,QAAQ;YACJV;YACAC;QACJ;IACJ;IACAE,eAAeQ,aAAa,CAACP;AACjC"}
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "dispatchToast", {
6
6
  enumerable: true,
7
- get: ()=>dispatchToast
7
+ get: function() {
8
+ return dispatchToast;
9
+ }
8
10
  });
9
11
  const _constants = require("../constants");
10
12
  let counter = 0;
@@ -1 +1 @@
1
- {"version":3,"sources":["dispatchToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nlet counter = 0;\nexport function dispatchToast(content, options = {}, targetDocument) {\n var _options_toastId;\n const detail = {\n ...options,\n content,\n toastId: (_options_toastId = options.toastId) !== null && _options_toastId !== void 0 ? _options_toastId : (counter++).toString()\n };\n const event = new CustomEvent(EVENTS.show, {\n bubbles: false,\n cancelable: false,\n detail\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["dispatchToast","counter","content","options","targetDocument","_options_toastId","detail","toastId","toString","event","CustomEvent","EVENTS","show","bubbles","cancelable","dispatchEvent"],"mappings":";;;;+BAEgBA;;aAAAA;;2BAFO;AACvB,IAAIC,UAAU;AACP,SAASD,cAAcE,OAAO,EAAEC,UAAU,CAAC,CAAC,EAAEC,cAAc,EAAE;IACjE,IAAIC;IACJ,MAAMC,SAAS;QACX,GAAGH,OAAO;QACVD;QACAK,SAAS,AAACF,CAAAA,mBAAmBF,QAAQI,OAAO,AAAD,MAAO,IAAI,IAAIF,qBAAqB,KAAK,IAAIA,mBAAmB,AAACJ,CAAAA,SAAQ,EAAGO,QAAQ,EAAE;IACrI;IACA,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,IAAI,EAAE;QACvCC,SAAS,KAAK;QACdC,YAAY,KAAK;QACjBR;IACJ;IACAF,eAAeW,aAAa,CAACN;AACjC"}
1
+ {"version":3,"sources":["dispatchToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nlet counter = 0;\nexport function dispatchToast(content, options = {}, targetDocument) {\n var _options_toastId;\n const detail = {\n ...options,\n content,\n toastId: (_options_toastId = options.toastId) !== null && _options_toastId !== void 0 ? _options_toastId : (counter++).toString()\n };\n const event = new CustomEvent(EVENTS.show, {\n bubbles: false,\n cancelable: false,\n detail\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["dispatchToast","counter","content","options","targetDocument","_options_toastId","detail","toastId","toString","event","CustomEvent","EVENTS","show","bubbles","cancelable","dispatchEvent"],"mappings":";;;;+BAEgBA;;;eAAAA;;;2BAFO;AACvB,IAAIC,UAAU;AACP,SAASD,cAAcE,OAAO,EAAEC,UAAU,CAAC,CAAC,EAAEC,cAAc;IAC/D,IAAIC;IACJ,MAAMC,SAAS;QACX,GAAGH,OAAO;QACVD;QACAK,SAAS,AAACF,CAAAA,mBAAmBF,QAAQI,OAAO,AAAD,MAAO,QAAQF,qBAAqB,KAAK,IAAIA,mBAAmB,AAACJ,CAAAA,SAAQ,EAAGO,QAAQ;IACnI;IACA,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,IAAI,EAAE;QACvCC,SAAS;QACTC,YAAY;QACZR;IACJ;IACAF,eAAeW,aAAa,CAACN;AACjC"}
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "getPositionStyles", {
6
6
  enumerable: true,
7
- get: ()=>getPositionStyles
7
+ get: function() {
8
+ return getPositionStyles;
9
+ }
8
10
  });
9
11
  const getPositionStyles = (position, dir, offset)=>{
10
12
  const positionStyles = {
@@ -12,7 +14,7 @@ const getPositionStyles = (position, dir, offset)=>{
12
14
  };
13
15
  var _offset_position;
14
16
  const offsetStyles = offset ? isShorthandOffset(offset) ? offset : (_offset_position = offset[position]) !== null && _offset_position !== void 0 ? _offset_position : {} : {};
15
- const { horizontal =20 , vertical =16 } = offsetStyles;
17
+ const { horizontal = 20, vertical = 16 } = offsetStyles;
16
18
  const start = dir === 'ltr' ? 'left' : 'right';
17
19
  const end = dir === 'ltr' ? 'right' : 'left';
18
20
  switch(position){
@@ -1 +1 @@
1
- {"version":3,"sources":["getPositionStyles.js"],"sourcesContent":["export const getPositionStyles = (position, dir, offset)=>{\n const positionStyles = {\n position: 'fixed'\n };\n var _offset_position;\n const offsetStyles = offset ? isShorthandOffset(offset) ? offset : (_offset_position = offset[position]) !== null && _offset_position !== void 0 ? _offset_position : {} : {};\n const { horizontal =20 , vertical =16 } = offsetStyles;\n const start = dir === 'ltr' ? 'left' : 'right';\n const end = dir === 'ltr' ? 'right' : 'left';\n switch(position){\n case 'top-start':\n Object.assign(positionStyles, {\n top: vertical,\n [start]: horizontal\n });\n break;\n case 'top-end':\n Object.assign(positionStyles, {\n top: vertical,\n [end]: horizontal\n });\n break;\n case 'bottom-start':\n Object.assign(positionStyles, {\n bottom: vertical,\n [start]: horizontal\n });\n break;\n case 'bottom-end':\n Object.assign(positionStyles, {\n bottom: vertical,\n [end]: horizontal\n });\n break;\n }\n return positionStyles;\n};\nfunction isShorthandOffset(offset) {\n return 'horizontal' in offset || 'vertical' in offset;\n}\n"],"names":["getPositionStyles","position","dir","offset","positionStyles","_offset_position","offsetStyles","isShorthandOffset","horizontal","vertical","start","end","Object","assign","top","bottom"],"mappings":";;;;+BAAaA;;aAAAA;;AAAN,MAAMA,oBAAoB,CAACC,UAAUC,KAAKC,SAAS;IACtD,MAAMC,iBAAiB;QACnBH,UAAU;IACd;IACA,IAAII;IACJ,MAAMC,eAAeH,SAASI,kBAAkBJ,UAAUA,SAAS,AAACE,CAAAA,mBAAmBF,MAAM,CAACF,SAAS,AAAD,MAAO,IAAI,IAAII,qBAAqB,KAAK,IAAIA,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC;IAC7K,MAAM,EAAEG,YAAY,GAAE,EAAGC,UAAU,GAAE,EAAG,GAAGH;IAC3C,MAAMI,QAAQR,QAAQ,QAAQ,SAAS,OAAO;IAC9C,MAAMS,MAAMT,QAAQ,QAAQ,UAAU,MAAM;IAC5C,OAAOD;QACH,KAAK;YACDW,OAAOC,MAAM,CAACT,gBAAgB;gBAC1BU,KAAKL;gBACL,CAACC,MAAM,EAAEF;YACb;YACA,KAAM;QACV,KAAK;YACDI,OAAOC,MAAM,CAACT,gBAAgB;gBAC1BU,KAAKL;gBACL,CAACE,IAAI,EAAEH;YACX;YACA,KAAM;QACV,KAAK;YACDI,OAAOC,MAAM,CAACT,gBAAgB;gBAC1BW,QAAQN;gBACR,CAACC,MAAM,EAAEF;YACb;YACA,KAAM;QACV,KAAK;YACDI,OAAOC,MAAM,CAACT,gBAAgB;gBAC1BW,QAAQN;gBACR,CAACE,IAAI,EAAEH;YACX;YACA,KAAM;IACd;IACA,OAAOJ;AACX;AACA,SAASG,kBAAkBJ,MAAM,EAAE;IAC/B,OAAO,gBAAgBA,UAAU,cAAcA;AACnD"}
1
+ {"version":3,"sources":["getPositionStyles.js"],"sourcesContent":["export const getPositionStyles = (position, dir, offset)=>{\n const positionStyles = {\n position: 'fixed'\n };\n var _offset_position;\n const offsetStyles = offset ? isShorthandOffset(offset) ? offset : (_offset_position = offset[position]) !== null && _offset_position !== void 0 ? _offset_position : {} : {};\n const { horizontal = 20, vertical = 16 } = offsetStyles;\n const start = dir === 'ltr' ? 'left' : 'right';\n const end = dir === 'ltr' ? 'right' : 'left';\n switch(position){\n case 'top-start':\n Object.assign(positionStyles, {\n top: vertical,\n [start]: horizontal\n });\n break;\n case 'top-end':\n Object.assign(positionStyles, {\n top: vertical,\n [end]: horizontal\n });\n break;\n case 'bottom-start':\n Object.assign(positionStyles, {\n bottom: vertical,\n [start]: horizontal\n });\n break;\n case 'bottom-end':\n Object.assign(positionStyles, {\n bottom: vertical,\n [end]: horizontal\n });\n break;\n }\n return positionStyles;\n};\nfunction isShorthandOffset(offset) {\n return 'horizontal' in offset || 'vertical' in offset;\n}\n"],"names":["getPositionStyles","position","dir","offset","positionStyles","_offset_position","offsetStyles","isShorthandOffset","horizontal","vertical","start","end","Object","assign","top","bottom"],"mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,MAAMA,oBAAoB,CAACC,UAAUC,KAAKC;IAC7C,MAAMC,iBAAiB;QACnBH,UAAU;IACd;IACA,IAAII;IACJ,MAAMC,eAAeH,SAASI,kBAAkBJ,UAAUA,SAAS,AAACE,CAAAA,mBAAmBF,MAAM,CAACF,SAAS,AAAD,MAAO,QAAQI,qBAAqB,KAAK,IAAIA,mBAAmB,CAAC,IAAI,CAAC;IAC5K,MAAM,EAAEG,aAAa,EAAE,EAAEC,WAAW,EAAE,EAAE,GAAGH;IAC3C,MAAMI,QAAQR,QAAQ,QAAQ,SAAS;IACvC,MAAMS,MAAMT,QAAQ,QAAQ,UAAU;IACtC,OAAOD;QACH,KAAK;YACDW,OAAOC,MAAM,CAACT,gBAAgB;gBAC1BU,KAAKL;gBACL,CAACC,MAAM,EAAEF;YACb;YACA;QACJ,KAAK;YACDI,OAAOC,MAAM,CAACT,gBAAgB;gBAC1BU,KAAKL;gBACL,CAACE,IAAI,EAAEH;YACX;YACA;QACJ,KAAK;YACDI,OAAOC,MAAM,CAACT,gBAAgB;gBAC1BW,QAAQN;gBACR,CAACC,MAAM,EAAEF;YACb;YACA;QACJ,KAAK;YACDI,OAAOC,MAAM,CAACT,gBAAgB;gBAC1BW,QAAQN;gBACR,CAACE,IAAI,EAAEH;YACX;YACA;IACR;IACA,OAAOJ;AACX;AACA,SAASG,kBAAkBJ,MAAM;IAC7B,OAAO,gBAAgBA,UAAU,cAAcA;AACnD"}
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
- _exportStar(require("./dispatchToast"), exports);
7
- _exportStar(require("./dismissToast"), exports);
8
- _exportStar(require("./dismissAllToasts"), exports);
9
- _exportStar(require("./updateToast"), exports);
10
- _exportStar(require("./pauseToast"), exports);
11
- _exportStar(require("./playToast"), exports);
12
- _exportStar(require("./createToaster"), exports);
13
- _exportStar(require("./getPositionStyles"), exports);
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./dispatchToast"), exports);
7
+ _export_star._(require("./dismissToast"), exports);
8
+ _export_star._(require("./dismissAllToasts"), exports);
9
+ _export_star._(require("./updateToast"), exports);
10
+ _export_star._(require("./pauseToast"), exports);
11
+ _export_star._(require("./playToast"), exports);
12
+ _export_star._(require("./createToaster"), exports);
13
+ _export_star._(require("./getPositionStyles"), exports);
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export * from './dispatchToast';\nexport * from './dismissToast';\nexport * from './dismissAllToasts';\nexport * from './updateToast';\nexport * from './pauseToast';\nexport * from './playToast';\nexport * from './createToaster';\nexport * from './getPositionStyles';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export * from './dispatchToast';\nexport * from './dismissToast';\nexport * from './dismissAllToasts';\nexport * from './updateToast';\nexport * from './pauseToast';\nexport * from './playToast';\nexport * from './createToaster';\nexport * from './getPositionStyles';\n"],"names":[],"mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA"}
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "pauseToast", {
6
6
  enumerable: true,
7
- get: ()=>pauseToast
7
+ get: function() {
8
+ return pauseToast;
9
+ }
8
10
  });
9
11
  const _constants = require("../constants");
10
12
  function pauseToast(toastId, toasterId = undefined, targetDocument) {
@@ -1 +1 @@
1
- {"version":3,"sources":["pauseToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nexport function pauseToast(toastId, toasterId = undefined, targetDocument) {\n const event = new CustomEvent(EVENTS.pause, {\n bubbles: false,\n cancelable: false,\n detail: {\n toastId,\n toasterId\n }\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["pauseToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","EVENTS","pause","bubbles","cancelable","detail","dispatchEvent"],"mappings":";;;;+BACgBA;;aAAAA;;2BADO;AAChB,SAASA,WAAWC,OAAO,EAAEC,YAAYC,SAAS,EAAEC,cAAc,EAAE;IACvE,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,KAAK,EAAE;QACxCC,SAAS,KAAK;QACdC,YAAY,KAAK;QACjBC,QAAQ;YACJV;YACAC;QACJ;IACJ;IACAE,eAAeQ,aAAa,CAACP;AACjC"}
1
+ {"version":3,"sources":["pauseToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nexport function pauseToast(toastId, toasterId = undefined, targetDocument) {\n const event = new CustomEvent(EVENTS.pause, {\n bubbles: false,\n cancelable: false,\n detail: {\n toastId,\n toasterId\n }\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["pauseToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","EVENTS","pause","bubbles","cancelable","detail","dispatchEvent"],"mappings":";;;;+BACgBA;;;eAAAA;;;2BADO;AAChB,SAASA,WAAWC,OAAO,EAAEC,YAAYC,SAAS,EAAEC,cAAc;IACrE,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,KAAK,EAAE;QACxCC,SAAS;QACTC,YAAY;QACZC,QAAQ;YACJV;YACAC;QACJ;IACJ;IACAE,eAAeQ,aAAa,CAACP;AACjC"}
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "playToast", {
6
6
  enumerable: true,
7
- get: ()=>playToast
7
+ get: function() {
8
+ return playToast;
9
+ }
8
10
  });
9
11
  const _constants = require("../constants");
10
12
  function playToast(toastId, toasterId = undefined, targetDocument) {
@@ -1 +1 @@
1
- {"version":3,"sources":["playToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nexport function playToast(toastId, toasterId = undefined, targetDocument) {\n const event = new CustomEvent(EVENTS.play, {\n bubbles: false,\n cancelable: false,\n detail: {\n toastId,\n toasterId\n }\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["playToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","EVENTS","play","bubbles","cancelable","detail","dispatchEvent"],"mappings":";;;;+BACgBA;;aAAAA;;2BADO;AAChB,SAASA,UAAUC,OAAO,EAAEC,YAAYC,SAAS,EAAEC,cAAc,EAAE;IACtE,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,IAAI,EAAE;QACvCC,SAAS,KAAK;QACdC,YAAY,KAAK;QACjBC,QAAQ;YACJV;YACAC;QACJ;IACJ;IACAE,eAAeQ,aAAa,CAACP;AACjC"}
1
+ {"version":3,"sources":["playToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nexport function playToast(toastId, toasterId = undefined, targetDocument) {\n const event = new CustomEvent(EVENTS.play, {\n bubbles: false,\n cancelable: false,\n detail: {\n toastId,\n toasterId\n }\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["playToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","EVENTS","play","bubbles","cancelable","detail","dispatchEvent"],"mappings":";;;;+BACgBA;;;eAAAA;;;2BADO;AAChB,SAASA,UAAUC,OAAO,EAAEC,YAAYC,SAAS,EAAEC,cAAc;IACpE,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,IAAI,EAAE;QACvCC,SAAS;QACTC,YAAY;QACZC,QAAQ;YACJV;YACAC;QACJ;IACJ;IACAE,eAAeQ,aAAa,CAACP;AACjC"}
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "updateToast", {
6
6
  enumerable: true,
7
- get: ()=>updateToast
7
+ get: function() {
8
+ return updateToast;
9
+ }
8
10
  });
9
11
  const _constants = require("../constants");
10
12
  function updateToast(options, targetDocument) {
@@ -1 +1 @@
1
- {"version":3,"sources":["updateToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nexport function updateToast(options, targetDocument) {\n const event = new CustomEvent(EVENTS.update, {\n bubbles: false,\n cancelable: false,\n detail: options\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["updateToast","options","targetDocument","event","CustomEvent","EVENTS","update","bubbles","cancelable","detail","dispatchEvent"],"mappings":";;;;+BACgBA;;aAAAA;;2BADO;AAChB,SAASA,YAAYC,OAAO,EAAEC,cAAc,EAAE;IACjD,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,MAAM,EAAE;QACzCC,SAAS,KAAK;QACdC,YAAY,KAAK;QACjBC,QAAQR;IACZ;IACAC,eAAeQ,aAAa,CAACP;AACjC"}
1
+ {"version":3,"sources":["updateToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nexport function updateToast(options, targetDocument) {\n const event = new CustomEvent(EVENTS.update, {\n bubbles: false,\n cancelable: false,\n detail: options\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["updateToast","options","targetDocument","event","CustomEvent","EVENTS","update","bubbles","cancelable","detail","dispatchEvent"],"mappings":";;;;+BACgBA;;;eAAAA;;;2BADO;AAChB,SAASA,YAAYC,OAAO,EAAEC,cAAc;IAC/C,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,MAAM,EAAE;QACzCC,SAAS;QACTC,YAAY;QACZC,QAAQR;IACZ;IACAC,eAAeQ,aAAa,CAACP;AACjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-toast",
3
- "version": "9.2.0",
3
+ "version": "9.2.1",
4
4
  "description": "Toast component for Fluent UI",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -36,23 +36,23 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "react-transition-group": "^4.4.1",
39
- "@fluentui/keyboard-keys": "^9.0.3",
40
- "@fluentui/react-aria": "^9.3.33",
39
+ "@fluentui/keyboard-keys": "^9.0.4",
40
+ "@fluentui/react-aria": "^9.3.34",
41
41
  "@fluentui/react-icons": "^2.0.207",
42
- "@fluentui/react-jsx-runtime": "^9.0.3",
43
- "@fluentui/react-portal": "^9.3.10",
44
- "@fluentui/react-shared-contexts": "^9.7.2",
45
- "@fluentui/react-tabster": "^9.12.5",
46
- "@fluentui/react-theme": "^9.1.11",
47
- "@fluentui/react-utilities": "^9.13.0",
42
+ "@fluentui/react-jsx-runtime": "^9.0.4",
43
+ "@fluentui/react-portal": "^9.3.11",
44
+ "@fluentui/react-shared-contexts": "^9.7.3",
45
+ "@fluentui/react-tabster": "^9.12.6",
46
+ "@fluentui/react-theme": "^9.1.12",
47
+ "@fluentui/react-utilities": "^9.13.1",
48
48
  "@griffel/react": "^1.5.14",
49
- "@swc/helpers": "^0.4.14"
49
+ "@swc/helpers": "^0.5.1"
50
50
  },
51
51
  "peerDependencies": {
52
- "@types/react": ">=16.8.0 <19.0.0",
53
- "@types/react-dom": ">=16.8.0 <19.0.0",
54
- "react": ">=16.8.0 <19.0.0",
55
- "react-dom": ">=16.8.0 <19.0.0"
52
+ "@types/react": ">=16.14.0 <19.0.0",
53
+ "@types/react-dom": ">=16.14.0 <19.0.0",
54
+ "react": ">=16.14.0 <19.0.0",
55
+ "react-dom": ">=16.14.0 <19.0.0"
56
56
  },
57
57
  "beachball": {
58
58
  "disallowedChangeTypes": [