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