@fluentui/react-toast 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +56 -0
- package/CHANGELOG.md +19 -0
- package/LICENSE +15 -0
- package/README.md +5 -0
- package/dist/index.d.ts +485 -0
- package/lib/AriaLive.js +1 -0
- package/lib/AriaLive.js.map +1 -0
- package/lib/Toast.js +1 -0
- package/lib/Toast.js.map +1 -0
- package/lib/ToastBody.js +1 -0
- package/lib/ToastBody.js.map +1 -0
- package/lib/ToastContainer.js +1 -0
- package/lib/ToastContainer.js.map +1 -0
- package/lib/ToastFooter.js +1 -0
- package/lib/ToastFooter.js.map +1 -0
- package/lib/ToastTitle.js +1 -0
- package/lib/ToastTitle.js.map +1 -0
- package/lib/ToastTrigger.js +1 -0
- package/lib/ToastTrigger.js.map +1 -0
- package/lib/Toaster.js +1 -0
- package/lib/Toaster.js.map +1 -0
- package/lib/components/AriaLive/AriaLive.js +12 -0
- package/lib/components/AriaLive/AriaLive.js.map +1 -0
- package/lib/components/AriaLive/AriaLive.types.js +1 -0
- package/lib/components/AriaLive/AriaLive.types.js.map +1 -0
- package/lib/components/AriaLive/index.js +5 -0
- package/lib/components/AriaLive/index.js.map +1 -0
- package/lib/components/AriaLive/renderAriaLive.js +8 -0
- package/lib/components/AriaLive/renderAriaLive.js.map +1 -0
- package/lib/components/AriaLive/useAriaLive.js +73 -0
- package/lib/components/AriaLive/useAriaLive.js.map +1 -0
- package/lib/components/AriaLive/useAriaLiveStyles.styles.js +19 -0
- package/lib/components/AriaLive/useAriaLiveStyles.styles.js.map +1 -0
- package/lib/components/Timer/Timer.js +21 -0
- package/lib/components/Timer/Timer.js.map +1 -0
- package/lib/components/Timer/index.js +1 -0
- package/lib/components/Timer/index.js.map +1 -0
- package/lib/components/Timer/useTimerStyles.styles.js +3 -0
- package/lib/components/Timer/useTimerStyles.styles.js.map +1 -0
- package/lib/components/Toast/Toast.js +13 -0
- package/lib/components/Toast/Toast.js.map +1 -0
- package/lib/components/Toast/Toast.types.js +1 -0
- package/lib/components/Toast/Toast.types.js.map +1 -0
- package/lib/components/Toast/index.js +5 -0
- package/lib/components/Toast/index.js.map +1 -0
- package/lib/components/Toast/renderToast.js +11 -0
- package/lib/components/Toast/renderToast.js.map +1 -0
- package/lib/components/Toast/useToast.js +22 -0
- package/lib/components/Toast/useToast.js.map +1 -0
- package/lib/components/Toast/useToastContextValues.js +6 -0
- package/lib/components/Toast/useToastContextValues.js.map +1 -0
- package/lib/components/Toast/useToastStyles.styles.js +24 -0
- package/lib/components/Toast/useToastStyles.styles.js.map +1 -0
- package/lib/components/ToastBody/ToastBody.js +12 -0
- package/lib/components/ToastBody/ToastBody.js.map +1 -0
- package/lib/components/ToastBody/ToastBody.types.js +1 -0
- package/lib/components/ToastBody/ToastBody.types.js.map +1 -0
- package/lib/components/ToastBody/index.js +5 -0
- package/lib/components/ToastBody/index.js.map +1 -0
- package/lib/components/ToastBody/renderToastBody.js +8 -0
- package/lib/components/ToastBody/renderToastBody.js.map +1 -0
- package/lib/components/ToastBody/useToastBody.js +29 -0
- package/lib/components/ToastBody/useToastBody.js.map +1 -0
- package/lib/components/ToastBody/useToastBodyStyles.styles.js +32 -0
- package/lib/components/ToastBody/useToastBodyStyles.styles.js.map +1 -0
- package/lib/components/ToastContainer/ToastContainer.js +13 -0
- package/lib/components/ToastContainer/ToastContainer.js.map +1 -0
- package/lib/components/ToastContainer/ToastContainer.types.js +1 -0
- package/lib/components/ToastContainer/ToastContainer.types.js.map +1 -0
- package/lib/components/ToastContainer/index.js +6 -0
- package/lib/components/ToastContainer/index.js.map +1 -0
- package/lib/components/ToastContainer/renderToastContainer.js +21 -0
- package/lib/components/ToastContainer/renderToastContainer.js.map +1 -0
- package/lib/components/ToastContainer/useToastContainer.js +219 -0
- package/lib/components/ToastContainer/useToastContainer.js.map +1 -0
- package/lib/components/ToastContainer/useToastContainerContextValues.js +18 -0
- package/lib/components/ToastContainer/useToastContainerContextValues.js.map +1 -0
- package/lib/components/ToastContainer/useToastContainerStyles.styles.js +36 -0
- package/lib/components/ToastContainer/useToastContainerStyles.styles.js.map +1 -0
- package/lib/components/ToastFooter/ToastFooter.js +12 -0
- package/lib/components/ToastFooter/ToastFooter.js.map +1 -0
- package/lib/components/ToastFooter/ToastFooter.types.js +1 -0
- package/lib/components/ToastFooter/ToastFooter.types.js.map +1 -0
- package/lib/components/ToastFooter/index.js +5 -0
- package/lib/components/ToastFooter/index.js.map +1 -0
- package/lib/components/ToastFooter/renderToastFooter.js +8 -0
- package/lib/components/ToastFooter/renderToastFooter.js.map +1 -0
- package/lib/components/ToastFooter/useToastFooter.js +21 -0
- package/lib/components/ToastFooter/useToastFooter.js.map +1 -0
- package/lib/components/ToastFooter/useToastFooterStyles.styles.js +17 -0
- package/lib/components/ToastFooter/useToastFooterStyles.styles.js.map +1 -0
- package/lib/components/ToastTitle/ToastTitle.js +12 -0
- package/lib/components/ToastTitle/ToastTitle.js.map +1 -0
- package/lib/components/ToastTitle/ToastTitle.types.js +1 -0
- package/lib/components/ToastTitle/ToastTitle.types.js.map +1 -0
- package/lib/components/ToastTitle/index.js +5 -0
- package/lib/components/ToastTitle/index.js.map +1 -0
- package/lib/components/ToastTitle/renderToastTitle.js +8 -0
- package/lib/components/ToastTitle/renderToastTitle.js.map +1 -0
- package/lib/components/ToastTitle/useToastTitle.js +54 -0
- package/lib/components/ToastTitle/useToastTitle.js.map +1 -0
- package/lib/components/ToastTitle/useToastTitleStyles.styles.js +78 -0
- package/lib/components/ToastTitle/useToastTitleStyles.styles.js.map +1 -0
- package/lib/components/ToastTrigger/ToastTrigger.js +10 -0
- package/lib/components/ToastTrigger/ToastTrigger.js.map +1 -0
- package/lib/components/ToastTrigger/ToastTrigger.types.js +1 -0
- package/lib/components/ToastTrigger/ToastTrigger.types.js.map +1 -0
- package/lib/components/ToastTrigger/index.js +4 -0
- package/lib/components/ToastTrigger/index.js.map +1 -0
- package/lib/components/ToastTrigger/renderToastTrigger.js +5 -0
- package/lib/components/ToastTrigger/renderToastTrigger.js.map +1 -0
- package/lib/components/ToastTrigger/useToastTrigger.js +36 -0
- package/lib/components/ToastTrigger/useToastTrigger.js.map +1 -0
- package/lib/components/Toaster/Toaster.js +12 -0
- package/lib/components/Toaster/Toaster.js.map +1 -0
- package/lib/components/Toaster/Toaster.types.js +1 -0
- package/lib/components/Toaster/Toaster.types.js.map +1 -0
- package/lib/components/Toaster/index.js +5 -0
- package/lib/components/Toaster/index.js.map +1 -0
- package/lib/components/Toaster/renderToaster.js +14 -0
- package/lib/components/Toaster/renderToaster.js.map +1 -0
- package/lib/components/Toaster/useToaster.js +71 -0
- package/lib/components/Toaster/useToaster.js.map +1 -0
- package/lib/components/Toaster/useToasterStyles.styles.js +43 -0
- package/lib/components/Toaster/useToasterStyles.styles.js.map +1 -0
- package/lib/contexts/toastContainerContext.js +11 -0
- package/lib/contexts/toastContainerContext.js.map +1 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/state/constants.js +14 -0
- package/lib/state/constants.js.map +1 -0
- package/lib/state/index.js +5 -0
- package/lib/state/index.js.map +1 -0
- package/lib/state/types.js +1 -0
- package/lib/state/types.js.map +1 -0
- package/lib/state/useToastController.js +57 -0
- package/lib/state/useToastController.js.map +1 -0
- package/lib/state/useToaster.js +162 -0
- package/lib/state/useToaster.js.map +1 -0
- package/lib/state/vanilla/createToaster.js +137 -0
- package/lib/state/vanilla/createToaster.js.map +1 -0
- package/lib/state/vanilla/dismissAllToasts.js +11 -0
- package/lib/state/vanilla/dismissAllToasts.js.map +1 -0
- package/lib/state/vanilla/dismissToast.js +12 -0
- package/lib/state/vanilla/dismissToast.js.map +1 -0
- package/lib/state/vanilla/dispatchToast.js +16 -0
- package/lib/state/vanilla/dispatchToast.js.map +1 -0
- package/lib/state/vanilla/getPositionStyles.js +40 -0
- package/lib/state/vanilla/getPositionStyles.js.map +1 -0
- package/lib/state/vanilla/index.js +8 -0
- package/lib/state/vanilla/index.js.map +1 -0
- package/lib/state/vanilla/pauseToast.js +12 -0
- package/lib/state/vanilla/pauseToast.js.map +1 -0
- package/lib/state/vanilla/playToast.js +12 -0
- package/lib/state/vanilla/playToast.js.map +1 -0
- package/lib/state/vanilla/updateToast.js +9 -0
- package/lib/state/vanilla/updateToast.js.map +1 -0
- package/lib-commonjs/AriaLive.js +6 -0
- package/lib-commonjs/AriaLive.js.map +1 -0
- package/lib-commonjs/Toast.js +6 -0
- package/lib-commonjs/Toast.js.map +1 -0
- package/lib-commonjs/ToastBody.js +6 -0
- package/lib-commonjs/ToastBody.js.map +1 -0
- package/lib-commonjs/ToastContainer.js +6 -0
- package/lib-commonjs/ToastContainer.js.map +1 -0
- package/lib-commonjs/ToastFooter.js +6 -0
- package/lib-commonjs/ToastFooter.js.map +1 -0
- package/lib-commonjs/ToastTitle.js +6 -0
- package/lib-commonjs/ToastTitle.js.map +1 -0
- package/lib-commonjs/ToastTrigger.js +6 -0
- package/lib-commonjs/ToastTrigger.js.map +1 -0
- package/lib-commonjs/Toaster.js +6 -0
- package/lib-commonjs/Toaster.js.map +1 -0
- package/lib-commonjs/components/AriaLive/AriaLive.js +19 -0
- package/lib-commonjs/components/AriaLive/AriaLive.js.map +1 -0
- package/lib-commonjs/components/AriaLive/AriaLive.types.js +6 -0
- package/lib-commonjs/components/AriaLive/AriaLive.types.js.map +1 -0
- package/lib-commonjs/components/AriaLive/index.js +10 -0
- package/lib-commonjs/components/AriaLive/index.js.map +1 -0
- package/lib-commonjs/components/AriaLive/renderAriaLive.js +14 -0
- package/lib-commonjs/components/AriaLive/renderAriaLive.js.map +1 -0
- package/lib-commonjs/components/AriaLive/useAriaLive.js +75 -0
- package/lib-commonjs/components/AriaLive/useAriaLive.js.map +1 -0
- package/lib-commonjs/components/AriaLive/useAriaLiveStyles.styles.js +31 -0
- package/lib-commonjs/components/AriaLive/useAriaLiveStyles.styles.js.map +1 -0
- package/lib-commonjs/components/Timer/Timer.js +30 -0
- package/lib-commonjs/components/Timer/Timer.js.map +1 -0
- package/lib-commonjs/components/Timer/index.js +6 -0
- package/lib-commonjs/components/Timer/index.js.map +1 -0
- package/lib-commonjs/components/Timer/useTimerStyles.styles.js +16 -0
- package/lib-commonjs/components/Timer/useTimerStyles.styles.js.map +1 -0
- package/lib-commonjs/components/Toast/Toast.js +20 -0
- package/lib-commonjs/components/Toast/Toast.js.map +1 -0
- package/lib-commonjs/components/Toast/Toast.types.js +4 -0
- package/lib-commonjs/components/Toast/Toast.types.js.map +1 -0
- package/lib-commonjs/components/Toast/index.js +10 -0
- package/lib-commonjs/components/Toast/index.js.map +1 -0
- package/lib-commonjs/components/Toast/renderToast.js +17 -0
- package/lib-commonjs/components/Toast/renderToast.js.map +1 -0
- package/lib-commonjs/components/Toast/useToast.js +23 -0
- package/lib-commonjs/components/Toast/useToast.js.map +1 -0
- package/lib-commonjs/components/Toast/useToastContextValues.js +14 -0
- package/lib-commonjs/components/Toast/useToastContextValues.js.map +1 -0
- package/lib-commonjs/components/Toast/useToastStyles.styles.js +39 -0
- package/lib-commonjs/components/Toast/useToastStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ToastBody/ToastBody.js +19 -0
- package/lib-commonjs/components/ToastBody/ToastBody.js.map +1 -0
- package/lib-commonjs/components/ToastBody/ToastBody.types.js +4 -0
- package/lib-commonjs/components/ToastBody/ToastBody.types.js.map +1 -0
- package/lib-commonjs/components/ToastBody/index.js +10 -0
- package/lib-commonjs/components/ToastBody/index.js.map +1 -0
- package/lib-commonjs/components/ToastBody/renderToastBody.js +14 -0
- package/lib-commonjs/components/ToastBody/renderToastBody.js.map +1 -0
- package/lib-commonjs/components/ToastBody/useToastBody.js +30 -0
- package/lib-commonjs/components/ToastBody/useToastBody.js.map +1 -0
- package/lib-commonjs/components/ToastBody/useToastBodyStyles.styles.js +47 -0
- package/lib-commonjs/components/ToastBody/useToastBodyStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ToastContainer/ToastContainer.js +20 -0
- package/lib-commonjs/components/ToastContainer/ToastContainer.js.map +1 -0
- package/lib-commonjs/components/ToastContainer/ToastContainer.types.js +6 -0
- package/lib-commonjs/components/ToastContainer/ToastContainer.types.js.map +1 -0
- package/lib-commonjs/components/ToastContainer/index.js +11 -0
- package/lib-commonjs/components/ToastContainer/index.js.map +1 -0
- package/lib-commonjs/components/ToastContainer/renderToastContainer.js +27 -0
- package/lib-commonjs/components/ToastContainer/renderToastContainer.js.map +1 -0
- package/lib-commonjs/components/ToastContainer/useToastContainer.js +220 -0
- package/lib-commonjs/components/ToastContainer/useToastContainer.js.map +1 -0
- package/lib-commonjs/components/ToastContainer/useToastContainerContextValues.js +27 -0
- package/lib-commonjs/components/ToastContainer/useToastContainerContextValues.js.map +1 -0
- package/lib-commonjs/components/ToastContainer/useToastContainerStyles.styles.js +64 -0
- package/lib-commonjs/components/ToastContainer/useToastContainerStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ToastFooter/ToastFooter.js +19 -0
- package/lib-commonjs/components/ToastFooter/ToastFooter.js.map +1 -0
- package/lib-commonjs/components/ToastFooter/ToastFooter.types.js +4 -0
- package/lib-commonjs/components/ToastFooter/ToastFooter.types.js.map +1 -0
- package/lib-commonjs/components/ToastFooter/index.js +10 -0
- package/lib-commonjs/components/ToastFooter/index.js.map +1 -0
- package/lib-commonjs/components/ToastFooter/renderToastFooter.js +14 -0
- package/lib-commonjs/components/ToastFooter/renderToastFooter.js.map +1 -0
- package/lib-commonjs/components/ToastFooter/useToastFooter.js +22 -0
- package/lib-commonjs/components/ToastFooter/useToastFooter.js.map +1 -0
- package/lib-commonjs/components/ToastFooter/useToastFooterStyles.styles.js +28 -0
- package/lib-commonjs/components/ToastFooter/useToastFooterStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ToastTitle/ToastTitle.js +19 -0
- package/lib-commonjs/components/ToastTitle/ToastTitle.js.map +1 -0
- package/lib-commonjs/components/ToastTitle/ToastTitle.types.js +4 -0
- package/lib-commonjs/components/ToastTitle/ToastTitle.types.js.map +1 -0
- package/lib-commonjs/components/ToastTitle/index.js +10 -0
- package/lib-commonjs/components/ToastTitle/index.js.map +1 -0
- package/lib-commonjs/components/ToastTitle/renderToastTitle.js +14 -0
- package/lib-commonjs/components/ToastTitle/renderToastTitle.js.map +1 -0
- package/lib-commonjs/components/ToastTitle/useToastTitle.js +55 -0
- package/lib-commonjs/components/ToastTitle/useToastTitle.js.map +1 -0
- package/lib-commonjs/components/ToastTitle/useToastTitleStyles.styles.js +107 -0
- package/lib-commonjs/components/ToastTitle/useToastTitleStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ToastTrigger/ToastTrigger.js +17 -0
- package/lib-commonjs/components/ToastTrigger/ToastTrigger.js.map +1 -0
- package/lib-commonjs/components/ToastTrigger/ToastTrigger.types.js +6 -0
- package/lib-commonjs/components/ToastTrigger/ToastTrigger.types.js.map +1 -0
- package/lib-commonjs/components/ToastTrigger/index.js +9 -0
- package/lib-commonjs/components/ToastTrigger/index.js.map +1 -0
- package/lib-commonjs/components/ToastTrigger/renderToastTrigger.js +13 -0
- package/lib-commonjs/components/ToastTrigger/renderToastTrigger.js.map +1 -0
- package/lib-commonjs/components/ToastTrigger/useToastTrigger.js +37 -0
- package/lib-commonjs/components/ToastTrigger/useToastTrigger.js.map +1 -0
- package/lib-commonjs/components/Toaster/Toaster.js +19 -0
- package/lib-commonjs/components/Toaster/Toaster.js.map +1 -0
- package/lib-commonjs/components/Toaster/Toaster.types.js +4 -0
- package/lib-commonjs/components/Toaster/Toaster.types.js.map +1 -0
- package/lib-commonjs/components/Toaster/index.js +10 -0
- package/lib-commonjs/components/Toaster/index.js.map +1 -0
- package/lib-commonjs/components/Toaster/renderToaster.js +20 -0
- package/lib-commonjs/components/Toaster/renderToaster.js.map +1 -0
- package/lib-commonjs/components/Toaster/useToaster.js +76 -0
- package/lib-commonjs/components/Toaster/useToaster.js.map +1 -0
- package/lib-commonjs/components/Toaster/useToasterStyles.styles.js +54 -0
- package/lib-commonjs/components/Toaster/useToasterStyles.styles.js.map +1 -0
- package/lib-commonjs/contexts/toastContainerContext.js +26 -0
- package/lib-commonjs/contexts/toastContainerContext.js.map +1 -0
- package/lib-commonjs/index.js +48 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/state/constants.js +28 -0
- package/lib-commonjs/state/constants.js.map +1 -0
- package/lib-commonjs/state/index.js +20 -0
- package/lib-commonjs/state/index.js.map +1 -0
- package/lib-commonjs/state/types.js +6 -0
- package/lib-commonjs/state/types.js.map +1 -0
- package/lib-commonjs/state/useToastController.js +63 -0
- package/lib-commonjs/state/useToastController.js.map +1 -0
- package/lib-commonjs/state/useToaster.js +171 -0
- package/lib-commonjs/state/useToaster.js.map +1 -0
- package/lib-commonjs/state/vanilla/createToaster.js +142 -0
- package/lib-commonjs/state/vanilla/createToaster.js.map +1 -0
- package/lib-commonjs/state/vanilla/dismissAllToasts.js +19 -0
- package/lib-commonjs/state/vanilla/dismissAllToasts.js.map +1 -0
- package/lib-commonjs/state/vanilla/dismissToast.js +20 -0
- package/lib-commonjs/state/vanilla/dismissToast.js.map +1 -0
- package/lib-commonjs/state/vanilla/dispatchToast.js +24 -0
- package/lib-commonjs/state/vanilla/dispatchToast.js.map +1 -0
- package/lib-commonjs/state/vanilla/getPositionStyles.js +48 -0
- package/lib-commonjs/state/vanilla/getPositionStyles.js.map +1 -0
- package/lib-commonjs/state/vanilla/index.js +13 -0
- package/lib-commonjs/state/vanilla/index.js.map +1 -0
- package/lib-commonjs/state/vanilla/pauseToast.js +20 -0
- package/lib-commonjs/state/vanilla/pauseToast.js.map +1 -0
- package/lib-commonjs/state/vanilla/playToast.js +20 -0
- package/lib-commonjs/state/vanilla/playToast.js.map +1 -0
- package/lib-commonjs/state/vanilla/updateToast.js +17 -0
- package/lib-commonjs/state/vanilla/updateToast.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["toastContainerContext.js"],"sourcesContent":["import * as React from 'react';\nconst toastContainerContextDefaultValue = {\n close: ()=>null,\n intent: undefined,\n bodyId: '',\n titleId: ''\n};\nconst ToastContainerContext = /*#__PURE__*/ React.createContext(undefined);\nexport const ToastContainerContextProvider = ToastContainerContext.Provider;\nvar _React_useContext;\nexport const useToastContainerContext = ()=>(_React_useContext = React.useContext(ToastContainerContext)) !== null && _React_useContext !== void 0 ? _React_useContext : toastContainerContextDefaultValue;\n"],"names":["ToastContainerContextProvider","useToastContainerContext","toastContainerContextDefaultValue","close","intent","undefined","bodyId","titleId","ToastContainerContext","React","createContext","Provider","_React_useContext","useContext"],"mappings":";;;;;;;;;;;IAQaA,6BAA6B,MAA7BA;IAEAC,wBAAwB,MAAxBA;;;6DAVU;AACvB,MAAMC,oCAAoC;IACtCC,OAAO,IAAI,IAAI;IACfC,QAAQC;IACRC,QAAQ;IACRC,SAAS;AACb;AACA,MAAMC,wBAAwB,WAAW,GAAGC,OAAMC,aAAa,CAACL;AACzD,MAAML,gCAAgCQ,sBAAsBG,QAAQ;AAC3E,IAAIC;AACG,MAAMX,2BAA2B,IAAI,AAACW,CAAAA,oBAAoBH,OAAMI,UAAU,CAACL,sBAAqB,MAAO,IAAI,IAAII,sBAAsB,KAAK,IAAIA,oBAAoBV,iCAAiC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
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
|
|
41
|
+
});
|
|
42
|
+
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");
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
EVENTS: ()=>EVENTS,
|
|
13
|
+
TOAST_POSITIONS: ()=>TOAST_POSITIONS
|
|
14
|
+
});
|
|
15
|
+
const EVENTS = {
|
|
16
|
+
show: 'fui-toast-show',
|
|
17
|
+
dismiss: 'fui-toast-dismiss',
|
|
18
|
+
dismissAll: 'fui-toast-dismiss-all',
|
|
19
|
+
update: 'fui-toast-update',
|
|
20
|
+
pause: 'fui-toast-pause',
|
|
21
|
+
play: 'fui-toast-play'
|
|
22
|
+
};
|
|
23
|
+
const TOAST_POSITIONS = {
|
|
24
|
+
bottomEnd: 'bottom-end',
|
|
25
|
+
bottomStart: 'bottom-start',
|
|
26
|
+
topEnd: 'top-end',
|
|
27
|
+
topStart: 'top-start'
|
|
28
|
+
};
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
getPositionStyles: ()=>_vanilla.getPositionStyles,
|
|
13
|
+
TOAST_POSITIONS: ()=>_constants.TOAST_POSITIONS
|
|
14
|
+
});
|
|
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 _vanilla = require("./vanilla");
|
|
20
|
+
const _constants = require("./constants");
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;6DAAuB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useToastController", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>useToastController
|
|
8
|
+
});
|
|
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");
|
|
12
|
+
const _vanilla = require("./vanilla");
|
|
13
|
+
const noop = ()=>undefined;
|
|
14
|
+
function useToastController(toasterId) {
|
|
15
|
+
const { targetDocument } = (0, _reactSharedContexts.useFluent_unstable)();
|
|
16
|
+
return _react.useMemo(()=>{
|
|
17
|
+
if (!targetDocument) {
|
|
18
|
+
return {
|
|
19
|
+
dispatchToast: noop,
|
|
20
|
+
dismissToast: noop,
|
|
21
|
+
dismissAllToasts: noop,
|
|
22
|
+
updateToast: noop,
|
|
23
|
+
pauseToast: noop,
|
|
24
|
+
playToast: noop
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
dispatchToast: (content, options)=>{
|
|
29
|
+
(0, _vanilla.dispatchToast)(content, {
|
|
30
|
+
...options,
|
|
31
|
+
toasterId,
|
|
32
|
+
data: {
|
|
33
|
+
root: options === null || options === void 0 ? void 0 : options.root
|
|
34
|
+
}
|
|
35
|
+
}, targetDocument);
|
|
36
|
+
},
|
|
37
|
+
dismissToast: (toastId)=>{
|
|
38
|
+
(0, _vanilla.dismissToast)(toastId, toasterId, targetDocument);
|
|
39
|
+
},
|
|
40
|
+
dismissAllToasts: ()=>{
|
|
41
|
+
(0, _vanilla.dismissAllToasts)(toasterId, targetDocument);
|
|
42
|
+
},
|
|
43
|
+
updateToast: (options)=>{
|
|
44
|
+
(0, _vanilla.updateToast)({
|
|
45
|
+
...options,
|
|
46
|
+
data: {
|
|
47
|
+
root: options.root
|
|
48
|
+
},
|
|
49
|
+
toasterId
|
|
50
|
+
}, targetDocument);
|
|
51
|
+
},
|
|
52
|
+
pauseToast: (toastId)=>{
|
|
53
|
+
(0, _vanilla.pauseToast)(toastId, toasterId, targetDocument);
|
|
54
|
+
},
|
|
55
|
+
playToast: (toastId)=>{
|
|
56
|
+
(0, _vanilla.playToast)(toastId, toasterId, targetDocument);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}, [
|
|
60
|
+
targetDocument,
|
|
61
|
+
toasterId
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useToaster", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>useToaster
|
|
8
|
+
});
|
|
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");
|
|
13
|
+
const _vanilla = require("./vanilla");
|
|
14
|
+
const _constants = require("./constants");
|
|
15
|
+
function useToaster(options = {}) {
|
|
16
|
+
const forceUpdate = (0, _reactUtilities.useForceUpdate)();
|
|
17
|
+
const { toasterId: userToasterId , shortcuts } = options;
|
|
18
|
+
// Currently the toaster options can never be changed at runtime
|
|
19
|
+
const [toaster] = _react.useState(()=>(0, _vanilla.createToaster)(options));
|
|
20
|
+
const { targetDocument } = (0, _reactSharedContexts.useFluent_unstable)();
|
|
21
|
+
const lastActiveElementRef = _react.useRef(null);
|
|
22
|
+
const isCorrectToaster = (0, _reactUtilities.useEventCallback)((toasterId)=>{
|
|
23
|
+
return toasterId === userToasterId;
|
|
24
|
+
});
|
|
25
|
+
const isFocusShortcut = (0, _reactUtilities.useEventCallback)((e)=>{
|
|
26
|
+
if (shortcuts === null || shortcuts === void 0 ? void 0 : shortcuts.focus) {
|
|
27
|
+
return shortcuts.focus(e);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const tryRestoreFocus = _react.useCallback(()=>{
|
|
31
|
+
var _lastActiveElementRef_current;
|
|
32
|
+
(_lastActiveElementRef_current = lastActiveElementRef.current) === null || _lastActiveElementRef_current === void 0 ? void 0 : _lastActiveElementRef_current.focus();
|
|
33
|
+
lastActiveElementRef.current = null;
|
|
34
|
+
}, []);
|
|
35
|
+
const pauseAllToasts = _react.useCallback(()=>{
|
|
36
|
+
toaster.visibleToasts.forEach((toastId)=>{
|
|
37
|
+
var _toast_imperativeRef_current;
|
|
38
|
+
const toast = toaster.toasts.get(toastId);
|
|
39
|
+
(_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();
|
|
40
|
+
});
|
|
41
|
+
}, [
|
|
42
|
+
toaster
|
|
43
|
+
]);
|
|
44
|
+
const playAllToasts = _react.useCallback(()=>{
|
|
45
|
+
toaster.visibleToasts.forEach((toastId)=>{
|
|
46
|
+
var _toast_imperativeRef_current;
|
|
47
|
+
const toast = toaster.toasts.get(toastId);
|
|
48
|
+
(_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();
|
|
49
|
+
});
|
|
50
|
+
}, [
|
|
51
|
+
toaster
|
|
52
|
+
]);
|
|
53
|
+
const getMostRecentVisibleToast = _react.useCallback(()=>{
|
|
54
|
+
return Array.from(toaster.visibleToasts).reduce((cur, next)=>{
|
|
55
|
+
const toast = toaster.toasts.get(next);
|
|
56
|
+
if (!toast) {
|
|
57
|
+
return cur;
|
|
58
|
+
}
|
|
59
|
+
if (!cur) {
|
|
60
|
+
return toast;
|
|
61
|
+
}
|
|
62
|
+
if (cur.order < (toast === null || toast === void 0 ? void 0 : toast.order)) {
|
|
63
|
+
return toast;
|
|
64
|
+
}
|
|
65
|
+
return cur;
|
|
66
|
+
}, undefined);
|
|
67
|
+
}, [
|
|
68
|
+
toaster
|
|
69
|
+
]);
|
|
70
|
+
_react.useEffect(()=>{
|
|
71
|
+
if (!targetDocument) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const addToastListener = (eventType, callback)=>{
|
|
75
|
+
const listener = (e)=>{
|
|
76
|
+
if (!isCorrectToaster(e.detail.toasterId)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
callback(e);
|
|
80
|
+
forceUpdate();
|
|
81
|
+
};
|
|
82
|
+
targetDocument.addEventListener(eventType, listener);
|
|
83
|
+
return ()=>targetDocument.removeEventListener(eventType, listener);
|
|
84
|
+
};
|
|
85
|
+
const buildToast = (e)=>{
|
|
86
|
+
toaster.buildToast(e.detail, forceUpdate);
|
|
87
|
+
};
|
|
88
|
+
const dismissToast = (e)=>{
|
|
89
|
+
toaster.dismissToast(e.detail.toastId);
|
|
90
|
+
};
|
|
91
|
+
const updateToast = (e)=>{
|
|
92
|
+
toaster.updateToast(e.detail);
|
|
93
|
+
};
|
|
94
|
+
const dismissAllToasts = (e)=>{
|
|
95
|
+
toaster.dismissAllToasts();
|
|
96
|
+
};
|
|
97
|
+
const pauseToast = (e)=>{
|
|
98
|
+
const toast = toaster.toasts.get(e.detail.toastId);
|
|
99
|
+
if (toast) {
|
|
100
|
+
var _toast_imperativeRef_current;
|
|
101
|
+
(_toast_imperativeRef_current = toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.pause();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const playToast = (e)=>{
|
|
105
|
+
const toast = toaster.toasts.get(e.detail.toastId);
|
|
106
|
+
if (toast) {
|
|
107
|
+
var _toast_imperativeRef_current;
|
|
108
|
+
(_toast_imperativeRef_current = toast.imperativeRef.current) === null || _toast_imperativeRef_current === void 0 ? void 0 : _toast_imperativeRef_current.play();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const cleanupBuildListener = addToastListener(_constants.EVENTS.show, buildToast);
|
|
112
|
+
const cleanupUpdateListener = addToastListener(_constants.EVENTS.update, updateToast);
|
|
113
|
+
const cleanupDismissListener = addToastListener(_constants.EVENTS.dismiss, dismissToast);
|
|
114
|
+
const cleanupDismissAllListener = addToastListener(_constants.EVENTS.dismissAll, dismissAllToasts);
|
|
115
|
+
const cleanupPauseListener = addToastListener(_constants.EVENTS.pause, pauseToast);
|
|
116
|
+
const cleanupPlayListener = addToastListener(_constants.EVENTS.play, playToast);
|
|
117
|
+
const focusShortcutListener = (e)=>{
|
|
118
|
+
if (isFocusShortcut(e)) {
|
|
119
|
+
pauseAllToasts();
|
|
120
|
+
const mostRecentToast = getMostRecentVisibleToast();
|
|
121
|
+
if (mostRecentToast) {
|
|
122
|
+
var _mostRecentToast_imperativeRef_current;
|
|
123
|
+
lastActiveElementRef.current = (0, _reactUtilities.isHTMLElement)(targetDocument.activeElement) ? targetDocument.activeElement : null;
|
|
124
|
+
(_mostRecentToast_imperativeRef_current = mostRecentToast.imperativeRef.current) === null || _mostRecentToast_imperativeRef_current === void 0 ? void 0 : _mostRecentToast_imperativeRef_current.focus();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
targetDocument.addEventListener('keydown', focusShortcutListener);
|
|
129
|
+
return ()=>{
|
|
130
|
+
cleanupBuildListener();
|
|
131
|
+
cleanupDismissAllListener();
|
|
132
|
+
cleanupUpdateListener();
|
|
133
|
+
cleanupDismissListener();
|
|
134
|
+
cleanupPauseListener();
|
|
135
|
+
cleanupPlayListener();
|
|
136
|
+
targetDocument.removeEventListener('keydown', focusShortcutListener);
|
|
137
|
+
};
|
|
138
|
+
}, [
|
|
139
|
+
toaster,
|
|
140
|
+
forceUpdate,
|
|
141
|
+
targetDocument,
|
|
142
|
+
isCorrectToaster,
|
|
143
|
+
pauseAllToasts,
|
|
144
|
+
getMostRecentVisibleToast,
|
|
145
|
+
isFocusShortcut
|
|
146
|
+
]);
|
|
147
|
+
const toastsToRender = (()=>{
|
|
148
|
+
if (!toaster) {
|
|
149
|
+
return new Map();
|
|
150
|
+
}
|
|
151
|
+
const toRender = new Map();
|
|
152
|
+
const toasts = Array.from(toaster.toasts.values());
|
|
153
|
+
toasts.forEach((toast)=>{
|
|
154
|
+
const { position } = toast;
|
|
155
|
+
toRender.has(position) || toRender.set(position, []);
|
|
156
|
+
if (position.startsWith('bottom')) {
|
|
157
|
+
toRender.get(position).push(toast);
|
|
158
|
+
} else {
|
|
159
|
+
toRender.get(position).unshift(toast);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
return toRender;
|
|
163
|
+
})();
|
|
164
|
+
return {
|
|
165
|
+
isToastVisible: toaster.isToastVisible,
|
|
166
|
+
toastsToRender,
|
|
167
|
+
pauseAllToasts,
|
|
168
|
+
playAllToasts,
|
|
169
|
+
tryRestoreFocus
|
|
170
|
+
};
|
|
171
|
+
}
|
|
@@ -0,0 +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 tryRestoreFocus = React.useCallback(()=>{\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 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 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 };\n}\n"],"names":["useToaster","options","forceUpdate","useForceUpdate","toasterId","userToasterId","shortcuts","toaster","React","useState","createToaster","targetDocument","useFluent","lastActiveElementRef","useRef","isCorrectToaster","useEventCallback","isFocusShortcut","e","focus","tryRestoreFocus","useCallback","_lastActiveElementRef_current","current","pauseAllToasts","visibleToasts","forEach","toastId","_toast_imperativeRef_current","toast","toasts","get","imperativeRef","pause","playAllToasts","play","getMostRecentVisibleToast","Array","from","reduce","cur","next","order","undefined","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","_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,kBAAkBZ,OAAMa,WAAW,CAAC,IAAI;QAC1C,IAAIC;QACHA,CAAAA,gCAAgCT,qBAAqBU,OAAO,AAAD,MAAO,IAAI,IAAID,kCAAkC,KAAK,IAAI,KAAK,IAAIA,8BAA8BH,KAAK,EAAE;QACpKN,qBAAqBU,OAAO,GAAG,IAAI;IACvC,GAAG,EAAE;IACL,MAAMC,iBAAiBhB,OAAMa,WAAW,CAAC,IAAI;QACzCd,QAAQkB,aAAa,CAACC,OAAO,CAAC,CAACC,UAAU;YACrC,IAAIC;YACJ,MAAMC,QAAQtB,QAAQuB,MAAM,CAACC,GAAG,CAACJ;YAChCC,CAAAA,+BAA+BC,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAI,KAAK,I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AAO;gBACH+C,SAAS7C,GAAG,CAAC+C,UAAUK,OAAO,CAACtD;YACnC,CAAC;QACL;QACA,OAAO+C;IACX,CAAA;IACA,OAAO;QACHQ,gBAAgB7E,QAAQ6E,cAAc;QACtCV;QACAlD;QACAU;QACAd;IACJ;AACJ"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "createToaster", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>createToaster
|
|
8
|
+
});
|
|
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
|
+
function assignDefined(a, b) {
|
|
13
|
+
// This cast is required, as Object.entries will return string as key which is not indexable
|
|
14
|
+
for (const [key, prop] of Object.entries(b)){
|
|
15
|
+
// eslint-disable-next-line eqeqeq
|
|
16
|
+
if (prop != undefined) {
|
|
17
|
+
a[key] = prop;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const defaulToastOptions = {
|
|
22
|
+
onStatusChange: undefined,
|
|
23
|
+
priority: 0,
|
|
24
|
+
pauseOnHover: false,
|
|
25
|
+
pauseOnWindowBlur: false,
|
|
26
|
+
position: 'bottom-end',
|
|
27
|
+
timeout: 3000
|
|
28
|
+
};
|
|
29
|
+
// Multiple toasts can be dispatched in a single tick, use counter to prevent collisions
|
|
30
|
+
let counter = 0;
|
|
31
|
+
function createToaster(options) {
|
|
32
|
+
const { limit =Number.POSITIVE_INFINITY } = options;
|
|
33
|
+
const visibleToasts = new Set();
|
|
34
|
+
const toasts = new Map();
|
|
35
|
+
const queue = (0, _reactUtilities.createPriorityQueue)((ta, tb)=>{
|
|
36
|
+
const a = toasts.get(ta);
|
|
37
|
+
const b = toasts.get(tb);
|
|
38
|
+
if (!a || !b) {
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
if (a.priority === b.priority) {
|
|
42
|
+
return a.order - b.order;
|
|
43
|
+
}
|
|
44
|
+
return a.priority - b.priority;
|
|
45
|
+
});
|
|
46
|
+
const isToastVisible = (toastId)=>{
|
|
47
|
+
return visibleToasts.has(toastId);
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Updates an existing toast with any available option
|
|
51
|
+
*/ const updateToast = (toastOptions)=>{
|
|
52
|
+
const { toastId } = toastOptions;
|
|
53
|
+
const toastToUpdate = toasts.get(toastId);
|
|
54
|
+
if (!toastToUpdate) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
Object.assign(toastToUpdate, toastOptions);
|
|
58
|
+
toastToUpdate.updateId++;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Dismisses a toast with a specific id
|
|
62
|
+
*/ const dismissToast = (toastId)=>{
|
|
63
|
+
visibleToasts.delete(toastId);
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Dismisses all toasts and clears the queue
|
|
67
|
+
*/ const dismissAllToasts = ()=>{
|
|
68
|
+
visibleToasts.clear();
|
|
69
|
+
queue.clear();
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* @param toastOptions user configured options
|
|
73
|
+
* @param onUpdate Some toast methods can result in UI changes (i.e. close) use this to dispatch callbacks
|
|
74
|
+
*/ const buildToast = (toastOptions, onUpdate)=>{
|
|
75
|
+
var _toast_onStatusChange;
|
|
76
|
+
const { toastId , content , toasterId } = toastOptions;
|
|
77
|
+
if (toasts.has(toastId)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const close = ()=>{
|
|
81
|
+
var _toast_onStatusChange;
|
|
82
|
+
const toast = toasts.get(toastId);
|
|
83
|
+
if (!toast) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
visibleToasts.delete(toastId);
|
|
87
|
+
onUpdate();
|
|
88
|
+
(_toast_onStatusChange = toast.onStatusChange) === null || _toast_onStatusChange === void 0 ? void 0 : _toast_onStatusChange.call(toast, null, {
|
|
89
|
+
status: 'dismissed',
|
|
90
|
+
...toast
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
const remove = ()=>{
|
|
94
|
+
const toast = toasts.get(toastId);
|
|
95
|
+
if (!toast) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
toasts.delete(toastId);
|
|
99
|
+
if (visibleToasts.size < limit && queue.peek()) {
|
|
100
|
+
const nextToast = toasts.get(queue.dequeue());
|
|
101
|
+
if (!nextToast) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
visibleToasts.add(nextToast.toastId);
|
|
105
|
+
}
|
|
106
|
+
onUpdate();
|
|
107
|
+
};
|
|
108
|
+
const toast = {
|
|
109
|
+
...defaulToastOptions,
|
|
110
|
+
close,
|
|
111
|
+
remove,
|
|
112
|
+
toastId,
|
|
113
|
+
content,
|
|
114
|
+
updateId: 0,
|
|
115
|
+
toasterId,
|
|
116
|
+
order: counter++,
|
|
117
|
+
data: {},
|
|
118
|
+
imperativeRef: /*#__PURE__*/ _react.createRef()
|
|
119
|
+
};
|
|
120
|
+
assignDefined(toast, options);
|
|
121
|
+
assignDefined(toast, toastOptions);
|
|
122
|
+
toasts.set(toastId, toast);
|
|
123
|
+
(_toast_onStatusChange = toast.onStatusChange) === null || _toast_onStatusChange === void 0 ? void 0 : _toast_onStatusChange.call(toast, null, {
|
|
124
|
+
status: 'queued',
|
|
125
|
+
...toast
|
|
126
|
+
});
|
|
127
|
+
if (visibleToasts.size >= limit) {
|
|
128
|
+
queue.enqueue(toastId);
|
|
129
|
+
} else {
|
|
130
|
+
visibleToasts.add(toastId);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
buildToast,
|
|
135
|
+
dismissAllToasts,
|
|
136
|
+
dismissToast,
|
|
137
|
+
isToastVisible,
|
|
138
|
+
updateToast,
|
|
139
|
+
visibleToasts,
|
|
140
|
+
toasts
|
|
141
|
+
};
|
|
142
|
+
}
|
|
@@ -0,0 +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,EAAES,QAAQ,GAAGR,EAAEQ,QAAQ;IAClC;IACA,MAAMoB,iBAAiB,CAACC,UAAU;QAC9B,OAAOX,cAAcY,GAAG,CAACD;IAC7B;IACA;;GAED,GAAG,MAAME,cAAc,CAACC,eAAe;QAClC,MAAM,EAAEH,QAAO,EAAG,GAAGG;QACrB,MAAMC,gBAAgBb,OAAOM,GAAG,CAACG;QACjC,IAAI,CAACI,eAAe;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,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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "dismissAllToasts", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>dismissAllToasts
|
|
8
|
+
});
|
|
9
|
+
const _constants = require("../constants");
|
|
10
|
+
function dismissAllToasts(toasterId = undefined, targetDocument) {
|
|
11
|
+
const event = new CustomEvent(_constants.EVENTS.dismissAll, {
|
|
12
|
+
bubbles: false,
|
|
13
|
+
cancelable: false,
|
|
14
|
+
detail: {
|
|
15
|
+
toasterId
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
targetDocument.dispatchEvent(event);
|
|
19
|
+
}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "dismissToast", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>dismissToast
|
|
8
|
+
});
|
|
9
|
+
const _constants = require("../constants");
|
|
10
|
+
function dismissToast(toastId, toasterId = undefined, targetDocument) {
|
|
11
|
+
const event = new CustomEvent(_constants.EVENTS.dismiss, {
|
|
12
|
+
bubbles: false,
|
|
13
|
+
cancelable: false,
|
|
14
|
+
detail: {
|
|
15
|
+
toastId,
|
|
16
|
+
toasterId
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
targetDocument.dispatchEvent(event);
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["dismissToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nexport function dismissToast(toastId, toasterId = undefined, targetDocument) {\n const event = new CustomEvent(EVENTS.dismiss, {\n bubbles: false,\n cancelable: false,\n detail: {\n toastId,\n toasterId\n }\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["dismissToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","EVENTS","dismiss","bubbles","cancelable","detail","dispatchEvent"],"mappings":";;;;+BACgBA;;aAAAA;;2BADO;AAChB,SAASA,aAAaC,OAAO,EAAEC,YAAYC,SAAS,EAAEC,cAAc,EAAE;IACzE,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,OAAO,EAAE;QAC1CC,SAAS,KAAK;QACdC,YAAY,KAAK;QACjBC,QAAQ;YACJV;YACAC;QACJ;IACJ;IACAE,eAAeQ,aAAa,CAACP;AACjC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "dispatchToast", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>dispatchToast
|
|
8
|
+
});
|
|
9
|
+
const _constants = require("../constants");
|
|
10
|
+
let counter = 0;
|
|
11
|
+
function dispatchToast(content, options = {}, targetDocument) {
|
|
12
|
+
var _options_toastId;
|
|
13
|
+
const detail = {
|
|
14
|
+
...options,
|
|
15
|
+
content,
|
|
16
|
+
toastId: (_options_toastId = options.toastId) !== null && _options_toastId !== void 0 ? _options_toastId : (counter++).toString()
|
|
17
|
+
};
|
|
18
|
+
const event = new CustomEvent(_constants.EVENTS.show, {
|
|
19
|
+
bubbles: false,
|
|
20
|
+
cancelable: false,
|
|
21
|
+
detail
|
|
22
|
+
});
|
|
23
|
+
targetDocument.dispatchEvent(event);
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["dispatchToast.js"],"sourcesContent":["import { EVENTS } from '../constants';\nlet counter = 0;\nexport function dispatchToast(content, options = {}, targetDocument) {\n var _options_toastId;\n const detail = {\n ...options,\n content,\n toastId: (_options_toastId = options.toastId) !== null && _options_toastId !== void 0 ? _options_toastId : (counter++).toString()\n };\n const event = new CustomEvent(EVENTS.show, {\n bubbles: false,\n cancelable: false,\n detail\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["dispatchToast","counter","content","options","targetDocument","_options_toastId","detail","toastId","toString","event","CustomEvent","EVENTS","show","bubbles","cancelable","dispatchEvent"],"mappings":";;;;+BAEgBA;;aAAAA;;2BAFO;AACvB,IAAIC,UAAU;AACP,SAASD,cAAcE,OAAO,EAAEC,UAAU,CAAC,CAAC,EAAEC,cAAc,EAAE;IACjE,IAAIC;IACJ,MAAMC,SAAS;QACX,GAAGH,OAAO;QACVD;QACAK,SAAS,AAACF,CAAAA,mBAAmBF,QAAQI,OAAO,AAAD,MAAO,IAAI,IAAIF,qBAAqB,KAAK,IAAIA,mBAAmB,AAACJ,CAAAA,SAAQ,EAAGO,QAAQ,EAAE;IACrI;IACA,MAAMC,QAAQ,IAAIC,YAAYC,iBAAM,CAACC,IAAI,EAAE;QACvCC,SAAS,KAAK;QACdC,YAAY,KAAK;QACjBR;IACJ;IACAF,eAAeW,aAAa,CAACN;AACjC"}
|