@fluentui/react-dialog 9.0.0-beta.10 → 9.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +34 -1
- package/CHANGELOG.md +14 -2
- package/dist/index.d.ts +1 -1
- package/lib/components/Dialog/useDialog.js +3 -4
- package/lib/components/Dialog/useDialog.js.map +1 -1
- package/lib/components/DialogSurface/DialogSurface.types.js.map +1 -1
- package/lib/components/DialogSurface/useDialogSurface.js +5 -77
- package/lib/components/DialogSurface/useDialogSurface.js.map +1 -1
- package/lib/components/DialogTitle/useDialogTitleStyles.js +29 -29
- package/lib/utils/index.js +0 -2
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isEscapeKeyDown.js +1 -4
- package/lib/utils/isEscapeKeyDown.js.map +1 -1
- package/lib/utils/useFocusFirstElement.js +1 -5
- package/lib/utils/useFocusFirstElement.js.map +1 -1
- package/lib-commonjs/components/Dialog/useDialog.js +1 -2
- package/lib-commonjs/components/Dialog/useDialog.js.map +1 -1
- package/lib-commonjs/components/DialogSurface/useDialogSurface.js +5 -77
- package/lib-commonjs/components/DialogSurface/useDialogSurface.js.map +1 -1
- package/lib-commonjs/components/DialogTitle/useDialogTitleStyles.js +29 -29
- package/lib-commonjs/utils/index.js +0 -4
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isEscapeKeyDown.js +1 -5
- package/lib-commonjs/utils/isEscapeKeyDown.js.map +1 -1
- package/lib-commonjs/utils/useFocusFirstElement.js +1 -6
- package/lib-commonjs/utils/useFocusFirstElement.js.map +1 -1
- package/package.json +4 -4
- package/lib/utils/isHTMLDialogElement.js +0 -4
- package/lib/utils/isHTMLDialogElement.js.map +0 -1
- package/lib/utils/useControlNativeDialogOpenState.js +0 -20
- package/lib/utils/useControlNativeDialogOpenState.js.map +0 -1
- package/lib-commonjs/utils/isHTMLDialogElement.js +0 -13
- package/lib-commonjs/utils/isHTMLDialogElement.js.map +0 -1
- package/lib-commonjs/utils/useControlNativeDialogOpenState.js +0 -31
- package/lib-commonjs/utils/useControlNativeDialogOpenState.js.map +0 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,40 @@
|
|
|
2
2
|
"name": "@fluentui/react-dialog",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Mon, 03 Oct 2022 22:22:47 GMT",
|
|
6
|
+
"tag": "@fluentui/react-dialog_v9.0.0-beta.11",
|
|
7
|
+
"version": "9.0.0-beta.11",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "bernardo.sunderhus@gmail.com",
|
|
12
|
+
"package": "@fluentui/react-dialog",
|
|
13
|
+
"commit": "da8a1d4d97efdb6d95818b605136415d9428e811",
|
|
14
|
+
"comment": "feat: removes DialogSurface native dialog support "
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@fluentui/react-dialog",
|
|
19
|
+
"comment": "Bump @fluentui/react-aria to v9.2.1",
|
|
20
|
+
"commit": "b0b7f99bbbb05b0bd136432983a74fea252c7163"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@fluentui/react-dialog",
|
|
25
|
+
"comment": "Bump @fluentui/react-tabster to v9.1.2",
|
|
26
|
+
"commit": "b0b7f99bbbb05b0bd136432983a74fea252c7163"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "beachball",
|
|
30
|
+
"package": "@fluentui/react-dialog",
|
|
31
|
+
"comment": "Bump @fluentui/react-portal to v9.0.6",
|
|
32
|
+
"commit": "b0b7f99bbbb05b0bd136432983a74fea252c7163"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"date": "Fri, 23 Sep 2022 10:32:29 GMT",
|
|
6
39
|
"tag": "@fluentui/react-dialog_v9.0.0-beta.10",
|
|
7
40
|
"version": "9.0.0-beta.10",
|
|
8
41
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-dialog
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 03 Oct 2022 22:22:47 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-beta.11](https://github.com/microsoft/fluentui/tree/@fluentui/react-dialog_v9.0.0-beta.11)
|
|
8
|
+
|
|
9
|
+
Mon, 03 Oct 2022 22:22:47 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-dialog_v9.0.0-beta.10..@fluentui/react-dialog_v9.0.0-beta.11)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- feat: removes DialogSurface native dialog support ([PR #24979](https://github.com/microsoft/fluentui/pull/24979) by bernardo.sunderhus@gmail.com)
|
|
15
|
+
- Bump @fluentui/react-aria to v9.2.1 ([PR #25016](https://github.com/microsoft/fluentui/pull/25016) by beachball)
|
|
16
|
+
- Bump @fluentui/react-tabster to v9.1.2 ([PR #25016](https://github.com/microsoft/fluentui/pull/25016) by beachball)
|
|
17
|
+
- Bump @fluentui/react-portal to v9.0.6 ([PR #25016](https://github.com/microsoft/fluentui/pull/25016) by beachball)
|
|
18
|
+
|
|
7
19
|
## [9.0.0-beta.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-dialog_v9.0.0-beta.10)
|
|
8
20
|
|
|
9
|
-
Fri, 23 Sep 2022 10:32:
|
|
21
|
+
Fri, 23 Sep 2022 10:32:29 GMT
|
|
10
22
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-dialog_v9.0.0-beta.9..@fluentui/react-dialog_v9.0.0-beta.10)
|
|
11
23
|
|
|
12
24
|
### Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -235,7 +235,7 @@ export declare type DialogSurfaceSlots = {
|
|
|
235
235
|
* since native `<dialog>` element supports [::backdrop](https://developer.mozilla.org/en-US/docs/Web/CSS/::backdrop)
|
|
236
236
|
*/
|
|
237
237
|
backdrop?: Slot<'div'>;
|
|
238
|
-
root:
|
|
238
|
+
root: Slot<'div'>;
|
|
239
239
|
};
|
|
240
240
|
|
|
241
241
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useControllableState, useEventCallback, useId, useIsomorphicLayoutEffect
|
|
2
|
+
import { useControllableState, useEventCallback, useId, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
|
3
3
|
import { useHasParentContext } from '@fluentui/react-context-selector';
|
|
4
|
-
import {
|
|
4
|
+
import { useDisableBodyScroll, useFocusFirstElement } from '../../utils';
|
|
5
5
|
import { DialogContext } from '../../contexts';
|
|
6
6
|
/**
|
|
7
7
|
* Create the state required to render Dialog.
|
|
@@ -33,7 +33,6 @@ export const useDialog_unstable = props => {
|
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
const focusRef = useFocusFirstElement(open, modalType);
|
|
36
|
-
const nativeControlRef = useControlNativeDialogOpenState(open, modalType);
|
|
37
36
|
const disableBodyScroll = useDisableBodyScroll();
|
|
38
37
|
const isBodyScrollLocked = Boolean(open && modalType !== 'non-modal');
|
|
39
38
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -53,7 +52,7 @@ export const useDialog_unstable = props => {
|
|
|
53
52
|
dialogContentId: useId('dialog-content-'),
|
|
54
53
|
dialogTitleId: useId('dialog-title-'),
|
|
55
54
|
isNestedDialog: useHasParentContext(DialogContext),
|
|
56
|
-
dialogRef:
|
|
55
|
+
dialogRef: focusRef
|
|
57
56
|
};
|
|
58
57
|
};
|
|
59
58
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-dialog/src/components/Dialog/useDialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-dialog/src/components/Dialog/useDialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,oBAAT,EAA+B,gBAA/B,EAAiD,KAAjD,EAAwD,yBAAxD,QAAyF,2BAAzF;AACA,SAAS,mBAAT,QAAoC,kCAApC;AACA,SAAS,oBAAT,EAA+B,oBAA/B,QAA2D,aAA3D;AACA,SAAS,aAAT,QAA8B,gBAA9B;AAIA;;;;;;;AAOG;;AACH,OAAO,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,oBAAoB,CAAC;IAC3C,KAAK,EAAE,KAAK,CAAC,IAD8B;IAE3C,YAAY,EAAE,KAAK,CAAC,WAFuB;IAG3C,YAAY,EAAE;EAH6B,CAAD,CAA5C;EAMA,MAAM,iBAAiB,GAAG,gBAAgB,CAAE,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,CARyC,CAA1C;EAUA,MAAM,QAAQ,GAAG,oBAAoB,CAAC,IAAD,EAAO,SAAP,CAArC;EACA,MAAM,iBAAiB,GAAG,oBAAoB,EAA9C;EACA,MAAM,kBAAkB,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,KAAK,WAAvB,CAAlC;EAEA,yBAAyB,CAAC,MAAK;IAC7B,IAAI,kBAAJ,EAAwB;MACtB,OAAO,iBAAiB,EAAxB;IACD;EACF,CAJwB,EAItB,CAAC,iBAAD,EAAoB,kBAApB,CAJsB,CAAzB;EAMA,OAAO;IACL,UAAU,EAAE;MACV,QAAQ,EAAE;IADA,CADP;IAIL,IAJK;IAKL,SALK;IAML,OAAO,EAAE,IAAI,GAAG,OAAH,GAAa,IANrB;IAOL,OAPK;IAQL,iBARK;IASL,eAAe,EAAE,KAAK,CAAC,iBAAD,CATjB;IAUL,aAAa,EAAE,KAAK,CAAC,eAAD,CAVf;IAWL,cAAc,EAAE,mBAAmB,CAAC,aAAD,CAX9B;IAYL,SAAS,EAAE;EAZN,CAAP;AAcD,CA7CM;AA+CP;;AAEG;;AACH,SAAS,2BAAT,CACE,QADF,EAC2B;EAEzB,MAAM,aAAa,GAAG,KAAK,CAAC,QAAN,CAAe,OAAf,CAAuB,QAAvB,CAAtB;;EACA,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;IACzC,IAAI,aAAa,CAAC,MAAd,KAAyB,CAAzB,IAA8B,aAAa,CAAC,MAAd,KAAyB,CAA3D,EAA8D;MAC5D;MACA,OAAO,CAAC,IAAR,CACE,+DACE,4EAFJ;IAID;EACF;;EACD,QAAQ,aAAa,CAAC,MAAtB;IACE;IACA,KAAK,CAAL;MACE,OAAO,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 { useControllableState, useEventCallback, useId, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useHasParentContext } from '@fluentui/react-context-selector';\nimport { 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 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 dialogContentId: useId('dialog-content-'),\n dialogTitleId: useId('dialog-title-'),\n isNestedDialog: useHasParentContext(DialogContext),\n dialogRef: focusRef,\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/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogSurface.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-dialog/src/components/DialogSurface/DialogSurface.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { DialogSurfaceContextValue } from '../../contexts';\n\nexport type DialogSurfaceSlots = {\n /**\n * Dimmed background of dialog.\n * The default backdrop is rendered as a `<div>` with styling.\n * This slot expects a `<div>` element which will replace the default backdrop.\n * The backdrop should have `aria-hidden=\"true\"`.\n *\n * By default if `DialogSurface` is `<dialog>` element the backdrop is ignored,\n * since native `<dialog>` element supports [::backdrop](https://developer.mozilla.org/en-US/docs/Web/CSS/::backdrop)\n */\n backdrop?: Slot<'div'>;\n root:
|
|
1
|
+
{"version":3,"file":"DialogSurface.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-dialog/src/components/DialogSurface/DialogSurface.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { DialogSurfaceContextValue } from '../../contexts';\n\nexport type DialogSurfaceSlots = {\n /**\n * Dimmed background of dialog.\n * The default backdrop is rendered as a `<div>` with styling.\n * This slot expects a `<div>` element which will replace the default backdrop.\n * The backdrop should have `aria-hidden=\"true\"`.\n *\n * By default if `DialogSurface` is `<dialog>` element the backdrop is ignored,\n * since native `<dialog>` element supports [::backdrop](https://developer.mozilla.org/en-US/docs/Web/CSS/::backdrop)\n */\n backdrop?: Slot<'div'>;\n root: Slot<'div'>;\n};\n\n/**\n * Union between all possible semantic element that represent a DialogSurface\n */\nexport type DialogSurfaceElement = HTMLDialogElement | HTMLDivElement;\n\n/** @internal */\nexport type DialogSurfaceElementIntersection = HTMLDialogElement & HTMLDivElement;\n\n/**\n * DialogSurface Props\n *\n * Omits basic types from native `dialog` (`open`, `onCancel` and `onClose`)\n * to ensure `onOpenChange`, `open` and `defaultOpen` from `Dialog` is used instead\n */\nexport type DialogSurfaceProps = Omit<ComponentProps<DialogSurfaceSlots>, 'open' | 'onCancel' | 'onClose'>;\n\nexport type DialogSurfaceContextValues = {\n dialogSurface: DialogSurfaceContextValue;\n};\n\n/**\n * State used in rendering DialogSurface\n */\nexport type DialogSurfaceState = ComponentState<DialogSurfaceSlots>;\n"]}
|
|
@@ -17,78 +17,12 @@ export const useDialogSurface_unstable = (props, ref) => {
|
|
|
17
17
|
backdrop,
|
|
18
18
|
as
|
|
19
19
|
} = props;
|
|
20
|
-
const isNativeDialog = as === 'dialog' || as === undefined;
|
|
21
20
|
const modalType = useDialogContext_unstable(ctx => ctx.modalType);
|
|
22
21
|
const dialogRef = useDialogContext_unstable(ctx => ctx.dialogRef);
|
|
23
22
|
const open = useDialogContext_unstable(ctx => ctx.open);
|
|
24
23
|
const requestOpenChange = useDialogContext_unstable(ctx => ctx.requestOpenChange);
|
|
25
24
|
const dialogTitleID = useDialogContext_unstable(ctx => ctx.dialogTitleId);
|
|
26
25
|
const dialogContentId = useDialogContext_unstable(ctx => ctx.dialogContentId);
|
|
27
|
-
const handleNativeClick = useEventCallback(event => {
|
|
28
|
-
var _a;
|
|
29
|
-
|
|
30
|
-
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
31
|
-
|
|
32
|
-
if (modalType === 'alert' || event.target !== event.currentTarget) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const {
|
|
37
|
-
clientX,
|
|
38
|
-
clientY
|
|
39
|
-
} = event;
|
|
40
|
-
const {
|
|
41
|
-
top,
|
|
42
|
-
left,
|
|
43
|
-
width,
|
|
44
|
-
height
|
|
45
|
-
} = event.currentTarget.getBoundingClientRect();
|
|
46
|
-
const isBackdropClick = top > clientY || clientY > top + height || left > clientX || clientX > left + width;
|
|
47
|
-
|
|
48
|
-
if (isBackdropClick) {
|
|
49
|
-
requestOpenChange({
|
|
50
|
-
event,
|
|
51
|
-
open: false,
|
|
52
|
-
type: 'backdropClick'
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
const handleNativeCancel = useEventCallback(event => {
|
|
57
|
-
var _a, _b;
|
|
58
|
-
|
|
59
|
-
(_b = (_a = props).onCancel) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
60
|
-
|
|
61
|
-
if (event.currentTarget !== event.target) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (modalType !== 'alert') {
|
|
66
|
-
requestOpenChange({
|
|
67
|
-
event,
|
|
68
|
-
open: false,
|
|
69
|
-
type: 'dialogCancel'
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
event.preventDefault();
|
|
74
|
-
});
|
|
75
|
-
const handleNativeClose = useEventCallback(event => {
|
|
76
|
-
var _a, _b;
|
|
77
|
-
|
|
78
|
-
(_b = (_a = props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a, event); // Ensure dialog remains open if force closed by close event
|
|
79
|
-
|
|
80
|
-
if (event.currentTarget.open !== open) {
|
|
81
|
-
if (open) {
|
|
82
|
-
if (modalType === 'non-modal') {
|
|
83
|
-
event.currentTarget.show();
|
|
84
|
-
} else {
|
|
85
|
-
event.currentTarget.showModal();
|
|
86
|
-
}
|
|
87
|
-
} else {
|
|
88
|
-
event.currentTarget.close();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
26
|
const handledBackdropClick = useEventCallback(event => {
|
|
93
27
|
var _a, _b;
|
|
94
28
|
|
|
@@ -128,24 +62,18 @@ export const useDialogSurface_unstable = (props, ref) => {
|
|
|
128
62
|
return {
|
|
129
63
|
components: {
|
|
130
64
|
backdrop: 'div',
|
|
131
|
-
root: '
|
|
65
|
+
root: 'div'
|
|
132
66
|
},
|
|
133
67
|
backdrop: resolveShorthand(backdrop, {
|
|
134
|
-
required:
|
|
68
|
+
required: open && modalType !== 'non-modal',
|
|
135
69
|
defaultProps: {
|
|
136
70
|
'aria-hidden': 'true',
|
|
137
71
|
onClick: handledBackdropClick
|
|
138
72
|
}
|
|
139
73
|
}),
|
|
140
|
-
root: getNativeElementProps(as !== null && as !== void 0 ? as : '
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
onClick: handleNativeClick,
|
|
144
|
-
onCancel: handleNativeCancel
|
|
145
|
-
} : {
|
|
146
|
-
'aria-modal': modalType !== 'non-modal',
|
|
147
|
-
role: modalType === 'alert' ? 'alertdialog' : 'dialog'
|
|
148
|
-
}),
|
|
74
|
+
root: getNativeElementProps(as !== null && as !== void 0 ? as : 'div', {
|
|
75
|
+
'aria-modal': modalType !== 'non-modal',
|
|
76
|
+
role: modalType === 'alert' ? 'alertdialog' : 'dialog',
|
|
149
77
|
...props,
|
|
150
78
|
...modalAttributes,
|
|
151
79
|
onKeyDown: handleKeyDown,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-dialog/src/components/DialogSurface/useDialogSurface.ts"],"names":[],"mappings":"AACA,SACE,qBADF,EAEE,gBAFF,EAGE,gBAHF,EAIE,aAJF,EAKE,mBALF,QAMO,2BANP;AAaA,SAAS,yBAAT,QAA0C,gBAA1C;AACA,SAAS,kBAAT,
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-dialog/src/components/DialogSurface/useDialogSurface.ts"],"names":[],"mappings":"AACA,SACE,qBADF,EAEE,gBAFF,EAGE,gBAHF,EAIE,aAJF,EAKE,mBALF,QAMO,2BANP;AAaA,SAAS,yBAAT,QAA0C,gBAA1C;AACA,SAAS,kBAAT,QAAmC,aAAnC;AACA,SAAS,kBAAT,QAAmC,yBAAnC;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,yBAAyB,GAAG,CACvC,KADuC,EAEvC,GAFuC,KAGjB;EACtB,MAAM;IAAE,QAAF;IAAY;EAAZ,IAAmB,KAAzB;EACA,MAAM,SAAS,GAAG,yBAAyB,CAAC,GAAG,IAAI,GAAG,CAAC,SAAZ,CAA3C;EACA,MAAM,SAAS,GAAG,yBAAyB,CAAC,GAAG,IAAI,GAAG,CAAC,SAAZ,CAA3C;EACA,MAAM,IAAI,GAAG,yBAAyB,CAAC,GAAG,IAAI,GAAG,CAAC,IAAZ,CAAtC;EACA,MAAM,iBAAiB,GAAG,yBAAyB,CAAC,GAAG,IAAI,GAAG,CAAC,iBAAZ,CAAnD;EACA,MAAM,aAAa,GAAG,yBAAyB,CAAC,GAAG,IAAI,GAAG,CAAC,aAAZ,CAA/C;EACA,MAAM,eAAe,GAAG,yBAAyB,CAAC,GAAG,IAAI,GAAG,CAAC,eAAZ,CAAjD;EAEA,MAAM,oBAAoB,GAAG,gBAAgB,CAAE,KAAD,IAA4C;;;IACxF,IAAI,mBAAmB,CAAC,KAAK,CAAC,QAAP,CAAvB,EAAyC;MACvC,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,KAAK,CAAC,QAAN,EAAe,OAAf,MAAsB,IAAtB,IAAsB,EAAA,KAAA,KAAA,CAAtB,GAAsB,KAAA,CAAtB,GAAsB,EAAA,CAAA,IAAA,CAAA,EAAA,EAAG,KAAH,CAAtB;IACD;;IACD,IAAI,SAAS,KAAK,OAAd,IAAyB,CAAC,KAAK,CAAC,kBAAN,EAA9B,EAA0D;MACxD,iBAAiB,CAAC;QAChB,KADgB;QAEhB,IAAI,EAAE,KAFU;QAGhB,IAAI,EAAE;MAHU,CAAD,CAAjB;IAKD;EACF,CAX4C,CAA7C;EAaA,MAAM,aAAa,GAAG,gBAAgB,CAAE,KAAD,IAAiE;;;IACtG,CAAA,EAAA,GAAA,KAAK,CAAC,SAAN,MAAe,IAAf,IAAe,EAAA,KAAA,KAAA,CAAf,GAAe,KAAA,CAAf,GAAe,EAAA,CAAA,IAAA,CAAf,KAAe,EAAG,KAAH,CAAf;;IAEA,IAAI,kBAAkB,CAAC,KAAD,EAAQ,SAAR,CAAtB,EAA0C;MACxC,iBAAiB,CAAC;QAChB,KADgB;QAEhB,IAAI,EAAE,KAFU;QAGhB,IAAI,EAAE;MAHU,CAAD,CAAjB,CADwC,CAMxC;MACA;;MACA,KAAK,CAAC,eAAN;IACD;EACF,CAbqC,CAAtC;EAeA,MAAM;IAAE;EAAF,IAAsB,kBAAkB,CAAC;IAAE,SAAS,EAAE,SAAS,KAAK;EAA3B,CAAD,CAA9C;EAEA,OAAO;IACL,UAAU,EAAE;MACV,QAAQ,EAAE,KADA;MAEV,IAAI,EAAE;IAFI,CADP;IAKL,QAAQ,EAAE,gBAAgB,CAAC,QAAD,EAAW;MACnC,QAAQ,EAAE,IAAI,IAAI,SAAS,KAAK,WADG;MAEnC,YAAY,EAAE;QACZ,eAAe,MADH;QAEZ,OAAO,EAAE;MAFG;IAFqB,CAAX,CALrB;IAYL,IAAI,EAAE,qBAAqB,CAAC,EAAE,KAAA,IAAF,IAAA,EAAE,KAAA,KAAA,CAAF,GAAA,EAAA,GAAM,KAAP,EAAc;MACvC,cAAc,SAAS,KAAK,WADW;MAEvC,IAAI,EAAE,SAAS,KAAK,OAAd,GAAwB,aAAxB,GAAwC,QAFP;MAGvC,GAAG,KAHoC;MAIvC,GAAG,eAJoC;MAKvC,SAAS,EAAE,aAL4B;MAMvC,oBAAoB,eANmB;MAOvC,mBAAmB,KAAK,CAAC,YAAD,CAAL,GAAsB,SAAtB,GAAkC,aAPd;MAQvC,GAAG,EAAE,aAAa,CAAC,GAAD,EAAM,SAAN;IARqB,CAAd;EAZtB,CAAP;AAuBD,CAjEM","sourcesContent":["import * as React from 'react';\nimport {\n getNativeElementProps,\n resolveShorthand,\n useEventCallback,\n useMergedRefs,\n isResolvedShorthand,\n} from '@fluentui/react-utilities';\nimport type {\n DialogSurfaceElement,\n DialogSurfaceElementIntersection,\n DialogSurfaceProps,\n DialogSurfaceState,\n} from './DialogSurface.types';\nimport { useDialogContext_unstable } from '../../contexts';\nimport { isEscapeKeyDismiss } from '../../utils';\nimport { useModalAttributes } from '@fluentui/react-tabster';\n\n/**\n * Create the state required to render DialogSurface.\n *\n * The returned state can be modified with hooks such as useDialogSurfaceStyles_unstable,\n * before being passed to renderDialogSurface_unstable.\n *\n * @param props - props from this instance of DialogSurface\n * @param ref - reference to root HTMLElement of DialogSurface\n */\nexport const useDialogSurface_unstable = (\n props: DialogSurfaceProps,\n ref: React.Ref<DialogSurfaceElement>,\n): DialogSurfaceState => {\n const { backdrop, as } = props;\n const modalType = useDialogContext_unstable(ctx => ctx.modalType);\n const dialogRef = useDialogContext_unstable(ctx => ctx.dialogRef);\n const open = useDialogContext_unstable(ctx => ctx.open);\n const requestOpenChange = useDialogContext_unstable(ctx => ctx.requestOpenChange);\n const dialogTitleID = useDialogContext_unstable(ctx => ctx.dialogTitleId);\n const dialogContentId = useDialogContext_unstable(ctx => ctx.dialogContentId);\n\n const handledBackdropClick = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {\n if (isResolvedShorthand(props.backdrop)) {\n props.backdrop.onClick?.(event);\n }\n if (modalType === 'modal' && !event.isDefaultPrevented()) {\n requestOpenChange({\n event,\n open: false,\n type: 'backdropClick',\n });\n }\n });\n\n const handleKeyDown = useEventCallback((event: React.KeyboardEvent<DialogSurfaceElementIntersection>) => {\n props.onKeyDown?.(event);\n\n if (isEscapeKeyDismiss(event, modalType)) {\n requestOpenChange({\n event,\n open: false,\n type: 'escapeKeyDown',\n });\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: nested Dialog, Popover, Menu and Tooltip\n event.stopPropagation();\n }\n });\n\n const { modalAttributes } = useModalAttributes({ trapFocus: modalType !== 'non-modal' });\n\n return {\n components: {\n backdrop: 'div',\n root: 'div',\n },\n backdrop: resolveShorthand(backdrop, {\n required: open && modalType !== 'non-modal',\n defaultProps: {\n 'aria-hidden': 'true',\n onClick: handledBackdropClick,\n },\n }),\n root: getNativeElementProps(as ?? 'div', {\n 'aria-modal': modalType !== 'non-modal',\n role: modalType === 'alert' ? 'alertdialog' : 'dialog',\n ...props,\n ...modalAttributes,\n onKeyDown: handleKeyDown,\n 'aria-describedby': dialogContentId,\n 'aria-labelledby': props['aria-label'] ? undefined : dialogTitleID,\n ref: useMergedRefs(ref, dialogRef),\n }),\n };\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -65,37 +65,37 @@ export const useDialogTitleInternalStyles = /*#__PURE__*/__styles({
|
|
|
65
65
|
"fsow6f": "fgusgyc",
|
|
66
66
|
"Brovlpu": "ftqa4ok",
|
|
67
67
|
"B486eqv": "f2hkw1w",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
68
|
+
"B8q5s1w": "f8hki3x",
|
|
69
|
+
"Bci5o5g": ["f1d2448m", "ffh67wi"],
|
|
70
|
+
"n8qw10": "f1bjia2o",
|
|
71
|
+
"Bdrgwmp": ["ffh67wi", "f1d2448m"],
|
|
72
|
+
"Bm4h7ae": "f15bsgw9",
|
|
73
|
+
"B7ys5i9": "f14e48fq",
|
|
74
|
+
"Busjfv9": "f18yb2kv",
|
|
75
|
+
"Bhk32uz": "fd6o370",
|
|
76
|
+
"Bf4ptjt": "fh1cnn4",
|
|
77
|
+
"kclons": ["fy7oxxb", "f184ne2d"],
|
|
78
|
+
"Bhdgwq3": "fpukqih",
|
|
79
|
+
"Blkhhs4": ["f184ne2d", "fy7oxxb"],
|
|
80
|
+
"Bqtpl0w": "frrh606",
|
|
81
|
+
"clg4pj": ["f1v5zibi", "fo2hd23"],
|
|
82
|
+
"hgwjuy": "ful5kiu",
|
|
83
|
+
"Bonggc9": ["fo2hd23", "f1v5zibi"],
|
|
84
|
+
"B1tsrr9": ["f1jqcqds", "ftffrms"],
|
|
85
|
+
"Dah5zi": ["ftffrms", "f1jqcqds"],
|
|
86
|
+
"Bkh64rk": ["f2e7qr6", "fsr1zz6"],
|
|
87
|
+
"qqdqy8": ["fsr1zz6", "f2e7qr6"],
|
|
88
|
+
"B6dhp37": "f1dvezut",
|
|
89
|
+
"i03rao": ["fd0oaoj", "f1cwg4i8"],
|
|
90
|
+
"Boxcth7": "fjvm52t",
|
|
91
|
+
"Bsom6fd": ["f1cwg4i8", "fd0oaoj"],
|
|
92
|
+
"J0r882": "fdiulkx",
|
|
93
|
+
"Bjwuhne": "f1yalx80",
|
|
94
|
+
"Ghsupd": ["fq22d5a", "f1jw7pan"],
|
|
95
|
+
"Bule8hv": ["f1jw7pan", "fq22d5a"]
|
|
96
96
|
}
|
|
97
97
|
}, {
|
|
98
|
-
"d": [".f10pi13n{position:relative;}", ".f1e4lqlz{box-sizing:content-box;}", ".f1u2r49w{background-color:inherit;}", ".f1ym3bx4{color:inherit;}", ".f1mo0ibp{font-family:inherit;}", ".fjoy568{font-size:inherit;}", ".fez10in{line-height:0;}", ".f1mtd64y{overflow-x:visible;}", ".f1y7q3j9{overflow-y:visible;}", ".f1g0x7ka{padding-top:0;}", ".fhxju0i{padding-right:0;}", ".f1cnd47f{padding-left:0;}", ".f1qch9an{padding-bottom:0;}", ".f1ern45e{border-top-style:none;}", ".f1n71otn{border-right-style:none;}", ".f1deefiw{border-left-style:none;}", ".f1h8hb77{border-bottom-style:none;}", ".f37px4s{-webkit-appearance:button;}", ".fgusgyc{text-align:unset;}", ".
|
|
98
|
+
"d": [".f10pi13n{position:relative;}", ".f1e4lqlz{box-sizing:content-box;}", ".f1u2r49w{background-color:inherit;}", ".f1ym3bx4{color:inherit;}", ".f1mo0ibp{font-family:inherit;}", ".fjoy568{font-size:inherit;}", ".fez10in{line-height:0;}", ".f1mtd64y{overflow-x:visible;}", ".f1y7q3j9{overflow-y:visible;}", ".f1g0x7ka{padding-top:0;}", ".fhxju0i{padding-right:0;}", ".f1cnd47f{padding-left:0;}", ".f1qch9an{padding-bottom:0;}", ".f1ern45e{border-top-style:none;}", ".f1n71otn{border-right-style:none;}", ".f1deefiw{border-left-style:none;}", ".f1h8hb77{border-bottom-style:none;}", ".f37px4s{-webkit-appearance:button;}", ".fgusgyc{text-align:unset;}", ".f8hki3x[data-fui-focus-visible]{border-top-color:transparent;}", ".f1d2448m[data-fui-focus-visible]{border-right-color:transparent;}", ".ffh67wi[data-fui-focus-visible]{border-left-color:transparent;}", ".f1bjia2o[data-fui-focus-visible]{border-bottom-color:transparent;}", ".f15bsgw9[data-fui-focus-visible]::after{content:\"\";}", ".f14e48fq[data-fui-focus-visible]::after{position:absolute;}", ".f18yb2kv[data-fui-focus-visible]::after{pointer-events:none;}", ".fd6o370[data-fui-focus-visible]::after{z-index:1;}", ".fh1cnn4[data-fui-focus-visible]::after{border-top-style:solid;}", ".fy7oxxb[data-fui-focus-visible]::after{border-right-style:solid;}", ".f184ne2d[data-fui-focus-visible]::after{border-left-style:solid;}", ".fpukqih[data-fui-focus-visible]::after{border-bottom-style:solid;}", ".frrh606[data-fui-focus-visible]::after{border-top-width:2px;}", ".f1v5zibi[data-fui-focus-visible]::after{border-right-width:2px;}", ".fo2hd23[data-fui-focus-visible]::after{border-left-width:2px;}", ".ful5kiu[data-fui-focus-visible]::after{border-bottom-width:2px;}", ".f1jqcqds[data-fui-focus-visible]::after{border-bottom-right-radius:var(--borderRadiusMedium);}", ".ftffrms[data-fui-focus-visible]::after{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f2e7qr6[data-fui-focus-visible]::after{border-top-right-radius:var(--borderRadiusMedium);}", ".fsr1zz6[data-fui-focus-visible]::after{border-top-left-radius:var(--borderRadiusMedium);}", ".f1dvezut[data-fui-focus-visible]::after{border-top-color:var(--colorStrokeFocus2);}", ".fd0oaoj[data-fui-focus-visible]::after{border-right-color:var(--colorStrokeFocus2);}", ".f1cwg4i8[data-fui-focus-visible]::after{border-left-color:var(--colorStrokeFocus2);}", ".fjvm52t[data-fui-focus-visible]::after{border-bottom-color:var(--colorStrokeFocus2);}", ".fdiulkx[data-fui-focus-visible]::after{top:-2px;}", ".f1yalx80[data-fui-focus-visible]::after{bottom:-2px;}", ".fq22d5a[data-fui-focus-visible]::after{left:-2px;}", ".f1jw7pan[data-fui-focus-visible]::after{right:-2px;}"],
|
|
99
99
|
"f": [".ftqa4ok:focus{outline-style:none;}"],
|
|
100
100
|
"i": [".f2hkw1w:focus-visible{outline-style:none;}"]
|
|
101
101
|
});
|
package/lib/utils/index.js
CHANGED
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-dialog/src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-dialog/src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './isEscapeKeyDown';\nexport * from './useDisableBodyScroll';\nexport * from './useFocusFirstElement';\n"]}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { Escape } from '@fluentui/keyboard-keys';
|
|
2
|
-
import { isHTMLDialogElement } from './isHTMLDialogElement';
|
|
3
2
|
/**
|
|
4
3
|
* Checks if keydown event is a proper Escape key dismiss
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
6
|
export function isEscapeKeyDismiss(event, modalType) {
|
|
8
|
-
return event.key === Escape &&
|
|
9
|
-
// `modal` should only be handled in the case of non native dialog
|
|
10
|
-
modalType === 'non-modal' || !isHTMLDialogElement(event.currentTarget) && modalType === 'modal') && !event.isDefaultPrevented();
|
|
7
|
+
return event.key === Escape && modalType !== 'alert' && !event.isDefaultPrevented();
|
|
11
8
|
}
|
|
12
9
|
//# sourceMappingURL=isEscapeKeyDown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-dialog/src/utils/isEscapeKeyDown.ts"],"names":[],"mappings":"AACA,SAAS,MAAT,QAAuB,yBAAvB;
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-dialog/src/utils/isEscapeKeyDown.ts"],"names":[],"mappings":"AACA,SAAS,MAAT,QAAuB,yBAAvB;AAIA;;AAEG;;AACH,OAAM,SAAU,kBAAV,CACJ,KADI,EAEJ,SAFI,EAEsB;EAE1B,OAAO,KAAK,CAAC,GAAN,KAAc,MAAd,IAAwB,SAAS,KAAK,OAAtC,IAAiD,CAAC,KAAK,CAAC,kBAAN,EAAzD;AACD","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/"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useFocusFinders } from '@fluentui/react-tabster';
|
|
3
3
|
import { useFluent_unstable } from '@fluentui/react-shared-contexts';
|
|
4
|
-
import { isHTMLDialogElement } from './isHTMLDialogElement';
|
|
5
4
|
/**
|
|
6
5
|
* Focus first element on content when dialog is opened,
|
|
7
6
|
*/
|
|
@@ -26,10 +25,7 @@ export function useFocusFirstElement(open, modalType) {
|
|
|
26
25
|
const element = dialogRef.current && findFirstFocusable(dialogRef.current);
|
|
27
26
|
|
|
28
27
|
if (element) {
|
|
29
|
-
|
|
30
|
-
if (!isHTMLDialogElement(dialogRef.current)) {
|
|
31
|
-
element.focus();
|
|
32
|
-
}
|
|
28
|
+
element.focus();
|
|
33
29
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
34
30
|
(_b = triggerRef.current) === null || _b === void 0 ? void 0 : _b.blur(); // eslint-disable-next-line no-console
|
|
35
31
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-dialog/src/utils/useFocusFirstElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,eAAT,QAAgC,yBAAhC;AACA,SAAS,kBAAT,QAAmC,iCAAnC;
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-dialog/src/utils/useFocusFirstElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,eAAT,QAAgC,yBAAhC;AACA,SAAS,kBAAT,QAAmC,iCAAnC;AAIA;;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,OAAO,CAAC,KAAR;IACD,CAFD,MAEO,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,CAbD,EAaG,CAAC,kBAAD,EAAqB,IAArB,EAA2B,SAA3B,EAAsC,cAAtC,CAbH;EAeA,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';\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 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/"}
|
|
@@ -45,7 +45,6 @@ const useDialog_unstable = props => {
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
const focusRef = utils_1.useFocusFirstElement(open, modalType);
|
|
48
|
-
const nativeControlRef = utils_1.useControlNativeDialogOpenState(open, modalType);
|
|
49
48
|
const disableBodyScroll = utils_1.useDisableBodyScroll();
|
|
50
49
|
const isBodyScrollLocked = Boolean(open && modalType !== 'non-modal');
|
|
51
50
|
react_utilities_1.useIsomorphicLayoutEffect(() => {
|
|
@@ -65,7 +64,7 @@ const useDialog_unstable = props => {
|
|
|
65
64
|
dialogContentId: react_utilities_1.useId('dialog-content-'),
|
|
66
65
|
dialogTitleId: react_utilities_1.useId('dialog-title-'),
|
|
67
66
|
isNestedDialog: react_context_selector_1.useHasParentContext(contexts_1.DialogContext),
|
|
68
|
-
dialogRef:
|
|
67
|
+
dialogRef: focusRef
|
|
69
68
|
};
|
|
70
69
|
};
|
|
71
70
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-dialog/src/components/Dialog/useDialog.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-dialog/src/components/Dialog/useDialog.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,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,CAAjB;EACA,MAAM,iBAAiB,GAAG,OAAA,CAAA,oBAAA,EAA1B;EACA,MAAM,kBAAkB,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,KAAK,WAAvB,CAAlC;EAEA,iBAAA,CAAA,yBAAA,CAA0B,MAAK;IAC7B,IAAI,kBAAJ,EAAwB;MACtB,OAAO,iBAAiB,EAAxB;IACD;EACF,CAJD,EAIG,CAAC,iBAAD,EAAoB,kBAApB,CAJH;EAMA,OAAO;IACL,UAAU,EAAE;MACV,QAAQ,EAAE;IADA,CADP;IAIL,IAJK;IAKL,SALK;IAML,OAAO,EAAE,IAAI,GAAG,OAAH,GAAa,IANrB;IAOL,OAPK;IAQL,iBARK;IASL,eAAe,EAAE,iBAAA,CAAA,KAAA,CAAM,iBAAN,CATZ;IAUL,aAAa,EAAE,iBAAA,CAAA,KAAA,CAAM,eAAN,CAVV;IAWL,cAAc,EAAE,wBAAA,CAAA,mBAAA,CAAoB,UAAA,CAAA,aAApB,CAXX;IAYL,SAAS,EAAE;EAZN,CAAP;AAcD,CA7CM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB;AA+Cb;;AAEG;;AACH,SAAS,2BAAT,CACE,QADF,EAC2B;EAEzB,MAAM,aAAa,GAAG,KAAK,CAAC,QAAN,CAAe,OAAf,CAAuB,QAAvB,CAAtB;;EACA,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;IACzC,IAAI,aAAa,CAAC,MAAd,KAAyB,CAAzB,IAA8B,aAAa,CAAC,MAAd,KAAyB,CAA3D,EAA8D;MAC5D;MACA,OAAO,CAAC,IAAR,CACE,+DACE,4EAFJ;IAID;EACF;;EACD,QAAQ,aAAa,CAAC,MAAtB;IACE;IACA,KAAK,CAAL;MACE,OAAO,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 { useControllableState, useEventCallback, useId, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useHasParentContext } from '@fluentui/react-context-selector';\nimport { 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 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 dialogContentId: useId('dialog-content-'),\n dialogTitleId: useId('dialog-title-'),\n isNestedDialog: useHasParentContext(DialogContext),\n dialogRef: focusRef,\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/"}
|
|
@@ -28,78 +28,12 @@ const useDialogSurface_unstable = (props, ref) => {
|
|
|
28
28
|
backdrop,
|
|
29
29
|
as
|
|
30
30
|
} = props;
|
|
31
|
-
const isNativeDialog = as === 'dialog' || as === undefined;
|
|
32
31
|
const modalType = contexts_1.useDialogContext_unstable(ctx => ctx.modalType);
|
|
33
32
|
const dialogRef = contexts_1.useDialogContext_unstable(ctx => ctx.dialogRef);
|
|
34
33
|
const open = contexts_1.useDialogContext_unstable(ctx => ctx.open);
|
|
35
34
|
const requestOpenChange = contexts_1.useDialogContext_unstable(ctx => ctx.requestOpenChange);
|
|
36
35
|
const dialogTitleID = contexts_1.useDialogContext_unstable(ctx => ctx.dialogTitleId);
|
|
37
36
|
const dialogContentId = contexts_1.useDialogContext_unstable(ctx => ctx.dialogContentId);
|
|
38
|
-
const handleNativeClick = react_utilities_1.useEventCallback(event => {
|
|
39
|
-
var _a;
|
|
40
|
-
|
|
41
|
-
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
42
|
-
|
|
43
|
-
if (modalType === 'alert' || event.target !== event.currentTarget) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const {
|
|
48
|
-
clientX,
|
|
49
|
-
clientY
|
|
50
|
-
} = event;
|
|
51
|
-
const {
|
|
52
|
-
top,
|
|
53
|
-
left,
|
|
54
|
-
width,
|
|
55
|
-
height
|
|
56
|
-
} = event.currentTarget.getBoundingClientRect();
|
|
57
|
-
const isBackdropClick = top > clientY || clientY > top + height || left > clientX || clientX > left + width;
|
|
58
|
-
|
|
59
|
-
if (isBackdropClick) {
|
|
60
|
-
requestOpenChange({
|
|
61
|
-
event,
|
|
62
|
-
open: false,
|
|
63
|
-
type: 'backdropClick'
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
const handleNativeCancel = react_utilities_1.useEventCallback(event => {
|
|
68
|
-
var _a, _b;
|
|
69
|
-
|
|
70
|
-
(_b = (_a = props).onCancel) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
71
|
-
|
|
72
|
-
if (event.currentTarget !== event.target) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (modalType !== 'alert') {
|
|
77
|
-
requestOpenChange({
|
|
78
|
-
event,
|
|
79
|
-
open: false,
|
|
80
|
-
type: 'dialogCancel'
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
event.preventDefault();
|
|
85
|
-
});
|
|
86
|
-
const handleNativeClose = react_utilities_1.useEventCallback(event => {
|
|
87
|
-
var _a, _b;
|
|
88
|
-
|
|
89
|
-
(_b = (_a = props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a, event); // Ensure dialog remains open if force closed by close event
|
|
90
|
-
|
|
91
|
-
if (event.currentTarget.open !== open) {
|
|
92
|
-
if (open) {
|
|
93
|
-
if (modalType === 'non-modal') {
|
|
94
|
-
event.currentTarget.show();
|
|
95
|
-
} else {
|
|
96
|
-
event.currentTarget.showModal();
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
event.currentTarget.close();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
37
|
const handledBackdropClick = react_utilities_1.useEventCallback(event => {
|
|
104
38
|
var _a, _b;
|
|
105
39
|
|
|
@@ -139,24 +73,18 @@ const useDialogSurface_unstable = (props, ref) => {
|
|
|
139
73
|
return {
|
|
140
74
|
components: {
|
|
141
75
|
backdrop: 'div',
|
|
142
|
-
root: '
|
|
76
|
+
root: 'div'
|
|
143
77
|
},
|
|
144
78
|
backdrop: react_utilities_1.resolveShorthand(backdrop, {
|
|
145
|
-
required:
|
|
79
|
+
required: open && modalType !== 'non-modal',
|
|
146
80
|
defaultProps: {
|
|
147
81
|
'aria-hidden': 'true',
|
|
148
82
|
onClick: handledBackdropClick
|
|
149
83
|
}
|
|
150
84
|
}),
|
|
151
|
-
root: react_utilities_1.getNativeElementProps(as !== null && as !== void 0 ? as : '
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
onClick: handleNativeClick,
|
|
155
|
-
onCancel: handleNativeCancel
|
|
156
|
-
} : {
|
|
157
|
-
'aria-modal': modalType !== 'non-modal',
|
|
158
|
-
role: modalType === 'alert' ? 'alertdialog' : 'dialog'
|
|
159
|
-
}),
|
|
85
|
+
root: react_utilities_1.getNativeElementProps(as !== null && as !== void 0 ? as : 'div', {
|
|
86
|
+
'aria-modal': modalType !== 'non-modal',
|
|
87
|
+
role: modalType === 'alert' ? 'alertdialog' : 'dialog',
|
|
160
88
|
...props,
|
|
161
89
|
...modalAttributes,
|
|
162
90
|
onKeyDown: handleKeyDown,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-dialog/src/components/DialogSurface/useDialogSurface.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAaA,MAAA,UAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-dialog/src/components/DialogSurface/useDialogSurface.ts"],"names":[],"mappings":"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","sourcesContent":["import * as React from 'react';\nimport {\n getNativeElementProps,\n resolveShorthand,\n useEventCallback,\n useMergedRefs,\n isResolvedShorthand,\n} from '@fluentui/react-utilities';\nimport type {\n DialogSurfaceElement,\n DialogSurfaceElementIntersection,\n DialogSurfaceProps,\n DialogSurfaceState,\n} from './DialogSurface.types';\nimport { useDialogContext_unstable } from '../../contexts';\nimport { isEscapeKeyDismiss } from '../../utils';\nimport { useModalAttributes } from '@fluentui/react-tabster';\n\n/**\n * Create the state required to render DialogSurface.\n *\n * The returned state can be modified with hooks such as useDialogSurfaceStyles_unstable,\n * before being passed to renderDialogSurface_unstable.\n *\n * @param props - props from this instance of DialogSurface\n * @param ref - reference to root HTMLElement of DialogSurface\n */\nexport const useDialogSurface_unstable = (\n props: DialogSurfaceProps,\n ref: React.Ref<DialogSurfaceElement>,\n): DialogSurfaceState => {\n const { backdrop, as } = props;\n const modalType = useDialogContext_unstable(ctx => ctx.modalType);\n const dialogRef = useDialogContext_unstable(ctx => ctx.dialogRef);\n const open = useDialogContext_unstable(ctx => ctx.open);\n const requestOpenChange = useDialogContext_unstable(ctx => ctx.requestOpenChange);\n const dialogTitleID = useDialogContext_unstable(ctx => ctx.dialogTitleId);\n const dialogContentId = useDialogContext_unstable(ctx => ctx.dialogContentId);\n\n const handledBackdropClick = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {\n if (isResolvedShorthand(props.backdrop)) {\n props.backdrop.onClick?.(event);\n }\n if (modalType === 'modal' && !event.isDefaultPrevented()) {\n requestOpenChange({\n event,\n open: false,\n type: 'backdropClick',\n });\n }\n });\n\n const handleKeyDown = useEventCallback((event: React.KeyboardEvent<DialogSurfaceElementIntersection>) => {\n props.onKeyDown?.(event);\n\n if (isEscapeKeyDismiss(event, modalType)) {\n requestOpenChange({\n event,\n open: false,\n type: 'escapeKeyDown',\n });\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: nested Dialog, Popover, Menu and Tooltip\n event.stopPropagation();\n }\n });\n\n const { modalAttributes } = useModalAttributes({ trapFocus: modalType !== 'non-modal' });\n\n return {\n components: {\n backdrop: 'div',\n root: 'div',\n },\n backdrop: resolveShorthand(backdrop, {\n required: open && modalType !== 'non-modal',\n defaultProps: {\n 'aria-hidden': 'true',\n onClick: handledBackdropClick,\n },\n }),\n root: getNativeElementProps(as ?? 'div', {\n 'aria-modal': modalType !== 'non-modal',\n role: modalType === 'alert' ? 'alertdialog' : 'dialog',\n ...props,\n ...modalAttributes,\n onKeyDown: handleKeyDown,\n 'aria-describedby': dialogContentId,\n 'aria-labelledby': props['aria-label'] ? undefined : dialogTitleID,\n ref: useMergedRefs(ref, dialogRef),\n }),\n };\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -76,37 +76,37 @@ exports.useDialogTitleInternalStyles = /*#__PURE__*/react_1.__styles({
|
|
|
76
76
|
"fsow6f": "fgusgyc",
|
|
77
77
|
"Brovlpu": "ftqa4ok",
|
|
78
78
|
"B486eqv": "f2hkw1w",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
79
|
+
"B8q5s1w": "f8hki3x",
|
|
80
|
+
"Bci5o5g": ["f1d2448m", "ffh67wi"],
|
|
81
|
+
"n8qw10": "f1bjia2o",
|
|
82
|
+
"Bdrgwmp": ["ffh67wi", "f1d2448m"],
|
|
83
|
+
"Bm4h7ae": "f15bsgw9",
|
|
84
|
+
"B7ys5i9": "f14e48fq",
|
|
85
|
+
"Busjfv9": "f18yb2kv",
|
|
86
|
+
"Bhk32uz": "fd6o370",
|
|
87
|
+
"Bf4ptjt": "fh1cnn4",
|
|
88
|
+
"kclons": ["fy7oxxb", "f184ne2d"],
|
|
89
|
+
"Bhdgwq3": "fpukqih",
|
|
90
|
+
"Blkhhs4": ["f184ne2d", "fy7oxxb"],
|
|
91
|
+
"Bqtpl0w": "frrh606",
|
|
92
|
+
"clg4pj": ["f1v5zibi", "fo2hd23"],
|
|
93
|
+
"hgwjuy": "ful5kiu",
|
|
94
|
+
"Bonggc9": ["fo2hd23", "f1v5zibi"],
|
|
95
|
+
"B1tsrr9": ["f1jqcqds", "ftffrms"],
|
|
96
|
+
"Dah5zi": ["ftffrms", "f1jqcqds"],
|
|
97
|
+
"Bkh64rk": ["f2e7qr6", "fsr1zz6"],
|
|
98
|
+
"qqdqy8": ["fsr1zz6", "f2e7qr6"],
|
|
99
|
+
"B6dhp37": "f1dvezut",
|
|
100
|
+
"i03rao": ["fd0oaoj", "f1cwg4i8"],
|
|
101
|
+
"Boxcth7": "fjvm52t",
|
|
102
|
+
"Bsom6fd": ["f1cwg4i8", "fd0oaoj"],
|
|
103
|
+
"J0r882": "fdiulkx",
|
|
104
|
+
"Bjwuhne": "f1yalx80",
|
|
105
|
+
"Ghsupd": ["fq22d5a", "f1jw7pan"],
|
|
106
|
+
"Bule8hv": ["f1jw7pan", "fq22d5a"]
|
|
107
107
|
}
|
|
108
108
|
}, {
|
|
109
|
-
"d": [".f10pi13n{position:relative;}", ".f1e4lqlz{box-sizing:content-box;}", ".f1u2r49w{background-color:inherit;}", ".f1ym3bx4{color:inherit;}", ".f1mo0ibp{font-family:inherit;}", ".fjoy568{font-size:inherit;}", ".fez10in{line-height:0;}", ".f1mtd64y{overflow-x:visible;}", ".f1y7q3j9{overflow-y:visible;}", ".f1g0x7ka{padding-top:0;}", ".fhxju0i{padding-right:0;}", ".f1cnd47f{padding-left:0;}", ".f1qch9an{padding-bottom:0;}", ".f1ern45e{border-top-style:none;}", ".f1n71otn{border-right-style:none;}", ".f1deefiw{border-left-style:none;}", ".f1h8hb77{border-bottom-style:none;}", ".f37px4s{-webkit-appearance:button;}", ".fgusgyc{text-align:unset;}", ".
|
|
109
|
+
"d": [".f10pi13n{position:relative;}", ".f1e4lqlz{box-sizing:content-box;}", ".f1u2r49w{background-color:inherit;}", ".f1ym3bx4{color:inherit;}", ".f1mo0ibp{font-family:inherit;}", ".fjoy568{font-size:inherit;}", ".fez10in{line-height:0;}", ".f1mtd64y{overflow-x:visible;}", ".f1y7q3j9{overflow-y:visible;}", ".f1g0x7ka{padding-top:0;}", ".fhxju0i{padding-right:0;}", ".f1cnd47f{padding-left:0;}", ".f1qch9an{padding-bottom:0;}", ".f1ern45e{border-top-style:none;}", ".f1n71otn{border-right-style:none;}", ".f1deefiw{border-left-style:none;}", ".f1h8hb77{border-bottom-style:none;}", ".f37px4s{-webkit-appearance:button;}", ".fgusgyc{text-align:unset;}", ".f8hki3x[data-fui-focus-visible]{border-top-color:transparent;}", ".f1d2448m[data-fui-focus-visible]{border-right-color:transparent;}", ".ffh67wi[data-fui-focus-visible]{border-left-color:transparent;}", ".f1bjia2o[data-fui-focus-visible]{border-bottom-color:transparent;}", ".f15bsgw9[data-fui-focus-visible]::after{content:\"\";}", ".f14e48fq[data-fui-focus-visible]::after{position:absolute;}", ".f18yb2kv[data-fui-focus-visible]::after{pointer-events:none;}", ".fd6o370[data-fui-focus-visible]::after{z-index:1;}", ".fh1cnn4[data-fui-focus-visible]::after{border-top-style:solid;}", ".fy7oxxb[data-fui-focus-visible]::after{border-right-style:solid;}", ".f184ne2d[data-fui-focus-visible]::after{border-left-style:solid;}", ".fpukqih[data-fui-focus-visible]::after{border-bottom-style:solid;}", ".frrh606[data-fui-focus-visible]::after{border-top-width:2px;}", ".f1v5zibi[data-fui-focus-visible]::after{border-right-width:2px;}", ".fo2hd23[data-fui-focus-visible]::after{border-left-width:2px;}", ".ful5kiu[data-fui-focus-visible]::after{border-bottom-width:2px;}", ".f1jqcqds[data-fui-focus-visible]::after{border-bottom-right-radius:var(--borderRadiusMedium);}", ".ftffrms[data-fui-focus-visible]::after{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f2e7qr6[data-fui-focus-visible]::after{border-top-right-radius:var(--borderRadiusMedium);}", ".fsr1zz6[data-fui-focus-visible]::after{border-top-left-radius:var(--borderRadiusMedium);}", ".f1dvezut[data-fui-focus-visible]::after{border-top-color:var(--colorStrokeFocus2);}", ".fd0oaoj[data-fui-focus-visible]::after{border-right-color:var(--colorStrokeFocus2);}", ".f1cwg4i8[data-fui-focus-visible]::after{border-left-color:var(--colorStrokeFocus2);}", ".fjvm52t[data-fui-focus-visible]::after{border-bottom-color:var(--colorStrokeFocus2);}", ".fdiulkx[data-fui-focus-visible]::after{top:-2px;}", ".f1yalx80[data-fui-focus-visible]::after{bottom:-2px;}", ".fq22d5a[data-fui-focus-visible]::after{left:-2px;}", ".f1jw7pan[data-fui-focus-visible]::after{right:-2px;}"],
|
|
110
110
|
"f": [".ftqa4ok:focus{outline-style:none;}"],
|
|
111
111
|
"i": [".f2hkw1w:focus-visible{outline-style:none;}"]
|
|
112
112
|
});
|
|
@@ -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
|
|
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 &&
|
|
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
|
|
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,10 +35,7 @@ function useFocusFirstElement(open, modalType) {
|
|
|
37
35
|
const element = dialogRef.current && findFirstFocusable(dialogRef.current);
|
|
38
36
|
|
|
39
37
|
if (element) {
|
|
40
|
-
|
|
41
|
-
if (!isHTMLDialogElement_1.isHTMLDialogElement(dialogRef.current)) {
|
|
42
|
-
element.focus();
|
|
43
|
-
}
|
|
38
|
+
element.focus();
|
|
44
39
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
45
40
|
(_b = triggerRef.current) === null || _b === void 0 ? void 0 : _b.blur(); // eslint-disable-next-line no-console
|
|
46
41
|
|
|
@@ -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
|
|
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,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,CAbD,EAaG,CAAC,kBAAD,EAAqB,IAArB,EAA2B,SAA3B,EAAsC,cAAtC,CAbH;EAeA,OAAO,SAAP;AACD;;AAtBD,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 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/"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-dialog",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.11",
|
|
4
4
|
"description": "Dialog component for Fluent UI React",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@fluentui/keyboard-keys": "^9.0.0",
|
|
39
39
|
"@fluentui/react-context-selector": "^9.0.3",
|
|
40
40
|
"@fluentui/react-shared-contexts": "^9.0.1",
|
|
41
|
-
"@fluentui/react-aria": "^9.2.
|
|
41
|
+
"@fluentui/react-aria": "^9.2.1",
|
|
42
42
|
"@fluentui/react-icons": "^2.0.175",
|
|
43
|
-
"@fluentui/react-tabster": "^9.1.
|
|
43
|
+
"@fluentui/react-tabster": "^9.1.2",
|
|
44
44
|
"@fluentui/react-theme": "^9.1.0",
|
|
45
|
-
"@fluentui/react-portal": "^9.0.
|
|
45
|
+
"@fluentui/react-portal": "^9.0.6",
|
|
46
46
|
"tslib": "^2.1.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
@@ -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/"}
|