@fluentui/react-toast 0.0.0-nightly-20230704-0416.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 (310) hide show
  1. package/CHANGELOG.json +161 -0
  2. package/CHANGELOG.md +56 -0
  3. package/LICENSE +15 -0
  4. package/README.md +5 -0
  5. package/dist/index.d.ts +485 -0
  6. package/lib/AriaLive.js +1 -0
  7. package/lib/AriaLive.js.map +1 -0
  8. package/lib/Toast.js +1 -0
  9. package/lib/Toast.js.map +1 -0
  10. package/lib/ToastBody.js +1 -0
  11. package/lib/ToastBody.js.map +1 -0
  12. package/lib/ToastContainer.js +1 -0
  13. package/lib/ToastContainer.js.map +1 -0
  14. package/lib/ToastFooter.js +1 -0
  15. package/lib/ToastFooter.js.map +1 -0
  16. package/lib/ToastTitle.js +1 -0
  17. package/lib/ToastTitle.js.map +1 -0
  18. package/lib/ToastTrigger.js +1 -0
  19. package/lib/ToastTrigger.js.map +1 -0
  20. package/lib/Toaster.js +1 -0
  21. package/lib/Toaster.js.map +1 -0
  22. package/lib/components/AriaLive/AriaLive.js +12 -0
  23. package/lib/components/AriaLive/AriaLive.js.map +1 -0
  24. package/lib/components/AriaLive/AriaLive.types.js +1 -0
  25. package/lib/components/AriaLive/AriaLive.types.js.map +1 -0
  26. package/lib/components/AriaLive/index.js +5 -0
  27. package/lib/components/AriaLive/index.js.map +1 -0
  28. package/lib/components/AriaLive/renderAriaLive.js +8 -0
  29. package/lib/components/AriaLive/renderAriaLive.js.map +1 -0
  30. package/lib/components/AriaLive/useAriaLive.js +73 -0
  31. package/lib/components/AriaLive/useAriaLive.js.map +1 -0
  32. package/lib/components/AriaLive/useAriaLiveStyles.styles.js +19 -0
  33. package/lib/components/AriaLive/useAriaLiveStyles.styles.js.map +1 -0
  34. package/lib/components/Timer/Timer.js +21 -0
  35. package/lib/components/Timer/Timer.js.map +1 -0
  36. package/lib/components/Timer/index.js +1 -0
  37. package/lib/components/Timer/index.js.map +1 -0
  38. package/lib/components/Timer/useTimerStyles.styles.js +3 -0
  39. package/lib/components/Timer/useTimerStyles.styles.js.map +1 -0
  40. package/lib/components/Toast/Toast.js +13 -0
  41. package/lib/components/Toast/Toast.js.map +1 -0
  42. package/lib/components/Toast/Toast.types.js +1 -0
  43. package/lib/components/Toast/Toast.types.js.map +1 -0
  44. package/lib/components/Toast/index.js +5 -0
  45. package/lib/components/Toast/index.js.map +1 -0
  46. package/lib/components/Toast/renderToast.js +11 -0
  47. package/lib/components/Toast/renderToast.js.map +1 -0
  48. package/lib/components/Toast/useToast.js +22 -0
  49. package/lib/components/Toast/useToast.js.map +1 -0
  50. package/lib/components/Toast/useToastContextValues.js +6 -0
  51. package/lib/components/Toast/useToastContextValues.js.map +1 -0
  52. package/lib/components/Toast/useToastStyles.styles.js +24 -0
  53. package/lib/components/Toast/useToastStyles.styles.js.map +1 -0
  54. package/lib/components/ToastBody/ToastBody.js +12 -0
  55. package/lib/components/ToastBody/ToastBody.js.map +1 -0
  56. package/lib/components/ToastBody/ToastBody.types.js +1 -0
  57. package/lib/components/ToastBody/ToastBody.types.js.map +1 -0
  58. package/lib/components/ToastBody/index.js +5 -0
  59. package/lib/components/ToastBody/index.js.map +1 -0
  60. package/lib/components/ToastBody/renderToastBody.js +8 -0
  61. package/lib/components/ToastBody/renderToastBody.js.map +1 -0
  62. package/lib/components/ToastBody/useToastBody.js +29 -0
  63. package/lib/components/ToastBody/useToastBody.js.map +1 -0
  64. package/lib/components/ToastBody/useToastBodyStyles.styles.js +32 -0
  65. package/lib/components/ToastBody/useToastBodyStyles.styles.js.map +1 -0
  66. package/lib/components/ToastContainer/ToastContainer.js +13 -0
  67. package/lib/components/ToastContainer/ToastContainer.js.map +1 -0
  68. package/lib/components/ToastContainer/ToastContainer.types.js +1 -0
  69. package/lib/components/ToastContainer/ToastContainer.types.js.map +1 -0
  70. package/lib/components/ToastContainer/index.js +6 -0
  71. package/lib/components/ToastContainer/index.js.map +1 -0
  72. package/lib/components/ToastContainer/renderToastContainer.js +21 -0
  73. package/lib/components/ToastContainer/renderToastContainer.js.map +1 -0
  74. package/lib/components/ToastContainer/useToastContainer.js +219 -0
  75. package/lib/components/ToastContainer/useToastContainer.js.map +1 -0
  76. package/lib/components/ToastContainer/useToastContainerContextValues.js +18 -0
  77. package/lib/components/ToastContainer/useToastContainerContextValues.js.map +1 -0
  78. package/lib/components/ToastContainer/useToastContainerStyles.styles.js +36 -0
  79. package/lib/components/ToastContainer/useToastContainerStyles.styles.js.map +1 -0
  80. package/lib/components/ToastFooter/ToastFooter.js +12 -0
  81. package/lib/components/ToastFooter/ToastFooter.js.map +1 -0
  82. package/lib/components/ToastFooter/ToastFooter.types.js +1 -0
  83. package/lib/components/ToastFooter/ToastFooter.types.js.map +1 -0
  84. package/lib/components/ToastFooter/index.js +5 -0
  85. package/lib/components/ToastFooter/index.js.map +1 -0
  86. package/lib/components/ToastFooter/renderToastFooter.js +8 -0
  87. package/lib/components/ToastFooter/renderToastFooter.js.map +1 -0
  88. package/lib/components/ToastFooter/useToastFooter.js +21 -0
  89. package/lib/components/ToastFooter/useToastFooter.js.map +1 -0
  90. package/lib/components/ToastFooter/useToastFooterStyles.styles.js +17 -0
  91. package/lib/components/ToastFooter/useToastFooterStyles.styles.js.map +1 -0
  92. package/lib/components/ToastTitle/ToastTitle.js +12 -0
  93. package/lib/components/ToastTitle/ToastTitle.js.map +1 -0
  94. package/lib/components/ToastTitle/ToastTitle.types.js +1 -0
  95. package/lib/components/ToastTitle/ToastTitle.types.js.map +1 -0
  96. package/lib/components/ToastTitle/index.js +5 -0
  97. package/lib/components/ToastTitle/index.js.map +1 -0
  98. package/lib/components/ToastTitle/renderToastTitle.js +8 -0
  99. package/lib/components/ToastTitle/renderToastTitle.js.map +1 -0
  100. package/lib/components/ToastTitle/useToastTitle.js +54 -0
  101. package/lib/components/ToastTitle/useToastTitle.js.map +1 -0
  102. package/lib/components/ToastTitle/useToastTitleStyles.styles.js +78 -0
  103. package/lib/components/ToastTitle/useToastTitleStyles.styles.js.map +1 -0
  104. package/lib/components/ToastTrigger/ToastTrigger.js +10 -0
  105. package/lib/components/ToastTrigger/ToastTrigger.js.map +1 -0
  106. package/lib/components/ToastTrigger/ToastTrigger.types.js +1 -0
  107. package/lib/components/ToastTrigger/ToastTrigger.types.js.map +1 -0
  108. package/lib/components/ToastTrigger/index.js +4 -0
  109. package/lib/components/ToastTrigger/index.js.map +1 -0
  110. package/lib/components/ToastTrigger/renderToastTrigger.js +5 -0
  111. package/lib/components/ToastTrigger/renderToastTrigger.js.map +1 -0
  112. package/lib/components/ToastTrigger/useToastTrigger.js +36 -0
  113. package/lib/components/ToastTrigger/useToastTrigger.js.map +1 -0
  114. package/lib/components/Toaster/Toaster.js +12 -0
  115. package/lib/components/Toaster/Toaster.js.map +1 -0
  116. package/lib/components/Toaster/Toaster.types.js +1 -0
  117. package/lib/components/Toaster/Toaster.types.js.map +1 -0
  118. package/lib/components/Toaster/index.js +5 -0
  119. package/lib/components/Toaster/index.js.map +1 -0
  120. package/lib/components/Toaster/renderToaster.js +14 -0
  121. package/lib/components/Toaster/renderToaster.js.map +1 -0
  122. package/lib/components/Toaster/useToaster.js +76 -0
  123. package/lib/components/Toaster/useToaster.js.map +1 -0
  124. package/lib/components/Toaster/useToasterStyles.styles.js +43 -0
  125. package/lib/components/Toaster/useToasterStyles.styles.js.map +1 -0
  126. package/lib/contexts/toastContainerContext.js +11 -0
  127. package/lib/contexts/toastContainerContext.js.map +1 -0
  128. package/lib/index.js +7 -0
  129. package/lib/index.js.map +1 -0
  130. package/lib/state/constants.js +14 -0
  131. package/lib/state/constants.js.map +1 -0
  132. package/lib/state/index.js +5 -0
  133. package/lib/state/index.js.map +1 -0
  134. package/lib/state/types.js +1 -0
  135. package/lib/state/types.js.map +1 -0
  136. package/lib/state/useToastController.js +57 -0
  137. package/lib/state/useToastController.js.map +1 -0
  138. package/lib/state/useToaster.js +162 -0
  139. package/lib/state/useToaster.js.map +1 -0
  140. package/lib/state/vanilla/createToaster.js +137 -0
  141. package/lib/state/vanilla/createToaster.js.map +1 -0
  142. package/lib/state/vanilla/dismissAllToasts.js +11 -0
  143. package/lib/state/vanilla/dismissAllToasts.js.map +1 -0
  144. package/lib/state/vanilla/dismissToast.js +12 -0
  145. package/lib/state/vanilla/dismissToast.js.map +1 -0
  146. package/lib/state/vanilla/dispatchToast.js +16 -0
  147. package/lib/state/vanilla/dispatchToast.js.map +1 -0
  148. package/lib/state/vanilla/getPositionStyles.js +40 -0
  149. package/lib/state/vanilla/getPositionStyles.js.map +1 -0
  150. package/lib/state/vanilla/index.js +8 -0
  151. package/lib/state/vanilla/index.js.map +1 -0
  152. package/lib/state/vanilla/pauseToast.js +12 -0
  153. package/lib/state/vanilla/pauseToast.js.map +1 -0
  154. package/lib/state/vanilla/playToast.js +12 -0
  155. package/lib/state/vanilla/playToast.js.map +1 -0
  156. package/lib/state/vanilla/updateToast.js +9 -0
  157. package/lib/state/vanilla/updateToast.js.map +1 -0
  158. package/lib-commonjs/AriaLive.js +6 -0
  159. package/lib-commonjs/AriaLive.js.map +1 -0
  160. package/lib-commonjs/Toast.js +6 -0
  161. package/lib-commonjs/Toast.js.map +1 -0
  162. package/lib-commonjs/ToastBody.js +6 -0
  163. package/lib-commonjs/ToastBody.js.map +1 -0
  164. package/lib-commonjs/ToastContainer.js +6 -0
  165. package/lib-commonjs/ToastContainer.js.map +1 -0
  166. package/lib-commonjs/ToastFooter.js +6 -0
  167. package/lib-commonjs/ToastFooter.js.map +1 -0
  168. package/lib-commonjs/ToastTitle.js +6 -0
  169. package/lib-commonjs/ToastTitle.js.map +1 -0
  170. package/lib-commonjs/ToastTrigger.js +6 -0
  171. package/lib-commonjs/ToastTrigger.js.map +1 -0
  172. package/lib-commonjs/Toaster.js +6 -0
  173. package/lib-commonjs/Toaster.js.map +1 -0
  174. package/lib-commonjs/components/AriaLive/AriaLive.js +19 -0
  175. package/lib-commonjs/components/AriaLive/AriaLive.js.map +1 -0
  176. package/lib-commonjs/components/AriaLive/AriaLive.types.js +6 -0
  177. package/lib-commonjs/components/AriaLive/AriaLive.types.js.map +1 -0
  178. package/lib-commonjs/components/AriaLive/index.js +10 -0
  179. package/lib-commonjs/components/AriaLive/index.js.map +1 -0
  180. package/lib-commonjs/components/AriaLive/renderAriaLive.js +14 -0
  181. package/lib-commonjs/components/AriaLive/renderAriaLive.js.map +1 -0
  182. package/lib-commonjs/components/AriaLive/useAriaLive.js +75 -0
  183. package/lib-commonjs/components/AriaLive/useAriaLive.js.map +1 -0
  184. package/lib-commonjs/components/AriaLive/useAriaLiveStyles.styles.js +31 -0
  185. package/lib-commonjs/components/AriaLive/useAriaLiveStyles.styles.js.map +1 -0
  186. package/lib-commonjs/components/Timer/Timer.js +30 -0
  187. package/lib-commonjs/components/Timer/Timer.js.map +1 -0
  188. package/lib-commonjs/components/Timer/index.js +6 -0
  189. package/lib-commonjs/components/Timer/index.js.map +1 -0
  190. package/lib-commonjs/components/Timer/useTimerStyles.styles.js +16 -0
  191. package/lib-commonjs/components/Timer/useTimerStyles.styles.js.map +1 -0
  192. package/lib-commonjs/components/Toast/Toast.js +20 -0
  193. package/lib-commonjs/components/Toast/Toast.js.map +1 -0
  194. package/lib-commonjs/components/Toast/Toast.types.js +4 -0
  195. package/lib-commonjs/components/Toast/Toast.types.js.map +1 -0
  196. package/lib-commonjs/components/Toast/index.js +10 -0
  197. package/lib-commonjs/components/Toast/index.js.map +1 -0
  198. package/lib-commonjs/components/Toast/renderToast.js +17 -0
  199. package/lib-commonjs/components/Toast/renderToast.js.map +1 -0
  200. package/lib-commonjs/components/Toast/useToast.js +23 -0
  201. package/lib-commonjs/components/Toast/useToast.js.map +1 -0
  202. package/lib-commonjs/components/Toast/useToastContextValues.js +14 -0
  203. package/lib-commonjs/components/Toast/useToastContextValues.js.map +1 -0
  204. package/lib-commonjs/components/Toast/useToastStyles.styles.js +39 -0
  205. package/lib-commonjs/components/Toast/useToastStyles.styles.js.map +1 -0
  206. package/lib-commonjs/components/ToastBody/ToastBody.js +19 -0
  207. package/lib-commonjs/components/ToastBody/ToastBody.js.map +1 -0
  208. package/lib-commonjs/components/ToastBody/ToastBody.types.js +4 -0
  209. package/lib-commonjs/components/ToastBody/ToastBody.types.js.map +1 -0
  210. package/lib-commonjs/components/ToastBody/index.js +10 -0
  211. package/lib-commonjs/components/ToastBody/index.js.map +1 -0
  212. package/lib-commonjs/components/ToastBody/renderToastBody.js +14 -0
  213. package/lib-commonjs/components/ToastBody/renderToastBody.js.map +1 -0
  214. package/lib-commonjs/components/ToastBody/useToastBody.js +30 -0
  215. package/lib-commonjs/components/ToastBody/useToastBody.js.map +1 -0
  216. package/lib-commonjs/components/ToastBody/useToastBodyStyles.styles.js +47 -0
  217. package/lib-commonjs/components/ToastBody/useToastBodyStyles.styles.js.map +1 -0
  218. package/lib-commonjs/components/ToastContainer/ToastContainer.js +20 -0
  219. package/lib-commonjs/components/ToastContainer/ToastContainer.js.map +1 -0
  220. package/lib-commonjs/components/ToastContainer/ToastContainer.types.js +6 -0
  221. package/lib-commonjs/components/ToastContainer/ToastContainer.types.js.map +1 -0
  222. package/lib-commonjs/components/ToastContainer/index.js +11 -0
  223. package/lib-commonjs/components/ToastContainer/index.js.map +1 -0
  224. package/lib-commonjs/components/ToastContainer/renderToastContainer.js +27 -0
  225. package/lib-commonjs/components/ToastContainer/renderToastContainer.js.map +1 -0
  226. package/lib-commonjs/components/ToastContainer/useToastContainer.js +220 -0
  227. package/lib-commonjs/components/ToastContainer/useToastContainer.js.map +1 -0
  228. package/lib-commonjs/components/ToastContainer/useToastContainerContextValues.js +27 -0
  229. package/lib-commonjs/components/ToastContainer/useToastContainerContextValues.js.map +1 -0
  230. package/lib-commonjs/components/ToastContainer/useToastContainerStyles.styles.js +64 -0
  231. package/lib-commonjs/components/ToastContainer/useToastContainerStyles.styles.js.map +1 -0
  232. package/lib-commonjs/components/ToastFooter/ToastFooter.js +19 -0
  233. package/lib-commonjs/components/ToastFooter/ToastFooter.js.map +1 -0
  234. package/lib-commonjs/components/ToastFooter/ToastFooter.types.js +4 -0
  235. package/lib-commonjs/components/ToastFooter/ToastFooter.types.js.map +1 -0
  236. package/lib-commonjs/components/ToastFooter/index.js +10 -0
  237. package/lib-commonjs/components/ToastFooter/index.js.map +1 -0
  238. package/lib-commonjs/components/ToastFooter/renderToastFooter.js +14 -0
  239. package/lib-commonjs/components/ToastFooter/renderToastFooter.js.map +1 -0
  240. package/lib-commonjs/components/ToastFooter/useToastFooter.js +22 -0
  241. package/lib-commonjs/components/ToastFooter/useToastFooter.js.map +1 -0
  242. package/lib-commonjs/components/ToastFooter/useToastFooterStyles.styles.js +28 -0
  243. package/lib-commonjs/components/ToastFooter/useToastFooterStyles.styles.js.map +1 -0
  244. package/lib-commonjs/components/ToastTitle/ToastTitle.js +19 -0
  245. package/lib-commonjs/components/ToastTitle/ToastTitle.js.map +1 -0
  246. package/lib-commonjs/components/ToastTitle/ToastTitle.types.js +4 -0
  247. package/lib-commonjs/components/ToastTitle/ToastTitle.types.js.map +1 -0
  248. package/lib-commonjs/components/ToastTitle/index.js +10 -0
  249. package/lib-commonjs/components/ToastTitle/index.js.map +1 -0
  250. package/lib-commonjs/components/ToastTitle/renderToastTitle.js +14 -0
  251. package/lib-commonjs/components/ToastTitle/renderToastTitle.js.map +1 -0
  252. package/lib-commonjs/components/ToastTitle/useToastTitle.js +55 -0
  253. package/lib-commonjs/components/ToastTitle/useToastTitle.js.map +1 -0
  254. package/lib-commonjs/components/ToastTitle/useToastTitleStyles.styles.js +107 -0
  255. package/lib-commonjs/components/ToastTitle/useToastTitleStyles.styles.js.map +1 -0
  256. package/lib-commonjs/components/ToastTrigger/ToastTrigger.js +17 -0
  257. package/lib-commonjs/components/ToastTrigger/ToastTrigger.js.map +1 -0
  258. package/lib-commonjs/components/ToastTrigger/ToastTrigger.types.js +6 -0
  259. package/lib-commonjs/components/ToastTrigger/ToastTrigger.types.js.map +1 -0
  260. package/lib-commonjs/components/ToastTrigger/index.js +9 -0
  261. package/lib-commonjs/components/ToastTrigger/index.js.map +1 -0
  262. package/lib-commonjs/components/ToastTrigger/renderToastTrigger.js +13 -0
  263. package/lib-commonjs/components/ToastTrigger/renderToastTrigger.js.map +1 -0
  264. package/lib-commonjs/components/ToastTrigger/useToastTrigger.js +37 -0
  265. package/lib-commonjs/components/ToastTrigger/useToastTrigger.js.map +1 -0
  266. package/lib-commonjs/components/Toaster/Toaster.js +19 -0
  267. package/lib-commonjs/components/Toaster/Toaster.js.map +1 -0
  268. package/lib-commonjs/components/Toaster/Toaster.types.js +4 -0
  269. package/lib-commonjs/components/Toaster/Toaster.types.js.map +1 -0
  270. package/lib-commonjs/components/Toaster/index.js +10 -0
  271. package/lib-commonjs/components/Toaster/index.js.map +1 -0
  272. package/lib-commonjs/components/Toaster/renderToaster.js +20 -0
  273. package/lib-commonjs/components/Toaster/renderToaster.js.map +1 -0
  274. package/lib-commonjs/components/Toaster/useToaster.js +81 -0
  275. package/lib-commonjs/components/Toaster/useToaster.js.map +1 -0
  276. package/lib-commonjs/components/Toaster/useToasterStyles.styles.js +54 -0
  277. package/lib-commonjs/components/Toaster/useToasterStyles.styles.js.map +1 -0
  278. package/lib-commonjs/contexts/toastContainerContext.js +26 -0
  279. package/lib-commonjs/contexts/toastContainerContext.js.map +1 -0
  280. package/lib-commonjs/index.js +48 -0
  281. package/lib-commonjs/index.js.map +1 -0
  282. package/lib-commonjs/state/constants.js +28 -0
  283. package/lib-commonjs/state/constants.js.map +1 -0
  284. package/lib-commonjs/state/index.js +20 -0
  285. package/lib-commonjs/state/index.js.map +1 -0
  286. package/lib-commonjs/state/types.js +6 -0
  287. package/lib-commonjs/state/types.js.map +1 -0
  288. package/lib-commonjs/state/useToastController.js +63 -0
  289. package/lib-commonjs/state/useToastController.js.map +1 -0
  290. package/lib-commonjs/state/useToaster.js +171 -0
  291. package/lib-commonjs/state/useToaster.js.map +1 -0
  292. package/lib-commonjs/state/vanilla/createToaster.js +142 -0
  293. package/lib-commonjs/state/vanilla/createToaster.js.map +1 -0
  294. package/lib-commonjs/state/vanilla/dismissAllToasts.js +19 -0
  295. package/lib-commonjs/state/vanilla/dismissAllToasts.js.map +1 -0
  296. package/lib-commonjs/state/vanilla/dismissToast.js +20 -0
  297. package/lib-commonjs/state/vanilla/dismissToast.js.map +1 -0
  298. package/lib-commonjs/state/vanilla/dispatchToast.js +24 -0
  299. package/lib-commonjs/state/vanilla/dispatchToast.js.map +1 -0
  300. package/lib-commonjs/state/vanilla/getPositionStyles.js +48 -0
  301. package/lib-commonjs/state/vanilla/getPositionStyles.js.map +1 -0
  302. package/lib-commonjs/state/vanilla/index.js +13 -0
  303. package/lib-commonjs/state/vanilla/index.js.map +1 -0
  304. package/lib-commonjs/state/vanilla/pauseToast.js +20 -0
  305. package/lib-commonjs/state/vanilla/pauseToast.js.map +1 -0
  306. package/lib-commonjs/state/vanilla/playToast.js +20 -0
  307. package/lib-commonjs/state/vanilla/playToast.js.map +1 -0
  308. package/lib-commonjs/state/vanilla/updateToast.js +17 -0
  309. package/lib-commonjs/state/vanilla/updateToast.js.map +1 -0
  310. package/package.json +66 -0
@@ -0,0 +1,485 @@
1
+ /// <reference types="react" />
2
+
3
+ import { ARIAButtonResultProps } from '@fluentui/react-aria';
4
+ import { ARIAButtonType } from '@fluentui/react-aria';
5
+ import { BackgroundAppearanceContextValue } from '@fluentui/react-shared-contexts';
6
+ import type { ComponentProps } from '@fluentui/react-utilities';
7
+ import type { ComponentState } from '@fluentui/react-utilities';
8
+ import type { ForwardRefComponent } from '@fluentui/react-utilities';
9
+ import { JSXElementConstructor } from 'react';
10
+ import * as React_2 from 'react';
11
+ import { ReactElement } from 'react';
12
+ import type { Slot } from '@fluentui/react-utilities';
13
+ import type { SlotClassNames } from '@fluentui/react-utilities';
14
+ import type { TriggerProps } from '@fluentui/react-utilities';
15
+
16
+ declare type Announce = (message: string, options: AnnounceOptions) => void;
17
+
18
+ declare type AnnounceOptions = {
19
+ politeness: AriaLivePoliteness;
20
+ };
21
+
22
+ declare type AriaLivePoliteness = 'polite' | 'assertive';
23
+
24
+ /**
25
+ * AriaLive Props
26
+ */
27
+ declare type AriaLiveProps = ComponentProps<Partial<AriaLiveSlots>> & {
28
+ announceRef: React_2.Ref<Announce>;
29
+ };
30
+
31
+ declare type AriaLiveSlots = {
32
+ assertive: NonNullable<Slot<'div'>>;
33
+ polite: NonNullable<Slot<'div'>>;
34
+ };
35
+
36
+ declare interface CommonToastDetail {
37
+ toasterId?: ToasterId;
38
+ }
39
+
40
+ declare interface DispatchToastOptions extends Partial<Omit<ToastOptions, 'toasterId'>> {
41
+ root?: RootSlot;
42
+ }
43
+
44
+ /**
45
+ * Render the final JSX of Toast
46
+ */
47
+ export declare const renderToast_unstable: (state: ToastState, contextValues: ToastContextValues) => JSX.Element;
48
+
49
+ /**
50
+ * Render the final JSX of ToastBody
51
+ */
52
+ export declare const renderToastBody_unstable: (state: ToastBodyState) => JSX.Element;
53
+
54
+ /**
55
+ * Render the final JSX of Toaster
56
+ */
57
+ export declare const renderToaster_unstable: (state: ToasterState) => JSX.Element;
58
+
59
+ /**
60
+ * Render the final JSX of ToastFooter
61
+ */
62
+ export declare const renderToastFooter_unstable: (state: ToastFooterState) => JSX.Element;
63
+
64
+ /**
65
+ * Render the final JSX of ToastTitle
66
+ */
67
+ export declare const renderToastTitle_unstable: (state: ToastTitleState) => JSX.Element;
68
+
69
+ /**
70
+ * Render the final JSX of MenuTrigger
71
+ *
72
+ * Only renders children
73
+ */
74
+ export declare const renderToastTrigger_unstable: (state: ToastTriggerState) => ReactElement<any, string | JSXElementConstructor<any>> | null;
75
+
76
+ declare type RootSlot = Slot<'div'>;
77
+
78
+ /**
79
+ * Toast component
80
+ */
81
+ export declare const Toast: ForwardRefComponent<ToastProps>;
82
+
83
+ declare interface Toast_2<TData = object> extends ToastOptions<TData> {
84
+ /**
85
+ * Determines the visiblity of a toast
86
+ */
87
+ close: () => void;
88
+ /**
89
+ * Removes a toast completely
90
+ */
91
+ remove: () => void;
92
+ /**
93
+ * A number used to track updates immutably
94
+ */
95
+ updateId: number;
96
+ /**
97
+ * Used to determine default priority when the user does not set one
98
+ * Simple counter of toasts dispatched.
99
+ */
100
+ order: number;
101
+ imperativeRef: React_2.RefObject<ToastImperativeRef>;
102
+ }
103
+
104
+ /**
105
+ * ToastBody component
106
+ */
107
+ export declare const ToastBody: ForwardRefComponent<ToastBodyProps>;
108
+
109
+ export declare const toastBodyClassNames: SlotClassNames<ToastBodySlots>;
110
+
111
+ /**
112
+ * ToastBody Props
113
+ */
114
+ export declare type ToastBodyProps = ComponentProps<ToastBodySlots> & {};
115
+
116
+ export declare type ToastBodySlots = {
117
+ root: Slot<'div'>;
118
+ subtitle?: Slot<'div'>;
119
+ };
120
+
121
+ /**
122
+ * State used in rendering ToastBody
123
+ */
124
+ export declare type ToastBodyState = ComponentState<ToastBodySlots> & {
125
+ backgroundAppearance: BackgroundAppearanceContextValue;
126
+ };
127
+
128
+ declare interface ToastChangeData extends ToastOptions, Pick<Toast_2, 'updateId'> {
129
+ status: ToastStatus;
130
+ }
131
+
132
+ declare type ToastChangeHandler = (event: null, data: ToastChangeData) => void;
133
+
134
+ export declare const toastClassNames: SlotClassNames<ToastSlots>;
135
+
136
+ declare type ToastContainerContextValue = {
137
+ close: () => void;
138
+ intent: ToastIntent | undefined;
139
+ bodyId: string;
140
+ titleId: string;
141
+ };
142
+
143
+ declare type ToastContextValues = {
144
+ backgroundAppearance: BackgroundAppearanceContextValue;
145
+ };
146
+
147
+ /**
148
+ * Toaster component - renders a collection of toasts dispatched imperatively
149
+ */
150
+ export declare const Toaster: React_2.FC<ToasterProps>;
151
+
152
+ export declare const toasterClassNames: SlotClassNames<ToasterSlots>;
153
+
154
+ declare type ToasterId = string;
155
+
156
+ declare interface ToasterOptions extends Pick<ToastOptions, 'position' | 'timeout' | 'pauseOnWindowBlur' | 'pauseOnHover' | 'priority'> {
157
+ offset?: ToastOffset;
158
+ toasterId?: ToasterId;
159
+ limit?: number;
160
+ shortcuts?: ToasterShortcuts;
161
+ }
162
+
163
+ /**
164
+ * Toaster Props
165
+ */
166
+ export declare type ToasterProps = Omit<ComponentProps<ToasterSlots>, 'children'> & Partial<ToasterOptions> & {
167
+ /**
168
+ * User override API for aria-live narration for toasts
169
+ */
170
+ announce?: Announce;
171
+ };
172
+
173
+ declare interface ToasterShortcuts {
174
+ focus: (e: KeyboardEvent) => boolean;
175
+ }
176
+
177
+ export declare type ToasterSlots = {
178
+ /**
179
+ * NOTE: This root slot maps in exactly the same way to the containers rendered for each toast position
180
+ * There is no intention (currently) to let users customize the div for each toast position.
181
+ */
182
+ root: Slot<'div'>;
183
+ };
184
+
185
+ declare type ToasterSlotsInternal = ToasterSlots & {
186
+ bottomEnd?: Slot<'div'>;
187
+ bottomStart?: Slot<'div'>;
188
+ topEnd?: Slot<'div'>;
189
+ topStart?: Slot<'div'>;
190
+ };
191
+
192
+ /**
193
+ * State used in rendering Toaster
194
+ */
195
+ export declare type ToasterState = ComponentState<ToasterSlotsInternal> & Pick<AriaLiveProps, 'announceRef'> & Pick<Required<ToasterProps>, 'announce'> & {
196
+ offset: ToasterOptions['offset'] | undefined;
197
+ renderAriaLive: boolean;
198
+ dir: 'rtl' | 'ltr';
199
+ };
200
+
201
+ /**
202
+ * ToastFooter component
203
+ */
204
+ export declare const ToastFooter: ForwardRefComponent<ToastFooterProps>;
205
+
206
+ export declare const toastFooterClassNames: SlotClassNames<ToastFooterSlots>;
207
+
208
+ /**
209
+ * ToastFooter Props
210
+ */
211
+ export declare type ToastFooterProps = ComponentProps<ToastFooterSlots> & {};
212
+
213
+ export declare type ToastFooterSlots = {
214
+ root: Slot<'div'>;
215
+ };
216
+
217
+ /**
218
+ * State used in rendering ToastFooter
219
+ */
220
+ export declare type ToastFooterState = ComponentState<ToastFooterSlots>;
221
+
222
+ export declare type ToastId = string;
223
+
224
+ declare type ToastImperativeRef = {
225
+ /**
226
+ * Focuses the Toast.
227
+ * If there are no focusable elements in the Toast, the Toast itself is focused.
228
+ */
229
+ focus: () => void;
230
+ /**
231
+ * Resumes the timeout of a paused toast
232
+ */
233
+ play: () => void;
234
+ /**
235
+ * Pauses the timeout of a toast
236
+ */
237
+ pause: () => void;
238
+ };
239
+
240
+ export declare type ToastIntent = 'info' | 'success' | 'error' | 'warning';
241
+
242
+ export declare type ToastOffset = Partial<Record<ToastPosition, ToastOffsetObject>> | ToastOffsetObject;
243
+
244
+ declare interface ToastOffsetObject {
245
+ horizontal?: number;
246
+ vertical?: number;
247
+ }
248
+
249
+ declare interface ToastOptions<TData = object> {
250
+ /**
251
+ * Uniquely identifies a toast, used for update and dismiss operations
252
+ */
253
+ toastId: ToastId;
254
+ /**
255
+ * The position the toast should render to
256
+ */
257
+ position: ToastPosition;
258
+ /**
259
+ * Toast content
260
+ */
261
+ content: unknown;
262
+ /**
263
+ * Auto dismiss timeout in milliseconds
264
+ * @default 3000
265
+ */
266
+ timeout: number;
267
+ /**
268
+ * Toast timeout pauses while focus is on another window
269
+ * @default false
270
+ */
271
+ pauseOnWindowBlur: boolean;
272
+ /**
273
+ * Toast timeout pauses while user cursor is on the toast
274
+ * @default false
275
+ */
276
+ pauseOnHover: boolean;
277
+ /**
278
+ * Toast belongs to a specific toaster
279
+ */
280
+ toasterId: ToasterId | undefined;
281
+ /**
282
+ * Higher priority toasts will be rendered before lower priority toasts
283
+ */
284
+ priority: number;
285
+ /**
286
+ * Used to determine [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) narration
287
+ * This will override the intent prop
288
+ */
289
+ politeness?: ToastPoliteness;
290
+ /**
291
+ * Default toast types that determine the urgency or [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) narration
292
+ * The UI layer may use these intents to apply specific styling.
293
+ * @default info
294
+ */
295
+ intent?: ToastIntent;
296
+ /**
297
+ * Additional data that needs to be passed to the toast
298
+ */
299
+ data: TData;
300
+ /**
301
+ * Reports changes to the Toast lifecycle
302
+ */
303
+ onStatusChange: ToastChangeHandler | undefined;
304
+ }
305
+
306
+ export declare type ToastPoliteness = 'assertive' | 'polite';
307
+
308
+ export declare type ToastPosition = 'top-end' | 'top-start' | 'bottom-end' | 'bottom-start';
309
+
310
+ /**
311
+ * Toast Props
312
+ */
313
+ export declare type ToastProps = ComponentProps<ToastSlots> & {
314
+ appearance?: BackgroundAppearanceContextValue;
315
+ };
316
+
317
+ export declare type ToastSlots = {
318
+ root: Slot<'div'>;
319
+ };
320
+
321
+ /**
322
+ * State used in rendering Toast
323
+ */
324
+ export declare type ToastState = ComponentState<ToastSlots> & {
325
+ backgroundAppearance: BackgroundAppearanceContextValue;
326
+ };
327
+
328
+ export declare type ToastStatus = 'queued' | 'visible' | 'dismissed' | 'unmounted';
329
+
330
+ /**
331
+ * ToastTitle component
332
+ */
333
+ export declare const ToastTitle: ForwardRefComponent<ToastTitleProps>;
334
+
335
+ export declare const toastTitleClassNames: SlotClassNames<ToastTitleSlots>;
336
+
337
+ /**
338
+ * ToastTitle Props
339
+ */
340
+ export declare type ToastTitleProps = ComponentProps<ToastTitleSlots> & {};
341
+
342
+ export declare type ToastTitleSlots = {
343
+ root: NonNullable<Slot<'div'>>;
344
+ media?: Slot<'div'>;
345
+ action?: Slot<'div'>;
346
+ };
347
+
348
+ /**
349
+ * State used in rendering ToastTitle
350
+ */
351
+ export declare type ToastTitleState = ComponentState<ToastTitleSlots> & Pick<ToastContainerContextValue, 'intent'> & {
352
+ backgroundAppearance: BackgroundAppearanceContextValue;
353
+ };
354
+
355
+ /**
356
+ * ToastTrigger component
357
+ */
358
+ export declare const ToastTrigger: React_2.FC<ToastTriggerProps>;
359
+
360
+ /**
361
+ * Props that are passed to the child of the ToastTrigger when cloned to ensure correct behaviour for the Toast
362
+ */
363
+ export declare type ToastTriggerChildProps<Type extends ARIAButtonType = ARIAButtonType, Props = {}> = ARIAButtonResultProps<Type, Props>;
364
+
365
+ export declare type ToastTriggerProps = TriggerProps<ToastTriggerChildProps> & {
366
+ /**
367
+ * Disables internal trigger mechanism that ensures a child provided will be a compliant ARIA button.
368
+ * @default false
369
+ */
370
+ disableButtonEnhancement?: boolean;
371
+ };
372
+
373
+ export declare type ToastTriggerState = {
374
+ children: React_2.ReactElement | null;
375
+ };
376
+
377
+ declare interface UpdateToastEventDetail extends Partial<ToastOptions>, CommonToastDetail {
378
+ toastId: ToastId;
379
+ }
380
+
381
+ declare interface UpdateToastOptions extends UpdateToastEventDetail {
382
+ root?: RootSlot;
383
+ }
384
+
385
+ /**
386
+ * Create the state required to render Toast.
387
+ *
388
+ * The returned state can be modified with hooks such as useToastStyles_unstable,
389
+ * before being passed to renderToast_unstable.
390
+ *
391
+ * @param props - props from this instance of Toast
392
+ * @param ref - reference to root HTMLElement of Toast
393
+ */
394
+ export declare const useToast_unstable: (props: ToastProps, ref: React_2.Ref<HTMLElement>) => ToastState;
395
+
396
+ /**
397
+ * Create the state required to render ToastBody.
398
+ *
399
+ * The returned state can be modified with hooks such as useToastBodyStyles_unstable,
400
+ * before being passed to renderToastBody_unstable.
401
+ *
402
+ * @param props - props from this instance of ToastBody
403
+ * @param ref - reference to root HTMLElement of ToastBody
404
+ */
405
+ export declare const useToastBody_unstable: (props: ToastBodyProps, ref: React_2.Ref<HTMLElement>) => ToastBodyState;
406
+
407
+ /**
408
+ * Apply styling to the ToastBody slots based on the state
409
+ */
410
+ export declare const useToastBodyStyles_unstable: (state: ToastBodyState) => ToastBodyState;
411
+
412
+ /**
413
+ * @param toasterId - If an id is provided all imperative methods control that specific toaster
414
+ * @returns Imperative methods to control toasts
415
+ */
416
+ export declare function useToastController(toasterId?: ToasterId): {
417
+ dispatchToast: (content: React_2.ReactNode, options?: DispatchToastOptions) => void;
418
+ dismissToast: (toastId: ToastId) => void;
419
+ dismissAllToasts: () => void;
420
+ updateToast: (options: UpdateToastOptions) => void;
421
+ pauseToast: (toastId: ToastId) => void;
422
+ playToast: (toastId: ToastId) => void;
423
+ };
424
+
425
+ /**
426
+ * Create the state required to render Toaster.
427
+ *
428
+ * @param props - props from this instance of Toaster
429
+ */
430
+ export declare const useToaster_unstable: (props: ToasterProps) => ToasterState;
431
+
432
+ /**
433
+ * Apply styling to the Toaster slots based on the state
434
+ */
435
+ export declare const useToasterStyles_unstable: (state: ToasterState) => ToasterState;
436
+
437
+ /**
438
+ * Create the state required to render ToastFooter.
439
+ *
440
+ * The returned state can be modified with hooks such as useToastFooterStyles_unstable,
441
+ * before being passed to renderToastFooter_unstable.
442
+ *
443
+ * @param props - props from this instance of ToastFooter
444
+ * @param ref - reference to root HTMLElement of ToastFooter
445
+ */
446
+ export declare const useToastFooter_unstable: (props: ToastFooterProps, ref: React_2.Ref<HTMLElement>) => ToastFooterState;
447
+
448
+ /**
449
+ * Apply styling to the ToastFooter slots based on the state
450
+ */
451
+ export declare const useToastFooterStyles_unstable: (state: ToastFooterState) => ToastFooterState;
452
+
453
+ /**
454
+ * Apply styling to the Toast slots based on the state
455
+ */
456
+ export declare const useToastStyles_unstable: (state: ToastState) => ToastState;
457
+
458
+ /**
459
+ * Create the state required to render ToastTitle.
460
+ *
461
+ * The returned state can be modified with hooks such as useToastTitleStyles_unstable,
462
+ * before being passed to renderToastTitle_unstable.
463
+ *
464
+ * @param props - props from this instance of ToastTitle
465
+ * @param ref - reference to root HTMLElement of ToastTitle
466
+ */
467
+ export declare const useToastTitle_unstable: (props: ToastTitleProps, ref: React_2.Ref<HTMLElement>) => ToastTitleState;
468
+
469
+ /**
470
+ * Apply styling to the ToastTitle slots based on the state
471
+ */
472
+ export declare const useToastTitleStyles_unstable: (state: ToastTitleState) => ToastTitleState;
473
+
474
+ /**
475
+ * A non-visual component that wraps its child
476
+ * and configures them to be the trigger that will close a `Toast`.
477
+ * This component should only accept one child.
478
+ *
479
+ * This component sole purpose is to avoid opting out of the internal controlled open state of a `Toast`
480
+ * Besides being a trigger that closes a toast through context this component doesn't do much,
481
+ * making it basically unnecessary in cases where the trigger is outside of a toast.
482
+ */
483
+ export declare const useToastTrigger_unstable: (props: ToastTriggerProps) => ToastTriggerState;
484
+
485
+ export { }
@@ -0,0 +1 @@
1
+ export * from './components/AriaLive/index';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["AriaLive.ts"],"sourcesContent":["export * from './components/AriaLive/index';\n"],"names":[],"mappings":"AAAA,cAAc,8BAA8B"}
package/lib/Toast.js ADDED
@@ -0,0 +1 @@
1
+ export * from './components/Toast/index';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Toast.ts"],"sourcesContent":["export * from './components/Toast/index';\n"],"names":[],"mappings":"AAAA,cAAc,2BAA2B"}
@@ -0,0 +1 @@
1
+ export * from './components/ToastBody/index';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ToastBody.ts"],"sourcesContent":["export * from './components/ToastBody/index';\n"],"names":[],"mappings":"AAAA,cAAc,+BAA+B"}
@@ -0,0 +1 @@
1
+ export * from './components/ToastContainer/index';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ToastContainer.ts"],"sourcesContent":["export * from './components/ToastContainer/index';\n"],"names":[],"mappings":"AAAA,cAAc,oCAAoC"}
@@ -0,0 +1 @@
1
+ export * from './components/ToastFooter/index';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ToastFooter.ts"],"sourcesContent":["export * from './components/ToastFooter/index';\n"],"names":[],"mappings":"AAAA,cAAc,iCAAiC"}
@@ -0,0 +1 @@
1
+ export * from './components/ToastTitle/index';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ToastTitle.ts"],"sourcesContent":["export * from './components/ToastTitle/index';\n"],"names":[],"mappings":"AAAA,cAAc,gCAAgC"}
@@ -0,0 +1 @@
1
+ export * from './components/ToastTrigger/index';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ToastTrigger.ts"],"sourcesContent":["export * from './components/ToastTrigger/index';\n"],"names":[],"mappings":"AAAA,cAAc,kCAAkC"}
package/lib/Toaster.js ADDED
@@ -0,0 +1 @@
1
+ export * from './components/Toaster/index';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Toaster.ts"],"sourcesContent":["export * from './components/Toaster/index';\n"],"names":[],"mappings":"AAAA,cAAc,6BAA6B"}
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { useAriaLive_unstable } from './useAriaLive';
3
+ import { renderAriaLive_unstable } from './renderAriaLive';
4
+ import { useAriaLiveStyles_unstable } from './useAriaLiveStyles.styles';
5
+ /**
6
+ * A component that manages aria live announcements imperatively
7
+ */ export const AriaLive = (props)=>{
8
+ const state = useAriaLive_unstable(props);
9
+ useAriaLiveStyles_unstable(state);
10
+ return renderAriaLive_unstable(state);
11
+ };
12
+ AriaLive.displayName = 'AriaLive';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["AriaLive.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useAriaLive_unstable } from './useAriaLive';\nimport { renderAriaLive_unstable } from './renderAriaLive';\nimport { useAriaLiveStyles_unstable } from './useAriaLiveStyles.styles';\nimport type { AriaLiveProps } from './AriaLive.types';\n\n/**\n * A component that manages aria live announcements imperatively\n */\nexport const AriaLive: React.FC<AriaLiveProps> = props => {\n const state = useAriaLive_unstable(props);\n\n useAriaLiveStyles_unstable(state);\n return renderAriaLive_unstable(state);\n};\n\nAriaLive.displayName = 'AriaLive';\n"],"names":["React","useAriaLive_unstable","renderAriaLive_unstable","useAriaLiveStyles_unstable","AriaLive","props","state","displayName"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ,gBAAgB;AACrD,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,0BAA0B,QAAQ,6BAA6B;AAGxE;;CAEC,GACD,OAAO,MAAMC,WAAoCC,CAAAA,QAAS;IACxD,MAAMC,QAAQL,qBAAqBI;IAEnCF,2BAA2BG;IAC3B,OAAOJ,wBAAwBI;AACjC,EAAE;AAEFF,SAASG,WAAW,GAAG"}
@@ -0,0 +1 @@
1
+ import * as React from 'react';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["AriaLive.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type AriaLiveSlots = {\n assertive: NonNullable<Slot<'div'>>;\n polite: NonNullable<Slot<'div'>>;\n};\n\nexport type AriaLivePoliteness = 'polite' | 'assertive';\n\n/**\n * AriaLive Props\n */\nexport type AriaLiveProps = ComponentProps<Partial<AriaLiveSlots>> & {\n announceRef: React.Ref<Announce>;\n};\n\n/**\n * State used in rendering AriaLive\n */\nexport type AriaLiveState = ComponentState<AriaLiveSlots>;\n\nexport type Announce = (message: string, options: AnnounceOptions) => void;\n\nexport type LiveMessage = {\n message: string;\n createdAt: number;\n politeness: AriaLivePoliteness;\n};\n\nexport type AnnounceOptions = {\n politeness: AriaLivePoliteness;\n};\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -0,0 +1,5 @@
1
+ export * from './AriaLive';
2
+ export * from './AriaLive.types';
3
+ export * from './renderAriaLive';
4
+ export * from './useAriaLive';
5
+ export * from './useAriaLiveStyles.styles';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './AriaLive';\nexport * from './AriaLive.types';\nexport * from './renderAriaLive';\nexport * from './useAriaLive';\nexport * from './useAriaLiveStyles.styles';\n"],"names":[],"mappings":"AAAA,cAAc,aAAa;AAC3B,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,gBAAgB;AAC9B,cAAc,6BAA6B"}
@@ -0,0 +1,8 @@
1
+ /** @jsxRuntime classic */ /** @jsxFrag Fragment */ /** @jsx createElement */ import { createElement, Fragment } from '@fluentui/react-jsx-runtime';
2
+ import { getSlotsNext } from '@fluentui/react-utilities';
3
+ /**
4
+ * Render the final JSX of AriaLive
5
+ */ export const renderAriaLive_unstable = (state)=>{
6
+ const { slots , slotProps } = getSlotsNext(state);
7
+ return /*#__PURE__*/ createElement(Fragment, null, /*#__PURE__*/ createElement(slots.assertive, slotProps.assertive), /*#__PURE__*/ createElement(slots.polite, slotProps.polite));
8
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["renderAriaLive.tsx"],"sourcesContent":["/** @jsxRuntime classic */\n/** @jsxFrag Fragment */\n/** @jsx createElement */\n\nimport { createElement, Fragment } from '@fluentui/react-jsx-runtime';\nimport { getSlotsNext } from '@fluentui/react-utilities';\nimport type { AriaLiveState, AriaLiveSlots } from './AriaLive.types';\n\n/**\n * Render the final JSX of AriaLive\n */\nexport const renderAriaLive_unstable = (state: AriaLiveState) => {\n const { slots, slotProps } = getSlotsNext<AriaLiveSlots>(state);\n\n return (\n <>\n <slots.assertive {...slotProps.assertive} />\n <slots.polite {...slotProps.polite} />\n </>\n );\n};\n"],"names":["createElement","Fragment","getSlotsNext","renderAriaLive_unstable","state","slots","slotProps","assertive","polite"],"mappings":"AAAA,wBAAwB,GACxB,sBAAsB,GACtB,uBAAuB,GAEvB,SAASA,aAAa,EAAEC,QAAQ,QAAQ,8BAA8B;AACtE,SAASC,YAAY,QAAQ,4BAA4B;AAGzD;;CAEC,GACD,OAAO,MAAMC,0BAA0B,CAACC,QAAyB;IAC/D,MAAM,EAAEC,MAAK,EAAEC,UAAS,EAAE,GAAGJ,aAA4BE;IAEzD,qBACE,AAbJ,cADA,8BAeM,AAdN,cAcOC,MAAME,SAAS,EAAKD,UAAUC,SAAS,iBACxC,AAfN,cAeOF,MAAMG,MAAM,EAAKF,UAAUE,MAAM;AAGxC,EAAE"}
@@ -0,0 +1,73 @@
1
+ import * as React from 'react';
2
+ import { resolveShorthand, createPriorityQueue, useEventCallback } from '@fluentui/react-utilities';
3
+ /** The duration the message needs to be in present in DOM for screen readers to register a change and announce */ const MESSAGE_DURATION = 500;
4
+ /**
5
+ * Create the state required to render AriaLive.
6
+ *
7
+ * The returned state can be modified with hooks such as useAriaLiveStyles_unstable,
8
+ * before being passed to renderAriaLive_unstable.
9
+ *
10
+ * @param props - props from this instance of AriaLive
11
+ */ export const useAriaLive_unstable = (props)=>{
12
+ const [currentMessage, setCurrentMessage] = React.useState(undefined);
13
+ // Can't rely on Date.now() if user invokes announce more than once in a code block
14
+ const order = React.useRef(0);
15
+ const [messageQueue] = React.useState(()=>createPriorityQueue((a, b)=>{
16
+ if (a.politeness === b.politeness) {
17
+ return a.createdAt - b.createdAt;
18
+ }
19
+ return a.politeness === 'assertive' ? -1 : 1;
20
+ }));
21
+ const announce = useEventCallback((message, options)=>{
22
+ const { politeness } = options;
23
+ if (message === (currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.message)) {
24
+ return;
25
+ }
26
+ const liveMessage = {
27
+ message,
28
+ politeness,
29
+ createdAt: order.current++
30
+ };
31
+ if (!currentMessage) {
32
+ setCurrentMessage(liveMessage);
33
+ } else {
34
+ messageQueue.enqueue(liveMessage);
35
+ }
36
+ });
37
+ React.useEffect(()=>{
38
+ const timeout = setTimeout(()=>{
39
+ if (messageQueue.peek()) {
40
+ setCurrentMessage(messageQueue.dequeue());
41
+ } else {
42
+ setCurrentMessage(undefined);
43
+ }
44
+ }, MESSAGE_DURATION);
45
+ return ()=>clearTimeout(timeout);
46
+ }, [
47
+ currentMessage,
48
+ messageQueue
49
+ ]);
50
+ React.useImperativeHandle(props.announceRef, ()=>announce);
51
+ const politeMessage = (currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.politeness) === 'polite' ? currentMessage.message : undefined;
52
+ const assertiveMessage = (currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.politeness) === 'assertive' ? currentMessage.message : undefined;
53
+ return {
54
+ components: {
55
+ assertive: 'div',
56
+ polite: 'div'
57
+ },
58
+ assertive: resolveShorthand(props.assertive, {
59
+ required: true,
60
+ defaultProps: {
61
+ 'aria-live': 'assertive',
62
+ children: assertiveMessage
63
+ }
64
+ }),
65
+ polite: resolveShorthand(props.polite, {
66
+ required: true,
67
+ defaultProps: {
68
+ 'aria-live': 'polite',
69
+ children: politeMessage
70
+ }
71
+ })
72
+ };
73
+ };