@fluentui/react-dialog 9.0.0-beta.7 → 9.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/CHANGELOG.json +154 -5
  2. package/CHANGELOG.md +34 -6
  3. package/Spec.md +44 -25
  4. package/dist/index.d.ts +59 -59
  5. package/lib/components/Dialog/Dialog.js +0 -2
  6. package/lib/components/Dialog/Dialog.js.map +1 -1
  7. package/lib/components/Dialog/Dialog.types.js.map +1 -1
  8. package/lib/components/Dialog/index.js +0 -1
  9. package/lib/components/Dialog/index.js.map +1 -1
  10. package/lib/components/Dialog/renderDialog.js +2 -10
  11. package/lib/components/Dialog/renderDialog.js.map +1 -1
  12. package/lib/components/Dialog/useDialog.js +19 -129
  13. package/lib/components/Dialog/useDialog.js.map +1 -1
  14. package/lib/components/Dialog/useDialogContextValues.js +4 -4
  15. package/lib/components/Dialog/useDialogContextValues.js.map +1 -1
  16. package/lib/components/DialogActions/useDialogActionsStyles.js +3 -5
  17. package/lib/components/DialogActions/useDialogActionsStyles.js.map +1 -1
  18. package/lib/components/DialogBody/useDialogBodyStyles.js +5 -5
  19. package/lib/components/DialogBody/useDialogBodyStyles.js.map +1 -1
  20. package/lib/components/DialogSurface/DialogSurface.types.js.map +1 -1
  21. package/lib/components/DialogSurface/renderDialogSurface.js +4 -2
  22. package/lib/components/DialogSurface/renderDialogSurface.js.map +1 -1
  23. package/lib/components/DialogSurface/useDialogSurface.js +120 -21
  24. package/lib/components/DialogSurface/useDialogSurface.js.map +1 -1
  25. package/lib/components/DialogSurface/useDialogSurfaceStyles.js +56 -7
  26. package/lib/components/DialogSurface/useDialogSurfaceStyles.js.map +1 -1
  27. package/lib/components/DialogTitle/DialogTitle.js +2 -3
  28. package/lib/components/DialogTitle/DialogTitle.js.map +1 -1
  29. package/lib/components/DialogTitle/DialogTitle.types.js.map +1 -1
  30. package/lib/components/DialogTitle/renderDialogTitle.js +2 -5
  31. package/lib/components/DialogTitle/renderDialogTitle.js.map +1 -1
  32. package/lib/components/DialogTitle/useDialogTitle.js +15 -9
  33. package/lib/components/DialogTitle/useDialogTitle.js.map +1 -1
  34. package/lib/components/DialogTitle/useDialogTitleStyles.js +61 -54
  35. package/lib/components/DialogTitle/useDialogTitleStyles.js.map +1 -1
  36. package/lib/components/DialogTrigger/DialogTrigger.types.js.map +1 -1
  37. package/lib/components/DialogTrigger/useDialogTrigger.js +3 -22
  38. package/lib/components/DialogTrigger/useDialogTrigger.js.map +1 -1
  39. package/lib/contexts/constants.js +1 -1
  40. package/lib/contexts/constants.js.map +1 -1
  41. package/lib/contexts/dialogContext.js +2 -4
  42. package/lib/contexts/dialogContext.js.map +1 -1
  43. package/lib/index.js +1 -1
  44. package/lib/index.js.map +1 -1
  45. package/lib/utils/index.js +4 -3
  46. package/lib/utils/index.js.map +1 -1
  47. package/lib/utils/isEscapeKeyDown.js +5 -4
  48. package/lib/utils/isEscapeKeyDown.js.map +1 -1
  49. package/lib/utils/isHTMLDialogElement.js +4 -0
  50. package/lib/utils/isHTMLDialogElement.js.map +1 -0
  51. package/lib/utils/useControlNativeDialogOpenState.js +20 -0
  52. package/lib/utils/useControlNativeDialogOpenState.js.map +1 -0
  53. package/lib/utils/useDisableBodyScroll.js +60 -0
  54. package/lib/utils/useDisableBodyScroll.js.map +1 -0
  55. package/lib/utils/useFocusFirstElement.js +41 -0
  56. package/lib/utils/useFocusFirstElement.js.map +1 -0
  57. package/lib-commonjs/components/Dialog/Dialog.js +0 -3
  58. package/lib-commonjs/components/Dialog/Dialog.js.map +1 -1
  59. package/lib-commonjs/components/Dialog/index.js +0 -2
  60. package/lib-commonjs/components/Dialog/index.js.map +1 -1
  61. package/lib-commonjs/components/Dialog/renderDialog.js +2 -12
  62. package/lib-commonjs/components/Dialog/renderDialog.js.map +1 -1
  63. package/lib-commonjs/components/Dialog/useDialog.js +18 -128
  64. package/lib-commonjs/components/Dialog/useDialog.js.map +1 -1
  65. package/lib-commonjs/components/Dialog/useDialogContextValues.js +4 -4
  66. package/lib-commonjs/components/Dialog/useDialogContextValues.js.map +1 -1
  67. package/lib-commonjs/components/DialogActions/useDialogActionsStyles.js +3 -6
  68. package/lib-commonjs/components/DialogActions/useDialogActionsStyles.js.map +1 -1
  69. package/lib-commonjs/components/DialogBody/useDialogBodyStyles.js +4 -5
  70. package/lib-commonjs/components/DialogBody/useDialogBodyStyles.js.map +1 -1
  71. package/lib-commonjs/components/DialogSurface/renderDialogSurface.js +5 -2
  72. package/lib-commonjs/components/DialogSurface/renderDialogSurface.js.map +1 -1
  73. package/lib-commonjs/components/DialogSurface/useDialogSurface.js +120 -21
  74. package/lib-commonjs/components/DialogSurface/useDialogSurface.js.map +1 -1
  75. package/lib-commonjs/components/DialogSurface/useDialogSurfaceStyles.js +56 -6
  76. package/lib-commonjs/components/DialogSurface/useDialogSurfaceStyles.js.map +1 -1
  77. package/lib-commonjs/components/DialogTitle/DialogTitle.js +2 -3
  78. package/lib-commonjs/components/DialogTitle/DialogTitle.js.map +1 -1
  79. package/lib-commonjs/components/DialogTitle/renderDialogTitle.js +2 -6
  80. package/lib-commonjs/components/DialogTitle/renderDialogTitle.js.map +1 -1
  81. package/lib-commonjs/components/DialogTitle/useDialogTitle.js +18 -10
  82. package/lib-commonjs/components/DialogTitle/useDialogTitle.js.map +1 -1
  83. package/lib-commonjs/components/DialogTitle/useDialogTitleStyles.js +62 -56
  84. package/lib-commonjs/components/DialogTitle/useDialogTitleStyles.js.map +1 -1
  85. package/lib-commonjs/components/DialogTrigger/useDialogTrigger.js +4 -24
  86. package/lib-commonjs/components/DialogTrigger/useDialogTrigger.js.map +1 -1
  87. package/lib-commonjs/contexts/constants.js +2 -2
  88. package/lib-commonjs/contexts/constants.js.map +1 -1
  89. package/lib-commonjs/contexts/dialogContext.js +2 -4
  90. package/lib-commonjs/contexts/dialogContext.js.map +1 -1
  91. package/lib-commonjs/index.js +1 -13
  92. package/lib-commonjs/index.js.map +1 -1
  93. package/lib-commonjs/utils/index.js +5 -3
  94. package/lib-commonjs/utils/index.js.map +1 -1
  95. package/lib-commonjs/utils/isEscapeKeyDown.js +5 -4
  96. package/lib-commonjs/utils/isEscapeKeyDown.js.map +1 -1
  97. package/lib-commonjs/utils/isHTMLDialogElement.js +13 -0
  98. package/lib-commonjs/utils/isHTMLDialogElement.js.map +1 -0
  99. package/lib-commonjs/utils/useControlNativeDialogOpenState.js +31 -0
  100. package/lib-commonjs/utils/useControlNativeDialogOpenState.js.map +1 -0
  101. package/lib-commonjs/utils/useDisableBodyScroll.js +73 -0
  102. package/lib-commonjs/utils/useDisableBodyScroll.js.map +1 -0
  103. package/lib-commonjs/utils/useFocusFirstElement.js +54 -0
  104. package/lib-commonjs/utils/useFocusFirstElement.js.map +1 -0
  105. package/package.json +13 -13
  106. package/dist/tsdoc-metadata.json +0 -11
  107. package/lib/components/Dialog/useDialogStyles.js +0 -41
  108. package/lib/components/Dialog/useDialogStyles.js.map +0 -1
  109. package/lib/utils/isTargetDisabled.js +0 -14
  110. package/lib/utils/isTargetDisabled.js.map +0 -1
  111. package/lib/utils/localShorthands.js +0 -9
  112. package/lib/utils/localShorthands.js.map +0 -1
  113. package/lib/utils/normalizeDefaultPrevented.js +0 -11
  114. package/lib/utils/normalizeDefaultPrevented.js.map +0 -1
  115. package/lib-commonjs/components/Dialog/useDialogStyles.js +0 -53
  116. package/lib-commonjs/components/Dialog/useDialogStyles.js.map +0 -1
  117. package/lib-commonjs/utils/isTargetDisabled.js +0 -23
  118. package/lib-commonjs/utils/isTargetDisabled.js.map +0 -1
  119. package/lib-commonjs/utils/localShorthands.js +0 -18
  120. package/lib-commonjs/utils/localShorthands.js.map +0 -1
  121. package/lib-commonjs/utils/normalizeDefaultPrevented.js +0 -20
  122. package/lib-commonjs/utils/normalizeDefaultPrevented.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"../src/","sources":["contexts/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,+BAA+B,GAAG,sCAAsC,CAAC;AACtF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAChC,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAC3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CAAC;AACvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,cAAc,CAAC;AACrD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC","sourcesContent":["export const MEDIA_QUERY_BREAKPOINT_SELECTOR = '@media screen and (max-width: 480px)';\nexport const SURFACE_PADDING = '24px';\nexport const DIALOG_GAP = '8px';\nexport const SURFACE_BORDER_RADIUS = '8px';\nexport const SURFACE_BORDER_WIDTH = '1px';\n\nexport const ACTIONS_START_GRID_AREA = 'actions-start';\nexport const ACTIONS_END_GRID_AREA = 'actions-end';\nexport const TITLE_GRID_AREA = 'title';\nexport const CLOSE_BUTTON_GRID_AREA = 'close-button';\nexport const BODY_GRID_AREA = 'body';\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"../src/","sources":["contexts/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,+BAA+B,GAAG,sCAAsC,CAAC;AACtF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAChC,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAC3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CAAC;AACvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,cAAc,CAAC;AACrD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC","sourcesContent":["export const MEDIA_QUERY_BREAKPOINT_SELECTOR = '@media screen and (max-width: 480px)';\nexport const SURFACE_PADDING = '24px';\nexport const DIALOG_GAP = '8px';\nexport const SURFACE_BORDER_RADIUS = '8px';\nexport const SURFACE_BORDER_WIDTH = '1px';\n\nexport const ACTIONS_START_GRID_AREA = 'actions-start';\nexport const ACTIONS_END_GRID_AREA = 'actions-end';\nexport const TITLE_GRID_AREA = 'title';\nexport const TITLE_ACTION_GRID_AREA = 'close-button';\nexport const BODY_GRID_AREA = 'body';\n"]}
@@ -2,10 +2,8 @@ import { createContext, useContextSelector } from '@fluentui/react-context-selec
2
2
  const defaultContextValue = {
3
3
  open: false,
4
4
  modalType: 'modal',
5
- triggerRef: {
6
- current: null
7
- },
8
- contentRef: {
5
+ isNestedDialog: false,
6
+ dialogRef: {
9
7
  current: null
10
8
  },
11
9
 
@@ -1 +1 @@
1
- {"version":3,"sources":["contexts/dialogContext.ts"],"names":[],"mappings":"AAAA,SAAS,aAAT,EAAyC,kBAAzC,QAAmE,kCAAnE;AAsBA,MAAM,mBAAmB,GAAuB;EAC9C,IAAI,EAAE,KADwC;EAE9C,SAAS,EAAE,OAFmC;EAG9C,UAAU,EAAE;IAAE,OAAO,EAAE;EAAX,CAHkC;EAI9C,UAAU,EAAE;IAAE,OAAO,EAAE;EAAX,CAJkC;;EAK9C,iBAAiB,GAAA;IACf;EACD;;AAP6C,CAAhD,C,CAUA;;AACA,OAAO,MAAM,aAAa,gBAA4C,aAAa,CACjF,SADiF,CAA5E;AAIP,OAAO,MAAM,cAAc,GAAG,aAAa,CAAC,QAArC;AACP,OAAO,MAAM,yBAAyB,GAAO,QAAJ,IACvC,kBAAkB,CAAC,aAAD,EAAgB,CAAC,GAAG,GAAG,mBAAP,KAA+B,QAAQ,CAAC,GAAD,CAAvD,CADb","sourcesContent":["import { createContext, ContextSelector, useContextSelector } from '@fluentui/react-context-selector';\nimport type { Context } from '@fluentui/react-context-selector';\nimport type { DialogOpenChangeData, DialogModalType } from '../Dialog';\nimport * as React from 'react';\n\nexport type DialogContextValue = {\n /**\n * Reference to trigger element that opened the Dialog\n * null if Dialog is closed\n */\n triggerRef: React.RefObject<HTMLElement>;\n contentRef: React.RefObject<HTMLElement>;\n modalType: DialogModalType;\n dialogTitleID?: string;\n dialogBodyID?: string;\n open: boolean;\n /**\n * Requests dialog main component to update it's internal open state\n */\n requestOpenChange: (data: DialogOpenChangeData) => void;\n};\n\nconst defaultContextValue: DialogContextValue = {\n open: false,\n modalType: 'modal',\n triggerRef: { current: null },\n contentRef: { current: null },\n requestOpenChange() {\n /* noop */\n },\n};\n\n// Contexts should default to undefined\nexport const DialogContext: Context<DialogContextValue | undefined> = createContext<DialogContextValue | undefined>(\n undefined,\n);\n\nexport const DialogProvider = DialogContext.Provider;\nexport const useDialogContext_unstable = <T>(selector: ContextSelector<DialogContextValue, T>): T =>\n useContextSelector(DialogContext, (ctx = defaultContextValue) => selector(ctx));\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["contexts/dialogContext.ts"],"names":[],"mappings":"AACA,SAAS,aAAT,EAAyC,kBAAzC,QAAmE,kCAAnE;AAkBA,MAAM,mBAAmB,GAAuB;EAC9C,IAAI,EAAE,KADwC;EAE9C,SAAS,EAAE,OAFmC;EAG9C,cAAc,EAAE,KAH8B;EAI9C,SAAS,EAAE;IAAE,OAAO,EAAE;EAAX,CAJmC;;EAK9C,iBAAiB,GAAA;IACf;EACD;;AAP6C,CAAhD,C,CAUA;;AACA,OAAO,MAAM,aAAa,gBAA4C,aAAa,CACjF,SADiF,CAA5E;AAIP,OAAO,MAAM,cAAc,GAAG,aAAa,CAAC,QAArC;AACP,OAAO,MAAM,yBAAyB,GAAO,QAAJ,IACvC,kBAAkB,CAAC,aAAD,EAAgB,CAAC,GAAG,GAAG,mBAAP,KAA+B,QAAQ,CAAC,GAAD,CAAvD,CADb","sourcesContent":["import * as React from 'react';\nimport { createContext, ContextSelector, useContextSelector } from '@fluentui/react-context-selector';\nimport { DialogSurfaceElement } from '../DialogSurface';\nimport type { Context } from '@fluentui/react-context-selector';\nimport type { DialogModalType, DialogOpenChangeData } from '../Dialog';\n\nexport type DialogContextValue = {\n open: boolean;\n dialogBodyID?: string;\n dialogTitleID?: string;\n isNestedDialog: boolean;\n dialogRef: React.Ref<DialogSurfaceElement>;\n modalType: DialogModalType;\n /**\n * Requests dialog main component to update it's internal open state\n */\n requestOpenChange: (data: DialogOpenChangeData) => void;\n};\n\nconst defaultContextValue: DialogContextValue = {\n open: false,\n modalType: 'modal',\n isNestedDialog: false,\n dialogRef: { current: null },\n requestOpenChange() {\n /* noop */\n },\n};\n\n// Contexts should default to undefined\nexport const DialogContext: Context<DialogContextValue | undefined> = createContext<DialogContextValue | undefined>(\n undefined,\n);\n\nexport const DialogProvider = DialogContext.Provider;\nexport const useDialogContext_unstable = <T>(selector: ContextSelector<DialogContextValue, T>): T =>\n useContextSelector(DialogContext, (ctx = defaultContextValue) => selector(ctx));\n"],"sourceRoot":"../src/"}
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { Dialog, dialogClassNames, renderDialog_unstable, useDialogStyles_unstable, useDialog_unstable } from './Dialog';
1
+ export { Dialog, renderDialog_unstable, useDialog_unstable } from './Dialog';
2
2
  export { DialogTrigger, useDialogTrigger_unstable, renderDialogTrigger_unstable } from './DialogTrigger';
3
3
  export { DialogActions, dialogActionsClassNames, useDialogActions_unstable, useDialogActionsStyles_unstable, renderDialogActions_unstable } from './DialogActions';
4
4
  export { DialogBody, dialogBodyClassNames, useDialogBody_unstable, useDialogBodyStyles_unstable, renderDialogBody_unstable } from './DialogBody';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,SACE,MADF,EAEE,gBAFF,EAGE,qBAHF,EAIE,wBAJF,EAKE,kBALF,QAMO,UANP;AASA,SAAS,aAAT,EAAwB,yBAAxB,EAAmD,4BAAnD,QAAuF,iBAAvF;AAQA,SACE,aADF,EAEE,uBAFF,EAGE,yBAHF,EAIE,+BAJF,EAKE,4BALF,QAMO,iBANP;AAcA,SACE,UADF,EAEE,oBAFF,EAGE,sBAHF,EAIE,4BAJF,EAKE,yBALF,QAMO,cANP;AASA,SACE,WADF,EAEE,qBAFF,EAGE,uBAHF,EAIE,6BAJF,EAKE,0BALF,QAMO,eANP;AASA,SACE,aADF,EAEE,uBAFF,EAGE,yBAHF,EAIE,+BAJF,EAKE,4BALF,QAMO,iBANP","sourcesContent":["export {\n Dialog,\n dialogClassNames,\n renderDialog_unstable,\n useDialogStyles_unstable,\n useDialog_unstable,\n} from './Dialog';\nexport type { DialogProps, DialogOpenChangeData, DialogOpenChangeEvent, DialogSlots, DialogState } from './Dialog';\n\nexport { DialogTrigger, useDialogTrigger_unstable, renderDialogTrigger_unstable } from './DialogTrigger';\nexport type {\n DialogTriggerProps,\n DialogTriggerChildProps,\n DialogTriggerState,\n DialogTriggerAction,\n} from './DialogTrigger';\n\nexport {\n DialogActions,\n dialogActionsClassNames,\n useDialogActions_unstable,\n useDialogActionsStyles_unstable,\n renderDialogActions_unstable,\n} from './DialogActions';\nexport type {\n DialogActionsProps,\n DialogActionsSlots,\n DialogActionsState,\n DialogActionsPosition,\n} from './DialogActions';\n\nexport {\n DialogBody,\n dialogBodyClassNames,\n useDialogBody_unstable,\n useDialogBodyStyles_unstable,\n renderDialogBody_unstable,\n} from './DialogBody';\nexport type { DialogBodyProps, DialogBodySlots, DialogBodyState } from './DialogBody';\n\nexport {\n DialogTitle,\n dialogTitleClassNames,\n useDialogTitle_unstable,\n useDialogTitleStyles_unstable,\n renderDialogTitle_unstable,\n} from './DialogTitle';\nexport type { DialogTitleProps, DialogTitleSlots, DialogTitleState } from './DialogTitle';\n\nexport {\n DialogSurface,\n dialogSurfaceClassNames,\n useDialogSurface_unstable,\n useDialogSurfaceStyles_unstable,\n renderDialogSurface_unstable,\n} from './DialogSurface';\nexport type { DialogSurfaceProps, DialogSurfaceSlots, DialogSurfaceState } from './DialogSurface';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,SAAS,MAAT,EAAiB,qBAAjB,EAAwC,kBAAxC,QAAkE,UAAlE;AAUA,SAAS,aAAT,EAAwB,yBAAxB,EAAmD,4BAAnD,QAAuF,iBAAvF;AAQA,SACE,aADF,EAEE,uBAFF,EAGE,yBAHF,EAIE,+BAJF,EAKE,4BALF,QAMO,iBANP;AAcA,SACE,UADF,EAEE,oBAFF,EAGE,sBAHF,EAIE,4BAJF,EAKE,yBALF,QAMO,cANP;AASA,SACE,WADF,EAEE,qBAFF,EAGE,uBAHF,EAIE,6BAJF,EAKE,0BALF,QAMO,eANP;AASA,SACE,aADF,EAEE,uBAFF,EAGE,yBAHF,EAIE,+BAJF,EAKE,4BALF,QAMO,iBANP","sourcesContent":["export { Dialog, renderDialog_unstable, useDialog_unstable } from './Dialog';\nexport type {\n DialogSlots,\n DialogProps,\n DialogState,\n DialogOpenChangeData,\n DialogOpenChangeEvent,\n DialogOpenChangeEventHandler,\n} from './Dialog';\n\nexport { DialogTrigger, useDialogTrigger_unstable, renderDialogTrigger_unstable } from './DialogTrigger';\nexport type {\n DialogTriggerProps,\n DialogTriggerChildProps,\n DialogTriggerState,\n DialogTriggerAction,\n} from './DialogTrigger';\n\nexport {\n DialogActions,\n dialogActionsClassNames,\n useDialogActions_unstable,\n useDialogActionsStyles_unstable,\n renderDialogActions_unstable,\n} from './DialogActions';\nexport type {\n DialogActionsProps,\n DialogActionsSlots,\n DialogActionsState,\n DialogActionsPosition,\n} from './DialogActions';\n\nexport {\n DialogBody,\n dialogBodyClassNames,\n useDialogBody_unstable,\n useDialogBodyStyles_unstable,\n renderDialogBody_unstable,\n} from './DialogBody';\nexport type { DialogBodyProps, DialogBodySlots, DialogBodyState } from './DialogBody';\n\nexport {\n DialogTitle,\n dialogTitleClassNames,\n useDialogTitle_unstable,\n useDialogTitleStyles_unstable,\n renderDialogTitle_unstable,\n} from './DialogTitle';\nexport type { DialogTitleProps, DialogTitleSlots, DialogTitleState } from './DialogTitle';\n\nexport {\n DialogSurface,\n dialogSurfaceClassNames,\n useDialogSurface_unstable,\n useDialogSurfaceStyles_unstable,\n renderDialogSurface_unstable,\n} from './DialogSurface';\nexport type { DialogSurfaceProps, DialogSurfaceSlots, DialogSurfaceState } from './DialogSurface';\n"],"sourceRoot":"../src/"}
@@ -1,5 +1,6 @@
1
1
  export * from './isEscapeKeyDown';
2
- export * from './isTargetDisabled';
3
- export * from './localShorthands';
4
- export * from './normalizeDefaultPrevented';
2
+ export * from './useDisableBodyScroll';
3
+ export * from './useFocusFirstElement';
4
+ export * from './isHTMLDialogElement';
5
+ export * from './useControlNativeDialogOpenState';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC","sourcesContent":["export * from './isEscapeKeyDown';\nexport * from './isTargetDisabled';\nexport * from './localShorthands';\nexport * from './normalizeDefaultPrevented';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC","sourcesContent":["export * from './isEscapeKeyDown';\nexport * from './useDisableBodyScroll';\nexport * from './useFocusFirstElement';\nexport * from './isHTMLDialogElement';\nexport * from './useControlNativeDialogOpenState';\n"]}
@@ -1,11 +1,12 @@
1
1
  import { Escape } from '@fluentui/keyboard-keys';
2
- import { normalizeDefaultPrevented } from './normalizeDefaultPrevented';
2
+ import { isHTMLDialogElement } from './isHTMLDialogElement';
3
3
  /**
4
4
  * Checks if keydown event is a proper Escape key dismiss
5
5
  */
6
6
 
7
- export function isEscapeKeyDismiss(event, type) {
8
- const isDefaultPrevented = normalizeDefaultPrevented(event);
9
- return event.key === Escape && type !== 'alert' && !isDefaultPrevented();
7
+ export function isEscapeKeyDismiss(event, modalType) {
8
+ return event.key === Escape && ( // `non-modal` should always have Escape key handling
9
+ // `modal` should only be handled in the case of non native dialog
10
+ modalType === 'non-modal' || !isHTMLDialogElement(event.currentTarget) && modalType === 'modal') && !event.isDefaultPrevented();
10
11
  }
11
12
  //# sourceMappingURL=isEscapeKeyDown.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/isEscapeKeyDown.ts"],"names":[],"mappings":"AACA,SAAS,MAAT,QAAuB,yBAAvB;AAEA,SAAS,yBAAT,QAA0C,6BAA1C;AAEA;;AAEG;;AACH,OAAM,SAAU,kBAAV,CAA6B,KAA7B,EAAyE,IAAzE,EAA8F;EAClG,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,KAAD,CAApD;EACA,OAAO,KAAK,CAAC,GAAN,KAAc,MAAd,IAAwB,IAAI,KAAK,OAAjC,IAA4C,CAAC,kBAAkB,EAAtE;AACD","sourcesContent":["import * as React from 'react';\nimport { Escape } from '@fluentui/keyboard-keys';\nimport { DialogModalType } from '../components/Dialog/Dialog.types';\nimport { normalizeDefaultPrevented } from './normalizeDefaultPrevented';\n\n/**\n * Checks if keydown event is a proper Escape key dismiss\n */\nexport function isEscapeKeyDismiss(event: React.KeyboardEvent | KeyboardEvent, type: DialogModalType): boolean {\n const isDefaultPrevented = normalizeDefaultPrevented(event);\n return event.key === Escape && type !== 'alert' && !isDefaultPrevented();\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/isEscapeKeyDown.ts"],"names":[],"mappings":"AACA,SAAS,MAAT,QAAuB,yBAAvB;AAGA,SAAS,mBAAT,QAAoC,uBAApC;AAEA;;AAEG;;AACH,OAAM,SAAU,kBAAV,CACJ,KADI,EAEJ,SAFI,EAEsB;EAE1B,OACE,KAAK,CAAC,GAAN,KAAc,MAAd,MACA;EACA;EACC,SAAS,KAAK,WAAd,IAA8B,CAAC,mBAAmB,CAAC,KAAK,CAAC,aAAP,CAApB,IAA6C,SAAS,KAAK,OAH1F,KAIA,CAAC,KAAK,CAAC,kBAAN,EALH;AAOD","sourcesContent":["import * as React from 'react';\nimport { Escape } from '@fluentui/keyboard-keys';\nimport type { DialogModalType } from '../components/Dialog/Dialog.types';\nimport { DialogSurfaceElement } from '../DialogSurface';\nimport { isHTMLDialogElement } from './isHTMLDialogElement';\n\n/**\n * Checks if keydown event is a proper Escape key dismiss\n */\nexport function isEscapeKeyDismiss(\n event: React.KeyboardEvent<DialogSurfaceElement>,\n modalType: DialogModalType,\n): boolean {\n return (\n event.key === Escape &&\n // `non-modal` should always have Escape key handling\n // `modal` should only be handled in the case of non native dialog\n (modalType === 'non-modal' || (!isHTMLDialogElement(event.currentTarget) && modalType === 'modal')) &&\n !event.isDefaultPrevented()\n );\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,4 @@
1
+ export function isHTMLDialogElement(element) {
2
+ return Boolean(element && 'open' in element && 'show' in element && 'showModal' in element && 'close' in element);
3
+ }
4
+ //# sourceMappingURL=isHTMLDialogElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/isHTMLDialogElement.ts"],"names":[],"mappings":"AAEA,OAAM,SAAU,mBAAV,CAA8B,OAA9B,EAA0D;EAC9D,OAAO,OAAO,CAAC,OAAO,IAAI,UAAU,OAArB,IAAgC,UAAU,OAA1C,IAAqD,eAAe,OAApE,IAA+E,WAAW,OAA3F,CAAd;AACD","sourcesContent":["import * as React from 'react';\n\nexport function isHTMLDialogElement(element?: HTMLElement | null): element is HTMLDialogElement {\n return Boolean(element && 'open' in element && 'show' in element && 'showModal' in element && 'close' in element);\n}\n\n/**\n * adds additional types which are missing from current version of react\n * @internal\n */\nexport type HTMLDialogElementProps = JSX.IntrinsicElements['dialog'] & {\n /**\n * The close event is fired on a <dialog> when it has been closed.\n */\n onClose?: (event: React.SyntheticEvent) => void;\n /**\n * The cancel event fires on a <dialog> when\n * the user instructs the browser that they wish to dismiss the current open dialog.\n * For example, the browser might fire this event when the user presses the Esc\n * key.\n */\n onCancel?: (event: React.SyntheticEvent) => void;\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import { isHTMLDialogElement } from './isHTMLDialogElement';
3
+ export function useControlNativeDialogOpenState(open, modalType) {
4
+ const dialogSurfaceRef = React.useRef(null);
5
+ React.useEffect(() => {
6
+ if (isHTMLDialogElement(dialogSurfaceRef.current) && dialogSurfaceRef.current.open !== open) {
7
+ if (open) {
8
+ if (modalType === 'non-modal') {
9
+ dialogSurfaceRef.current.show();
10
+ } else {
11
+ dialogSurfaceRef.current.showModal();
12
+ }
13
+ } else {
14
+ dialogSurfaceRef.current.close();
15
+ }
16
+ }
17
+ }, [open, modalType]);
18
+ return dialogSurfaceRef;
19
+ }
20
+ //# sourceMappingURL=useControlNativeDialogOpenState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/useControlNativeDialogOpenState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,mBAAT,QAAoC,uBAApC;AAIA,OAAM,SAAU,+BAAV,CAA0C,IAA1C,EAAyD,SAAzD,EAAmF;EACvF,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAN,CAAmC,IAAnC,CAAzB;EAEA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,IAAI,mBAAmB,CAAC,gBAAgB,CAAC,OAAlB,CAAnB,IAAiD,gBAAgB,CAAC,OAAjB,CAAyB,IAAzB,KAAkC,IAAvF,EAA6F;MAC3F,IAAI,IAAJ,EAAU;QACR,IAAI,SAAS,KAAK,WAAlB,EAA+B;UAC7B,gBAAgB,CAAC,OAAjB,CAAyB,IAAzB;QACD,CAFD,MAEO;UACL,gBAAgB,CAAC,OAAjB,CAAyB,SAAzB;QACD;MACF,CAND,MAMO;QACL,gBAAgB,CAAC,OAAjB,CAAyB,KAAzB;MACD;IACF;EACF,CAZD,EAYG,CAAC,IAAD,EAAO,SAAP,CAZH;EAcA,OAAO,gBAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { isHTMLDialogElement } from './isHTMLDialogElement';\nimport type { DialogModalType } from '../Dialog';\nimport type { DialogSurfaceElement } from '../DialogSurface';\n\nexport function useControlNativeDialogOpenState(open: boolean, modalType: DialogModalType) {\n const dialogSurfaceRef = React.useRef<DialogSurfaceElement>(null);\n\n React.useEffect(() => {\n if (isHTMLDialogElement(dialogSurfaceRef.current) && dialogSurfaceRef.current.open !== open) {\n if (open) {\n if (modalType === 'non-modal') {\n dialogSurfaceRef.current.show();\n } else {\n dialogSurfaceRef.current.showModal();\n }\n } else {\n dialogSurfaceRef.current.close();\n }\n }\n }, [open, modalType]);\n\n return dialogSurfaceRef;\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,60 @@
1
+ import { useFluent_unstable } from '@fluentui/react-shared-contexts';
2
+ import { useCallback } from 'react';
3
+ const disableScrollElementProp = '__fluentDisableScrollElement';
4
+ /**
5
+ * hook that disables body scrolling through `overflow: hidden` CSS property
6
+ */
7
+
8
+ export function useDisableBodyScroll() {
9
+ const {
10
+ targetDocument
11
+ } = useFluent_unstable();
12
+ return useCallback(() => {
13
+ if (targetDocument) {
14
+ return disableScroll(targetDocument.body);
15
+ }
16
+ }, [targetDocument]);
17
+ }
18
+ /**
19
+ * disables scrolling from a given element through `overflow: hidden` CSS property
20
+ * @param target - element to disable scrolling from
21
+ * @returns a method for enabling scrolling again
22
+ */
23
+
24
+ export function disableScroll(target) {
25
+ var _a, _b;
26
+
27
+ const {
28
+ clientWidth
29
+ } = target.ownerDocument.documentElement;
30
+ const innerWidth = (_b = (_a = target.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.innerWidth) !== null && _b !== void 0 ? _b : 0;
31
+ assertIsDisableScrollElement(target);
32
+
33
+ if (target[disableScrollElementProp].count === 0) {
34
+ target.style.overflow = 'hidden';
35
+ target.style.paddingRight = `${innerWidth - clientWidth}px`;
36
+ }
37
+
38
+ target[disableScrollElementProp].count++;
39
+ return () => {
40
+ target[disableScrollElementProp].count--;
41
+
42
+ if (target[disableScrollElementProp].count === 0) {
43
+ target.style.overflow = target[disableScrollElementProp].previousOverflowStyle;
44
+ target.style.paddingRight = target[disableScrollElementProp].previousPaddingRightStyle;
45
+ }
46
+ };
47
+ }
48
+
49
+ function assertIsDisableScrollElement(element) {
50
+ var _a;
51
+
52
+ var _b;
53
+
54
+ (_a = (_b = element)[disableScrollElementProp]) !== null && _a !== void 0 ? _a : _b[disableScrollElementProp] = {
55
+ count: 0,
56
+ previousOverflowStyle: element.style.overflow,
57
+ previousPaddingRightStyle: element.style.paddingRight
58
+ };
59
+ }
60
+ //# sourceMappingURL=useDisableBodyScroll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/useDisableBodyScroll.ts"],"names":[],"mappings":"AAAA,SAAS,kBAAT,QAAmC,iCAAnC;AACA,SAAS,WAAT,QAA4B,OAA5B;AAEA,MAAM,wBAAwB,GAAG,8BAAjC;AAUA;;AAEG;;AACH,OAAM,SAAU,oBAAV,GAA8B;EAClC,MAAM;IAAE;EAAF,IAAqB,kBAAkB,EAA7C;EACA,OAAO,WAAW,CAAC,MAAK;IACtB,IAAI,cAAJ,EAAoB;MAClB,OAAO,aAAa,CAAC,cAAc,CAAC,IAAhB,CAApB;IACD;EACF,CAJiB,EAIf,CAAC,cAAD,CAJe,CAAlB;AAKD;AAED;;;;AAIG;;AACH,OAAM,SAAU,aAAV,CAAwB,MAAx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+B;IAGpE,yBAAyB,EAAE,OAAO,CAAC,KAAR,CAAc;EAH2B,CAAtE;AAKD","sourcesContent":["import { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport { useCallback } from 'react';\n\nconst disableScrollElementProp = '__fluentDisableScrollElement' as const;\n\ntype FluentDisableScrollElement = HTMLElement & {\n [disableScrollElementProp]: {\n count: number;\n previousOverflowStyle: string;\n previousPaddingRightStyle: string;\n };\n};\n\n/**\n * hook that disables body scrolling through `overflow: hidden` CSS property\n */\nexport function useDisableBodyScroll() {\n const { targetDocument } = useFluent_unstable();\n return useCallback(() => {\n if (targetDocument) {\n return disableScroll(targetDocument.body);\n }\n }, [targetDocument]);\n}\n\n/**\n * disables scrolling from a given element through `overflow: hidden` CSS property\n * @param target - element to disable scrolling from\n * @returns a method for enabling scrolling again\n */\nexport function disableScroll(target: HTMLElement) {\n const { clientWidth } = target.ownerDocument.documentElement;\n const innerWidth = target.ownerDocument.defaultView?.innerWidth ?? 0;\n assertIsDisableScrollElement(target);\n if (target[disableScrollElementProp].count === 0) {\n target.style.overflow = 'hidden';\n target.style.paddingRight = `${innerWidth - clientWidth}px`;\n }\n target[disableScrollElementProp].count++;\n return () => {\n target[disableScrollElementProp].count--;\n if (target[disableScrollElementProp].count === 0) {\n target.style.overflow = target[disableScrollElementProp].previousOverflowStyle;\n target.style.paddingRight = target[disableScrollElementProp].previousPaddingRightStyle;\n }\n };\n}\n\nfunction assertIsDisableScrollElement(element: HTMLElement): asserts element is FluentDisableScrollElement {\n (element as FluentDisableScrollElement)[disableScrollElementProp] ??= {\n count: 0,\n previousOverflowStyle: element.style.overflow,\n previousPaddingRightStyle: element.style.paddingRight,\n };\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,41 @@
1
+ import * as React from 'react';
2
+ import { useFocusFinders } from '@fluentui/react-tabster';
3
+ import { useFluent_unstable } from '@fluentui/react-shared-contexts';
4
+ import { isHTMLDialogElement } from './isHTMLDialogElement';
5
+ /**
6
+ * Focus first element on content when dialog is opened,
7
+ */
8
+
9
+ export function useFocusFirstElement(open, modalType) {
10
+ const {
11
+ findFirstFocusable
12
+ } = useFocusFinders();
13
+ const {
14
+ targetDocument
15
+ } = useFluent_unstable();
16
+ const dialogRef = React.useRef(null);
17
+ const triggerRef = React.useRef();
18
+ React.useEffect(() => {
19
+ var _a, _b;
20
+
21
+ if (!open) {
22
+ return (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
23
+ }
24
+
25
+ triggerRef.current = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;
26
+ const element = dialogRef.current && findFirstFocusable(dialogRef.current);
27
+
28
+ if (element) {
29
+ // this is only required for non native dialogs
30
+ if (!isHTMLDialogElement(dialogRef.current)) {
31
+ element.focus();
32
+ }
33
+ } else if (process.env.NODE_ENV !== 'production') {
34
+ (_b = triggerRef.current) === null || _b === void 0 ? void 0 : _b.blur(); // eslint-disable-next-line no-console
35
+
36
+ console.warn('A Dialog should have at least one focusable element inside DialogSurface');
37
+ }
38
+ }, [findFirstFocusable, open, modalType, targetDocument]);
39
+ return dialogRef;
40
+ }
41
+ //# sourceMappingURL=useFocusFirstElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/useFocusFirstElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,eAAT,QAAgC,yBAAhC;AACA,SAAS,kBAAT,QAAmC,iCAAnC;AAGA,SAAS,mBAAT,QAAoC,uBAApC;AAEA;;AAEG;;AACH,OAAM,SAAU,oBAAV,CAA+B,IAA/B,EAA8C,SAA9C,EAAwE;EAC5E,MAAM;IAAE;EAAF,IAAyB,eAAe,EAA9C;EACA,MAAM;IAAE;EAAF,IAAqB,kBAAkB,EAA7C;EACA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAN,CAAmC,IAAnC,CAAlB;EACA,MAAM,UAAU,GAAG,KAAK,CAAC,MAAN,EAAnB;EAEA,KAAK,CAAC,SAAN,CAAgB,MAAK;;;IACnB,IAAI,CAAC,IAAL,EAAW;MACT,OAAO,CAAA,EAAA,GAAA,UAAU,CAAC,OAAX,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,KAAF,EAAzB;IACD;;IACD,UAAU,CAAC,OAAX,GAAqB,cAAc,KAAA,IAAd,IAAA,cAAc,KAAA,KAAA,CAAd,GAAc,KAAA,CAAd,GAAA,cAAc,CAAE,aAArC;IACA,MAAM,OAAO,GAAG,SAAS,CAAC,OAAV,IAAqB,kBAAkB,CAAC,SAAS,CAAC,OAAX,CAAvD;;IACA,IAAI,OAAJ,EAAa;MACX;MACA,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,OAAX,CAAxB,EAA6C;QAC3C,OAAO,CAAC,KAAR;MACD;IACF,CALD,MAKO,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;MAChD,CAAA,EAAA,GAAA,UAAU,CAAC,OAAX,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,IAAF,EAAlB,CADgD,CAEhD;;MACA,OAAO,CAAC,IAAR,CAAa,0EAAb;IACD;EACF,CAhBD,EAgBG,CAAC,kBAAD,EAAqB,IAArB,EAA2B,SAA3B,EAAsC,cAAtC,CAhBH;EAkBA,OAAO,SAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport type { DialogSurfaceElement } from '../DialogSurface';\nimport type { DialogModalType } from '../Dialog';\nimport { isHTMLDialogElement } from './isHTMLDialogElement';\n\n/**\n * Focus first element on content when dialog is opened,\n */\nexport function useFocusFirstElement(open: boolean, modalType: DialogModalType) {\n const { findFirstFocusable } = useFocusFinders();\n const { targetDocument } = useFluent_unstable();\n const dialogRef = React.useRef<DialogSurfaceElement>(null);\n const triggerRef = React.useRef<HTMLElement>();\n\n React.useEffect(() => {\n if (!open) {\n return triggerRef.current?.focus();\n }\n triggerRef.current = targetDocument?.activeElement as HTMLElement | undefined;\n const element = dialogRef.current && findFirstFocusable(dialogRef.current);\n if (element) {\n // this is only required for non native dialogs\n if (!isHTMLDialogElement(dialogRef.current)) {\n element.focus();\n }\n } else if (process.env.NODE_ENV !== 'production') {\n triggerRef.current?.blur();\n // eslint-disable-next-line no-console\n console.warn('A Dialog should have at least one focusable element inside DialogSurface');\n }\n }, [findFirstFocusable, open, modalType, targetDocument]);\n\n return dialogRef;\n}\n"],"sourceRoot":"../src/"}
@@ -11,8 +11,6 @@ const useDialog_1 = /*#__PURE__*/require("./useDialog");
11
11
 
12
12
  const renderDialog_1 = /*#__PURE__*/require("./renderDialog");
13
13
 
14
- const useDialogStyles_1 = /*#__PURE__*/require("./useDialogStyles");
15
-
16
14
  const useDialogContextValues_1 = /*#__PURE__*/require("./useDialogContextValues");
17
15
  /**
18
16
  * The `Dialog` root level component serves as an interface for interaction with all possible behaviors exposed.
@@ -26,7 +24,6 @@ const useDialogContextValues_1 = /*#__PURE__*/require("./useDialogContextValues"
26
24
  exports.Dialog = /*#__PURE__*/React.memo(props => {
27
25
  const state = useDialog_1.useDialog_unstable(props);
28
26
  const contextValues = useDialogContextValues_1.useDialogContextValues_unstable(state);
29
- useDialogStyles_1.useDialogStyles_unstable(state);
30
27
  return renderDialog_1.renderDialog_unstable(state, contextValues);
31
28
  });
32
29
  exports.Dialog.displayName = 'Dialog';
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Dialog/Dialog.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;;AAEA,MAAA,wBAAA,gBAAA,OAAA,CAAA,0BAAA,CAAA;AAEA;;;;;;AAMG;;;AACU,OAAA,CAAA,MAAA,gBAAgC,KAAK,CAAC,IAAN,CAAW,KAAK,IAAG;EAC9D,MAAM,KAAK,GAAG,WAAA,CAAA,kBAAA,CAAmB,KAAnB,CAAd;EACA,MAAM,aAAa,GAAG,wBAAA,CAAA,+BAAA,CAAgC,KAAhC,CAAtB;EAEA,iBAAA,CAAA,wBAAA,CAAyB,KAAzB;EACA,OAAO,cAAA,CAAA,qBAAA,CAAsB,KAAtB,EAA6B,aAA7B,CAAP;AACD,CAN4C,CAAhC;AAQb,OAAA,CAAA,MAAA,CAAO,WAAP,GAAqB,QAArB","sourcesContent":["import * as React from 'react';\nimport { useDialog_unstable } from './useDialog';\nimport { renderDialog_unstable } from './renderDialog';\nimport { useDialogStyles_unstable } from './useDialogStyles';\nimport type { DialogProps } from './Dialog.types';\nimport { useDialogContextValues_unstable } from './useDialogContextValues';\n\n/**\n * The `Dialog` root level component serves as an interface for interaction with all possible behaviors exposed.\n * It provides context down the hierarchy to `children` compound components to allow functionality.\n * This component expects to receive as children either a `DialogSurface` or a `DialogTrigger`\n * and a `DialogSurface` (or some component that will eventually render one of those compound components)\n * in this specific order\n */\nexport const Dialog: React.FC<DialogProps> = React.memo(props => {\n const state = useDialog_unstable(props);\n const contextValues = useDialogContextValues_unstable(state);\n\n useDialogStyles_unstable(state);\n return renderDialog_unstable(state, contextValues);\n});\n\nDialog.displayName = 'Dialog';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["components/Dialog/Dialog.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAEA,MAAA,wBAAA,gBAAA,OAAA,CAAA,0BAAA,CAAA;AAEA;;;;;;AAMG;;;AACU,OAAA,CAAA,MAAA,gBAAgC,KAAK,CAAC,IAAN,CAAW,KAAK,IAAG;EAC9D,MAAM,KAAK,GAAG,WAAA,CAAA,kBAAA,CAAmB,KAAnB,CAAd;EACA,MAAM,aAAa,GAAG,wBAAA,CAAA,+BAAA,CAAgC,KAAhC,CAAtB;EAEA,OAAO,cAAA,CAAA,qBAAA,CAAsB,KAAtB,EAA6B,aAA7B,CAAP;AACD,CAL4C,CAAhC;AAOb,OAAA,CAAA,MAAA,CAAO,WAAP,GAAqB,QAArB","sourcesContent":["import * as React from 'react';\nimport { useDialog_unstable } from './useDialog';\nimport { renderDialog_unstable } from './renderDialog';\nimport type { DialogProps } from './Dialog.types';\nimport { useDialogContextValues_unstable } from './useDialogContextValues';\n\n/**\n * The `Dialog` root level component serves as an interface for interaction with all possible behaviors exposed.\n * It provides context down the hierarchy to `children` compound components to allow functionality.\n * This component expects to receive as children either a `DialogSurface` or a `DialogTrigger`\n * and a `DialogSurface` (or some component that will eventually render one of those compound components)\n * in this specific order\n */\nexport const Dialog: React.FC<DialogProps> = React.memo(props => {\n const state = useDialog_unstable(props);\n const contextValues = useDialogContextValues_unstable(state);\n\n return renderDialog_unstable(state, contextValues);\n});\n\nDialog.displayName = 'Dialog';\n"],"sourceRoot":"../src/"}
@@ -13,6 +13,4 @@ tslib_1.__exportStar(require("./Dialog.types"), exports);
13
13
  tslib_1.__exportStar(require("./renderDialog"), exports);
14
14
 
15
15
  tslib_1.__exportStar(require("./useDialog"), exports);
16
-
17
- tslib_1.__exportStar(require("./useDialogStyles"), exports);
18
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Dialog/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,UAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Dialog';\nexport * from './Dialog.types';\nexport * from './renderDialog';\nexport * from './useDialog';\nexport * from './useDialogStyles';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["components/Dialog/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,UAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Dialog';\nexport * from './Dialog.types';\nexport * from './renderDialog';\nexport * from './useDialog';\n"],"sourceRoot":"../src/"}
@@ -7,10 +7,6 @@ exports.renderDialog_unstable = void 0;
7
7
 
8
8
  const React = /*#__PURE__*/require("react");
9
9
 
10
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
-
12
- const react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
13
-
14
10
  const contexts_1 = /*#__PURE__*/require("../../contexts");
15
11
  /**
16
12
  * Render the final JSX of Dialog
@@ -20,19 +16,13 @@ const contexts_1 = /*#__PURE__*/require("../../contexts");
20
16
  const renderDialog_unstable = (state, contextValues) => {
21
17
  const {
22
18
  content,
23
- trigger,
24
- open
19
+ trigger
25
20
  } = state;
26
- const {
27
- slots,
28
- slotProps
29
- } = react_utilities_1.getSlots(state);
30
21
  return React.createElement(contexts_1.DialogProvider, {
31
22
  value: contextValues.dialog
32
23
  }, React.createElement(contexts_1.DialogSurfaceProvider, {
33
24
  value: contextValues.dialogSurface
34
- }, trigger, open && React.createElement(react_portal_1.Portal, null, slots.overlay && React.createElement(slots.overlay, { ...slotProps.overlay
35
- }), content)));
25
+ }, trigger, content));
36
26
  };
37
27
 
38
28
  exports.renderDialog_unstable = renderDialog_unstable;
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Dialog/renderDialog.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,UAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,qBAAqB,GAAG,CAAC,KAAD,EAAqB,aAArB,KAA2D;EAC9F,MAAM;IAAE,OAAF;IAAW,OAAX;IAAoB;EAApB,IAA6B,KAAnC;EACA,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,iBAAA,CAAA,QAAA,CAAsB,KAAtB,CAA7B;EAEA,OACE,KAAA,CAAA,aAAA,CAAC,UAAA,CAAA,cAAD,EAAe;IAAC,KAAK,EAAE,aAAa,CAAC;EAAtB,CAAf,EACE,KAAA,CAAA,aAAA,CAAC,UAAA,CAAA,qBAAD,EAAsB;IAAC,KAAK,EAAE,aAAa,CAAC;EAAtB,CAAtB,EACG,OADH,EAEG,IAAI,IACH,KAAA,CAAA,aAAA,CAAC,cAAA,CAAA,MAAD,EAAO,IAAP,EACG,KAAK,CAAC,OAAN,IAAiB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAK,SAAS,CAAC;EAAf,CAAd,CADpB,EAEG,OAFH,CAHJ,CADF,CADF;AAaD,CAjBM;;AAAM,OAAA,CAAA,qBAAA,GAAqB,qBAArB","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { Portal } from '@fluentui/react-portal';\nimport { DialogProvider, DialogSurfaceProvider } from '../../contexts';\nimport type { DialogState, DialogSlots, DialogContextValues } from './Dialog.types';\n\n/**\n * Render the final JSX of Dialog\n */\nexport const renderDialog_unstable = (state: DialogState, contextValues: DialogContextValues) => {\n const { content, trigger, open } = state;\n const { slots, slotProps } = getSlots<DialogSlots>(state);\n\n return (\n <DialogProvider value={contextValues.dialog}>\n <DialogSurfaceProvider value={contextValues.dialogSurface}>\n {trigger}\n {open && (\n <Portal>\n {slots.overlay && <slots.overlay {...slotProps.overlay} />}\n {content}\n </Portal>\n )}\n </DialogSurfaceProvider>\n </DialogProvider>\n );\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["components/Dialog/renderDialog.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,UAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,qBAAqB,GAAG,CAAC,KAAD,EAAqB,aAArB,KAA2D;EAC9F,MAAM;IAAE,OAAF;IAAW;EAAX,IAAuB,KAA7B;EAEA,OACE,KAAA,CAAA,aAAA,CAAC,UAAA,CAAA,cAAD,EAAe;IAAC,KAAK,EAAE,aAAa,CAAC;EAAtB,CAAf,EACE,KAAA,CAAA,aAAA,CAAC,UAAA,CAAA,qBAAD,EAAsB;IAAC,KAAK,EAAE,aAAa,CAAC;EAAtB,CAAtB,EACG,OADH,EAEG,OAFH,CADF,CADF;AAQD,CAXM;;AAAM,OAAA,CAAA,qBAAA,GAAqB,qBAArB","sourcesContent":["import * as React from 'react';\nimport { DialogProvider, DialogSurfaceProvider } from '../../contexts';\nimport type { DialogState, DialogContextValues } from './Dialog.types';\n\n/**\n * Render the final JSX of Dialog\n */\nexport const renderDialog_unstable = (state: DialogState, contextValues: DialogContextValues) => {\n const { content, trigger } = state;\n\n return (\n <DialogProvider value={contextValues.dialog}>\n <DialogSurfaceProvider value={contextValues.dialogSurface}>\n {trigger}\n {content}\n </DialogSurfaceProvider>\n </DialogProvider>\n );\n};\n"],"sourceRoot":"../src/"}
@@ -9,11 +9,11 @@ const React = /*#__PURE__*/require("react");
9
9
 
10
10
  const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
11
 
12
- const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
13
-
14
- const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
12
+ const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
15
13
 
16
14
  const utils_1 = /*#__PURE__*/require("../../utils");
15
+
16
+ const contexts_1 = /*#__PURE__*/require("../../contexts");
17
17
  /**
18
18
  * Create the state required to render Dialog.
19
19
  *
@@ -27,7 +27,6 @@ const utils_1 = /*#__PURE__*/require("../../utils");
27
27
  const useDialog_unstable = props => {
28
28
  const {
29
29
  children,
30
- overlay,
31
30
  modalType = 'modal',
32
31
  onOpenChange
33
32
  } = props;
@@ -37,63 +36,36 @@ const useDialog_unstable = props => {
37
36
  defaultState: props.defaultOpen,
38
37
  initialState: false
39
38
  });
40
- const overlayShorthand = react_utilities_1.resolveShorthand(overlay, {
41
- required: modalType !== 'non-modal',
42
- defaultProps: {
43
- 'aria-hidden': 'true'
44
- }
45
- });
46
39
  const requestOpenChange = react_utilities_1.useEventCallback(data => {
47
- const isDefaultPrevented = utils_1.normalizeDefaultPrevented(data.event);
48
-
49
- if (onOpenChange) {
50
- onOpenChange(data.event, data);
51
- } // if user prevents default then do not change state value
40
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(data.event, data); // if user prevents default then do not change state value
52
41
  // otherwise updates state value and trigger reference to the element that caused the opening
53
42
 
54
-
55
- if (!isDefaultPrevented()) {
56
- triggerRef.current = !open && data.open ? data.event.currentTarget : null;
43
+ if (!data.event.isDefaultPrevented()) {
57
44
  setOpen(data.open);
58
45
  }
59
46
  });
60
- const {
61
- contentRef,
62
- triggerRef
63
- } = useFocusFirstElement({
64
- open,
65
- modalType,
66
- requestOpenChange
67
- });
68
- const handleOverLayClick = react_utilities_1.useEventCallback(event => {
69
- var _a;
70
-
71
- (_a = overlayShorthand === null || overlayShorthand === void 0 ? void 0 : overlayShorthand.onClick) === null || _a === void 0 ? void 0 : _a.call(overlayShorthand, event);
72
-
73
- if (isOverlayClickDismiss(event, modalType)) {
74
- requestOpenChange({
75
- event,
76
- open: false,
77
- type: 'overlayClick'
78
- });
47
+ const focusRef = utils_1.useFocusFirstElement(open, modalType);
48
+ const nativeControlRef = utils_1.useControlNativeDialogOpenState(open, modalType);
49
+ const disableBodyScroll = utils_1.useDisableBodyScroll();
50
+ const isBodyScrollLocked = Boolean(open && modalType !== 'non-modal');
51
+ react_utilities_1.useIsomorphicLayoutEffect(() => {
52
+ if (isBodyScrollLocked) {
53
+ return disableBodyScroll();
79
54
  }
80
- });
55
+ }, [disableBodyScroll, isBodyScrollLocked]);
81
56
  return {
82
57
  components: {
83
- overlay: 'div'
84
- },
85
- overlay: overlayShorthand && { ...overlayShorthand,
86
- onClick: handleOverLayClick
58
+ backdrop: 'div'
87
59
  },
88
60
  open,
89
61
  modalType,
90
- content,
62
+ content: open ? content : null,
91
63
  trigger,
92
- triggerRef,
93
- contentRef,
94
64
  requestOpenChange,
95
65
  dialogBodyID: react_utilities_1.useId('dialog-body-'),
96
- dialogTitleID: react_utilities_1.useId('dialog-title-')
66
+ dialogTitleID: react_utilities_1.useId('dialog-title-'),
67
+ isNestedDialog: react_context_selector_1.useHasParentContext(contexts_1.DialogContext),
68
+ dialogRef: react_utilities_1.useMergedRefs(focusRef, nativeControlRef)
97
69
  };
98
70
  };
99
71
 
@@ -126,86 +98,4 @@ function childrenToTriggerAndContent(children) {
126
98
  return [undefined, undefined];
127
99
  }
128
100
  }
129
- /**
130
- * Checks is click event is a proper Overlay click dismiss
131
- */
132
-
133
-
134
- function isOverlayClickDismiss(event, type) {
135
- const isDefaultPrevented = utils_1.normalizeDefaultPrevented(event);
136
- return type === 'modal' && !isDefaultPrevented();
137
- }
138
- /**
139
- * Focus first element on content when dialog is opened,
140
- * in case there's no focusable element, then a eventlistener is added to document
141
- * to ensure Escape keydown functionality
142
- */
143
-
144
-
145
- function useFocusFirstElement({
146
- open,
147
- requestOpenChange,
148
- modalType
149
- }) {
150
- const {
151
- findFirstFocusable
152
- } = react_tabster_1.useFocusFinders();
153
- const {
154
- targetDocument
155
- } = react_shared_contexts_1.useFluent_unstable();
156
- const contentRef = React.useRef(null);
157
- const triggerRef = React.useRef(null);
158
- React.useEffect(() => {
159
- if (!open) {
160
- return;
161
- }
162
-
163
- const element = contentRef.current && findFirstFocusable(contentRef.current);
164
-
165
- if (element) {
166
- element.focus(); // NOTE: if it's non-modal global listener to escape is necessary
167
-
168
- if (modalType !== 'non-modal') {
169
- return;
170
- }
171
- } else {
172
- if (process.env.NODE_ENV !== 'production') {
173
- // eslint-disable-next-line no-console
174
- console.warn('A Dialog should have at least one focusable element inside DialogSurface');
175
- }
176
- }
177
-
178
- if (triggerRef.current && targetDocument) {
179
- const trigger = triggerRef.current; // if the trigger is still the active element, the default behavior is to return focus to document.body,
180
- // which can be achived by blurring
181
-
182
- if (targetDocument.activeElement === trigger) {
183
- trigger.blur();
184
- }
185
-
186
- const listener = event => {
187
- if (utils_1.isEscapeKeyDismiss(event, modalType)) {
188
- requestOpenChange({
189
- event,
190
- open: false,
191
- type: 'documentEscapeKeyDown'
192
- });
193
- trigger.focus();
194
- event.stopImmediatePropagation();
195
- }
196
- };
197
-
198
- targetDocument.addEventListener('keydown', listener, {
199
- passive: false
200
- });
201
- return () => {
202
- targetDocument.removeEventListener('keydown', listener);
203
- };
204
- }
205
- }, [findFirstFocusable, requestOpenChange, open, modalType, targetDocument]);
206
- return {
207
- contentRef,
208
- triggerRef
209
- };
210
- }
211
101
  //# sourceMappingURL=useDialog.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Dialog/useDialog.ts"],"names":[],"mappings":";;;;;;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AC7B;MACD;IACF,CAND,MAMO;MACL,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;QACzC;QACA,OAAO,CAAC,IAAR,CAAa,0EAAb;MACD;IACF;;IAED,IAAI,UAAU,CAAC,OAAX,IAAsB,cAA1B,EAA0C;MACxC,MAAM,OAAO,GAAG,UAAU,CAAC,OAA3B,CADwC,CAExC;MACA;;MACA,IAAI,cAAc,CAAC,aAAf,KAAiC,OAArC,EAA8C;QAC5C,OAAO,CAAC,IAAR;MACD;;MACD,MAAM,QAAQ,GAAI,KAAD,IAAyB;QACxC,IAAI,OAAA,CAAA,kBAAA,CAAmB,KAAnB,EAA0B,SAA1B,CAAJ,EAA0C;UACxC,iBAAiB,CAAC;YAChB,KADgB;YAEhB,IAAI,EAAE,KAFU;YAGhB,IAAI,EAAE;UAHU,CAAD,CAAjB;UAKA,OAAO,CAAC,KAAR;UACA,KAAK,CAAC,wBAAN;QACD;MACF,CAVD;;MAWA,cAAc,CAAC,gBAAf,CAAgC,SAAhC,EAA2C,QAA3C,EAAqD;QAAE,OAAO,EAAE;MAAX,CAArD;MACA,OAAO,MAAK;QACV,cAAc,CAAC,mBAAf,CAAmC,SAAnC,EAA8C,QAA9C;MACD,CAFD;IAGD;EACF,CA1CD,EA0CG,CAAC,kBAAD,EAAqB,iBAArB,EAAwC,IAAxC,EAA8C,SAA9C,EAAyD,cAAzD,CA1CH;EA4CA,OAAO;IAAE,UAAF;IAAc;EAAd,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { resolveShorthand, useControllableState, useEventCallback, useId } from '@fluentui/react-utilities';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport { normalizeDefaultPrevented, isEscapeKeyDismiss } from '../../utils';\n\nimport type { DialogProps, DialogState, DialogModalType, DialogOpenChangeData } 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, overlay, modalType = 'modal', onOpenChange } = 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 overlayShorthand = resolveShorthand(overlay, {\n required: modalType !== 'non-modal',\n defaultProps: {\n 'aria-hidden': 'true',\n },\n });\n\n const requestOpenChange = useEventCallback((data: DialogOpenChangeData) => {\n const isDefaultPrevented = normalizeDefaultPrevented(data.event);\n\n if (onOpenChange) {\n onOpenChange(data.event, data);\n }\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 (!isDefaultPrevented()) {\n (triggerRef as React.MutableRefObject<HTMLElement | null>).current =\n !open && data.open ? (data.event.currentTarget as HTMLElement) : null;\n setOpen(data.open);\n }\n });\n\n const { contentRef, triggerRef } = useFocusFirstElement({\n open,\n modalType,\n requestOpenChange,\n });\n\n const handleOverLayClick = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {\n overlayShorthand?.onClick?.(event);\n if (isOverlayClickDismiss(event, modalType)) {\n requestOpenChange({ event, open: false, type: 'overlayClick' });\n }\n });\n\n return {\n components: {\n overlay: 'div',\n },\n overlay: overlayShorthand && {\n ...overlayShorthand,\n onClick: handleOverLayClick,\n },\n open,\n modalType,\n content,\n trigger,\n triggerRef,\n contentRef,\n requestOpenChange,\n dialogBodyID: useId('dialog-body-'),\n dialogTitleID: useId('dialog-title-'),\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(\n 'Dialog must contain at least one child <DialogSurface/>,\\n' +\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\n/**\n * Checks is click event is a proper Overlay click dismiss\n */\nfunction isOverlayClickDismiss(event: React.MouseEvent, type: DialogModalType): boolean {\n const isDefaultPrevented = normalizeDefaultPrevented(event);\n return type === 'modal' && !isDefaultPrevented();\n}\n\n/**\n * Focus first element on content when dialog is opened,\n * in case there's no focusable element, then a eventlistener is added to document\n * to ensure Escape keydown functionality\n */\nfunction useFocusFirstElement({\n open,\n requestOpenChange,\n modalType,\n}: Pick<DialogState, 'open' | 'requestOpenChange' | 'modalType'>) {\n const { findFirstFocusable } = useFocusFinders();\n const { targetDocument } = useFluent_unstable();\n const contentRef = React.useRef<HTMLElement>(null);\n const triggerRef = React.useRef<HTMLElement>(null);\n\n React.useEffect(() => {\n if (!open) {\n return;\n }\n\n const element = contentRef.current && findFirstFocusable(contentRef.current);\n if (element) {\n element.focus();\n // NOTE: if it's non-modal global listener to escape is necessary\n if (modalType !== 'non-modal') {\n return;\n }\n } else {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn('A Dialog should have at least one focusable element inside DialogSurface');\n }\n }\n\n if (triggerRef.current && targetDocument) {\n const trigger = triggerRef.current;\n // if the trigger is still the active element, the default behavior is to return focus to document.body,\n // which can be achived by blurring\n if (targetDocument.activeElement === trigger) {\n trigger.blur();\n }\n const listener = (event: KeyboardEvent) => {\n if (isEscapeKeyDismiss(event, modalType)) {\n requestOpenChange({\n event,\n open: false,\n type: 'documentEscapeKeyDown',\n });\n trigger.focus();\n event.stopImmediatePropagation();\n }\n };\n targetDocument.addEventListener('keydown', listener, { passive: false });\n return () => {\n targetDocument.removeEventListener('keydown', listener);\n };\n }\n }, [findFirstFocusable, requestOpenChange, open, modalType, targetDocument]);\n\n return { contentRef, triggerRef };\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["components/Dialog/useDialog.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAOA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;;AACA,MAAA,UAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;AAIA;;;;;;;AAOG;;;AACI,MAAM,kBAAkB,GAAI,KAAD,IAAoC;EACpE,MAAM;IAAE,QAAF;IAAY,SAAS,GAAG,OAAxB;IAAiC;EAAjC,IAAkD,KAAxD;EAEA,MAAM,CAAC,OAAD,EAAU,OAAV,IAAqB,2BAA2B,CAAC,QAAD,CAAtD;EAEA,MAAM,CAAC,IAAD,EAAO,OAAP,IAAkB,iBAAA,CAAA,oBAAA,CAAqB;IAC3C,KAAK,EAAE,KAAK,CAAC,IAD8B;IAE3C,YAAY,EAAE,KAAK,CAAC,WAFuB;IAG3C,YAAY,EAAE;EAH6B,CAArB,CAAxB;EAMA,MAAM,iBAAiB,GAAG,iBAAA,CAAA,gBAAA,CAAkB,IAAD,IAA+B;IACxE,YAAY,KAAA,IAAZ,IAAA,YAAY,KAAA,KAAA,CAAZ,GAAY,KAAA,CAAZ,GAAA,YAAY,CAAG,IAAI,CAAC,KAAR,EAAe,IAAf,CAAZ,CADwE,CAGxE;IACA;;IACA,IAAI,CAAC,IAAI,CAAC,KAAL,CAAW,kBAAX,EAAL,EAAsC;MACpC,OAAO,CAAC,IAAI,CAAC,IAAN,CAAP;IACD;EACF,CARyB,CAA1B;EAUA,MAAM,QAAQ,GAAG,OAAA,CAAA,oBAAA,CAAqB,IAArB,EAA2B,SAA3B,C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O,aAAP;IACF;;IACA,KAAK,CAAL;MACE,OAAO,CAAC,SAAD,EAAY,aAAa,CAAC,CAAD,CAAzB,CAAP;IACF;;IACA;MACE,OAAO,CAAC,SAAD,EAAY,SAAZ,CAAP;EATJ;AAWD","sourcesContent":["import * as React from 'react';\nimport {\n useControllableState,\n useEventCallback,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { useHasParentContext } from '@fluentui/react-context-selector';\nimport { useControlNativeDialogOpenState, useDisableBodyScroll, useFocusFirstElement } from '../../utils';\nimport { DialogContext } from '../../contexts';\n\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 } = 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 const nativeControlRef = useControlNativeDialogOpenState(open, modalType);\n const disableBodyScroll = useDisableBodyScroll();\n const isBodyScrollLocked = Boolean(open && modalType !== 'non-modal');\n\n useIsomorphicLayoutEffect(() => {\n if (isBodyScrollLocked) {\n return disableBodyScroll();\n }\n }, [disableBodyScroll, isBodyScrollLocked]);\n\n return {\n components: {\n backdrop: 'div',\n },\n open,\n modalType,\n content: open ? content : null,\n trigger,\n requestOpenChange,\n dialogBodyID: useId('dialog-body-'),\n dialogTitleID: useId('dialog-title-'),\n isNestedDialog: useHasParentContext(DialogContext),\n dialogRef: useMergedRefs(focusRef, nativeControlRef),\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(\n 'Dialog must contain at least one child <DialogSurface/>,\\n' +\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"],"sourceRoot":"../src/"}
@@ -9,10 +9,10 @@ function useDialogContextValues_unstable(state) {
9
9
  const {
10
10
  modalType,
11
11
  open,
12
- triggerRef,
13
- contentRef,
14
12
  dialogBodyID,
13
+ dialogRef,
15
14
  dialogTitleID,
15
+ isNestedDialog,
16
16
  requestOpenChange
17
17
  } = state;
18
18
  /**
@@ -23,10 +23,10 @@ function useDialogContextValues_unstable(state) {
23
23
  const dialog = {
24
24
  open,
25
25
  modalType,
26
- triggerRef,
27
- contentRef,
26
+ dialogRef,
28
27
  dialogBodyID,
29
28
  dialogTitleID,
29
+ isNestedDialog,
30
30
  requestOpenChange
31
31
  };
32
32
  const dialogSurface = false;
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Dialog/useDialogContextValues.ts"],"names":[],"mappings":";;;;;;;AAGA,SAAgB,+BAAhB,CAAgD,KAAhD,EAAkE;EAChE,MAAM;IAAE,SAAF;IAAa,IAAb;IAAmB,UAAnB;IAA+B,UAA/B;IAA2C,YAA3C;IAAyD,aAAzD;IAAwE;EAAxE,IAA8F,KAApG;EAEA;;;AAGG;;EACH,MAAM,MAAM,GAAuB;IACjC,IADiC;IAEjC,SAFiC;IAGjC,UAHiC;IAIjC,UAJiC;IAKjC,YALiC;IAMjC,aANiC;IAOjC;EAPiC,CAAnC;EAUA,MAAM,aAAa,GAA8B,KAAjD;EAEA,OAAO;IAAE,MAAF;IAAU;EAAV,CAAP;AACD;;AApBD,OAAA,CAAA,+BAAA,GAAA,+BAAA","sourcesContent":["import type { DialogContextValue, DialogSurfaceContextValue } from '../../contexts';\nimport type { DialogContextValues, DialogState } from './Dialog.types';\n\nexport function useDialogContextValues_unstable(state: DialogState): DialogContextValues {\n const { modalType, open, triggerRef, contentRef, dialogBodyID, dialogTitleID, requestOpenChange } = state;\n\n /**\n * This context is created with \"@fluentui/react-context-selector\",\n * there is no sense to memoize it\n */\n const dialog: DialogContextValue = {\n open,\n modalType,\n triggerRef,\n contentRef,\n dialogBodyID,\n dialogTitleID,\n requestOpenChange,\n };\n\n const dialogSurface: DialogSurfaceContextValue = false;\n\n return { dialog, dialogSurface };\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["components/Dialog/useDialogContextValues.ts"],"names":[],"mappings":";;;;;;;AAGA,SAAgB,+BAAhB,CAAgD,KAAhD,EAAkE;EAChE,MAAM;IAAE,SAAF;IAAa,IAAb;IAAmB,YAAnB;IAAiC,SAAjC;IAA4C,aAA5C;IAA2D,cAA3D;IAA2E;EAA3E,IAAiG,KAAvG;EAEA;;;AAGG;;EACH,MAAM,MAAM,GAAuB;IACjC,IADiC;IAEjC,SAFiC;IAGjC,SAHiC;IAIjC,YAJiC;IAKjC,aALiC;IAMjC,cANiC;IAOjC;EAPiC,CAAnC;EAUA,MAAM,aAAa,GAA8B,KAAjD;EAEA,OAAO;IAAE,MAAF;IAAU;EAAV,CAAP;AACD;;AApBD,OAAA,CAAA,+BAAA,GAAA,+BAAA","sourcesContent":["import type { DialogContextValue, DialogSurfaceContextValue } from '../../contexts';\nimport type { DialogContextValues, DialogState } from './Dialog.types';\n\nexport function useDialogContextValues_unstable(state: DialogState): DialogContextValues {\n const { modalType, open, dialogBodyID, dialogRef, dialogTitleID, isNestedDialog, requestOpenChange } = state;\n\n /**\n * This context is created with \"@fluentui/react-context-selector\",\n * there is no sense to memoize it\n */\n const dialog: DialogContextValue = {\n open,\n modalType,\n dialogRef,\n dialogBodyID,\n dialogTitleID,\n isNestedDialog,\n requestOpenChange,\n };\n\n const dialogSurface: DialogSurfaceContextValue = false;\n\n return { dialog, dialogSurface };\n}\n"],"sourceRoot":"../src/"}