@fluentui/react-toast 9.1.6 → 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 (212) hide show
  1. package/CHANGELOG.json +115 -1
  2. package/CHANGELOG.md +34 -2
  3. package/dist/index.d.ts +3 -2
  4. package/lib/components/AriaLive/AriaLive.js.map +1 -1
  5. package/lib/components/AriaLive/renderAriaLive.js +7 -2
  6. package/lib/components/AriaLive/renderAriaLive.js.map +1 -1
  7. package/lib/components/AriaLive/useAriaLive.js +6 -4
  8. package/lib/components/AriaLive/useAriaLive.js.map +1 -1
  9. package/lib/components/Timer/Timer.js +1 -1
  10. package/lib/components/Timer/Timer.js.map +1 -1
  11. package/lib/components/Toast/Toast.js.map +1 -1
  12. package/lib/components/Toast/renderToast.js +5 -4
  13. package/lib/components/Toast/renderToast.js.map +1 -1
  14. package/lib/components/Toast/useToast.js.map +1 -1
  15. package/lib/components/Toast/useToastContextValues.js +1 -1
  16. package/lib/components/Toast/useToastContextValues.js.map +1 -1
  17. package/lib/components/ToastBody/ToastBody.js.map +1 -1
  18. package/lib/components/ToastBody/renderToastBody.js +7 -2
  19. package/lib/components/ToastBody/renderToastBody.js.map +1 -1
  20. package/lib/components/ToastBody/useToastBody.js +1 -1
  21. package/lib/components/ToastBody/useToastBody.js.map +1 -1
  22. package/lib/components/ToastContainer/ToastContainer.js.map +1 -1
  23. package/lib/components/ToastContainer/renderToastContainer.js +12 -7
  24. package/lib/components/ToastContainer/renderToastContainer.js.map +1 -1
  25. package/lib/components/ToastContainer/useToastContainer.js +15 -15
  26. package/lib/components/ToastContainer/useToastContainer.js.map +1 -1
  27. package/lib/components/ToastContainer/useToastContainerContextValues.js +1 -1
  28. package/lib/components/ToastContainer/useToastContainerContextValues.js.map +1 -1
  29. package/lib/components/ToastFooter/ToastFooter.js.map +1 -1
  30. package/lib/components/ToastFooter/renderToastFooter.js +2 -2
  31. package/lib/components/ToastFooter/renderToastFooter.js.map +1 -1
  32. package/lib/components/ToastFooter/useToastFooter.js.map +1 -1
  33. package/lib/components/ToastTitle/ToastTitle.js.map +1 -1
  34. package/lib/components/ToastTitle/renderToastTitle.js +8 -2
  35. package/lib/components/ToastTitle/renderToastTitle.js.map +1 -1
  36. package/lib/components/ToastTitle/useToastTitle.js +1 -1
  37. package/lib/components/ToastTitle/useToastTitle.js.map +1 -1
  38. package/lib/components/ToastTitle/useToastTitleStyles.styles.js.map +1 -1
  39. package/lib/components/ToastTrigger/ToastTrigger.js.map +1 -1
  40. package/lib/components/ToastTrigger/useToastTrigger.js +8 -7
  41. package/lib/components/ToastTrigger/useToastTrigger.js.map +1 -1
  42. package/lib/components/Toaster/Toaster.js.map +1 -1
  43. package/lib/components/Toaster/Toaster.types.js.map +1 -1
  44. package/lib/components/Toaster/renderToaster.js +18 -5
  45. package/lib/components/Toaster/renderToaster.js.map +1 -1
  46. package/lib/components/Toaster/useToastAnnounce.js.map +1 -1
  47. package/lib/components/Toaster/useToaster.js +7 -6
  48. package/lib/components/Toaster/useToaster.js.map +1 -1
  49. package/lib/components/Toaster/useToasterFocusManagement.js +2 -2
  50. package/lib/components/Toaster/useToasterFocusManagement.js.map +1 -1
  51. package/lib/contexts/toastContainerContext.js.map +1 -1
  52. package/lib/state/useToastController.js +3 -2
  53. package/lib/state/useToastController.js.map +1 -1
  54. package/lib/state/useToaster.js +15 -11
  55. package/lib/state/useToaster.js.map +1 -1
  56. package/lib/state/vanilla/createToaster.js +7 -7
  57. package/lib/state/vanilla/createToaster.js.map +1 -1
  58. package/lib/state/vanilla/dismissAllToasts.js.map +1 -1
  59. package/lib/state/vanilla/dismissToast.js.map +1 -1
  60. package/lib/state/vanilla/dispatchToast.js.map +1 -1
  61. package/lib/state/vanilla/getPositionStyles.js +1 -1
  62. package/lib/state/vanilla/getPositionStyles.js.map +1 -1
  63. package/lib/state/vanilla/pauseToast.js.map +1 -1
  64. package/lib/state/vanilla/playToast.js.map +1 -1
  65. package/lib/state/vanilla/updateToast.js.map +1 -1
  66. package/lib-commonjs/AriaLive.js +2 -2
  67. package/lib-commonjs/AriaLive.js.map +1 -1
  68. package/lib-commonjs/Toast.js +2 -2
  69. package/lib-commonjs/Toast.js.map +1 -1
  70. package/lib-commonjs/ToastBody.js +2 -2
  71. package/lib-commonjs/ToastBody.js.map +1 -1
  72. package/lib-commonjs/ToastContainer.js +2 -2
  73. package/lib-commonjs/ToastContainer.js.map +1 -1
  74. package/lib-commonjs/ToastFooter.js +2 -2
  75. package/lib-commonjs/ToastFooter.js.map +1 -1
  76. package/lib-commonjs/ToastTitle.js +2 -2
  77. package/lib-commonjs/ToastTitle.js.map +1 -1
  78. package/lib-commonjs/ToastTrigger.js +2 -2
  79. package/lib-commonjs/ToastTrigger.js.map +1 -1
  80. package/lib-commonjs/Toaster.js +2 -2
  81. package/lib-commonjs/Toaster.js.map +1 -1
  82. package/lib-commonjs/components/AriaLive/AriaLive.js +7 -5
  83. package/lib-commonjs/components/AriaLive/AriaLive.js.map +1 -1
  84. package/lib-commonjs/components/AriaLive/AriaLive.types.js +2 -2
  85. package/lib-commonjs/components/AriaLive/AriaLive.types.js.map +1 -1
  86. package/lib-commonjs/components/AriaLive/index.js +6 -6
  87. package/lib-commonjs/components/AriaLive/index.js.map +1 -1
  88. package/lib-commonjs/components/AriaLive/renderAriaLive.js +13 -6
  89. package/lib-commonjs/components/AriaLive/renderAriaLive.js.map +1 -1
  90. package/lib-commonjs/components/AriaLive/useAriaLive.js +16 -12
  91. package/lib-commonjs/components/AriaLive/useAriaLive.js.map +1 -1
  92. package/lib-commonjs/components/AriaLive/useAriaLiveStyles.styles.js +7 -3
  93. package/lib-commonjs/components/AriaLive/useAriaLiveStyles.styles.js.map +1 -1
  94. package/lib-commonjs/components/Timer/Timer.js +8 -6
  95. package/lib-commonjs/components/Timer/Timer.js.map +1 -1
  96. package/lib-commonjs/components/Timer/index.js +2 -2
  97. package/lib-commonjs/components/Timer/index.js.map +1 -1
  98. package/lib-commonjs/components/Timer/useTimerStyles.styles.js +4 -2
  99. package/lib-commonjs/components/Timer/useTimerStyles.styles.js.map +1 -1
  100. package/lib-commonjs/components/Toast/Toast.js +7 -5
  101. package/lib-commonjs/components/Toast/Toast.js.map +1 -1
  102. package/lib-commonjs/components/Toast/index.js +6 -6
  103. package/lib-commonjs/components/Toast/index.js.map +1 -1
  104. package/lib-commonjs/components/Toast/renderToast.js +12 -9
  105. package/lib-commonjs/components/Toast/renderToast.js.map +1 -1
  106. package/lib-commonjs/components/Toast/useToast.js +7 -5
  107. package/lib-commonjs/components/Toast/useToast.js.map +1 -1
  108. package/lib-commonjs/components/Toast/useToastContextValues.js +4 -2
  109. package/lib-commonjs/components/Toast/useToastContextValues.js.map +1 -1
  110. package/lib-commonjs/components/Toast/useToastStyles.styles.js +8 -4
  111. package/lib-commonjs/components/Toast/useToastStyles.styles.js.map +1 -1
  112. package/lib-commonjs/components/ToastBody/ToastBody.js +7 -5
  113. package/lib-commonjs/components/ToastBody/ToastBody.js.map +1 -1
  114. package/lib-commonjs/components/ToastBody/index.js +6 -6
  115. package/lib-commonjs/components/ToastBody/index.js.map +1 -1
  116. package/lib-commonjs/components/ToastBody/renderToastBody.js +13 -6
  117. package/lib-commonjs/components/ToastBody/renderToastBody.js.map +1 -1
  118. package/lib-commonjs/components/ToastBody/useToastBody.js +11 -9
  119. package/lib-commonjs/components/ToastBody/useToastBody.js.map +1 -1
  120. package/lib-commonjs/components/ToastBody/useToastBodyStyles.styles.js +9 -5
  121. package/lib-commonjs/components/ToastBody/useToastBodyStyles.styles.js.map +1 -1
  122. package/lib-commonjs/components/ToastContainer/ToastContainer.js +7 -5
  123. package/lib-commonjs/components/ToastContainer/ToastContainer.js.map +1 -1
  124. package/lib-commonjs/components/ToastContainer/ToastContainer.types.js +2 -2
  125. package/lib-commonjs/components/ToastContainer/ToastContainer.types.js.map +1 -1
  126. package/lib-commonjs/components/ToastContainer/index.js +7 -7
  127. package/lib-commonjs/components/ToastContainer/index.js.map +1 -1
  128. package/lib-commonjs/components/ToastContainer/renderToastContainer.js +19 -12
  129. package/lib-commonjs/components/ToastContainer/renderToastContainer.js.map +1 -1
  130. package/lib-commonjs/components/ToastContainer/useToastContainer.js +42 -40
  131. package/lib-commonjs/components/ToastContainer/useToastContainer.js.map +1 -1
  132. package/lib-commonjs/components/ToastContainer/useToastContainerContextValues.js +6 -4
  133. package/lib-commonjs/components/ToastContainer/useToastContainerContextValues.js.map +1 -1
  134. package/lib-commonjs/components/ToastContainer/useToastContainerStyles.styles.js +8 -4
  135. package/lib-commonjs/components/ToastContainer/useToastContainerStyles.styles.js.map +1 -1
  136. package/lib-commonjs/components/ToastFooter/ToastFooter.js +7 -5
  137. package/lib-commonjs/components/ToastFooter/ToastFooter.js.map +1 -1
  138. package/lib-commonjs/components/ToastFooter/index.js +6 -6
  139. package/lib-commonjs/components/ToastFooter/index.js.map +1 -1
  140. package/lib-commonjs/components/ToastFooter/renderToastFooter.js +8 -6
  141. package/lib-commonjs/components/ToastFooter/renderToastFooter.js.map +1 -1
  142. package/lib-commonjs/components/ToastFooter/useToastFooter.js +7 -5
  143. package/lib-commonjs/components/ToastFooter/useToastFooter.js.map +1 -1
  144. package/lib-commonjs/components/ToastFooter/useToastFooterStyles.styles.js +7 -3
  145. package/lib-commonjs/components/ToastFooter/useToastFooterStyles.styles.js.map +1 -1
  146. package/lib-commonjs/components/ToastTitle/ToastTitle.js +7 -5
  147. package/lib-commonjs/components/ToastTitle/ToastTitle.js.map +1 -1
  148. package/lib-commonjs/components/ToastTitle/index.js +6 -6
  149. package/lib-commonjs/components/ToastTitle/index.js.map +1 -1
  150. package/lib-commonjs/components/ToastTitle/renderToastTitle.js +14 -6
  151. package/lib-commonjs/components/ToastTitle/renderToastTitle.js.map +1 -1
  152. package/lib-commonjs/components/ToastTitle/useToastTitle.js +17 -15
  153. package/lib-commonjs/components/ToastTitle/useToastTitle.js.map +1 -1
  154. package/lib-commonjs/components/ToastTitle/useToastTitleStyles.styles.js +13 -9
  155. package/lib-commonjs/components/ToastTitle/useToastTitleStyles.styles.js.map +1 -1
  156. package/lib-commonjs/components/ToastTrigger/ToastTrigger.js +5 -3
  157. package/lib-commonjs/components/ToastTrigger/ToastTrigger.js.map +1 -1
  158. package/lib-commonjs/components/ToastTrigger/ToastTrigger.types.js +2 -2
  159. package/lib-commonjs/components/ToastTrigger/ToastTrigger.types.js.map +1 -1
  160. package/lib-commonjs/components/ToastTrigger/index.js +5 -5
  161. package/lib-commonjs/components/ToastTrigger/index.js.map +1 -1
  162. package/lib-commonjs/components/ToastTrigger/renderToastTrigger.js +3 -1
  163. package/lib-commonjs/components/ToastTrigger/renderToastTrigger.js.map +1 -1
  164. package/lib-commonjs/components/ToastTrigger/useToastTrigger.js +18 -15
  165. package/lib-commonjs/components/ToastTrigger/useToastTrigger.js.map +1 -1
  166. package/lib-commonjs/components/Toaster/Toaster.js +7 -5
  167. package/lib-commonjs/components/Toaster/Toaster.js.map +1 -1
  168. package/lib-commonjs/components/Toaster/index.js +6 -6
  169. package/lib-commonjs/components/Toaster/index.js.map +1 -1
  170. package/lib-commonjs/components/Toaster/renderToaster.js +26 -11
  171. package/lib-commonjs/components/Toaster/renderToaster.js.map +1 -1
  172. package/lib-commonjs/components/Toaster/useToastAnnounce.js +8 -6
  173. package/lib-commonjs/components/Toaster/useToastAnnounce.js.map +1 -1
  174. package/lib-commonjs/components/Toaster/useToaster.js +25 -22
  175. package/lib-commonjs/components/Toaster/useToaster.js.map +1 -1
  176. package/lib-commonjs/components/Toaster/useToasterFocusManagement.js +19 -17
  177. package/lib-commonjs/components/Toaster/useToasterFocusManagement.js.map +1 -1
  178. package/lib-commonjs/components/Toaster/useToasterStyles.styles.js +7 -3
  179. package/lib-commonjs/components/Toaster/useToasterStyles.styles.js.map +1 -1
  180. package/lib-commonjs/contexts/toastContainerContext.js +8 -4
  181. package/lib-commonjs/contexts/toastContainerContext.js.map +1 -1
  182. package/lib-commonjs/index.js +93 -35
  183. package/lib-commonjs/index.js.map +1 -1
  184. package/lib-commonjs/state/constants.js +6 -2
  185. package/lib-commonjs/state/constants.js.map +1 -1
  186. package/lib-commonjs/state/index.js +10 -6
  187. package/lib-commonjs/state/index.js.map +1 -1
  188. package/lib-commonjs/state/types.js +2 -2
  189. package/lib-commonjs/state/types.js.map +1 -1
  190. package/lib-commonjs/state/useToastController.js +9 -6
  191. package/lib-commonjs/state/useToastController.js.map +1 -1
  192. package/lib-commonjs/state/useToaster.js +26 -20
  193. package/lib-commonjs/state/useToaster.js.map +1 -1
  194. package/lib-commonjs/state/vanilla/createToaster.js +14 -12
  195. package/lib-commonjs/state/vanilla/createToaster.js.map +1 -1
  196. package/lib-commonjs/state/vanilla/dismissAllToasts.js +3 -1
  197. package/lib-commonjs/state/vanilla/dismissAllToasts.js.map +1 -1
  198. package/lib-commonjs/state/vanilla/dismissToast.js +3 -1
  199. package/lib-commonjs/state/vanilla/dismissToast.js.map +1 -1
  200. package/lib-commonjs/state/vanilla/dispatchToast.js +3 -1
  201. package/lib-commonjs/state/vanilla/dispatchToast.js.map +1 -1
  202. package/lib-commonjs/state/vanilla/getPositionStyles.js +4 -2
  203. package/lib-commonjs/state/vanilla/getPositionStyles.js.map +1 -1
  204. package/lib-commonjs/state/vanilla/index.js +9 -9
  205. package/lib-commonjs/state/vanilla/index.js.map +1 -1
  206. package/lib-commonjs/state/vanilla/pauseToast.js +3 -1
  207. package/lib-commonjs/state/vanilla/pauseToast.js.map +1 -1
  208. package/lib-commonjs/state/vanilla/playToast.js +3 -1
  209. package/lib-commonjs/state/vanilla/playToast.js.map +1 -1
  210. package/lib-commonjs/state/vanilla/updateToast.js +3 -1
  211. package/lib-commonjs/state/vanilla/updateToast.js.map +1 -1
  212. package/package.json +14 -14
@@ -9,40 +9,98 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- useToastController: ()=>_state.useToastController,
13
- ToastTrigger: ()=>_toastTrigger.ToastTrigger,
14
- useToastTrigger_unstable: ()=>_toastTrigger.useToastTrigger_unstable,
15
- renderToastTrigger_unstable: ()=>_toastTrigger.renderToastTrigger_unstable,
16
- Toaster: ()=>_toaster.Toaster,
17
- useToaster_unstable: ()=>_toaster.useToaster_unstable,
18
- useToasterStyles_unstable: ()=>_toaster.useToasterStyles_unstable,
19
- renderToaster_unstable: ()=>_toaster.renderToaster_unstable,
20
- toasterClassNames: ()=>_toaster.toasterClassNames,
21
- Toast: ()=>_toast.Toast,
22
- useToastStyles_unstable: ()=>_toast.useToastStyles_unstable,
23
- useToast_unstable: ()=>_toast.useToast_unstable,
24
- renderToast_unstable: ()=>_toast.renderToast_unstable,
25
- toastClassNames: ()=>_toast.toastClassNames,
26
- ToastTitle: ()=>_toastTitle.ToastTitle,
27
- useToastTitleStyles_unstable: ()=>_toastTitle.useToastTitleStyles_unstable,
28
- useToastTitle_unstable: ()=>_toastTitle.useToastTitle_unstable,
29
- renderToastTitle_unstable: ()=>_toastTitle.renderToastTitle_unstable,
30
- toastTitleClassNames: ()=>_toastTitle.toastTitleClassNames,
31
- ToastBody: ()=>_toastBody.ToastBody,
32
- useToastBodyStyles_unstable: ()=>_toastBody.useToastBodyStyles_unstable,
33
- useToastBody_unstable: ()=>_toastBody.useToastBody_unstable,
34
- renderToastBody_unstable: ()=>_toastBody.renderToastBody_unstable,
35
- toastBodyClassNames: ()=>_toastBody.toastBodyClassNames,
36
- ToastFooter: ()=>_toastFooter.ToastFooter,
37
- useToastFooterStyles_unstable: ()=>_toastFooter.useToastFooterStyles_unstable,
38
- useToastFooter_unstable: ()=>_toastFooter.useToastFooter_unstable,
39
- renderToastFooter_unstable: ()=>_toastFooter.renderToastFooter_unstable,
40
- toastFooterClassNames: ()=>_toastFooter.toastFooterClassNames
12
+ useToastController: function() {
13
+ return _state.useToastController;
14
+ },
15
+ ToastTrigger: function() {
16
+ return _ToastTrigger.ToastTrigger;
17
+ },
18
+ useToastTrigger_unstable: function() {
19
+ return _ToastTrigger.useToastTrigger_unstable;
20
+ },
21
+ renderToastTrigger_unstable: function() {
22
+ return _ToastTrigger.renderToastTrigger_unstable;
23
+ },
24
+ Toaster: function() {
25
+ return _Toaster.Toaster;
26
+ },
27
+ useToaster_unstable: function() {
28
+ return _Toaster.useToaster_unstable;
29
+ },
30
+ useToasterStyles_unstable: function() {
31
+ return _Toaster.useToasterStyles_unstable;
32
+ },
33
+ renderToaster_unstable: function() {
34
+ return _Toaster.renderToaster_unstable;
35
+ },
36
+ toasterClassNames: function() {
37
+ return _Toaster.toasterClassNames;
38
+ },
39
+ Toast: function() {
40
+ return _Toast.Toast;
41
+ },
42
+ useToastStyles_unstable: function() {
43
+ return _Toast.useToastStyles_unstable;
44
+ },
45
+ useToast_unstable: function() {
46
+ return _Toast.useToast_unstable;
47
+ },
48
+ renderToast_unstable: function() {
49
+ return _Toast.renderToast_unstable;
50
+ },
51
+ toastClassNames: function() {
52
+ return _Toast.toastClassNames;
53
+ },
54
+ ToastTitle: function() {
55
+ return _ToastTitle.ToastTitle;
56
+ },
57
+ useToastTitleStyles_unstable: function() {
58
+ return _ToastTitle.useToastTitleStyles_unstable;
59
+ },
60
+ useToastTitle_unstable: function() {
61
+ return _ToastTitle.useToastTitle_unstable;
62
+ },
63
+ renderToastTitle_unstable: function() {
64
+ return _ToastTitle.renderToastTitle_unstable;
65
+ },
66
+ toastTitleClassNames: function() {
67
+ return _ToastTitle.toastTitleClassNames;
68
+ },
69
+ ToastBody: function() {
70
+ return _ToastBody.ToastBody;
71
+ },
72
+ useToastBodyStyles_unstable: function() {
73
+ return _ToastBody.useToastBodyStyles_unstable;
74
+ },
75
+ useToastBody_unstable: function() {
76
+ return _ToastBody.useToastBody_unstable;
77
+ },
78
+ renderToastBody_unstable: function() {
79
+ return _ToastBody.renderToastBody_unstable;
80
+ },
81
+ toastBodyClassNames: function() {
82
+ return _ToastBody.toastBodyClassNames;
83
+ },
84
+ ToastFooter: function() {
85
+ return _ToastFooter.ToastFooter;
86
+ },
87
+ useToastFooterStyles_unstable: function() {
88
+ return _ToastFooter.useToastFooterStyles_unstable;
89
+ },
90
+ useToastFooter_unstable: function() {
91
+ return _ToastFooter.useToastFooter_unstable;
92
+ },
93
+ renderToastFooter_unstable: function() {
94
+ return _ToastFooter.renderToastFooter_unstable;
95
+ },
96
+ toastFooterClassNames: function() {
97
+ return _ToastFooter.toastFooterClassNames;
98
+ }
41
99
  });
42
100
  const _state = require("./state");
43
- const _toastTrigger = require("./ToastTrigger");
44
- const _toaster = require("./Toaster");
45
- const _toast = require("./Toast");
46
- const _toastTitle = require("./ToastTitle");
47
- const _toastBody = require("./ToastBody");
48
- const _toastFooter = require("./ToastFooter");
101
+ const _ToastTrigger = require("./ToastTrigger");
102
+ const _Toaster = require("./Toaster");
103
+ const _Toast = require("./Toast");
104
+ const _ToastTitle = require("./ToastTitle");
105
+ const _ToastBody = require("./ToastBody");
106
+ const _ToastFooter = require("./ToastFooter");
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export { useToastController } from './state';\nexport { ToastTrigger, useToastTrigger_unstable, renderToastTrigger_unstable } from './ToastTrigger';\nexport { Toaster, useToaster_unstable, useToasterStyles_unstable, renderToaster_unstable, toasterClassNames } from './Toaster';\nexport { Toast, useToastStyles_unstable, useToast_unstable, renderToast_unstable, toastClassNames } from './Toast';\nexport { ToastTitle, useToastTitleStyles_unstable, useToastTitle_unstable, renderToastTitle_unstable, toastTitleClassNames } from './ToastTitle';\nexport { ToastBody, useToastBodyStyles_unstable, useToastBody_unstable, renderToastBody_unstable, toastBodyClassNames } from './ToastBody';\nexport { ToastFooter, useToastFooterStyles_unstable, useToastFooter_unstable, renderToastFooter_unstable, toastFooterClassNames } from './ToastFooter';\n"],"names":["useToastController","ToastTrigger","useToastTrigger_unstable","renderToastTrigger_unstable","Toaster","useToaster_unstable","useToasterStyles_unstable","renderToaster_unstable","toasterClassNames","Toast","useToastStyles_unstable","useToast_unstable","renderToast_unstable","toastClassNames","ToastTitle","useToastTitleStyles_unstable","useToastTitle_unstable","renderToastTitle_unstable","toastTitleClassNames","ToastBody","useToastBodyStyles_unstable","useToastBody_unstable","renderToastBody_unstable","toastBodyClassNames","ToastFooter","useToastFooterStyles_unstable","useToastFooter_unstable","renderToastFooter_unstable","toastFooterClassNames"],"mappings":";;;;;;;;;;;IAASA,kBAAkB,MAAlBA,yBAAkB;IAClBC,YAAY,MAAZA,0BAAY;IAAEC,wBAAwB,MAAxBA,sCAAwB;IAAEC,2BAA2B,MAA3BA,yCAA2B;IACnEC,OAAO,MAAPA,gBAAO;IAAEC,mBAAmB,MAAnBA,4BAAmB;IAAEC,yBAAyB,MAAzBA,kCAAyB;IAAEC,sBAAsB,MAAtBA,+BAAsB;IAAEC,iBAAiB,MAAjBA,0BAAiB;IAClGC,KAAK,MAALA,YAAK;IAAEC,uBAAuB,MAAvBA,8BAAuB;IAAEC,iBAAiB,MAAjBA,wBAAiB;IAAEC,oBAAoB,MAApBA,2BAAoB;IAAEC,eAAe,MAAfA,sBAAe;IACxFC,UAAU,MAAVA,sBAAU;IAAEC,4BAA4B,MAA5BA,wCAA4B;IAAEC,sBAAsB,MAAtBA,kCAAsB;IAAEC,yBAAyB,MAAzBA,qCAAyB;IAAEC,oBAAoB,MAApBA,gCAAoB;IACjHC,SAAS,MAATA,oBAAS;IAAEC,2BAA2B,MAA3BA,sCAA2B;IAAEC,qBAAqB,MAArBA,gCAAqB;IAAEC,wBAAwB,MAAxBA,mCAAwB;IAAEC,mBAAmB,MAAnBA,8BAAmB;IAC5GC,WAAW,MAAXA,wBAAW;IAAEC,6BAA6B,MAA7BA,0CAA6B;IAAEC,uBAAuB,MAAvBA,oCAAuB;IAAEC,0BAA0B,MAA1BA,uCAA0B;IAAEC,qBAAqB,MAArBA,kCAAqB;;uBAN5F;8BACiD;yBAC+B;uBACV;4BACyB;2BACL;6BACU"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export { useToastController } from './state';\nexport { ToastTrigger, useToastTrigger_unstable, renderToastTrigger_unstable } from './ToastTrigger';\nexport { Toaster, useToaster_unstable, useToasterStyles_unstable, renderToaster_unstable, toasterClassNames } from './Toaster';\nexport { Toast, useToastStyles_unstable, useToast_unstable, renderToast_unstable, toastClassNames } from './Toast';\nexport { ToastTitle, useToastTitleStyles_unstable, useToastTitle_unstable, renderToastTitle_unstable, toastTitleClassNames } from './ToastTitle';\nexport { ToastBody, useToastBodyStyles_unstable, useToastBody_unstable, renderToastBody_unstable, toastBodyClassNames } from './ToastBody';\nexport { ToastFooter, useToastFooterStyles_unstable, useToastFooter_unstable, renderToastFooter_unstable, toastFooterClassNames } from './ToastFooter';\n"],"names":["useToastController","ToastTrigger","useToastTrigger_unstable","renderToastTrigger_unstable","Toaster","useToaster_unstable","useToasterStyles_unstable","renderToaster_unstable","toasterClassNames","Toast","useToastStyles_unstable","useToast_unstable","renderToast_unstable","toastClassNames","ToastTitle","useToastTitleStyles_unstable","useToastTitle_unstable","renderToastTitle_unstable","toastTitleClassNames","ToastBody","useToastBodyStyles_unstable","useToastBody_unstable","renderToastBody_unstable","toastBodyClassNames","ToastFooter","useToastFooterStyles_unstable","useToastFooter_unstable","renderToastFooter_unstable","toastFooterClassNames"],"mappings":";;;;;;;;;;;IAASA,kBAAkB;eAAlBA,yBAAkB;;IAClBC,YAAY;eAAZA,0BAAY;;IAAEC,wBAAwB;eAAxBA,sCAAwB;;IAAEC,2BAA2B;eAA3BA,yCAA2B;;IACnEC,OAAO;eAAPA,gBAAO;;IAAEC,mBAAmB;eAAnBA,4BAAmB;;IAAEC,yBAAyB;eAAzBA,kCAAyB;;IAAEC,sBAAsB;eAAtBA,+BAAsB;;IAAEC,iBAAiB;eAAjBA,0BAAiB;;IAClGC,KAAK;eAALA,YAAK;;IAAEC,uBAAuB;eAAvBA,8BAAuB;;IAAEC,iBAAiB;eAAjBA,wBAAiB;;IAAEC,oBAAoB;eAApBA,2BAAoB;;IAAEC,eAAe;eAAfA,sBAAe;;IACxFC,UAAU;eAAVA,sBAAU;;IAAEC,4BAA4B;eAA5BA,wCAA4B;;IAAEC,sBAAsB;eAAtBA,kCAAsB;;IAAEC,yBAAyB;eAAzBA,qCAAyB;;IAAEC,oBAAoB;eAApBA,gCAAoB;;IACjHC,SAAS;eAATA,oBAAS;;IAAEC,2BAA2B;eAA3BA,sCAA2B;;IAAEC,qBAAqB;eAArBA,gCAAqB;;IAAEC,wBAAwB;eAAxBA,mCAAwB;;IAAEC,mBAAmB;eAAnBA,8BAAmB;;IAC5GC,WAAW;eAAXA,wBAAW;;IAAEC,6BAA6B;eAA7BA,0CAA6B;;IAAEC,uBAAuB;eAAvBA,oCAAuB;;IAAEC,0BAA0B;eAA1BA,uCAA0B;;IAAEC,qBAAqB;eAArBA,kCAAqB;;;uBAN5F;8BACiD;yBAC+B;uBACV;4BACyB;2BACL;6BACU"}
@@ -9,8 +9,12 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- EVENTS: ()=>EVENTS,
13
- TOAST_POSITIONS: ()=>TOAST_POSITIONS
12
+ EVENTS: function() {
13
+ return EVENTS;
14
+ },
15
+ TOAST_POSITIONS: function() {
16
+ return TOAST_POSITIONS;
17
+ }
14
18
  });
15
19
  const EVENTS = {
16
20
  show: 'fui-toast-show',
@@ -1 +1 @@
1
- {"version":3,"sources":["constants.js"],"sourcesContent":["export const EVENTS = {\n show: 'fui-toast-show',\n dismiss: 'fui-toast-dismiss',\n dismissAll: 'fui-toast-dismiss-all',\n update: 'fui-toast-update',\n pause: 'fui-toast-pause',\n play: 'fui-toast-play'\n};\nexport const TOAST_POSITIONS = {\n bottomEnd: 'bottom-end',\n bottomStart: 'bottom-start',\n topEnd: 'top-end',\n topStart: 'top-start'\n};\n"],"names":["EVENTS","TOAST_POSITIONS","show","dismiss","dismissAll","update","pause","play","bottomEnd","bottomStart","topEnd","topStart"],"mappings":";;;;;;;;;;;IAAaA,MAAM,MAANA;IAQAC,eAAe,MAAfA;;AARN,MAAMD,SAAS;IAClBE,MAAM;IACNC,SAAS;IACTC,YAAY;IACZC,QAAQ;IACRC,OAAO;IACPC,MAAM;AACV;AACO,MAAMN,kBAAkB;IAC3BO,WAAW;IACXC,aAAa;IACbC,QAAQ;IACRC,UAAU;AACd"}
1
+ {"version":3,"sources":["constants.js"],"sourcesContent":["export const EVENTS = {\n show: 'fui-toast-show',\n dismiss: 'fui-toast-dismiss',\n dismissAll: 'fui-toast-dismiss-all',\n update: 'fui-toast-update',\n pause: 'fui-toast-pause',\n play: 'fui-toast-play'\n};\nexport const TOAST_POSITIONS = {\n bottomEnd: 'bottom-end',\n bottomStart: 'bottom-start',\n topEnd: 'top-end',\n topStart: 'top-start'\n};\n"],"names":["EVENTS","TOAST_POSITIONS","show","dismiss","dismissAll","update","pause","play","bottomEnd","bottomStart","topEnd","topStart"],"mappings":";;;;;;;;;;;IAAaA,MAAM;eAANA;;IAQAC,eAAe;eAAfA;;;AARN,MAAMD,SAAS;IAClBE,MAAM;IACNC,SAAS;IACTC,YAAY;IACZC,QAAQ;IACRC,OAAO;IACPC,MAAM;AACV;AACO,MAAMN,kBAAkB;IAC3BO,WAAW;IACXC,aAAa;IACbC,QAAQ;IACRC,UAAU;AACd"}
@@ -9,12 +9,16 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- getPositionStyles: ()=>_vanilla.getPositionStyles,
13
- TOAST_POSITIONS: ()=>_constants.TOAST_POSITIONS
12
+ getPositionStyles: function() {
13
+ return _vanilla.getPositionStyles;
14
+ },
15
+ TOAST_POSITIONS: function() {
16
+ return _constants.TOAST_POSITIONS;
17
+ }
14
18
  });
15
- const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
16
- _exportStar(require("./types"), exports);
17
- _exportStar(require("./useToaster"), exports);
18
- _exportStar(require("./useToastController"), exports);
19
+ const _export_star = require("@swc/helpers/_/_export_star");
20
+ _export_star._(require("./types"), exports);
21
+ _export_star._(require("./useToaster"), exports);
22
+ _export_star._(require("./useToastController"), exports);
19
23
  const _vanilla = require("./vanilla");
20
24
  const _constants = require("./constants");
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export * from './types';\nexport * from './useToaster';\nexport * from './useToastController';\nexport { getPositionStyles } from './vanilla';\nexport { TOAST_POSITIONS } from './constants';\n"],"names":["getPositionStyles","TOAST_POSITIONS"],"mappings":";;;;;;;;;;;IAGSA,iBAAiB,MAAjBA,0BAAiB;IACjBC,eAAe,MAAfA,0BAAe;;;oBAJV;oBACA;oBACA;yBACoB;2BACF"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export * from './types';\nexport * from './useToaster';\nexport * from './useToastController';\nexport { getPositionStyles } from './vanilla';\nexport { TOAST_POSITIONS } from './constants';\n"],"names":["getPositionStyles","TOAST_POSITIONS"],"mappings":";;;;;;;;;;;IAGSA,iBAAiB;eAAjBA,0BAAiB;;IACjBC,eAAe;eAAfA,0BAAe;;;;uBAJV;uBACA;uBACA;yBACoB;2BACF"}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
6
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
5
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
6
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
@@ -1 +1 @@
1
- {"version":3,"sources":["types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;6DAAuB"}
1
+ {"version":3,"sources":["types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;iEAAuB"}
@@ -4,15 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useToastController", {
6
6
  enumerable: true,
7
- get: ()=>useToastController
7
+ get: function() {
8
+ return useToastController;
9
+ }
8
10
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
- 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 _reactsharedcontexts = require("@fluentui/react-shared-contexts");
12
14
  const _vanilla = require("./vanilla");
13
15
  const noop = ()=>undefined;
14
16
  function useToastController(toasterId) {
15
- const { targetDocument } = (0, _reactSharedContexts.useFluent_unstable)();
17
+ const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
16
18
  return _react.useMemo(()=>{
17
19
  if (!targetDocument) {
18
20
  return {
@@ -26,11 +28,12 @@ function useToastController(toasterId) {
26
28
  }
27
29
  return {
28
30
  dispatchToast: (content, options)=>{
31
+ var _options;
29
32
  (0, _vanilla.dispatchToast)(content, {
30
33
  ...options,
31
34
  toasterId,
32
35
  data: {
33
- root: options === null || options === void 0 ? void 0 : options.root
36
+ root: (_options = options) === null || _options === void 0 ? void 0 : _options.root
34
37
  }
35
38
  }, targetDocument);
36
39
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["useToastController.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { dispatchToast as dispatchToastVanilla, dismissToast as dismissToastVanilla, dismissAllToasts as dismissAllToastsVanilla, updateToast as updateToastVanilla, playToast as playToastVanilla, pauseToast as pauseToastVanilla } from './vanilla';\nconst noop = ()=>undefined;\n/**\n * @param toasterId - If an id is provided all imperative methods control that specific toaster\n * @returns Imperative methods to control toasts\n */ export function useToastController(toasterId) {\n const { targetDocument } = useFluent();\n return React.useMemo(()=>{\n if (!targetDocument) {\n return {\n dispatchToast: noop,\n dismissToast: noop,\n dismissAllToasts: noop,\n updateToast: noop,\n pauseToast: noop,\n playToast: noop\n };\n }\n return {\n dispatchToast: (content, options)=>{\n dispatchToastVanilla(content, {\n ...options,\n toasterId,\n data: {\n root: options === null || options === void 0 ? void 0 : options.root\n }\n }, targetDocument);\n },\n dismissToast: (toastId)=>{\n dismissToastVanilla(toastId, toasterId, targetDocument);\n },\n dismissAllToasts: ()=>{\n dismissAllToastsVanilla(toasterId, targetDocument);\n },\n updateToast: (options)=>{\n updateToastVanilla({\n ...options,\n data: {\n root: options.root\n },\n toasterId\n }, targetDocument);\n },\n pauseToast: (toastId)=>{\n pauseToastVanilla(toastId, toasterId, targetDocument);\n },\n playToast: (toastId)=>{\n playToastVanilla(toastId, toasterId, targetDocument);\n }\n };\n }, [\n targetDocument,\n toasterId\n ]);\n}\n"],"names":["useToastController","noop","undefined","toasterId","targetDocument","useFluent","React","useMemo","dispatchToast","dismissToast","dismissAllToasts","updateToast","pauseToast","playToast","content","options","dispatchToastVanilla","data","root","toastId","dismissToastVanilla","dismissAllToastsVanilla","updateToastVanilla","pauseToastVanilla","playToastVanilla"],"mappings":";;;;+BAOoBA;;aAAAA;;;6DAPG;qCACyB;yBAC2L;AAC3O,MAAMC,OAAO,IAAIC;AAIN,SAASF,mBAAmBG,SAAS,EAAE;IAC9C,MAAM,EAAEC,eAAc,EAAG,GAAGC,IAAAA,uCAAS;IACrC,OAAOC,OAAMC,OAAO,CAAC,IAAI;QACrB,IAAI,CAACH,gBAAgB;YACjB,OAAO;gBACHI,eAAeP;gBACfQ,cAAcR;gBACdS,kBAAkBT;gBAClBU,aAAaV;gBACbW,YAAYX;gBACZY,WAAWZ;YACf;QACJ,CAAC;QACD,OAAO;YACHO,eAAe,CAACM,SAASC,UAAU;gBAC/BC,IAAAA,sBAAoB,EAACF,SAAS;oBAC1B,GAAGC,OAAO;oBACVZ;oBACAc,MAAM;wBACFC,MAAMH,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQG,IAAI;oBACxE;gBACJ,GAAGd;YACP;YACAK,cAAc,CAACU,UAAU;gBACrBC,IAAAA,qBAAmB,EAACD,SAAShB,WAAWC;YAC5C;YACAM,kBAAkB,IAAI;gBAClBW,IAAAA,yBAAuB,EAAClB,WAAWC;YACvC;YACAO,aAAa,CAACI,UAAU;gBACpBO,IAAAA,oBAAkB,EAAC;oBACf,GAAGP,OAAO;oBACVE,MAAM;wBACFC,MAAMH,QAAQG,IAAI;oBACtB;oBACAf;gBACJ,GAAGC;YACP;YACAQ,YAAY,CAACO,UAAU;gBACnBI,IAAAA,mBAAiB,EAACJ,SAAShB,WAAWC;YAC1C;YACAS,WAAW,CAACM,UAAU;gBAClBK,IAAAA,kBAAgB,EAACL,SAAShB,WAAWC;YACzC;QACJ;IACJ,GAAG;QACCA;QACAD;KACH;AACL"}
1
+ {"version":3,"sources":["useToastController.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { dispatchToast as dispatchToastVanilla, dismissToast as dismissToastVanilla, dismissAllToasts as dismissAllToastsVanilla, updateToast as updateToastVanilla, playToast as playToastVanilla, pauseToast as pauseToastVanilla } from './vanilla';\nconst noop = ()=>undefined;\n/**\n * @param toasterId - If an id is provided all imperative methods control that specific toaster\n * @returns Imperative methods to control toasts\n */ export function useToastController(toasterId) {\n const { targetDocument } = useFluent();\n return React.useMemo(()=>{\n if (!targetDocument) {\n return {\n dispatchToast: noop,\n dismissToast: noop,\n dismissAllToasts: noop,\n updateToast: noop,\n pauseToast: noop,\n playToast: noop\n };\n }\n return {\n dispatchToast: (content, options)=>{\n var _options;\n dispatchToastVanilla(content, {\n ...options,\n toasterId,\n data: {\n root: (_options = options) === null || _options === void 0 ? void 0 : _options.root\n }\n }, targetDocument);\n },\n dismissToast: (toastId)=>{\n dismissToastVanilla(toastId, toasterId, targetDocument);\n },\n dismissAllToasts: ()=>{\n dismissAllToastsVanilla(toasterId, targetDocument);\n },\n updateToast: (options)=>{\n updateToastVanilla({\n ...options,\n data: {\n root: options.root\n },\n toasterId\n }, targetDocument);\n },\n pauseToast: (toastId)=>{\n pauseToastVanilla(toastId, toasterId, targetDocument);\n },\n playToast: (toastId)=>{\n playToastVanilla(toastId, toasterId, targetDocument);\n }\n };\n }, [\n targetDocument,\n toasterId\n ]);\n}\n"],"names":["useToastController","noop","undefined","toasterId","targetDocument","useFluent","React","useMemo","dispatchToast","dismissToast","dismissAllToasts","updateToast","pauseToast","playToast","content","options","_options","dispatchToastVanilla","data","root","toastId","dismissToastVanilla","dismissAllToastsVanilla","updateToastVanilla","pauseToastVanilla","playToastVanilla"],"mappings":";;;;+BAOoBA;;;eAAAA;;;;iEAPG;qCACyB;yBAC2L;AAC3O,MAAMC,OAAO,IAAIC;AAIN,SAASF,mBAAmBG,SAAS;IAC5C,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,OAAOC,OAAMC,OAAO,CAAC;QACjB,IAAI,CAACH,gBAAgB;YACjB,OAAO;gBACHI,eAAeP;gBACfQ,cAAcR;gBACdS,kBAAkBT;gBAClBU,aAAaV;gBACbW,YAAYX;gBACZY,WAAWZ;YACf;QACJ;QACA,OAAO;YACHO,eAAe,CAACM,SAASC;gBACrB,IAAIC;gBACJC,IAAAA,sBAAoB,EAACH,SAAS;oBAC1B,GAAGC,OAAO;oBACVZ;oBACAe,MAAM;wBACFC,MAAM,AAACH,CAAAA,WAAWD,OAAM,MAAO,QAAQC,aAAa,KAAK,IAAI,KAAK,IAAIA,SAASG,IAAI;oBACvF;gBACJ,GAAGf;YACP;YACAK,cAAc,CAACW;gBACXC,IAAAA,qBAAmB,EAACD,SAASjB,WAAWC;YAC5C;YACAM,kBAAkB;gBACdY,IAAAA,yBAAuB,EAACnB,WAAWC;YACvC;YACAO,aAAa,CAACI;gBACVQ,IAAAA,oBAAkB,EAAC;oBACf,GAAGR,OAAO;oBACVG,MAAM;wBACFC,MAAMJ,QAAQI,IAAI;oBACtB;oBACAhB;gBACJ,GAAGC;YACP;YACAQ,YAAY,CAACQ;gBACTI,IAAAA,mBAAiB,EAACJ,SAASjB,WAAWC;YAC1C;YACAS,WAAW,CAACO;gBACRK,IAAAA,kBAAgB,EAACL,SAASjB,WAAWC;YACzC;QACJ;IACJ,GAAG;QACCA;QACAD;KACH;AACL"}
@@ -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,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GAAG4C,IAAAA,6BAAa,EAAC/D,eAAegE,aAAa,IAAIhE,eAAegE,aAAa,GAAG,IAAI;oBAC/GF,CAAAA,yCAAyC9B,gBAAgBd,aAAa,CAACC,OAAO,AAAD,MAAO,IAAI,IAAI2C,2CAA2C,KAAK,IAAI,KAAK,IAAIA,uCAAuCtD,KAAK,EAAE;gBAC5M,CAAC;YACL,CAAC;QACL;QACAR,eAAe0C,gBAAgB,CAAC,WAAWmB;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,CA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IAAIA,uCAAuCxD,KAAK;gBAC1M;YACJ;QACJ;QACAT,eAAe6C,gBAAgB,CAAC,WAAWmB;QAC3C,OAAO;YACHX;YACAO;YACAJ;YACAE;YACAI;YACAC;YACA/D,eAAe8C,mBAAmB,CAAC,WAAWkB;QAClD;IACJ,GAAG;QACCpE;QACAL;QACAS;QACAI;QACAM;QACAe;QACAnB;KACH;IACD,MAAM8D,iBAAiB,AAAC,CAAA;QACpB,IAAI,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","dequeue","add","data","imperativeRef","React","createRef","set","enqueue"],"mappings":";;;;+BAyBoBA;;aAAAA;;;6DAzBG;gCACa;AACpC,SAASC,cAAcC,CAAC,EAAEC,CAAC,EAAE;IACzB,4FAA4F;IAC5F,KAAK,MAAM,CAACC,KAAKC,KAAK,IAAIC,OAAOC,OAAO,CAACJ,GAAG;QACxC,kCAAkC;QAClC,IAAIE,QAAQG,WAAW;YACnBN,CAAC,CAACE,IAAI,GAAGC;QACb,CAAC;IACL;AACJ;AACA,MAAMI,qBAAqB;IACvBC,gBAAgBF;IAChBG,UAAU;IACVC,cAAc,KAAK;IACnBC,mBAAmB,KAAK;IACxBC,UAAU;IACVC,SAAS;AACb;AACA,wFAAwF;AACxF,IAAIC,UAAU;AAKH,SAAShB,cAAciB,OAAO,EAAE;IACvC,MAAM,EAAEC,OAAOC,OAAOC,iBAAiB,CAAA,EAAG,GAAGH;IAC7C,MAAMI,gBAAgB,IAAIC;IAC1B,MAAMC,SAAS,IAAIC;IACnB,MAAMC,QAAQC,IAAAA,mCAAmB,EAAC,CAACC,IAAIC,KAAK;QACxC,MAAM1B,IAAIqB,OAAOM,GAAG,CAACF;QACrB,MAAMxB,IAAIoB,OAAOM,GAAG,CAACD;QACrB,IAAI,CAAC1B,KAAK,CAACC,GAAG;YACV,OAAO;QACX,CAAC;QACD,IAAID,EAAES,QAAQ,KAAKR,EAAEQ,QAAQ,EAAE;YAC3B,OAAOT,EAAE4B,KAAK,GAAG3B,EAAE2B,KAAK;QAC5B,CAAC;QACD,OAAO5B,EA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B,IAAI,IAAI;gBAC5C,MAAMC,YAAYhC,OAAOM,GAAG,CAACJ,MAAM+B,OAAO;gBAC1C,IAAI,CAACD,WAAW;oBACZ;gBACJ,CAAC;gBACDlC,cAAcoC,GAAG,CAACF,UAAUvB,OAAO;YACvC,CAAC;YACDY;QACJ;QACA,MAAMK,QAAQ;YACV,GAAGxC,kBAAkB;YACrBuC;YACAI;YACApB;YACAc;YACAR,UAAU;YACVS;YACAjB,OAAOd;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,gB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AAGxC,cAAc,AAAD,MAAO,QAAQmC,0BAA0B,KAAK,IAAI,KAAK,IAAIA,sBAAsBM,IAAI,CAACL,QAAQ,MAAM;gBACvJM,QAAQ;gBACR,GAAGF,KAAK;YACZ;QACJ;QACA,MAAMG,SAAS;YACX,MAAMH,QAAQ3B,OAAOM,GAAG,CAACG;YACzB,IAAI,CAACkB,OAAO;gBACR;YACJ;YACA3B,OAAOiB,MAAM,CAACR;YACd,IAAIX,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"}