@fluentui/react-dialog 9.0.0-beta.9 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/CHANGELOG.json +141 -2
  2. package/CHANGELOG.md +47 -3
  3. package/README.md +41 -1
  4. package/dist/index.d.ts +27 -21
  5. package/lib/components/Dialog/Dialog.types.js.map +1 -1
  6. package/lib/components/Dialog/useDialog.js +5 -6
  7. package/lib/components/Dialog/useDialog.js.map +1 -1
  8. package/lib/components/Dialog/useDialogContextValues.js +4 -4
  9. package/lib/components/Dialog/useDialogContextValues.js.map +1 -1
  10. package/lib/components/DialogBody/useDialogBody.js +3 -3
  11. package/lib/components/DialogBody/useDialogBody.js.map +1 -1
  12. package/lib/components/DialogBody/useDialogBodyStyles.js +25 -17
  13. package/lib/components/DialogBody/useDialogBodyStyles.js.map +1 -1
  14. package/lib/components/DialogContent/DialogContent.js +2 -1
  15. package/lib/components/DialogContent/DialogContent.js.map +1 -1
  16. package/lib/components/DialogContent/DialogContent.types.js.map +1 -1
  17. package/lib/components/DialogContent/renderDialogContent.js +1 -2
  18. package/lib/components/DialogContent/renderDialogContent.js.map +1 -1
  19. package/lib/components/DialogContent/useDialogContent.js +11 -10
  20. package/lib/components/DialogContent/useDialogContent.js.map +1 -1
  21. package/lib/components/DialogContent/useDialogContentStyles.js +23 -9
  22. package/lib/components/DialogContent/useDialogContentStyles.js.map +1 -1
  23. package/lib/components/DialogSurface/DialogSurface.types.js.map +1 -1
  24. package/lib/components/DialogSurface/useDialogSurface.js +10 -81
  25. package/lib/components/DialogSurface/useDialogSurface.js.map +1 -1
  26. package/lib/components/DialogSurface/useDialogSurfaceStyles.js +61 -59
  27. package/lib/components/DialogSurface/useDialogSurfaceStyles.js.map +1 -1
  28. package/lib/components/DialogTitle/DialogTitle.types.js.map +1 -1
  29. package/lib/components/DialogTitle/useDialogTitle.js +1 -1
  30. package/lib/components/DialogTitle/useDialogTitle.js.map +1 -1
  31. package/lib/components/DialogTitle/useDialogTitleStyles.js +29 -29
  32. package/lib/components/DialogTrigger/DialogTrigger.types.js.map +1 -1
  33. package/lib/components/DialogTrigger/useDialogTrigger.js +4 -3
  34. package/lib/components/DialogTrigger/useDialogTrigger.js.map +1 -1
  35. package/lib/contexts/constants.js +1 -1
  36. package/lib/contexts/constants.js.map +1 -1
  37. package/lib/contexts/dialogContext.js.map +1 -1
  38. package/lib/utils/index.js +0 -2
  39. package/lib/utils/index.js.map +1 -1
  40. package/lib/utils/isEscapeKeyDown.js +1 -4
  41. package/lib/utils/isEscapeKeyDown.js.map +1 -1
  42. package/lib/utils/useFocusFirstElement.js +7 -8
  43. package/lib/utils/useFocusFirstElement.js.map +1 -1
  44. package/lib-commonjs/components/Dialog/useDialog.js +3 -4
  45. package/lib-commonjs/components/Dialog/useDialog.js.map +1 -1
  46. package/lib-commonjs/components/Dialog/useDialogContextValues.js +4 -4
  47. package/lib-commonjs/components/Dialog/useDialogContextValues.js.map +1 -1
  48. package/lib-commonjs/components/DialogBody/useDialogBody.js +3 -4
  49. package/lib-commonjs/components/DialogBody/useDialogBody.js.map +1 -1
  50. package/lib-commonjs/components/DialogBody/useDialogBodyStyles.js +25 -18
  51. package/lib-commonjs/components/DialogBody/useDialogBodyStyles.js.map +1 -1
  52. package/lib-commonjs/components/DialogContent/DialogContent.js +2 -1
  53. package/lib-commonjs/components/DialogContent/DialogContent.js.map +1 -1
  54. package/lib-commonjs/components/DialogContent/renderDialogContent.js +1 -2
  55. package/lib-commonjs/components/DialogContent/renderDialogContent.js.map +1 -1
  56. package/lib-commonjs/components/DialogContent/useDialogContent.js +12 -10
  57. package/lib-commonjs/components/DialogContent/useDialogContent.js.map +1 -1
  58. package/lib-commonjs/components/DialogContent/useDialogContentStyles.js +24 -8
  59. package/lib-commonjs/components/DialogContent/useDialogContentStyles.js.map +1 -1
  60. package/lib-commonjs/components/DialogSurface/useDialogSurface.js +10 -81
  61. package/lib-commonjs/components/DialogSurface/useDialogSurface.js.map +1 -1
  62. package/lib-commonjs/components/DialogSurface/useDialogSurfaceStyles.js +62 -60
  63. package/lib-commonjs/components/DialogSurface/useDialogSurfaceStyles.js.map +1 -1
  64. package/lib-commonjs/components/DialogTitle/useDialogTitle.js +1 -1
  65. package/lib-commonjs/components/DialogTitle/useDialogTitle.js.map +1 -1
  66. package/lib-commonjs/components/DialogTitle/useDialogTitleStyles.js +29 -29
  67. package/lib-commonjs/components/DialogTrigger/useDialogTrigger.js +4 -4
  68. package/lib-commonjs/components/DialogTrigger/useDialogTrigger.js.map +1 -1
  69. package/lib-commonjs/contexts/constants.js +2 -2
  70. package/lib-commonjs/contexts/constants.js.map +1 -1
  71. package/lib-commonjs/contexts/dialogContext.js.map +1 -1
  72. package/lib-commonjs/utils/index.js +0 -4
  73. package/lib-commonjs/utils/index.js.map +1 -1
  74. package/lib-commonjs/utils/isEscapeKeyDown.js +1 -5
  75. package/lib-commonjs/utils/isEscapeKeyDown.js.map +1 -1
  76. package/lib-commonjs/utils/useFocusFirstElement.js +7 -9
  77. package/lib-commonjs/utils/useFocusFirstElement.js.map +1 -1
  78. package/package.json +9 -11
  79. package/lib/utils/isHTMLDialogElement.js +0 -4
  80. package/lib/utils/isHTMLDialogElement.js.map +0 -1
  81. package/lib/utils/useControlNativeDialogOpenState.js +0 -20
  82. package/lib/utils/useControlNativeDialogOpenState.js.map +0 -1
  83. package/lib-commonjs/utils/isHTMLDialogElement.js +0 -13
  84. package/lib-commonjs/utils/isHTMLDialogElement.js.map +0 -1
  85. package/lib-commonjs/utils/useControlNativeDialogOpenState.js +0 -31
  86. package/lib-commonjs/utils/useControlNativeDialogOpenState.js.map +0 -1
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.BODY_GRID_AREA = exports.TITLE_ACTION_GRID_AREA = exports.TITLE_GRID_AREA = exports.ACTIONS_END_GRID_AREA = exports.ACTIONS_START_GRID_AREA = exports.SURFACE_BORDER_WIDTH = exports.SURFACE_BORDER_RADIUS = exports.DIALOG_GAP = exports.SURFACE_PADDING = exports.MEDIA_QUERY_BREAKPOINT_SELECTOR = void 0;
6
+ exports.CONTENT_GRID_AREA = exports.TITLE_ACTION_GRID_AREA = exports.TITLE_GRID_AREA = exports.ACTIONS_END_GRID_AREA = exports.ACTIONS_START_GRID_AREA = exports.SURFACE_BORDER_WIDTH = exports.SURFACE_BORDER_RADIUS = exports.DIALOG_GAP = exports.SURFACE_PADDING = exports.MEDIA_QUERY_BREAKPOINT_SELECTOR = void 0;
7
7
  exports.MEDIA_QUERY_BREAKPOINT_SELECTOR = '@media screen and (max-width: 480px)';
8
8
  exports.SURFACE_PADDING = '24px';
9
9
  exports.DIALOG_GAP = '8px';
@@ -13,5 +13,5 @@ exports.ACTIONS_START_GRID_AREA = 'actions-start';
13
13
  exports.ACTIONS_END_GRID_AREA = 'actions-end';
14
14
  exports.TITLE_GRID_AREA = 'title';
15
15
  exports.TITLE_ACTION_GRID_AREA = 'close-button';
16
- exports.BODY_GRID_AREA = 'body';
16
+ exports.CONTENT_GRID_AREA = 'body';
17
17
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-dialog/src/contexts/constants.ts"],"names":[],"mappings":";;;;;;AAAa,OAAA,CAAA,+BAAA,GAAkC,sCAAlC;AACA,OAAA,CAAA,eAAA,GAAkB,MAAlB;AACA,OAAA,CAAA,UAAA,GAAa,KAAb;AACA,OAAA,CAAA,qBAAA,GAAwB,KAAxB;AACA,OAAA,CAAA,oBAAA,GAAuB,KAAvB;AAEA,OAAA,CAAA,uBAAA,GAA0B,eAA1B;AACA,OAAA,CAAA,qBAAA,GAAwB,aAAxB;AACA,OAAA,CAAA,eAAA,GAAkB,OAAlB;AACA,OAAA,CAAA,sBAAA,GAAyB,cAAzB;AACA,OAAA,CAAA,cAAA,GAAiB,MAAjB","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-dialog/src/contexts/constants.ts"],"names":[],"mappings":";;;;;;AAAa,OAAA,CAAA,+BAAA,GAAkC,sCAAlC;AACA,OAAA,CAAA,eAAA,GAAkB,MAAlB;AACA,OAAA,CAAA,UAAA,GAAa,KAAb;AACA,OAAA,CAAA,qBAAA,GAAwB,KAAxB;AACA,OAAA,CAAA,oBAAA,GAAuB,KAAvB;AAEA,OAAA,CAAA,uBAAA,GAA0B,eAA1B;AACA,OAAA,CAAA,qBAAA,GAAwB,aAAxB;AACA,OAAA,CAAA,eAAA,GAAkB,OAAlB;AACA,OAAA,CAAA,sBAAA,GAAyB,cAAzB;AACA,OAAA,CAAA,iBAAA,GAAoB,MAApB","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 CONTENT_GRID_AREA = 'body';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-dialog/src/contexts/dialogContext.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;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,OAAA,CAAA,aAAA,gBAAyD,wBAAA,CAAA,aAAA,CACpE,SADoE,CAAzD;AAIA,OAAA,CAAA,cAAA,GAAiB,OAAA,CAAA,aAAA,CAAc,QAA/B;;AACN,MAAM,yBAAyB,GAAO,QAAJ,IACvC,wBAAA,CAAA,kBAAA,CAAmB,OAAA,CAAA,aAAnB,EAAkC,CAAC,GAAG,GAAG,mBAAP,KAA+B,QAAQ,CAAC,GAAD,CAAzE,CADK;;AAAM,OAAA,CAAA,yBAAA,GAAyB,yBAAzB","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/"}
1
+ {"version":3,"sources":["packages/react-components/react-dialog/src/contexts/dialogContext.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;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,OAAA,CAAA,aAAA,gBAAyD,wBAAA,CAAA,aAAA,CACpE,SADoE,CAAzD;AAIA,OAAA,CAAA,cAAA,GAAiB,OAAA,CAAA,aAAA,CAAc,QAA/B;;AACN,MAAM,yBAAyB,GAAO,QAAJ,IACvC,wBAAA,CAAA,kBAAA,CAAmB,OAAA,CAAA,aAAnB,EAAkC,CAAC,GAAG,GAAG,mBAAP,KAA+B,QAAQ,CAAC,GAAD,CAAzE,CADK;;AAAM,OAAA,CAAA,yBAAA,GAAyB,yBAAzB","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 dialogContentId?: 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/"}
@@ -11,8 +11,4 @@ tslib_1.__exportStar(require("./isEscapeKeyDown"), exports);
11
11
  tslib_1.__exportStar(require("./useDisableBodyScroll"), exports);
12
12
 
13
13
  tslib_1.__exportStar(require("./useFocusFirstElement"), exports);
14
-
15
- tslib_1.__exportStar(require("./isHTMLDialogElement"), exports);
16
-
17
- tslib_1.__exportStar(require("./useControlNativeDialogOpenState"), exports);
18
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-dialog/src/utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,uBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mCAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './isEscapeKeyDown';\nexport * from './useDisableBodyScroll';\nexport * from './useFocusFirstElement';\nexport * from './isHTMLDialogElement';\nexport * from './useControlNativeDialogOpenState';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-dialog/src/utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './isEscapeKeyDown';\nexport * from './useDisableBodyScroll';\nexport * from './useFocusFirstElement';\n"],"sourceRoot":"../src/"}
@@ -6,17 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.isEscapeKeyDismiss = void 0;
7
7
 
8
8
  const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
9
-
10
- const isHTMLDialogElement_1 = /*#__PURE__*/require("./isHTMLDialogElement");
11
9
  /**
12
10
  * Checks if keydown event is a proper Escape key dismiss
13
11
  */
14
12
 
15
13
 
16
14
  function isEscapeKeyDismiss(event, modalType) {
17
- return event.key === keyboard_keys_1.Escape && ( // `non-modal` should always have Escape key handling
18
- // `modal` should only be handled in the case of non native dialog
19
- modalType === 'non-modal' || !isHTMLDialogElement_1.isHTMLDialogElement(event.currentTarget) && modalType === 'modal') && !event.isDefaultPrevented();
15
+ return event.key === keyboard_keys_1.Escape && modalType !== 'alert' && !event.isDefaultPrevented();
20
16
  }
21
17
 
22
18
  exports.isEscapeKeyDismiss = isEscapeKeyDismiss;
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-dialog/src/utils/isEscapeKeyDown.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AAGA,MAAA,qBAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;AAEA;;AAEG;;;AACH,SAAgB,kBAAhB,CACE,KADF,EAEE,SAFF,EAE4B;EAE1B,OACE,KAAK,CAAC,GAAN,KAAc,eAAA,CAAA,MAAd,MACA;EACA;EACC,SAAS,KAAK,WAAd,IAA8B,CAAC,qBAAA,CAAA,mBAAA,CAAoB,KAAK,CAAC,aAA1B,CAAD,IAA6C,SAAS,KAAK,OAH1F,KAIA,CAAC,KAAK,CAAC,kBAAN,EALH;AAOD;;AAXD,OAAA,CAAA,kBAAA,GAAA,kBAAA","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/"}
1
+ {"version":3,"sources":["packages/react-components/react-dialog/src/utils/isEscapeKeyDown.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;AAIA;;AAEG;;;AACH,SAAgB,kBAAhB,CACE,KADF,EAEE,SAFF,EAE4B;EAE1B,OAAO,KAAK,CAAC,GAAN,KAAc,eAAA,CAAA,MAAd,IAAwB,SAAS,KAAK,OAAtC,IAAiD,CAAC,KAAK,CAAC,kBAAN,EAAzD;AACD;;AALD,OAAA,CAAA,kBAAA,GAAA,kBAAA","sourcesContent":["import * as React from 'react';\nimport { Escape } from '@fluentui/keyboard-keys';\nimport type { DialogModalType } from '../components/Dialog/Dialog.types';\nimport { DialogSurfaceElement } from '../DialogSurface';\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 event.key === Escape && modalType !== 'alert' && !event.isDefaultPrevented();\n}\n"],"sourceRoot":"../src/"}
@@ -10,8 +10,6 @@ const React = /*#__PURE__*/require("react");
10
10
  const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
11
11
 
12
12
  const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
13
-
14
- const isHTMLDialogElement_1 = /*#__PURE__*/require("./isHTMLDialogElement");
15
13
  /**
16
14
  * Focus first element on content when dialog is opened,
17
15
  */
@@ -37,14 +35,14 @@ function useFocusFirstElement(open, modalType) {
37
35
  const element = dialogRef.current && findFirstFocusable(dialogRef.current);
38
36
 
39
37
  if (element) {
40
- // this is only required for non native dialogs
41
- if (!isHTMLDialogElement_1.isHTMLDialogElement(dialogRef.current)) {
42
- element.focus();
43
- }
44
- } else if (process.env.NODE_ENV !== 'production') {
45
- (_b = triggerRef.current) === null || _b === void 0 ? void 0 : _b.blur(); // eslint-disable-next-line no-console
38
+ element.focus();
39
+ } else {
40
+ (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.focus(); // https://github.com/microsoft/fluentui/issues/25150
46
41
 
47
- console.warn('A Dialog should have at least one focusable element inside DialogSurface');
42
+ if (process.env.NODE_ENV !== 'production') {
43
+ // eslint-disable-next-line no-console
44
+ console.warn(['@fluentui/react-dialog: a Dialog should have at least one focusable element inside DialogSurface.', 'Please add at least a close button either on `DialogTitle` action slot or inside `DialogActions`'].join('\n'));
45
+ }
48
46
  }
49
47
  }, [findFirstFocusable, open, modalType, targetDocument]);
50
48
  return dialogRef;
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-dialog/src/utils/useFocusFirstElement.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AAGA,MAAA,qBAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;AAEA;;AAEG;;;AACH,SAAgB,oBAAhB,CAAqC,IAArC,EAAoD,SAApD,EAA8E;EAC5E,MAAM;IAAE;EAAF,IAAyB,eAAA,CAAA,eAAA,EAA/B;EACA,MAAM;IAAE;EAAF,IAAqB,uBAAA,CAAA,kBAAA,EAA3B;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,qBAAA,CAAA,mBAAA,CAAoB,SAAS,CAAC,OAA9B,CAAL,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;;AAzBD,OAAA,CAAA,oBAAA,GAAA,oBAAA","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/"}
1
+ {"version":3,"sources":["packages/react-components/react-dialog/src/utils/useFocusFirstElement.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;AAIA;;AAEG;;;AACH,SAAgB,oBAAhB,CAAqC,IAArC,EAAoD,SAApD,EAA8E;EAC5E,MAAM;IAAE;EAAF,IAAyB,eAAA,CAAA,eAAA,EAA/B;EACA,MAAM;IAAE;EAAF,IAAqB,uBAAA,CAAA,kBAAA,EAA3B;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,OAAO,CAAC,KAAR;IACD,CAFD,MAEO;MACL,CAAA,EAAA,GAAA,SAAS,CAAC,OAAV,MAAiB,IAAjB,IAAiB,EAAA,KAAA,KAAA,CAAjB,GAAiB,KAAA,CAAjB,GAAiB,EAAA,CAAE,KAAF,EAAjB,CADK,CACuB;;MAC5B,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;QACzC;QACA,OAAO,CAAC,IAAR,CACE,CACE,mGADF,EAEE,kGAFF,EAGE,IAHF,CAGO,IAHP,CADF;MAMD;IACF;EACF,CApBD,EAoBG,CAAC,kBAAD,EAAqB,IAArB,EAA2B,SAA3B,EAAsC,cAAtC,CApBH;EAsBA,OAAO,SAAP;AACD;;AA7BD,OAAA,CAAA,oBAAA,GAAA,oBAAA","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';\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 element.focus();\n } else {\n dialogRef.current?.focus(); // https://github.com/microsoft/fluentui/issues/25150\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(\n [\n '@fluentui/react-dialog: a Dialog should have at least one focusable element inside DialogSurface.',\n 'Please add at least a close button either on `DialogTitle` action slot or inside `DialogActions`',\n ].join('\\n'),\n );\n }\n }\n }, [findFirstFocusable, open, modalType, targetDocument]);\n\n return dialogRef;\n}\n"],"sourceRoot":"../src/"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-dialog",
3
- "version": "9.0.0-beta.9",
3
+ "version": "9.0.0",
4
4
  "description": "Dialog component for Fluent UI React",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -29,20 +29,20 @@
29
29
  "devDependencies": {
30
30
  "@fluentui/eslint-plugin": "*",
31
31
  "@fluentui/react-conformance": "*",
32
- "@fluentui/react-conformance-griffel": "9.0.0-beta.14",
32
+ "@fluentui/react-conformance-griffel": "9.0.0-beta.15",
33
33
  "@fluentui/scripts": "^1.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "@griffel/react": "^1.3.0",
37
- "@fluentui/react-utilities": "^9.1.0",
36
+ "@griffel/react": "^1.4.0",
37
+ "@fluentui/react-utilities": "^9.1.1",
38
38
  "@fluentui/keyboard-keys": "^9.0.0",
39
- "@fluentui/react-context-selector": "^9.0.3",
39
+ "@fluentui/react-context-selector": "^9.0.4",
40
40
  "@fluentui/react-shared-contexts": "^9.0.1",
41
- "@fluentui/react-aria": "^9.2.0",
41
+ "@fluentui/react-aria": "^9.2.2",
42
42
  "@fluentui/react-icons": "^2.0.175",
43
- "@fluentui/react-tabster": "^9.1.1",
43
+ "@fluentui/react-tabster": "^9.1.3",
44
44
  "@fluentui/react-theme": "^9.1.0",
45
- "@fluentui/react-portal": "^9.0.5",
45
+ "@fluentui/react-portal": "^9.0.7",
46
46
  "tslib": "^2.1.0"
47
47
  },
48
48
  "peerDependencies": {
@@ -53,9 +53,7 @@
53
53
  },
54
54
  "beachball": {
55
55
  "disallowedChangeTypes": [
56
- "major",
57
- "minor",
58
- "patch"
56
+ "major"
59
57
  ]
60
58
  },
61
59
  "exports": {
@@ -1,4 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"sources":["packages/react-components/react-dialog/src/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/"}
@@ -1,20 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"sources":["packages/react-components/react-dialog/src/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/"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isHTMLDialogElement = void 0;
7
-
8
- function isHTMLDialogElement(element) {
9
- return Boolean(element && 'open' in element && 'show' in element && 'showModal' in element && 'close' in element);
10
- }
11
-
12
- exports.isHTMLDialogElement = isHTMLDialogElement;
13
- //# sourceMappingURL=isHTMLDialogElement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["packages/react-components/react-dialog/src/utils/isHTMLDialogElement.ts"],"names":[],"mappings":";;;;;;;AAEA,SAAgB,mBAAhB,CAAoC,OAApC,EAAgE;EAC9D,OAAO,OAAO,CAAC,OAAO,IAAI,UAAU,OAArB,IAAgC,UAAU,OAA1C,IAAqD,eAAe,OAApE,IAA+E,WAAW,OAA3F,CAAd;AACD;;AAFD,OAAA,CAAA,mBAAA,GAAA,mBAAA","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/"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useControlNativeDialogOpenState = void 0;
7
-
8
- const React = /*#__PURE__*/require("react");
9
-
10
- const isHTMLDialogElement_1 = /*#__PURE__*/require("./isHTMLDialogElement");
11
-
12
- function useControlNativeDialogOpenState(open, modalType) {
13
- const dialogSurfaceRef = React.useRef(null);
14
- React.useEffect(() => {
15
- if (isHTMLDialogElement_1.isHTMLDialogElement(dialogSurfaceRef.current) && dialogSurfaceRef.current.open !== open) {
16
- if (open) {
17
- if (modalType === 'non-modal') {
18
- dialogSurfaceRef.current.show();
19
- } else {
20
- dialogSurfaceRef.current.showModal();
21
- }
22
- } else {
23
- dialogSurfaceRef.current.close();
24
- }
25
- }
26
- }, [open, modalType]);
27
- return dialogSurfaceRef;
28
- }
29
-
30
- exports.useControlNativeDialogOpenState = useControlNativeDialogOpenState;
31
- //# sourceMappingURL=useControlNativeDialogOpenState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["packages/react-components/react-dialog/src/utils/useControlNativeDialogOpenState.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,qBAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAIA,SAAgB,+BAAhB,CAAgD,IAAhD,EAA+D,SAA/D,EAAyF;EACvF,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAN,CAAmC,IAAnC,CAAzB;EAEA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,IAAI,qBAAA,CAAA,mBAAA,CAAoB,gBAAgB,CAAC,OAArC,KAAiD,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;;AAlBD,OAAA,CAAA,+BAAA,GAAA,+BAAA","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/"}