@fluentui/react-dialog 9.11.8 → 9.11.9

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,9 +1,18 @@
1
1
  # Change Log - @fluentui/react-dialog
2
2
 
3
- This log was last generated on Tue, 23 Jul 2024 20:13:11 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 06 Aug 2024 21:39:52 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.11.9](https://github.com/microsoft/fluentui/tree/@fluentui/react-dialog_v9.11.9)
8
+
9
+ Tue, 06 Aug 2024 21:39:52 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-dialog_v9.11.6..@fluentui/react-dialog_v9.11.9)
11
+
12
+ ### Patches
13
+
14
+ - fix: do not require ref forwarding ([PR #32095](https://github.com/microsoft/fluentui/pull/32095) by olfedias@microsoft.com)
15
+
7
16
  ## [9.11.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-dialog_v9.11.6)
8
17
 
9
18
  Tue, 23 Jul 2024 20:13:11 GMT
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
2
  import { assertSlots } from '@fluentui/react-utilities';
3
3
  import * as React from 'react';
4
+ import { MotionRefForwarder } from '../MotionRefForwarder';
4
5
  import { DialogProvider, DialogSurfaceProvider } from '../../contexts';
5
6
  /**
6
7
  * Render the final JSX of Dialog
@@ -13,7 +14,9 @@ import { DialogProvider, DialogSurfaceProvider } from '../../contexts';
13
14
  children: [
14
15
  state.trigger,
15
16
  state.content && /*#__PURE__*/ _jsx(state.surfaceMotion, {
16
- children: state.content
17
+ children: /*#__PURE__*/ _jsx(MotionRefForwarder, {
18
+ children: state.content
19
+ })
17
20
  })
18
21
  ]
19
22
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["renderDialog.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { DialogProvider, DialogSurfaceProvider } from '../../contexts';\nimport type { DialogState, DialogContextValues, DialogSlots } from './Dialog.types';\n\n/**\n * Render the final JSX of Dialog\n */\nexport const renderDialog_unstable = (state: DialogState, contextValues: DialogContextValues) => {\n assertSlots<DialogSlots>(state);\n\n return (\n <DialogProvider value={contextValues.dialog}>\n <DialogSurfaceProvider value={contextValues.dialogSurface}>\n {state.trigger}\n {state.content && (\n <state.surfaceMotion>\n {/* Casting here as content should be equivalent to <DialogSurface/> */}\n {/* FIXME: content should not be ReactNode it should be ReactElement instead. */}\n {state.content as React.ReactElement}\n </state.surfaceMotion>\n )}\n </DialogSurfaceProvider>\n </DialogProvider>\n );\n};\n"],"names":["assertSlots","React","DialogProvider","DialogSurfaceProvider","renderDialog_unstable","state","contextValues","value","dialog","dialogSurface","trigger","content","surfaceMotion"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AACxD,YAAYC,WAAW,QAAQ;AAE/B,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,iBAAiB;AAGvE;;CAEC,GACD,OAAO,MAAMC,wBAAwB,CAACC,OAAoBC;IACxDN,YAAyBK;IAEzB,qBACE,KAACH;QAAeK,OAAOD,cAAcE,MAAM;kBACzC,cAAA,MAACL;YAAsBI,OAAOD,cAAcG,aAAa;;gBACtDJ,MAAMK,OAAO;gBACbL,MAAMM,OAAO,kBACZ,KAACN,MAAMO,aAAa;8BAGjBP,MAAMM,OAAO;;;;;AAM1B,EAAE"}
1
+ {"version":3,"sources":["renderDialog.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { MotionRefForwarder } from '../MotionRefForwarder';\nimport { DialogProvider, DialogSurfaceProvider } from '../../contexts';\nimport type { DialogState, DialogContextValues, DialogSlots } from './Dialog.types';\n\n/**\n * Render the final JSX of Dialog\n */\nexport const renderDialog_unstable = (state: DialogState, contextValues: DialogContextValues) => {\n assertSlots<DialogSlots>(state);\n\n return (\n <DialogProvider value={contextValues.dialog}>\n <DialogSurfaceProvider value={contextValues.dialogSurface}>\n {state.trigger}\n {state.content && (\n <state.surfaceMotion>\n <MotionRefForwarder>\n {/* Casting here as content should be equivalent to <DialogSurface/> */}\n {/* FIXME: content should not be ReactNode it should be ReactElement instead. */}\n {state.content as React.ReactElement}\n </MotionRefForwarder>\n </state.surfaceMotion>\n )}\n </DialogSurfaceProvider>\n </DialogProvider>\n );\n};\n"],"names":["assertSlots","React","MotionRefForwarder","DialogProvider","DialogSurfaceProvider","renderDialog_unstable","state","contextValues","value","dialog","dialogSurface","trigger","content","surfaceMotion"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AACxD,YAAYC,WAAW,QAAQ;AAE/B,SAASC,kBAAkB,QAAQ,wBAAwB;AAC3D,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,iBAAiB;AAGvE;;CAEC,GACD,OAAO,MAAMC,wBAAwB,CAACC,OAAoBC;IACxDP,YAAyBM;IAEzB,qBACE,KAACH;QAAeK,OAAOD,cAAcE,MAAM;kBACzC,cAAA,MAACL;YAAsBI,OAAOD,cAAcG,aAAa;;gBACtDJ,MAAMK,OAAO;gBACbL,MAAMM,OAAO,kBACZ,KAACN,MAAMO,aAAa;8BAClB,cAAA,KAACX;kCAGEI,MAAMM,OAAO;;;;;;AAO5B,EAAE"}
@@ -5,6 +5,7 @@ import * as React from 'react';
5
5
  import { useDialogContext_unstable } from '../../contexts';
6
6
  import { useDisableBodyScroll } from '../../utils/useDisableBodyScroll';
7
7
  import { DialogBackdropMotion } from '../DialogBackdropMotion';
8
+ import { useMotionForwardedRef } from '../MotionRefForwarder';
8
9
  /**
9
10
  * Create the state required to render DialogSurface.
10
11
  *
@@ -14,6 +15,7 @@ import { DialogBackdropMotion } from '../DialogBackdropMotion';
14
15
  * @param props - props from this instance of DialogSurface
15
16
  * @param ref - reference to root HTMLElement of DialogSurface
16
17
  */ export const useDialogSurface_unstable = (props, ref)=>{
18
+ const contextRef = useMotionForwardedRef();
17
19
  const modalType = useDialogContext_unstable((ctx)=>ctx.modalType);
18
20
  const isNestedDialog = useDialogContext_unstable((ctx)=>ctx.isNestedDialog);
19
21
  const modalAttributes = useDialogContext_unstable((ctx)=>ctx.modalAttributes);
@@ -98,7 +100,7 @@ import { DialogBackdropMotion } from '../DialogBackdropMotion';
98
100
  // FIXME:
99
101
  // `DialogSurfaceElement` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`
100
102
  // but since it would be a breaking change to fix it, we are casting ref to it's proper type
101
- ref: useMergedRefs(ref, dialogRef)
103
+ ref: useMergedRefs(ref, contextRef, dialogRef)
102
104
  }), {
103
105
  elementType: 'div'
104
106
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["useDialogSurface.ts"],"sourcesContent":["import { Escape } from '@fluentui/keyboard-keys';\nimport { presenceMotionSlot, type PresenceMotionSlotProps } from '@fluentui/react-motion';\nimport {\n useEventCallback,\n useMergedRefs,\n isResolvedShorthand,\n slot,\n getIntrinsicElementProps,\n useIsomorphicLayoutEffect,\n} from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useDialogContext_unstable } from '../../contexts';\nimport { useDisableBodyScroll } from '../../utils/useDisableBodyScroll';\nimport { DialogBackdropMotion } from '../DialogBackdropMotion';\nimport type { DialogSurfaceElement, DialogSurfaceProps, DialogSurfaceState } from './DialogSurface.types';\n\n/**\n * Create the state required to render DialogSurface.\n *\n * The returned state can be modified with hooks such as useDialogSurfaceStyles_unstable,\n * before being passed to renderDialogSurface_unstable.\n *\n * @param props - props from this instance of DialogSurface\n * @param ref - reference to root HTMLElement of DialogSurface\n */\nexport const useDialogSurface_unstable = (\n props: DialogSurfaceProps,\n ref: React.Ref<DialogSurfaceElement>,\n): DialogSurfaceState => {\n const modalType = useDialogContext_unstable(ctx => ctx.modalType);\n const isNestedDialog = useDialogContext_unstable(ctx => ctx.isNestedDialog);\n\n const modalAttributes = useDialogContext_unstable(ctx => ctx.modalAttributes);\n const dialogRef = useDialogContext_unstable(ctx => ctx.dialogRef);\n const requestOpenChange = useDialogContext_unstable(ctx => ctx.requestOpenChange);\n const dialogTitleID = useDialogContext_unstable(ctx => ctx.dialogTitleId);\n const open = useDialogContext_unstable(ctx => ctx.open);\n\n const handledBackdropClick = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {\n if (isResolvedShorthand(props.backdrop)) {\n props.backdrop.onClick?.(event);\n }\n if (modalType === 'modal' && !event.isDefaultPrevented()) {\n requestOpenChange({\n event,\n open: false,\n type: 'backdropClick',\n });\n }\n });\n\n const handleKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLDivElement>) => {\n props.onKeyDown?.(event);\n\n if (event.key === Escape && !event.isDefaultPrevented()) {\n requestOpenChange({\n event,\n open: false,\n type: 'escapeKeyDown',\n });\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: nested Dialog, Popover, Menu and Tooltip\n event.preventDefault();\n }\n });\n\n const backdrop = slot.optional(props.backdrop, {\n renderByDefault: modalType !== 'non-modal',\n defaultProps: {\n 'aria-hidden': 'true',\n },\n elementType: 'div',\n });\n if (backdrop) {\n backdrop.onClick = handledBackdropClick;\n }\n\n const { disableBodyScroll, enableBodyScroll } = useDisableBodyScroll();\n\n useIsomorphicLayoutEffect(() => {\n if (isNestedDialog || modalType === 'non-modal') {\n return;\n }\n\n disableBodyScroll();\n\n return () => {\n enableBodyScroll();\n };\n }, [enableBodyScroll, isNestedDialog, disableBodyScroll, modalType]);\n\n return {\n components: {\n backdrop: 'div',\n root: 'div',\n // TODO: remove once React v18 slot API is modified\n // This is a problem at the moment due to UnknownSlotProps assumption\n // that `children` property is `ReactNode`, which in this case is not valid\n // as PresenceComponentProps['children'] is `ReactElement`\n backdropMotion: DialogBackdropMotion as React.FC<PresenceMotionSlotProps>,\n },\n open,\n backdrop,\n isNestedDialog,\n mountNode: props.mountNode,\n root: slot.always(\n getIntrinsicElementProps('div', {\n tabIndex: -1, // https://github.com/microsoft/fluentui/issues/25150\n 'aria-modal': modalType !== 'non-modal',\n role: modalType === 'alert' ? 'alertdialog' : 'dialog',\n 'aria-labelledby': props['aria-label'] ? undefined : dialogTitleID,\n ...props,\n ...modalAttributes,\n onKeyDown: handleKeyDown,\n // FIXME:\n // `DialogSurfaceElement` 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: useMergedRefs(ref, dialogRef) as React.Ref<HTMLDivElement>,\n }),\n { elementType: 'div' },\n ),\n backdropMotion: presenceMotionSlot(props.backdropMotion, {\n elementType: DialogBackdropMotion,\n defaultProps: {\n appear: true,\n visible: open,\n },\n }),\n\n // Deprecated properties\n transitionStatus: undefined,\n };\n};\n"],"names":["Escape","presenceMotionSlot","useEventCallback","useMergedRefs","isResolvedShorthand","slot","getIntrinsicElementProps","useIsomorphicLayoutEffect","React","useDialogContext_unstable","useDisableBodyScroll","DialogBackdropMotion","useDialogSurface_unstable","props","ref","modalType","ctx","isNestedDialog","modalAttributes","dialogRef","requestOpenChange","dialogTitleID","dialogTitleId","open","handledBackdropClick","event","backdrop","onClick","isDefaultPrevented","type","handleKeyDown","onKeyDown","key","preventDefault","optional","renderByDefault","defaultProps","elementType","disableBodyScroll","enableBodyScroll","components","root","backdropMotion","mountNode","always","tabIndex","role","undefined","appear","visible","transitionStatus"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;gBACRC,SAAS1B;YACX;QACF;QAEA,wBAAwB;QACxB2B,kBAAkBH;IACpB;AACF,EAAE"}
1
+ {"version":3,"sources":["useDialogSurface.ts"],"sourcesContent":["import { Escape } from '@fluentui/keyboard-keys';\nimport { presenceMotionSlot, type PresenceMotionSlotProps } from '@fluentui/react-motion';\nimport {\n useEventCallback,\n useMergedRefs,\n isResolvedShorthand,\n slot,\n getIntrinsicElementProps,\n useIsomorphicLayoutEffect,\n} from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useDialogContext_unstable } from '../../contexts';\nimport { useDisableBodyScroll } from '../../utils/useDisableBodyScroll';\nimport { DialogBackdropMotion } from '../DialogBackdropMotion';\nimport { useMotionForwardedRef } from '../MotionRefForwarder';\nimport type { DialogSurfaceElement, DialogSurfaceProps, DialogSurfaceState } from './DialogSurface.types';\n\n/**\n * Create the state required to render DialogSurface.\n *\n * The returned state can be modified with hooks such as useDialogSurfaceStyles_unstable,\n * before being passed to renderDialogSurface_unstable.\n *\n * @param props - props from this instance of DialogSurface\n * @param ref - reference to root HTMLElement of DialogSurface\n */\nexport const useDialogSurface_unstable = (\n props: DialogSurfaceProps,\n ref: React.Ref<DialogSurfaceElement>,\n): DialogSurfaceState => {\n const contextRef = useMotionForwardedRef();\n\n const modalType = useDialogContext_unstable(ctx => ctx.modalType);\n const isNestedDialog = useDialogContext_unstable(ctx => ctx.isNestedDialog);\n\n const modalAttributes = useDialogContext_unstable(ctx => ctx.modalAttributes);\n const dialogRef = useDialogContext_unstable(ctx => ctx.dialogRef);\n const requestOpenChange = useDialogContext_unstable(ctx => ctx.requestOpenChange);\n const dialogTitleID = useDialogContext_unstable(ctx => ctx.dialogTitleId);\n const open = useDialogContext_unstable(ctx => ctx.open);\n\n const handledBackdropClick = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {\n if (isResolvedShorthand(props.backdrop)) {\n props.backdrop.onClick?.(event);\n }\n if (modalType === 'modal' && !event.isDefaultPrevented()) {\n requestOpenChange({\n event,\n open: false,\n type: 'backdropClick',\n });\n }\n });\n\n const handleKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLDivElement>) => {\n props.onKeyDown?.(event);\n\n if (event.key === Escape && !event.isDefaultPrevented()) {\n requestOpenChange({\n event,\n open: false,\n type: 'escapeKeyDown',\n });\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: nested Dialog, Popover, Menu and Tooltip\n event.preventDefault();\n }\n });\n\n const backdrop = slot.optional(props.backdrop, {\n renderByDefault: modalType !== 'non-modal',\n defaultProps: {\n 'aria-hidden': 'true',\n },\n elementType: 'div',\n });\n if (backdrop) {\n backdrop.onClick = handledBackdropClick;\n }\n\n const { disableBodyScroll, enableBodyScroll } = useDisableBodyScroll();\n\n useIsomorphicLayoutEffect(() => {\n if (isNestedDialog || modalType === 'non-modal') {\n return;\n }\n\n disableBodyScroll();\n\n return () => {\n enableBodyScroll();\n };\n }, [enableBodyScroll, isNestedDialog, disableBodyScroll, modalType]);\n\n return {\n components: {\n backdrop: 'div',\n root: 'div',\n // TODO: remove once React v18 slot API is modified\n // This is a problem at the moment due to UnknownSlotProps assumption\n // that `children` property is `ReactNode`, which in this case is not valid\n // as PresenceComponentProps['children'] is `ReactElement`\n backdropMotion: DialogBackdropMotion as React.FC<PresenceMotionSlotProps>,\n },\n open,\n backdrop,\n isNestedDialog,\n mountNode: props.mountNode,\n root: slot.always(\n getIntrinsicElementProps('div', {\n tabIndex: -1, // https://github.com/microsoft/fluentui/issues/25150\n 'aria-modal': modalType !== 'non-modal',\n role: modalType === 'alert' ? 'alertdialog' : 'dialog',\n 'aria-labelledby': props['aria-label'] ? undefined : dialogTitleID,\n ...props,\n ...modalAttributes,\n onKeyDown: handleKeyDown,\n // FIXME:\n // `DialogSurfaceElement` 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: useMergedRefs(ref, contextRef, dialogRef) as React.Ref<HTMLDivElement>,\n }),\n { elementType: 'div' },\n ),\n backdropMotion: presenceMotionSlot(props.backdropMotion, {\n elementType: DialogBackdropMotion,\n defaultProps: {\n appear: true,\n visible: open,\n },\n }),\n\n // Deprecated properties\n transitionStatus: undefined,\n };\n};\n"],"names":["Escape","presenceMotionSlot","useEventCallback","useMergedRefs","isResolvedShorthand","slot","getIntrinsicElementProps","useIsomorphicLayoutEffect","React","useDialogContext_unstable","useDisableBodyScroll","DialogBackdropMotion","useMotionForwardedRef","useDialogSurface_unstable","props","ref","contextRef","modalType","ctx","isNestedDialog","modalAttributes","dialogRef","requestOpenChange","dialogTitleID","dialogTitleId","open","handledBackdropClick","event","backdrop","onClick","isDefaultPrevented","type","handleKeyDown","onKeyDown","key","preventDefault","optional","renderByDefault","defaultProps","elementType","disableBodyScroll","enableBodyScroll","components","root","backdropMotion","mountNode","always","tabIndex","role","undefined","appear","visible","transitionStatus"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,MAAM,QAAQ,0BAA0B;AACjD,SAASC,kBAAkB,QAAsC,yBAAyB;AAC1F,SACEC,gBAAgB,EAChBC,aAAa,EACbC,mBAAmB,EACnBC,IAAI,EACJC,wBAAwB,EACxBC,yBAAyB,QACpB,4BAA4B;AACnC,YAAYC,WAAW,QAAQ;AAE/B,SAASC,yBAAyB,QAAQ,iBAAiB;AAC3D,SAASC,oBAAoB,QAAQ,mCAAmC;AACxE,SAASC,oBAAoB,QAAQ,0BAA0B;AAC/D,SAASC,qBAAqB,QAAQ,wBAAwB;AAG9D;;;;;;;;CAQC,GACD,OAAO,MAAMC,4BAA4B,CACvCC,OACAC;IAEA,MAAMC,aAAaJ;IAEnB,MAAMK,YAAYR,0BAA0BS,CAAAA,MAAOA,IAAID,SAAS;IAChE,MAAME,iBAAiBV,0BAA0BS,C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F,cAAc,aAAa;YAC/C;QACF;QAEAuB;QAEA,OAAO;YACLC;QACF;IACF,GAAG;QAACA;QAAkBtB;QAAgBqB;QAAmBvB;KAAU;IAEnE,OAAO;QACLyB,YAAY;YACVd,UAAU;YACVe,MAAM;YACN,mDAAmD;YACnD,qEAAqE;YACrE,2EAA2E;YAC3E,0DAA0D;YAC1DC,gBAAgBjC;QAClB;QACAc;QACAG;QACAT;QACA0B,WAAW/B,MAAM+B,SAAS;QAC1BF,MAAMtC,KAAKyC,MAAM,CACfxC,yBAAyB,OAAO;YAC9ByC,UAAU,CAAC;YACX,cAAc9B,cAAc;YAC5B+B,MAAM/B,cAAc,UAAU,gBAAgB;YAC9C,mBAAmBH,KAAK,CAAC,aAAa,GAAGmC,YAAY1B;YACrD,GAAGT,KAAK;YACR,GAAGM,eAAe;YAClBa,WAAWD;YACX,SAAS;YACT,6FAA6F;YAC7F,4FAA4F;YAC5FjB,KAAKZ,cAAcY,KAAKC,YAAYK;QACtC,IACA;YAAEkB,aAAa;QAAM;QAEvBK,gBAAgB3C,mBAAmBa,MAAM8B,cAAc,EAAE;YACvDL,aAAa5B;YACb2B,cAAc;gBACZY,QAAQ;gBACRC,SAAS1B;YACX;QACF;QAEA,wBAAwB;QACxB2B,kBAAkBH;IACpB;AACF,EAAE"}
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ const MotionRefForwarderContext = /*#__PURE__*/ React.createContext(undefined);
3
+ /**
4
+ * @internal
5
+ */ export function useMotionForwardedRef() {
6
+ return React.useContext(MotionRefForwarderContext);
7
+ }
8
+ /**
9
+ * A component that forwards a ref to its children via a React context.
10
+ *
11
+ * @internal
12
+ */ export const MotionRefForwarder = /*#__PURE__*/ React.forwardRef((props, ref)=>{
13
+ return /*#__PURE__*/ React.createElement(MotionRefForwarderContext.Provider, {
14
+ value: ref
15
+ }, props.children);
16
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["MotionRefForwarder.tsx"],"sourcesContent":["import * as React from 'react';\n\nconst MotionRefForwarderContext = React.createContext<React.Ref<HTMLElement> | undefined>(undefined);\n\n/**\n * @internal\n */\nexport function useMotionForwardedRef() {\n return React.useContext(MotionRefForwarderContext);\n}\n\n/**\n * A component that forwards a ref to its children via a React context.\n *\n * @internal\n */\nexport const MotionRefForwarder = React.forwardRef<HTMLElement, { children: React.ReactElement }>((props, ref) => {\n return <MotionRefForwarderContext.Provider value={ref}>{props.children}</MotionRefForwarderContext.Provider>;\n});\n"],"names":["React","MotionRefForwarderContext","createContext","undefined","useMotionForwardedRef","useContext","MotionRefForwarder","forwardRef","props","ref","Provider","value","children"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,MAAMC,0CAA4BD,MAAME,aAAa,CAAqCC;AAE1F;;CAEC,GACD,OAAO,SAASC;IACd,OAAOJ,MAAMK,UAAU,CAACJ;AAC1B;AAEA;;;;CAIC,GACD,OAAO,MAAMK,mCAAqBN,MAAMO,UAAU,CAAgD,CAACC,OAAOC;IACxG,qBAAO,oBAACR,0BAA0BS,QAAQ;QAACC,OAAOF;OAAMD,MAAMI,QAAQ;AACxE,GAAG"}
@@ -12,6 +12,7 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
12
12
  const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
13
13
  const _reactutilities = require("@fluentui/react-utilities");
14
14
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
15
+ const _MotionRefForwarder = require("../MotionRefForwarder");
15
16
  const _contexts = require("../../contexts");
16
17
  const renderDialog_unstable = (state, contextValues)=>{
17
18
  (0, _reactutilities.assertSlots)(state);
@@ -22,7 +23,9 @@ const renderDialog_unstable = (state, contextValues)=>{
22
23
  children: [
23
24
  state.trigger,
24
25
  state.content && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.surfaceMotion, {
25
- children: state.content
26
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_MotionRefForwarder.MotionRefForwarder, {
27
+ children: state.content
28
+ })
26
29
  })
27
30
  ]
28
31
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["renderDialog.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { DialogProvider, DialogSurfaceProvider } from '../../contexts';\nimport type { DialogState, DialogContextValues, DialogSlots } from './Dialog.types';\n\n/**\n * Render the final JSX of Dialog\n */\nexport const renderDialog_unstable = (state: DialogState, contextValues: DialogContextValues) => {\n assertSlots<DialogSlots>(state);\n\n return (\n <DialogProvider value={contextValues.dialog}>\n <DialogSurfaceProvider value={contextValues.dialogSurface}>\n {state.trigger}\n {state.content && (\n <state.surfaceMotion>\n {/* Casting here as content should be equivalent to <DialogSurface/> */}\n {/* FIXME: content should not be ReactNode it should be ReactElement instead. */}\n {state.content as React.ReactElement}\n </state.surfaceMotion>\n )}\n </DialogSurfaceProvider>\n </DialogProvider>\n );\n};\n"],"names":["renderDialog_unstable","state","contextValues","assertSlots","_jsx","DialogProvider","value","dialog","_jsxs","DialogSurfaceProvider","dialogSurface","trigger","content","surfaceMotion"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAYaA;;;eAAAA;;;;4BAXb;gCAE4B;iEACL;0BAE+B;AAM/C,MAAMA,wBAAwB,CAACC,OAAoBC;IACxDC,IAAAA,2BAAAA,EAAyBF;IAEzB,OAAA,WAAA,GACEG,IAAAA,eAAA,EAACC,wBAAAA,EAAAA;QAAeC,OAAOJ,cAAcK,MAAM;kBACzC,WAAA,GAAAC,IAAAA,gBAAA,EAACC,+BAAAA,EAAAA;YAAsBH,OAAOJ,cAAcQ,aAAa;;gBACtDT,MAAMU,OAAO;gBACbV,MAAMW,OAAO,IAAA,WAAA,GACZR,IAAAA,eAAA,EAACH,MAAMY,aAAa,EAAA;8BAGjBZ,MAAMW,OAAO;;;;;AAM1B"}
1
+ {"version":3,"sources":["renderDialog.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { MotionRefForwarder } from '../MotionRefForwarder';\nimport { DialogProvider, DialogSurfaceProvider } from '../../contexts';\nimport type { DialogState, DialogContextValues, DialogSlots } from './Dialog.types';\n\n/**\n * Render the final JSX of Dialog\n */\nexport const renderDialog_unstable = (state: DialogState, contextValues: DialogContextValues) => {\n assertSlots<DialogSlots>(state);\n\n return (\n <DialogProvider value={contextValues.dialog}>\n <DialogSurfaceProvider value={contextValues.dialogSurface}>\n {state.trigger}\n {state.content && (\n <state.surfaceMotion>\n <MotionRefForwarder>\n {/* Casting here as content should be equivalent to <DialogSurface/> */}\n {/* FIXME: content should not be ReactNode it should be ReactElement instead. */}\n {state.content as React.ReactElement}\n </MotionRefForwarder>\n </state.surfaceMotion>\n )}\n </DialogSurfaceProvider>\n </DialogProvider>\n );\n};\n"],"names":["renderDialog_unstable","state","contextValues","assertSlots","_jsx","DialogProvider","value","dialog","_jsxs","DialogSurfaceProvider","dialogSurface","trigger","content","surfaceMotion","MotionRefForwarder"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAaaA;;;eAAAA;;;;4BAZb;gCAE4B;iEACL;oCAEY;0BACmB;AAM/C,MAAMA,wBAAwB,CAACC,OAAoBC;IACxDC,IAAAA,2BAAAA,EAAyBF;IAEzB,OAAA,WAAA,GACEG,IAAAA,eAAA,EAACC,wBAAAA,EAAAA;QAAeC,OAAOJ,cAAcK,MAAM;kBACzC,WAAA,GAAAC,IAAAA,gBAAA,EAACC,+BAAAA,EAAAA;YAAsBH,OAAOJ,cAAcQ,aAAa;;gBACtDT,MAAMU,OAAO;gBACbV,MAAMW,OAAO,IAAA,WAAA,GACZR,IAAAA,eAAA,EAACH,MAAMY,aAAa,EAAA;8BAClB,WAAA,GAAAT,IAAAA,eAAA,EAACU,sCAAAA,EAAAA;kCAGEb,MAAMW,OAAO;;;;;;AAO5B"}
@@ -16,7 +16,9 @@ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
16
16
  const _contexts = require("../../contexts");
17
17
  const _useDisableBodyScroll = require("../../utils/useDisableBodyScroll");
18
18
  const _DialogBackdropMotion = require("../DialogBackdropMotion");
19
+ const _MotionRefForwarder = require("../MotionRefForwarder");
19
20
  const useDialogSurface_unstable = (props, ref)=>{
21
+ const contextRef = (0, _MotionRefForwarder.useMotionForwardedRef)();
20
22
  const modalType = (0, _contexts.useDialogContext_unstable)((ctx)=>ctx.modalType);
21
23
  const isNestedDialog = (0, _contexts.useDialogContext_unstable)((ctx)=>ctx.isNestedDialog);
22
24
  const modalAttributes = (0, _contexts.useDialogContext_unstable)((ctx)=>ctx.modalAttributes);
@@ -101,7 +103,7 @@ const useDialogSurface_unstable = (props, ref)=>{
101
103
  // FIXME:
102
104
  // `DialogSurfaceElement` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`
103
105
  // but since it would be a breaking change to fix it, we are casting ref to it's proper type
104
- ref: (0, _reactutilities.useMergedRefs)(ref, dialogRef)
106
+ ref: (0, _reactutilities.useMergedRefs)(ref, contextRef, dialogRef)
105
107
  }), {
106
108
  elementType: 'div'
107
109
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["useDialogSurface.ts"],"sourcesContent":["import { Escape } from '@fluentui/keyboard-keys';\nimport { presenceMotionSlot, type PresenceMotionSlotProps } from '@fluentui/react-motion';\nimport {\n useEventCallback,\n useMergedRefs,\n isResolvedShorthand,\n slot,\n getIntrinsicElementProps,\n useIsomorphicLayoutEffect,\n} from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useDialogContext_unstable } from '../../contexts';\nimport { useDisableBodyScroll } from '../../utils/useDisableBodyScroll';\nimport { DialogBackdropMotion } from '../DialogBackdropMotion';\nimport type { DialogSurfaceElement, DialogSurfaceProps, DialogSurfaceState } from './DialogSurface.types';\n\n/**\n * Create the state required to render DialogSurface.\n *\n * The returned state can be modified with hooks such as useDialogSurfaceStyles_unstable,\n * before being passed to renderDialogSurface_unstable.\n *\n * @param props - props from this instance of DialogSurface\n * @param ref - reference to root HTMLElement of DialogSurface\n */\nexport const useDialogSurface_unstable = (\n props: DialogSurfaceProps,\n ref: React.Ref<DialogSurfaceElement>,\n): DialogSurfaceState => {\n const modalType = useDialogContext_unstable(ctx => ctx.modalType);\n const isNestedDialog = useDialogContext_unstable(ctx => ctx.isNestedDialog);\n\n const modalAttributes = useDialogContext_unstable(ctx => ctx.modalAttributes);\n const dialogRef = useDialogContext_unstable(ctx => ctx.dialogRef);\n const requestOpenChange = useDialogContext_unstable(ctx => ctx.requestOpenChange);\n const dialogTitleID = useDialogContext_unstable(ctx => ctx.dialogTitleId);\n const open = useDialogContext_unstable(ctx => ctx.open);\n\n const handledBackdropClick = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {\n if (isResolvedShorthand(props.backdrop)) {\n props.backdrop.onClick?.(event);\n }\n if (modalType === 'modal' && !event.isDefaultPrevented()) {\n requestOpenChange({\n event,\n open: false,\n type: 'backdropClick',\n });\n }\n });\n\n const handleKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLDivElement>) => {\n props.onKeyDown?.(event);\n\n if (event.key === Escape && !event.isDefaultPrevented()) {\n requestOpenChange({\n event,\n open: false,\n type: 'escapeKeyDown',\n });\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: nested Dialog, Popover, Menu and Tooltip\n event.preventDefault();\n }\n });\n\n const backdrop = slot.optional(props.backdrop, {\n renderByDefault: modalType !== 'non-modal',\n defaultProps: {\n 'aria-hidden': 'true',\n },\n elementType: 'div',\n });\n if (backdrop) {\n backdrop.onClick = handledBackdropClick;\n }\n\n const { disableBodyScroll, enableBodyScroll } = useDisableBodyScroll();\n\n useIsomorphicLayoutEffect(() => {\n if (isNestedDialog || modalType === 'non-modal') {\n return;\n }\n\n disableBodyScroll();\n\n return () => {\n enableBodyScroll();\n };\n }, [enableBodyScroll, isNestedDialog, disableBodyScroll, modalType]);\n\n return {\n components: {\n backdrop: 'div',\n root: 'div',\n // TODO: remove once React v18 slot API is modified\n // This is a problem at the moment due to UnknownSlotProps assumption\n // that `children` property is `ReactNode`, which in this case is not valid\n // as PresenceComponentProps['children'] is `ReactElement`\n backdropMotion: DialogBackdropMotion as React.FC<PresenceMotionSlotProps>,\n },\n open,\n backdrop,\n isNestedDialog,\n mountNode: props.mountNode,\n root: slot.always(\n getIntrinsicElementProps('div', {\n tabIndex: -1, // https://github.com/microsoft/fluentui/issues/25150\n 'aria-modal': modalType !== 'non-modal',\n role: modalType === 'alert' ? 'alertdialog' : 'dialog',\n 'aria-labelledby': props['aria-label'] ? undefined : dialogTitleID,\n ...props,\n ...modalAttributes,\n onKeyDown: handleKeyDown,\n // FIXME:\n // `DialogSurfaceElement` 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: useMergedRefs(ref, dialogRef) as React.Ref<HTMLDivElement>,\n }),\n { elementType: 'div' },\n ),\n backdropMotion: presenceMotionSlot(props.backdropMotion, {\n elementType: DialogBackdropMotion,\n defaultProps: {\n appear: true,\n visible: open,\n },\n }),\n\n // Deprecated properties\n transitionStatus: undefined,\n };\n};\n"],"names":["useDialogSurface_unstable","props","ref","modalType","useDialogContext_unstable","ctx","isNestedDialog","modalAttributes","dialogRef","requestOpenChange","dialogTitleID","dialogTitleId","open","handledBackdropClick","useEventCallback","event","isResolvedShorthand","backdrop","onClick","isDefaultPrevented","type","handleKeyDown","onKeyDown","key","Escape","preventDefault","slot","optional","renderByDefault","defaultProps","elementType","disableBodyScroll","enableBodyScroll","useDisableBodyScroll","useIsomorphicLayoutEffect","components","root","backdropMotion","DialogBackdropMotion","mountNode","always","getIntrinsicElementProps","tabIndex","role","undefined","useMergedRefs","presenceMotionSlot","appear","visible","transit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;YAClBe,WAAWD;YACX,SAAS;YACT,6FAA6F;YAC7F,4FAA4F;YAC5FnB,KAAK2C,IAAAA,6BAAAA,EAAc3C,KAAKM;QAC1B,IACA;YAAEsB,aAAa;QAAM;QAEvBO,gBAAgBS,IAAAA,+BAAAA,EAAmB7C,MAAMoC,cAAc,EAAE;YACvDP,aAAaQ,0CAAAA;YACbT,cAAc;gBACZkB,QAAQ;gBACRC,SAASpC;YACX;QACF;QAEA,wBAAwB;QACxBqC,kBAAkBL;IACpB;AACF"}
1
+ {"version":3,"sources":["useDialogSurface.ts"],"sourcesContent":["import { Escape } from '@fluentui/keyboard-keys';\nimport { presenceMotionSlot, type PresenceMotionSlotProps } from '@fluentui/react-motion';\nimport {\n useEventCallback,\n useMergedRefs,\n isResolvedShorthand,\n slot,\n getIntrinsicElementProps,\n useIsomorphicLayoutEffect,\n} from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useDialogContext_unstable } from '../../contexts';\nimport { useDisableBodyScroll } from '../../utils/useDisableBodyScroll';\nimport { DialogBackdropMotion } from '../DialogBackdropMotion';\nimport { useMotionForwardedRef } from '../MotionRefForwarder';\nimport type { DialogSurfaceElement, DialogSurfaceProps, DialogSurfaceState } from './DialogSurface.types';\n\n/**\n * Create the state required to render DialogSurface.\n *\n * The returned state can be modified with hooks such as useDialogSurfaceStyles_unstable,\n * before being passed to renderDialogSurface_unstable.\n *\n * @param props - props from this instance of DialogSurface\n * @param ref - reference to root HTMLElement of DialogSurface\n */\nexport const useDialogSurface_unstable = (\n props: DialogSurfaceProps,\n ref: React.Ref<DialogSurfaceElement>,\n): DialogSurfaceState => {\n const contextRef = useMotionForwardedRef();\n\n const modalType = useDialogContext_unstable(ctx => ctx.modalType);\n const isNestedDialog = useDialogContext_unstable(ctx => ctx.isNestedDialog);\n\n const modalAttributes = useDialogContext_unstable(ctx => ctx.modalAttributes);\n const dialogRef = useDialogContext_unstable(ctx => ctx.dialogRef);\n const requestOpenChange = useDialogContext_unstable(ctx => ctx.requestOpenChange);\n const dialogTitleID = useDialogContext_unstable(ctx => ctx.dialogTitleId);\n const open = useDialogContext_unstable(ctx => ctx.open);\n\n const handledBackdropClick = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {\n if (isResolvedShorthand(props.backdrop)) {\n props.backdrop.onClick?.(event);\n }\n if (modalType === 'modal' && !event.isDefaultPrevented()) {\n requestOpenChange({\n event,\n open: false,\n type: 'backdropClick',\n });\n }\n });\n\n const handleKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLDivElement>) => {\n props.onKeyDown?.(event);\n\n if (event.key === Escape && !event.isDefaultPrevented()) {\n requestOpenChange({\n event,\n open: false,\n type: 'escapeKeyDown',\n });\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: nested Dialog, Popover, Menu and Tooltip\n event.preventDefault();\n }\n });\n\n const backdrop = slot.optional(props.backdrop, {\n renderByDefault: modalType !== 'non-modal',\n defaultProps: {\n 'aria-hidden': 'true',\n },\n elementType: 'div',\n });\n if (backdrop) {\n backdrop.onClick = handledBackdropClick;\n }\n\n const { disableBodyScroll, enableBodyScroll } = useDisableBodyScroll();\n\n useIsomorphicLayoutEffect(() => {\n if (isNestedDialog || modalType === 'non-modal') {\n return;\n }\n\n disableBodyScroll();\n\n return () => {\n enableBodyScroll();\n };\n }, [enableBodyScroll, isNestedDialog, disableBodyScroll, modalType]);\n\n return {\n components: {\n backdrop: 'div',\n root: 'div',\n // TODO: remove once React v18 slot API is modified\n // This is a problem at the moment due to UnknownSlotProps assumption\n // that `children` property is `ReactNode`, which in this case is not valid\n // as PresenceComponentProps['children'] is `ReactElement`\n backdropMotion: DialogBackdropMotion as React.FC<PresenceMotionSlotProps>,\n },\n open,\n backdrop,\n isNestedDialog,\n mountNode: props.mountNode,\n root: slot.always(\n getIntrinsicElementProps('div', {\n tabIndex: -1, // https://github.com/microsoft/fluentui/issues/25150\n 'aria-modal': modalType !== 'non-modal',\n role: modalType === 'alert' ? 'alertdialog' : 'dialog',\n 'aria-labelledby': props['aria-label'] ? undefined : dialogTitleID,\n ...props,\n ...modalAttributes,\n onKeyDown: handleKeyDown,\n // FIXME:\n // `DialogSurfaceElement` 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: useMergedRefs(ref, contextRef, dialogRef) as React.Ref<HTMLDivElement>,\n }),\n { elementType: 'div' },\n ),\n backdropMotion: presenceMotionSlot(props.backdropMotion, {\n elementType: DialogBackdropMotion,\n defaultProps: {\n appear: true,\n visible: open,\n },\n }),\n\n // Deprecated properties\n transitionStatus: undefined,\n };\n};\n"],"names":["useDialogSurface_unstable","props","ref","contextRef","useMotionForwardedRef","modalType","useDialogContext_unstable","ctx","isNestedDialog","modalAttributes","dialogRef","requestOpenChange","dialogTitleID","dialogTitleId","open","handledBackdropClick","useEventCallback","event","isResolvedShorthand","backdrop","onClick","isDefaultPrevented","type","handleKeyDown","onKeyDown","key","Escape","preventDefault","slot","optional","renderByDefault","defaultProps","elementType","disableBodyScroll","enableBodyScroll","useDisableBodyScroll","useIsomorphicLayoutEffect","components","root","backdropMotion","DialogBackdropMotion","mountNode","always","getIntrinsicElementProps","tabIndex","role","undefined","useMergedRefs","presenceMotionSlot","appear","visible","transitionStatus"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA2BaA;;;eAAAA;;;;8BA3BU;6BAC0C;gCAQ1D;iEACgB;0BAEmB;sCACL;sCACA;oCACC;AAY/B,MAAMA,4BAA4B,CACvCC,OACAC;IAEA,MAAMC,aAAaC,IAAAA,yCAAAA;IAEnB,MAAMC,YAAYC,IAAAA,mCAAAA,EAA0BC,CAAAA,MAAOA,IAAIF,SAAS;IAChE,MAAMG,iBAAiBF,IAAAA,mCAAAA,EAA0BC,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: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ MotionRefForwarder: function() {
13
+ return MotionRefForwarder;
14
+ },
15
+ useMotionForwardedRef: function() {
16
+ return useMotionForwardedRef;
17
+ }
18
+ });
19
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
20
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
21
+ const MotionRefForwarderContext = /*#__PURE__*/ _react.createContext(undefined);
22
+ function useMotionForwardedRef() {
23
+ return _react.useContext(MotionRefForwarderContext);
24
+ }
25
+ const MotionRefForwarder = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
26
+ return /*#__PURE__*/ _react.createElement(MotionRefForwarderContext.Provider, {
27
+ value: ref
28
+ }, props.children);
29
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["MotionRefForwarder.tsx"],"sourcesContent":["import * as React from 'react';\n\nconst MotionRefForwarderContext = React.createContext<React.Ref<HTMLElement> | undefined>(undefined);\n\n/**\n * @internal\n */\nexport function useMotionForwardedRef() {\n return React.useContext(MotionRefForwarderContext);\n}\n\n/**\n * A component that forwards a ref to its children via a React context.\n *\n * @internal\n */\nexport const MotionRefForwarder = React.forwardRef<HTMLElement, { children: React.ReactElement }>((props, ref) => {\n return <MotionRefForwarderContext.Provider value={ref}>{props.children}</MotionRefForwarderContext.Provider>;\n});\n"],"names":["MotionRefForwarder","useMotionForwardedRef","MotionRefForwarderContext","React","createContext","undefined","useContext","forwardRef","props","ref","createElement","Provider","value","children"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAgBaA,kBAAAA;eAAAA;;IATGC,qBAAAA;eAAAA;;;;iEAPO;AAEvB,MAAMC,4BAAAA,WAAAA,GAA4BC,OAAMC,aAAa,CAAqCC;AAKnF,SAASJ;IACd,OAAOE,OAAMG,UAAU,CAACJ;AAC1B;AAOO,MAAMF,qBAAAA,WAAAA,GAAqBG,OAAMI,UAAU,CAAgD,CAACC,OAAOC;IACxG,OAAA,WAAA,GAAON,OAAAO,aAAA,CAACR,0BAA0BS,QAAQ,EAAA;QAACC,OAAOH;OAAMD,MAAMK,QAAQ;AACxE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-dialog",
3
- "version": "9.11.8",
3
+ "version": "9.11.9",
4
4
  "description": "Dialog component for Fluent UI React",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",