@fluentui/react-toast 9.7.18 → 9.8.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/dist/index.d.ts +155 -50
  3. package/lib/Toast.js +1 -1
  4. package/lib/Toast.js.map +1 -1
  5. package/lib/ToastBody.js +1 -1
  6. package/lib/ToastBody.js.map +1 -1
  7. package/lib/ToastTitle.js +1 -1
  8. package/lib/ToastTitle.js.map +1 -1
  9. package/lib/Toaster.js +1 -1
  10. package/lib/Toaster.js.map +1 -1
  11. package/lib/components/Toast/Toast.types.js +1 -1
  12. package/lib/components/Toast/Toast.types.js.map +1 -1
  13. package/lib/components/Toast/index.js +1 -1
  14. package/lib/components/Toast/index.js.map +1 -1
  15. package/lib/components/Toast/useToast.js +18 -7
  16. package/lib/components/Toast/useToast.js.map +1 -1
  17. package/lib/components/ToastBody/ToastBody.types.js +1 -1
  18. package/lib/components/ToastBody/ToastBody.types.js.map +1 -1
  19. package/lib/components/ToastBody/index.js +1 -1
  20. package/lib/components/ToastBody/index.js.map +1 -1
  21. package/lib/components/ToastBody/useToastBody.js +17 -7
  22. package/lib/components/ToastBody/useToastBody.js.map +1 -1
  23. package/lib/components/ToastTitle/ToastTitle.types.js +1 -1
  24. package/lib/components/ToastTitle/ToastTitle.types.js.map +1 -1
  25. package/lib/components/ToastTitle/index.js +1 -1
  26. package/lib/components/ToastTitle/index.js.map +1 -1
  27. package/lib/components/ToastTitle/useToastTitle.js +39 -23
  28. package/lib/components/ToastTitle/useToastTitle.js.map +1 -1
  29. package/lib/components/Toaster/index.js +1 -0
  30. package/lib/components/Toaster/index.js.map +1 -1
  31. package/lib/components/Toaster/useToastAnnounce.js +1 -1
  32. package/lib/components/Toaster/useToastAnnounce.js.map +1 -1
  33. package/lib/index.js +7 -5
  34. package/lib/index.js.map +1 -1
  35. package/lib/state/types.js.map +1 -1
  36. package/lib-commonjs/Toast.js +3 -0
  37. package/lib-commonjs/Toast.js.map +1 -1
  38. package/lib-commonjs/ToastBody.js +3 -0
  39. package/lib-commonjs/ToastBody.js.map +1 -1
  40. package/lib-commonjs/ToastTitle.js +3 -0
  41. package/lib-commonjs/ToastTitle.js.map +1 -1
  42. package/lib-commonjs/Toaster.js +3 -0
  43. package/lib-commonjs/Toaster.js.map +1 -1
  44. package/lib-commonjs/components/Toast/Toast.types.js +1 -1
  45. package/lib-commonjs/components/Toast/Toast.types.js.map +1 -1
  46. package/lib-commonjs/components/Toast/index.js +3 -0
  47. package/lib-commonjs/components/Toast/index.js.map +1 -1
  48. package/lib-commonjs/components/Toast/useToast.js +19 -5
  49. package/lib-commonjs/components/Toast/useToast.js.map +1 -1
  50. package/lib-commonjs/components/ToastBody/ToastBody.types.js +1 -1
  51. package/lib-commonjs/components/ToastBody/ToastBody.types.js.map +1 -1
  52. package/lib-commonjs/components/ToastBody/index.js +3 -0
  53. package/lib-commonjs/components/ToastBody/index.js.map +1 -1
  54. package/lib-commonjs/components/ToastBody/useToastBody.js +19 -6
  55. package/lib-commonjs/components/ToastBody/useToastBody.js.map +1 -1
  56. package/lib-commonjs/components/ToastTitle/ToastTitle.types.js +1 -1
  57. package/lib-commonjs/components/ToastTitle/ToastTitle.types.js.map +1 -1
  58. package/lib-commonjs/components/ToastTitle/index.js +3 -0
  59. package/lib-commonjs/components/ToastTitle/index.js.map +1 -1
  60. package/lib-commonjs/components/ToastTitle/useToastTitle.js +43 -24
  61. package/lib-commonjs/components/ToastTitle/useToastTitle.js.map +1 -1
  62. package/lib-commonjs/components/Toaster/index.js +4 -0
  63. package/lib-commonjs/components/Toaster/index.js.map +1 -1
  64. package/lib-commonjs/components/Toaster/useToastAnnounce.js.map +1 -1
  65. package/lib-commonjs/index.js +31 -0
  66. package/lib-commonjs/index.js.map +1 -1
  67. package/lib-commonjs/state/types.js.map +1 -1
  68. package/package.json +1 -1
@@ -3,9 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "useToastTitle_unstable", {
7
- enumerable: true,
8
- get: function() {
6
+ function _export(target, all) {
7
+ for(var name in all)Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ useToastTitleBase_unstable: function() {
14
+ return useToastTitleBase_unstable;
15
+ },
16
+ useToastTitle_unstable: function() {
9
17
  return useToastTitle_unstable;
10
18
  }
11
19
  });
@@ -15,24 +23,8 @@ const _reacticons = require("@fluentui/react-icons");
15
23
  const _reactutilities = require("@fluentui/react-utilities");
16
24
  const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
17
25
  const _toastContainerContext = require("../../contexts/toastContainerContext");
18
- const useToastTitle_unstable = (props, ref)=>{
26
+ const useToastTitleBase_unstable = (props, ref)=>{
19
27
  const { intent, titleId } = (0, _toastContainerContext.useToastContainerContext)();
20
- const backgroundAppearance = (0, _reactsharedcontexts.useBackgroundAppearance)();
21
- /** Determine the role and media to render based on the intent */ let defaultIcon;
22
- switch(intent){
23
- case 'success':
24
- defaultIcon = /*#__PURE__*/ _react.createElement(_reacticons.CheckmarkCircleFilled, null);
25
- break;
26
- case 'error':
27
- defaultIcon = /*#__PURE__*/ _react.createElement(_reacticons.DiamondDismissFilled, null);
28
- break;
29
- case 'warning':
30
- defaultIcon = /*#__PURE__*/ _react.createElement(_reacticons.WarningFilled, null);
31
- break;
32
- case 'info':
33
- defaultIcon = /*#__PURE__*/ _react.createElement(_reacticons.InfoFilled, null);
34
- break;
35
- }
36
28
  return {
37
29
  action: _reactutilities.slot.optional(props.action, {
38
30
  elementType: 'div'
@@ -44,9 +36,6 @@ const useToastTitle_unstable = (props, ref)=>{
44
36
  },
45
37
  media: _reactutilities.slot.optional(props.media, {
46
38
  renderByDefault: !!intent,
47
- defaultProps: {
48
- children: defaultIcon
49
- },
50
39
  elementType: 'div'
51
40
  }),
52
41
  root: _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('div', {
@@ -60,7 +49,37 @@ const useToastTitle_unstable = (props, ref)=>{
60
49
  }), {
61
50
  elementType: 'div'
62
51
  }),
63
- intent,
52
+ intent
53
+ };
54
+ };
55
+ const useToastTitle_unstable = (props, ref)=>{
56
+ 'use no memo';
57
+ const backgroundAppearance = (0, _reactsharedcontexts.useBackgroundAppearance)();
58
+ const baseState = useToastTitleBase_unstable(props, ref);
59
+ /** Determine the role and media to render based on the intent */ let defaultIcon;
60
+ switch(baseState.intent){
61
+ case 'success':
62
+ defaultIcon = /*#__PURE__*/ _react.createElement(_reacticons.CheckmarkCircleFilled, null);
63
+ break;
64
+ case 'error':
65
+ defaultIcon = /*#__PURE__*/ _react.createElement(_reacticons.DiamondDismissFilled, null);
66
+ break;
67
+ case 'warning':
68
+ defaultIcon = /*#__PURE__*/ _react.createElement(_reacticons.WarningFilled, null);
69
+ break;
70
+ case 'info':
71
+ defaultIcon = /*#__PURE__*/ _react.createElement(_reacticons.InfoFilled, null);
72
+ break;
73
+ }
74
+ return {
75
+ ...baseState,
76
+ media: _reactutilities.slot.optional(props.media, {
77
+ defaultProps: {
78
+ children: defaultIcon
79
+ },
80
+ renderByDefault: !!baseState.intent,
81
+ elementType: 'div'
82
+ }),
64
83
  backgroundAppearance
65
84
  };
66
85
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/ToastTitle/useToastTitle.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { CheckmarkCircleFilled, DiamondDismissFilled, InfoFilled, WarningFilled } from '@fluentui/react-icons';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';\nimport { useBackgroundAppearance } from '@fluentui/react-shared-contexts';\n\nimport type { ToastTitleProps, ToastTitleState } from './ToastTitle.types';\nimport { useToastContainerContext } from '../../contexts/toastContainerContext';\n\n/**\n * Create the state required to render ToastTitle.\n *\n * The returned state can be modified with hooks such as useToastTitleStyles_unstable,\n * before being passed to renderToastTitle_unstable.\n *\n * @param props - props from this instance of ToastTitle\n * @param ref - reference to root HTMLElement of ToastTitle\n */\nexport const useToastTitle_unstable = (props: ToastTitleProps, ref: React.Ref<HTMLElement>): ToastTitleState => {\n const { intent, titleId } = useToastContainerContext();\n const backgroundAppearance = useBackgroundAppearance();\n\n /** Determine the role and media to render based on the intent */\n let defaultIcon;\n switch (intent) {\n case 'success':\n defaultIcon = <CheckmarkCircleFilled />;\n break;\n case 'error':\n defaultIcon = <DiamondDismissFilled />;\n break;\n case 'warning':\n defaultIcon = <WarningFilled />;\n break;\n case 'info':\n defaultIcon = <InfoFilled />;\n break;\n }\n\n return {\n action: slot.optional(props.action, { elementType: 'div' }),\n components: { root: 'div', media: 'div', action: 'div' },\n media: slot.optional(props.media, {\n renderByDefault: !!intent,\n defaultProps: { children: defaultIcon },\n elementType: 'div',\n }),\n root: slot.always(\n getIntrinsicElementProps('div', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: ref as React.Ref<HTMLDivElement>,\n children: props.children,\n id: titleId,\n ...props,\n }),\n { elementType: 'div' },\n ),\n intent,\n backgroundAppearance,\n };\n};\n"],"names":["React","CheckmarkCircleFilled","DiamondDismissFilled","InfoFilled","WarningFilled","getIntrinsicElementProps","slot","useBackgroundAppearance","useToastContainerContext","useToastTitle_unstable","props","ref","intent","titleId","backgroundAppearance","defaultIcon","action","optional","elementType","components","root","media","renderByDefault","defaultProps","children","always","id"],"mappings":"AAAA;;;;;+BAoBaS;;;;;;;iEAlBU,QAAQ;4BAEwD,wBAAwB;gCAChE,4BAA4B;qCACnC,kCAAkC;uCAGjC,uCAAuC;AAWzE,+BAA+B,CAACC,OAAwBC;IAC7D,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,OAAGL,+CAAAA;IAC5B,MAAMM,uBAAuBP,gDAAAA;IAE7B,+DAA+D,GAC/D,IAAIQ;IACJ,OAAQH;QACN,KAAK;YACHG,cAAAA,WAAAA,GAAc,OAAA,aAAA,CAACd,iCAAAA,EAAAA;YACf;QACF,KAAK;YACHc,cAAAA,WAAAA,GAAc,OAAA,aAAA,CAACb,gCAAAA,EAAAA;YACf;QACF,KAAK;YACHa,cAAAA,WAAAA,GAAc,OAAA,aAAA,CAACX,yBAAAA,EAAAA;YACf;QACF,KAAK;YACHW,cAAAA,WAAAA,GAAc,OAAA,aAAA,CAACZ,sBAAAA,EAAAA;YACf;IACJ;IAEA,OAAO;QACLa,QAAQV,oBAAAA,CAAKW,QAAQ,CAACP,MAAMM,MAAM,EAAE;YAAEE,aAAa;QAAM;QACzDC,YAAY;YAAEC,MAAM;YAAOC,OAAO;YAAOL,QAAQ;QAAM;QACvDK,OAAOf,oBAAAA,CAAKW,QAAQ,CAACP,MAAMW,KAAK,EAAE;YAChCC,iBAAiB,CAAC,CAACV;YACnBW,cAAc;gBAAEC,UAAUT;YAAY;YACtCG,aAAa;QACf;QACAE,MAAMd,oBAAAA,CAAKmB,MAAM,KACfpB,wCAAAA,EAAyB,OAAO;YAC9B,SAAS;YACT,4EAA4E;YAC5E,4FAA4F;YAC5FM,KAAKA;YACLa,UAAUd,MAAMc,QAAQ;YACxBE,IAAIb;YACJ,GAAGH,KAAK;QACV,IACA;YAAEQ,aAAa;QAAM;QAEvBN;QACAE;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/ToastTitle/useToastTitle.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { CheckmarkCircleFilled, DiamondDismissFilled, InfoFilled, WarningFilled } from '@fluentui/react-icons';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';\nimport { useBackgroundAppearance } from '@fluentui/react-shared-contexts';\n\nimport type { ToastTitleBaseProps, ToastTitleBaseState, ToastTitleProps, ToastTitleState } from './ToastTitle.types';\nimport { useToastContainerContext } from '../../contexts/toastContainerContext';\n\n/**\n * Create the base state required to render ToastTitle, without design-only props.\n *\n * @param props - props from this instance of ToastTitle\n * @param ref - reference to root HTMLElement of ToastTitle\n */\nexport const useToastTitleBase_unstable = (\n props: ToastTitleBaseProps,\n ref: React.Ref<HTMLElement>,\n): ToastTitleBaseState => {\n const { intent, titleId } = useToastContainerContext();\n\n return {\n action: slot.optional(props.action, { elementType: 'div' }),\n components: { root: 'div', media: 'div', action: 'div' },\n media: slot.optional(props.media, {\n renderByDefault: !!intent,\n elementType: 'div',\n }),\n root: slot.always(\n getIntrinsicElementProps('div', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: ref as React.Ref<HTMLDivElement>,\n children: props.children,\n id: titleId,\n ...props,\n }),\n { elementType: 'div' },\n ),\n intent,\n };\n};\n\n/**\n * Create the state required to render ToastTitle.\n *\n * The returned state can be modified with hooks such as useToastTitleStyles_unstable,\n * before being passed to renderToastTitle_unstable.\n *\n * @param props - props from this instance of ToastTitle\n * @param ref - reference to root HTMLElement of ToastTitle\n */\nexport const useToastTitle_unstable = (props: ToastTitleProps, ref: React.Ref<HTMLElement>): ToastTitleState => {\n 'use no memo';\n\n const backgroundAppearance = useBackgroundAppearance();\n const baseState = useToastTitleBase_unstable(props, ref);\n\n /** Determine the role and media to render based on the intent */\n let defaultIcon;\n switch (baseState.intent) {\n case 'success':\n defaultIcon = <CheckmarkCircleFilled />;\n break;\n case 'error':\n defaultIcon = <DiamondDismissFilled />;\n break;\n case 'warning':\n defaultIcon = <WarningFilled />;\n break;\n case 'info':\n defaultIcon = <InfoFilled />;\n break;\n }\n\n return {\n ...baseState,\n media: slot.optional(props.media, {\n defaultProps: { children: defaultIcon },\n renderByDefault: !!baseState.intent,\n elementType: 'div',\n }),\n backgroundAppearance,\n };\n};\n"],"names":["React","CheckmarkCircleFilled","DiamondDismissFilled","InfoFilled","WarningFilled","getIntrinsicElementProps","slot","useBackgroundAppearance","useToastContainerContext","useToastTitleBase_unstable","props","ref","intent","titleId","action","optional","elementType","components","root","media","renderByDefault","always","children","id","useToastTitle_unstable","backgroundAppearance","baseState","defaultIcon","defaultProps"],"mappings":"AAAA;;;;;;;;;;;;IAiBaS,0BAAAA;;;0BAsCAe;eAAAA;;;;iEArDU,QAAQ;4BAEwD,wBAAwB;gCAChE,4BAA4B;qCACnC,kCAAkC;uCAGjC,uCAAuC;AAQzE,mCAAmC,CACxCd,OACAC;IAEA,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,OAAGL,+CAAAA;IAE5B,OAAO;QACLM,QAAQR,oBAAAA,CAAKS,QAAQ,CAACL,MAAMI,MAAM,EAAE;YAAEE,aAAa;QAAM;QACzDC,YAAY;YAAEC,MAAM;YAAOC,OAAO;YAAOL,QAAQ;QAAM;QACvDK,OAAOb,oBAAAA,CAAKS,QAAQ,CAACL,MAAMS,KAAK,EAAE;YAChCC,iBAAiB,CAAC,CAACR;YACnBI,aAAa;QACf;QACAE,MAAMZ,oBAAAA,CAAKe,MAAM,KACfhB,wCAAAA,EAAyB,OAAO;YAC9B,SAAS;YACT,4EAA4E;YAC5E,4FAA4F;YAC5FM,KAAKA;YACLW,UAAUZ,MAAMY,QAAQ;YACxBC,IAAIV;YACJ,GAAGH,KAAK;QACV,IACA;YAAEM,aAAa;QAAM;QAEvBJ;IACF;AACF,EAAE;AAWK,+BAA+B,CAACF,OAAwBC;IAC7D;IAEA,MAAMc,2BAAuBlB,4CAAAA;IAC7B,MAAMmB,YAAYjB,2BAA2BC,OAAOC;IAEpD,+DAA+D,GAC/D,IAAIgB;IACJ,OAAQD,UAAUd,MAAM;QACtB,KAAK;YACHe,cAAAA,WAAAA,GAAc,OAAA,aAAA,CAAC1B,iCAAAA,EAAAA;YACf;QACF,KAAK;YACH0B,cAAAA,WAAAA,GAAc,OAAA,aAAA,CAACzB,gCAAAA,EAAAA;YACf;QACF,KAAK;YACHyB,cAAAA,WAAAA,GAAc,OAAA,aAAA,CAACvB,yBAAAA,EAAAA;YACf;QACF,KAAK;YACHuB,cAAAA,WAAAA,GAAc,OAAA,aAAA,CAACxB,sBAAAA,EAAAA;YACf;IACJ;IAEA,OAAO;QACL,GAAGuB,SAAS;QACZP,OAAOb,oBAAAA,CAAKS,QAAQ,CAACL,MAAMS,KAAK,EAAE;YAChCS,cAAc;gBAAEN,UAAUK;YAAY;YACtCP,iBAAiB,CAAC,CAACM,UAAUd,MAAM;YACnCI,aAAa;QACf;QACAS;IACF;AACF,EAAE"}
@@ -18,6 +18,9 @@ _export(exports, {
18
18
  toasterClassNames: function() {
19
19
  return _useToasterStylesstyles.toasterClassNames;
20
20
  },
21
+ useToastAnnounce: function() {
22
+ return _useToastAnnounce.useToastAnnounce;
23
+ },
21
24
  useToasterStyles_unstable: function() {
22
25
  return _useToasterStylesstyles.useToasterStyles_unstable;
23
26
  },
@@ -29,3 +32,4 @@ const _Toaster = require("./Toaster");
29
32
  const _renderToaster = require("./renderToaster");
30
33
  const _useToaster = require("./useToaster");
31
34
  const _useToasterStylesstyles = require("./useToasterStyles.styles");
35
+ const _useToastAnnounce = require("./useToastAnnounce");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Toaster/index.ts"],"sourcesContent":["export { Toaster } from './Toaster';\nexport type { ToasterProps, ToasterSlots, ToasterSlotsInternal, ToasterState } from './Toaster.types';\nexport { renderToaster_unstable } from './renderToaster';\nexport { useToaster_unstable } from './useToaster';\nexport { toasterClassNames, useToasterStyles_unstable } from './useToasterStyles.styles';\n"],"names":["Toaster","renderToaster_unstable","useToaster_unstable","toasterClassNames","useToasterStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,gBAAO;;;eAEPC,qCAAsB;;;eAEtBE,yCAAiB;;;eAAEC,iDAAyB;;;eAD5CF,+BAAmB;;;yBAHJ,YAAY;+BAEG,kBAAkB;4BACrB,eAAe;wCACU,4BAA4B"}
1
+ {"version":3,"sources":["../src/components/Toaster/index.ts"],"sourcesContent":["export { Toaster } from './Toaster';\nexport type { ToasterProps, ToasterSlots, ToasterSlotsInternal, ToasterState } from './Toaster.types';\nexport { renderToaster_unstable } from './renderToaster';\nexport { useToaster_unstable } from './useToaster';\nexport { toasterClassNames, useToasterStyles_unstable } from './useToasterStyles.styles';\nexport { useToastAnnounce } from './useToastAnnounce';\n"],"names":["Toaster","renderToaster_unstable","useToaster_unstable","toasterClassNames","useToasterStyles_unstable","useToastAnnounce"],"mappings":";;;;;;;;;;;;eAASA,gBAAO;;;eAEPC,qCAAsB;;;eAEtBE,yCAAiB;;;eACjBE,kCAAgB;;;eADGD,iDAAyB;;;eAD5CF,+BAAmB;;;yBAHJ,YAAY;+BAEG,kBAAkB;4BACrB,eAAe;wCACU,4BAA4B;kCACxD,qBAAqB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Toaster/useToastAnnounce.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { Announce } from '../AriaLive';\nimport { isHTMLElement } from '@fluentui/react-utilities';\n\n/**\n * Wraps an aria live announcement function.\n * Aria live announcements can be detrimental once the user is already navigating\n * multiple toasts. Once the user is focused inside the toaster, the announecments should be disabled.\n * @param announce\n * @returns A function to announce a toast and a ref to attach to the toaster element\n */\nexport function useToastAnnounce(announce: Announce): {\n announceToast: Announce;\n toasterRef: React.RefCallback<HTMLDivElement>;\n} {\n const activeRef = React.useRef(true);\n const cleanupRef = React.useRef<() => void>(() => undefined);\n const announceToast = React.useCallback<Announce>(\n (message, options) => {\n if (activeRef.current) {\n announce(message, options);\n }\n },\n [announce],\n );\n\n const toasterRef = React.useCallback((el: HTMLDivElement | null) => {\n if (!el) {\n cleanupRef.current();\n return;\n }\n\n const onFocusIn = (e: FocusEvent) => {\n if (\n isHTMLElement(e.currentTarget) &&\n e.currentTarget.contains(isHTMLElement(e.relatedTarget) ? e.relatedTarget : null)\n ) {\n return;\n }\n\n activeRef.current = false;\n };\n\n const onFocusOut = (e: FocusEvent) => {\n if (\n isHTMLElement(e.currentTarget) &&\n e.currentTarget.contains(isHTMLElement(e.relatedTarget) ? e.relatedTarget : null)\n ) {\n return;\n }\n\n activeRef.current = true;\n };\n\n el.addEventListener('focusin', onFocusIn);\n el.addEventListener('focusout', onFocusOut);\n\n cleanupRef.current = () => {\n el.removeEventListener('focusin', onFocusIn);\n el.removeEventListener('focusout', onFocusOut);\n };\n }, []);\n\n return {\n announceToast,\n toasterRef,\n };\n}\n"],"names":["React","isHTMLElement","useToastAnnounce","announce","activeRef","useRef","cleanupRef","undefined","announceToast","useCallback","message","options","current","toasterRef","el","onFocusIn","e","currentTarget","contains","relatedTarget","onFocusOut","addEventListener","removeEventListener"],"mappings":"AAAA;;;;;+BAagBE;;;;;;;iEAXO,QAAQ;gCAED,4BAA4B;AASnD,0BAA0BC,QAAkB;IAIjD,MAAMC,YAAYJ,OAAMK,MAAM,CAAC;IAC/B,MAAMC,aAAaN,OAAMK,MAAM,CAAa,IAAME;IAClD,MAAMC,gBAAgBR,OAAMS,WAAW,CACrC,CAACC,SAASC;QACR,IAAIP,UAAUQ,OAAO,EAAE;YACrBT,SAASO,SAASC;QACpB;IACF,GACA;QAACR;KAAS;IAGZ,MAAMU,aAAab,OAAMS,WAAW,CAAC,CAACK;QACpC,IAAI,CAACA,IAAI;YACPR,WAAWM,OAAO;YAClB;QACF;QAEA,MAAMG,YAAY,CAACC;YACjB,QACEf,6BAAAA,EAAce,EAAEC,aAAa,KAC7BD,EAAEC,aAAa,CAACC,QAAQ,KAACjB,6BAAAA,EAAce,EAAEG,aAAa,IAAIH,EAAEG,aAAa,GAAG,OAC5E;gBACA;YACF;YAEAf,UAAUQ,OAAO,GAAG;QACtB;QAEA,MAAMQ,aAAa,CAACJ;YAClB,QACEf,6BAAAA,EAAce,EAAEC,aAAa,KAC7BD,EAAEC,aAAa,CAACC,QAAQ,CAACjB,iCAAAA,EAAce,EAAEG,aAAa,IAAIH,EAAEG,aAAa,GAAG,OAC5E;gBACA;YACF;YAEAf,UAAUQ,OAAO,GAAG;QACtB;QAEAE,GAAGO,gBAAgB,CAAC,WAAWN;QAC/BD,GAAGO,gBAAgB,CAAC,YAAYD;QAEhCd,WAAWM,OAAO,GAAG;YACnBE,GAAGQ,mBAAmB,CAAC,WAAWP;YAClCD,GAAGQ,mBAAmB,CAAC,YAAYF;QACrC;IACF,GAAG,EAAE;IAEL,OAAO;QACLZ;QACAK;IACF;AACF"}
1
+ {"version":3,"sources":["../src/components/Toaster/useToastAnnounce.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { Announce } from '../AriaLive';\nimport { isHTMLElement } from '@fluentui/react-utilities';\n\n/**\n * Wraps an aria live announcement function.\n * Aria live announcements can be detrimental once the user is already navigating\n * multiple toasts. Once the user is focused inside the toaster, the announecments should be disabled.\n * @param announce - The aria live announcement function to wrap\n * @returns A function to announce a toast and a ref to attach to the toaster element\n */\nexport function useToastAnnounce(announce: Announce): {\n announceToast: Announce;\n toasterRef: React.RefCallback<HTMLDivElement>;\n} {\n const activeRef = React.useRef(true);\n const cleanupRef = React.useRef<() => void>(() => undefined);\n const announceToast = React.useCallback<Announce>(\n (message, options) => {\n if (activeRef.current) {\n announce(message, options);\n }\n },\n [announce],\n );\n\n const toasterRef = React.useCallback((el: HTMLDivElement | null) => {\n if (!el) {\n cleanupRef.current();\n return;\n }\n\n const onFocusIn = (e: FocusEvent) => {\n if (\n isHTMLElement(e.currentTarget) &&\n e.currentTarget.contains(isHTMLElement(e.relatedTarget) ? e.relatedTarget : null)\n ) {\n return;\n }\n\n activeRef.current = false;\n };\n\n const onFocusOut = (e: FocusEvent) => {\n if (\n isHTMLElement(e.currentTarget) &&\n e.currentTarget.contains(isHTMLElement(e.relatedTarget) ? e.relatedTarget : null)\n ) {\n return;\n }\n\n activeRef.current = true;\n };\n\n el.addEventListener('focusin', onFocusIn);\n el.addEventListener('focusout', onFocusOut);\n\n cleanupRef.current = () => {\n el.removeEventListener('focusin', onFocusIn);\n el.removeEventListener('focusout', onFocusOut);\n };\n }, []);\n\n return {\n announceToast,\n toasterRef,\n };\n}\n"],"names":["React","isHTMLElement","useToastAnnounce","announce","activeRef","useRef","cleanupRef","undefined","announceToast","useCallback","message","options","current","toasterRef","el","onFocusIn","e","currentTarget","contains","relatedTarget","onFocusOut","addEventListener","removeEventListener"],"mappings":"AAAA;;;;;+BAagBE;;;;;;;iEAXO,QAAQ;gCAED,4BAA4B;AASnD,0BAA0BC,QAAkB;IAIjD,MAAMC,YAAYJ,OAAMK,MAAM,CAAC;IAC/B,MAAMC,aAAaN,OAAMK,MAAM,CAAa,IAAME;IAClD,MAAMC,gBAAgBR,OAAMS,WAAW,CACrC,CAACC,SAASC;QACR,IAAIP,UAAUQ,OAAO,EAAE;YACrBT,SAASO,SAASC;QACpB;IACF,GACA;QAACR;KAAS;IAGZ,MAAMU,aAAab,OAAMS,WAAW,CAAC,CAACK;QACpC,IAAI,CAACA,IAAI;YACPR,WAAWM,OAAO;YAClB;QACF;QAEA,MAAMG,YAAY,CAACC;YACjB,QACEf,6BAAAA,EAAce,EAAEC,aAAa,KAC7BD,EAAEC,aAAa,CAACC,QAAQ,KAACjB,6BAAAA,EAAce,EAAEG,aAAa,IAAIH,EAAEG,aAAa,GAAG,OAC5E;gBACA;YACF;YAEAf,UAAUQ,OAAO,GAAG;QACtB;QAEA,MAAMQ,aAAa,CAACJ;YAClB,QACEf,6BAAAA,EAAce,EAAEC,aAAa,KAC7BD,EAAEC,aAAa,CAACC,QAAQ,CAACjB,iCAAAA,EAAce,EAAEG,aAAa,IAAIH,EAAEG,aAAa,GAAG,OAC5E;gBACA;YACF;YAEAf,UAAUQ,OAAO,GAAG;QACtB;QAEAE,GAAGO,gBAAgB,CAAC,WAAWN;QAC/BD,GAAGO,gBAAgB,CAAC,YAAYD;QAEhCd,WAAWM,OAAO,GAAG;YACnBE,GAAGQ,mBAAmB,CAAC,WAAWP;YAClCD,GAAGQ,mBAAmB,CAAC,YAAYF;QACrC;IACF,GAAG,EAAE;IAEL,OAAO;QACLZ;QACAK;IACF;AACF"}
@@ -15,6 +15,9 @@ _export(exports, {
15
15
  ToastBody: function() {
16
16
  return _ToastBody.ToastBody;
17
17
  },
18
+ ToastContainerContextProvider: function() {
19
+ return _toastContainerContext.ToastContainerContextProvider;
20
+ },
18
21
  ToastFooter: function() {
19
22
  return _ToastFooter.ToastFooter;
20
23
  },
@@ -30,6 +33,9 @@ _export(exports, {
30
33
  renderToastBody_unstable: function() {
31
34
  return _ToastBody.renderToastBody_unstable;
32
35
  },
36
+ renderToastContainer_unstable: function() {
37
+ return _ToastContainer.renderToastContainer_unstable;
38
+ },
33
39
  renderToastFooter_unstable: function() {
34
40
  return _ToastFooter.renderToastFooter_unstable;
35
41
  },
@@ -63,12 +69,30 @@ _export(exports, {
63
69
  toasterClassNames: function() {
64
70
  return _Toaster.toasterClassNames;
65
71
  },
72
+ useToastAnnounce: function() {
73
+ return _Toaster.useToastAnnounce;
74
+ },
75
+ useToastBase_unstable: function() {
76
+ return _Toast.useToastBase_unstable;
77
+ },
78
+ useToastBodyBase_unstable: function() {
79
+ return _ToastBody.useToastBodyBase_unstable;
80
+ },
66
81
  useToastBodyStyles_unstable: function() {
67
82
  return _ToastBody.useToastBodyStyles_unstable;
68
83
  },
69
84
  useToastBody_unstable: function() {
70
85
  return _ToastBody.useToastBody_unstable;
71
86
  },
87
+ useToastContainerContext: function() {
88
+ return _toastContainerContext.useToastContainerContext;
89
+ },
90
+ useToastContainerContextValues_unstable: function() {
91
+ return _ToastContainer.useToastContainerContextValues_unstable;
92
+ },
93
+ useToastContainer_unstable: function() {
94
+ return _ToastContainer.useToastContainer_unstable;
95
+ },
72
96
  useToastController: function() {
73
97
  return _state.useToastController;
74
98
  },
@@ -81,6 +105,9 @@ _export(exports, {
81
105
  useToastStyles_unstable: function() {
82
106
  return _Toast.useToastStyles_unstable;
83
107
  },
108
+ useToastTitleBase_unstable: function() {
109
+ return _ToastTitle.useToastTitleBase_unstable;
110
+ },
84
111
  useToastTitleStyles_unstable: function() {
85
112
  return _ToastTitle.useToastTitleStyles_unstable;
86
113
  },
@@ -93,6 +120,9 @@ _export(exports, {
93
120
  useToast_unstable: function() {
94
121
  return _Toast.useToast_unstable;
95
122
  },
123
+ useToaster: function() {
124
+ return _state.useToaster;
125
+ },
96
126
  useToasterStyles_unstable: function() {
97
127
  return _Toaster.useToasterStyles_unstable;
98
128
  },
@@ -107,4 +137,5 @@ const _Toast = require("./Toast");
107
137
  const _ToastTitle = require("./ToastTitle");
108
138
  const _ToastBody = require("./ToastBody");
109
139
  const _ToastFooter = require("./ToastFooter");
140
+ const _toastContainerContext = require("./contexts/toastContainerContext");
110
141
  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\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"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { useToastController, useToaster } from './state';\nexport type {\n Announce as ToastAnnounce,\n AnnounceOptions as ToastAnnounceOptions,\n LiveMessage as ToastLiveMessage,\n} from './AriaLive';\nexport type {\n ToastPosition,\n ToastId,\n ToastOffset,\n ToastPoliteness,\n ToastStatus,\n ToastIntent,\n ToasterId,\n ToasterOptions,\n ToasterShortcuts,\n ToastImperativeRef,\n Toast as ToastData,\n ToastChangeData,\n ToastChangeHandler,\n ToastOptions,\n DispatchToastOptions as ToastDispatchOptions,\n UpdateToastOptions as ToastUpdateOptions,\n UpdateToastEventDetail as ToastUpdateEventDetail,\n} 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 useToastAnnounce,\n} from './Toaster';\nexport type { ToasterProps, ToasterState, ToasterSlots } from './Toaster';\nexport {\n Toast,\n useToastStyles_unstable,\n useToastBase_unstable,\n useToast_unstable,\n renderToast_unstable,\n toastClassNames,\n} from './Toast';\nexport type { ToastBaseProps, ToastBaseState, ToastProps, ToastState, ToastSlots } from './Toast';\n\nexport {\n ToastTitle,\n useToastTitleStyles_unstable,\n useToastTitleBase_unstable,\n useToastTitle_unstable,\n renderToastTitle_unstable,\n toastTitleClassNames,\n} from './ToastTitle';\nexport type {\n ToastTitleBaseProps,\n ToastTitleBaseState,\n ToastTitleProps,\n ToastTitleState,\n ToastTitleSlots,\n} from './ToastTitle';\n\nexport {\n ToastBody,\n useToastBodyStyles_unstable,\n useToastBodyBase_unstable,\n useToastBody_unstable,\n renderToastBody_unstable,\n toastBodyClassNames,\n} from './ToastBody';\nexport type {\n ToastBodyBaseProps,\n ToastBodyBaseState,\n ToastBodyProps,\n ToastBodyState,\n ToastBodySlots,\n} 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 type { ToastContainerContextValue } from './contexts/toastContainerContext';\nexport { ToastContainerContextProvider, useToastContainerContext } from './contexts/toastContainerContext';\nexport { toastContainerClassNames } from './ToastContainer';\nexport type { ToastContainerSlots, ToastContainerProps, ToastContainerState } from './ToastContainer';\nexport {\n useToastContainer_unstable,\n renderToastContainer_unstable,\n useToastContainerContextValues_unstable,\n} from './ToastContainer';\n"],"names":["useToastController","useToaster","ToastTrigger","useToastTrigger_unstable","renderToastTrigger_unstable","Toaster","useToaster_unstable","useToasterStyles_unstable","renderToaster_unstable","toasterClassNames","useToastAnnounce","Toast","useToastStyles_unstable","useToastBase_unstable","useToast_unstable","renderToast_unstable","toastClassNames","ToastTitle","useToastTitleStyles_unstable","useToastTitleBase_unstable","useToastTitle_unstable","renderToastTitle_unstable","toastTitleClassNames","ToastBody","useToastBodyStyles_unstable","useToastBodyBase_unstable","useToastBody_unstable","renderToastBody_unstable","toastBodyClassNames","ToastFooter","useToastFooterStyles_unstable","useToastFooter_unstable","renderToastFooter_unstable","toastFooterClassNames","ToastContainerContextProvider","useToastContainerContext","toastContainerClassNames","useToastContainer_unstable","renderToastContainer_unstable","useToastContainerContextValues_unstable"],"mappings":";;;;;;;;;;;;eAsCEW,YAAK;;aA0BI;eAATY;;iCAyBoC;eAA7BW;;IATPL,WAAW;;;;eAhCXZ,sBAAU;;;eAtBHf,0BAAY;;;eAGnBG,gBAAO;;;eAuCPsB,mCAAwB;;;eA0BxBW,6CAA6B;;;eAX7BN,uCAA0B;;;eA/B1BX,qCAAyB;;+BA1BiD;eAA3BjB;;;eAgB/CW,2BAAoB;;;eAVpBP,+BAAsB;;IAqCtBoB;6CAAmB;;;eA1BnBZ,sBAAe;;;eA+CRoB,wCAAwB;;yBANV;eAArBH;;;eA/BAX,gCAAoB;;qBApBH;eAAjBb;;IACAC,gBAAgB;;;;eAMhBG,4BAAqB;;;eA0BrBY,oCAAyB;;;eADzBD,sCAA2B;;;eAE3BE,gCAAqB;;IAsBiBS,wBAAwB;;;;eAM9DI,uDAAuC,QAClC,mBAAmB;;IAHxBF;yDAA0B;;;eA7FnBrC,yBAAkB;;;eAiFzB8B,0CAA6B;;;eAC7BC,oCAAuB;;;eA3CvBnB,8BAAuB;;;eAWvBO,sCAA0B;;IAD1BD,4BAA4B;;;;eAE5BE,kCAAsB;;;eAzBDjB,sCAAwB;;;eAe7CW,wBAAiB;;;eAzCUb,iBAAU;;;eA+BrCM,kCAAyB;;;eADzBD,4BAAmB;;;uBA9B0B,UAAU;8BA0B2B,iBAAiB;yBAS9F,YAAY;uBASZ,UAAU;4BAUV,eAAe;2BAgBf,cAAc;6BAed,gBAAgB;uCAIiD,mCAAmC;gCAClE,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/state/types.ts"],"sourcesContent":["import type { Slot } from '@fluentui/react-utilities';\nimport type { EVENTS } from './constants';\nimport type * as React from 'react';\n\nexport type ToastId = string;\nexport type ToasterId = string;\n\nexport type ToastPosition = 'top-end' | 'top-start' | 'bottom-end' | 'bottom-start' | 'top' | 'bottom';\nexport type ToastPoliteness = 'assertive' | 'polite';\nexport type ToastStatus = 'queued' | 'visible' | 'dismissed' | 'unmounted';\nexport type ToastIntent = 'info' | 'success' | 'error' | 'warning';\nexport type ToastChangeHandler = (event: null, data: ToastChangeData) => void;\n\nexport interface ToastChangeData extends ToastOptions, Pick<Toast, 'updateId'> {\n status: ToastStatus;\n}\n\nexport interface ToastOptions<TData = object> {\n /**\n * Uniquely identifies a toast, used for update and dismiss operations\n */\n toastId: ToastId;\n /**\n * The position the toast should render to\n */\n position: ToastPosition;\n /**\n * Toast content\n */\n content: unknown;\n /**\n * Auto dismiss timeout in milliseconds\n * @default 3000\n */\n timeout: number;\n /**\n * Toast timeout pauses while focus is on another window\n * @default false\n */\n pauseOnWindowBlur: boolean;\n /**\n * Toast timeout pauses while user cursor is on the toast\n * @default false\n */\n pauseOnHover: boolean;\n /**\n * Toast belongs to a specific toaster\n */\n toasterId: ToasterId | undefined;\n /**\n * Higher priority toasts will be rendered before lower priority toasts\n */\n priority: number;\n /**\n * Used to determine [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) narration\n * This will override the intent prop\n */\n politeness?: ToastPoliteness;\n\n /**\n * Default toast types that determine the urgency or [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) narration\n * The UI layer may use these intents to apply specific styling.\n * @default info\n */\n intent?: ToastIntent;\n /**\n * Additional data that needs to be passed to the toast\n */\n data: TData;\n\n /**\n * Reports changes to the Toast lifecycle\n */\n onStatusChange: ToastChangeHandler | undefined;\n}\n\nexport interface ToastOffsetObject {\n horizontal?: number;\n vertical?: number;\n}\n\nexport type ToastOffset = Partial<Record<ToastPosition, ToastOffsetObject>> | ToastOffsetObject;\n\nexport interface ToasterShortcuts {\n focus: (e: KeyboardEvent) => boolean;\n}\n\nexport interface ToasterOptions\n extends Pick<ToastOptions, 'position' | 'timeout' | 'pauseOnWindowBlur' | 'pauseOnHover' | 'priority'> {\n offset?: ToastOffset;\n toasterId?: ToasterId;\n limit?: number;\n shortcuts?: ToasterShortcuts;\n}\n\nexport interface Toast<TData = object> extends ToastOptions<TData> {\n /**\n * Determines the visiblity of a toast\n */\n close: () => void;\n /**\n * Removes a toast completely\n */\n remove: () => void;\n /**\n * A number used to track updates immutably\n */\n updateId: number;\n /**\n * Used to determine default priority when the user does not set one\n * Simple counter of toasts dispatched.\n */\n order: number;\n\n imperativeRef: React.RefObject<ToastImperativeRef | null>;\n}\n\nexport interface CommonToastDetail {\n toasterId?: ToasterId;\n}\n\nexport interface ShowToastEventDetail extends Partial<ToastOptions>, CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface UpdateToastEventDetail extends Partial<ToastOptions>, CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface DismissToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface PauseToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface PlayToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface DismissAllToastsEventDetail extends CommonToastDetail {}\n\ntype EventListener<TDetail> = (e: CustomEvent<TDetail>) => void;\n\nexport type ToastListenerMap = {\n [EVENTS.show]: EventListener<ShowToastEventDetail>;\n [EVENTS.dismiss]: EventListener<DismissToastEventDetail>;\n [EVENTS.dismissAll]: EventListener<DismissAllToastsEventDetail>;\n [EVENTS.update]: EventListener<UpdateToastEventDetail>;\n [EVENTS.play]: EventListener<PlayToastEventDetail>;\n [EVENTS.pause]: EventListener<PauseToastEventDetail>;\n};\n\ntype RootSlot = Slot<'div'>;\n\nexport interface DispatchToastOptions extends Partial<Omit<ToastOptions, 'toasterId'>> {\n root?: RootSlot;\n}\n\nexport interface UpdateToastOptions extends UpdateToastEventDetail {\n root?: RootSlot;\n}\n\nexport type ToastImperativeRef = {\n /**\n * Focuses the Toast.\n * If there are no focusable elements in the Toast, the Toast itself is focused.\n */\n focus: () => void;\n\n /**\n * Resumes the timeout of a paused toast\n */\n play: () => void;\n\n /**\n * Pauses the timeout of a toast\n */\n pause: () => void;\n};\n"],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../src/state/types.ts"],"sourcesContent":["import type { Slot } from '@fluentui/react-utilities';\nimport type { EVENTS } from './constants';\nimport type * as React from 'react';\n\nexport type ToastId = string;\nexport type ToasterId = string;\n\nexport type ToastPosition = 'top-end' | 'top-start' | 'bottom-end' | 'bottom-start' | 'top' | 'bottom';\nexport type ToastPoliteness = 'assertive' | 'polite';\nexport type ToastStatus = 'queued' | 'visible' | 'dismissed' | 'unmounted';\nexport type ToastIntent = 'info' | 'success' | 'error' | 'warning';\nexport type ToastChangeHandler = (event: null, data: ToastChangeData) => void;\n\nexport interface ToastChangeData extends ToastOptions, Pick<Toast, 'updateId'> {\n status: ToastStatus;\n}\n\nexport interface ToastOptions<TData = object> {\n /**\n * Uniquely identifies a toast, used for update and dismiss operations\n */\n toastId: ToastId;\n /**\n * The position the toast should render to\n */\n position: ToastPosition;\n /**\n * Toast content\n */\n content: unknown;\n /**\n * Auto dismiss timeout in milliseconds\n * @default 3000\n */\n timeout: number;\n /**\n * Toast timeout pauses while focus is on another window\n * @default false\n */\n pauseOnWindowBlur: boolean;\n /**\n * Toast timeout pauses while user cursor is on the toast\n * @default false\n */\n pauseOnHover: boolean;\n /**\n * Toast belongs to a specific toaster\n */\n toasterId: ToasterId | undefined;\n /**\n * Higher priority toasts will be rendered before lower priority toasts\n */\n priority: number;\n /**\n * Used to determine [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) narration\n * This will override the intent prop\n */\n politeness?: ToastPoliteness;\n\n /**\n * Default toast types that determine the urgency or [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) narration\n * The UI layer may use these intents to apply specific styling.\n * @default info\n */\n intent?: ToastIntent;\n /**\n * Additional data that needs to be passed to the toast\n */\n data: TData;\n\n /**\n * Reports changes to the Toast lifecycle\n */\n onStatusChange: ToastChangeHandler | undefined;\n}\n\nexport interface ToastOffsetObject {\n horizontal?: number;\n vertical?: number;\n}\n\nexport type ToastOffset = Partial<Record<ToastPosition, ToastOffsetObject>> | ToastOffsetObject;\n\nexport interface ToasterShortcuts {\n focus: (e: KeyboardEvent) => boolean;\n}\n\nexport interface ToasterOptions\n extends Pick<ToastOptions, 'position' | 'timeout' | 'pauseOnWindowBlur' | 'pauseOnHover' | 'priority'> {\n offset?: ToastOffset;\n toasterId?: ToasterId;\n limit?: number;\n shortcuts?: ToasterShortcuts;\n}\n\nexport interface Toast<TData = object> extends ToastOptions<TData> {\n /**\n * Determines the visiblity of a toast\n */\n close: () => void;\n /**\n * Removes a toast completely\n */\n remove: () => void;\n /**\n * A number used to track updates immutably\n */\n updateId: number;\n /**\n * Used to determine default priority when the user does not set one\n * Simple counter of toasts dispatched.\n */\n order: number;\n\n imperativeRef: React.RefObject<ToastImperativeRef | null>;\n}\n\nexport interface CommonToastDetail {\n toasterId?: ToasterId;\n}\n\nexport interface ShowToastEventDetail extends Partial<ToastOptions>, CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface UpdateToastEventDetail extends Partial<ToastOptions>, CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface DismissToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface PauseToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface PlayToastEventDetail extends CommonToastDetail {\n toastId: ToastId;\n}\n\nexport interface DismissAllToastsEventDetail extends CommonToastDetail {}\n\ntype EventListener<TDetail> = (e: CustomEvent<TDetail>) => void;\n\nexport type ToastListenerMap = {\n [EVENTS.show]: EventListener<ShowToastEventDetail>;\n [EVENTS.dismiss]: EventListener<DismissToastEventDetail>;\n [EVENTS.dismissAll]: EventListener<DismissAllToastsEventDetail>;\n [EVENTS.update]: EventListener<UpdateToastEventDetail>;\n [EVENTS.play]: EventListener<PlayToastEventDetail>;\n [EVENTS.pause]: EventListener<PauseToastEventDetail>;\n};\n\nexport interface DispatchToastOptions extends Partial<Omit<ToastOptions, 'toasterId'>> {\n root?: Slot<'div'>;\n}\n\nexport interface UpdateToastOptions extends UpdateToastEventDetail {\n root?: Slot<'div'>;\n}\n\nexport type ToastImperativeRef = {\n /**\n * Focuses the Toast.\n * If there are no focusable elements in the Toast, the Toast itself is focused.\n */\n focus: () => void;\n\n /**\n * Resumes the timeout of a paused toast\n */\n play: () => void;\n\n /**\n * Pauses the timeout of a toast\n */\n pause: () => void;\n};\n"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-toast",
3
- "version": "9.7.18",
3
+ "version": "9.8.0",
4
4
  "description": "Toast component for Fluent UI",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",