@fluentui/react-toast 9.5.5 → 9.6.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.
- package/CHANGELOG.md +29 -2
- package/lib/AriaLive.js.map +1 -1
- package/lib/Toast.js.map +1 -1
- package/lib/ToastBody.js.map +1 -1
- package/lib/ToastContainer.js.map +1 -1
- package/lib/ToastFooter.js.map +1 -1
- package/lib/ToastTitle.js.map +1 -1
- package/lib/ToastTrigger.js.map +1 -1
- package/lib/Toaster.js.map +1 -1
- package/lib/components/AriaLive/AriaLive.js.map +1 -1
- package/lib/components/AriaLive/AriaLive.types.js.map +1 -1
- package/lib/components/AriaLive/index.js.map +1 -1
- package/lib/components/AriaLive/renderAriaLive.js.map +1 -1
- package/lib/components/AriaLive/useAriaLive.js.map +1 -1
- package/lib/components/AriaLive/useAriaLiveStyles.styles.raw.js +25 -0
- package/lib/components/AriaLive/useAriaLiveStyles.styles.raw.js.map +1 -0
- package/lib/components/Timer/Timer.js.map +1 -1
- package/lib/components/Timer/index.js.map +1 -1
- package/lib/components/Timer/useTimerStyles.styles.raw.js +11 -0
- package/lib/components/Timer/useTimerStyles.styles.raw.js.map +1 -0
- package/lib/components/Toast/Toast.js.map +1 -1
- package/lib/components/Toast/Toast.types.js.map +1 -1
- package/lib/components/Toast/index.js.map +1 -1
- package/lib/components/Toast/renderToast.js.map +1 -1
- package/lib/components/Toast/useToast.js.map +1 -1
- package/lib/components/Toast/useToastContextValues.js.map +1 -1
- package/lib/components/Toast/useToastStyles.styles.raw.js +33 -0
- package/lib/components/Toast/useToastStyles.styles.raw.js.map +1 -0
- package/lib/components/ToastBody/ToastBody.js.map +1 -1
- package/lib/components/ToastBody/ToastBody.types.js.map +1 -1
- package/lib/components/ToastBody/index.js.map +1 -1
- package/lib/components/ToastBody/renderToastBody.js.map +1 -1
- package/lib/components/ToastBody/useToastBody.js.map +1 -1
- package/lib/components/ToastBody/useToastBodyStyles.styles.raw.js +46 -0
- package/lib/components/ToastBody/useToastBodyStyles.styles.raw.js.map +1 -0
- package/lib/components/ToastContainer/ToastContainer.js.map +1 -1
- package/lib/components/ToastContainer/ToastContainer.types.js.map +1 -1
- package/lib/components/ToastContainer/index.js.map +1 -1
- package/lib/components/ToastContainer/renderToastContainer.js.map +1 -1
- package/lib/components/ToastContainer/useToastContainer.js.map +1 -1
- package/lib/components/ToastContainer/useToastContainerContextValues.js.map +1 -1
- package/lib/components/ToastContainer/useToastContainerStyles.styles.raw.js +24 -0
- package/lib/components/ToastContainer/useToastContainerStyles.styles.raw.js.map +1 -0
- package/lib/components/ToastFooter/ToastFooter.js.map +1 -1
- package/lib/components/ToastFooter/ToastFooter.types.js.map +1 -1
- package/lib/components/ToastFooter/index.js.map +1 -1
- package/lib/components/ToastFooter/renderToastFooter.js.map +1 -1
- package/lib/components/ToastFooter/useToastFooter.js.map +1 -1
- package/lib/components/ToastFooter/useToastFooterStyles.styles.raw.js +22 -0
- package/lib/components/ToastFooter/useToastFooterStyles.styles.raw.js.map +1 -0
- package/lib/components/ToastTitle/ToastTitle.js.map +1 -1
- package/lib/components/ToastTitle/ToastTitle.types.js.map +1 -1
- package/lib/components/ToastTitle/index.js.map +1 -1
- package/lib/components/ToastTitle/renderToastTitle.js.map +1 -1
- package/lib/components/ToastTitle/useToastTitle.js.map +1 -1
- package/lib/components/ToastTitle/useToastTitleStyles.styles.raw.js +87 -0
- package/lib/components/ToastTitle/useToastTitleStyles.styles.raw.js.map +1 -0
- package/lib/components/ToastTrigger/ToastTrigger.js.map +1 -1
- package/lib/components/ToastTrigger/ToastTrigger.types.js.map +1 -1
- package/lib/components/ToastTrigger/index.js.map +1 -1
- package/lib/components/ToastTrigger/renderToastTrigger.js.map +1 -1
- package/lib/components/ToastTrigger/useToastTrigger.js.map +1 -1
- package/lib/components/Toaster/Toaster.js.map +1 -1
- package/lib/components/Toaster/Toaster.types.js.map +1 -1
- package/lib/components/Toaster/index.js.map +1 -1
- package/lib/components/Toaster/renderToaster.js.map +1 -1
- package/lib/components/Toaster/useToastAnnounce.js.map +1 -1
- package/lib/components/Toaster/useToaster.js.map +1 -1
- package/lib/components/Toaster/useToasterFocusManagement.js.map +1 -1
- package/lib/components/Toaster/useToasterStyles.styles.raw.js +68 -0
- package/lib/components/Toaster/useToasterStyles.styles.raw.js.map +1 -0
- package/lib/contexts/toastContainerContext.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/state/constants.js.map +1 -1
- package/lib/state/index.js.map +1 -1
- package/lib/state/types.js.map +1 -1
- package/lib/state/useToastController.js.map +1 -1
- package/lib/state/useToaster.js.map +1 -1
- package/lib/state/vanilla/createToaster.js.map +1 -1
- package/lib/state/vanilla/dismissAllToasts.js.map +1 -1
- package/lib/state/vanilla/dismissToast.js.map +1 -1
- package/lib/state/vanilla/dispatchToast.js.map +1 -1
- package/lib/state/vanilla/getPositionStyles.js.map +1 -1
- package/lib/state/vanilla/index.js.map +1 -1
- package/lib/state/vanilla/pauseToast.js.map +1 -1
- package/lib/state/vanilla/playToast.js.map +1 -1
- package/lib/state/vanilla/updateToast.js.map +1 -1
- package/lib-commonjs/AriaLive.js.map +1 -1
- package/lib-commonjs/Toast.js.map +1 -1
- package/lib-commonjs/ToastBody.js.map +1 -1
- package/lib-commonjs/ToastContainer.js.map +1 -1
- package/lib-commonjs/ToastFooter.js.map +1 -1
- package/lib-commonjs/ToastTitle.js.map +1 -1
- package/lib-commonjs/ToastTrigger.js.map +1 -1
- package/lib-commonjs/Toaster.js.map +1 -1
- package/lib-commonjs/components/AriaLive/AriaLive.js.map +1 -1
- package/lib-commonjs/components/AriaLive/AriaLive.types.js.map +1 -1
- package/lib-commonjs/components/AriaLive/index.js.map +1 -1
- package/lib-commonjs/components/AriaLive/renderAriaLive.js.map +1 -1
- package/lib-commonjs/components/AriaLive/useAriaLive.js.map +1 -1
- package/lib-commonjs/components/AriaLive/useAriaLiveStyles.styles.js.map +1 -1
- package/lib-commonjs/components/AriaLive/useAriaLiveStyles.styles.raw.js +41 -0
- package/lib-commonjs/components/AriaLive/useAriaLiveStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/Timer/Timer.js.map +1 -1
- package/lib-commonjs/components/Timer/index.js.map +1 -1
- package/lib-commonjs/components/Timer/useTimerStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Timer/useTimerStyles.styles.raw.js +21 -0
- package/lib-commonjs/components/Timer/useTimerStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/Toast/Toast.js.map +1 -1
- package/lib-commonjs/components/Toast/Toast.types.js.map +1 -1
- package/lib-commonjs/components/Toast/index.js.map +1 -1
- package/lib-commonjs/components/Toast/renderToast.js.map +1 -1
- package/lib-commonjs/components/Toast/useToast.js.map +1 -1
- package/lib-commonjs/components/Toast/useToastContextValues.js.map +1 -1
- package/lib-commonjs/components/Toast/useToastStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Toast/useToastStyles.styles.raw.js +49 -0
- package/lib-commonjs/components/Toast/useToastStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/ToastBody/ToastBody.js.map +1 -1
- package/lib-commonjs/components/ToastBody/ToastBody.types.js.map +1 -1
- package/lib-commonjs/components/ToastBody/index.js.map +1 -1
- package/lib-commonjs/components/ToastBody/renderToastBody.js.map +1 -1
- package/lib-commonjs/components/ToastBody/useToastBody.js.map +1 -1
- package/lib-commonjs/components/ToastBody/useToastBodyStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ToastBody/useToastBodyStyles.styles.raw.js +62 -0
- package/lib-commonjs/components/ToastBody/useToastBodyStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/ToastContainer/ToastContainer.js.map +1 -1
- package/lib-commonjs/components/ToastContainer/ToastContainer.types.js.map +1 -1
- package/lib-commonjs/components/ToastContainer/index.js.map +1 -1
- package/lib-commonjs/components/ToastContainer/renderToastContainer.js.map +1 -1
- package/lib-commonjs/components/ToastContainer/useToastContainer.js.map +1 -1
- package/lib-commonjs/components/ToastContainer/useToastContainerContextValues.js.map +1 -1
- package/lib-commonjs/components/ToastContainer/useToastContainerStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ToastContainer/useToastContainerStyles.styles.raw.js +40 -0
- package/lib-commonjs/components/ToastContainer/useToastContainerStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/ToastFooter/ToastFooter.js.map +1 -1
- package/lib-commonjs/components/ToastFooter/ToastFooter.types.js.map +1 -1
- package/lib-commonjs/components/ToastFooter/index.js.map +1 -1
- package/lib-commonjs/components/ToastFooter/renderToastFooter.js.map +1 -1
- package/lib-commonjs/components/ToastFooter/useToastFooter.js.map +1 -1
- package/lib-commonjs/components/ToastFooter/useToastFooterStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ToastFooter/useToastFooterStyles.styles.raw.js +38 -0
- package/lib-commonjs/components/ToastFooter/useToastFooterStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/ToastTitle/ToastTitle.js.map +1 -1
- package/lib-commonjs/components/ToastTitle/ToastTitle.types.js.map +1 -1
- package/lib-commonjs/components/ToastTitle/index.js.map +1 -1
- package/lib-commonjs/components/ToastTitle/renderToastTitle.js.map +1 -1
- package/lib-commonjs/components/ToastTitle/useToastTitle.js.map +1 -1
- package/lib-commonjs/components/ToastTitle/useToastTitleStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ToastTitle/useToastTitleStyles.styles.raw.js +103 -0
- package/lib-commonjs/components/ToastTitle/useToastTitleStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/ToastTrigger/ToastTrigger.js.map +1 -1
- package/lib-commonjs/components/ToastTrigger/ToastTrigger.types.js.map +1 -1
- package/lib-commonjs/components/ToastTrigger/index.js.map +1 -1
- package/lib-commonjs/components/ToastTrigger/renderToastTrigger.js.map +1 -1
- package/lib-commonjs/components/ToastTrigger/useToastTrigger.js.map +1 -1
- package/lib-commonjs/components/Toaster/Toaster.js.map +1 -1
- package/lib-commonjs/components/Toaster/Toaster.types.js.map +1 -1
- package/lib-commonjs/components/Toaster/index.js.map +1 -1
- package/lib-commonjs/components/Toaster/renderToaster.js.map +1 -1
- package/lib-commonjs/components/Toaster/useToastAnnounce.js.map +1 -1
- package/lib-commonjs/components/Toaster/useToaster.js.map +1 -1
- package/lib-commonjs/components/Toaster/useToasterFocusManagement.js.map +1 -1
- package/lib-commonjs/components/Toaster/useToasterStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Toaster/useToasterStyles.styles.raw.js +84 -0
- package/lib-commonjs/components/Toaster/useToasterStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/contexts/toastContainerContext.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/state/constants.js.map +1 -1
- package/lib-commonjs/state/index.js.map +1 -1
- package/lib-commonjs/state/types.js.map +1 -1
- package/lib-commonjs/state/useToastController.js.map +1 -1
- package/lib-commonjs/state/useToaster.js.map +1 -1
- package/lib-commonjs/state/vanilla/createToaster.js.map +1 -1
- package/lib-commonjs/state/vanilla/dismissAllToasts.js.map +1 -1
- package/lib-commonjs/state/vanilla/dismissToast.js.map +1 -1
- package/lib-commonjs/state/vanilla/dispatchToast.js.map +1 -1
- package/lib-commonjs/state/vanilla/getPositionStyles.js.map +1 -1
- package/lib-commonjs/state/vanilla/index.js.map +1 -1
- package/lib-commonjs/state/vanilla/pauseToast.js.map +1 -1
- package/lib-commonjs/state/vanilla/playToast.js.map +1 -1
- package/lib-commonjs/state/vanilla/updateToast.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/constants.ts"],"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} as const;\n\nexport const TOAST_POSITIONS = {\n bottom: 'bottom',\n bottomEnd: 'bottom-end',\n bottomStart: 'bottom-start',\n top: 'top',\n topEnd: 'top-end',\n topStart: 'top-start',\n} as const;\n"],"names":["EVENTS","show","dismiss","dismissAll","update","pause","play","TOAST_POSITIONS","bottom","bottomEnd","bottomStart","top","topEnd","topStart"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/constants.ts"],"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} as const;\n\nexport const TOAST_POSITIONS = {\n bottom: 'bottom',\n bottomEnd: 'bottom-end',\n bottomStart: 'bottom-start',\n top: 'top',\n topEnd: 'top-end',\n topStart: 'top-start',\n} as const;\n"],"names":["EVENTS","show","dismiss","dismissAll","update","pause","play","TOAST_POSITIONS","bottom","bottomEnd","bottomStart","top","topEnd","topStart"],"mappings":"AAAA,OAAO,MAAMA,SAAS;IACpBC,MAAM;IACNC,SAAS;IACTC,YAAY;IACZC,QAAQ;IACRC,OAAO;IACPC,MAAM;AACR,EAAW;AAEX,OAAO,MAAMC,kBAAkB;IAC7BC,QAAQ;IACRC,WAAW;IACXC,aAAa;IACbC,KAAK;IACLC,QAAQ;IACRC,UAAU;AACZ,EAAW"}
|
package/lib/state/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/index.ts"],"sourcesContent":["export type {\n CommonToastDetail,\n DismissAllToastsEventDetail,\n DismissToastEventDetail,\n DispatchToastOptions,\n PauseToastEventDetail,\n PlayToastEventDetail,\n ShowToastEventDetail,\n Toast,\n ToastChangeData,\n ToastChangeHandler,\n ToastId,\n ToastImperativeRef,\n ToastIntent,\n ToastListenerMap,\n ToastOffset,\n ToastOffsetObject,\n ToastOptions,\n ToastPoliteness,\n ToastPosition,\n ToastStatus,\n ToasterId,\n ToasterOptions,\n ToasterShortcuts,\n UpdateToastEventDetail,\n UpdateToastOptions,\n} from './types';\nexport { useToaster } from './useToaster';\nexport { useToastController } from './useToastController';\nexport { getPositionStyles } from './vanilla';\nexport { TOAST_POSITIONS } from './constants';\n"],"names":["useToaster","useToastController","getPositionStyles","TOAST_POSITIONS"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/index.ts"],"sourcesContent":["export type {\n CommonToastDetail,\n DismissAllToastsEventDetail,\n DismissToastEventDetail,\n DispatchToastOptions,\n PauseToastEventDetail,\n PlayToastEventDetail,\n ShowToastEventDetail,\n Toast,\n ToastChangeData,\n ToastChangeHandler,\n ToastId,\n ToastImperativeRef,\n ToastIntent,\n ToastListenerMap,\n ToastOffset,\n ToastOffsetObject,\n ToastOptions,\n ToastPoliteness,\n ToastPosition,\n ToastStatus,\n ToasterId,\n ToasterOptions,\n ToasterShortcuts,\n UpdateToastEventDetail,\n UpdateToastOptions,\n} from './types';\nexport { useToaster } from './useToaster';\nexport { useToastController } from './useToastController';\nexport { getPositionStyles } from './vanilla';\nexport { TOAST_POSITIONS } from './constants';\n"],"names":["useToaster","useToastController","getPositionStyles","TOAST_POSITIONS"],"mappings":"AA2BA,SAASA,UAAU,QAAQ,eAAe;AAC1C,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,eAAe,QAAQ,cAAc"}
|
package/lib/state/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/types.ts"],"sourcesContent":["import type { Slot } from '@fluentui/react-utilities';\nimport { EVENTS } from './constants';\nimport * as React from 'react';\n\nexport type ToastId = string;\nexport type ToasterId = string;\n\nexport type ToastPosition = 'top-end' | 'top-start' | 'bottom-end' | 'bottom-start' | 'top' | 'bottom';\nexport type ToastPoliteness = 'assertive' | 'polite';\nexport type ToastStatus = 'queued' | 'visible' | 'dismissed' | 'unmounted';\nexport type ToastIntent = 'info' | 'success' | 'error' | 'warning';\nexport type ToastChangeHandler = (event: null, data: ToastChangeData) => void;\n\nexport interface ToastChangeData extends ToastOptions, Pick<Toast, 'updateId'> {\n status: ToastStatus;\n}\n\nexport interface ToastOptions<TData = object> {\n /**\n * Uniquely identifies a toast, used for update and dismiss operations\n */\n toastId: ToastId;\n /**\n * The position the toast should render to\n */\n position: ToastPosition;\n /**\n * Toast content\n */\n content: unknown;\n /**\n * Auto dismiss timeout in milliseconds\n * @default 3000\n */\n timeout: number;\n /**\n * Toast timeout pauses while focus is on another window\n * @default false\n */\n pauseOnWindowBlur: boolean;\n /**\n * Toast timeout pauses while user cursor is on the toast\n * @default false\n */\n pauseOnHover: boolean;\n /**\n * Toast belongs to a specific toaster\n */\n toasterId: ToasterId | undefined;\n /**\n * Higher priority toasts will be rendered before lower priority toasts\n */\n priority: number;\n /**\n * Used to determine [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) narration\n * This will override the intent prop\n */\n politeness?: ToastPoliteness;\n\n /**\n * Default toast types that determine the urgency or [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) narration\n * The UI layer may use these intents to apply specific styling.\n * @default info\n */\n intent?: ToastIntent;\n /**\n * Additional data that needs to be passed to the toast\n */\n data: TData;\n\n /**\n * Reports changes to the Toast lifecycle\n */\n onStatusChange: ToastChangeHandler | undefined;\n}\n\nexport interface ToastOffsetObject {\n horizontal?: number;\n vertical?: number;\n}\n\nexport type ToastOffset = Partial<Record<ToastPosition, ToastOffsetObject>> | ToastOffsetObject;\n\nexport interface ToasterShortcuts {\n focus: (e: KeyboardEvent) => boolean;\n}\n\nexport interface ToasterOptions\n extends Pick<ToastOptions, 'position' | 'timeout' | 'pauseOnWindowBlur' | 'pauseOnHover' | 'priority'> {\n offset?: ToastOffset;\n toasterId?: ToasterId;\n limit?: number;\n shortcuts?: ToasterShortcuts;\n}\n\nexport interface Toast<TData = object> extends ToastOptions<TData> {\n /**\n * Determines the visiblity of a toast\n */\n close: () => void;\n /**\n * Removes a toast completely\n */\n remove: () => void;\n /**\n * A number used to track updates immutably\n */\n updateId: number;\n /**\n * Used to determine default priority when the user does not set one\n * Simple counter of toasts dispatched.\n */\n order: number;\n\n imperativeRef: React.RefObject<ToastImperativeRef>;\n}\n\nexport interface CommonToastDetail {\n toasterId?: ToasterId;\n}\n\nexport interface ShowToastEventDetail extends Partial<ToastOptions>, CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface UpdateToastEventDetail extends Partial<ToastOptions>, CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface DismissToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface PauseToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface PlayToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface DismissAllToastsEventDetail extends CommonToastDetail {}\n\ntype EventListener<TDetail> = (e: CustomEvent<TDetail>) => void;\n\nexport type ToastListenerMap = {\n [EVENTS.show]: EventListener<ShowToastEventDetail>;\n [EVENTS.dismiss]: EventListener<DismissToastEventDetail>;\n [EVENTS.dismissAll]: EventListener<DismissAllToastsEventDetail>;\n [EVENTS.update]: EventListener<UpdateToastEventDetail>;\n [EVENTS.play]: EventListener<PlayToastEventDetail>;\n [EVENTS.pause]: EventListener<PauseToastEventDetail>;\n};\n\ntype RootSlot = Slot<'div'>;\n\nexport interface DispatchToastOptions extends Partial<Omit<ToastOptions, 'toasterId'>> {\n root?: RootSlot;\n}\n\nexport interface UpdateToastOptions extends UpdateToastEventDetail {\n root?: RootSlot;\n}\n\nexport type ToastImperativeRef = {\n /**\n * Focuses the Toast.\n * If there are no focusable elements in the Toast, the Toast itself is focused.\n */\n focus: () => void;\n\n /**\n * Resumes the timeout of a paused toast\n */\n play: () => void;\n\n /**\n * Pauses the timeout of a toast\n */\n pause: () => void;\n};\n"],"names":["React"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/types.ts"],"sourcesContent":["import type { Slot } from '@fluentui/react-utilities';\nimport { EVENTS } from './constants';\nimport * as React from 'react';\n\nexport type ToastId = string;\nexport type ToasterId = string;\n\nexport type ToastPosition = 'top-end' | 'top-start' | 'bottom-end' | 'bottom-start' | 'top' | 'bottom';\nexport type ToastPoliteness = 'assertive' | 'polite';\nexport type ToastStatus = 'queued' | 'visible' | 'dismissed' | 'unmounted';\nexport type ToastIntent = 'info' | 'success' | 'error' | 'warning';\nexport type ToastChangeHandler = (event: null, data: ToastChangeData) => void;\n\nexport interface ToastChangeData extends ToastOptions, Pick<Toast, 'updateId'> {\n status: ToastStatus;\n}\n\nexport interface ToastOptions<TData = object> {\n /**\n * Uniquely identifies a toast, used for update and dismiss operations\n */\n toastId: ToastId;\n /**\n * The position the toast should render to\n */\n position: ToastPosition;\n /**\n * Toast content\n */\n content: unknown;\n /**\n * Auto dismiss timeout in milliseconds\n * @default 3000\n */\n timeout: number;\n /**\n * Toast timeout pauses while focus is on another window\n * @default false\n */\n pauseOnWindowBlur: boolean;\n /**\n * Toast timeout pauses while user cursor is on the toast\n * @default false\n */\n pauseOnHover: boolean;\n /**\n * Toast belongs to a specific toaster\n */\n toasterId: ToasterId | undefined;\n /**\n * Higher priority toasts will be rendered before lower priority toasts\n */\n priority: number;\n /**\n * Used to determine [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) narration\n * This will override the intent prop\n */\n politeness?: ToastPoliteness;\n\n /**\n * Default toast types that determine the urgency or [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) narration\n * The UI layer may use these intents to apply specific styling.\n * @default info\n */\n intent?: ToastIntent;\n /**\n * Additional data that needs to be passed to the toast\n */\n data: TData;\n\n /**\n * Reports changes to the Toast lifecycle\n */\n onStatusChange: ToastChangeHandler | undefined;\n}\n\nexport interface ToastOffsetObject {\n horizontal?: number;\n vertical?: number;\n}\n\nexport type ToastOffset = Partial<Record<ToastPosition, ToastOffsetObject>> | ToastOffsetObject;\n\nexport interface ToasterShortcuts {\n focus: (e: KeyboardEvent) => boolean;\n}\n\nexport interface ToasterOptions\n extends Pick<ToastOptions, 'position' | 'timeout' | 'pauseOnWindowBlur' | 'pauseOnHover' | 'priority'> {\n offset?: ToastOffset;\n toasterId?: ToasterId;\n limit?: number;\n shortcuts?: ToasterShortcuts;\n}\n\nexport interface Toast<TData = object> extends ToastOptions<TData> {\n /**\n * Determines the visiblity of a toast\n */\n close: () => void;\n /**\n * Removes a toast completely\n */\n remove: () => void;\n /**\n * A number used to track updates immutably\n */\n updateId: number;\n /**\n * Used to determine default priority when the user does not set one\n * Simple counter of toasts dispatched.\n */\n order: number;\n\n imperativeRef: React.RefObject<ToastImperativeRef>;\n}\n\nexport interface CommonToastDetail {\n toasterId?: ToasterId;\n}\n\nexport interface ShowToastEventDetail extends Partial<ToastOptions>, CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface UpdateToastEventDetail extends Partial<ToastOptions>, CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface DismissToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface PauseToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface PlayToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface DismissAllToastsEventDetail extends CommonToastDetail {}\n\ntype EventListener<TDetail> = (e: CustomEvent<TDetail>) => void;\n\nexport type ToastListenerMap = {\n [EVENTS.show]: EventListener<ShowToastEventDetail>;\n [EVENTS.dismiss]: EventListener<DismissToastEventDetail>;\n [EVENTS.dismissAll]: EventListener<DismissAllToastsEventDetail>;\n [EVENTS.update]: EventListener<UpdateToastEventDetail>;\n [EVENTS.play]: EventListener<PlayToastEventDetail>;\n [EVENTS.pause]: EventListener<PauseToastEventDetail>;\n};\n\ntype RootSlot = Slot<'div'>;\n\nexport interface DispatchToastOptions extends Partial<Omit<ToastOptions, 'toasterId'>> {\n root?: RootSlot;\n}\n\nexport interface UpdateToastOptions extends UpdateToastEventDetail {\n root?: RootSlot;\n}\n\nexport type ToastImperativeRef = {\n /**\n * Focuses the Toast.\n * If there are no focusable elements in the Toast, the Toast itself is focused.\n */\n focus: () => void;\n\n /**\n * Resumes the timeout of a paused toast\n */\n play: () => void;\n\n /**\n * Pauses the timeout of a toast\n */\n pause: () => void;\n};\n"],"names":["React"],"mappings":"AAEA,YAAYA,WAAW,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/useToastController.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n dispatchToast as dispatchToastVanilla,\n dismissToast as dismissToastVanilla,\n dismissAllToasts as dismissAllToastsVanilla,\n updateToast as updateToastVanilla,\n playToast as playToastVanilla,\n pauseToast as pauseToastVanilla,\n} from './vanilla';\nimport { DispatchToastOptions, ToastId, ToasterId, UpdateToastOptions } from './types';\n\nconst noop = () => undefined;\n\n/**\n * @param toasterId - If an id is provided all imperative methods control that specific toaster\n * @returns Imperative methods to control toasts\n */\nexport function useToastController(toasterId?: ToasterId) {\n const { targetDocument } = useFluent();\n\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\n return {\n dispatchToast: (content: React.ReactNode, options?: DispatchToastOptions) => {\n dispatchToastVanilla(content, { ...options, toasterId, data: { root: options?.root } }, targetDocument);\n },\n dismissToast: (toastId: ToastId) => {\n dismissToastVanilla(toastId, toasterId, targetDocument);\n },\n dismissAllToasts: () => {\n dismissAllToastsVanilla(toasterId, targetDocument);\n },\n updateToast: (options: UpdateToastOptions) => {\n updateToastVanilla({ ...options, data: { root: options.root }, toasterId }, targetDocument);\n },\n pauseToast: (toastId: ToastId) => {\n pauseToastVanilla(toastId, toasterId, targetDocument);\n },\n playToast: (toastId: ToastId) => {\n playToastVanilla(toastId, toasterId, targetDocument);\n },\n };\n }, [targetDocument, toasterId]);\n}\n"],"names":["React","useFluent_unstable","useFluent","dispatchToast","dispatchToastVanilla","dismissToast","dismissToastVanilla","dismissAllToasts","dismissAllToastsVanilla","updateToast","updateToastVanilla","playToast","playToastVanilla","pauseToast","pauseToastVanilla","noop","undefined","useToastController","toasterId","targetDocument","useMemo","content","options","data","root","toastId"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/useToastController.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n dispatchToast as dispatchToastVanilla,\n dismissToast as dismissToastVanilla,\n dismissAllToasts as dismissAllToastsVanilla,\n updateToast as updateToastVanilla,\n playToast as playToastVanilla,\n pauseToast as pauseToastVanilla,\n} from './vanilla';\nimport { DispatchToastOptions, ToastId, ToasterId, UpdateToastOptions } from './types';\n\nconst noop = () => undefined;\n\n/**\n * @param toasterId - If an id is provided all imperative methods control that specific toaster\n * @returns Imperative methods to control toasts\n */\nexport function useToastController(toasterId?: ToasterId) {\n const { targetDocument } = useFluent();\n\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\n return {\n dispatchToast: (content: React.ReactNode, options?: DispatchToastOptions) => {\n dispatchToastVanilla(content, { ...options, toasterId, data: { root: options?.root } }, targetDocument);\n },\n dismissToast: (toastId: ToastId) => {\n dismissToastVanilla(toastId, toasterId, targetDocument);\n },\n dismissAllToasts: () => {\n dismissAllToastsVanilla(toasterId, targetDocument);\n },\n updateToast: (options: UpdateToastOptions) => {\n updateToastVanilla({ ...options, data: { root: options.root }, toasterId }, targetDocument);\n },\n pauseToast: (toastId: ToastId) => {\n pauseToastVanilla(toastId, toasterId, targetDocument);\n },\n playToast: (toastId: ToastId) => {\n playToastVanilla(toastId, toasterId, targetDocument);\n },\n };\n }, [targetDocument, toasterId]);\n}\n"],"names":["React","useFluent_unstable","useFluent","dispatchToast","dispatchToastVanilla","dismissToast","dismissToastVanilla","dismissAllToasts","dismissAllToastsVanilla","updateToast","updateToastVanilla","playToast","playToastVanilla","pauseToast","pauseToastVanilla","noop","undefined","useToastController","toasterId","targetDocument","useMemo","content","options","data","root","toastId"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SACEC,iBAAiBC,oBAAoB,EACrCC,gBAAgBC,mBAAmB,EACnCC,oBAAoBC,uBAAuB,EAC3CC,eAAeC,kBAAkB,EACjCC,aAAaC,gBAAgB,EAC7BC,cAAcC,iBAAiB,QAC1B,YAAY;AAGnB,MAAMC,OAAO,IAAMC;AAEnB;;;CAGC,GACD,OAAO,SAASC,mBAAmBC,SAAqB;IACtD,MAAM,EAAEC,cAAc,EAAE,GAAGjB;IAE3B,OAAOF,MAAMoB,OAAO,CAAC;QACnB,IAAI,CAACD,gBAAgB;YACnB,OAAO;gBACLhB,eAAeY;gBACfV,cAAcU;gBACdR,kBAAkBQ;gBAClBN,aAAaM;gBACbF,YAAYE;gBACZJ,WAAWI;YACb;QACF;QAEA,OAAO;YACLZ,eAAe,CAACkB,SAA0BC;gBACxClB,qBAAqBiB,SAAS;oBAAE,GAAGC,OAAO;oBAAEJ;oBAAWK,MAAM;wBAAEC,IAAI,EAAEF,oBAAAA,8BAAAA,QAASE,IAAI;oBAAC;gBAAE,GAAGL;YAC1F;YACAd,cAAc,CAACoB;gBACbnB,oBAAoBmB,SAASP,WAAWC;YAC1C;YACAZ,kBAAkB;gBAChBC,wBAAwBU,WAAWC;YACrC;YACAV,aAAa,CAACa;gBACZZ,mBAAmB;oBAAE,GAAGY,OAAO;oBAAEC,MAAM;wBAAEC,MAAMF,QAAQE,IAAI;oBAAC;oBAAGN;gBAAU,GAAGC;YAC9E;YACAN,YAAY,CAACY;gBACXX,kBAAkBW,SAASP,WAAWC;YACxC;YACAR,WAAW,CAACc;gBACVb,iBAAiBa,SAASP,WAAWC;YACvC;QACF;IACF,GAAG;QAACA;QAAgBD;KAAU;AAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/useToaster.ts"],"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 type {\n CommonToastDetail,\n ShowToastEventDetail,\n Toast,\n ToastListenerMap,\n ToastPosition,\n ToasterId,\n ToasterOptions,\n} from './types';\nimport { EVENTS } from './constants';\n\nexport function useToaster<TElement extends HTMLElement = HTMLDivElement>(options: Partial<ToasterOptions> = {}) {\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\n const lastActiveElementRef = React.useRef<HTMLElement | null>(null);\n\n const isCorrectToaster = useEventCallback((toasterId: ToasterId | undefined) => {\n return toasterId === userToasterId;\n });\n\n const isFocusShortcut = useEventCallback((e: KeyboardEvent) => {\n if (shortcuts?.focus) {\n return shortcuts.focus(e);\n }\n });\n\n const pauseAllToasts = React.useCallback(() => {\n toaster.visibleToasts.forEach(toastId => {\n const toast = toaster.toasts.get(toastId);\n toast?.imperativeRef.current?.pause();\n });\n }, [toaster]);\n\n const playAllToasts = React.useCallback(() => {\n toaster.visibleToasts.forEach(toastId => {\n const toast = toaster.toasts.get(toastId);\n toast?.imperativeRef.current?.play();\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\n if (!cur) {\n return toast;\n }\n\n if (cur.order < toast?.order) {\n return toast;\n }\n\n return cur;\n }, undefined as Toast | undefined);\n }, [toaster]);\n\n const tryRestoreFocus = React.useCallback(() => {\n const mostRecentToast = getMostRecentVisibleToast();\n if (mostRecentToast?.imperativeRef.current) {\n mostRecentToast.imperativeRef.current.focus();\n } else {\n lastActiveElementRef.current?.focus();\n lastActiveElementRef.current = null;\n }\n }, [getMostRecentVisibleToast]);\n\n const closeAllToasts = React.useCallback(() => {\n toaster.visibleToasts.forEach(toastId => {\n const toast = toaster.toasts.get(toastId);\n toast?.close();\n });\n\n tryRestoreFocus();\n }, [toaster, tryRestoreFocus]);\n\n React.useEffect(() => {\n if (!targetDocument) {\n return;\n }\n\n const addToastListener = <TType extends keyof ToastListenerMap>(\n eventType: TType,\n callback: ToastListenerMap[TType],\n ) => {\n const listener: ToastListenerMap[TType] = (e: CustomEvent<CommonToastDetail>) => {\n if (!isCorrectToaster(e.detail.toasterId)) {\n return;\n }\n\n callback(e as CustomEvent<ShowToastEventDetail>);\n forceUpdate();\n };\n\n targetDocument.addEventListener(eventType, listener as () => void);\n return () => targetDocument.removeEventListener(eventType, listener as () => void);\n };\n\n const buildToast: ToastListenerMap[typeof EVENTS.show] = e => {\n toaster.buildToast(e.detail, forceUpdate);\n };\n\n const dismissToast: ToastListenerMap[typeof EVENTS.dismiss] = e => {\n toaster.dismissToast(e.detail.toastId);\n };\n\n const updateToast: ToastListenerMap[typeof EVENTS.update] = e => {\n toaster.updateToast(e.detail);\n };\n\n const dismissAllToasts: ToastListenerMap[typeof EVENTS.dismissAll] = e => {\n toaster.dismissAllToasts();\n };\n\n const pauseToast: ToastListenerMap[typeof EVENTS.pause] = e => {\n const toast = toaster.toasts.get(e.detail.toastId);\n if (toast) {\n toast.imperativeRef.current?.pause();\n }\n };\n\n const playToast: ToastListenerMap[typeof EVENTS.play] = e => {\n const toast = toaster.toasts.get(e.detail.toastId);\n if (toast) {\n toast.imperativeRef.current?.play();\n }\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\n const focusShortcutListener = (e: KeyboardEvent) => {\n if (isFocusShortcut(e)) {\n pauseAllToasts();\n const mostRecentToast = getMostRecentVisibleToast();\n\n if (mostRecentToast) {\n lastActiveElementRef.current = isHTMLElement(targetDocument.activeElement)\n ? targetDocument.activeElement\n : null;\n mostRecentToast.imperativeRef.current?.focus();\n }\n }\n };\n\n targetDocument.addEventListener('keydown', focusShortcutListener);\n\n return () => {\n cleanupBuildListener();\n cleanupDismissAllListener();\n cleanupUpdateListener();\n cleanupDismissListener();\n cleanupPauseListener();\n cleanupPlayListener();\n\n targetDocument.removeEventListener('keydown', focusShortcutListener);\n };\n }, [\n toaster,\n forceUpdate,\n targetDocument,\n isCorrectToaster,\n pauseAllToasts,\n getMostRecentVisibleToast,\n isFocusShortcut,\n ]);\n\n const toastsToRender = (() => {\n if (!toaster) {\n return new Map<ToastPosition, Toast[]>();\n }\n\n const toRender = new Map<ToastPosition, Toast[]>();\n const toasts = Array.from(toaster.toasts.values());\n\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\n return toRender;\n })();\n\n return {\n isToastVisible: toaster.isToastVisible,\n toastsToRender,\n pauseAllToasts,\n playAllToasts,\n tryRestoreFocus,\n closeAllToasts,\n };\n}\n"],"names":["React","isHTMLElement","useEventCallback","useForceUpdate","useFluent_unstable","useFluent","createToaster","EVENTS","useToaster","options","forceUpdate","toasterId","userToasterId","shortcuts","toaster","useState","targetDocument","lastActiveElementRef","useRef","isCorrectToaster","isFocusShortcut","e","focus","pauseAllToasts","useCallback","visibleToasts","forEach","toastId","toast","toasts","get","imperativeRef","current","pause","playAllToasts","play","getMostRecentVisibleToast","Array","from","reduce","cur","next","order","undefined","tryRestoreFocus","mostRecentToast","closeAllToasts","close","useEffect","addToastListener","eventType","callback","listener","detail","addEventListener","removeEventListener","buildToast","dismissToast","updateToast","dismissAllToasts","pauseToast","playToast","cleanupBuildListener","show","cleanupUpdateListener","update","cleanupDismissListener","dismiss","cleanupDismissAllListener","dismissAll","cleanupPauseListener","cleanupPlayListener","focusShortcutListener","activeElement","toastsToRender","Map","toRender","values","position","has","set","startsWith","push","unshift","isToastVisible"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,aAAa,EAAEC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAC5F,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,aAAa,QAAQ,YAAY;AAU1C,SAASC,MAAM,QAAQ,cAAc;AAErC,OAAO,SAASC,WAA0DC,UAAmC,CAAC,CAAC;IAC7G,MAAMC,cAAcP;IACpB,MAAM,EAAEQ,WAAWC,aAAa,EAAEC,SAAS,EAAE,GAAGJ;IAChD,gEAAgE;IAChE,MAAM,CAACK,QAAQ,GAAGd,MAAMe,QAAQ,CAAC,IAAMT,cAAcG;IACrD,MAAM,EAAEO,cAAc,EAAE,GAAGX;IAE3B,MAAMY,uBAAuBjB,MAAMkB,MAAM,CAAqB;IAE9D,MAAMC,mBAAmBjB,iBAAiB,CAACS;QACzC,OAAOA,cAAcC;IACvB;IAEA,MAAMQ,kBAAkBlB,iBAAiB,CAACmB;QACxC,IAAIR,sBAAAA,gCAAAA,UAAWS,KAAK,EAAE;YACpB,OAAOT,UAAUS,KAAK,CAACD;QACzB;IACF;IAEA,MAAME,iBAAiBvB,MAAMwB,WAAW,CAAC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D,SAASG,GAAG,CAACD,aAAaF,SAASI,GAAG,CAACF,UAAU,EAAE;YACnD,IAAIA,SAASG,UAAU,CAAC,WAAW;gBACjCL,SAAS9C,GAAG,CAACgD,UAAWI,IAAI,CAACtD;YAC/B,OAAO;gBACLgD,SAAS9C,GAAG,CAACgD,UAAWK,OAAO,CAACvD;YAClC;QACF;QAEA,OAAOgD;IACT,CAAA;IAEA,OAAO;QACLQ,gBAAgBtE,QAAQsE,cAAc;QACtCV;QACAnD;QACAW;QACAU;QACAE;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../src/state/useToaster.ts"],"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 type {\n CommonToastDetail,\n ShowToastEventDetail,\n Toast,\n ToastListenerMap,\n ToastPosition,\n ToasterId,\n ToasterOptions,\n} from './types';\nimport { EVENTS } from './constants';\n\nexport function useToaster<TElement extends HTMLElement = HTMLDivElement>(options: Partial<ToasterOptions> = {}) {\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\n const lastActiveElementRef = React.useRef<HTMLElement | null>(null);\n\n const isCorrectToaster = useEventCallback((toasterId: ToasterId | undefined) => {\n return toasterId === userToasterId;\n });\n\n const isFocusShortcut = useEventCallback((e: KeyboardEvent) => {\n if (shortcuts?.focus) {\n return shortcuts.focus(e);\n }\n });\n\n const pauseAllToasts = React.useCallback(() => {\n toaster.visibleToasts.forEach(toastId => {\n const toast = toaster.toasts.get(toastId);\n toast?.imperativeRef.current?.pause();\n });\n }, [toaster]);\n\n const playAllToasts = React.useCallback(() => {\n toaster.visibleToasts.forEach(toastId => {\n const toast = toaster.toasts.get(toastId);\n toast?.imperativeRef.current?.play();\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\n if (!cur) {\n return toast;\n }\n\n if (cur.order < toast?.order) {\n return toast;\n }\n\n return cur;\n }, undefined as Toast | undefined);\n }, [toaster]);\n\n const tryRestoreFocus = React.useCallback(() => {\n const mostRecentToast = getMostRecentVisibleToast();\n if (mostRecentToast?.imperativeRef.current) {\n mostRecentToast.imperativeRef.current.focus();\n } else {\n lastActiveElementRef.current?.focus();\n lastActiveElementRef.current = null;\n }\n }, [getMostRecentVisibleToast]);\n\n const closeAllToasts = React.useCallback(() => {\n toaster.visibleToasts.forEach(toastId => {\n const toast = toaster.toasts.get(toastId);\n toast?.close();\n });\n\n tryRestoreFocus();\n }, [toaster, tryRestoreFocus]);\n\n React.useEffect(() => {\n if (!targetDocument) {\n return;\n }\n\n const addToastListener = <TType extends keyof ToastListenerMap>(\n eventType: TType,\n callback: ToastListenerMap[TType],\n ) => {\n const listener: ToastListenerMap[TType] = (e: CustomEvent<CommonToastDetail>) => {\n if (!isCorrectToaster(e.detail.toasterId)) {\n return;\n }\n\n callback(e as CustomEvent<ShowToastEventDetail>);\n forceUpdate();\n };\n\n targetDocument.addEventListener(eventType, listener as () => void);\n return () => targetDocument.removeEventListener(eventType, listener as () => void);\n };\n\n const buildToast: ToastListenerMap[typeof EVENTS.show] = e => {\n toaster.buildToast(e.detail, forceUpdate);\n };\n\n const dismissToast: ToastListenerMap[typeof EVENTS.dismiss] = e => {\n toaster.dismissToast(e.detail.toastId);\n };\n\n const updateToast: ToastListenerMap[typeof EVENTS.update] = e => {\n toaster.updateToast(e.detail);\n };\n\n const dismissAllToasts: ToastListenerMap[typeof EVENTS.dismissAll] = e => {\n toaster.dismissAllToasts();\n };\n\n const pauseToast: ToastListenerMap[typeof EVENTS.pause] = e => {\n const toast = toaster.toasts.get(e.detail.toastId);\n if (toast) {\n toast.imperativeRef.current?.pause();\n }\n };\n\n const playToast: ToastListenerMap[typeof EVENTS.play] = e => {\n const toast = toaster.toasts.get(e.detail.toastId);\n if (toast) {\n toast.imperativeRef.current?.play();\n }\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\n const focusShortcutListener = (e: KeyboardEvent) => {\n if (isFocusShortcut(e)) {\n pauseAllToasts();\n const mostRecentToast = getMostRecentVisibleToast();\n\n if (mostRecentToast) {\n lastActiveElementRef.current = isHTMLElement(targetDocument.activeElement)\n ? targetDocument.activeElement\n : null;\n mostRecentToast.imperativeRef.current?.focus();\n }\n }\n };\n\n targetDocument.addEventListener('keydown', focusShortcutListener);\n\n return () => {\n cleanupBuildListener();\n cleanupDismissAllListener();\n cleanupUpdateListener();\n cleanupDismissListener();\n cleanupPauseListener();\n cleanupPlayListener();\n\n targetDocument.removeEventListener('keydown', focusShortcutListener);\n };\n }, [\n toaster,\n forceUpdate,\n targetDocument,\n isCorrectToaster,\n pauseAllToasts,\n getMostRecentVisibleToast,\n isFocusShortcut,\n ]);\n\n const toastsToRender = (() => {\n if (!toaster) {\n return new Map<ToastPosition, Toast[]>();\n }\n\n const toRender = new Map<ToastPosition, Toast[]>();\n const toasts = Array.from(toaster.toasts.values());\n\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\n return toRender;\n })();\n\n return {\n isToastVisible: toaster.isToastVisible,\n toastsToRender,\n pauseAllToasts,\n playAllToasts,\n tryRestoreFocus,\n closeAllToasts,\n };\n}\n"],"names":["React","isHTMLElement","useEventCallback","useForceUpdate","useFluent_unstable","useFluent","createToaster","EVENTS","useToaster","options","forceUpdate","toasterId","userToasterId","shortcuts","toaster","useState","targetDocument","lastActiveElementRef","useRef","isCorrectToaster","isFocusShortcut","e","focus","pauseAllToasts","useCallback","visibleToasts","forEach","toastId","toast","toasts","get","imperativeRef","current","pause","playAllToasts","play","getMostRecentVisibleToast","Array","from","reduce","cur","next","order","undefined","tryRestoreFocus","mostRecentToast","closeAllToasts","close","useEffect","addToastListener","eventType","callback","listener","detail","addEventListener","removeEventListener","buildToast","dismissToast","updateToast","dismissAllToasts","pauseToast","playToast","cleanupBuildListener","show","cleanupUpdateListener","update","cleanupDismissListener","dismiss","cleanupDismissAllListener","dismissAll","cleanupPauseListener","cleanupPlayListener","focusShortcutListener","activeElement","toastsToRender","Map","toRender","values","position","has","set","startsWith","push","unshift","isToastVisible"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,aAAa,EAAEC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAC5F,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,aAAa,QAAQ,YAAY;AAU1C,SAASC,MAAM,QAAQ,cAAc;AAErC,OAAO,SAASC,WAA0DC,UAAmC,CAAC,CAAC;IAC7G,MAAMC,cAAcP;IACpB,MAAM,EAAEQ,WAAWC,aAAa,EAAEC,SAAS,EAAE,GAAGJ;IAChD,gEAAgE;IAChE,MAAM,CAACK,QAAQ,GAAGd,MAAMe,QAAQ,CAAC,IAAMT,cAAcG;IACrD,MAAM,EAAEO,cAAc,EAAE,GAAGX;IAE3B,MAAMY,uBAAuBjB,MAAMkB,MAAM,CAAqB;IAE9D,MAAMC,mBAAmBjB,iBAAiB,CAACS;QACzC,OAAOA,cAAcC;IACvB;IAEA,MAAMQ,kBAAkBlB,iBAAiB,CAACmB;QACxC,IAAIR,sBAAAA,gCAAAA,UAAWS,KAAK,EAAE;YACpB,OAAOT,UA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OH,OAAO,CAACE,CAAAA;YACb,MAAM,EAAEkD,QAAQ,EAAE,GAAGlD;YACrBgD,SAASG,GAAG,CAACD,aAAaF,SAASI,GAAG,CAACF,UAAU,EAAE;YACnD,IAAIA,SAASG,UAAU,CAAC,WAAW;gBACjCL,SAAS9C,GAAG,CAACgD,UAAWI,IAAI,CAACtD;YAC/B,OAAO;gBACLgD,SAAS9C,GAAG,CAACgD,UAAWK,OAAO,CAACvD;YAClC;QACF;QAEA,OAAOgD;IACT,CAAA;IAEA,OAAO;QACLQ,gBAAgBtE,QAAQsE,cAAc;QACtCV;QACAnD;QACAW;QACAU;QACAE;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/vanilla/createToaster.ts"],"sourcesContent":["import * as React from 'react';\nimport { createPriorityQueue } from '@fluentui/react-utilities';\nimport { Toast, ToasterOptions, ToastId, ToastImperativeRef, ToastOptions, UpdateToastEventDetail } from '../types';\n\nfunction assignDefined<T extends object>(a: Partial<T>, b: Partial<T>) {\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) as [keyof T, T[keyof T]][]) {\n // eslint-disable-next-line eqeqeq\n if (prop != undefined) {\n a[key] = prop;\n }\n }\n}\nconst defaulToastOptions: Pick<\n ToastOptions,\n 'priority' | 'pauseOnHover' | 'pauseOnWindowBlur' | 'position' | 'timeout' | 'politeness' | 'onStatusChange'\n> = {\n onStatusChange: undefined,\n priority: 0,\n pauseOnHover: false,\n pauseOnWindowBlur: false,\n position: 'bottom-end',\n timeout: 3000,\n};\n\n// Multiple toasts can be dispatched in a single tick, use counter to prevent collisions\nlet counter = 0;\n\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 */\nexport function createToaster(options: Partial<ToasterOptions>) {\n const { limit = Number.POSITIVE_INFINITY } = options;\n const visibleToasts = new Set<ToastId>();\n const toasts = new Map<ToastId, Toast>();\n\n const queue = createPriorityQueue<ToastId>((ta, tb) => {\n const a = toasts.get(ta);\n const b = toasts.get(tb);\n if (!a || !b) {\n return 0;\n }\n\n if (a.priority === b.priority) {\n return a.order - b.order;\n }\n\n return a.priority - b.priority;\n });\n\n const isToastVisible = (toastId: ToastId) => {\n return visibleToasts.has(toastId);\n };\n\n /**\n * Updates an existing toast with any available option\n */\n const updateToast = (toastOptions: UpdateToastEventDetail) => {\n const { toastId } = toastOptions;\n const toastToUpdate = toasts.get(toastId);\n if (!toastToUpdate) {\n return;\n }\n\n Object.assign(toastToUpdate, toastOptions);\n toastToUpdate.updateId++;\n };\n\n /**\n * Dismisses a toast with a specific id\n */\n const dismissToast = (toastId: ToastId) => {\n visibleToasts.delete(toastId);\n };\n\n /**\n * Dismisses all toasts and clears the queue\n */\n const dismissAllToasts = () => {\n visibleToasts.clear();\n queue.clear();\n };\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 */\n const buildToast = (toastOptions: Partial<ToastOptions> & { toastId: ToastId }, onUpdate: () => void) => {\n const { toastId, content, toasterId } = toastOptions;\n\n if (toasts.has(toastId)) {\n return;\n }\n\n const close = () => {\n const toast = toasts.get(toastId);\n if (!toast) {\n return;\n }\n\n visibleToasts.delete(toastId);\n onUpdate();\n toast.onStatusChange?.(null, { status: 'dismissed', ...toast });\n };\n\n const remove = () => {\n const toast = toasts.get(toastId);\n if (!toast) {\n return;\n }\n\n toasts.delete(toastId);\n\n if (visibleToasts.size < limit && queue.peek()) {\n const nextToast = toasts.get(queue.dequeue());\n if (!nextToast) {\n return;\n }\n\n visibleToasts.add(nextToast.toastId);\n }\n\n onUpdate();\n };\n\n const toast: 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<ToastImperativeRef>(),\n };\n\n assignDefined(toast, options);\n assignDefined(toast, toastOptions);\n\n toasts.set(toastId, toast);\n toast.onStatusChange?.(null, { status: 'queued', ...toast });\n if (visibleToasts.size >= limit) {\n queue.enqueue(toastId);\n } else {\n visibleToasts.add(toastId);\n }\n };\n\n return {\n buildToast,\n dismissAllToasts,\n dismissToast,\n isToastVisible,\n updateToast,\n visibleToasts,\n toasts,\n };\n}\n"],"names":["React","createPriorityQueue","assignDefined","a","b","key","prop","Object","entries","undefined","defaulToastOptions","onStatusChange","priority","pauseOnHover","pauseOnWindowBlur","position","timeout","counter","createToaster","options","limit","Number","POSITIVE_INFINITY","visibleToasts","Set","toasts","Map","queue","ta","tb","get","order","isToastVisible","toastId","has","updateToast","toastOptions","toastToUpdate","assign","updateId","dismissToast","delete","dismissAllToasts","clear","buildToast","onUpdate","toast","content","toasterId","close","status","remove","size","peek","nextToast","dequeue","add","data","imperativeRef","createRef","set","enqueue"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/vanilla/createToaster.ts"],"sourcesContent":["import * as React from 'react';\nimport { createPriorityQueue } from '@fluentui/react-utilities';\nimport { Toast, ToasterOptions, ToastId, ToastImperativeRef, ToastOptions, UpdateToastEventDetail } from '../types';\n\nfunction assignDefined<T extends object>(a: Partial<T>, b: Partial<T>) {\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) as [keyof T, T[keyof T]][]) {\n // eslint-disable-next-line eqeqeq\n if (prop != undefined) {\n a[key] = prop;\n }\n }\n}\nconst defaulToastOptions: Pick<\n ToastOptions,\n 'priority' | 'pauseOnHover' | 'pauseOnWindowBlur' | 'position' | 'timeout' | 'politeness' | 'onStatusChange'\n> = {\n onStatusChange: undefined,\n priority: 0,\n pauseOnHover: false,\n pauseOnWindowBlur: false,\n position: 'bottom-end',\n timeout: 3000,\n};\n\n// Multiple toasts can be dispatched in a single tick, use counter to prevent collisions\nlet counter = 0;\n\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 */\nexport function createToaster(options: Partial<ToasterOptions>) {\n const { limit = Number.POSITIVE_INFINITY } = options;\n const visibleToasts = new Set<ToastId>();\n const toasts = new Map<ToastId, Toast>();\n\n const queue = createPriorityQueue<ToastId>((ta, tb) => {\n const a = toasts.get(ta);\n const b = toasts.get(tb);\n if (!a || !b) {\n return 0;\n }\n\n if (a.priority === b.priority) {\n return a.order - b.order;\n }\n\n return a.priority - b.priority;\n });\n\n const isToastVisible = (toastId: ToastId) => {\n return visibleToasts.has(toastId);\n };\n\n /**\n * Updates an existing toast with any available option\n */\n const updateToast = (toastOptions: UpdateToastEventDetail) => {\n const { toastId } = toastOptions;\n const toastToUpdate = toasts.get(toastId);\n if (!toastToUpdate) {\n return;\n }\n\n Object.assign(toastToUpdate, toastOptions);\n toastToUpdate.updateId++;\n };\n\n /**\n * Dismisses a toast with a specific id\n */\n const dismissToast = (toastId: ToastId) => {\n visibleToasts.delete(toastId);\n };\n\n /**\n * Dismisses all toasts and clears the queue\n */\n const dismissAllToasts = () => {\n visibleToasts.clear();\n queue.clear();\n };\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 */\n const buildToast = (toastOptions: Partial<ToastOptions> & { toastId: ToastId }, onUpdate: () => void) => {\n const { toastId, content, toasterId } = toastOptions;\n\n if (toasts.has(toastId)) {\n return;\n }\n\n const close = () => {\n const toast = toasts.get(toastId);\n if (!toast) {\n return;\n }\n\n visibleToasts.delete(toastId);\n onUpdate();\n toast.onStatusChange?.(null, { status: 'dismissed', ...toast });\n };\n\n const remove = () => {\n const toast = toasts.get(toastId);\n if (!toast) {\n return;\n }\n\n toasts.delete(toastId);\n\n if (visibleToasts.size < limit && queue.peek()) {\n const nextToast = toasts.get(queue.dequeue());\n if (!nextToast) {\n return;\n }\n\n visibleToasts.add(nextToast.toastId);\n }\n\n onUpdate();\n };\n\n const toast: 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<ToastImperativeRef>(),\n };\n\n assignDefined(toast, options);\n assignDefined(toast, toastOptions);\n\n toasts.set(toastId, toast);\n toast.onStatusChange?.(null, { status: 'queued', ...toast });\n if (visibleToasts.size >= limit) {\n queue.enqueue(toastId);\n } else {\n visibleToasts.add(toastId);\n }\n };\n\n return {\n buildToast,\n dismissAllToasts,\n dismissToast,\n isToastVisible,\n updateToast,\n visibleToasts,\n toasts,\n };\n}\n"],"names":["React","createPriorityQueue","assignDefined","a","b","key","prop","Object","entries","undefined","defaulToastOptions","onStatusChange","priority","pauseOnHover","pauseOnWindowBlur","position","timeout","counter","createToaster","options","limit","Number","POSITIVE_INFINITY","visibleToasts","Set","toasts","Map","queue","ta","tb","get","order","isToastVisible","toastId","has","updateToast","toastOptions","toastToUpdate","assign","updateId","dismissToast","delete","dismissAllToasts","clear","buildToast","onUpdate","toast","content","toasterId","close","status","remove","size","peek","nextToast","dequeue","add","data","imperativeRef","createRef","set","enqueue"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,mBAAmB,QAAQ,4BAA4B;AAGhE,SAASC,cAAgCC,CAAa,EAAEC,CAAa;IACnE,4FAA4F;IAC5F,KAAK,MAAM,CAACC,KAAKC,KAAK,IAAIC,OAAOC,OAAO,CAACJ,GAA+B;QACtE,kCAAkC;QAClC,IAAIE,QAAQG,WAAW;YACrBN,CAAC,CAACE,IAAI,GAAGC;QACX;IACF;AACF;AACA,MAAMI,qBAGF;IACFC,gBAAgBF;IAChBG,UAAU;IACVC,cAAc;IACdC,mBAAmB;IACnBC,UAAU;IACVC,SAAS;AACX;AAEA,wFAAwF;AACxF,IAAIC,UAAU;AAEd;;;;CAIC,GACD,OAAO,SAASC,cAAcC,OAAgC;IAC5D,MAAM,EAAEC,QAAQC,OAAOC,iBAAiB,EAAE,GAAGH;IAC7C,MAAMI,gBAAgB,IAAIC;IAC1B,MAAMC,SAAS,IAAIC;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AEA,MAAMK,SAAS;YACb,MAAML,QAAQrB,OAAOK,GAAG,CAACG;YACzB,IAAI,CAACa,OAAO;gBACV;YACF;YAEArB,OAAOgB,MAAM,CAACR;YAEd,IAAIV,cAAc6B,IAAI,GAAGhC,SAASO,MAAM0B,IAAI,IAAI;gBAC9C,MAAMC,YAAY7B,OAAOK,GAAG,CAACH,MAAM4B,OAAO;gBAC1C,IAAI,CAACD,WAAW;oBACd;gBACF;gBAEA/B,cAAciC,GAAG,CAACF,UAAUrB,OAAO;YACrC;YAEAY;QACF;QAEA,MAAMC,QAAe;YACnB,GAAGpC,kBAAkB;YACrBuC;YACAE;YACAlB;YACAc;YACAR,UAAU;YACVS;YACAjB,OAAOd;YACPwC,MAAM,CAAC;YACPC,eAAe1D,MAAM2D,SAAS;QAChC;QAEAzD,cAAc4C,OAAO3B;QACrBjB,cAAc4C,OAAOV;QAErBX,OAAOmC,GAAG,CAAC3B,SAASa;SACpBA,wBAAAA,MAAMnC,cAAc,cAApBmC,4CAAAA,2BAAAA,OAAuB,MAAM;YAAEI,QAAQ;YAAU,GAAGJ,KAAK;QAAC;QAC1D,IAAIvB,cAAc6B,IAAI,IAAIhC,OAAO;YAC/BO,MAAMkC,OAAO,CAAC5B;QAChB,OAAO;YACLV,cAAciC,GAAG,CAACvB;QACpB;IACF;IAEA,OAAO;QACLW;QACAF;QACAF;QACAR;QACAG;QACAZ;QACAE;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/vanilla/dismissAllToasts.ts"],"sourcesContent":["import { EVENTS } from '../constants';\nimport { DismissAllToastsEventDetail, ToasterId } from '../types';\n\nexport function dismissAllToasts(toasterId: ToasterId | undefined = undefined, targetDocument: Document) {\n const event = new CustomEvent<DismissAllToastsEventDetail>(EVENTS.dismissAll, {\n bubbles: false,\n cancelable: false,\n detail: { toasterId },\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","dismissAllToasts","toasterId","undefined","targetDocument","event","CustomEvent","dismissAll","bubbles","cancelable","detail","dispatchEvent"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/vanilla/dismissAllToasts.ts"],"sourcesContent":["import { EVENTS } from '../constants';\nimport { DismissAllToastsEventDetail, ToasterId } from '../types';\n\nexport function dismissAllToasts(toasterId: ToasterId | undefined = undefined, targetDocument: Document) {\n const event = new CustomEvent<DismissAllToastsEventDetail>(EVENTS.dismissAll, {\n bubbles: false,\n cancelable: false,\n detail: { toasterId },\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","dismissAllToasts","toasterId","undefined","targetDocument","event","CustomEvent","dismissAll","bubbles","cancelable","detail","dispatchEvent"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AAGtC,OAAO,SAASC,iBAAiBC,YAAmCC,SAAS,EAAEC,cAAwB;IACrG,MAAMC,QAAQ,IAAIC,YAAyCN,OAAOO,UAAU,EAAE;QAC5EC,SAAS;QACTC,YAAY;QACZC,QAAQ;YAAER;QAAU;IACtB;IACAE,eAAeO,aAAa,CAACN;AAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/vanilla/dismissToast.ts"],"sourcesContent":["import { EVENTS } from '../constants';\nimport { DismissToastEventDetail, ToastId, ToasterId } from '../types';\n\nexport function dismissToast(toastId: ToastId, toasterId: ToasterId | undefined = undefined, targetDocument: Document) {\n const event = new CustomEvent<DismissToastEventDetail>(EVENTS.dismiss, {\n bubbles: false,\n cancelable: false,\n detail: { toastId, toasterId },\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","dismissToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","dismiss","bubbles","cancelable","detail","dispatchEvent"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/vanilla/dismissToast.ts"],"sourcesContent":["import { EVENTS } from '../constants';\nimport { DismissToastEventDetail, ToastId, ToasterId } from '../types';\n\nexport function dismissToast(toastId: ToastId, toasterId: ToasterId | undefined = undefined, targetDocument: Document) {\n const event = new CustomEvent<DismissToastEventDetail>(EVENTS.dismiss, {\n bubbles: false,\n cancelable: false,\n detail: { toastId, toasterId },\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","dismissToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","dismiss","bubbles","cancelable","detail","dispatchEvent"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AAGtC,OAAO,SAASC,aAAaC,OAAgB,EAAEC,YAAmCC,SAAS,EAAEC,cAAwB;IACnH,MAAMC,QAAQ,IAAIC,YAAqCP,OAAOQ,OAAO,EAAE;QACrEC,SAAS;QACTC,YAAY;QACZC,QAAQ;YAAET;YAASC;QAAU;IAC/B;IACAE,eAAeO,aAAa,CAACN;AAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/vanilla/dispatchToast.ts"],"sourcesContent":["import { ShowToastEventDetail, ToastOptions } from '../types';\nimport { EVENTS } from '../constants';\n\nlet counter = 0;\n\nexport function dispatchToast(content: unknown, options: Partial<ToastOptions> = {}, targetDocument: Document) {\n const detail: ShowToastEventDetail = {\n ...options,\n content,\n toastId: options.toastId ?? (counter++).toString(),\n };\n const event = new CustomEvent<ShowToastEventDetail>(EVENTS.show, {\n bubbles: false,\n cancelable: false,\n detail,\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","counter","dispatchToast","content","options","targetDocument","detail","toastId","toString","event","CustomEvent","show","bubbles","cancelable","dispatchEvent"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/vanilla/dispatchToast.ts"],"sourcesContent":["import { ShowToastEventDetail, ToastOptions } from '../types';\nimport { EVENTS } from '../constants';\n\nlet counter = 0;\n\nexport function dispatchToast(content: unknown, options: Partial<ToastOptions> = {}, targetDocument: Document) {\n const detail: ShowToastEventDetail = {\n ...options,\n content,\n toastId: options.toastId ?? (counter++).toString(),\n };\n const event = new CustomEvent<ShowToastEventDetail>(EVENTS.show, {\n bubbles: false,\n cancelable: false,\n detail,\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","counter","dispatchToast","content","options","targetDocument","detail","toastId","toString","event","CustomEvent","show","bubbles","cancelable","dispatchEvent"],"mappings":"AACA,SAASA,MAAM,QAAQ,eAAe;AAEtC,IAAIC,UAAU;AAEd,OAAO,SAASC,cAAcC,OAAgB,EAAEC,UAAiC,CAAC,CAAC,EAAEC,cAAwB;QAIhGD;IAHX,MAAME,SAA+B;QACnC,GAAGF,OAAO;QACVD;QACAI,SAASH,CAAAA,mBAAAA,QAAQG,OAAO,cAAfH,8BAAAA,mBAAmB,AAACH,CAAAA,SAAQ,EAAGO,QAAQ;IAClD;IACA,MAAMC,QAAQ,IAAIC,YAAkCV,OAAOW,IAAI,EAAE;QAC/DC,SAAS;QACTC,YAAY;QACZP;IACF;IACAD,eAAeS,aAAa,CAACL;AAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/vanilla/getPositionStyles.ts"],"sourcesContent":["import { ToastOffsetObject, ToastOffset, ToastPosition } from '../types';\n\ninterface PositionStyles {\n top?: number;\n left?: number;\n right?: number;\n bottom?: number;\n}\n\nexport const getPositionStyles = (position: ToastPosition, dir: 'rtl' | 'ltr', offset?: ToastOffset) => {\n const positionStyles: PositionStyles = {};\n\n const offsetStyles: ToastOffsetObject = offset ? (isShorthandOffset(offset) ? offset : offset[position] ?? {}) : {};\n\n const centered = position === 'top' || position === 'bottom';\n\n const { horizontal = centered ? 0 : 20, vertical = 16 } = offsetStyles;\n const start = dir === 'ltr' ? 'left' : 'right';\n const end = dir === 'ltr' ? 'right' : 'left';\n\n switch (position) {\n case 'top':\n Object.assign(positionStyles, {\n top: vertical,\n left: `calc(50% + ${horizontal}px)`,\n transform: 'translateX(-50%)',\n });\n break;\n\n case 'bottom':\n Object.assign(positionStyles, {\n bottom: vertical,\n left: `calc(50% + ${horizontal}px)`,\n transform: 'translateX(-50%)',\n });\n break;\n\n case 'top-start':\n Object.assign(positionStyles, {\n top: vertical,\n [start]: horizontal,\n });\n break;\n case 'top-end':\n Object.assign(positionStyles, {\n top: vertical,\n [end]: horizontal,\n });\n break;\n case 'bottom-start':\n Object.assign(positionStyles, {\n bottom: vertical,\n [start]: horizontal,\n });\n break;\n case 'bottom-end':\n Object.assign(positionStyles, {\n bottom: vertical,\n [end]: horizontal,\n });\n break;\n }\n\n return positionStyles;\n};\n\nfunction isShorthandOffset(offset: ToastOffset): offset is ToastOffsetObject {\n return 'horizontal' in offset || 'vertical' in offset;\n}\n"],"names":["getPositionStyles","position","dir","offset","positionStyles","offsetStyles","isShorthandOffset","centered","horizontal","vertical","start","end","Object","assign","top","left","transform","bottom"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/vanilla/getPositionStyles.ts"],"sourcesContent":["import { ToastOffsetObject, ToastOffset, ToastPosition } from '../types';\n\ninterface PositionStyles {\n top?: number;\n left?: number;\n right?: number;\n bottom?: number;\n}\n\nexport const getPositionStyles = (position: ToastPosition, dir: 'rtl' | 'ltr', offset?: ToastOffset) => {\n const positionStyles: PositionStyles = {};\n\n const offsetStyles: ToastOffsetObject = offset ? (isShorthandOffset(offset) ? offset : offset[position] ?? {}) : {};\n\n const centered = position === 'top' || position === 'bottom';\n\n const { horizontal = centered ? 0 : 20, vertical = 16 } = offsetStyles;\n const start = dir === 'ltr' ? 'left' : 'right';\n const end = dir === 'ltr' ? 'right' : 'left';\n\n switch (position) {\n case 'top':\n Object.assign(positionStyles, {\n top: vertical,\n left: `calc(50% + ${horizontal}px)`,\n transform: 'translateX(-50%)',\n });\n break;\n\n case 'bottom':\n Object.assign(positionStyles, {\n bottom: vertical,\n left: `calc(50% + ${horizontal}px)`,\n transform: 'translateX(-50%)',\n });\n break;\n\n case 'top-start':\n Object.assign(positionStyles, {\n top: vertical,\n [start]: horizontal,\n });\n break;\n case 'top-end':\n Object.assign(positionStyles, {\n top: vertical,\n [end]: horizontal,\n });\n break;\n case 'bottom-start':\n Object.assign(positionStyles, {\n bottom: vertical,\n [start]: horizontal,\n });\n break;\n case 'bottom-end':\n Object.assign(positionStyles, {\n bottom: vertical,\n [end]: horizontal,\n });\n break;\n }\n\n return positionStyles;\n};\n\nfunction isShorthandOffset(offset: ToastOffset): offset is ToastOffsetObject {\n return 'horizontal' in offset || 'vertical' in offset;\n}\n"],"names":["getPositionStyles","position","dir","offset","positionStyles","offsetStyles","isShorthandOffset","centered","horizontal","vertical","start","end","Object","assign","top","left","transform","bottom"],"mappings":"AASA,OAAO,MAAMA,oBAAoB,CAACC,UAAyBC,KAAoBC;IAC7E,MAAMC,iBAAiC,CAAC;QAE+CD;IAAvF,MAAME,eAAkCF,SAAUG,kBAAkBH,UAAUA,SAASA,CAAAA,mBAAAA,MAAM,CAACF,SAAS,cAAhBE,8BAAAA,mBAAoB,CAAC,IAAK,CAAC;IAElH,MAAMI,WAAWN,aAAa,SAASA,aAAa;IAEpD,MAAM,EAAEO,aAAaD,WAAW,IAAI,EAAE,EAAEE,WAAW,EAAE,EAAE,GAAGJ;IAC1D,MAAMK,QAAQR,QAAQ,QAAQ,SAAS;IACvC,MAAMS,MAAMT,QAAQ,QAAQ,UAAU;IAEtC,OAAQD;QACN,KAAK;YACHW,OAAOC,MAAM,CAACT,gBAAgB;gBAC5BU,KAAKL;gBACLM,MAAM,CAAC,WAAW,EAAEP,WAAW,GAAG,CAAC;gBACnCQ,WAAW;YACb;YACA;QAEF,KAAK;YACHJ,OAAOC,MAAM,CAACT,gBAAgB;gBAC5Ba,QAAQR;gBACRM,MAAM,CAAC,WAAW,EAAEP,WAAW,GAAG,CAAC;gBACnCQ,WAAW;YACb;YACA;QAEF,KAAK;YACHJ,OAAOC,MAAM,CAACT,gBAAgB;gBAC5BU,KAAKL;gBACL,CAACC,MAAM,EAAEF;YACX;YACA;QACF,KAAK;YACHI,OAAOC,MAAM,CAACT,gBAAgB;gBAC5BU,KAAKL;gBACL,CAACE,IAAI,EAAEH;YACT;YACA;QACF,KAAK;YACHI,OAAOC,MAAM,CAACT,gBAAgB;gBAC5Ba,QAAQR;gBACR,CAACC,MAAM,EAAEF;YACX;YACA;QACF,KAAK;YACHI,OAAOC,MAAM,CAACT,gBAAgB;gBAC5Ba,QAAQR;gBACR,CAACE,IAAI,EAAEH;YACT;YACA;IACJ;IAEA,OAAOJ;AACT,EAAE;AAEF,SAASE,kBAAkBH,MAAmB;IAC5C,OAAO,gBAAgBA,UAAU,cAAcA;AACjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/vanilla/index.ts"],"sourcesContent":["export { dispatchToast } from './dispatchToast';\nexport { dismissToast } from './dismissToast';\nexport { dismissAllToasts } from './dismissAllToasts';\nexport { updateToast } from './updateToast';\nexport { pauseToast } from './pauseToast';\nexport { playToast } from './playToast';\nexport { createToaster } from './createToaster';\nexport { getPositionStyles } from './getPositionStyles';\n"],"names":["dispatchToast","dismissToast","dismissAllToasts","updateToast","pauseToast","playToast","createToaster","getPositionStyles"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/vanilla/index.ts"],"sourcesContent":["export { dispatchToast } from './dispatchToast';\nexport { dismissToast } from './dismissToast';\nexport { dismissAllToasts } from './dismissAllToasts';\nexport { updateToast } from './updateToast';\nexport { pauseToast } from './pauseToast';\nexport { playToast } from './playToast';\nexport { createToaster } from './createToaster';\nexport { getPositionStyles } from './getPositionStyles';\n"],"names":["dispatchToast","dismissToast","dismissAllToasts","updateToast","pauseToast","playToast","createToaster","getPositionStyles"],"mappings":"AAAA,SAASA,aAAa,QAAQ,kBAAkB;AAChD,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,SAAS,QAAQ,cAAc;AACxC,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,iBAAiB,QAAQ,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/vanilla/pauseToast.ts"],"sourcesContent":["import { EVENTS } from '../constants';\nimport { PauseToastEventDetail, ToastId, ToasterId } from '../types';\n\nexport function pauseToast(toastId: ToastId, toasterId: ToasterId | undefined = undefined, targetDocument: Document) {\n const event = new CustomEvent<PauseToastEventDetail>(EVENTS.pause, {\n bubbles: false,\n cancelable: false,\n detail: { toastId, toasterId },\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","pauseToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","pause","bubbles","cancelable","detail","dispatchEvent"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/vanilla/pauseToast.ts"],"sourcesContent":["import { EVENTS } from '../constants';\nimport { PauseToastEventDetail, ToastId, ToasterId } from '../types';\n\nexport function pauseToast(toastId: ToastId, toasterId: ToasterId | undefined = undefined, targetDocument: Document) {\n const event = new CustomEvent<PauseToastEventDetail>(EVENTS.pause, {\n bubbles: false,\n cancelable: false,\n detail: { toastId, toasterId },\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","pauseToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","pause","bubbles","cancelable","detail","dispatchEvent"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AAGtC,OAAO,SAASC,WAAWC,OAAgB,EAAEC,YAAmCC,SAAS,EAAEC,cAAwB;IACjH,MAAMC,QAAQ,IAAIC,YAAmCP,OAAOQ,KAAK,EAAE;QACjEC,SAAS;QACTC,YAAY;QACZC,QAAQ;YAAET;YAASC;QAAU;IAC/B;IACAE,eAAeO,aAAa,CAACN;AAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/vanilla/playToast.ts"],"sourcesContent":["import { EVENTS } from '../constants';\nimport { PlayToastEventDetail, ToastId, ToasterId } from '../types';\n\nexport function playToast(toastId: ToastId, toasterId: ToasterId | undefined = undefined, targetDocument: Document) {\n const event = new CustomEvent<PlayToastEventDetail>(EVENTS.play, {\n bubbles: false,\n cancelable: false,\n detail: { toastId, toasterId },\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","playToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","play","bubbles","cancelable","detail","dispatchEvent"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/vanilla/playToast.ts"],"sourcesContent":["import { EVENTS } from '../constants';\nimport { PlayToastEventDetail, ToastId, ToasterId } from '../types';\n\nexport function playToast(toastId: ToastId, toasterId: ToasterId | undefined = undefined, targetDocument: Document) {\n const event = new CustomEvent<PlayToastEventDetail>(EVENTS.play, {\n bubbles: false,\n cancelable: false,\n detail: { toastId, toasterId },\n });\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","playToast","toastId","toasterId","undefined","targetDocument","event","CustomEvent","play","bubbles","cancelable","detail","dispatchEvent"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AAGtC,OAAO,SAASC,UAAUC,OAAgB,EAAEC,YAAmCC,SAAS,EAAEC,cAAwB;IAChH,MAAMC,QAAQ,IAAIC,YAAkCP,OAAOQ,IAAI,EAAE;QAC/DC,SAAS;QACTC,YAAY;QACZC,QAAQ;YAAET;YAASC;QAAU;IAC/B;IACAE,eAAeO,aAAa,CAACN;AAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/vanilla/updateToast.ts"],"sourcesContent":["import { UpdateToastEventDetail } from '../types';\nimport { EVENTS } from '../constants';\n\nexport function updateToast(options: UpdateToastEventDetail, targetDocument: Document) {\n const event = new CustomEvent<UpdateToastEventDetail>(EVENTS.update, {\n bubbles: false,\n cancelable: false,\n detail: options,\n });\n\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","updateToast","options","targetDocument","event","CustomEvent","update","bubbles","cancelable","detail","dispatchEvent"],"
|
|
1
|
+
{"version":3,"sources":["../src/state/vanilla/updateToast.ts"],"sourcesContent":["import { UpdateToastEventDetail } from '../types';\nimport { EVENTS } from '../constants';\n\nexport function updateToast(options: UpdateToastEventDetail, targetDocument: Document) {\n const event = new CustomEvent<UpdateToastEventDetail>(EVENTS.update, {\n bubbles: false,\n cancelable: false,\n detail: options,\n });\n\n targetDocument.dispatchEvent(event);\n}\n"],"names":["EVENTS","updateToast","options","targetDocument","event","CustomEvent","update","bubbles","cancelable","detail","dispatchEvent"],"mappings":"AACA,SAASA,MAAM,QAAQ,eAAe;AAEtC,OAAO,SAASC,YAAYC,OAA+B,EAAEC,cAAwB;IACnF,MAAMC,QAAQ,IAAIC,YAAoCL,OAAOM,MAAM,EAAE;QACnEC,SAAS;QACTC,YAAY;QACZC,QAAQP;IACV;IAEAC,eAAeO,aAAa,CAACN;AAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/AriaLive.ts"],"sourcesContent":["export type {\n Announce,\n AnnounceOptions,\n AriaLivePoliteness,\n AriaLiveProps,\n AriaLiveSlots,\n AriaLiveState,\n LiveMessage,\n} from './components/AriaLive/index';\nexport {\n AriaLive,\n ariaLiveClassNames,\n renderAriaLive_unstable,\n useAriaLiveStyles_unstable,\n useAriaLive_unstable,\n} from './components/AriaLive/index';\n"],"names":["AriaLive","ariaLiveClassNames","renderAriaLive_unstable","useAriaLiveStyles_unstable","useAriaLive_unstable"],"
|
|
1
|
+
{"version":3,"sources":["../src/AriaLive.ts"],"sourcesContent":["export type {\n Announce,\n AnnounceOptions,\n AriaLivePoliteness,\n AriaLiveProps,\n AriaLiveSlots,\n AriaLiveState,\n LiveMessage,\n} from './components/AriaLive/index';\nexport {\n AriaLive,\n ariaLiveClassNames,\n renderAriaLive_unstable,\n useAriaLiveStyles_unstable,\n useAriaLive_unstable,\n} from './components/AriaLive/index';\n"],"names":["AriaLive","ariaLiveClassNames","renderAriaLive_unstable","useAriaLiveStyles_unstable","useAriaLive_unstable"],"mappings":";;;;;;;;;;;;eAUEA,eAAQ;;;eACRC,yBAAkB;;;eAClBC,8BAAuB;;;eACvBC,iCAA0B;;;eAC1BC,2BAAoB;;;uBACf,8BAA8B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Toast.ts"],"sourcesContent":["export type { ToastContextValues, ToastProps, ToastSlots, ToastState } from './components/Toast/index';\nexport {\n Toast,\n renderToast_unstable,\n toastClassNames,\n useToastStyles_unstable,\n useToast_unstable,\n} from './components/Toast/index';\n"],"names":["Toast","renderToast_unstable","toastClassNames","useToastStyles_unstable","useToast_unstable"],"
|
|
1
|
+
{"version":3,"sources":["../src/Toast.ts"],"sourcesContent":["export type { ToastContextValues, ToastProps, ToastSlots, ToastState } from './components/Toast/index';\nexport {\n Toast,\n renderToast_unstable,\n toastClassNames,\n useToastStyles_unstable,\n useToast_unstable,\n} from './components/Toast/index';\n"],"names":["Toast","renderToast_unstable","toastClassNames","useToastStyles_unstable","useToast_unstable"],"mappings":";;;;;;;;;;;;eAEEA,YAAK;;;eACLC,2BAAoB;;;eACpBC,sBAAe;;;eACfC,8BAAuB;;;eACvBC,wBAAiB;;;uBACZ,2BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ToastBody.ts"],"sourcesContent":["export type { ToastBodyProps, ToastBodySlots, ToastBodyState } from './components/ToastBody/index';\nexport {\n ToastBody,\n renderToastBody_unstable,\n toastBodyClassNames,\n useToastBodyStyles_unstable,\n useToastBody_unstable,\n} from './components/ToastBody/index';\n"],"names":["ToastBody","renderToastBody_unstable","toastBodyClassNames","useToastBodyStyles_unstable","useToastBody_unstable"],"
|
|
1
|
+
{"version":3,"sources":["../src/ToastBody.ts"],"sourcesContent":["export type { ToastBodyProps, ToastBodySlots, ToastBodyState } from './components/ToastBody/index';\nexport {\n ToastBody,\n renderToastBody_unstable,\n toastBodyClassNames,\n useToastBodyStyles_unstable,\n useToastBody_unstable,\n} from './components/ToastBody/index';\n"],"names":["ToastBody","renderToastBody_unstable","toastBodyClassNames","useToastBodyStyles_unstable","useToastBody_unstable"],"mappings":";;;;;;;;;;;;eAEEA,gBAAS;;;eACTC,+BAAwB;;;eACxBC,0BAAmB;;;eACnBC,kCAA2B;;;eAC3BC,4BAAqB;;;uBAChB,+BAA+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ToastContainer.ts"],"sourcesContent":["export type {\n ToastContainerContextValues,\n ToastContainerProps,\n ToastContainerSlots,\n ToastContainerState,\n} from './components/ToastContainer/index';\nexport {\n ToastContainer,\n renderToastContainer_unstable,\n toastContainerClassNames,\n useToastContainerContextValues_unstable,\n useToastContainerStyles_unstable,\n useToastContainer_unstable,\n} from './components/ToastContainer/index';\n"],"names":["ToastContainer","renderToastContainer_unstable","toastContainerClassNames","useToastContainerContextValues_unstable","useToastContainerStyles_unstable","useToastContainer_unstable"],"
|
|
1
|
+
{"version":3,"sources":["../src/ToastContainer.ts"],"sourcesContent":["export type {\n ToastContainerContextValues,\n ToastContainerProps,\n ToastContainerSlots,\n ToastContainerState,\n} from './components/ToastContainer/index';\nexport {\n ToastContainer,\n renderToastContainer_unstable,\n toastContainerClassNames,\n useToastContainerContextValues_unstable,\n useToastContainerStyles_unstable,\n useToastContainer_unstable,\n} from './components/ToastContainer/index';\n"],"names":["ToastContainer","renderToastContainer_unstable","toastContainerClassNames","useToastContainerContextValues_unstable","useToastContainerStyles_unstable","useToastContainer_unstable"],"mappings":";;;;;;;;;;;;eAOEA,qBAAc;;;eACdC,oCAA6B;;;eAC7BC,+BAAwB;;;eACxBC,8CAAuC;;;eACvCC,uCAAgC;;;eAChCC,iCAA0B;;;uBACrB,oCAAoC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ToastFooter.ts"],"sourcesContent":["export type { ToastFooterProps, ToastFooterSlots, ToastFooterState } from './components/ToastFooter/index';\nexport {\n ToastFooter,\n renderToastFooter_unstable,\n toastFooterClassNames,\n useToastFooterStyles_unstable,\n useToastFooter_unstable,\n} from './components/ToastFooter/index';\n"],"names":["ToastFooter","renderToastFooter_unstable","toastFooterClassNames","useToastFooterStyles_unstable","useToastFooter_unstable"],"
|
|
1
|
+
{"version":3,"sources":["../src/ToastFooter.ts"],"sourcesContent":["export type { ToastFooterProps, ToastFooterSlots, ToastFooterState } from './components/ToastFooter/index';\nexport {\n ToastFooter,\n renderToastFooter_unstable,\n toastFooterClassNames,\n useToastFooterStyles_unstable,\n useToastFooter_unstable,\n} from './components/ToastFooter/index';\n"],"names":["ToastFooter","renderToastFooter_unstable","toastFooterClassNames","useToastFooterStyles_unstable","useToastFooter_unstable"],"mappings":";;;;;;;;;;;;eAEEA,kBAAW;;;eACXC,iCAA0B;;;eAC1BC,4BAAqB;;;eACrBC,oCAA6B;;;eAC7BC,8BAAuB;;;uBAClB,iCAAiC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ToastTitle.ts"],"sourcesContent":["export type { ToastTitleProps, ToastTitleSlots, ToastTitleState } from './components/ToastTitle/index';\nexport {\n ToastTitle,\n renderToastTitle_unstable,\n toastTitleClassNames,\n useToastTitleStyles_unstable,\n useToastTitle_unstable,\n} from './components/ToastTitle/index';\n"],"names":["ToastTitle","renderToastTitle_unstable","toastTitleClassNames","useToastTitleStyles_unstable","useToastTitle_unstable"],"
|
|
1
|
+
{"version":3,"sources":["../src/ToastTitle.ts"],"sourcesContent":["export type { ToastTitleProps, ToastTitleSlots, ToastTitleState } from './components/ToastTitle/index';\nexport {\n ToastTitle,\n renderToastTitle_unstable,\n toastTitleClassNames,\n useToastTitleStyles_unstable,\n useToastTitle_unstable,\n} from './components/ToastTitle/index';\n"],"names":["ToastTitle","renderToastTitle_unstable","toastTitleClassNames","useToastTitleStyles_unstable","useToastTitle_unstable"],"mappings":";;;;;;;;;;;;eAEEA,iBAAU;;;eACVC,gCAAyB;;;eACzBC,2BAAoB;;;eACpBC,mCAA4B;;;eAC5BC,6BAAsB;;;uBACjB,gCAAgC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ToastTrigger.ts"],"sourcesContent":["export type { ToastTriggerChildProps, ToastTriggerProps, ToastTriggerState } from './components/ToastTrigger/index';\nexport { ToastTrigger, renderToastTrigger_unstable, useToastTrigger_unstable } from './components/ToastTrigger/index';\n"],"names":["ToastTrigger","renderToastTrigger_unstable","useToastTrigger_unstable"],"
|
|
1
|
+
{"version":3,"sources":["../src/ToastTrigger.ts"],"sourcesContent":["export type { ToastTriggerChildProps, ToastTriggerProps, ToastTriggerState } from './components/ToastTrigger/index';\nexport { ToastTrigger, renderToastTrigger_unstable, useToastTrigger_unstable } from './components/ToastTrigger/index';\n"],"names":["ToastTrigger","renderToastTrigger_unstable","useToastTrigger_unstable"],"mappings":";;;;;;;;;;;;eACSA,mBAAY;;;eAAEC,kCAA2B;;;eAAEC,+BAAwB;;;uBAAQ,kCAAkC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Toaster.ts"],"sourcesContent":["export type { ToasterProps, ToasterSlots, ToasterSlotsInternal, ToasterState } from './components/Toaster/index';\nexport {\n Toaster,\n renderToaster_unstable,\n toasterClassNames,\n useToasterStyles_unstable,\n useToaster_unstable,\n} from './components/Toaster/index';\n"],"names":["Toaster","renderToaster_unstable","toasterClassNames","useToasterStyles_unstable","useToaster_unstable"],"
|
|
1
|
+
{"version":3,"sources":["../src/Toaster.ts"],"sourcesContent":["export type { ToasterProps, ToasterSlots, ToasterSlotsInternal, ToasterState } from './components/Toaster/index';\nexport {\n Toaster,\n renderToaster_unstable,\n toasterClassNames,\n useToasterStyles_unstable,\n useToaster_unstable,\n} from './components/Toaster/index';\n"],"names":["Toaster","renderToaster_unstable","toasterClassNames","useToasterStyles_unstable","useToaster_unstable"],"mappings":";;;;;;;;;;;;eAEEA,cAAO;;;eACPC,6BAAsB;;;eACtBC,wBAAiB;;;eACjBC,gCAAyB;;;eACzBC,0BAAmB;;;uBACd,6BAA6B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/AriaLive/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":["
|
|
1
|
+
{"version":3,"sources":["../src/components/AriaLive/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":";;;;;;;;;;;iEAAuB,QAAQ;6BACM,gBAAgB;gCACb,mBAAmB;yCAChB,6BAA6B;AAMjE,MAAMI,WAAoCC,CAAAA;IAC/C,MAAMC,YAAQL,iCAAAA,EAAqBI;QAEnCF,mDAAAA,EAA2BG;IAC3B,WAAOJ,uCAAAA,EAAwBI;AACjC,EAAE;AAEFF,SAASG,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/AriaLive/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 children?: React.ReactNode;\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":[
|
|
1
|
+
{"version":3,"sources":["../src/components/AriaLive/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 children?: React.ReactNode;\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":";;;;;iEAAuB,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/AriaLive/index.ts"],"sourcesContent":["export { AriaLive } from './AriaLive';\nexport type {\n Announce,\n AnnounceOptions,\n AriaLivePoliteness,\n AriaLiveProps,\n AriaLiveSlots,\n AriaLiveState,\n LiveMessage,\n} from './AriaLive.types';\nexport { renderAriaLive_unstable } from './renderAriaLive';\nexport { useAriaLive_unstable } from './useAriaLive';\nexport { ariaLiveClassNames, useAriaLiveStyles_unstable } from './useAriaLiveStyles.styles';\n"],"names":["AriaLive","
|
|
1
|
+
{"version":3,"sources":["../src/components/AriaLive/index.ts"],"sourcesContent":["export { AriaLive } from './AriaLive';\nexport type {\n Announce,\n AnnounceOptions,\n AriaLivePoliteness,\n AriaLiveProps,\n AriaLiveSlots,\n AriaLiveState,\n LiveMessage,\n} from './AriaLive.types';\nexport { renderAriaLive_unstable } from './renderAriaLive';\nexport { useAriaLive_unstable } from './useAriaLive';\nexport { ariaLiveClassNames, useAriaLiveStyles_unstable } from './useAriaLiveStyles.styles';\n"],"names":["AriaLive","renderAriaLive_unstable","useAriaLive_unstable","ariaLiveClassNames","useAriaLiveStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,kBAAQ;;;eAYRG,2CAAkB;;;eAFlBF,uCAAuB;;;eAEHG,mDAA0B;;;eAD9CF,iCAAoB;;;0BAXJ,aAAa;gCAUE,mBAAmB;6BACtB,gBAAgB;yCACU,6BAA6B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/AriaLive/renderAriaLive.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } 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 assertSlots<AriaLiveSlots>(state);\n\n return (\n <>\n <state.assertive />\n <state.polite />\n </>\n );\n};\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/components/AriaLive/renderAriaLive.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } 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 assertSlots<AriaLiveSlots>(state);\n\n return (\n <>\n <state.assertive />\n <state.polite />\n </>\n );\n};\n"],"names":["assertSlots","renderAriaLive_unstable","state","assertive","polite"],"mappings":";;;;+BASaC;;;;;;4BARb,UAAiD;gCAErB,4BAA4B;AAMjD,gCAAgC,CAACC;QACtCF,2BAAAA,EAA2BE;IAE3B,OAAA,WAAA,OACE,gBAAA,EAAA,oBAAA,EAAA;;8BACE,eAAA,EAACA,MAAMC,SAAS,EAAA,CAAA;8BAChB,eAAA,EAACD,MAAME,MAAM,EAAA,CAAA;;;AAGnB,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/AriaLive/useAriaLive.ts"],"sourcesContent":["import * as React from 'react';\nimport { createPriorityQueue, useEventCallback, slot, useTimeout } from '@fluentui/react-utilities';\nimport type { AnnounceOptions, AriaLiveProps, AriaLiveState, LiveMessage } from './AriaLive.types';\n\n/** The duration the message needs to be in present in DOM for screen readers to register a change and announce */\nconst MESSAGE_DURATION = 500;\n\n/**\n * Create the state required to render AriaLive.\n *\n * The returned state can be modified with hooks such as useAriaLiveStyles_unstable,\n * before being passed to renderAriaLive_unstable.\n *\n * @param props - props from this instance of AriaLive\n */\nexport const useAriaLive_unstable = (props: AriaLiveProps): AriaLiveState => {\n const [currentMessage, setCurrentMessage] = React.useState<LiveMessage | undefined>(undefined);\n // Can't rely on Date.now() if user invokes announce more than once in a code block\n const order = React.useRef(0);\n const [messageQueue] = React.useState(() =>\n createPriorityQueue<LiveMessage>((a, b) => {\n if (a.politeness === b.politeness) {\n return a.createdAt - b.createdAt;\n }\n\n return a.politeness === 'assertive' ? -1 : 1;\n }),\n );\n\n const announce = useEventCallback((message: string, options: AnnounceOptions) => {\n const { politeness } = options;\n if (message === currentMessage?.message) {\n return;\n }\n\n const liveMessage: LiveMessage = {\n message,\n politeness,\n createdAt: order.current++,\n };\n\n if (!currentMessage) {\n setCurrentMessage(liveMessage);\n } else {\n messageQueue.enqueue(liveMessage);\n }\n });\n\n const [setMessageTimeout, clearMessageTimeout] = useTimeout();\n\n React.useEffect(() => {\n setMessageTimeout(() => {\n if (messageQueue.peek()) {\n setCurrentMessage(messageQueue.dequeue());\n } else {\n setCurrentMessage(undefined);\n }\n }, MESSAGE_DURATION);\n\n return () => clearMessageTimeout();\n }, [currentMessage, messageQueue, setMessageTimeout, clearMessageTimeout]);\n\n React.useImperativeHandle(props.announceRef, () => announce);\n\n const politeMessage = currentMessage?.politeness === 'polite' ? currentMessage.message : undefined;\n const assertiveMessage = currentMessage?.politeness === 'assertive' ? currentMessage.message : undefined;\n\n return {\n components: {\n assertive: 'div',\n polite: 'div',\n },\n\n assertive: slot.always(props.assertive, {\n defaultProps: { 'aria-live': 'assertive', children: assertiveMessage },\n elementType: 'div',\n }),\n polite: slot.always(props.polite, {\n defaultProps: { 'aria-live': 'polite', children: politeMessage },\n elementType: 'div',\n }),\n };\n};\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/components/AriaLive/useAriaLive.ts"],"sourcesContent":["import * as React from 'react';\nimport { createPriorityQueue, useEventCallback, slot, useTimeout } from '@fluentui/react-utilities';\nimport type { AnnounceOptions, AriaLiveProps, AriaLiveState, LiveMessage } from './AriaLive.types';\n\n/** The duration the message needs to be in present in DOM for screen readers to register a change and announce */\nconst MESSAGE_DURATION = 500;\n\n/**\n * Create the state required to render AriaLive.\n *\n * The returned state can be modified with hooks such as useAriaLiveStyles_unstable,\n * before being passed to renderAriaLive_unstable.\n *\n * @param props - props from this instance of AriaLive\n */\nexport const useAriaLive_unstable = (props: AriaLiveProps): AriaLiveState => {\n const [currentMessage, setCurrentMessage] = React.useState<LiveMessage | undefined>(undefined);\n // Can't rely on Date.now() if user invokes announce more than once in a code block\n const order = React.useRef(0);\n const [messageQueue] = React.useState(() =>\n createPriorityQueue<LiveMessage>((a, b) => {\n if (a.politeness === b.politeness) {\n return a.createdAt - b.createdAt;\n }\n\n return a.politeness === 'assertive' ? -1 : 1;\n }),\n );\n\n const announce = useEventCallback((message: string, options: AnnounceOptions) => {\n const { politeness } = options;\n if (message === currentMessage?.message) {\n return;\n }\n\n const liveMessage: LiveMessage = {\n message,\n politeness,\n createdAt: order.current++,\n };\n\n if (!currentMessage) {\n setCurrentMessage(liveMessage);\n } else {\n messageQueue.enqueue(liveMessage);\n }\n });\n\n const [setMessageTimeout, clearMessageTimeout] = useTimeout();\n\n React.useEffect(() => {\n setMessageTimeout(() => {\n if (messageQueue.peek()) {\n setCurrentMessage(messageQueue.dequeue());\n } else {\n setCurrentMessage(undefined);\n }\n }, MESSAGE_DURATION);\n\n return () => clearMessageTimeout();\n }, [currentMessage, messageQueue, setMessageTimeout, clearMessageTimeout]);\n\n React.useImperativeHandle(props.announceRef, () => announce);\n\n const politeMessage = currentMessage?.politeness === 'polite' ? currentMessage.message : undefined;\n const assertiveMessage = currentMessage?.politeness === 'assertive' ? currentMessage.message : undefined;\n\n return {\n components: {\n assertive: 'div',\n polite: 'div',\n },\n\n assertive: slot.always(props.assertive, {\n defaultProps: { 'aria-live': 'assertive', children: assertiveMessage },\n elementType: 'div',\n }),\n polite: slot.always(props.polite, {\n defaultProps: { 'aria-live': 'polite', children: politeMessage },\n elementType: 'div',\n }),\n };\n};\n"],"names":["React","createPriorityQueue","useEventCallback","slot","useTimeout","MESSAGE_DURATION","useAriaLive_unstable","props","currentMessage","setCurrentMessage","useState","undefined","order","useRef","messageQueue","a","b","politeness","createdAt","announce","message","options","liveMessage","current","enqueue","setMessageTimeout","clearMessageTimeout","useEffect","peek","dequeue","useImperativeHandle","announceRef","politeMessage","assertiveMessage","components","assertive","polite","always","defaultProps","children","elementType"],"mappings":";;;;+BAeaM;;;;;;;iEAfU,QAAQ;gCACyC,4BAA4B;AAGpG,gHAAgH,GAChH,MAAMD,mBAAmB;AAUlB,6BAA6B,CAACE;IACnC,MAAM,CAACC,gBAAgBC,kBAAkB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KAAAA,IAAAA,KAAAA,IAAAA,eAAgBS,UAAAA,AAAU,MAAK,cAAcT,eAAeY,OAAO,GAAGT;IAE/F,OAAO;QACLuB,YAAY;YACVC,WAAW;YACXC,QAAQ;QACV;QAEAD,WAAWhC,oBAAAA,CAAKkC,MAAM,CAAC9B,MAAM4B,SAAS,EAAE;YACtCG,cAAc;gBAAE,aAAa;gBAAaC,UAAUN;YAAiB;YACrEO,aAAa;QACf;QACAJ,QAAQjC,oBAAAA,CAAKkC,MAAM,CAAC9B,MAAM6B,MAAM,EAAE;YAChCE,cAAc;gBAAE,aAAa;gBAAUC,UAAUP;YAAc;YAC/DQ,aAAa;QACf;IACF;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useAriaLiveStyles.styles.js"],"sourcesContent":["import { mergeClasses, makeResetStyles } from '@griffel/react';\nexport const ariaLiveClassNames = {\n assertive: 'fui-AriaLive__assertive',\n polite: 'fui-AriaLive__polite'\n};\n/**\n * Styles for the root slot\n */ const useResetStyles = makeResetStyles({\n clip: 'rect(0px, 0px, 0px, 0px)',\n height: '1px',\n margin: '-1px',\n overflow: 'hidden',\n padding: '0px',\n width: '1px',\n position: 'absolute'\n});\n/**\n * Apply styling to the AriaLive slots based on the state\n */ export const useAriaLiveStyles_unstable = (state)=>{\n 'use no memo';\n const visuallyHidden = useResetStyles();\n state.assertive.className = mergeClasses(visuallyHidden, ariaLiveClassNames.assertive, state.assertive.className);\n state.polite.className = mergeClasses(visuallyHidden, ariaLiveClassNames.polite, state.polite.className);\n return state;\n};\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["useAriaLiveStyles.styles.js"],"sourcesContent":["import { mergeClasses, makeResetStyles } from '@griffel/react';\nexport const ariaLiveClassNames = {\n assertive: 'fui-AriaLive__assertive',\n polite: 'fui-AriaLive__polite'\n};\n/**\n * Styles for the root slot\n */ const useResetStyles = makeResetStyles({\n clip: 'rect(0px, 0px, 0px, 0px)',\n height: '1px',\n margin: '-1px',\n overflow: 'hidden',\n padding: '0px',\n width: '1px',\n position: 'absolute'\n});\n/**\n * Apply styling to the AriaLive slots based on the state\n */ export const useAriaLiveStyles_unstable = (state)=>{\n 'use no memo';\n const visuallyHidden = useResetStyles();\n state.assertive.className = mergeClasses(visuallyHidden, ariaLiveClassNames.assertive, state.assertive.className);\n state.polite.className = mergeClasses(visuallyHidden, ariaLiveClassNames.polite, state.polite.className);\n return state;\n};\n"],"names":["mergeClasses","__resetStyles","ariaLiveClassNames","assertive","polite","useResetStyles","useAriaLiveStyles_unstable","state","visuallyHidden","className"],"mappings":";;;;;;;;;;;IACaE,kBAAkB;;;8BAiBY;;;;uBAlBG,gBAAgB;AACvD,2BAA2B;IAC9BC,SAAS,EAAE,yBAAyB;IACpCC,MAAM,EAAE;AACZ,CAAC;AACD;;CAEA,GAAI,MAAMC,cAAc,GAAA,WAAA,OAAGJ,oBAAA,EAAA,WAAA,MAAA;IAAA;CAQ1B,CAAC;AAGS,MAAMK,8BAA8BC,KAAK,IAAG;IACnD,aAAa;IACb,MAAMC,cAAc,GAAGH,cAAc,CAAC,CAAC;IACvCE,KAAK,CAACJ,SAAS,CAACM,SAAS,OAAGT,mBAAY,EAACQ,cAAc,EAAEN,kBAAkB,CAACC,SAAS,EAAEI,KAAK,CAACJ,SAAS,CAACM,SAAS,CAAC;IACjHF,KAAK,CAACH,MAAM,CAACK,SAAS,OAAGT,mBAAY,EAACQ,cAAc,EAAEN,kBAAkB,CAACE,MAAM,EAAEG,KAAK,CAACH,MAAM,CAACK,SAAS,CAAC;IACxG,OAAOF,KAAK;AAChB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
ariaLiveClassNames: function() {
|
|
13
|
+
return ariaLiveClassNames;
|
|
14
|
+
},
|
|
15
|
+
useAriaLiveStyles_unstable: function() {
|
|
16
|
+
return useAriaLiveStyles_unstable;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _react = require("@griffel/react");
|
|
20
|
+
const ariaLiveClassNames = {
|
|
21
|
+
assertive: 'fui-AriaLive__assertive',
|
|
22
|
+
polite: 'fui-AriaLive__polite'
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Styles for the root slot
|
|
26
|
+
*/ const useResetStyles = (0, _react.makeResetStyles)({
|
|
27
|
+
clip: 'rect(0px, 0px, 0px, 0px)',
|
|
28
|
+
height: '1px',
|
|
29
|
+
margin: '-1px',
|
|
30
|
+
overflow: 'hidden',
|
|
31
|
+
padding: '0px',
|
|
32
|
+
width: '1px',
|
|
33
|
+
position: 'absolute'
|
|
34
|
+
});
|
|
35
|
+
const useAriaLiveStyles_unstable = (state)=>{
|
|
36
|
+
'use no memo';
|
|
37
|
+
const visuallyHidden = useResetStyles();
|
|
38
|
+
state.assertive.className = (0, _react.mergeClasses)(visuallyHidden, ariaLiveClassNames.assertive, state.assertive.className);
|
|
39
|
+
state.polite.className = (0, _react.mergeClasses)(visuallyHidden, ariaLiveClassNames.polite, state.polite.className);
|
|
40
|
+
return state;
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/AriaLive/useAriaLiveStyles.styles.ts"],"sourcesContent":["import { mergeClasses, makeResetStyles } from '@griffel/react';\nimport type { AriaLiveSlots, AriaLiveState } from './AriaLive.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const ariaLiveClassNames: SlotClassNames<AriaLiveSlots> = {\n assertive: 'fui-AriaLive__assertive',\n polite: 'fui-AriaLive__polite',\n};\n\n/**\n * Styles for the root slot\n */\nconst useResetStyles = makeResetStyles({\n clip: 'rect(0px, 0px, 0px, 0px)',\n height: '1px',\n margin: '-1px',\n overflow: 'hidden',\n padding: '0px',\n width: '1px',\n position: 'absolute',\n});\n\n/**\n * Apply styling to the AriaLive slots based on the state\n */\nexport const useAriaLiveStyles_unstable = (state: AriaLiveState): AriaLiveState => {\n 'use no memo';\n\n const visuallyHidden = useResetStyles();\n state.assertive.className = mergeClasses(visuallyHidden, ariaLiveClassNames.assertive, state.assertive.className);\n state.polite.className = mergeClasses(visuallyHidden, ariaLiveClassNames.polite, state.polite.className);\n\n return state;\n};\n"],"names":["mergeClasses","makeResetStyles","ariaLiveClassNames","assertive","polite","useResetStyles","clip","height","margin","overflow","padding","width","position","useAriaLiveStyles_unstable","state","visuallyHidden","className"],"mappings":";;;;;;;;;;;IAIaE,kBAAAA;;;8BAqBAW;;;;uBAzBiC,iBAAiB;AAIxD,2BAA0D;IAC/DV,WAAW;IACXC,QAAQ;AACV,EAAE;AAEF;;CAEC,GACD,MAAMC,qBAAiBJ,sBAAAA,EAAgB;IACrCK,MAAM;IACNC,QAAQ;IACRC,QAAQ;IACRC,UAAU;IACVC,SAAS;IACTC,OAAO;IACPC,UAAU;AACZ;AAKO,MAAMC,6BAA6B,CAACC;IACzC;IAEA,MAAMC,iBAAiBV;IACvBS,MAAMX,SAAS,CAACa,SAAS,OAAGhB,mBAAAA,EAAae,gBAAgBb,mBAAmBC,SAAS,EAAEW,MAAMX,SAAS,CAACa,SAAS;IAChHF,MAAMV,MAAM,CAACY,SAAS,OAAGhB,mBAAAA,EAAae,gBAAgBb,mBAAmBE,MAAM,EAAEU,MAAMV,MAAM,CAACY,SAAS;IAEvG,OAAOF;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Timer/Timer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useBaseAnimationStyles } from './useTimerStyles.styles';\n\nexport type TimerProps = {\n running: boolean;\n timeout: number;\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onTimeout: () => void;\n as?: 'span';\n};\n\nexport const Timer = React.forwardRef<HTMLDivElement, TimerProps>((props, ref) => {\n const baseAnimationStyles = useBaseAnimationStyles();\n const { running, timeout, onTimeout } = props;\n\n const style: React.CSSProperties = {\n animationDuration: `${timeout}ms`,\n animationPlayState: running ? 'running' : 'paused',\n };\n\n if (timeout < 0) {\n return null;\n }\n\n return (\n <span\n onAnimationEnd={onTimeout}\n data-timer-status={style.animationPlayState}\n ref={ref}\n style={style}\n className={baseAnimationStyles}\n />\n );\n});\n\nTimer.displayName = 'Timer';\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/components/Timer/Timer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useBaseAnimationStyles } from './useTimerStyles.styles';\n\nexport type TimerProps = {\n running: boolean;\n timeout: number;\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onTimeout: () => void;\n as?: 'span';\n};\n\nexport const Timer = React.forwardRef<HTMLDivElement, TimerProps>((props, ref) => {\n const baseAnimationStyles = useBaseAnimationStyles();\n const { running, timeout, onTimeout } = props;\n\n const style: React.CSSProperties = {\n animationDuration: `${timeout}ms`,\n animationPlayState: running ? 'running' : 'paused',\n };\n\n if (timeout < 0) {\n return null;\n }\n\n return (\n <span\n onAnimationEnd={onTimeout}\n data-timer-status={style.animationPlayState}\n ref={ref}\n style={style}\n className={baseAnimationStyles}\n />\n );\n});\n\nTimer.displayName = 'Timer';\n"],"names":["React","useBaseAnimationStyles","Timer","forwardRef","props","ref","baseAnimationStyles","running","timeout","onTimeout","style","animationDuration","animationPlayState","span","onAnimationEnd","data-timer-status","className","displayName"],"mappings":";;;;+BAWaE;;;;;;;iEAXU,QAAQ;sCACQ,0BAA0B;AAU1D,cAAMA,WAAAA,GAAQF,OAAMG,UAAU,CAA6B,CAACC,OAAOC;IACxE,MAAMC,0BAAsBL,4CAAAA;IAC5B,MAAM,EAAEM,OAAO,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGL;IAExC,MAAMM,QAA6B;QACjCC,mBAAmB,GAAGH,QAAQ,EAAE,CAAC;QACjCI,oBAAoBL,UAAU,YAAY;IAC5C;IAEA,IAAIC,UAAU,GAAG;QACf,OAAO;IACT;IAEA,OAAA,WAAA,GACE,OAAA,aAAA,CAACK,QAAAA;QACCC,gBAAgBL;QAChBM,qBAAmBL,MAAME,kBAAkB;QAC3CP,KAAKA;QACLK,OAAOA;QACPM,WAAWV;;AAGjB,GAAG;AAEHJ,MAAMe,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Timer/index.ts"],"sourcesContent":["export type { TimerProps } from './Timer';\nexport { Timer } from './Timer';\n"],"names":["Timer"],"
|
|
1
|
+
{"version":3,"sources":["../src/components/Timer/index.ts"],"sourcesContent":["export type { TimerProps } from './Timer';\nexport { Timer } from './Timer';\n"],"names":["Timer"],"mappings":";;;;;;;eACSA,YAAK;;;uBAAQ,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTimerStyles.styles.js"],"sourcesContent":["import { makeResetStyles } from '@griffel/react';\nexport const useBaseAnimationStyles = makeResetStyles({\n animationName: {\n from: {\n opacity: 0\n },\n to: {\n opacity: 0\n }\n }\n});\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["useTimerStyles.styles.js"],"sourcesContent":["import { makeResetStyles } from '@griffel/react';\nexport const useBaseAnimationStyles = makeResetStyles({\n animationName: {\n from: {\n opacity: 0\n },\n to: {\n opacity: 0\n }\n }\n});\n"],"names":["__resetStyles","useBaseAnimationStyles"],"mappings":";;;;;;;;;;uBAAgC,gBAAgB;AACzC,MAAMC,sBAAsB,GAAA,WAAA,OAAGD,oBAAA,EAAA,YAAA,WAAA;IAAA;IAAA;IAAA;CASrC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useBaseAnimationStyles", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return useBaseAnimationStyles;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = require("@griffel/react");
|
|
12
|
+
const useBaseAnimationStyles = (0, _react.makeResetStyles)({
|
|
13
|
+
animationName: {
|
|
14
|
+
from: {
|
|
15
|
+
opacity: 0
|
|
16
|
+
},
|
|
17
|
+
to: {
|
|
18
|
+
opacity: 0
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Timer/useTimerStyles.styles.ts"],"sourcesContent":["import { makeResetStyles } from '@griffel/react';\n\nexport const useBaseAnimationStyles = makeResetStyles({\n animationName: {\n from: {\n opacity: 0,\n },\n to: {\n opacity: 0,\n },\n },\n});\n"],"names":["makeResetStyles","useBaseAnimationStyles","animationName","from","opacity","to"],"mappings":";;;;;;;;;;uBAAgC,iBAAiB;AAE1C,MAAMC,6BAAyBD,sBAAAA,EAAgB;IACpDE,eAAe;QACbC,MAAM;YACJC,SAAS;QACX;QACAC,IAAI;YACFD,SAAS;QACX;IACF;AACF,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Toast/Toast.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useToast_unstable } from './useToast';\nimport { renderToast_unstable } from './renderToast';\nimport { useToastStyles_unstable } from './useToastStyles.styles';\nimport type { ToastProps } from './Toast.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useToastContextValues_unstable } from './useToastContextValues';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * Toast component\n */\nexport const Toast: ForwardRefComponent<ToastProps> = React.forwardRef((props, ref) => {\n const state = useToast_unstable(props, ref);\n\n useToastStyles_unstable(state);\n useCustomStyleHook_unstable('useToastStyles_unstable')(state);\n\n return renderToast_unstable(state, useToastContextValues_unstable(state));\n});\n\nToast.displayName = 'Toast';\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/components/Toast/Toast.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useToast_unstable } from './useToast';\nimport { renderToast_unstable } from './renderToast';\nimport { useToastStyles_unstable } from './useToastStyles.styles';\nimport type { ToastProps } from './Toast.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useToastContextValues_unstable } from './useToastContextValues';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * Toast component\n */\nexport const Toast: ForwardRefComponent<ToastProps> = React.forwardRef((props, ref) => {\n const state = useToast_unstable(props, ref);\n\n useToastStyles_unstable(state);\n useCustomStyleHook_unstable('useToastStyles_unstable')(state);\n\n return renderToast_unstable(state, useToastContextValues_unstable(state));\n});\n\nToast.displayName = 'Toast';\n"],"names":["React","useToast_unstable","renderToast_unstable","useToastStyles_unstable","useToastContextValues_unstable","useCustomStyleHook_unstable","Toast","forwardRef","props","ref","state","displayName"],"mappings":";;;;+BAYaM;;;;;;;iEAZU,QAAQ;0BACG,aAAa;6BACV,gBAAgB;sCACb,0BAA0B;uCAGnB,0BAA0B;qCAC7B,kCAAkC;AAKvE,cAAMA,WAAAA,GAAyCN,OAAMO,UAAU,CAAC,CAACC,OAAOC;IAC7E,MAAMC,YAAQT,2BAAAA,EAAkBO,OAAOC;QAEvCN,6CAAAA,EAAwBO;QACxBL,gDAAAA,EAA4B,2BAA2BK;IAEvD,WAAOR,iCAAAA,EAAqBQ,WAAON,qDAAAA,EAA+BM;AACpE,GAAG;AAEHJ,MAAMK,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Toast/Toast.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { BackgroundAppearanceContextValue } from '@fluentui/react-shared-contexts';\nimport type { ToastIntent } from '../../state/types';\n\nexport type ToastSlots = {\n root: Slot<'div'>;\n};\n\nexport type ToastContextValues = {\n backgroundAppearance: BackgroundAppearanceContextValue;\n};\n\n/**\n * Toast Props\n */\nexport type ToastProps = ComponentProps<ToastSlots> & {\n appearance?: BackgroundAppearanceContextValue;\n};\n\n/**\n * State used in rendering Toast\n */\nexport type ToastState = ComponentState<ToastSlots> & {\n backgroundAppearance: BackgroundAppearanceContextValue;\n intent?: ToastIntent | undefined;\n};\n"],"names":[],"
|
|
1
|
+
{"version":3,"sources":["../src/components/Toast/Toast.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { BackgroundAppearanceContextValue } from '@fluentui/react-shared-contexts';\nimport type { ToastIntent } from '../../state/types';\n\nexport type ToastSlots = {\n root: Slot<'div'>;\n};\n\nexport type ToastContextValues = {\n backgroundAppearance: BackgroundAppearanceContextValue;\n};\n\n/**\n * Toast Props\n */\nexport type ToastProps = ComponentProps<ToastSlots> & {\n appearance?: BackgroundAppearanceContextValue;\n};\n\n/**\n * State used in rendering Toast\n */\nexport type ToastState = ComponentState<ToastSlots> & {\n backgroundAppearance: BackgroundAppearanceContextValue;\n intent?: ToastIntent | undefined;\n};\n"],"names":[],"mappings":"AAmBA;;CAEC,GACD,WAGE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Toast/index.ts"],"sourcesContent":["export { Toast } from './Toast';\nexport type { ToastContextValues, ToastProps, ToastSlots, ToastState } from './Toast.types';\nexport { renderToast_unstable } from './renderToast';\nexport { useToast_unstable } from './useToast';\nexport { toastClassNames, useToastStyles_unstable } from './useToastStyles.styles';\n"],"names":["Toast","renderToast_unstable","
|
|
1
|
+
{"version":3,"sources":["../src/components/Toast/index.ts"],"sourcesContent":["export { Toast } from './Toast';\nexport type { ToastContextValues, ToastProps, ToastSlots, ToastState } from './Toast.types';\nexport { renderToast_unstable } from './renderToast';\nexport { useToast_unstable } from './useToast';\nexport { toastClassNames, useToastStyles_unstable } from './useToastStyles.styles';\n"],"names":["Toast","renderToast_unstable","useToast_unstable","toastClassNames","useToastStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,YAAK;;;eAELC,iCAAoB;;;eAEpBE,qCAAe;;;eAAEC,6CAAuB;;;eADxCF,2BAAiB;;;uBAHJ,UAAU;6BAEK,gBAAgB;0BACnB,aAAa;sCACU,0BAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Toast/renderToast.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport { BackgroundAppearanceProvider } from '@fluentui/react-shared-contexts';\nimport type { ToastState, ToastSlots, ToastContextValues } from './Toast.types';\n\n/**\n * Render the final JSX of Toast\n */\nexport const renderToast_unstable = (state: ToastState, contextValues: ToastContextValues) => {\n assertSlots<ToastSlots>(state);\n\n return (\n <BackgroundAppearanceProvider value={contextValues.backgroundAppearance}>\n <state.root />\n </BackgroundAppearanceProvider>\n );\n};\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/components/Toast/renderToast.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport { BackgroundAppearanceProvider } from '@fluentui/react-shared-contexts';\nimport type { ToastState, ToastSlots, ToastContextValues } from './Toast.types';\n\n/**\n * Render the final JSX of Toast\n */\nexport const renderToast_unstable = (state: ToastState, contextValues: ToastContextValues) => {\n assertSlots<ToastSlots>(state);\n\n return (\n <BackgroundAppearanceProvider value={contextValues.backgroundAppearance}>\n <state.root />\n </BackgroundAppearanceProvider>\n );\n};\n"],"names":["assertSlots","BackgroundAppearanceProvider","renderToast_unstable","state","contextValues","value","backgroundAppearance","root"],"mappings":";;;;+BASaE;;;;;;4BARb,gDAAiD;gCACrB,4BAA4B;qCACX,kCAAkC;AAMxE,6BAA6B,CAACC,OAAmBC;QACtDJ,2BAAAA,EAAwBG;IAExB,OAAA,WAAA,OACE,eAAA,EAACF,iDAAAA,EAAAA;QAA6BI,OAAOD,cAAcE,oBAAoB;kBACrE,WAAA,OAAA,eAAA,EAACH,MAAMI,IAAI,EAAA,CAAA;;AAGjB,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Toast/useToast.ts"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';\nimport type { ToastProps, ToastState } from './Toast.types';\nimport { useToastContainerContext } from '../../contexts/toastContainerContext';\n\n/**\n * Create the state required to render Toast.\n *\n * The returned state can be modified with hooks such as useToastStyles_unstable,\n * before being passed to renderToast_unstable.\n *\n * @param props - props from this instance of Toast\n * @param ref - reference to root HTMLElement of Toast\n */\nexport const useToast_unstable = (props: ToastProps, ref: React.Ref<HTMLElement>): ToastState => {\n const { intent } = useToastContainerContext();\n\n return {\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: ref as React.Ref<HTMLDivElement>,\n ...props,\n }),\n { elementType: 'div' },\n ),\n backgroundAppearance: props.appearance,\n intent,\n };\n};\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/components/Toast/useToast.ts"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';\nimport type { ToastProps, ToastState } from './Toast.types';\nimport { useToastContainerContext } from '../../contexts/toastContainerContext';\n\n/**\n * Create the state required to render Toast.\n *\n * The returned state can be modified with hooks such as useToastStyles_unstable,\n * before being passed to renderToast_unstable.\n *\n * @param props - props from this instance of Toast\n * @param ref - reference to root HTMLElement of Toast\n */\nexport const useToast_unstable = (props: ToastProps, ref: React.Ref<HTMLElement>): ToastState => {\n const { intent } = useToastContainerContext();\n\n return {\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: ref as React.Ref<HTMLDivElement>,\n ...props,\n }),\n { elementType: 'div' },\n ),\n backgroundAppearance: props.appearance,\n intent,\n };\n};\n"],"names":["React","getIntrinsicElementProps","slot","useToastContainerContext","useToast_unstable","props","ref","intent","components","root","always","elementType","backgroundAppearance","appearance"],"mappings":";;;;+BAcaI;;;;;;;iEAdU,QAAQ;gCACgB,4BAA4B;uCAElC,uCAAuC;AAWzE,0BAA0B,CAACC,OAAmBC;IACnD,MAAM,EAAEC,MAAM,EAAE,OAAGJ,+CAAAA;IAEnB,OAAO;QACLK,YAAY;YACVC,MAAM;QACR;QACAA,MAAMP,oBAAAA,CAAKQ,MAAM,KACfT,wCAAAA,EAAyB,OAAO;YAC9B,SAAS;YACT,4EAA4E;YAC5E,4FAA4F;YAC5FK,KAAKA;YACL,GAAGD,KAAK;QACV,IACA;YAAEM,aAAa;QAAM;QAEvBC,sBAAsBP,MAAMQ,UAAU;QACtCN;IACF;AACF,EAAE"}
|