@fluentui/react-dialog 9.0.0-beta.7
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 +328 -0
- package/CHANGELOG.md +152 -0
- package/LICENSE +15 -0
- package/README.md +5 -0
- package/Spec.md +518 -0
- package/assets/AlertDialogKeyboardInteraction.png +0 -0
- package/assets/AlertDialogMouseInteraction.png +0 -0
- package/assets/ModalDialogKeyboardInteraction.png +0 -0
- package/assets/ModalDialogMouseInteraction.png +0 -0
- package/assets/NonModalDialogKeyboardInteraction.png +0 -0
- package/assets/NonModalDialogMouseInteraction.png +0 -0
- package/dist/index.d.ts +406 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/Dialog.js +2 -0
- package/lib/Dialog.js.map +1 -0
- package/lib/DialogActions.js +2 -0
- package/lib/DialogActions.js.map +1 -0
- package/lib/DialogBody.js +2 -0
- package/lib/DialogBody.js.map +1 -0
- package/lib/DialogSurface.js +2 -0
- package/lib/DialogSurface.js.map +1 -0
- package/lib/DialogTitle.js +2 -0
- package/lib/DialogTitle.js.map +1 -0
- package/lib/DialogTrigger.js +2 -0
- package/lib/DialogTrigger.js.map +1 -0
- package/lib/components/Dialog/Dialog.js +21 -0
- package/lib/components/Dialog/Dialog.js.map +1 -0
- package/lib/components/Dialog/Dialog.types.js +2 -0
- package/lib/components/Dialog/Dialog.types.js.map +1 -0
- package/lib/components/Dialog/index.js +6 -0
- package/lib/components/Dialog/index.js.map +1 -0
- package/lib/components/Dialog/renderDialog.js +26 -0
- package/lib/components/Dialog/renderDialog.js.map +1 -0
- package/lib/components/Dialog/useDialog.js +197 -0
- package/lib/components/Dialog/useDialog.js.map +1 -0
- package/lib/components/Dialog/useDialogContextValues.js +31 -0
- package/lib/components/Dialog/useDialogContextValues.js.map +1 -0
- package/lib/components/Dialog/useDialogStyles.js +41 -0
- package/lib/components/Dialog/useDialogStyles.js.map +1 -0
- package/lib/components/DialogActions/DialogActions.js +16 -0
- package/lib/components/DialogActions/DialogActions.js.map +1 -0
- package/lib/components/DialogActions/DialogActions.types.js +2 -0
- package/lib/components/DialogActions/DialogActions.types.js.map +1 -0
- package/lib/components/DialogActions/index.js +6 -0
- package/lib/components/DialogActions/index.js.map +1 -0
- package/lib/components/DialogActions/renderDialogActions.js +16 -0
- package/lib/components/DialogActions/renderDialogActions.js.map +1 -0
- package/lib/components/DialogActions/useDialogActions.js +27 -0
- package/lib/components/DialogActions/useDialogActions.js.map +1 -0
- package/lib/components/DialogActions/useDialogActionsStyles.js +51 -0
- package/lib/components/DialogActions/useDialogActionsStyles.js.map +1 -0
- package/lib/components/DialogBody/DialogBody.js +16 -0
- package/lib/components/DialogBody/DialogBody.js.map +1 -0
- package/lib/components/DialogBody/DialogBody.types.js +2 -0
- package/lib/components/DialogBody/DialogBody.types.js.map +1 -0
- package/lib/components/DialogBody/index.js +6 -0
- package/lib/components/DialogBody/index.js.map +1 -0
- package/lib/components/DialogBody/renderDialogBody.js +16 -0
- package/lib/components/DialogBody/renderDialogBody.js.map +1 -0
- package/lib/components/DialogBody/useDialogBody.js +25 -0
- package/lib/components/DialogBody/useDialogBody.js.map +1 -0
- package/lib/components/DialogBody/useDialogBodyStyles.js +42 -0
- package/lib/components/DialogBody/useDialogBodyStyles.js.map +1 -0
- package/lib/components/DialogSurface/DialogSurface.js +18 -0
- package/lib/components/DialogSurface/DialogSurface.js.map +1 -0
- package/lib/components/DialogSurface/DialogSurface.types.js +2 -0
- package/lib/components/DialogSurface/DialogSurface.types.js.map +1 -0
- package/lib/components/DialogSurface/index.js +6 -0
- package/lib/components/DialogSurface/index.js.map +1 -0
- package/lib/components/DialogSurface/renderDialogSurface.js +18 -0
- package/lib/components/DialogSurface/renderDialogSurface.js.map +1 -0
- package/lib/components/DialogSurface/useDialogSurface.js +59 -0
- package/lib/components/DialogSurface/useDialogSurface.js.map +1 -0
- package/lib/components/DialogSurface/useDialogSurfaceContextValues.js +7 -0
- package/lib/components/DialogSurface/useDialogSurfaceContextValues.js.map +1 -0
- package/lib/components/DialogSurface/useDialogSurfaceStyles.js +78 -0
- package/lib/components/DialogSurface/useDialogSurfaceStyles.js.map +1 -0
- package/lib/components/DialogTitle/DialogTitle.js +17 -0
- package/lib/components/DialogTitle/DialogTitle.js.map +1 -0
- package/lib/components/DialogTitle/DialogTitle.types.js +2 -0
- package/lib/components/DialogTitle/DialogTitle.types.js.map +1 -0
- package/lib/components/DialogTitle/index.js +6 -0
- package/lib/components/DialogTitle/index.js.map +1 -0
- package/lib/components/DialogTitle/renderDialogTitle.js +19 -0
- package/lib/components/DialogTitle/renderDialogTitle.js.map +1 -0
- package/lib/components/DialogTitle/useDialogTitle.js +42 -0
- package/lib/components/DialogTitle/useDialogTitle.js.map +1 -0
- package/lib/components/DialogTitle/useDialogTitleStyles.js +109 -0
- package/lib/components/DialogTitle/useDialogTitleStyles.js.map +1 -0
- package/lib/components/DialogTrigger/DialogTrigger.js +20 -0
- package/lib/components/DialogTrigger/DialogTrigger.js.map +1 -0
- package/lib/components/DialogTrigger/DialogTrigger.types.js +2 -0
- package/lib/components/DialogTrigger/DialogTrigger.types.js.map +1 -0
- package/lib/components/DialogTrigger/index.js +5 -0
- package/lib/components/DialogTrigger/index.js.map +1 -0
- package/lib/components/DialogTrigger/renderDialogTrigger.js +7 -0
- package/lib/components/DialogTrigger/renderDialogTrigger.js.map +1 -0
- package/lib/components/DialogTrigger/useDialogTrigger.js +65 -0
- package/lib/components/DialogTrigger/useDialogTrigger.js.map +1 -0
- package/lib/contexts/constants.js +11 -0
- package/lib/contexts/constants.js.map +1 -0
- package/lib/contexts/dialogContext.js +21 -0
- package/lib/contexts/dialogContext.js.map +1 -0
- package/lib/contexts/dialogSurfaceContext.js +10 -0
- package/lib/contexts/dialogSurfaceContext.js.map +1 -0
- package/lib/contexts/index.js +4 -0
- package/lib/contexts/index.js.map +1 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/index.js +5 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/isEscapeKeyDown.js +11 -0
- package/lib/utils/isEscapeKeyDown.js.map +1 -0
- package/lib/utils/isTargetDisabled.js +14 -0
- package/lib/utils/isTargetDisabled.js.map +1 -0
- package/lib/utils/localShorthands.js +9 -0
- package/lib/utils/localShorthands.js.map +1 -0
- package/lib/utils/normalizeDefaultPrevented.js +11 -0
- package/lib/utils/normalizeDefaultPrevented.js.map +1 -0
- package/lib-commonjs/Dialog.js +10 -0
- package/lib-commonjs/Dialog.js.map +1 -0
- package/lib-commonjs/DialogActions.js +10 -0
- package/lib-commonjs/DialogActions.js.map +1 -0
- package/lib-commonjs/DialogBody.js +10 -0
- package/lib-commonjs/DialogBody.js.map +1 -0
- package/lib-commonjs/DialogSurface.js +10 -0
- package/lib-commonjs/DialogSurface.js.map +1 -0
- package/lib-commonjs/DialogTitle.js +10 -0
- package/lib-commonjs/DialogTitle.js.map +1 -0
- package/lib-commonjs/DialogTrigger.js +10 -0
- package/lib-commonjs/DialogTrigger.js.map +1 -0
- package/lib-commonjs/components/Dialog/Dialog.js +33 -0
- package/lib-commonjs/components/Dialog/Dialog.js.map +1 -0
- package/lib-commonjs/components/Dialog/Dialog.types.js +6 -0
- package/lib-commonjs/components/Dialog/Dialog.types.js.map +1 -0
- package/lib-commonjs/components/Dialog/index.js +18 -0
- package/lib-commonjs/components/Dialog/index.js.map +1 -0
- package/lib-commonjs/components/Dialog/renderDialog.js +39 -0
- package/lib-commonjs/components/Dialog/renderDialog.js.map +1 -0
- package/lib-commonjs/components/Dialog/useDialog.js +211 -0
- package/lib-commonjs/components/Dialog/useDialog.js.map +1 -0
- package/lib-commonjs/components/Dialog/useDialogContextValues.js +40 -0
- package/lib-commonjs/components/Dialog/useDialogContextValues.js.map +1 -0
- package/lib-commonjs/components/Dialog/useDialogStyles.js +53 -0
- package/lib-commonjs/components/Dialog/useDialogStyles.js.map +1 -0
- package/lib-commonjs/components/DialogActions/DialogActions.js +27 -0
- package/lib-commonjs/components/DialogActions/DialogActions.js.map +1 -0
- package/lib-commonjs/components/DialogActions/DialogActions.types.js +6 -0
- package/lib-commonjs/components/DialogActions/DialogActions.types.js.map +1 -0
- package/lib-commonjs/components/DialogActions/index.js +18 -0
- package/lib-commonjs/components/DialogActions/index.js.map +1 -0
- package/lib-commonjs/components/DialogActions/renderDialogActions.js +27 -0
- package/lib-commonjs/components/DialogActions/renderDialogActions.js.map +1 -0
- package/lib-commonjs/components/DialogActions/useDialogActions.js +37 -0
- package/lib-commonjs/components/DialogActions/useDialogActions.js.map +1 -0
- package/lib-commonjs/components/DialogActions/useDialogActionsStyles.js +63 -0
- package/lib-commonjs/components/DialogActions/useDialogActionsStyles.js.map +1 -0
- package/lib-commonjs/components/DialogBody/DialogBody.js +27 -0
- package/lib-commonjs/components/DialogBody/DialogBody.js.map +1 -0
- package/lib-commonjs/components/DialogBody/DialogBody.types.js +6 -0
- package/lib-commonjs/components/DialogBody/DialogBody.types.js.map +1 -0
- package/lib-commonjs/components/DialogBody/index.js +18 -0
- package/lib-commonjs/components/DialogBody/index.js.map +1 -0
- package/lib-commonjs/components/DialogBody/renderDialogBody.js +27 -0
- package/lib-commonjs/components/DialogBody/renderDialogBody.js.map +1 -0
- package/lib-commonjs/components/DialogBody/useDialogBody.js +36 -0
- package/lib-commonjs/components/DialogBody/useDialogBody.js.map +1 -0
- package/lib-commonjs/components/DialogBody/useDialogBodyStyles.js +55 -0
- package/lib-commonjs/components/DialogBody/useDialogBodyStyles.js.map +1 -0
- package/lib-commonjs/components/DialogSurface/DialogSurface.js +30 -0
- package/lib-commonjs/components/DialogSurface/DialogSurface.js.map +1 -0
- package/lib-commonjs/components/DialogSurface/DialogSurface.types.js +6 -0
- package/lib-commonjs/components/DialogSurface/DialogSurface.types.js.map +1 -0
- package/lib-commonjs/components/DialogSurface/index.js +18 -0
- package/lib-commonjs/components/DialogSurface/index.js.map +1 -0
- package/lib-commonjs/components/DialogSurface/renderDialogSurface.js +30 -0
- package/lib-commonjs/components/DialogSurface/renderDialogSurface.js.map +1 -0
- package/lib-commonjs/components/DialogSurface/useDialogSurface.js +72 -0
- package/lib-commonjs/components/DialogSurface/useDialogSurface.js.map +1 -0
- package/lib-commonjs/components/DialogSurface/useDialogSurfaceContextValues.js +16 -0
- package/lib-commonjs/components/DialogSurface/useDialogSurfaceContextValues.js.map +1 -0
- package/lib-commonjs/components/DialogSurface/useDialogSurfaceStyles.js +90 -0
- package/lib-commonjs/components/DialogSurface/useDialogSurfaceStyles.js.map +1 -0
- package/lib-commonjs/components/DialogTitle/DialogTitle.js +28 -0
- package/lib-commonjs/components/DialogTitle/DialogTitle.js.map +1 -0
- package/lib-commonjs/components/DialogTitle/DialogTitle.types.js +6 -0
- package/lib-commonjs/components/DialogTitle/DialogTitle.types.js.map +1 -0
- package/lib-commonjs/components/DialogTitle/index.js +18 -0
- package/lib-commonjs/components/DialogTitle/index.js.map +1 -0
- package/lib-commonjs/components/DialogTitle/renderDialogTitle.js +31 -0
- package/lib-commonjs/components/DialogTitle/renderDialogTitle.js.map +1 -0
- package/lib-commonjs/components/DialogTitle/useDialogTitle.js +56 -0
- package/lib-commonjs/components/DialogTitle/useDialogTitle.js.map +1 -0
- package/lib-commonjs/components/DialogTitle/useDialogTitleStyles.js +123 -0
- package/lib-commonjs/components/DialogTitle/useDialogTitleStyles.js.map +1 -0
- package/lib-commonjs/components/DialogTrigger/DialogTrigger.js +31 -0
- package/lib-commonjs/components/DialogTrigger/DialogTrigger.js.map +1 -0
- package/lib-commonjs/components/DialogTrigger/DialogTrigger.types.js +6 -0
- package/lib-commonjs/components/DialogTrigger/DialogTrigger.types.js.map +1 -0
- package/lib-commonjs/components/DialogTrigger/index.js +16 -0
- package/lib-commonjs/components/DialogTrigger/index.js.map +1 -0
- package/lib-commonjs/components/DialogTrigger/renderDialogTrigger.js +16 -0
- package/lib-commonjs/components/DialogTrigger/renderDialogTrigger.js.map +1 -0
- package/lib-commonjs/components/DialogTrigger/useDialogTrigger.js +80 -0
- package/lib-commonjs/components/DialogTrigger/useDialogTrigger.js.map +1 -0
- package/lib-commonjs/contexts/constants.js +17 -0
- package/lib-commonjs/contexts/constants.js.map +1 -0
- package/lib-commonjs/contexts/dialogContext.js +32 -0
- package/lib-commonjs/contexts/dialogContext.js.map +1 -0
- package/lib-commonjs/contexts/dialogSurfaceContext.js +21 -0
- package/lib-commonjs/contexts/dialogSurfaceContext.js.map +1 -0
- package/lib-commonjs/contexts/index.js +14 -0
- package/lib-commonjs/contexts/index.js.map +1 -0
- package/lib-commonjs/index.js +193 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/utils/index.js +16 -0
- package/lib-commonjs/utils/index.js.map +1 -0
- package/lib-commonjs/utils/isEscapeKeyDown.js +22 -0
- package/lib-commonjs/utils/isEscapeKeyDown.js.map +1 -0
- package/lib-commonjs/utils/isTargetDisabled.js +23 -0
- package/lib-commonjs/utils/isTargetDisabled.js.map +1 -0
- package/lib-commonjs/utils/localShorthands.js +18 -0
- package/lib-commonjs/utils/localShorthands.js.map +1 -0
- package/lib-commonjs/utils/normalizeDefaultPrevented.js +20 -0
- package/lib-commonjs/utils/normalizeDefaultPrevented.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { resolveShorthand, useControllableState, useEventCallback, useId } from '@fluentui/react-utilities';
|
|
3
|
+
import { useFocusFinders } from '@fluentui/react-tabster';
|
|
4
|
+
import { useFluent_unstable } from '@fluentui/react-shared-contexts';
|
|
5
|
+
import { normalizeDefaultPrevented, isEscapeKeyDismiss } from '../../utils';
|
|
6
|
+
/**
|
|
7
|
+
* Create the state required to render Dialog.
|
|
8
|
+
*
|
|
9
|
+
* The returned state can be modified with hooks such as useDialogStyles_unstable,
|
|
10
|
+
* before being passed to renderDialog_unstable.
|
|
11
|
+
*
|
|
12
|
+
* @param props - props from this instance of Dialog
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const useDialog_unstable = props => {
|
|
16
|
+
const {
|
|
17
|
+
children,
|
|
18
|
+
overlay,
|
|
19
|
+
modalType = 'modal',
|
|
20
|
+
onOpenChange
|
|
21
|
+
} = props;
|
|
22
|
+
const [trigger, content] = childrenToTriggerAndContent(children);
|
|
23
|
+
const [open, setOpen] = useControllableState({
|
|
24
|
+
state: props.open,
|
|
25
|
+
defaultState: props.defaultOpen,
|
|
26
|
+
initialState: false
|
|
27
|
+
});
|
|
28
|
+
const overlayShorthand = resolveShorthand(overlay, {
|
|
29
|
+
required: modalType !== 'non-modal',
|
|
30
|
+
defaultProps: {
|
|
31
|
+
'aria-hidden': 'true'
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const requestOpenChange = useEventCallback(data => {
|
|
35
|
+
const isDefaultPrevented = normalizeDefaultPrevented(data.event);
|
|
36
|
+
|
|
37
|
+
if (onOpenChange) {
|
|
38
|
+
onOpenChange(data.event, data);
|
|
39
|
+
} // if user prevents default then do not change state value
|
|
40
|
+
// otherwise updates state value and trigger reference to the element that caused the opening
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if (!isDefaultPrevented()) {
|
|
44
|
+
triggerRef.current = !open && data.open ? data.event.currentTarget : null;
|
|
45
|
+
setOpen(data.open);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const {
|
|
49
|
+
contentRef,
|
|
50
|
+
triggerRef
|
|
51
|
+
} = useFocusFirstElement({
|
|
52
|
+
open,
|
|
53
|
+
modalType,
|
|
54
|
+
requestOpenChange
|
|
55
|
+
});
|
|
56
|
+
const handleOverLayClick = useEventCallback(event => {
|
|
57
|
+
var _a;
|
|
58
|
+
|
|
59
|
+
(_a = overlayShorthand === null || overlayShorthand === void 0 ? void 0 : overlayShorthand.onClick) === null || _a === void 0 ? void 0 : _a.call(overlayShorthand, event);
|
|
60
|
+
|
|
61
|
+
if (isOverlayClickDismiss(event, modalType)) {
|
|
62
|
+
requestOpenChange({
|
|
63
|
+
event,
|
|
64
|
+
open: false,
|
|
65
|
+
type: 'overlayClick'
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
components: {
|
|
71
|
+
overlay: 'div'
|
|
72
|
+
},
|
|
73
|
+
overlay: overlayShorthand && { ...overlayShorthand,
|
|
74
|
+
onClick: handleOverLayClick
|
|
75
|
+
},
|
|
76
|
+
open,
|
|
77
|
+
modalType,
|
|
78
|
+
content,
|
|
79
|
+
trigger,
|
|
80
|
+
triggerRef,
|
|
81
|
+
contentRef,
|
|
82
|
+
requestOpenChange,
|
|
83
|
+
dialogBodyID: useId('dialog-body-'),
|
|
84
|
+
dialogTitleID: useId('dialog-title-')
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Extracts trigger and content from children
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
function childrenToTriggerAndContent(children) {
|
|
92
|
+
const childrenArray = React.Children.toArray(children);
|
|
93
|
+
|
|
94
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
95
|
+
if (childrenArray.length !== 1 && childrenArray.length !== 2) {
|
|
96
|
+
// eslint-disable-next-line no-console
|
|
97
|
+
console.warn('Dialog must contain at least one child <DialogSurface/>,\n' + 'and at most two children <DialogTrigger/> <DialogSurface/> (in this order)');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
switch (childrenArray.length) {
|
|
102
|
+
// case where there's a trigger followed by content
|
|
103
|
+
case 2:
|
|
104
|
+
return childrenArray;
|
|
105
|
+
// case where there's only content
|
|
106
|
+
|
|
107
|
+
case 1:
|
|
108
|
+
return [undefined, childrenArray[0]];
|
|
109
|
+
// unknown case
|
|
110
|
+
|
|
111
|
+
default:
|
|
112
|
+
return [undefined, undefined];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Checks is click event is a proper Overlay click dismiss
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
function isOverlayClickDismiss(event, type) {
|
|
121
|
+
const isDefaultPrevented = normalizeDefaultPrevented(event);
|
|
122
|
+
return type === 'modal' && !isDefaultPrevented();
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Focus first element on content when dialog is opened,
|
|
126
|
+
* in case there's no focusable element, then a eventlistener is added to document
|
|
127
|
+
* to ensure Escape keydown functionality
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
function useFocusFirstElement({
|
|
132
|
+
open,
|
|
133
|
+
requestOpenChange,
|
|
134
|
+
modalType
|
|
135
|
+
}) {
|
|
136
|
+
const {
|
|
137
|
+
findFirstFocusable
|
|
138
|
+
} = useFocusFinders();
|
|
139
|
+
const {
|
|
140
|
+
targetDocument
|
|
141
|
+
} = useFluent_unstable();
|
|
142
|
+
const contentRef = React.useRef(null);
|
|
143
|
+
const triggerRef = React.useRef(null);
|
|
144
|
+
React.useEffect(() => {
|
|
145
|
+
if (!open) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const element = contentRef.current && findFirstFocusable(contentRef.current);
|
|
150
|
+
|
|
151
|
+
if (element) {
|
|
152
|
+
element.focus(); // NOTE: if it's non-modal global listener to escape is necessary
|
|
153
|
+
|
|
154
|
+
if (modalType !== 'non-modal') {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
159
|
+
// eslint-disable-next-line no-console
|
|
160
|
+
console.warn('A Dialog should have at least one focusable element inside DialogSurface');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (triggerRef.current && targetDocument) {
|
|
165
|
+
const trigger = triggerRef.current; // if the trigger is still the active element, the default behavior is to return focus to document.body,
|
|
166
|
+
// which can be achived by blurring
|
|
167
|
+
|
|
168
|
+
if (targetDocument.activeElement === trigger) {
|
|
169
|
+
trigger.blur();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const listener = event => {
|
|
173
|
+
if (isEscapeKeyDismiss(event, modalType)) {
|
|
174
|
+
requestOpenChange({
|
|
175
|
+
event,
|
|
176
|
+
open: false,
|
|
177
|
+
type: 'documentEscapeKeyDown'
|
|
178
|
+
});
|
|
179
|
+
trigger.focus();
|
|
180
|
+
event.stopImmediatePropagation();
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
targetDocument.addEventListener('keydown', listener, {
|
|
185
|
+
passive: false
|
|
186
|
+
});
|
|
187
|
+
return () => {
|
|
188
|
+
targetDocument.removeEventListener('keydown', listener);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}, [findFirstFocusable, requestOpenChange, open, modalType, targetDocument]);
|
|
192
|
+
return {
|
|
193
|
+
contentRef,
|
|
194
|
+
triggerRef
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=useDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Dialog/useDialog.ts"],"names":[],"mappings":"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","sourcesContent":["import * as React from 'react';\nimport { resolveShorthand, useControllableState, useEventCallback, useId } from '@fluentui/react-utilities';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport { normalizeDefaultPrevented, isEscapeKeyDismiss } from '../../utils';\n\nimport type { DialogProps, DialogState, DialogModalType, DialogOpenChangeData } from './Dialog.types';\n\n/**\n * Create the state required to render Dialog.\n *\n * The returned state can be modified with hooks such as useDialogStyles_unstable,\n * before being passed to renderDialog_unstable.\n *\n * @param props - props from this instance of Dialog\n */\nexport const useDialog_unstable = (props: DialogProps): DialogState => {\n const { children, overlay, modalType = 'modal', onOpenChange } = props;\n\n const [trigger, content] = childrenToTriggerAndContent(children);\n\n const [open, setOpen] = useControllableState({\n state: props.open,\n defaultState: props.defaultOpen,\n initialState: false,\n });\n\n const overlayShorthand = resolveShorthand(overlay, {\n required: modalType !== 'non-modal',\n defaultProps: {\n 'aria-hidden': 'true',\n },\n });\n\n const requestOpenChange = useEventCallback((data: DialogOpenChangeData) => {\n const isDefaultPrevented = normalizeDefaultPrevented(data.event);\n\n if (onOpenChange) {\n onOpenChange(data.event, data);\n }\n\n // if user prevents default then do not change state value\n // otherwise updates state value and trigger reference to the element that caused the opening\n if (!isDefaultPrevented()) {\n (triggerRef as React.MutableRefObject<HTMLElement | null>).current =\n !open && data.open ? (data.event.currentTarget as HTMLElement) : null;\n setOpen(data.open);\n }\n });\n\n const { contentRef, triggerRef } = useFocusFirstElement({\n open,\n modalType,\n requestOpenChange,\n });\n\n const handleOverLayClick = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {\n overlayShorthand?.onClick?.(event);\n if (isOverlayClickDismiss(event, modalType)) {\n requestOpenChange({ event, open: false, type: 'overlayClick' });\n }\n });\n\n return {\n components: {\n overlay: 'div',\n },\n overlay: overlayShorthand && {\n ...overlayShorthand,\n onClick: handleOverLayClick,\n },\n open,\n modalType,\n content,\n trigger,\n triggerRef,\n contentRef,\n requestOpenChange,\n dialogBodyID: useId('dialog-body-'),\n dialogTitleID: useId('dialog-title-'),\n };\n};\n\n/**\n * Extracts trigger and content from children\n */\nfunction childrenToTriggerAndContent(\n children: React.ReactNode,\n): readonly [trigger: React.ReactNode, content: React.ReactNode] {\n const childrenArray = React.Children.toArray(children) as React.ReactElement[];\n if (process.env.NODE_ENV !== 'production') {\n if (childrenArray.length !== 1 && childrenArray.length !== 2) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Dialog must contain at least one child <DialogSurface/>,\\n' +\n 'and at most two children <DialogTrigger/> <DialogSurface/> (in this order)',\n );\n }\n }\n switch (childrenArray.length) {\n // case where there's a trigger followed by content\n case 2:\n return childrenArray as [trigger: React.ReactNode, content: React.ReactNode];\n // case where there's only content\n case 1:\n return [undefined, childrenArray[0]];\n // unknown case\n default:\n return [undefined, undefined];\n }\n}\n\n/**\n * Checks is click event is a proper Overlay click dismiss\n */\nfunction isOverlayClickDismiss(event: React.MouseEvent, type: DialogModalType): boolean {\n const isDefaultPrevented = normalizeDefaultPrevented(event);\n return type === 'modal' && !isDefaultPrevented();\n}\n\n/**\n * Focus first element on content when dialog is opened,\n * in case there's no focusable element, then a eventlistener is added to document\n * to ensure Escape keydown functionality\n */\nfunction useFocusFirstElement({\n open,\n requestOpenChange,\n modalType,\n}: Pick<DialogState, 'open' | 'requestOpenChange' | 'modalType'>) {\n const { findFirstFocusable } = useFocusFinders();\n const { targetDocument } = useFluent_unstable();\n const contentRef = React.useRef<HTMLElement>(null);\n const triggerRef = React.useRef<HTMLElement>(null);\n\n React.useEffect(() => {\n if (!open) {\n return;\n }\n\n const element = contentRef.current && findFirstFocusable(contentRef.current);\n if (element) {\n element.focus();\n // NOTE: if it's non-modal global listener to escape is necessary\n if (modalType !== 'non-modal') {\n return;\n }\n } else {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn('A Dialog should have at least one focusable element inside DialogSurface');\n }\n }\n\n if (triggerRef.current && targetDocument) {\n const trigger = triggerRef.current;\n // if the trigger is still the active element, the default behavior is to return focus to document.body,\n // which can be achived by blurring\n if (targetDocument.activeElement === trigger) {\n trigger.blur();\n }\n const listener = (event: KeyboardEvent) => {\n if (isEscapeKeyDismiss(event, modalType)) {\n requestOpenChange({\n event,\n open: false,\n type: 'documentEscapeKeyDown',\n });\n trigger.focus();\n event.stopImmediatePropagation();\n }\n };\n targetDocument.addEventListener('keydown', listener, { passive: false });\n return () => {\n targetDocument.removeEventListener('keydown', listener);\n };\n }\n }, [findFirstFocusable, requestOpenChange, open, modalType, targetDocument]);\n\n return { contentRef, triggerRef };\n}\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function useDialogContextValues_unstable(state) {
|
|
2
|
+
const {
|
|
3
|
+
modalType,
|
|
4
|
+
open,
|
|
5
|
+
triggerRef,
|
|
6
|
+
contentRef,
|
|
7
|
+
dialogBodyID,
|
|
8
|
+
dialogTitleID,
|
|
9
|
+
requestOpenChange
|
|
10
|
+
} = state;
|
|
11
|
+
/**
|
|
12
|
+
* This context is created with "@fluentui/react-context-selector",
|
|
13
|
+
* there is no sense to memoize it
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const dialog = {
|
|
17
|
+
open,
|
|
18
|
+
modalType,
|
|
19
|
+
triggerRef,
|
|
20
|
+
contentRef,
|
|
21
|
+
dialogBodyID,
|
|
22
|
+
dialogTitleID,
|
|
23
|
+
requestOpenChange
|
|
24
|
+
};
|
|
25
|
+
const dialogSurface = false;
|
|
26
|
+
return {
|
|
27
|
+
dialog,
|
|
28
|
+
dialogSurface
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=useDialogContextValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Dialog/useDialogContextValues.ts"],"names":[],"mappings":"AAGA,OAAM,SAAU,+BAAV,CAA0C,KAA1C,EAA4D;EAChE,MAAM;IAAE,SAAF;IAAa,IAAb;IAAmB,UAAnB;IAA+B,UAA/B;IAA2C,YAA3C;IAAyD,aAAzD;IAAwE;EAAxE,IAA8F,KAApG;EAEA;;;AAGG;;EACH,MAAM,MAAM,GAAuB;IACjC,IADiC;IAEjC,SAFiC;IAGjC,UAHiC;IAIjC,UAJiC;IAKjC,YALiC;IAMjC,aANiC;IAOjC;EAPiC,CAAnC;EAUA,MAAM,aAAa,GAA8B,KAAjD;EAEA,OAAO;IAAE,MAAF;IAAU;EAAV,CAAP;AACD","sourcesContent":["import type { DialogContextValue, DialogSurfaceContextValue } from '../../contexts';\nimport type { DialogContextValues, DialogState } from './Dialog.types';\n\nexport function useDialogContextValues_unstable(state: DialogState): DialogContextValues {\n const { modalType, open, triggerRef, contentRef, dialogBodyID, dialogTitleID, requestOpenChange } = state;\n\n /**\n * This context is created with \"@fluentui/react-context-selector\",\n * there is no sense to memoize it\n */\n const dialog: DialogContextValue = {\n open,\n modalType,\n triggerRef,\n contentRef,\n dialogBodyID,\n dialogTitleID,\n requestOpenChange,\n };\n\n const dialogSurface: DialogSurfaceContextValue = false;\n\n return { dialog, dialogSurface };\n}\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { __styles, mergeClasses, shorthands } from '@griffel/react';
|
|
2
|
+
import { useHasParentContext } from '@fluentui/react-context-selector';
|
|
3
|
+
import { DialogContext } from '../../contexts/dialogContext';
|
|
4
|
+
export const dialogClassNames = {
|
|
5
|
+
overlay: 'fui-Dialog__overlay'
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Styles for the root slot
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const useStyles = /*#__PURE__*/__styles({
|
|
12
|
+
"overlay": {
|
|
13
|
+
"qhf8xq": "f19dog8a",
|
|
14
|
+
"De3pzq": "fju19wo",
|
|
15
|
+
"Bhzewxz": "f113wtx2",
|
|
16
|
+
"j35jbq": ["f10k790i", "f1xynx9j"],
|
|
17
|
+
"B5kzvoi": "f5gq2j6",
|
|
18
|
+
"oyh7mz": ["f1xynx9j", "f10k790i"]
|
|
19
|
+
},
|
|
20
|
+
"nestedDialogOverlay": {
|
|
21
|
+
"De3pzq": "f3rmtva"
|
|
22
|
+
}
|
|
23
|
+
}, {
|
|
24
|
+
"d": [".f19dog8a{position:fixed;}", ".fju19wo{background-color:rgba(0, 0, 0, 0.4);}", ".f113wtx2{top:0px;}", ".f10k790i{right:0px;}", ".f1xynx9j{left:0px;}", ".f5gq2j6{bottom:0px;}", ".f3rmtva{background-color:transparent;}"]
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Apply styling to the Dialog slots based on the state
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export const useDialogStyles_unstable = state => {
|
|
32
|
+
const styles = useStyles();
|
|
33
|
+
const isNestedDialog = useHasParentContext(DialogContext);
|
|
34
|
+
|
|
35
|
+
if (state.overlay) {
|
|
36
|
+
state.overlay.className = mergeClasses(dialogClassNames.overlay, styles.overlay, isNestedDialog && styles.nestedDialogOverlay, state.overlay.className);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return state;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=useDialogStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Dialog/useDialogStyles.ts"],"names":[],"mappings":"AACA,mBAAqB,YAArB,EAAmC,UAAnC,QAAqD,gBAArD;AACA,SAAS,mBAAT,QAAoC,kCAApC;AACA,SAAS,aAAT,QAA8B,8BAA9B;AAGA,OAAO,MAAM,gBAAgB,GAAgC;EAC3D,OAAO,EAAE;AADkD,CAAtD;AAGP;;AAEG;;AACH,MAAM,SAAS,gBAAG;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAAlB;AAWA;;AAEG;;;AACH,OAAO,MAAM,wBAAwB,GAAI,KAAD,IAAoC;EAC1E,MAAM,MAAM,GAAG,SAAS,EAAxB;EACA,MAAM,cAAc,GAAG,mBAAmB,CAAC,aAAD,CAA1C;;EAEA,IAAI,KAAK,CAAC,OAAV,EAAmB;IACjB,KAAK,CAAC,OAAN,CAAc,SAAd,GAA0B,YAAY,CACpC,gBAAgB,CAAC,OADmB,EAEpC,MAAM,CAAC,OAF6B,EAGpC,cAAc,IAAI,MAAM,CAAC,mBAHW,EAIpC,KAAK,CAAC,OAAN,CAAc,SAJsB,CAAtC;EAMD;;EAED,OAAO,KAAP;AACD,CAdM","sourcesContent":["import type { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { useHasParentContext } from '@fluentui/react-context-selector';\nimport { DialogContext } from '../../contexts/dialogContext';\nimport type { DialogSlots, DialogState } from './Dialog.types';\n\nexport const dialogClassNames: SlotClassNames<DialogSlots> = {\n overlay: 'fui-Dialog__overlay',\n};\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n overlay: {\n position: 'fixed',\n backgroundColor: 'rgba(0, 0, 0, 0.4)',\n ...shorthands.inset('0px'),\n },\n nestedDialogOverlay: {\n backgroundColor: 'transparent',\n },\n});\n\n/**\n * Apply styling to the Dialog slots based on the state\n */\nexport const useDialogStyles_unstable = (state: DialogState): DialogState => {\n const styles = useStyles();\n const isNestedDialog = useHasParentContext(DialogContext);\n\n if (state.overlay) {\n state.overlay.className = mergeClasses(\n dialogClassNames.overlay,\n styles.overlay,\n isNestedDialog && styles.nestedDialogOverlay,\n state.overlay.className,\n );\n }\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useDialogActions_unstable } from './useDialogActions';
|
|
3
|
+
import { renderDialogActions_unstable } from './renderDialogActions';
|
|
4
|
+
import { useDialogActionsStyles_unstable } from './useDialogActionsStyles';
|
|
5
|
+
/**
|
|
6
|
+
* `DialogActions` is a container for the actions of the dialog.
|
|
7
|
+
* Apart from styling, this component does not have other behavior.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const DialogActions = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
11
|
+
const state = useDialogActions_unstable(props, ref);
|
|
12
|
+
useDialogActionsStyles_unstable(state);
|
|
13
|
+
return renderDialogActions_unstable(state);
|
|
14
|
+
});
|
|
15
|
+
DialogActions.displayName = 'DialogActions';
|
|
16
|
+
//# sourceMappingURL=DialogActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/DialogActions/DialogActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,yBAAT,QAA0C,oBAA1C;AACA,SAAS,4BAAT,QAA6C,uBAA7C;AACA,SAAS,+BAAT,QAAgD,0BAAhD;AAIA;;;AAGG;;AACH,OAAO,MAAM,aAAa,gBAA4C,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EACpG,MAAM,KAAK,GAAG,yBAAyB,CAAC,KAAD,EAAQ,GAAR,CAAvC;EAEA,+BAA+B,CAAC,KAAD,CAA/B;EACA,OAAO,4BAA4B,CAAC,KAAD,CAAnC;AACD,CALqE,CAA/D;AAOP,aAAa,CAAC,WAAd,GAA4B,eAA5B","sourcesContent":["import * as React from 'react';\nimport { useDialogActions_unstable } from './useDialogActions';\nimport { renderDialogActions_unstable } from './renderDialogActions';\nimport { useDialogActionsStyles_unstable } from './useDialogActionsStyles';\nimport type { DialogActionsProps } from './DialogActions.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * `DialogActions` is a container for the actions of the dialog.\n * Apart from styling, this component does not have other behavior.\n */\nexport const DialogActions: ForwardRefComponent<DialogActionsProps> = React.forwardRef((props, ref) => {\n const state = useDialogActions_unstable(props, ref);\n\n useDialogActionsStyles_unstable(state);\n return renderDialogActions_unstable(state);\n});\n\nDialogActions.displayName = 'DialogActions';\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogActions.types.js","sourceRoot":"../src/","sources":["components/DialogActions/DialogActions.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type DialogActionsSlots = {\n root: Slot<'div'>;\n};\n\nexport type DialogActionsPosition = 'start' | 'end';\n\n/**\n * DialogActions Props\n */\nexport type DialogActionsProps = ComponentProps<DialogActionsSlots> & {\n /**\n * defines the position on the dialog grid of the actions\n * @default 'end'\n */\n position?: DialogActionsPosition;\n};\n\n/**\n * State used in rendering DialogActions\n */\nexport type DialogActionsState = ComponentState<DialogActionsSlots> & {\n position: DialogActionsPosition;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/DialogActions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './DialogActions';\nexport * from './DialogActions.types';\nexport * from './renderDialogActions';\nexport * from './useDialogActions';\nexport * from './useDialogActionsStyles';\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getSlots } from '@fluentui/react-utilities';
|
|
3
|
+
/**
|
|
4
|
+
* Render the final JSX of DialogActions
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const renderDialogActions_unstable = state => {
|
|
8
|
+
const {
|
|
9
|
+
slots,
|
|
10
|
+
slotProps
|
|
11
|
+
} = getSlots(state); // TODO Add additional slots in the appropriate place
|
|
12
|
+
|
|
13
|
+
return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=renderDialogActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/DialogActions/renderDialogActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,4BAA4B,GAAI,KAAD,IAA8B;EACxE,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,QAAQ,CAAqB,KAArB,CAArC,CADwE,CAGxE;;EACA,oBAAO,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,CAAP;AACD,CALM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { DialogActionsState, DialogActionsSlots } from './DialogActions.types';\n\n/**\n * Render the final JSX of DialogActions\n */\nexport const renderDialogActions_unstable = (state: DialogActionsState) => {\n const { slots, slotProps } = getSlots<DialogActionsSlots>(state);\n\n // TODO Add additional slots in the appropriate place\n return <slots.root {...slotProps.root} />;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getNativeElementProps } from '@fluentui/react-utilities';
|
|
2
|
+
/**
|
|
3
|
+
* Create the state required to render DialogActions.
|
|
4
|
+
*
|
|
5
|
+
* The returned state can be modified with hooks such as useDialogActionsStyles_unstable,
|
|
6
|
+
* before being passed to renderDialogActions_unstable.
|
|
7
|
+
*
|
|
8
|
+
* @param props - props from this instance of DialogActions
|
|
9
|
+
* @param ref - reference to root HTMLElement of DialogActions
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const useDialogActions_unstable = (props, ref) => {
|
|
13
|
+
const {
|
|
14
|
+
position = 'end'
|
|
15
|
+
} = props;
|
|
16
|
+
return {
|
|
17
|
+
components: {
|
|
18
|
+
root: 'div'
|
|
19
|
+
},
|
|
20
|
+
root: getNativeElementProps('div', {
|
|
21
|
+
ref,
|
|
22
|
+
...props
|
|
23
|
+
}),
|
|
24
|
+
position
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useDialogActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/DialogActions/useDialogActions.ts"],"names":[],"mappings":"AACA,SAAS,qBAAT,QAAsC,2BAAtC;AAGA;;;;;;;;AAQG;;AACH,OAAO,MAAM,yBAAyB,GAAG,CACvC,KADuC,EAEvC,GAFuC,KAGjB;EACtB,MAAM;IAAE,QAAQ,GAAG;EAAb,IAAuB,KAA7B;EACA,OAAO;IACL,UAAU,EAAE;MACV,IAAI,EAAE;IADI,CADP;IAIL,IAAI,EAAE,qBAAqB,CAAC,KAAD,EAAQ;MACjC,GADiC;MAEjC,GAAG;IAF8B,CAAR,CAJtB;IAQL;EARK,CAAP;AAUD,CAfM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps } from '@fluentui/react-utilities';\nimport type { DialogActionsProps, DialogActionsState } from './DialogActions.types';\n\n/**\n * Create the state required to render DialogActions.\n *\n * The returned state can be modified with hooks such as useDialogActionsStyles_unstable,\n * before being passed to renderDialogActions_unstable.\n *\n * @param props - props from this instance of DialogActions\n * @param ref - reference to root HTMLElement of DialogActions\n */\nexport const useDialogActions_unstable = (\n props: DialogActionsProps,\n ref: React.Ref<HTMLElement>,\n): DialogActionsState => {\n const { position = 'end' } = props;\n return {\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n ref,\n ...props,\n }),\n position,\n };\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { __styles, mergeClasses, shorthands } from '@griffel/react';
|
|
2
|
+
import { DIALOG_GAP, ACTIONS_END_GRID_AREA, ACTIONS_START_GRID_AREA, MEDIA_QUERY_BREAKPOINT_SELECTOR } from '../../contexts/constants';
|
|
3
|
+
import * as localShorthands from '../../utils/localShorthands';
|
|
4
|
+
export const dialogActionsClassNames = {
|
|
5
|
+
root: 'fui-DialogActions'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const useStyles = /*#__PURE__*/__styles({
|
|
9
|
+
"root": {
|
|
10
|
+
"Bqenvij": "f3052tw",
|
|
11
|
+
"B7ck84d": "f1ewtqcl",
|
|
12
|
+
"mc9l5x": "f22iagw",
|
|
13
|
+
"i8kkvl": "f4px1ci",
|
|
14
|
+
"Belr9w4": "fn67r4l",
|
|
15
|
+
"Bnr8eeb": "f12ep7o",
|
|
16
|
+
"Bmdcpmo": "f6glcwc",
|
|
17
|
+
"th9wkt": "f1e3st1r"
|
|
18
|
+
},
|
|
19
|
+
"gridPositionEnd": {
|
|
20
|
+
"Bdqf98w": "f1a7i8kp",
|
|
21
|
+
"Ijaq50": "f11u0jfc",
|
|
22
|
+
"nk6f5a": "f23awfp",
|
|
23
|
+
"Br312pm": "f1d6tb1o",
|
|
24
|
+
"Bw0ie65": "fiappcv"
|
|
25
|
+
},
|
|
26
|
+
"gridPositionStart": {
|
|
27
|
+
"Bdqf98w": "fsxvdwy",
|
|
28
|
+
"Ijaq50": "f1vnb230",
|
|
29
|
+
"nk6f5a": "f13d374e",
|
|
30
|
+
"Br312pm": "f14781pt",
|
|
31
|
+
"Bw0ie65": "f1fjo411"
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
"d": [".f3052tw{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;}", ".f1ewtqcl{box-sizing:border-box;}", ".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f4px1ci{-webkit-column-gap:8px;column-gap:8px;}", ".fn67r4l{row-gap:8px;}", ".f12ep7o>.fui-Button{max-width:100%;}", ".f1a7i8kp{justify-self:end;}", ".f11u0jfc{grid-row-start:actions-end;}", ".f23awfp{grid-row-end:actions-end;}", ".f1d6tb1o{grid-column-start:actions-end;}", ".fiappcv{grid-column-end:actions-end;}", ".fsxvdwy{justify-self:start;}", ".f1vnb230{grid-row-start:actions-start;}", ".f13d374e{grid-row-end:actions-start;}", ".f14781pt{grid-column-start:actions-start;}", ".f1fjo411{grid-column-end:actions-start;}"],
|
|
35
|
+
"m": [["@media screen and (max-width: 480px){.f6glcwc{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}}", {
|
|
36
|
+
"m": "screen and (max-width: 480px)"
|
|
37
|
+
}], ["@media screen and (max-width: 480px){.f1e3st1r{justify-self:stretch;}}", {
|
|
38
|
+
"m": "screen and (max-width: 480px)"
|
|
39
|
+
}]]
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Apply styling to the DialogActions slots based on the state
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export const useDialogActionsStyles_unstable = state => {
|
|
47
|
+
const styles = useStyles();
|
|
48
|
+
state.root.className = mergeClasses(dialogActionsClassNames.root, styles.root, state.position === 'start' && styles.gridPositionStart, state.position === 'end' && styles.gridPositionEnd, state.root.className);
|
|
49
|
+
return state;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=useDialogActionsStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/DialogActions/useDialogActionsStyles.ts"],"names":[],"mappings":"AAAA,mBAAqB,YAArB,EAAmC,UAAnC,QAAqD,gBAArD;AAGA,SACE,UADF,EAEE,qBAFF,EAGE,uBAHF,EAIE,+BAJF,QAKO,0BALP;AAMA,OAAO,KAAK,eAAZ,MAAiC,6BAAjC;AAEA,OAAO,MAAM,uBAAuB,GAAuC;EACzE,IAAI,EAAE;AADmE,CAApE;;AAIP,MAAM,SAAS,gBAAG;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;AAAA;EAAA;EAAA;IAAA;EAAA;IAAA;EAAA;AAAA,EAAlB;AAwBA;;AAEG;;;AACH,OAAO,MAAM,+BAA+B,GAAI,KAAD,IAAkD;EAC/F,MAAM,MAAM,GAAG,SAAS,EAAxB;EACA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CACjC,uBAAuB,CAAC,IADS,EAEjC,MAAM,CAAC,IAF0B,EAGjC,KAAK,CAAC,QAAN,KAAmB,OAAnB,IAA8B,MAAM,CAAC,iBAHJ,EAIjC,KAAK,CAAC,QAAN,KAAmB,KAAnB,IAA4B,MAAM,CAAC,eAJF,EAKjC,KAAK,CAAC,IAAN,CAAW,SALsB,CAAnC;EAOA,OAAO,KAAP;AACD,CAVM","sourcesContent":["import { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport type { DialogActionsSlots, DialogActionsState } from './DialogActions.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport {\n DIALOG_GAP,\n ACTIONS_END_GRID_AREA,\n ACTIONS_START_GRID_AREA,\n MEDIA_QUERY_BREAKPOINT_SELECTOR,\n} from '../../contexts/constants';\nimport * as localShorthands from '../../utils/localShorthands';\n\nexport const dialogActionsClassNames: SlotClassNames<DialogActionsSlots> = {\n root: 'fui-DialogActions',\n};\n\nconst useStyles = makeStyles({\n root: {\n height: 'fit-content',\n boxSizing: 'border-box',\n display: 'flex',\n ...shorthands.gap(DIALOG_GAP),\n '> .fui-Button': {\n maxWidth: '100%',\n },\n [MEDIA_QUERY_BREAKPOINT_SELECTOR]: {\n flexDirection: 'column',\n justifySelf: 'stretch',\n },\n },\n gridPositionEnd: {\n justifySelf: 'end',\n ...localShorthands.gridArea(ACTIONS_END_GRID_AREA),\n },\n gridPositionStart: {\n justifySelf: 'start',\n ...localShorthands.gridArea(ACTIONS_START_GRID_AREA),\n },\n});\n\n/**\n * Apply styling to the DialogActions slots based on the state\n */\nexport const useDialogActionsStyles_unstable = (state: DialogActionsState): DialogActionsState => {\n const styles = useStyles();\n state.root.className = mergeClasses(\n dialogActionsClassNames.root,\n styles.root,\n state.position === 'start' && styles.gridPositionStart,\n state.position === 'end' && styles.gridPositionEnd,\n state.root.className,\n );\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useDialogBody_unstable } from './useDialogBody';
|
|
3
|
+
import { renderDialogBody_unstable } from './renderDialogBody';
|
|
4
|
+
import { useDialogBodyStyles_unstable } from './useDialogBodyStyles';
|
|
5
|
+
/**
|
|
6
|
+
* The `DialogBody` is a container where the content of the dialog is rendered.
|
|
7
|
+
* Apart from styling, this component does not have other behavior.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const DialogBody = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
11
|
+
const state = useDialogBody_unstable(props, ref);
|
|
12
|
+
useDialogBodyStyles_unstable(state);
|
|
13
|
+
return renderDialogBody_unstable(state);
|
|
14
|
+
});
|
|
15
|
+
DialogBody.displayName = 'DialogBody';
|
|
16
|
+
//# sourceMappingURL=DialogBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/DialogBody/DialogBody.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,sBAAT,QAAuC,iBAAvC;AACA,SAAS,yBAAT,QAA0C,oBAA1C;AACA,SAAS,4BAAT,QAA6C,uBAA7C;AAIA;;;AAGG;;AACH,OAAO,MAAM,UAAU,gBAAyC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EAC9F,MAAM,KAAK,GAAG,sBAAsB,CAAC,KAAD,EAAQ,GAAR,CAApC;EAEA,4BAA4B,CAAC,KAAD,CAA5B;EACA,OAAO,yBAAyB,CAAC,KAAD,CAAhC;AACD,CAL+D,CAAzD;AAOP,UAAU,CAAC,WAAX,GAAyB,YAAzB","sourcesContent":["import * as React from 'react';\nimport { useDialogBody_unstable } from './useDialogBody';\nimport { renderDialogBody_unstable } from './renderDialogBody';\nimport { useDialogBodyStyles_unstable } from './useDialogBodyStyles';\nimport type { DialogBodyProps } from './DialogBody.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * The `DialogBody` is a container where the content of the dialog is rendered.\n * Apart from styling, this component does not have other behavior.\n */\nexport const DialogBody: ForwardRefComponent<DialogBodyProps> = React.forwardRef((props, ref) => {\n const state = useDialogBody_unstable(props, ref);\n\n useDialogBodyStyles_unstable(state);\n return renderDialogBody_unstable(state);\n});\n\nDialogBody.displayName = 'DialogBody';\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogBody.types.js","sourceRoot":"../src/","sources":["components/DialogBody/DialogBody.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type DialogBodySlots = {\n root: Slot<'div'>;\n};\n\n/**\n * DialogBody Props\n */\nexport type DialogBodyProps = ComponentProps<DialogBodySlots> & {};\n\n/**\n * State used in rendering DialogBody\n */\nexport type DialogBodyState = ComponentState<DialogBodySlots>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/DialogBody/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC","sourcesContent":["export * from './DialogBody';\nexport * from './DialogBody.types';\nexport * from './renderDialogBody';\nexport * from './useDialogBody';\nexport * from './useDialogBodyStyles';\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getSlots } from '@fluentui/react-utilities';
|
|
3
|
+
/**
|
|
4
|
+
* Render the final JSX of DialogBody
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const renderDialogBody_unstable = state => {
|
|
8
|
+
const {
|
|
9
|
+
slots,
|
|
10
|
+
slotProps
|
|
11
|
+
} = getSlots(state); // TODO Add additional slots in the appropriate place
|
|
12
|
+
|
|
13
|
+
return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=renderDialogBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/DialogBody/renderDialogBody.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,yBAAyB,GAAI,KAAD,IAA2B;EAClE,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,QAAQ,CAAkB,KAAlB,CAArC,CADkE,CAGlE;;EACA,oBAAO,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,CAAP;AACD,CALM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { DialogBodyState, DialogBodySlots } from './DialogBody.types';\n\n/**\n * Render the final JSX of DialogBody\n */\nexport const renderDialogBody_unstable = (state: DialogBodyState) => {\n const { slots, slotProps } = getSlots<DialogBodySlots>(state);\n\n // TODO Add additional slots in the appropriate place\n return <slots.root {...slotProps.root} />;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getNativeElementProps } from '@fluentui/react-utilities';
|
|
2
|
+
import { useDialogContext_unstable } from '../../contexts';
|
|
3
|
+
/**
|
|
4
|
+
* Create the state required to render DialogBody.
|
|
5
|
+
*
|
|
6
|
+
* The returned state can be modified with hooks such as useDialogBodyStyles_unstable,
|
|
7
|
+
* before being passed to renderDialogBody_unstable.
|
|
8
|
+
*
|
|
9
|
+
* @param props - props from this instance of DialogBody
|
|
10
|
+
* @param ref - reference to root HTMLElement of DialogBody
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const useDialogBody_unstable = (props, ref) => {
|
|
14
|
+
return {
|
|
15
|
+
components: {
|
|
16
|
+
root: 'div'
|
|
17
|
+
},
|
|
18
|
+
root: getNativeElementProps('div', {
|
|
19
|
+
ref,
|
|
20
|
+
id: useDialogContext_unstable(ctx => ctx.dialogBodyID),
|
|
21
|
+
...props
|
|
22
|
+
})
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=useDialogBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/DialogBody/useDialogBody.ts"],"names":[],"mappings":"AACA,SAAS,qBAAT,QAAsC,2BAAtC;AAEA,SAAS,yBAAT,QAA0C,gBAA1C;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,sBAAsB,GAAG,CAAC,KAAD,EAAyB,GAAzB,KAAyE;EAC7G,OAAO;IACL,UAAU,EAAE;MACV,IAAI,EAAE;IADI,CADP;IAIL,IAAI,EAAE,qBAAqB,CAAC,KAAD,EAAQ;MACjC,GADiC;MAEjC,EAAE,EAAE,yBAAyB,CAAC,GAAG,IAAI,GAAG,CAAC,YAAZ,CAFI;MAGjC,GAAG;IAH8B,CAAR;EAJtB,CAAP;AAUD,CAXM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps } from '@fluentui/react-utilities';\nimport type { DialogBodyProps, DialogBodyState } from './DialogBody.types';\nimport { useDialogContext_unstable } from '../../contexts';\n\n/**\n * Create the state required to render DialogBody.\n *\n * The returned state can be modified with hooks such as useDialogBodyStyles_unstable,\n * before being passed to renderDialogBody_unstable.\n *\n * @param props - props from this instance of DialogBody\n * @param ref - reference to root HTMLElement of DialogBody\n */\nexport const useDialogBody_unstable = (props: DialogBodyProps, ref: React.Ref<HTMLElement>): DialogBodyState => {\n return {\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n ref,\n id: useDialogContext_unstable(ctx => ctx.dialogBodyID),\n ...props,\n }),\n };\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __styles, mergeClasses } from '@griffel/react';
|
|
2
|
+
import { typographyStyles } from '@fluentui/react-theme';
|
|
3
|
+
import * as localShorthands from '../../utils/localShorthands';
|
|
4
|
+
import { BODY_GRID_AREA } from '../../contexts/constants';
|
|
5
|
+
export const dialogBodyClassNames = {
|
|
6
|
+
root: 'fui-DialogBody'
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Styles for the root slot
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const useStyles = /*#__PURE__*/__styles({
|
|
13
|
+
"root": {
|
|
14
|
+
"a9b677": "fly5x3f",
|
|
15
|
+
"Bqenvij": "f3052tw",
|
|
16
|
+
"sshi5w": "f1nxs5xn",
|
|
17
|
+
"B7ck84d": "f1ewtqcl",
|
|
18
|
+
"Ijaq50": "f6owso0",
|
|
19
|
+
"nk6f5a": "foucsne",
|
|
20
|
+
"Br312pm": "fupswjn",
|
|
21
|
+
"Bw0ie65": "f1ka72gx",
|
|
22
|
+
"Bahqtrf": "fk6fouc",
|
|
23
|
+
"Be2twd7": "fkhj508",
|
|
24
|
+
"Bhrd7zp": "figsok6",
|
|
25
|
+
"Bg96gwp": "f1i3iumi"
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
"d": [".fly5x3f{width:100%;}", ".f3052tw{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;}", ".f1nxs5xn{min-height:32px;}", ".f1ewtqcl{box-sizing:border-box;}", ".f6owso0{grid-row-start:body;}", ".foucsne{grid-row-end:body;}", ".fupswjn{grid-column-start:body;}", ".f1ka72gx{grid-column-end:body;}", ".fk6fouc{font-family:var(--fontFamilyBase);}", ".fkhj508{font-size:var(--fontSizeBase300);}", ".figsok6{font-weight:var(--fontWeightRegular);}", ".f1i3iumi{line-height:var(--lineHeightBase300);}"]
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Apply styling to the DialogBody slots based on the state
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export const useDialogBodyStyles_unstable = state => {
|
|
36
|
+
const styles = useStyles();
|
|
37
|
+
state.root.className = mergeClasses(dialogBodyClassNames.root, styles.root, state.root.className); // TODO Add class names to slots, for example:
|
|
38
|
+
// state.mySlot.className = mergeClasses(styles.mySlot, state.mySlot.className);
|
|
39
|
+
|
|
40
|
+
return state;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=useDialogBodyStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/DialogBody/useDialogBodyStyles.ts"],"names":[],"mappings":"AAAA,mBAAqB,YAArB,QAAyC,gBAAzC;AAGA,SAAS,gBAAT,QAAiC,uBAAjC;AACA,OAAO,KAAK,eAAZ,MAAiC,6BAAjC;AACA,SAAS,cAAT,QAA+B,0BAA/B;AAEA,OAAO,MAAM,oBAAoB,GAAoC;EACnE,IAAI,EAAE;AAD6D,CAA9D;AAIP;;AAEG;;AACH,MAAM,SAAS,gBAAG;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAAlB;AAWA;;AAEG;;;AACH,OAAO,MAAM,4BAA4B,GAAI,KAAD,IAA4C;EACtF,MAAM,MAAM,GAAG,SAAS,EAAxB;EACA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CAAC,oBAAoB,CAAC,IAAtB,EAA4B,MAAM,CAAC,IAAnC,EAAyC,KAAK,CAAC,IAAN,CAAW,SAApD,CAAnC,CAFsF,CAItF;EACA;;EAEA,OAAO,KAAP;AACD,CARM","sourcesContent":["import { makeStyles, mergeClasses } from '@griffel/react';\nimport type { DialogBodySlots, DialogBodyState } from './DialogBody.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { typographyStyles } from '@fluentui/react-theme';\nimport * as localShorthands from '../../utils/localShorthands';\nimport { BODY_GRID_AREA } from '../../contexts/constants';\n\nexport const dialogBodyClassNames: SlotClassNames<DialogBodySlots> = {\n root: 'fui-DialogBody',\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n width: '100%',\n height: 'fit-content',\n minHeight: '32px',\n boxSizing: 'border-box',\n ...localShorthands.gridArea(BODY_GRID_AREA),\n ...typographyStyles.body1,\n },\n});\n\n/**\n * Apply styling to the DialogBody slots based on the state\n */\nexport const useDialogBodyStyles_unstable = (state: DialogBodyState): DialogBodyState => {\n const styles = useStyles();\n state.root.className = mergeClasses(dialogBodyClassNames.root, styles.root, state.root.className);\n\n // TODO Add class names to slots, for example:\n // state.mySlot.className = mergeClasses(styles.mySlot, state.mySlot.className);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useDialogSurface_unstable } from './useDialogSurface';
|
|
3
|
+
import { renderDialogSurface_unstable } from './renderDialogSurface';
|
|
4
|
+
import { useDialogSurfaceStyles_unstable } from './useDialogSurfaceStyles';
|
|
5
|
+
import { useDialogSurfaceContextValues_unstable } from './useDialogSurfaceContextValues';
|
|
6
|
+
/**
|
|
7
|
+
* DialogSurface component represents the visual part of a `Dialog` as a whole,
|
|
8
|
+
* it contains everything that should be visible.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const DialogSurface = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
12
|
+
const state = useDialogSurface_unstable(props, ref);
|
|
13
|
+
const contextValues = useDialogSurfaceContextValues_unstable(state);
|
|
14
|
+
useDialogSurfaceStyles_unstable(state);
|
|
15
|
+
return renderDialogSurface_unstable(state, contextValues);
|
|
16
|
+
});
|
|
17
|
+
DialogSurface.displayName = 'DialogSurface';
|
|
18
|
+
//# sourceMappingURL=DialogSurface.js.map
|