@fluentui/react-toast 9.6.3 → 9.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,49 @@
1
1
  # Change Log - @fluentui/react-toast
2
2
 
3
- This log was last generated on Wed, 30 Jul 2025 16:53:00 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 21 Aug 2025 12:20:27 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.7.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-toast_v9.7.0)
8
+
9
+ Thu, 21 Aug 2025 12:20:27 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-toast_v9.6.4..@fluentui/react-toast_v9.7.0)
11
+
12
+ ### Minor changes
13
+
14
+ - feat: Export ToastContainer state and classNames nessecary for style overrides ([PR #35007](https://github.com/microsoft/fluentui/pull/35007) by mifraser@microsoft.com)
15
+ - Bump @fluentui/react-aria to v9.16.4 ([PR #35055](https://github.com/microsoft/fluentui/pull/35055) by beachball)
16
+ - Bump @fluentui/react-jsx-runtime to v9.1.6 ([PR #35055](https://github.com/microsoft/fluentui/pull/35055) by beachball)
17
+ - Bump @fluentui/react-motion to v9.10.3 ([PR #35055](https://github.com/microsoft/fluentui/pull/35055) by beachball)
18
+ - Bump @fluentui/react-motion-components-preview to v0.9.0 ([PR #35055](https://github.com/microsoft/fluentui/pull/35055) by beachball)
19
+ - Bump @fluentui/react-portal to v9.8.1 ([PR #35055](https://github.com/microsoft/fluentui/pull/35055) by beachball)
20
+ - Bump @fluentui/react-shared-contexts to v9.25.0 ([PR #35055](https://github.com/microsoft/fluentui/pull/35055) by beachball)
21
+ - Bump @fluentui/react-tabster to v9.26.4 ([PR #35055](https://github.com/microsoft/fluentui/pull/35055) by beachball)
22
+ - Bump @fluentui/react-utilities to v9.24.0 ([PR #35055](https://github.com/microsoft/fluentui/pull/35055) by beachball)
23
+
24
+ ### Patches
25
+
26
+ - fix: replace deprecated element.ref usages to support react 19 ([PR #35030](https://github.com/microsoft/fluentui/pull/35030) by dmytrokirpa@microsoft.com)
27
+
28
+ ## [9.6.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-toast_v9.6.4)
29
+
30
+ Thu, 07 Aug 2025 10:03:29 GMT
31
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-toast_v9.6.3..@fluentui/react-toast_v9.6.4)
32
+
33
+ ### Patches
34
+
35
+ - fix: Toaster should merge user onKeyDown handler ([PR #34982](https://github.com/microsoft/fluentui/pull/34982) by lingfangao@hotmail.com)
36
+ - Bump @fluentui/react-aria to v9.16.3 ([PR #34980](https://github.com/microsoft/fluentui/pull/34980) by beachball)
37
+ - Bump @fluentui/react-jsx-runtime to v9.1.5 ([PR #34980](https://github.com/microsoft/fluentui/pull/34980) by beachball)
38
+ - Bump @fluentui/react-motion to v9.10.2 ([PR #34980](https://github.com/microsoft/fluentui/pull/34980) by beachball)
39
+ - Bump @fluentui/react-motion-components-preview to v0.8.2 ([PR #34980](https://github.com/microsoft/fluentui/pull/34980) by beachball)
40
+ - Bump @fluentui/react-portal to v9.8.0 ([PR #34980](https://github.com/microsoft/fluentui/pull/34980) by beachball)
41
+ - Bump @fluentui/react-tabster to v9.26.3 ([PR #34980](https://github.com/microsoft/fluentui/pull/34980) by beachball)
42
+ - Bump @fluentui/react-utilities to v9.23.2 ([PR #34980](https://github.com/microsoft/fluentui/pull/34980) by beachball)
43
+
7
44
  ## [9.6.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-toast_v9.6.3)
8
45
 
9
- Wed, 30 Jul 2025 16:53:00 GMT
46
+ Wed, 30 Jul 2025 16:55:39 GMT
10
47
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-toast_v9.6.2..@fluentui/react-toast_v9.6.3)
11
48
 
12
49
  ### Patches
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- /// <reference types="react" />
2
-
3
1
  import { ARIAButtonResultProps } from '@fluentui/react-aria';
4
2
  import { ARIAButtonType } from '@fluentui/react-aria';
5
3
  import { BackgroundAppearanceContextValue } from '@fluentui/react-shared-contexts';
@@ -77,6 +75,13 @@ export declare const renderToastTrigger_unstable: (state: ToastTriggerState) =>
77
75
 
78
76
  declare type RootSlot = Slot<'div'>;
79
77
 
78
+ declare type TimerProps = {
79
+ running: boolean;
80
+ timeout: number;
81
+ onTimeout: () => void;
82
+ as?: 'span';
83
+ };
84
+
80
85
  /**
81
86
  * Toast component
82
87
  */
@@ -135,6 +140,8 @@ declare type ToastChangeHandler = (event: null, data: ToastChangeData) => void;
135
140
 
136
141
  export declare const toastClassNames: SlotClassNames<ToastSlots>;
137
142
 
143
+ export declare const toastContainerClassNames: SlotClassNames<ToastContainerSlots>;
144
+
138
145
  declare type ToastContainerContextValue = {
139
146
  close: () => void;
140
147
  intent: ToastIntent | undefined;
@@ -142,6 +149,44 @@ declare type ToastContainerContextValue = {
142
149
  titleId: string;
143
150
  };
144
151
 
152
+ /**
153
+ * ToastContainer Props
154
+ */
155
+ declare type ToastContainerProps = Omit<ComponentProps<Partial<ToastContainerSlots>>, 'content'> & Toast_2 & {
156
+ visible: boolean;
157
+ announce: Announce;
158
+ intent: ToastIntent | undefined;
159
+ tryRestoreFocus: () => void;
160
+ };
161
+
162
+ declare type ToastContainerSlots = {
163
+ root: NonNullable<Slot<'div'>>;
164
+ timer: NonNullable<Slot<TimerProps>>;
165
+ };
166
+
167
+ /**
168
+ * State used in rendering ToastContainer
169
+ */
170
+ export declare type ToastContainerState = ComponentState<ToastContainerSlots> & Pick<ToastContainerProps, 'remove' | 'close' | 'updateId' | 'visible' | 'intent'> & Pick<ToastContainerContextValue, 'titleId' | 'bodyId'> & {
171
+ /**
172
+ * @deprecated Will be always "0".
173
+ */
174
+ transitionTimeout: number;
175
+ timerTimeout: number;
176
+ running: boolean;
177
+ /**
178
+ * @deprecated Will be always no-op.
179
+ */
180
+ onTransitionEntering: () => void;
181
+ /**
182
+ * @deprecated now merged with root ref
183
+ */
184
+ nodeRef: React_2.Ref<HTMLDivElement>;
185
+ onMotionFinish?: (event: null, data: {
186
+ direction: 'enter' | 'exit';
187
+ }) => void;
188
+ };
189
+
145
190
  declare type ToastContextValues = {
146
191
  backgroundAppearance: BackgroundAppearanceContextValue;
147
192
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/ToastContainer/ToastContainer.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { Announce } from '../AriaLive/AriaLive.types';\nimport { Toast, ToastIntent } from '../../state';\nimport { ToastContainerContextValue } from '../../contexts/toastContainerContext';\nimport { TimerProps } from '../Timer/Timer';\n\nexport type ToastContainerContextValues = {\n toast: ToastContainerContextValue;\n};\n\nexport type ToastContainerSlots = {\n root: NonNullable<Slot<'div'>>;\n timer: NonNullable<Slot<TimerProps>>;\n};\n\n/**\n * ToastContainer Props\n */\nexport type ToastContainerProps = Omit<ComponentProps<Partial<ToastContainerSlots>>, 'content'> &\n Toast & {\n visible: boolean;\n announce: Announce;\n intent: ToastIntent | undefined;\n tryRestoreFocus: () => void;\n };\n\n/**\n * State used in rendering ToastContainer\n */\nexport type ToastContainerState = ComponentState<ToastContainerSlots> &\n Pick<ToastContainerProps, 'remove' | 'close' | 'updateId' | 'visible' | 'intent'> &\n Pick<ToastContainerContextValue, 'titleId' | 'bodyId'> & {\n /**\n * @deprecated Will be always \"0\".\n */\n transitionTimeout: number;\n timerTimeout: number;\n running: boolean;\n /**\n * @deprecated Will be always no-op.\n */\n onTransitionEntering: () => void;\n /**\n * @deprecated\n */\n nodeRef: React.Ref<HTMLDivElement>;\n\n onMotionFinish?: (event: null, data: { direction: 'enter' | 'exit' }) => void;\n };\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
1
+ {"version":3,"sources":["../src/components/ToastContainer/ToastContainer.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { Announce } from '../AriaLive/AriaLive.types';\nimport { Toast, ToastIntent } from '../../state';\nimport { ToastContainerContextValue } from '../../contexts/toastContainerContext';\nimport { TimerProps } from '../Timer/Timer';\n\nexport type ToastContainerContextValues = {\n toast: ToastContainerContextValue;\n};\n\nexport type ToastContainerSlots = {\n root: NonNullable<Slot<'div'>>;\n timer: NonNullable<Slot<TimerProps>>;\n};\n\n/**\n * ToastContainer Props\n */\nexport type ToastContainerProps = Omit<ComponentProps<Partial<ToastContainerSlots>>, 'content'> &\n Toast & {\n visible: boolean;\n announce: Announce;\n intent: ToastIntent | undefined;\n tryRestoreFocus: () => void;\n };\n\n/**\n * State used in rendering ToastContainer\n */\nexport type ToastContainerState = ComponentState<ToastContainerSlots> &\n Pick<ToastContainerProps, 'remove' | 'close' | 'updateId' | 'visible' | 'intent'> &\n Pick<ToastContainerContextValue, 'titleId' | 'bodyId'> & {\n /**\n * @deprecated Will be always \"0\".\n */\n transitionTimeout: number;\n timerTimeout: number;\n running: boolean;\n /**\n * @deprecated Will be always no-op.\n */\n onTransitionEntering: () => void;\n /**\n * @deprecated now merged with root ref\n */\n nodeRef: React.Ref<HTMLDivElement>;\n\n onMotionFinish?: (event: null, data: { direction: 'enter' | 'exit' }) => void;\n };\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { applyTriggerPropsToChildren, getTriggerChild, useEventCallback } from '@fluentui/react-utilities';
2
+ import { applyTriggerPropsToChildren, getTriggerChild, getReactElementRef, useEventCallback } from '@fluentui/react-utilities';
3
3
  import { useARIAButtonProps } from '@fluentui/react-aria';
4
4
  import { useToastContainerContext } from '../../contexts/toastContainerContext';
5
5
  /**
@@ -23,7 +23,7 @@ import { useToastContainerContext } from '../../contexts/toastContainerContext';
23
23
  });
24
24
  const triggerChildProps = {
25
25
  ...child === null || child === void 0 ? void 0 : child.props,
26
- ref: child === null || child === void 0 ? void 0 : child.ref,
26
+ ref: getReactElementRef(child),
27
27
  onClick: handleClick
28
28
  };
29
29
  const ariaButtonTriggerChildProps = useARIAButtonProps((child === null || child === void 0 ? void 0 : child.type) === 'button' || (child === null || child === void 0 ? void 0 : child.type) === 'a' ? child.type : 'div', {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/ToastTrigger/useToastTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport { applyTriggerPropsToChildren, getTriggerChild, useEventCallback } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\nimport type { ToastTriggerProps, ToastTriggerState } from './ToastTrigger.types';\nimport { useToastContainerContext } from '../../contexts/toastContainerContext';\n\n/**\n * A non-visual component that wraps its child\n * and configures them to be the trigger that will close a `Toast`.\n * This component should only accept one child.\n *\n * This component sole purpose is to avoid opting out of the internal controlled open state of a `Toast`\n * Besides being a trigger that closes a toast through context this component doesn't do much,\n * making it basically unnecessary in cases where the trigger is outside of a toast.\n */\nexport const useToastTrigger_unstable = (props: ToastTriggerProps): ToastTriggerState => {\n const { children, disableButtonEnhancement = false } = props;\n const { close } = useToastContainerContext();\n\n const child = getTriggerChild(children);\n\n const handleClick = useEventCallback(\n (e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n child?.props.onClick?.(e);\n if (!e.isDefaultPrevented()) {\n close();\n }\n },\n );\n\n const triggerChildProps = {\n ...child?.props,\n ref: child?.ref,\n onClick: handleClick,\n };\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n {\n ...triggerChildProps,\n type: 'button',\n },\n );\n\n return {\n children: applyTriggerPropsToChildren(\n children,\n disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n };\n};\n"],"names":["React","applyTriggerPropsToChildren","getTriggerChild","useEventCallback","useARIAButtonProps","useToastContainerContext","useToastTrigger_unstable","props","children","disableButtonEnhancement","close","child","handleClick","e","onClick","isDefaultPrevented","triggerChildProps","ref","ariaButtonTriggerChildProps","type"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,2BAA2B,EAAEC,eAAe,EAAEC,gBAAgB,QAAQ,4BAA4B;AAC3G,SAASC,kBAAkB,QAAQ,uBAAuB;AAE1D,SAASC,wBAAwB,QAAQ,uCAAuC;AAEhF;;;;;;;;CAQC,GACD,OAAO,MAAMC,2BAA2B,CAACC;IACvC,MAAM,EAAEC,QAAQ,EAAEC,2BAA2B,KAAK,EAAE,GAAGF;IACvD,MAAM,EAAEG,KAAK,EAAE,GAAGL;IAElB,MAAMM,QAAQT,gBAAgBM;IAE9B,MAAMI,cAAcT,iBAClB,CAACU;YACCF,sBAAAA;QAAAA,kBAAAA,6BAAAA,uBAAAA,CAAAA,eAAAA,MAAOJ,KAAK,EAACO,OAAO,cAApBH,2CAAAA,0BAAAA,cAAuBE;QACvB,IAAI,CAACA,EAAEE,kBAAkB,IAAI;YAC3BL;QACF;IACF;IAGF,MAAMM,oBAAoB;WACrBL,kBAAAA,4BAAAA,MAAOJ,KAAK,AAAf;QACAU,GAAG,EAAEN,kBAAAA,4BAAAA,MAAOM,GAAG;QACfH,SAASF;IACX;IAEA,MAAMM,8BAA8Bd,mBAClCO,CAAAA,kBAAAA,4BAAAA,MAAOQ,IAAI,MAAK,YAAYR,CAAAA,kBAAAA,4BAAAA,MAAOQ,IAAI,MAAK,MAAMR,MAAMQ,IAAI,GAAG,OAC/D;QACE,GAAGH,iBAAiB;QACpBG,MAAM;IACR;IAGF,OAAO;QACLX,UAAUP,4BACRO,UACAC,2BAA2BO,oBAAoBE;IAEnD;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/ToastTrigger/useToastTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n applyTriggerPropsToChildren,\n getTriggerChild,\n getReactElementRef,\n useEventCallback,\n} from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\nimport type { ToastTriggerProps, ToastTriggerState } from './ToastTrigger.types';\nimport { useToastContainerContext } from '../../contexts/toastContainerContext';\n\n/**\n * A non-visual component that wraps its child\n * and configures them to be the trigger that will close a `Toast`.\n * This component should only accept one child.\n *\n * This component sole purpose is to avoid opting out of the internal controlled open state of a `Toast`\n * Besides being a trigger that closes a toast through context this component doesn't do much,\n * making it basically unnecessary in cases where the trigger is outside of a toast.\n */\nexport const useToastTrigger_unstable = (props: ToastTriggerProps): ToastTriggerState => {\n const { children, disableButtonEnhancement = false } = props;\n const { close } = useToastContainerContext();\n\n const child = getTriggerChild(children);\n\n const handleClick = useEventCallback(\n (e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n child?.props.onClick?.(e);\n if (!e.isDefaultPrevented()) {\n close();\n }\n },\n );\n\n const triggerChildProps = {\n ...child?.props,\n ref: getReactElementRef<HTMLButtonElement>(child),\n onClick: handleClick,\n };\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n {\n ...triggerChildProps,\n type: 'button',\n },\n );\n\n return {\n children: applyTriggerPropsToChildren(\n children,\n disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n };\n};\n"],"names":["React","applyTriggerPropsToChildren","getTriggerChild","getReactElementRef","useEventCallback","useARIAButtonProps","useToastContainerContext","useToastTrigger_unstable","props","children","disableButtonEnhancement","close","child","handleClick","e","onClick","isDefaultPrevented","triggerChildProps","ref","ariaButtonTriggerChildProps","type"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,2BAA2B,EAC3BC,eAAe,EACfC,kBAAkB,EAClBC,gBAAgB,QACX,4BAA4B;AACnC,SAASC,kBAAkB,QAAQ,uBAAuB;AAE1D,SAASC,wBAAwB,QAAQ,uCAAuC;AAEhF;;;;;;;;CAQC,GACD,OAAO,MAAMC,2BAA2B,CAACC;IACvC,MAAM,EAAEC,QAAQ,EAAEC,2BAA2B,KAAK,EAAE,GAAGF;IACvD,MAAM,EAAEG,KAAK,EAAE,GAAGL;IAElB,MAAMM,QAAQV,gBAAgBO;IAE9B,MAAMI,cAAcT,iBAClB,CAACU;YACCF,sBAAAA;QAAAA,kBAAAA,6BAAAA,uBAAAA,CAAAA,eAAAA,MAAOJ,KAAK,EAACO,OAAO,cAApBH,2CAAAA,0BAAAA,cAAuBE;QACvB,IAAI,CAACA,EAAEE,kBAAkB,IAAI;YAC3BL;QACF;IACF;IAGF,MAAMM,oBAAoB;WACrBL,kBAAAA,4BAAAA,MAAOJ,KAAK,AAAf;QACAU,KAAKf,mBAAsCS;QAC3CG,SAASF;IACX;IAEA,MAAMM,8BAA8Bd,mBAClCO,CAAAA,kBAAAA,4BAAAA,MAAOQ,IAAI,MAAK,YAAYR,CAAAA,kBAAAA,4BAAAA,MAAOQ,IAAI,MAAK,MAAMR,MAAMQ,IAAI,GAAG,OAC/D;QACE,GAAGH,iBAAiB;QACpBG,MAAM;IACR;IAGF,OAAO;QACLX,UAAUR,4BACRQ,UACAC,2BAA2BO,oBAAoBE;IAEnD;AACF,EAAE"}
@@ -18,7 +18,7 @@ import { useToastAnnounce } from './useToastAnnounce';
18
18
  const { toastsToRender, isToastVisible, pauseAllToasts, playAllToasts, tryRestoreFocus, closeAllToasts } = useToaster(rest);
19
19
  const announce = React.useCallback((message, options)=>announceRef.current(message, options), []);
20
20
  const { dir } = useFluent();
21
- const rootProps = slot.always(getIntrinsicElementProps('div', rest), {
21
+ const { onKeyDown: onKeyDownProp, ...rootProps } = slot.always(getIntrinsicElementProps('div', rest), {
22
22
  elementType: 'div'
23
23
  });
24
24
  const focusableGroupAttr = useFocusableGroup({
@@ -28,12 +28,11 @@ import { useToastAnnounce } from './useToastAnnounce';
28
28
  }
29
29
  });
30
30
  const onKeyDown = useEventCallback((e)=>{
31
- var _props_onKeyDown;
32
31
  if (e.key === Escape) {
33
32
  e.preventDefault();
34
33
  closeAllToasts();
35
34
  }
36
- (_props_onKeyDown = props.onKeyDown) === null || _props_onKeyDown === void 0 ? void 0 : _props_onKeyDown.call(props, e);
35
+ onKeyDownProp === null || onKeyDownProp === void 0 ? void 0 : onKeyDownProp(e);
37
36
  });
38
37
  const usePositionSlot = (toastPosition)=>{
39
38
  var _toastsToRender_get;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Toaster/useToaster.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n ExtractSlotProps,\n Slot,\n getIntrinsicElementProps,\n useEventCallback,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\nimport { Escape } from '@fluentui/keyboard-keys';\nimport type { ToasterProps, ToasterState } from './Toaster.types';\nimport { TOAST_POSITIONS, ToastPosition, useToaster } from '../../state';\nimport { Announce } from '../AriaLive';\nimport { ToastContainer } from '../ToastContainer';\nimport { useToasterFocusManagement_unstable } from './useToasterFocusManagement';\nimport { useToastAnnounce } from './useToastAnnounce';\n\n/**\n * Create the state required to render Toaster.\n *\n * @param props - props from this instance of Toaster\n */\nexport const useToaster_unstable = (props: ToasterProps): ToasterState => {\n 'use no memo';\n\n const { offset, announce: announceProp, mountNode, inline = false, ...rest } = props;\n const announceRef = React.useRef<Announce>(() => null);\n const { toastsToRender, isToastVisible, pauseAllToasts, playAllToasts, tryRestoreFocus, closeAllToasts } =\n useToaster<HTMLDivElement>(rest);\n const announce = React.useCallback<Announce>((message, options) => announceRef.current(message, options), []);\n const { dir } = useFluent();\n\n const rootProps = slot.always(getIntrinsicElementProps<ExtractSlotProps<Slot<'div'>>>('div', rest), {\n elementType: 'div',\n });\n const focusableGroupAttr = useFocusableGroup({\n tabBehavior: 'limited-trap-focus',\n ignoreDefaultKeydown: { Escape: true },\n });\n const onKeyDown = useEventCallback((e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key === Escape) {\n e.preventDefault();\n closeAllToasts();\n }\n props.onKeyDown?.(e);\n });\n const usePositionSlot = (toastPosition: ToastPosition) => {\n const focusManagementRef = useToasterFocusManagement_unstable(pauseAllToasts, playAllToasts);\n const { announceToast, toasterRef } = useToastAnnounce(announceProp ?? announce);\n return slot.optional<ExtractSlotProps<Slot<'div'>>>(toastsToRender.has(toastPosition) ? rootProps : null, {\n defaultProps: {\n ref: useMergedRefs(focusManagementRef, toasterRef),\n children: toastsToRender.get(toastPosition)?.map(toast => (\n <ToastContainer\n {...toast}\n tryRestoreFocus={tryRestoreFocus}\n intent={toast.intent}\n announce={announceToast}\n key={toast.toastId}\n visible={isToastVisible(toast.toastId)}\n >\n {toast.content as React.ReactNode}\n </ToastContainer>\n )),\n onKeyDown,\n ...focusableGroupAttr,\n 'data-toaster-position': toastPosition,\n role: 'list',\n // Explicitly casting because our slot types can't handle data attributes\n } as ExtractSlotProps<Slot<'div'>>,\n elementType: 'div',\n });\n };\n\n return {\n dir,\n mountNode,\n components: {\n root: 'div',\n bottomStart: 'div',\n bottomEnd: 'div',\n topStart: 'div',\n topEnd: 'div',\n top: 'div',\n bottom: 'div',\n },\n root: slot.always(rootProps, { elementType: 'div' }),\n bottomStart: usePositionSlot(TOAST_POSITIONS.bottomStart),\n bottomEnd: usePositionSlot(TOAST_POSITIONS.bottomEnd),\n topStart: usePositionSlot(TOAST_POSITIONS.topStart),\n topEnd: usePositionSlot(TOAST_POSITIONS.topEnd),\n top: usePositionSlot(TOAST_POSITIONS.top),\n bottom: usePositionSlot(TOAST_POSITIONS.bottom),\n announceRef,\n offset,\n announce: announceProp ?? announce,\n renderAriaLive: !announceProp,\n inline,\n };\n};\n"],"names":["React","getIntrinsicElementProps","useEventCallback","useMergedRefs","slot","useFluent_unstable","useFluent","useFocusableGroup","Escape","TOAST_POSITIONS","useToaster","ToastContainer","useToasterFocusManagement_unstable","useToastAnnounce","useToaster_unstable","props","offset","announce","announceProp","mountNode","inline","rest","announceRef","useRef","toastsToRender","isToastVisible","pauseAllToasts","playAllToasts","tryRestoreFocus","closeAllToasts","useCallback","message","options","current","dir","rootProps","always","elementType","focusableGroupAttr","tabBehavior","ignoreDefaultKeydown","onKeyDown","e","key","preventDefault","usePositionSlot","toastPosition","focusManagementRef","announceToast","toasterRef","optional","has","defaultProps","ref","children","get","map","toast","intent","toastId","visible","content","role","components","root","bottomStart","bottomEnd","topStart","topEnd","top","bottom","renderAriaLive"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAGEC,wBAAwB,EACxBC,gBAAgB,EAChBC,aAAa,EACbC,IAAI,QACC,4BAA4B;AACnC,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,MAAM,QAAQ,0BAA0B;AAEjD,SAASC,eAAe,EAAiBC,UAAU,QAAQ,cAAc;AAEzE,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,kCAAkC,QAAQ,8BAA8B;AACjF,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD;;;;CAIC,GACD,OAAO,MAAMC,sBAAsB,CAACC;IAClC;IAEA,MAAM,EAAEC,MAAM,EAAEC,UAAUC,YAAY,EAAEC,SAAS,EAAEC,SAAS,KAAK,EAAE,GAAGC,MAAM,GAAGN;IAC/E,MAAMO,cAActB,MAAMuB,MAAM,CAAW,IAAM;IACjD,MAAM,EAAEC,cAAc,EAAEC,cAAc,EAAEC,cAAc,EAAEC,aAAa,EAAEC,eAAe,EAAEC,cAAc,EAAE,GACtGnB,WAA2BW;IAC7B,MAAMJ,WAAWjB,MAAM8B,WAAW,CAAW,CAACC,SAASC,UAAYV,YAAYW,OAAO,CAACF,SAASC,UAAU,EAAE;IAC5G,MAAM,EAAEE,GAAG,EAAE,GAAG5B;IAEhB,MAAM6B,YAAY/B,KAAKgC,MAAM,CAACnC,yBAAwD,OAAOoB,OAAO;QAClGgB,aAAa;IACf;IACA,MAAMC,qBAAqB/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B,gBAAgBpC,gBAAgB0D,QAAQ;QAClDC,QAAQvB,gBAAgBpC,gBAAgB2D,MAAM;QAC9CC,KAAKxB,gBAAgBpC,gBAAgB4D,GAAG;QACxCC,QAAQzB,gBAAgBpC,gBAAgB6D,MAAM;QAC9ChD;QACAN;QACAC,UAAUC,yBAAAA,0BAAAA,eAAgBD;QAC1BsD,gBAAgB,CAACrD;QACjBE;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/Toaster/useToaster.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n ExtractSlotProps,\n Slot,\n getIntrinsicElementProps,\n useEventCallback,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\nimport { Escape } from '@fluentui/keyboard-keys';\nimport type { ToasterProps, ToasterState } from './Toaster.types';\nimport { TOAST_POSITIONS, ToastPosition, useToaster } from '../../state';\nimport { Announce } from '../AriaLive';\nimport { ToastContainer } from '../ToastContainer';\nimport { useToasterFocusManagement_unstable } from './useToasterFocusManagement';\nimport { useToastAnnounce } from './useToastAnnounce';\n\n/**\n * Create the state required to render Toaster.\n *\n * @param props - props from this instance of Toaster\n */\nexport const useToaster_unstable = (props: ToasterProps): ToasterState => {\n 'use no memo';\n\n const { offset, announce: announceProp, mountNode, inline = false, ...rest } = props;\n const announceRef = React.useRef<Announce>(() => null);\n const { toastsToRender, isToastVisible, pauseAllToasts, playAllToasts, tryRestoreFocus, closeAllToasts } =\n useToaster<HTMLDivElement>(rest);\n const announce = React.useCallback<Announce>((message, options) => announceRef.current(message, options), []);\n const { dir } = useFluent();\n\n const { onKeyDown: onKeyDownProp, ...rootProps } = slot.always(\n getIntrinsicElementProps<ExtractSlotProps<Slot<'div'>>>('div', rest),\n {\n elementType: 'div',\n },\n );\n const focusableGroupAttr = useFocusableGroup({\n tabBehavior: 'limited-trap-focus',\n ignoreDefaultKeydown: { Escape: true },\n });\n const onKeyDown = useEventCallback((e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key === Escape) {\n e.preventDefault();\n closeAllToasts();\n }\n onKeyDownProp?.(e);\n });\n const usePositionSlot = (toastPosition: ToastPosition) => {\n const focusManagementRef = useToasterFocusManagement_unstable(pauseAllToasts, playAllToasts);\n const { announceToast, toasterRef } = useToastAnnounce(announceProp ?? announce);\n return slot.optional<ExtractSlotProps<Slot<'div'>>>(toastsToRender.has(toastPosition) ? rootProps : null, {\n defaultProps: {\n ref: useMergedRefs(focusManagementRef, toasterRef),\n children: toastsToRender.get(toastPosition)?.map(toast => (\n <ToastContainer\n {...toast}\n tryRestoreFocus={tryRestoreFocus}\n intent={toast.intent}\n announce={announceToast}\n key={toast.toastId}\n visible={isToastVisible(toast.toastId)}\n >\n {toast.content as React.ReactNode}\n </ToastContainer>\n )),\n onKeyDown,\n ...focusableGroupAttr,\n 'data-toaster-position': toastPosition,\n role: 'list',\n // Explicitly casting because our slot types can't handle data attributes\n } as ExtractSlotProps<Slot<'div'>>,\n elementType: 'div',\n });\n };\n\n return {\n dir,\n mountNode,\n components: {\n root: 'div',\n bottomStart: 'div',\n bottomEnd: 'div',\n topStart: 'div',\n topEnd: 'div',\n top: 'div',\n bottom: 'div',\n },\n root: slot.always(rootProps, { elementType: 'div' }),\n bottomStart: usePositionSlot(TOAST_POSITIONS.bottomStart),\n bottomEnd: usePositionSlot(TOAST_POSITIONS.bottomEnd),\n topStart: usePositionSlot(TOAST_POSITIONS.topStart),\n topEnd: usePositionSlot(TOAST_POSITIONS.topEnd),\n top: usePositionSlot(TOAST_POSITIONS.top),\n bottom: usePositionSlot(TOAST_POSITIONS.bottom),\n announceRef,\n offset,\n announce: announceProp ?? announce,\n renderAriaLive: !announceProp,\n inline,\n };\n};\n"],"names":["React","getIntrinsicElementProps","useEventCallback","useMergedRefs","slot","useFluent_unstable","useFluent","useFocusableGroup","Escape","TOAST_POSITIONS","useToaster","ToastContainer","useToasterFocusManagement_unstable","useToastAnnounce","useToaster_unstable","props","offset","announce","announceProp","mountNode","inline","rest","announceRef","useRef","toastsToRender","isToastVisible","pauseAllToasts","playAllToasts","tryRestoreFocus","closeAllToasts","useCallback","message","options","current","dir","onKeyDown","onKeyDownProp","rootProps","always","elementType","focusableGroupAttr","tabBehavior","ignoreDefaultKeydown","e","key","preventDefault","usePositionSlot","toastPosition","focusManagementRef","announceToast","toasterRef","optional","has","defaultProps","ref","children","get","map","toast","intent","toastId","visible","content","role","components","root","bottomStart","bottomEnd","topStart","topEnd","top","bottom","renderAriaLive"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAGEC,wBAAwB,EACxBC,gBAAgB,EAChBC,aAAa,EACbC,IAAI,QACC,4BAA4B;AACnC,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,MAAM,QAAQ,0BAA0B;AAEjD,SAASC,eAAe,EAAiBC,UAAU,QAAQ,cAAc;AAEzE,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,kCAAkC,QAAQ,8BAA8B;AACjF,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD;;;;CAIC,GACD,OAAO,MAAMC,sBAAsB,CAACC;IAClC;IAEA,MAAM,EAAEC,MAAM,EAAEC,UAAUC,YAAY,EAAEC,SAAS,EAAEC,SAAS,KAAK,EAAE,GAAGC,MAAM,GAAGN;IAC/E,MAAMO,cAActB,MAAMuB,MAAM,CAAW,IAAM;IACjD,MAAM,EAAEC,cAAc,EAAEC,cAAc,EAAEC,cAAc,EAAEC,aAAa,EAAEC,eAAe,EAAEC,cAAc,EAAE,GACtGnB,WAA2BW;IAC7B,MAAMJ,WAAWjB,MAAM8B,WAAW,CAAW,CAACC,SAASC,UAAYV,YAAYW,OAAO,CAACF,SAASC,UAAU,EAAE;IAC5G,MAAM,EAAEE,GAAG,EAAE,GAAG5B;IAEhB,MAAM,EAAE6B,WAAWC,aAAa,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BAAgByD,WAAW;QACxDC,WAAWrB,gBAAgBrC,gBAAgB0D,SAAS;QACpDC,UAAUtB,gBAAgBrC,gBAAgB2D,QAAQ;QAClDC,QAAQvB,gBAAgBrC,gBAAgB4D,MAAM;QAC9CC,KAAKxB,gBAAgBrC,gBAAgB6D,GAAG;QACxCC,QAAQzB,gBAAgBrC,gBAAgB8D,MAAM;QAC9CjD;QACAN;QACAC,UAAUC,yBAAAA,0BAAAA,eAAgBD;QAC1BuD,gBAAgB,CAACtD;QACjBE;IACF;AACF,EAAE"}
package/lib/index.js CHANGED
@@ -5,3 +5,4 @@ export { Toast, useToastStyles_unstable, useToast_unstable, renderToast_unstable
5
5
  export { ToastTitle, useToastTitleStyles_unstable, useToastTitle_unstable, renderToastTitle_unstable, toastTitleClassNames } from './ToastTitle';
6
6
  export { ToastBody, useToastBodyStyles_unstable, useToastBody_unstable, renderToastBody_unstable, toastBodyClassNames } from './ToastBody';
7
7
  export { ToastFooter, useToastFooterStyles_unstable, useToastFooter_unstable, renderToastFooter_unstable, toastFooterClassNames } from './ToastFooter';
8
+ export { toastContainerClassNames } from './ToastContainer';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { useToastController } from './state';\nexport type { ToastPosition, ToastId, ToastOffset, ToastPoliteness, ToastStatus, ToastIntent } from './state';\n\nexport { ToastTrigger, useToastTrigger_unstable, renderToastTrigger_unstable } from './ToastTrigger';\nexport type { ToastTriggerChildProps, ToastTriggerProps, ToastTriggerState } from './ToastTrigger';\nexport {\n Toaster,\n useToaster_unstable,\n useToasterStyles_unstable,\n renderToaster_unstable,\n toasterClassNames,\n} from './Toaster';\nexport type { ToasterProps, ToasterState, ToasterSlots } from './Toaster';\nexport { Toast, useToastStyles_unstable, useToast_unstable, renderToast_unstable, toastClassNames } from './Toast';\nexport type { ToastProps, ToastState, ToastSlots } from './Toast';\n\nexport {\n ToastTitle,\n useToastTitleStyles_unstable,\n useToastTitle_unstable,\n renderToastTitle_unstable,\n toastTitleClassNames,\n} from './ToastTitle';\nexport type { ToastTitleProps, ToastTitleState, ToastTitleSlots } from './ToastTitle';\n\nexport {\n ToastBody,\n useToastBodyStyles_unstable,\n useToastBody_unstable,\n renderToastBody_unstable,\n toastBodyClassNames,\n} from './ToastBody';\nexport type { ToastBodyProps, ToastBodyState, ToastBodySlots } from './ToastBody';\n\nexport {\n ToastFooter,\n useToastFooterStyles_unstable,\n useToastFooter_unstable,\n renderToastFooter_unstable,\n toastFooterClassNames,\n} from './ToastFooter';\nexport type { ToastFooterProps, ToastFooterState, ToastFooterSlots } from './ToastFooter';\n"],"names":["useToastController","ToastTrigger","useToastTrigger_unstable","renderToastTrigger_unstable","Toaster","useToaster_unstable","useToasterStyles_unstable","renderToaster_unstable","toasterClassNames","Toast","useToastStyles_unstable","useToast_unstable","renderToast_unstable","toastClassNames","ToastTitle","useToastTitleStyles_unstable","useToastTitle_unstable","renderToastTitle_unstable","toastTitleClassNames","ToastBody","useToastBodyStyles_unstable","useToastBody_unstable","renderToastBody_unstable","toastBodyClassNames","ToastFooter","useToastFooterStyles_unstable","useToastFooter_unstable","renderToastFooter_unstable","toastFooterClassNames"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,UAAU;AAG7C,SAASC,YAAY,EAAEC,wBAAwB,EAAEC,2BAA2B,QAAQ,iBAAiB;AAErG,SACEC,OAAO,EACPC,mBAAmB,EACnBC,yBAAyB,EACzBC,sBAAsB,EACtBC,iBAAiB,QACZ,YAAY;AAEnB,SAASC,KAAK,EAAEC,uBAAuB,EAAEC,iBAAiB,EAAEC,oBAAoB,EAAEC,eAAe,QAAQ,UAAU;AAGnH,SACEC,UAAU,EACVC,4BAA4B,EAC5BC,sBAAsB,EACtBC,yBAAyB,EACzBC,oBAAoB,QACf,eAAe;AAGtB,SACEC,SAAS,EACTC,2BAA2B,EAC3BC,qBAAqB,EACrBC,wBAAwB,EACxBC,mBAAmB,QACd,cAAc;AAGrB,SACEC,WAAW,EACXC,6BAA6B,EAC7BC,uBAAuB,EACvBC,0BAA0B,EAC1BC,qBAAqB,QAChB,gBAAgB"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { useToastController } from './state';\nexport type { ToastPosition, ToastId, ToastOffset, ToastPoliteness, ToastStatus, ToastIntent } from './state';\n\nexport { ToastTrigger, useToastTrigger_unstable, renderToastTrigger_unstable } from './ToastTrigger';\nexport type { ToastTriggerChildProps, ToastTriggerProps, ToastTriggerState } from './ToastTrigger';\nexport {\n Toaster,\n useToaster_unstable,\n useToasterStyles_unstable,\n renderToaster_unstable,\n toasterClassNames,\n} from './Toaster';\nexport type { ToasterProps, ToasterState, ToasterSlots } from './Toaster';\nexport { Toast, useToastStyles_unstable, useToast_unstable, renderToast_unstable, toastClassNames } from './Toast';\nexport type { ToastProps, ToastState, ToastSlots } from './Toast';\n\nexport {\n ToastTitle,\n useToastTitleStyles_unstable,\n useToastTitle_unstable,\n renderToastTitle_unstable,\n toastTitleClassNames,\n} from './ToastTitle';\nexport type { ToastTitleProps, ToastTitleState, ToastTitleSlots } from './ToastTitle';\n\nexport {\n ToastBody,\n useToastBodyStyles_unstable,\n useToastBody_unstable,\n renderToastBody_unstable,\n toastBodyClassNames,\n} from './ToastBody';\nexport type { ToastBodyProps, ToastBodyState, ToastBodySlots } from './ToastBody';\n\nexport {\n ToastFooter,\n useToastFooterStyles_unstable,\n useToastFooter_unstable,\n renderToastFooter_unstable,\n toastFooterClassNames,\n} from './ToastFooter';\nexport type { ToastFooterProps, ToastFooterState, ToastFooterSlots } from './ToastFooter';\n\nexport { toastContainerClassNames } from './ToastContainer';\nexport type { ToastContainerState } from './ToastContainer';\n"],"names":["useToastController","ToastTrigger","useToastTrigger_unstable","renderToastTrigger_unstable","Toaster","useToaster_unstable","useToasterStyles_unstable","renderToaster_unstable","toasterClassNames","Toast","useToastStyles_unstable","useToast_unstable","renderToast_unstable","toastClassNames","ToastTitle","useToastTitleStyles_unstable","useToastTitle_unstable","renderToastTitle_unstable","toastTitleClassNames","ToastBody","useToastBodyStyles_unstable","useToastBody_unstable","renderToastBody_unstable","toastBodyClassNames","ToastFooter","useToastFooterStyles_unstable","useToastFooter_unstable","renderToastFooter_unstable","toastFooterClassNames","toastContainerClassNames"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,UAAU;AAG7C,SAASC,YAAY,EAAEC,wBAAwB,EAAEC,2BAA2B,QAAQ,iBAAiB;AAErG,SACEC,OAAO,EACPC,mBAAmB,EACnBC,yBAAyB,EACzBC,sBAAsB,EACtBC,iBAAiB,QACZ,YAAY;AAEnB,SAASC,KAAK,EAAEC,uBAAuB,EAAEC,iBAAiB,EAAEC,oBAAoB,EAAEC,eAAe,QAAQ,UAAU;AAGnH,SACEC,UAAU,EACVC,4BAA4B,EAC5BC,sBAAsB,EACtBC,yBAAyB,EACzBC,oBAAoB,QACf,eAAe;AAGtB,SACEC,SAAS,EACTC,2BAA2B,EAC3BC,qBAAqB,EACrBC,wBAAwB,EACxBC,mBAAmB,QACd,cAAc;AAGrB,SACEC,WAAW,EACXC,6BAA6B,EAC7BC,uBAAuB,EACvBC,0BAA0B,EAC1BC,qBAAqB,QAChB,gBAAgB;AAGvB,SAASC,wBAAwB,QAAQ,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/ToastContainer/ToastContainer.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { Announce } from '../AriaLive/AriaLive.types';\nimport { Toast, ToastIntent } from '../../state';\nimport { ToastContainerContextValue } from '../../contexts/toastContainerContext';\nimport { TimerProps } from '../Timer/Timer';\n\nexport type ToastContainerContextValues = {\n toast: ToastContainerContextValue;\n};\n\nexport type ToastContainerSlots = {\n root: NonNullable<Slot<'div'>>;\n timer: NonNullable<Slot<TimerProps>>;\n};\n\n/**\n * ToastContainer Props\n */\nexport type ToastContainerProps = Omit<ComponentProps<Partial<ToastContainerSlots>>, 'content'> &\n Toast & {\n visible: boolean;\n announce: Announce;\n intent: ToastIntent | undefined;\n tryRestoreFocus: () => void;\n };\n\n/**\n * State used in rendering ToastContainer\n */\nexport type ToastContainerState = ComponentState<ToastContainerSlots> &\n Pick<ToastContainerProps, 'remove' | 'close' | 'updateId' | 'visible' | 'intent'> &\n Pick<ToastContainerContextValue, 'titleId' | 'bodyId'> & {\n /**\n * @deprecated Will be always \"0\".\n */\n transitionTimeout: number;\n timerTimeout: number;\n running: boolean;\n /**\n * @deprecated Will be always no-op.\n */\n onTransitionEntering: () => void;\n /**\n * @deprecated\n */\n nodeRef: React.Ref<HTMLDivElement>;\n\n onMotionFinish?: (event: null, data: { direction: 'enter' | 'exit' }) => void;\n };\n"],"names":["React"],"mappings":";;;;;iEAAuB,QAAQ"}
1
+ {"version":3,"sources":["../src/components/ToastContainer/ToastContainer.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { Announce } from '../AriaLive/AriaLive.types';\nimport { Toast, ToastIntent } from '../../state';\nimport { ToastContainerContextValue } from '../../contexts/toastContainerContext';\nimport { TimerProps } from '../Timer/Timer';\n\nexport type ToastContainerContextValues = {\n toast: ToastContainerContextValue;\n};\n\nexport type ToastContainerSlots = {\n root: NonNullable<Slot<'div'>>;\n timer: NonNullable<Slot<TimerProps>>;\n};\n\n/**\n * ToastContainer Props\n */\nexport type ToastContainerProps = Omit<ComponentProps<Partial<ToastContainerSlots>>, 'content'> &\n Toast & {\n visible: boolean;\n announce: Announce;\n intent: ToastIntent | undefined;\n tryRestoreFocus: () => void;\n };\n\n/**\n * State used in rendering ToastContainer\n */\nexport type ToastContainerState = ComponentState<ToastContainerSlots> &\n Pick<ToastContainerProps, 'remove' | 'close' | 'updateId' | 'visible' | 'intent'> &\n Pick<ToastContainerContextValue, 'titleId' | 'bodyId'> & {\n /**\n * @deprecated Will be always \"0\".\n */\n transitionTimeout: number;\n timerTimeout: number;\n running: boolean;\n /**\n * @deprecated Will be always no-op.\n */\n onTransitionEntering: () => void;\n /**\n * @deprecated now merged with root ref\n */\n nodeRef: React.Ref<HTMLDivElement>;\n\n onMotionFinish?: (event: null, data: { direction: 'enter' | 'exit' }) => void;\n };\n"],"names":["React"],"mappings":";;;;;iEAAuB,QAAQ"}
@@ -26,7 +26,7 @@ const useToastTrigger_unstable = (props)=>{
26
26
  });
27
27
  const triggerChildProps = {
28
28
  ...child === null || child === void 0 ? void 0 : child.props,
29
- ref: child === null || child === void 0 ? void 0 : child.ref,
29
+ ref: (0, _reactutilities.getReactElementRef)(child),
30
30
  onClick: handleClick
31
31
  };
32
32
  const ariaButtonTriggerChildProps = (0, _reactaria.useARIAButtonProps)((child === null || child === void 0 ? void 0 : child.type) === 'button' || (child === null || child === void 0 ? void 0 : child.type) === 'a' ? child.type : 'div', {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/ToastTrigger/useToastTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport { applyTriggerPropsToChildren, getTriggerChild, useEventCallback } from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\nimport type { ToastTriggerProps, ToastTriggerState } from './ToastTrigger.types';\nimport { useToastContainerContext } from '../../contexts/toastContainerContext';\n\n/**\n * A non-visual component that wraps its child\n * and configures them to be the trigger that will close a `Toast`.\n * This component should only accept one child.\n *\n * This component sole purpose is to avoid opting out of the internal controlled open state of a `Toast`\n * Besides being a trigger that closes a toast through context this component doesn't do much,\n * making it basically unnecessary in cases where the trigger is outside of a toast.\n */\nexport const useToastTrigger_unstable = (props: ToastTriggerProps): ToastTriggerState => {\n const { children, disableButtonEnhancement = false } = props;\n const { close } = useToastContainerContext();\n\n const child = getTriggerChild(children);\n\n const handleClick = useEventCallback(\n (e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n child?.props.onClick?.(e);\n if (!e.isDefaultPrevented()) {\n close();\n }\n },\n );\n\n const triggerChildProps = {\n ...child?.props,\n ref: child?.ref,\n onClick: handleClick,\n };\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n {\n ...triggerChildProps,\n type: 'button',\n },\n );\n\n return {\n children: applyTriggerPropsToChildren(\n children,\n disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n };\n};\n"],"names":["React","applyTriggerPropsToChildren","getTriggerChild","useEventCallback","useARIAButtonProps","useToastContainerContext","useToastTrigger_unstable","props","children","disableButtonEnhancement","close","child","handleClick","e","onClick","isDefaultPrevented","triggerChildProps","ref","ariaButtonTriggerChildProps","type"],"mappings":";;;;+BAeaM;;;;;;;iEAfU,QAAQ;gCACgD,4BAA4B;2BACxE,uBAAuB;uCAEjB,uCAAuC;AAWzE,iCAAiC,CAACC;IACvC,MAAM,EAAEC,QAAQ,EAAEC,2BAA2B,KAAK,EAAE,GAAGF;IACvD,MAAM,EAAEG,KAAK,EAAE,OAAGL,+CAAAA;IAElB,MAAMM,YAAQT,+BAAAA,EAAgBM;IAE9B,MAAMI,kBAAcT,gCAAAA,EAClB,CAACU;YACCF,sBAAAA;QAAAA,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,wBAAAA,CAAAA,eAAAA,MAAOJ,KAAAA,AAAK,EAACO,OAAAA,AAAO,MAAA,QAApBH,yBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,qBAAAA,IAAAA,CAAAA,cAAuBE;QACvB,IAAI,CAACA,EAAEE,kBAAkB,IAAI;YAC3BL;QACF;IACF;IAGF,MAAMM,oBAAoB;WACrBL,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,MAAOJ,KAAV;QACAU,GAAG,EAAEN,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,MAAOM,GAAG;QACfH,SAASF;IACX;IAEA,MAAMM,kCAA8Bd,6BAAAA,EAClCO,CAAAA,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,MAAOQ,IAAAA,AAAI,MAAK,YAAYR,CAAAA,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,MAAOQ,IAAAA,AAAI,MAAK,MAAMR,MAAMQ,IAAI,GAAG,OAC/D;QACE,GAAGH,iBAAiB;QACpBG,MAAM;IACR;IAGF,OAAO;QACLX,cAAUP,2CAAAA,EACRO,UACAC,2BAA2BO,oBAAoBE;IAEnD;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/ToastTrigger/useToastTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n applyTriggerPropsToChildren,\n getTriggerChild,\n getReactElementRef,\n useEventCallback,\n} from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\nimport type { ToastTriggerProps, ToastTriggerState } from './ToastTrigger.types';\nimport { useToastContainerContext } from '../../contexts/toastContainerContext';\n\n/**\n * A non-visual component that wraps its child\n * and configures them to be the trigger that will close a `Toast`.\n * This component should only accept one child.\n *\n * This component sole purpose is to avoid opting out of the internal controlled open state of a `Toast`\n * Besides being a trigger that closes a toast through context this component doesn't do much,\n * making it basically unnecessary in cases where the trigger is outside of a toast.\n */\nexport const useToastTrigger_unstable = (props: ToastTriggerProps): ToastTriggerState => {\n const { children, disableButtonEnhancement = false } = props;\n const { close } = useToastContainerContext();\n\n const child = getTriggerChild(children);\n\n const handleClick = useEventCallback(\n (e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n child?.props.onClick?.(e);\n if (!e.isDefaultPrevented()) {\n close();\n }\n },\n );\n\n const triggerChildProps = {\n ...child?.props,\n ref: getReactElementRef<HTMLButtonElement>(child),\n onClick: handleClick,\n };\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n {\n ...triggerChildProps,\n type: 'button',\n },\n );\n\n return {\n children: applyTriggerPropsToChildren(\n children,\n disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n };\n};\n"],"names":["React","applyTriggerPropsToChildren","getTriggerChild","getReactElementRef","useEventCallback","useARIAButtonProps","useToastContainerContext","useToastTrigger_unstable","props","children","disableButtonEnhancement","close","child","handleClick","e","onClick","isDefaultPrevented","triggerChildProps","ref","ariaButtonTriggerChildProps","type"],"mappings":";;;;+BAoBaO;;;;;;;iEApBU,QAAQ;gCAMxB,4BAA4B;2BACA,uBAAuB;uCAEjB,uCAAuC;AAWzE,iCAAiC,CAACC;IACvC,MAAM,EAAEC,QAAQ,EAAEC,2BAA2B,KAAK,EAAE,GAAGF;IACvD,MAAM,EAAEG,KAAK,EAAE,OAAGL,+CAAAA;IAElB,MAAMM,YAAQV,+BAAAA,EAAgBO;IAE9B,MAAMI,kBAAcT,gCAAAA,EAClB,CAACU;YACCF,sBAAAA;QAAAA,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,wBAAAA,CAAAA,eAAAA,MAAOJ,KAAAA,AAAK,EAACO,OAAAA,AAAO,MAAA,QAApBH,yBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,qBAAAA,IAAAA,CAAAA,cAAuBE;QACvB,IAAI,CAACA,EAAEE,kBAAkB,IAAI;YAC3BL;QACF;IACF;IAGF,MAAMM,oBAAoB;WACrBL,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,MAAOJ,KAAV;QACAU,SAAKf,kCAAAA,EAAsCS;QAC3CG,SAASF;IACX;IAEA,MAAMM,kCAA8Bd,6BAAAA,EAClCO,WAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,MAAOQ,IAAAA,AAAI,MAAK,YAAYR,CAAAA,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,MAAOQ,IAAAA,AAAI,MAAK,MAAMR,MAAMQ,IAAI,GAAG,OAC/D;QACE,GAAGH,iBAAiB;QACpBG,MAAM;IACR;IAGF,OAAO;QACLX,cAAUR,2CAAAA,EACRQ,UACAC,2BAA2BO,oBAAoBE;IAEnD;AACF,EAAE"}
@@ -25,7 +25,7 @@ const useToaster_unstable = (props)=>{
25
25
  const { toastsToRender, isToastVisible, pauseAllToasts, playAllToasts, tryRestoreFocus, closeAllToasts } = (0, _state.useToaster)(rest);
26
26
  const announce = _react.useCallback((message, options)=>announceRef.current(message, options), []);
27
27
  const { dir } = (0, _reactsharedcontexts.useFluent_unstable)();
28
- const rootProps = _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('div', rest), {
28
+ const { onKeyDown: onKeyDownProp, ...rootProps } = _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('div', rest), {
29
29
  elementType: 'div'
30
30
  });
31
31
  const focusableGroupAttr = (0, _reacttabster.useFocusableGroup)({
@@ -35,12 +35,11 @@ const useToaster_unstable = (props)=>{
35
35
  }
36
36
  });
37
37
  const onKeyDown = (0, _reactutilities.useEventCallback)((e)=>{
38
- var _props_onKeyDown;
39
38
  if (e.key === _keyboardkeys.Escape) {
40
39
  e.preventDefault();
41
40
  closeAllToasts();
42
41
  }
43
- (_props_onKeyDown = props.onKeyDown) === null || _props_onKeyDown === void 0 ? void 0 : _props_onKeyDown.call(props, e);
42
+ onKeyDownProp === null || onKeyDownProp === void 0 ? void 0 : onKeyDownProp(e);
44
43
  });
45
44
  const usePositionSlot = (toastPosition)=>{
46
45
  var _toastsToRender_get;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Toaster/useToaster.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n ExtractSlotProps,\n Slot,\n getIntrinsicElementProps,\n useEventCallback,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\nimport { Escape } from '@fluentui/keyboard-keys';\nimport type { ToasterProps, ToasterState } from './Toaster.types';\nimport { TOAST_POSITIONS, ToastPosition, useToaster } from '../../state';\nimport { Announce } from '../AriaLive';\nimport { ToastContainer } from '../ToastContainer';\nimport { useToasterFocusManagement_unstable } from './useToasterFocusManagement';\nimport { useToastAnnounce } from './useToastAnnounce';\n\n/**\n * Create the state required to render Toaster.\n *\n * @param props - props from this instance of Toaster\n */\nexport const useToaster_unstable = (props: ToasterProps): ToasterState => {\n 'use no memo';\n\n const { offset, announce: announceProp, mountNode, inline = false, ...rest } = props;\n const announceRef = React.useRef<Announce>(() => null);\n const { toastsToRender, isToastVisible, pauseAllToasts, playAllToasts, tryRestoreFocus, closeAllToasts } =\n useToaster<HTMLDivElement>(rest);\n const announce = React.useCallback<Announce>((message, options) => announceRef.current(message, options), []);\n const { dir } = useFluent();\n\n const rootProps = slot.always(getIntrinsicElementProps<ExtractSlotProps<Slot<'div'>>>('div', rest), {\n elementType: 'div',\n });\n const focusableGroupAttr = useFocusableGroup({\n tabBehavior: 'limited-trap-focus',\n ignoreDefaultKeydown: { Escape: true },\n });\n const onKeyDown = useEventCallback((e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key === Escape) {\n e.preventDefault();\n closeAllToasts();\n }\n props.onKeyDown?.(e);\n });\n const usePositionSlot = (toastPosition: ToastPosition) => {\n const focusManagementRef = useToasterFocusManagement_unstable(pauseAllToasts, playAllToasts);\n const { announceToast, toasterRef } = useToastAnnounce(announceProp ?? announce);\n return slot.optional<ExtractSlotProps<Slot<'div'>>>(toastsToRender.has(toastPosition) ? rootProps : null, {\n defaultProps: {\n ref: useMergedRefs(focusManagementRef, toasterRef),\n children: toastsToRender.get(toastPosition)?.map(toast => (\n <ToastContainer\n {...toast}\n tryRestoreFocus={tryRestoreFocus}\n intent={toast.intent}\n announce={announceToast}\n key={toast.toastId}\n visible={isToastVisible(toast.toastId)}\n >\n {toast.content as React.ReactNode}\n </ToastContainer>\n )),\n onKeyDown,\n ...focusableGroupAttr,\n 'data-toaster-position': toastPosition,\n role: 'list',\n // Explicitly casting because our slot types can't handle data attributes\n } as ExtractSlotProps<Slot<'div'>>,\n elementType: 'div',\n });\n };\n\n return {\n dir,\n mountNode,\n components: {\n root: 'div',\n bottomStart: 'div',\n bottomEnd: 'div',\n topStart: 'div',\n topEnd: 'div',\n top: 'div',\n bottom: 'div',\n },\n root: slot.always(rootProps, { elementType: 'div' }),\n bottomStart: usePositionSlot(TOAST_POSITIONS.bottomStart),\n bottomEnd: usePositionSlot(TOAST_POSITIONS.bottomEnd),\n topStart: usePositionSlot(TOAST_POSITIONS.topStart),\n topEnd: usePositionSlot(TOAST_POSITIONS.topEnd),\n top: usePositionSlot(TOAST_POSITIONS.top),\n bottom: usePositionSlot(TOAST_POSITIONS.bottom),\n announceRef,\n offset,\n announce: announceProp ?? announce,\n renderAriaLive: !announceProp,\n inline,\n };\n};\n"],"names":["React","getIntrinsicElementProps","useEventCallback","useMergedRefs","slot","useFluent_unstable","useFluent","useFocusableGroup","Escape","TOAST_POSITIONS","useToaster","ToastContainer","useToasterFocusManagement_unstable","useToastAnnounce","useToaster_unstable","props","offset","announce","announceProp","mountNode","inline","rest","announceRef","useRef","toastsToRender","isToastVisible","pauseAllToasts","playAllToasts","tryRestoreFocus","closeAllToasts","useCallback","message","options","current","dir","rootProps","always","elementType","focusableGroupAttr","tabBehavior","ignoreDefaultKeydown","onKeyDown","e","key","preventDefault","usePositionSlot","toastPosition","focusManagementRef","announceToast","toasterRef","optional","has","defaultProps","ref","children","get","map","toast","intent","toastId","visible","content","role","components","root","bottomStart","bottomEnd","topStart","topEnd","top","bottom","renderAriaLive"],"mappings":";;;;+BAwBac;;;;;;;iEAxBU,QAAQ;gCAQxB,4BAA4B;qCACa,kCAAkC;8BAChD,0BAA0B;8BACrC,0BAA0B;uBAEU,cAAc;gCAE1C,oBAAoB;2CACA,8BAA8B;kCAChD,qBAAqB;AAO/C,4BAA4B,CAACC;IAClC;IAEA,MAAM,EAAEC,MAAM,EAAEC,UAAUC,YAAY,EAAEC,SAAS,EAAEC,SAAS,KAAK,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AA,QAAnBtB,wBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,oBAAmCgC,GAAG,CAACC,CAAAA,QAAAA,WAAAA,GAC/C,OAAA,aAAA,CAAC9C,8BAAAA,EAAAA;wBACE,GAAG8C,KAAK;wBACT7B,iBAAiBA;wBACjB8B,QAAQD,MAAMC,MAAM;wBACpBzC,UAAU+B;wBACVL,KAAKc,MAAME,OAAO;wBAClBC,SAASnC,eAAegC,MAAME,OAAO;uBAEpCF,MAAMI,OAAO;gBAGlBpB;gBACA,GAAGH,kBAAkB;gBACrB,yBAAyBQ;gBACzBgB,MAAM;YAER;YACAzB,aAAa;QACf;IACF;IAEA,OAAO;QACLH;QACAf;QACA4C,YAAY;YACVC,MAAM;YACNC,aAAa;YACbC,WAAW;YACXC,UAAU;YACVC,QAAQ;YACRC,KAAK;YACLC,QAAQ;QACV;QACAN,MAAM5D,oBAAAA,CAAKgC,MAAM,CAACD,WAAW;YAAEE,aAAa;QAAM;QAClD4B,aAAapB,gBAAgBpC,sBAAAA,CAAgBwD,WAAW;QACxDC,WAAWrB,gBAAgBpC,sBAAAA,CAAgByD,SAAS;QACpDC,UAAUtB,gBAAgBpC,sBAAAA,CAAgB0D,QAAQ;QAClDC,QAAQvB,gBAAgBpC,sBAAAA,CAAgB2D,MAAM;QAC9CC,KAAKxB,gBAAgBpC,sBAAAA,CAAgB4D,GAAG;QACxCC,QAAQzB,gBAAgBpC,sBAAAA,CAAgB6D,MAAM;QAC9ChD;QACAN;QACAC,UAAUC,iBAAAA,QAAAA,iBAAAA,KAAAA,IAAAA,eAAgBD;QAC1BsD,gBAAgB,CAACrD;QACjBE;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/Toaster/useToaster.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n ExtractSlotProps,\n Slot,\n getIntrinsicElementProps,\n useEventCallback,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\nimport { Escape } from '@fluentui/keyboard-keys';\nimport type { ToasterProps, ToasterState } from './Toaster.types';\nimport { TOAST_POSITIONS, ToastPosition, useToaster } from '../../state';\nimport { Announce } from '../AriaLive';\nimport { ToastContainer } from '../ToastContainer';\nimport { useToasterFocusManagement_unstable } from './useToasterFocusManagement';\nimport { useToastAnnounce } from './useToastAnnounce';\n\n/**\n * Create the state required to render Toaster.\n *\n * @param props - props from this instance of Toaster\n */\nexport const useToaster_unstable = (props: ToasterProps): ToasterState => {\n 'use no memo';\n\n const { offset, announce: announceProp, mountNode, inline = false, ...rest } = props;\n const announceRef = React.useRef<Announce>(() => null);\n const { toastsToRender, isToastVisible, pauseAllToasts, playAllToasts, tryRestoreFocus, closeAllToasts } =\n useToaster<HTMLDivElement>(rest);\n const announce = React.useCallback<Announce>((message, options) => announceRef.current(message, options), []);\n const { dir } = useFluent();\n\n const { onKeyDown: onKeyDownProp, ...rootProps } = slot.always(\n getIntrinsicElementProps<ExtractSlotProps<Slot<'div'>>>('div', rest),\n {\n elementType: 'div',\n },\n );\n const focusableGroupAttr = useFocusableGroup({\n tabBehavior: 'limited-trap-focus',\n ignoreDefaultKeydown: { Escape: true },\n });\n const onKeyDown = useEventCallback((e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key === Escape) {\n e.preventDefault();\n closeAllToasts();\n }\n onKeyDownProp?.(e);\n });\n const usePositionSlot = (toastPosition: ToastPosition) => {\n const focusManagementRef = useToasterFocusManagement_unstable(pauseAllToasts, playAllToasts);\n const { announceToast, toasterRef } = useToastAnnounce(announceProp ?? announce);\n return slot.optional<ExtractSlotProps<Slot<'div'>>>(toastsToRender.has(toastPosition) ? rootProps : null, {\n defaultProps: {\n ref: useMergedRefs(focusManagementRef, toasterRef),\n children: toastsToRender.get(toastPosition)?.map(toast => (\n <ToastContainer\n {...toast}\n tryRestoreFocus={tryRestoreFocus}\n intent={toast.intent}\n announce={announceToast}\n key={toast.toastId}\n visible={isToastVisible(toast.toastId)}\n >\n {toast.content as React.ReactNode}\n </ToastContainer>\n )),\n onKeyDown,\n ...focusableGroupAttr,\n 'data-toaster-position': toastPosition,\n role: 'list',\n // Explicitly casting because our slot types can't handle data attributes\n } as ExtractSlotProps<Slot<'div'>>,\n elementType: 'div',\n });\n };\n\n return {\n dir,\n mountNode,\n components: {\n root: 'div',\n bottomStart: 'div',\n bottomEnd: 'div',\n topStart: 'div',\n topEnd: 'div',\n top: 'div',\n bottom: 'div',\n },\n root: slot.always(rootProps, { elementType: 'div' }),\n bottomStart: usePositionSlot(TOAST_POSITIONS.bottomStart),\n bottomEnd: usePositionSlot(TOAST_POSITIONS.bottomEnd),\n topStart: usePositionSlot(TOAST_POSITIONS.topStart),\n topEnd: usePositionSlot(TOAST_POSITIONS.topEnd),\n top: usePositionSlot(TOAST_POSITIONS.top),\n bottom: usePositionSlot(TOAST_POSITIONS.bottom),\n announceRef,\n offset,\n announce: announceProp ?? announce,\n renderAriaLive: !announceProp,\n inline,\n };\n};\n"],"names":["React","getIntrinsicElementProps","useEventCallback","useMergedRefs","slot","useFluent_unstable","useFluent","useFocusableGroup","Escape","TOAST_POSITIONS","useToaster","ToastContainer","useToasterFocusManagement_unstable","useToastAnnounce","useToaster_unstable","props","offset","announce","announceProp","mountNode","inline","rest","announceRef","useRef","toastsToRender","isToastVisible","pauseAllToasts","playAllToasts","tryRestoreFocus","closeAllToasts","useCallback","message","options","current","dir","onKeyDown","onKeyDownProp","rootProps","always","elementType","focusableGroupAttr","tabBehavior","ignoreDefaultKeydown","e","key","preventDefault","usePositionSlot","toastPosition","focusManagementRef","announceToast","toasterRef","optional","has","defaultProps","ref","children","get","map","toast","intent","toastId","visible","content","role","components","root","bottomStart","bottomEnd","topStart","topEnd","top","bottom","renderAriaLive"],"mappings":";;;;+BAwBac;;;;;;;iEAxBU,QAAQ;gCAQxB,4BAA4B;qCACa,kCAAkC;8BAChD,0BAA0B;8BACrC,0BAA0B;uBAEU,c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assNames;
53
53
  },
54
+ toastContainerClassNames: function() {
55
+ return _ToastContainer.toastContainerClassNames;
56
+ },
54
57
  toastFooterClassNames: function() {
55
58
  return _ToastFooter.toastFooterClassNames;
56
59
  },
@@ -104,3 +107,4 @@ const _Toast = require("./Toast");
104
107
  const _ToastTitle = require("./ToastTitle");
105
108
  const _ToastBody = require("./ToastBody");
106
109
  const _ToastFooter = require("./ToastFooter");
110
+ const _ToastContainer = require("./ToastContainer");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { useToastController } from './state';\nexport type { ToastPosition, ToastId, ToastOffset, ToastPoliteness, ToastStatus, ToastIntent } from './state';\n\nexport { ToastTrigger, useToastTrigger_unstable, renderToastTrigger_unstable } from './ToastTrigger';\nexport type { ToastTriggerChildProps, ToastTriggerProps, ToastTriggerState } from './ToastTrigger';\nexport {\n Toaster,\n useToaster_unstable,\n useToasterStyles_unstable,\n renderToaster_unstable,\n toasterClassNames,\n} from './Toaster';\nexport type { ToasterProps, ToasterState, ToasterSlots } from './Toaster';\nexport { Toast, useToastStyles_unstable, useToast_unstable, renderToast_unstable, toastClassNames } from './Toast';\nexport type { ToastProps, ToastState, ToastSlots } from './Toast';\n\nexport {\n ToastTitle,\n useToastTitleStyles_unstable,\n useToastTitle_unstable,\n renderToastTitle_unstable,\n toastTitleClassNames,\n} from './ToastTitle';\nexport type { ToastTitleProps, ToastTitleState, ToastTitleSlots } from './ToastTitle';\n\nexport {\n ToastBody,\n useToastBodyStyles_unstable,\n useToastBody_unstable,\n renderToastBody_unstable,\n toastBodyClassNames,\n} from './ToastBody';\nexport type { ToastBodyProps, ToastBodyState, ToastBodySlots } from './ToastBody';\n\nexport {\n ToastFooter,\n useToastFooterStyles_unstable,\n useToastFooter_unstable,\n renderToastFooter_unstable,\n toastFooterClassNames,\n} from './ToastFooter';\nexport type { ToastFooterProps, ToastFooterState, ToastFooterSlots } from './ToastFooter';\n"],"names":["useToastController","ToastTrigger","useToastTrigger_unstable","renderToastTrigger_unstable","Toaster","useToaster_unstable","useToasterStyles_unstable","renderToaster_unstable","toasterClassNames","Toast","useToastStyles_unstable","useToast_unstable","renderToast_unstable","toastClassNames","ToastTitle","useToastTitleStyles_unstable","useToastTitle_unstable","renderToastTitle_unstable","toastTitleClassNames","ToastBody","useToastBodyStyles_unstable","useToastBody_unstable","renderToastBody_unstable","toastBodyClassNames","ToastFooter","useToastFooterStyles_unstable","useToastFooter_unstable","renderToastFooter_unstable","toastFooterClassNames"],"mappings":";;;;;;;;;;;IAaSS,KAAK;;;IAaZU;mCAAS;;;eASTK,wBAAW;;IAlBXV;qCAAU;;;eAdHb,0BAAY;;;eAGnBG,gBAAO;;;eAuBPkB,mCAAwB;;;eASxBK,uCAA0B;;IAlB1BV,yBAAyB;;;;eAjBsBd,yCAA2B;;IAUhBS,oBAAoB;;;;eAJ9EL,+BAAsB;;;eAqBtBgB,8BAAmB;;IAjB6DV,eAAe;;;IA0B/Fe;iDAAqB;;wBAlBD;eAApBV;;qBAXiB;eAAjBV;;;eAiBAY,sCAA2B;;IAC3BC,qBAAqB;;;;eA5BdrB,yBAAkB;;;eAoCzByB,0CAA6B;;2BACN;eAAvBC;;;eAxBchB,8BAAuB;;;eAKrCK,wCAA4B;;;eAC5BC,kCAAsB;;;eAhBDd,sCAAwB;;;eAUNS,wBAAiB;;;eALxDL,kCAAyB;;;eADzBD,4BAAmB;;;uBAPc,UAAU;8BAGuC,iBAAiB;yBAQ9F,YAAY;uBAEsF,UAAU;4BAS5G,eAAe;2BASf,cAAc;6BASd,gBAAgB"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { useToastController } from './state';\nexport type { ToastPosition, ToastId, ToastOffset, ToastPoliteness, ToastStatus, ToastIntent } from './state';\n\nexport { ToastTrigger, useToastTrigger_unstable, renderToastTrigger_unstable } from './ToastTrigger';\nexport type { ToastTriggerChildProps, ToastTriggerProps, ToastTriggerState } from './ToastTrigger';\nexport {\n Toaster,\n useToaster_unstable,\n useToasterStyles_unstable,\n renderToaster_unstable,\n toasterClassNames,\n} from './Toaster';\nexport type { ToasterProps, ToasterState, ToasterSlots } from './Toaster';\nexport { Toast, useToastStyles_unstable, useToast_unstable, renderToast_unstable, toastClassNames } from './Toast';\nexport type { ToastProps, ToastState, ToastSlots } from './Toast';\n\nexport {\n ToastTitle,\n useToastTitleStyles_unstable,\n useToastTitle_unstable,\n renderToastTitle_unstable,\n toastTitleClassNames,\n} from './ToastTitle';\nexport type { ToastTitleProps, ToastTitleState, ToastTitleSlots } from './ToastTitle';\n\nexport {\n ToastBody,\n useToastBodyStyles_unstable,\n useToastBody_unstable,\n renderToastBody_unstable,\n toastBodyClassNames,\n} from './ToastBody';\nexport type { ToastBodyProps, ToastBodyState, ToastBodySlots } from './ToastBody';\n\nexport {\n ToastFooter,\n useToastFooterStyles_unstable,\n useToastFooter_unstable,\n renderToastFooter_unstable,\n toastFooterClassNames,\n} from './ToastFooter';\nexport type { ToastFooterProps, ToastFooterState, ToastFooterSlots } from './ToastFooter';\n\nexport { toastContainerClassNames } from './ToastContainer';\nexport type { ToastContainerState } from './ToastContainer';\n"],"names":["useToastController","ToastTrigger","useToastTrigger_unstable","renderToastTrigger_unstable","Toaster","useToaster_unstable","useToasterStyles_unstable","renderToaster_unstable","toasterClassNames","Toast","useToastStyles_unstable","useToast_unstable","renderToast_unstable","toastClassNames","ToastTitle","useToastTitleStyles_unstable","useToastTitle_unstable","renderToastTitle_unstable","toastTitleClassNames","ToastBody","useToastBodyStyles_unstable","useToastBody_unstable","renderToastBody_unstable","toastBodyClassNames","ToastFooter","useToastFooterStyles_unstable","useToastFooter_unstable","renderToastFooter_unstable","toastFooterClassNames","toastContainerClassNames"],"mappings":";;;;;;;;;;;IAaSS;2BAAK;;;eAaZU,oBAAS;;;eASTK,wBAAW;;IAlBXV;qCAAU;;;eAdHb,0BAAY;;;eAGnBG,gBAAO;;4BAuBiB;eAAxBkB;;IASAK;sDAA0B;;6BAlBD;eAAzBV;;;eAjB+Cd,yCAA2B;;;eAUhBS,2BAAoB;;0BAJxD;eAAtBL;;;eAqBAgB,8BAAmB;;;eAjB6DV,sBAAe;;;eA8BxFgB,wCAAwB;;IAJ/BD,qBAAqB;;;wBAlBD;eAApBV;;;eAXAV,0BAAiB;;;eAiBjBY,sCAA2B;;;eAC3BC,gCAAqB;;;eA5BdrB,yBAAkB;;IAoCzByB;yDAA6B;;;eAC7BC,oCAAuB;;;eAxBThB,8BAAuB;;;eAKrCK,wCAA4B;;;eAC5BC,kCAAsB;;;eAhBDd,sCAAwB;;;eAUNS,wBAAiB;;6BAL/B;eAAzBL;;;eADAD,4BAAmB;;;uBAPc,UAAU;8BAGuC,iBAAiB;yBAQ9F,YAAY;uBAEsF,UAAU;4BAS5G,eAAe;2BASf,cAAc;6BASd,gBAAgB;gCAGkB,mBAAmB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-toast",
3
- "version": "9.6.3",
3
+ "version": "9.7.0",
4
4
  "description": "Toast component for Fluent UI",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -21,16 +21,16 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@fluentui/keyboard-keys": "^9.0.8",
24
- "@fluentui/react-aria": "^9.16.2",
24
+ "@fluentui/react-aria": "^9.16.4",
25
25
  "@fluentui/react-icons": "^2.0.245",
26
- "@fluentui/react-jsx-runtime": "^9.1.4",
27
- "@fluentui/react-motion": "^9.10.1",
28
- "@fluentui/react-motion-components-preview": "^0.8.1",
29
- "@fluentui/react-portal": "^9.7.2",
30
- "@fluentui/react-shared-contexts": "^9.24.1",
31
- "@fluentui/react-tabster": "^9.26.2",
26
+ "@fluentui/react-jsx-runtime": "^9.1.6",
27
+ "@fluentui/react-motion": "^9.10.3",
28
+ "@fluentui/react-motion-components-preview": "^0.9.0",
29
+ "@fluentui/react-portal": "^9.8.1",
30
+ "@fluentui/react-shared-contexts": "^9.25.0",
31
+ "@fluentui/react-tabster": "^9.26.4",
32
32
  "@fluentui/react-theme": "^9.2.0",
33
- "@fluentui/react-utilities": "^9.23.1",
33
+ "@fluentui/react-utilities": "^9.24.0",
34
34
  "@griffel/react": "^1.5.22",
35
35
  "@swc/helpers": "^0.5.1"
36
36
  },