@fluentui/react-dialog 9.12.11 → 9.13.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,9 +1,25 @@
1
1
  # Change Log - @fluentui/react-dialog
2
2
 
3
- This log was last generated on Fri, 06 Jun 2025 13:15:17 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 12 Jun 2025 09:39:10 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.13.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-dialog_v9.13.0)
8
+
9
+ Thu, 12 Jun 2025 09:39:10 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-dialog_v9.12.10..@fluentui/react-dialog_v9.13.0)
11
+
12
+ ### Minor changes
13
+
14
+ - Bump @fluentui/react-utilities to v9.21.0 ([PR #34456](https://github.com/microsoft/fluentui/pull/34456) by beachball)
15
+ - Bump @fluentui/react-jsx-runtime to v9.1.0 ([PR #34456](https://github.com/microsoft/fluentui/pull/34456) by beachball)
16
+ - Bump @fluentui/react-context-selector to v9.2.0 ([PR #34456](https://github.com/microsoft/fluentui/pull/34456) by beachball)
17
+ - Bump @fluentui/react-motion to v9.8.0 ([PR #34456](https://github.com/microsoft/fluentui/pull/34456) by beachball)
18
+ - Bump @fluentui/react-motion-components-preview to v0.6.0 ([PR #34456](https://github.com/microsoft/fluentui/pull/34456) by beachball)
19
+ - Bump @fluentui/react-aria to v9.15.0 ([PR #34456](https://github.com/microsoft/fluentui/pull/34456) by beachball)
20
+ - Bump @fluentui/react-tabster to v9.25.0 ([PR #34456](https://github.com/microsoft/fluentui/pull/34456) by beachball)
21
+ - Bump @fluentui/react-portal to v9.6.0 ([PR #34456](https://github.com/microsoft/fluentui/pull/34456) by beachball)
22
+
7
23
  ## [9.12.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-dialog_v9.12.10)
8
24
 
9
25
  Fri, 06 Jun 2025 13:15:17 GMT
@@ -37,10 +37,6 @@ import { DialogSurfaceMotion } from '../DialogSurfaceMotion';
37
37
  const isNestedDialog = useHasParentContext(DialogContext);
38
38
  return {
39
39
  components: {
40
- // TODO: remove once React v18 slot API is modified
41
- // This is a problem at the moment due to UnknownSlotProps assumption
42
- // that `children` property is `ReactNode`, which in this case is not valid
43
- // as PresenceComponentProps['children'] is `ReactElement`
44
40
  surfaceMotion: DialogSurfaceMotion
45
41
  },
46
42
  inertTrapFocus,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Dialog/useDialog.ts"],"sourcesContent":["import { useHasParentContext } from '@fluentui/react-context-selector';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { presenceMotionSlot, type PresenceMotionSlotProps } from '@fluentui/react-motion';\nimport { useControllableState, useEventCallback, useId } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useFocusFirstElement } from '../../utils';\nimport { DialogContext } from '../../contexts';\nimport { DialogSurfaceMotion } from '../DialogSurfaceMotion';\nimport type { DialogOpenChangeData, DialogProps, DialogState } from './Dialog.types';\n\n/**\n * Create the state required to render Dialog.\n *\n * The returned state can be modified with hooks such as useDialogStyles_unstable,\n * before being passed to renderDialog_unstable.\n *\n * @param props - props from this instance of Dialog\n */\nexport const useDialog_unstable = (props: DialogProps): DialogState => {\n const { children, modalType = 'modal', onOpenChange, inertTrapFocus = false } = props;\n\n const [trigger, content] = childrenToTriggerAndContent(children);\n\n const [open, setOpen] = useControllableState({\n state: props.open,\n defaultState: props.defaultOpen,\n initialState: false,\n });\n\n const requestOpenChange = useEventCallback((data: DialogOpenChangeData) => {\n onOpenChange?.(data.event, data);\n\n // if user prevents default then do not change state value\n // otherwise updates state value and trigger reference to the element that caused the opening\n if (!data.event.isDefaultPrevented()) {\n setOpen(data.open);\n }\n });\n\n const focusRef = useFocusFirstElement(open, modalType);\n\n const { modalAttributes, triggerAttributes } = useModalAttributes({\n trapFocus: modalType !== 'non-modal',\n legacyTrapFocus: !inertTrapFocus,\n });\n const isNestedDialog = useHasParentContext(DialogContext);\n\n return {\n components: {\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 surfaceMotion: DialogSurfaceMotion as React.FC<PresenceMotionSlotProps>,\n },\n inertTrapFocus,\n open,\n modalType,\n content,\n trigger,\n requestOpenChange,\n dialogTitleId: useId('dialog-title-'),\n isNestedDialog,\n dialogRef: focusRef,\n modalAttributes,\n triggerAttributes,\n surfaceMotion: presenceMotionSlot(props.surfaceMotion, {\n elementType: DialogSurfaceMotion,\n defaultProps: {\n appear: true,\n visible: open,\n unmountOnExit: true,\n },\n }),\n };\n};\n\n/**\n * Extracts trigger and content from children\n */\nfunction childrenToTriggerAndContent(\n children: React.ReactNode,\n): readonly [trigger: React.ReactNode, content: React.ReactNode] {\n const childrenArray = React.Children.toArray(children) as React.ReactElement[];\n if (process.env.NODE_ENV !== 'production') {\n if (childrenArray.length !== 1 && childrenArray.length !== 2) {\n // eslint-disable-next-line no-console\n console.warn(/* #__DE-INDENT__ */ `\n @fluentui/react-dialog [useDialog]:\n Dialog must contain at least one child <DialogSurface/>,\n and at most two children <DialogTrigger/> <DialogSurface/> (in this order).\n `);\n }\n }\n switch (childrenArray.length) {\n // case where there's a trigger followed by content\n case 2:\n return childrenArray as [trigger: React.ReactNode, content: React.ReactNode];\n // case where there's only content\n case 1:\n return [undefined, childrenArray[0]];\n // unknown case\n default:\n return [undefined, undefined];\n }\n}\n"],"names":["useHasParentContext","useModalAttributes","presenceMotionSlot","useControllableState","useEventCallback","useId","React","useFocusFirstElement","DialogContext","DialogSurfaceMotion","useDialog_unstable","props","children","modalType","onOpenChange","inertTrapFocus","trigger","content","childrenToTriggerAndContent","open","setOpen","state","defaultState","defaultOpen","initialState","requestOpenChange","data","event","isDefaultPrevented","focusRef","modalAttributes","triggerAttributes","trapFocus","legacyTrapFocus","isNestedDialog","components","surfaceMotion","dialogTitleId","dialogRef","elementType","defaultProps","appear","visible","unmountOnExit","childrenArray","Children","toArray","process","env","NODE_ENV","length","console","warn","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,mBAAmB,QAAQ,mCAAmC;AACvE,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,kBAAkB,QAAsC,yBAAyB;AAC1F,SAASC,oBAAoB,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ,4BAA4B;AAC1F,YAAYC,WAAW,QAAQ;AAE/B,SAASC,oBAAoB,QAAQ,cAAc;AACnD,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,mBAAmB,QAAQ,yBAAyB;AAG7D;;;;;;;CAOC,GACD,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAM,EAAEC,QAAQ,EAAEC,YAAY,OAAO,EAAEC,YAAY,EAAEC,iBAAiB,KAAK,EAAE,GAAGJ;IAEhF,MAAM,CAACK,SAASC,QAAQ,GAAGC,4BAA4BN;IAEvD,MAAM,CAACO,MAAMC,QAAQ,GAAGjB,qBAAqB;QAC3CkB,OAAOV,MAAMQ,IAAI;QACjBG,cAAcX,MAAMY,WAAW;QAC/BC,cAAc;IAChB;IAEA,MAAMC,oBAAoBrB,iBAAiB,CAACsB;QAC1CZ,yBAAAA,mCAAAA,aAAeY,KAAKC,KAAK,EAAED;QAE3B,0DAA0D;QAC1D,6FAA6F;QAC7F,IAAI,CAACA,KAAKC,KAAK,CAACC,kBAAkB,IAAI;YACpCR,QAAQM,KAAKP,IAAI;QACnB;IACF;IAEA,MAAMU,WAAWtB,qBAAqBY,MAAMN;IAE5C,MAAM,EAAEiB,eAAe,EAAEC,iBAAiB,EAAE,GAAG9B,mBAAmB;QAChE+B,WAAWnB,cAAc;QACzBoB,iBAAiB,CAAClB;IACpB;IACA,MAAMmB,iBAAiBlC,oBAAoBQ;IAE3C,OAAO;QACL2B,YAAY;YACV,mDAAmD;YACnD,qEAAqE;YACrE,2EAA2E;YAC3E,0DAA0D;YAC1DC,eAAe3B;QACjB;QACAM;QACAI;QACAN;QACAI;QACAD;QACAS;QACAY,eAAehC,MAAM;QACrB6B;QACAI,WAAWT;QACXC;QACAC;QACAK,eAAelC,mBAAmBS,MAAMyB,aAAa,EAAE;YACrDG,aAAa9B;YACb+B,cAAc;gBACZC,QAAQ;gBACRC,SAASvB;gBACTwB,eAAe;YACjB;QACF;IACF;AACF,EAAE;AAEF;;CAEC,GACD,SAASzB,4BACPN,QAAyB;IAEzB,MAAMgC,gBAAgBtC,MAAMuC,QAAQ,CAACC,OAAO,CAAClC;IAC7C,IAAImC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAIL,cAAcM,MAAM,KAAK,KAAKN,cAAcM,MAAM,KAAK,GAAG;YAC5D,sCAAsC;YACtCC,QAAQC,IAAI,CAAsB,CAAC;;2EAInC,CAAC;QACH;IACF;IACA,OAAQR,cAAcM,MAAM;QAC1B,mDAAmD;QACnD,KAAK;YACH,OAAON;QACT,kCAAkC;QAClC,KAAK;YACH,OAAO;gBAACS;gBAAWT,aAAa,CAAC,EAAE;aAAC;QACtC,eAAe;QACf;YACE,OAAO;gBAACS;gBAAWA;aAAU;IACjC;AACF"}
1
+ {"version":3,"sources":["../src/components/Dialog/useDialog.ts"],"sourcesContent":["import { useHasParentContext } from '@fluentui/react-context-selector';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { presenceMotionSlot } from '@fluentui/react-motion';\nimport { useControllableState, useEventCallback, useId } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useFocusFirstElement } from '../../utils';\nimport { DialogContext } from '../../contexts';\nimport { DialogSurfaceMotion } from '../DialogSurfaceMotion';\nimport type { DialogOpenChangeData, DialogProps, DialogState } from './Dialog.types';\n\n/**\n * Create the state required to render Dialog.\n *\n * The returned state can be modified with hooks such as useDialogStyles_unstable,\n * before being passed to renderDialog_unstable.\n *\n * @param props - props from this instance of Dialog\n */\nexport const useDialog_unstable = (props: DialogProps): DialogState => {\n const { children, modalType = 'modal', onOpenChange, inertTrapFocus = false } = props;\n\n const [trigger, content] = childrenToTriggerAndContent(children);\n\n const [open, setOpen] = useControllableState({\n state: props.open,\n defaultState: props.defaultOpen,\n initialState: false,\n });\n\n const requestOpenChange = useEventCallback((data: DialogOpenChangeData) => {\n onOpenChange?.(data.event, data);\n\n // if user prevents default then do not change state value\n // otherwise updates state value and trigger reference to the element that caused the opening\n if (!data.event.isDefaultPrevented()) {\n setOpen(data.open);\n }\n });\n\n const focusRef = useFocusFirstElement(open, modalType);\n\n const { modalAttributes, triggerAttributes } = useModalAttributes({\n trapFocus: modalType !== 'non-modal',\n legacyTrapFocus: !inertTrapFocus,\n });\n const isNestedDialog = useHasParentContext(DialogContext);\n\n return {\n components: {\n surfaceMotion: DialogSurfaceMotion,\n },\n inertTrapFocus,\n open,\n modalType,\n content,\n trigger,\n requestOpenChange,\n dialogTitleId: useId('dialog-title-'),\n isNestedDialog,\n dialogRef: focusRef,\n modalAttributes,\n triggerAttributes,\n surfaceMotion: presenceMotionSlot(props.surfaceMotion, {\n elementType: DialogSurfaceMotion,\n defaultProps: {\n appear: true,\n visible: open,\n unmountOnExit: true,\n },\n }),\n };\n};\n\n/**\n * Extracts trigger and content from children\n */\nfunction childrenToTriggerAndContent(\n children: React.ReactNode,\n): readonly [trigger: React.ReactNode, content: React.ReactNode] {\n const childrenArray = React.Children.toArray(children) as React.ReactElement[];\n if (process.env.NODE_ENV !== 'production') {\n if (childrenArray.length !== 1 && childrenArray.length !== 2) {\n // eslint-disable-next-line no-console\n console.warn(/* #__DE-INDENT__ */ `\n @fluentui/react-dialog [useDialog]:\n Dialog must contain at least one child <DialogSurface/>,\n and at most two children <DialogTrigger/> <DialogSurface/> (in this order).\n `);\n }\n }\n switch (childrenArray.length) {\n // case where there's a trigger followed by content\n case 2:\n return childrenArray as [trigger: React.ReactNode, content: React.ReactNode];\n // case where there's only content\n case 1:\n return [undefined, childrenArray[0]];\n // unknown case\n default:\n return [undefined, undefined];\n }\n}\n"],"names":["useHasParentContext","useModalAttributes","presenceMotionSlot","useControllableState","useEventCallback","useId","React","useFocusFirstElement","DialogContext","DialogSurfaceMotion","useDialog_unstable","props","children","modalType","onOpenChange","inertTrapFocus","trigger","content","childrenToTriggerAndContent","open","setOpen","state","defaultState","defaultOpen","initialState","requestOpenChange","data","event","isDefaultPrevented","focusRef","modalAttributes","triggerAttributes","trapFocus","legacyTrapFocus","isNestedDialog","components","surfaceMotion","dialogTitleId","dialogRef","elementType","defaultProps","appear","visible","unmountOnExit","childrenArray","Children","toArray","process","env","NODE_ENV","length","console","warn","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,mBAAmB,QAAQ,mCAAmC;AACvE,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,oBAAoB,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ,4BAA4B;AAC1F,YAAYC,WAAW,QAAQ;AAE/B,SAASC,oBAAoB,QAAQ,cAAc;AACnD,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,mBAAmB,QAAQ,yBAAyB;AAG7D;;;;;;;CAOC,GACD,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAM,EAAEC,QAAQ,EAAEC,YAAY,OAAO,EAAEC,YAAY,EAAEC,iBAAiB,KAAK,EAAE,GAAGJ;IAEhF,MAAM,CAACK,SAASC,QAAQ,GAAGC,4BAA4BN;IAEvD,MAAM,CAACO,MAAMC,QAAQ,GAAGjB,qBAAqB;QAC3CkB,OAAOV,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jC;AACF"}
@@ -79,10 +79,6 @@ import { useMotionForwardedRef } from '../MotionRefForwarder';
79
79
  components: {
80
80
  backdrop: 'div',
81
81
  root: 'div',
82
- // TODO: remove once React v18 slot API is modified
83
- // This is a problem at the moment due to UnknownSlotProps assumption
84
- // that `children` property is `ReactNode`, which in this case is not valid
85
- // as PresenceComponentProps['children'] is `ReactElement`
86
82
  backdropMotion: DialogBackdropMotion
87
83
  },
88
84
  open,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DialogSurface/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,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EAAE;QAC7CS,iBAAiBpB,cAAc;QAC/BqB,cAAc;YACZ,eAAe;QACjB;QACAC,aAAa;IACf;IACA,IAAIX,UAAU;QACZA,SAASC,OAAO,GAAGH;IACrB;IAEA,MAAM,EAAEc,iBAAiB,EAAEC,gBAAgB,EAAE,GAAG/B;IAEhDH,0BAA0B;QACxB,IAAIY,kBAAkBF,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"}
1
+ {"version":3,"sources":["../src/components/DialogSurface/useDialogSurface.ts"],"sourcesContent":["import { Escape } from '@fluentui/keyboard-keys';\nimport { presenceMotionSlot } 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 backdropMotion: DialogBackdropMotion,\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,QAAQ,yBAAyB;AAC5D,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,CAAAA,MAAOA,IAAIC,cAAc;IAE1E,MAAMC,kBAAkBX,0BAA0BS,CAAAA,MAAOA,IAAIE,eAAe;IAC5E,MAAMC,YAAYZ,0BAA0BS,CAAAA,MAAOA,IAAIG,SAAS;IAChE,MAAMC,oBAAoBb,0BAA0BS,CAAAA,MAAOA,IAAII,iBAAiB;IAChF,MAAMC,gBAAgBd,0BAA0BS,CAAAA,MAAOA,IAAIM,aAAa;IACxE,MAAMC,OAAOhB,0BAA0BS,CAAAA,MAAOA,IAAIO,IAAI;IAEtD,MAAMC,uBAAuBxB,iBAAiB,CAACyB;QAC7C,IAAIvB,oBAAoBU,MAAMc,QAAQ,GAAG;gBACvCd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AAGT,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"}
@@ -41,10 +41,6 @@ const useDialog_unstable = (props)=>{
41
41
  const isNestedDialog = (0, _reactcontextselector.useHasParentContext)(_contexts.DialogContext);
42
42
  return {
43
43
  components: {
44
- // TODO: remove once React v18 slot API is modified
45
- // This is a problem at the moment due to UnknownSlotProps assumption
46
- // that `children` property is `ReactNode`, which in this case is not valid
47
- // as PresenceComponentProps['children'] is `ReactElement`
48
44
  surfaceMotion: _DialogSurfaceMotion.DialogSurfaceMotion
49
45
  },
50
46
  inertTrapFocus,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Dialog/useDialog.ts"],"sourcesContent":["import { useHasParentContext } from '@fluentui/react-context-selector';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { presenceMotionSlot, type PresenceMotionSlotProps } from '@fluentui/react-motion';\nimport { useControllableState, useEventCallback, useId } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useFocusFirstElement } from '../../utils';\nimport { DialogContext } from '../../contexts';\nimport { DialogSurfaceMotion } from '../DialogSurfaceMotion';\nimport type { DialogOpenChangeData, DialogProps, DialogState } from './Dialog.types';\n\n/**\n * Create the state required to render Dialog.\n *\n * The returned state can be modified with hooks such as useDialogStyles_unstable,\n * before being passed to renderDialog_unstable.\n *\n * @param props - props from this instance of Dialog\n */\nexport const useDialog_unstable = (props: DialogProps): DialogState => {\n const { children, modalType = 'modal', onOpenChange, inertTrapFocus = false } = props;\n\n const [trigger, content] = childrenToTriggerAndContent(children);\n\n const [open, setOpen] = useControllableState({\n state: props.open,\n defaultState: props.defaultOpen,\n initialState: false,\n });\n\n const requestOpenChange = useEventCallback((data: DialogOpenChangeData) => {\n onOpenChange?.(data.event, data);\n\n // if user prevents default then do not change state value\n // otherwise updates state value and trigger reference to the element that caused the opening\n if (!data.event.isDefaultPrevented()) {\n setOpen(data.open);\n }\n });\n\n const focusRef = useFocusFirstElement(open, modalType);\n\n const { modalAttributes, triggerAttributes } = useModalAttributes({\n trapFocus: modalType !== 'non-modal',\n legacyTrapFocus: !inertTrapFocus,\n });\n const isNestedDialog = useHasParentContext(DialogContext);\n\n return {\n components: {\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 surfaceMotion: DialogSurfaceMotion as React.FC<PresenceMotionSlotProps>,\n },\n inertTrapFocus,\n open,\n modalType,\n content,\n trigger,\n requestOpenChange,\n dialogTitleId: useId('dialog-title-'),\n isNestedDialog,\n dialogRef: focusRef,\n modalAttributes,\n triggerAttributes,\n surfaceMotion: presenceMotionSlot(props.surfaceMotion, {\n elementType: DialogSurfaceMotion,\n defaultProps: {\n appear: true,\n visible: open,\n unmountOnExit: true,\n },\n }),\n };\n};\n\n/**\n * Extracts trigger and content from children\n */\nfunction childrenToTriggerAndContent(\n children: React.ReactNode,\n): readonly [trigger: React.ReactNode, content: React.ReactNode] {\n const childrenArray = React.Children.toArray(children) as React.ReactElement[];\n if (process.env.NODE_ENV !== 'production') {\n if (childrenArray.length !== 1 && childrenArray.length !== 2) {\n // eslint-disable-next-line no-console\n console.warn(/* #__DE-INDENT__ */ `\n @fluentui/react-dialog [useDialog]:\n Dialog must contain at least one child <DialogSurface/>,\n and at most two children <DialogTrigger/> <DialogSurface/> (in this order).\n `);\n }\n }\n switch (childrenArray.length) {\n // case where there's a trigger followed by content\n case 2:\n return childrenArray as [trigger: React.ReactNode, content: React.ReactNode];\n // case where there's only content\n case 1:\n return [undefined, childrenArray[0]];\n // unknown case\n default:\n return [undefined, undefined];\n }\n}\n"],"names":["useDialog_unstable","props","children","modalType","onOpenChange","inertTrapFocus","trigger","content","childrenToTriggerAndContent","open","setOpen","useControllableState","state","defaultState","defaultOpen","initialState","requestOpenChange","useEventCallback","data","event","isDefaultPrevented","focusRef","useFocusFirstElement","modalAttributes","triggerAttributes","useModalAttributes","trapFocus","legacyTrapFocus","isNestedDialog","useHasParentContext","DialogContext","components","surfaceMotion","DialogSurfaceMotion","dialogTitleId","useId","dialogRef","presenceMotionSlot","elementType","defaultProps","appear","visible","unmountOnExit","childrenArray","React","Children","toArray","process","env","NODE_ENV","length","console","warn","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAmBaA;;;eAAAA;;;;sCAnBuB;8BACD;6BAC8B;gCACH;iEACvC;uBAEc;0BACP;qCACM;AAW7B,MAAMA,qBAAqB,CAACC;IACjC,MAAM,EAAEC,QAAQ,EAAEC,YAAY,OAAO,EAAEC,YAAY,EAAEC,iBAAiB,KAAK,EAAE,GAAGJ;IAEhF,MAAM,CAACK,SAASC,QAAQ,GAAGC,4BAA4BN;IAEvD,MAAM,CAACO,MAAMC,QAAQ,GAAGC,IAAAA,oCAAAA,EAAqB;QAC3CC,OAAOX,MAAMQ,IAAI;QACjBI,cAAcZ,MAAMa,WAAW;QAC/BC,cAAc;IAChB;IAEA,MAAMC,oBAAoBC,IAAAA,gCAAAA,EAAiB,CAACC;QAC1Cd,iBAAAA,QAAAA,iBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,aAAec,KAAKC,KAAK,EAAED;QAE3B,0DAA0D;QAC1D,6FAA6F;QAC7F,IAAI,CAACA,KAAKC,KAAK,CAACC,kBAAkB,IAAI;YACpCV,QAAQQ,KAAKT,IAAI;QACnB;IACF;IAEA,MAAMY,WAAWC,IAAAA,2BAAAA,EAAqBb,MAAMN;IAE5C,MAAM,EAAEoB,eAAe,EAAEC,iBAAiB,EAAE,GAAGC,IAAAA,gCAAAA,EAAmB;QAChEC,WAAWvB,cAAc;QACzBwB,iBAAiB,CAACtB;IACpB;IACA,MAAMuB,iBAAiBC,IAAAA,yCAAAA,EAAoBC,uBAAAA;IAE3C,OAAO;QACLC,YAAY;YACV,mDAAmD;YACnD,qEAAqE;YACrE,2EAA2E;YAC3E,0DAA0D;YAC1DC,eAAeC,wCAAAA;QACjB;QACA5B;QACAI;QACAN;QACAI;QACAD;QACAU;QACAkB,eAAeC,IAAAA,qBAAAA,EAAM;QACrBP;QACAQ,WAAWf;QACXE;QACAC;QACAQ,eAAeK,IAAAA,+BAAAA,EAAmBpC,MAAM+B,aAAa,EAAE;YACrDM,aAAaL,wCAAAA;YACbM,cAAc;gBACZC,QAAQ;gBACRC,SAAShC;gBACTiC,eAAe;YACjB;QACF;IACF;AACF;AAEA;;CAEC,GACD,SAASlC,4BACPN,QAAyB;IAEzB,MAAMyC,gBAAgBC,OAAMC,QAAQ,CAACC,OAAO,CAAC5C;IAC7C,IAAI6C,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAIN,cAAcO,MAAM,KAAK,KAAKP,cAAcO,MAAM,KAAK,GAAG;YAC5D,sCAAsC;YACtCC,QAAQC,IAAI,CAAsB,CAAC;;2EAInC,CAAC;QACH;IACF;IACA,OAAQT,cAAcO,MAAM;QAC1B,mDAAmD;QACnD,KAAK;YACH,OAAOP;QACT,kCAAkC;QAClC,KAAK;YACH,OAAO;gBAACU;gBAAWV,aAAa,CAAC,EAAE;aAAC;QACtC,eAAe;QACf;YACE,OAAO;gBAACU;gBAAWA;aAAU;IACjC;AACF"}
1
+ {"version":3,"sources":["../src/components/Dialog/useDialog.ts"],"sourcesContent":["import { useHasParentContext } from '@fluentui/react-context-selector';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { presenceMotionSlot } from '@fluentui/react-motion';\nimport { useControllableState, useEventCallback, useId } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useFocusFirstElement } from '../../utils';\nimport { DialogContext } from '../../contexts';\nimport { DialogSurfaceMotion } from '../DialogSurfaceMotion';\nimport type { DialogOpenChangeData, DialogProps, DialogState } from './Dialog.types';\n\n/**\n * Create the state required to render Dialog.\n *\n * The returned state can be modified with hooks such as useDialogStyles_unstable,\n * before being passed to renderDialog_unstable.\n *\n * @param props - props from this instance of Dialog\n */\nexport const useDialog_unstable = (props: DialogProps): DialogState => {\n const { children, modalType = 'modal', onOpenChange, inertTrapFocus = false } = props;\n\n const [trigger, content] = childrenToTriggerAndContent(children);\n\n const [open, setOpen] = useControllableState({\n state: props.open,\n defaultState: props.defaultOpen,\n initialState: false,\n });\n\n const requestOpenChange = useEventCallback((data: DialogOpenChangeData) => {\n onOpenChange?.(data.event, data);\n\n // if user prevents default then do not change state value\n // otherwise updates state value and trigger reference to the element that caused the opening\n if (!data.event.isDefaultPrevented()) {\n setOpen(data.open);\n }\n });\n\n const focusRef = useFocusFirstElement(open, modalType);\n\n const { modalAttributes, triggerAttributes } = useModalAttributes({\n trapFocus: modalType !== 'non-modal',\n legacyTrapFocus: !inertTrapFocus,\n });\n const isNestedDialog = useHasParentContext(DialogContext);\n\n return {\n components: {\n surfaceMotion: DialogSurfaceMotion,\n },\n inertTrapFocus,\n open,\n modalType,\n content,\n trigger,\n requestOpenChange,\n dialogTitleId: useId('dialog-title-'),\n isNestedDialog,\n dialogRef: focusRef,\n modalAttributes,\n triggerAttributes,\n surfaceMotion: presenceMotionSlot(props.surfaceMotion, {\n elementType: DialogSurfaceMotion,\n defaultProps: {\n appear: true,\n visible: open,\n unmountOnExit: true,\n },\n }),\n };\n};\n\n/**\n * Extracts trigger and content from children\n */\nfunction childrenToTriggerAndContent(\n children: React.ReactNode,\n): readonly [trigger: React.ReactNode, content: React.ReactNode] {\n const childrenArray = React.Children.toArray(children) as React.ReactElement[];\n if (process.env.NODE_ENV !== 'production') {\n if (childrenArray.length !== 1 && childrenArray.length !== 2) {\n // eslint-disable-next-line no-console\n console.warn(/* #__DE-INDENT__ */ `\n @fluentui/react-dialog [useDialog]:\n Dialog must contain at least one child <DialogSurface/>,\n and at most two children <DialogTrigger/> <DialogSurface/> (in this order).\n `);\n }\n }\n switch (childrenArray.length) {\n // case where there's a trigger followed by content\n case 2:\n return childrenArray as [trigger: React.ReactNode, content: React.ReactNode];\n // case where there's only content\n case 1:\n return [undefined, childrenArray[0]];\n // unknown case\n default:\n return [undefined, undefined];\n }\n}\n"],"names":["useDialog_unstable","props","children","modalType","onOpenChange","inertTrapFocus","trigger","content","childrenToTriggerAndContent","open","setOpen","useControllableState","state","defaultState","defaultOpen","initialState","requestOpenChange","useEventCallback","data","event","isDefaultPrevented","focusRef","useFocusFirstElement","modalAttributes","triggerAttributes","useModalAttributes","trapFocus","legacyTrapFocus","isNestedDialog","useHasParentContext","DialogContext","components","surfaceMotion","DialogSurfaceMotion","dialogTitleId","useId","dialogRef","presenceMotionSlot","elementType","defaultProps","appear","visible","unmountOnExit","childrenArray","React","Children","toArray","process","env","NODE_ENV","length","console","warn","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAmBaA;;;eAAAA;;;;sCAnBuB;8BACD;6BACA;gCAC2B;iEACvC;uBAEc;0BACP;qCACM;AAW7B,MAAMA,qBAAqB,CAACC;IACjC,MAAM,EAAEC,QAAQ,EAAEC,YAAY,OAAO,EAAEC,YAAY,EAAEC,iBAAiB,KAAK,EAAE,GAAGJ;IAEhF,MAAM,CAACK,SAASC,QAAQ,GAAGC,4BAA4BN;IAEvD,MAAM,CAACO,MAAMC,QAAQ,GAAGC,IAAAA,oCAAAA,EAAqB;QAC3CC,OAAOX,MAAMQ,I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QACT,kCAAkC;QAClC,KAAK;YACH,OAAO;gBAACU;gBAAWV,aAAa,CAAC,EAAE;aAAC;QACtC,eAAe;QACf;YACE,OAAO;gBAACU;gBAAWA;aAAU;IACjC;AACF"}
@@ -82,10 +82,6 @@ const useDialogSurface_unstable = (props, ref)=>{
82
82
  components: {
83
83
  backdrop: 'div',
84
84
  root: 'div',
85
- // TODO: remove once React v18 slot API is modified
86
- // This is a problem at the moment due to UnknownSlotProps assumption
87
- // that `children` property is `ReactNode`, which in this case is not valid
88
- // as PresenceComponentProps['children'] is `ReactElement`
89
85
  backdropMotion: _DialogBackdropMotion.DialogBackdropMotion
90
86
  },
91
87
  open,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DialogSurface/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;I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X;QACF;QAEA,wBAAwB;QACxBqC,kBAAkBL;IACpB;AACF"}
1
+ {"version":3,"sources":["../src/components/DialogSurface/useDialogSurface.ts"],"sourcesContent":["import { Escape } from '@fluentui/keyboard-keys';\nimport { presenceMotionSlot } 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 backdropMotion: DialogBackdropMotion,\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;6BACY;gCAQ5B;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,CAAAA,MAAOA,IAAIC,cAAc;IAE1E,MAAMC,kBAAkBH,IAAAA,mCAAAA,EAA0BC,CAAAA,MAAOA,IAAIE,eAAe;IAC5E,MAAMC,YAAYJ,IAAAA,mCAAAA,EAA0BC,CAAAA,MAAOA,IAAIG,SAAS;IAChE,MAAMC,oBAAoBL,IAAAA,mCAAAA,EAA0BC,CAAAA,MAAOA,IAAII,iBAAiB;IAChF,MAAMC,gBAAgBN,IAAAA,mCAAAA,EAA0BC,CAAAA,MAAOA,IAAIM,aAAa;IACxE,MAAMC,OAAOR,IAAAA,mCAAAA,EAA0BC,CAAAA,MAAOA,IAAIO,IAAI;IAEtD,MAAMC,uB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QACLgC,YAAY;YACVlB,UAAU;YACVmB,MAAM;YACNC,gBAAgBC,0CAAAA;QAClB;QACA1B;QACAK;QACAX;QACAiC,WAAWxC,MAAMwC,SAAS;QAC1BH,MAAMV,oBAAAA,CAAKc,MAAM,CACfC,IAAAA,wCAAAA,EAAyB,OAAO;YAC9BC,UAAU,CAAC;YACX,cAAcvC,cAAc;YAC5BwC,MAAMxC,cAAc,UAAU,gBAAgB;YAC9C,mBAAmBJ,KAAK,CAAC,aAAa,GAAG6C,YAAYlC;YACrD,GAAGX,KAAK;YACR,GAAGQ,eAAe;YAClBe,WAAWD;YACX,SAAS;YACT,6FAA6F;YAC7F,4FAA4F;YAC5FrB,KAAK6C,IAAAA,6BAAAA,EAAc7C,KAAKC,YAAYO;QACtC,IACA;YAAEsB,aAAa;QAAM;QAEvBO,gBAAgBS,IAAAA,+BAAAA,EAAmB/C,MAAMsC,cAAc,EAAE;YACvDP,aAAaQ,0CAAAA;YACbT,cAAc;gBACZkB,QAAQ;gBACRC,SAASpC;YACX;QACF;QAEA,wBAAwB;QACxBqC,kBAAkBL;IACpB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-dialog",
3
- "version": "9.12.11",
3
+ "version": "9.13.0",
4
4
  "description": "Dialog component for Fluent UI React",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -24,18 +24,18 @@
24
24
  "@fluentui/scripts-cypress": "*"
25
25
  },
26
26
  "dependencies": {
27
- "@fluentui/react-utilities": "^9.20.0",
28
- "@fluentui/react-jsx-runtime": "^9.0.55",
27
+ "@fluentui/react-utilities": "^9.21.0",
28
+ "@fluentui/react-jsx-runtime": "^9.1.0",
29
29
  "@fluentui/keyboard-keys": "^9.0.8",
30
- "@fluentui/react-context-selector": "^9.1.77",
31
- "@fluentui/react-motion": "^9.7.4",
32
- "@fluentui/react-motion-components-preview": "^0.5.1",
30
+ "@fluentui/react-context-selector": "^9.2.0",
31
+ "@fluentui/react-motion": "^9.8.0",
32
+ "@fluentui/react-motion-components-preview": "^0.6.0",
33
33
  "@fluentui/react-shared-contexts": "^9.23.1",
34
- "@fluentui/react-aria": "^9.14.8",
34
+ "@fluentui/react-aria": "^9.15.0",
35
35
  "@fluentui/react-icons": "^2.0.245",
36
- "@fluentui/react-tabster": "^9.24.8",
36
+ "@fluentui/react-tabster": "^9.25.0",
37
37
  "@fluentui/react-theme": "^9.1.24",
38
- "@fluentui/react-portal": "^9.5.8",
38
+ "@fluentui/react-portal": "^9.6.0",
39
39
  "@griffel/react": "^1.5.22",
40
40
  "@swc/helpers": "^0.5.1"
41
41
  },