@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.
Files changed (226) hide show
  1. package/CHANGELOG.json +328 -0
  2. package/CHANGELOG.md +152 -0
  3. package/LICENSE +15 -0
  4. package/README.md +5 -0
  5. package/Spec.md +518 -0
  6. package/assets/AlertDialogKeyboardInteraction.png +0 -0
  7. package/assets/AlertDialogMouseInteraction.png +0 -0
  8. package/assets/ModalDialogKeyboardInteraction.png +0 -0
  9. package/assets/ModalDialogMouseInteraction.png +0 -0
  10. package/assets/NonModalDialogKeyboardInteraction.png +0 -0
  11. package/assets/NonModalDialogMouseInteraction.png +0 -0
  12. package/dist/index.d.ts +406 -0
  13. package/dist/tsdoc-metadata.json +11 -0
  14. package/lib/Dialog.js +2 -0
  15. package/lib/Dialog.js.map +1 -0
  16. package/lib/DialogActions.js +2 -0
  17. package/lib/DialogActions.js.map +1 -0
  18. package/lib/DialogBody.js +2 -0
  19. package/lib/DialogBody.js.map +1 -0
  20. package/lib/DialogSurface.js +2 -0
  21. package/lib/DialogSurface.js.map +1 -0
  22. package/lib/DialogTitle.js +2 -0
  23. package/lib/DialogTitle.js.map +1 -0
  24. package/lib/DialogTrigger.js +2 -0
  25. package/lib/DialogTrigger.js.map +1 -0
  26. package/lib/components/Dialog/Dialog.js +21 -0
  27. package/lib/components/Dialog/Dialog.js.map +1 -0
  28. package/lib/components/Dialog/Dialog.types.js +2 -0
  29. package/lib/components/Dialog/Dialog.types.js.map +1 -0
  30. package/lib/components/Dialog/index.js +6 -0
  31. package/lib/components/Dialog/index.js.map +1 -0
  32. package/lib/components/Dialog/renderDialog.js +26 -0
  33. package/lib/components/Dialog/renderDialog.js.map +1 -0
  34. package/lib/components/Dialog/useDialog.js +197 -0
  35. package/lib/components/Dialog/useDialog.js.map +1 -0
  36. package/lib/components/Dialog/useDialogContextValues.js +31 -0
  37. package/lib/components/Dialog/useDialogContextValues.js.map +1 -0
  38. package/lib/components/Dialog/useDialogStyles.js +41 -0
  39. package/lib/components/Dialog/useDialogStyles.js.map +1 -0
  40. package/lib/components/DialogActions/DialogActions.js +16 -0
  41. package/lib/components/DialogActions/DialogActions.js.map +1 -0
  42. package/lib/components/DialogActions/DialogActions.types.js +2 -0
  43. package/lib/components/DialogActions/DialogActions.types.js.map +1 -0
  44. package/lib/components/DialogActions/index.js +6 -0
  45. package/lib/components/DialogActions/index.js.map +1 -0
  46. package/lib/components/DialogActions/renderDialogActions.js +16 -0
  47. package/lib/components/DialogActions/renderDialogActions.js.map +1 -0
  48. package/lib/components/DialogActions/useDialogActions.js +27 -0
  49. package/lib/components/DialogActions/useDialogActions.js.map +1 -0
  50. package/lib/components/DialogActions/useDialogActionsStyles.js +51 -0
  51. package/lib/components/DialogActions/useDialogActionsStyles.js.map +1 -0
  52. package/lib/components/DialogBody/DialogBody.js +16 -0
  53. package/lib/components/DialogBody/DialogBody.js.map +1 -0
  54. package/lib/components/DialogBody/DialogBody.types.js +2 -0
  55. package/lib/components/DialogBody/DialogBody.types.js.map +1 -0
  56. package/lib/components/DialogBody/index.js +6 -0
  57. package/lib/components/DialogBody/index.js.map +1 -0
  58. package/lib/components/DialogBody/renderDialogBody.js +16 -0
  59. package/lib/components/DialogBody/renderDialogBody.js.map +1 -0
  60. package/lib/components/DialogBody/useDialogBody.js +25 -0
  61. package/lib/components/DialogBody/useDialogBody.js.map +1 -0
  62. package/lib/components/DialogBody/useDialogBodyStyles.js +42 -0
  63. package/lib/components/DialogBody/useDialogBodyStyles.js.map +1 -0
  64. package/lib/components/DialogSurface/DialogSurface.js +18 -0
  65. package/lib/components/DialogSurface/DialogSurface.js.map +1 -0
  66. package/lib/components/DialogSurface/DialogSurface.types.js +2 -0
  67. package/lib/components/DialogSurface/DialogSurface.types.js.map +1 -0
  68. package/lib/components/DialogSurface/index.js +6 -0
  69. package/lib/components/DialogSurface/index.js.map +1 -0
  70. package/lib/components/DialogSurface/renderDialogSurface.js +18 -0
  71. package/lib/components/DialogSurface/renderDialogSurface.js.map +1 -0
  72. package/lib/components/DialogSurface/useDialogSurface.js +59 -0
  73. package/lib/components/DialogSurface/useDialogSurface.js.map +1 -0
  74. package/lib/components/DialogSurface/useDialogSurfaceContextValues.js +7 -0
  75. package/lib/components/DialogSurface/useDialogSurfaceContextValues.js.map +1 -0
  76. package/lib/components/DialogSurface/useDialogSurfaceStyles.js +78 -0
  77. package/lib/components/DialogSurface/useDialogSurfaceStyles.js.map +1 -0
  78. package/lib/components/DialogTitle/DialogTitle.js +17 -0
  79. package/lib/components/DialogTitle/DialogTitle.js.map +1 -0
  80. package/lib/components/DialogTitle/DialogTitle.types.js +2 -0
  81. package/lib/components/DialogTitle/DialogTitle.types.js.map +1 -0
  82. package/lib/components/DialogTitle/index.js +6 -0
  83. package/lib/components/DialogTitle/index.js.map +1 -0
  84. package/lib/components/DialogTitle/renderDialogTitle.js +19 -0
  85. package/lib/components/DialogTitle/renderDialogTitle.js.map +1 -0
  86. package/lib/components/DialogTitle/useDialogTitle.js +42 -0
  87. package/lib/components/DialogTitle/useDialogTitle.js.map +1 -0
  88. package/lib/components/DialogTitle/useDialogTitleStyles.js +109 -0
  89. package/lib/components/DialogTitle/useDialogTitleStyles.js.map +1 -0
  90. package/lib/components/DialogTrigger/DialogTrigger.js +20 -0
  91. package/lib/components/DialogTrigger/DialogTrigger.js.map +1 -0
  92. package/lib/components/DialogTrigger/DialogTrigger.types.js +2 -0
  93. package/lib/components/DialogTrigger/DialogTrigger.types.js.map +1 -0
  94. package/lib/components/DialogTrigger/index.js +5 -0
  95. package/lib/components/DialogTrigger/index.js.map +1 -0
  96. package/lib/components/DialogTrigger/renderDialogTrigger.js +7 -0
  97. package/lib/components/DialogTrigger/renderDialogTrigger.js.map +1 -0
  98. package/lib/components/DialogTrigger/useDialogTrigger.js +65 -0
  99. package/lib/components/DialogTrigger/useDialogTrigger.js.map +1 -0
  100. package/lib/contexts/constants.js +11 -0
  101. package/lib/contexts/constants.js.map +1 -0
  102. package/lib/contexts/dialogContext.js +21 -0
  103. package/lib/contexts/dialogContext.js.map +1 -0
  104. package/lib/contexts/dialogSurfaceContext.js +10 -0
  105. package/lib/contexts/dialogSurfaceContext.js.map +1 -0
  106. package/lib/contexts/index.js +4 -0
  107. package/lib/contexts/index.js.map +1 -0
  108. package/lib/index.js +7 -0
  109. package/lib/index.js.map +1 -0
  110. package/lib/utils/index.js +5 -0
  111. package/lib/utils/index.js.map +1 -0
  112. package/lib/utils/isEscapeKeyDown.js +11 -0
  113. package/lib/utils/isEscapeKeyDown.js.map +1 -0
  114. package/lib/utils/isTargetDisabled.js +14 -0
  115. package/lib/utils/isTargetDisabled.js.map +1 -0
  116. package/lib/utils/localShorthands.js +9 -0
  117. package/lib/utils/localShorthands.js.map +1 -0
  118. package/lib/utils/normalizeDefaultPrevented.js +11 -0
  119. package/lib/utils/normalizeDefaultPrevented.js.map +1 -0
  120. package/lib-commonjs/Dialog.js +10 -0
  121. package/lib-commonjs/Dialog.js.map +1 -0
  122. package/lib-commonjs/DialogActions.js +10 -0
  123. package/lib-commonjs/DialogActions.js.map +1 -0
  124. package/lib-commonjs/DialogBody.js +10 -0
  125. package/lib-commonjs/DialogBody.js.map +1 -0
  126. package/lib-commonjs/DialogSurface.js +10 -0
  127. package/lib-commonjs/DialogSurface.js.map +1 -0
  128. package/lib-commonjs/DialogTitle.js +10 -0
  129. package/lib-commonjs/DialogTitle.js.map +1 -0
  130. package/lib-commonjs/DialogTrigger.js +10 -0
  131. package/lib-commonjs/DialogTrigger.js.map +1 -0
  132. package/lib-commonjs/components/Dialog/Dialog.js +33 -0
  133. package/lib-commonjs/components/Dialog/Dialog.js.map +1 -0
  134. package/lib-commonjs/components/Dialog/Dialog.types.js +6 -0
  135. package/lib-commonjs/components/Dialog/Dialog.types.js.map +1 -0
  136. package/lib-commonjs/components/Dialog/index.js +18 -0
  137. package/lib-commonjs/components/Dialog/index.js.map +1 -0
  138. package/lib-commonjs/components/Dialog/renderDialog.js +39 -0
  139. package/lib-commonjs/components/Dialog/renderDialog.js.map +1 -0
  140. package/lib-commonjs/components/Dialog/useDialog.js +211 -0
  141. package/lib-commonjs/components/Dialog/useDialog.js.map +1 -0
  142. package/lib-commonjs/components/Dialog/useDialogContextValues.js +40 -0
  143. package/lib-commonjs/components/Dialog/useDialogContextValues.js.map +1 -0
  144. package/lib-commonjs/components/Dialog/useDialogStyles.js +53 -0
  145. package/lib-commonjs/components/Dialog/useDialogStyles.js.map +1 -0
  146. package/lib-commonjs/components/DialogActions/DialogActions.js +27 -0
  147. package/lib-commonjs/components/DialogActions/DialogActions.js.map +1 -0
  148. package/lib-commonjs/components/DialogActions/DialogActions.types.js +6 -0
  149. package/lib-commonjs/components/DialogActions/DialogActions.types.js.map +1 -0
  150. package/lib-commonjs/components/DialogActions/index.js +18 -0
  151. package/lib-commonjs/components/DialogActions/index.js.map +1 -0
  152. package/lib-commonjs/components/DialogActions/renderDialogActions.js +27 -0
  153. package/lib-commonjs/components/DialogActions/renderDialogActions.js.map +1 -0
  154. package/lib-commonjs/components/DialogActions/useDialogActions.js +37 -0
  155. package/lib-commonjs/components/DialogActions/useDialogActions.js.map +1 -0
  156. package/lib-commonjs/components/DialogActions/useDialogActionsStyles.js +63 -0
  157. package/lib-commonjs/components/DialogActions/useDialogActionsStyles.js.map +1 -0
  158. package/lib-commonjs/components/DialogBody/DialogBody.js +27 -0
  159. package/lib-commonjs/components/DialogBody/DialogBody.js.map +1 -0
  160. package/lib-commonjs/components/DialogBody/DialogBody.types.js +6 -0
  161. package/lib-commonjs/components/DialogBody/DialogBody.types.js.map +1 -0
  162. package/lib-commonjs/components/DialogBody/index.js +18 -0
  163. package/lib-commonjs/components/DialogBody/index.js.map +1 -0
  164. package/lib-commonjs/components/DialogBody/renderDialogBody.js +27 -0
  165. package/lib-commonjs/components/DialogBody/renderDialogBody.js.map +1 -0
  166. package/lib-commonjs/components/DialogBody/useDialogBody.js +36 -0
  167. package/lib-commonjs/components/DialogBody/useDialogBody.js.map +1 -0
  168. package/lib-commonjs/components/DialogBody/useDialogBodyStyles.js +55 -0
  169. package/lib-commonjs/components/DialogBody/useDialogBodyStyles.js.map +1 -0
  170. package/lib-commonjs/components/DialogSurface/DialogSurface.js +30 -0
  171. package/lib-commonjs/components/DialogSurface/DialogSurface.js.map +1 -0
  172. package/lib-commonjs/components/DialogSurface/DialogSurface.types.js +6 -0
  173. package/lib-commonjs/components/DialogSurface/DialogSurface.types.js.map +1 -0
  174. package/lib-commonjs/components/DialogSurface/index.js +18 -0
  175. package/lib-commonjs/components/DialogSurface/index.js.map +1 -0
  176. package/lib-commonjs/components/DialogSurface/renderDialogSurface.js +30 -0
  177. package/lib-commonjs/components/DialogSurface/renderDialogSurface.js.map +1 -0
  178. package/lib-commonjs/components/DialogSurface/useDialogSurface.js +72 -0
  179. package/lib-commonjs/components/DialogSurface/useDialogSurface.js.map +1 -0
  180. package/lib-commonjs/components/DialogSurface/useDialogSurfaceContextValues.js +16 -0
  181. package/lib-commonjs/components/DialogSurface/useDialogSurfaceContextValues.js.map +1 -0
  182. package/lib-commonjs/components/DialogSurface/useDialogSurfaceStyles.js +90 -0
  183. package/lib-commonjs/components/DialogSurface/useDialogSurfaceStyles.js.map +1 -0
  184. package/lib-commonjs/components/DialogTitle/DialogTitle.js +28 -0
  185. package/lib-commonjs/components/DialogTitle/DialogTitle.js.map +1 -0
  186. package/lib-commonjs/components/DialogTitle/DialogTitle.types.js +6 -0
  187. package/lib-commonjs/components/DialogTitle/DialogTitle.types.js.map +1 -0
  188. package/lib-commonjs/components/DialogTitle/index.js +18 -0
  189. package/lib-commonjs/components/DialogTitle/index.js.map +1 -0
  190. package/lib-commonjs/components/DialogTitle/renderDialogTitle.js +31 -0
  191. package/lib-commonjs/components/DialogTitle/renderDialogTitle.js.map +1 -0
  192. package/lib-commonjs/components/DialogTitle/useDialogTitle.js +56 -0
  193. package/lib-commonjs/components/DialogTitle/useDialogTitle.js.map +1 -0
  194. package/lib-commonjs/components/DialogTitle/useDialogTitleStyles.js +123 -0
  195. package/lib-commonjs/components/DialogTitle/useDialogTitleStyles.js.map +1 -0
  196. package/lib-commonjs/components/DialogTrigger/DialogTrigger.js +31 -0
  197. package/lib-commonjs/components/DialogTrigger/DialogTrigger.js.map +1 -0
  198. package/lib-commonjs/components/DialogTrigger/DialogTrigger.types.js +6 -0
  199. package/lib-commonjs/components/DialogTrigger/DialogTrigger.types.js.map +1 -0
  200. package/lib-commonjs/components/DialogTrigger/index.js +16 -0
  201. package/lib-commonjs/components/DialogTrigger/index.js.map +1 -0
  202. package/lib-commonjs/components/DialogTrigger/renderDialogTrigger.js +16 -0
  203. package/lib-commonjs/components/DialogTrigger/renderDialogTrigger.js.map +1 -0
  204. package/lib-commonjs/components/DialogTrigger/useDialogTrigger.js +80 -0
  205. package/lib-commonjs/components/DialogTrigger/useDialogTrigger.js.map +1 -0
  206. package/lib-commonjs/contexts/constants.js +17 -0
  207. package/lib-commonjs/contexts/constants.js.map +1 -0
  208. package/lib-commonjs/contexts/dialogContext.js +32 -0
  209. package/lib-commonjs/contexts/dialogContext.js.map +1 -0
  210. package/lib-commonjs/contexts/dialogSurfaceContext.js +21 -0
  211. package/lib-commonjs/contexts/dialogSurfaceContext.js.map +1 -0
  212. package/lib-commonjs/contexts/index.js +14 -0
  213. package/lib-commonjs/contexts/index.js.map +1 -0
  214. package/lib-commonjs/index.js +193 -0
  215. package/lib-commonjs/index.js.map +1 -0
  216. package/lib-commonjs/utils/index.js +16 -0
  217. package/lib-commonjs/utils/index.js.map +1 -0
  218. package/lib-commonjs/utils/isEscapeKeyDown.js +22 -0
  219. package/lib-commonjs/utils/isEscapeKeyDown.js.map +1 -0
  220. package/lib-commonjs/utils/isTargetDisabled.js +23 -0
  221. package/lib-commonjs/utils/isTargetDisabled.js.map +1 -0
  222. package/lib-commonjs/utils/localShorthands.js +18 -0
  223. package/lib-commonjs/utils/localShorthands.js.map +1 -0
  224. package/lib-commonjs/utils/normalizeDefaultPrevented.js +20 -0
  225. package/lib-commonjs/utils/normalizeDefaultPrevented.js.map +1 -0
  226. package/package.json +69 -0
@@ -0,0 +1,406 @@
1
+ /// <reference types="react" />
2
+
3
+ import { ARIAButtonSlotProps } from '@fluentui/react-aria';
4
+ import type { ComponentProps } from '@fluentui/react-utilities';
5
+ import type { ComponentState } from '@fluentui/react-utilities';
6
+ import type { FluentTriggerComponent } from '@fluentui/react-utilities';
7
+ import type { ForwardRefComponent } from '@fluentui/react-utilities';
8
+ import { JSXElementConstructor } from 'react';
9
+ import * as React_2 from 'react';
10
+ import { ReactElement } from 'react';
11
+ import type { Slot } from '@fluentui/react-utilities';
12
+ import type { SlotClassNames } from '@fluentui/react-utilities';
13
+
14
+ /**
15
+ * The `Dialog` root level component serves as an interface for interaction with all possible behaviors exposed.
16
+ * It provides context down the hierarchy to `children` compound components to allow functionality.
17
+ * This component expects to receive as children either a `DialogSurface` or a `DialogTrigger`
18
+ * and a `DialogSurface` (or some component that will eventually render one of those compound components)
19
+ * in this specific order
20
+ */
21
+ export declare const Dialog: React_2.FC<DialogProps>;
22
+
23
+ /**
24
+ * `DialogActions` is a container for the actions of the dialog.
25
+ * Apart from styling, this component does not have other behavior.
26
+ */
27
+ export declare const DialogActions: ForwardRefComponent<DialogActionsProps>;
28
+
29
+ export declare const dialogActionsClassNames: SlotClassNames<DialogActionsSlots>;
30
+
31
+ export declare type DialogActionsPosition = 'start' | 'end';
32
+
33
+ /**
34
+ * DialogActions Props
35
+ */
36
+ export declare type DialogActionsProps = ComponentProps<DialogActionsSlots> & {
37
+ /**
38
+ * defines the position on the dialog grid of the actions
39
+ * @default 'end'
40
+ */
41
+ position?: DialogActionsPosition;
42
+ };
43
+
44
+ export declare type DialogActionsSlots = {
45
+ root: Slot<'div'>;
46
+ };
47
+
48
+ /**
49
+ * State used in rendering DialogActions
50
+ */
51
+ export declare type DialogActionsState = ComponentState<DialogActionsSlots> & {
52
+ position: DialogActionsPosition;
53
+ };
54
+
55
+ /**
56
+ * The `DialogBody` is a container where the content of the dialog is rendered.
57
+ * Apart from styling, this component does not have other behavior.
58
+ */
59
+ export declare const DialogBody: ForwardRefComponent<DialogBodyProps>;
60
+
61
+ export declare const dialogBodyClassNames: SlotClassNames<DialogBodySlots>;
62
+
63
+ /**
64
+ * DialogBody Props
65
+ */
66
+ export declare type DialogBodyProps = ComponentProps<DialogBodySlots> & {};
67
+
68
+ export declare type DialogBodySlots = {
69
+ root: Slot<'div'>;
70
+ };
71
+
72
+ /**
73
+ * State used in rendering DialogBody
74
+ */
75
+ export declare type DialogBodyState = ComponentState<DialogBodySlots>;
76
+
77
+ export declare const dialogClassNames: SlotClassNames<DialogSlots>;
78
+
79
+ declare type DialogContextValue = {
80
+ /**
81
+ * Reference to trigger element that opened the Dialog
82
+ * null if Dialog is closed
83
+ */
84
+ triggerRef: React_2.RefObject<HTMLElement>;
85
+ contentRef: React_2.RefObject<HTMLElement>;
86
+ modalType: DialogModalType;
87
+ dialogTitleID?: string;
88
+ dialogBodyID?: string;
89
+ open: boolean;
90
+ /**
91
+ * Requests dialog main component to update it's internal open state
92
+ */
93
+ requestOpenChange: (data: DialogOpenChangeData) => void;
94
+ };
95
+
96
+ declare type DialogContextValues = {
97
+ dialog: DialogContextValue;
98
+ /**
99
+ * dialogSurface context is provided by Dialog as false
100
+ * to ensure components inside Dialog but outside DialogSurface will consume this as false
101
+ */
102
+ dialogSurface: DialogSurfaceContextValue;
103
+ };
104
+
105
+ declare type DialogModalType = 'modal' | 'non-modal' | 'alert';
106
+
107
+ export declare type DialogOpenChangeData = {
108
+ type: 'escapeKeyDown';
109
+ open: boolean;
110
+ event: React_2.KeyboardEvent;
111
+ }
112
+ /**
113
+ * document escape keydown defers from internal escape keydown events because of the synthetic event API
114
+ */
115
+ | {
116
+ type: 'documentEscapeKeyDown';
117
+ open: boolean;
118
+ event: KeyboardEvent;
119
+ } | {
120
+ type: 'overlayClick';
121
+ open: boolean;
122
+ event: React_2.MouseEvent;
123
+ } | {
124
+ type: 'triggerClick';
125
+ open: boolean;
126
+ event: React_2.MouseEvent;
127
+ };
128
+
129
+ export declare type DialogOpenChangeEvent = React_2.KeyboardEvent | React_2.MouseEvent | KeyboardEvent;
130
+
131
+ export declare type DialogProps = ComponentProps<Partial<DialogSlots>> & {
132
+ /**
133
+ * Dialog variations.
134
+ *
135
+ * `modal`: When this type of dialog is open, the rest of the page is dimmed out and cannot be interacted with.
136
+ * The tab sequence is kept within the dialog and moving the focus outside
137
+ * the dialog will imply closing it. This is the default type of the component.
138
+ *
139
+ * `non-modal`: When a non-modal dialog is open, the rest of the page is not dimmed out
140
+ * and users can interact with the rest of the page.
141
+ * This also implies that the tab focus can move outside the dialog when it reaches the last focusable element.
142
+ *
143
+ * `alert`: is a special type of modal dialogs that interrupts the user's workflow
144
+ * to communicate an important message or ask for a decision.
145
+ * Unlike a typical modal dialog, the user must take an action through the options given to dismiss the dialog,
146
+ * and it cannot be dismissed through the dimmed background or escape key.
147
+ *
148
+ * @default modal
149
+ */
150
+ modalType?: DialogModalType;
151
+ /**
152
+ * Controls the open state of the dialog
153
+ * @default false
154
+ */
155
+ open?: boolean;
156
+ /**
157
+ * Default value for the uncontrolled open state of the dialog.
158
+ * @default false
159
+ */
160
+ defaultOpen?: boolean;
161
+ /**
162
+ * Callback fired when the component changes value from open state.
163
+ *
164
+ * @param event - a React's Synthetic event or a KeyboardEvent in case of `documentEscapeKeyDown`
165
+ * @param data - A data object with relevant information, such as open value and type
166
+ */
167
+ onOpenChange?: (event: DialogOpenChangeEvent, data: DialogOpenChangeData) => void;
168
+ /**
169
+ * Can contain two children including {@link DialogTrigger} and {@link DialogSurface}.
170
+ * Alternatively can only contain {@link DialogSurface} if using trigger outside dialog, or controlling state.
171
+ */
172
+ children: [JSX.Element, JSX.Element] | JSX.Element;
173
+ };
174
+
175
+ export declare type DialogSlots = {
176
+ /**
177
+ * Dimmed background of dialog.
178
+ * The default overlay is rendered as a `<div>` with styling.
179
+ * This slot expects a `<div>` element which will replace the default overlay.
180
+ * The overlay should have `aria-hidden="true"`.
181
+ */
182
+ overlay?: Slot<'div'>;
183
+ };
184
+
185
+ export declare type DialogState = ComponentState<DialogSlots> & DialogContextValue & {
186
+ content: React_2.ReactNode;
187
+ trigger: React_2.ReactNode;
188
+ };
189
+
190
+ /**
191
+ * DialogSurface component represents the visual part of a `Dialog` as a whole,
192
+ * it contains everything that should be visible.
193
+ */
194
+ export declare const DialogSurface: ForwardRefComponent<DialogSurfaceProps>;
195
+
196
+ export declare const dialogSurfaceClassNames: SlotClassNames<DialogSurfaceSlots>;
197
+
198
+ declare type DialogSurfaceContextValue = boolean;
199
+
200
+ declare type DialogSurfaceContextValues = {
201
+ dialogSurface: DialogSurfaceContextValue;
202
+ };
203
+
204
+ /**
205
+ * DialogSurface Props
206
+ */
207
+ export declare type DialogSurfaceProps = ComponentProps<DialogSurfaceSlots> & {};
208
+
209
+ export declare type DialogSurfaceSlots = {
210
+ root: Slot<'div', 'main'>;
211
+ };
212
+
213
+ /**
214
+ * State used in rendering DialogSurface
215
+ */
216
+ export declare type DialogSurfaceState = ComponentState<DialogSurfaceSlots>;
217
+
218
+ /**
219
+ * The `DialogTitle` component will expect to have a dialog title/header
220
+ * and will show the close (X icon) button if specified so.
221
+ * Apart from styling and presenting `closeButton`, this component does not have other behavior.
222
+ */
223
+ export declare const DialogTitle: ForwardRefComponent<DialogTitleProps>;
224
+
225
+ export declare const dialogTitleClassNames: SlotClassNames<DialogTitleSlots>;
226
+
227
+ /**
228
+ * DialogTitle Props
229
+ */
230
+ export declare type DialogTitleProps = ComponentProps<DialogTitleSlots> & {};
231
+
232
+ export declare type DialogTitleSlots = {
233
+ /**
234
+ * By default this is a div, but can be a heading.
235
+ */
236
+ root: Slot<'div', 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'>;
237
+ closeButton?: Slot<ARIAButtonSlotProps>;
238
+ };
239
+
240
+ /**
241
+ * State used in rendering DialogTitle
242
+ */
243
+ export declare type DialogTitleState = ComponentState<DialogTitleSlots>;
244
+
245
+ /**
246
+ * A non-visual component that wraps its child
247
+ * and configures them to be the trigger that will open or close a `Dialog`.
248
+ * This component should only accept one child.
249
+ *
250
+ * In case the trigger is used outside `Dialog` component
251
+ * it'll still provide basic ARIA related attributes
252
+ * to it's wrapped child, but it won't be able to alter the dialog `open` state anymore,
253
+ * in that case the user must provide a `controlled state`
254
+ */
255
+ export declare const DialogTrigger: React_2.FC<DialogTriggerProps> & FluentTriggerComponent;
256
+
257
+ export declare type DialogTriggerAction = 'open' | 'close';
258
+
259
+ /**
260
+ * Props that are passed to the child of the DialogTrigger when cloned to ensure correct behaviour for the Dialog
261
+ */
262
+ export declare type DialogTriggerChildProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'onClick' | 'onKeyDown' | 'aria-haspopup'> & {
263
+ ref?: React_2.Ref<never>;
264
+ };
265
+
266
+ export declare type DialogTriggerProps = {
267
+ /**
268
+ * Explicitly declare if the trigger is responsible for opening or
269
+ * closing a Dialog visibility state.
270
+ * @default 'open' // if it's outside DialogSurface
271
+ * @default 'close' // if it's inside DialogSurface
272
+ */
273
+ action?: DialogTriggerAction;
274
+ /**
275
+ * Explicitly require single child or render function
276
+ * to inject properties
277
+ */
278
+ children: (React_2.ReactElement & {
279
+ ref?: React_2.Ref<unknown>;
280
+ }) | ((props: DialogTriggerChildProps) => React_2.ReactElement | null);
281
+ };
282
+
283
+ export declare type DialogTriggerState = {
284
+ children: React_2.ReactElement | null;
285
+ };
286
+
287
+ /**
288
+ * Render the final JSX of Dialog
289
+ */
290
+ export declare const renderDialog_unstable: (state: DialogState, contextValues: DialogContextValues) => JSX.Element;
291
+
292
+ /**
293
+ * Render the final JSX of DialogActions
294
+ */
295
+ export declare const renderDialogActions_unstable: (state: DialogActionsState) => JSX.Element;
296
+
297
+ /**
298
+ * Render the final JSX of DialogBody
299
+ */
300
+ export declare const renderDialogBody_unstable: (state: DialogBodyState) => JSX.Element;
301
+
302
+ /**
303
+ * Render the final JSX of DialogSurface
304
+ */
305
+ export declare const renderDialogSurface_unstable: (state: DialogSurfaceState, contextValues: DialogSurfaceContextValues) => JSX.Element;
306
+
307
+ /**
308
+ * Render the final JSX of DialogTitle
309
+ */
310
+ export declare const renderDialogTitle_unstable: (state: DialogTitleState) => JSX.Element;
311
+
312
+ /**
313
+ * Render the final JSX of MenuTrigger
314
+ *
315
+ * Only renders children
316
+ */
317
+ export declare const renderDialogTrigger_unstable: (state: DialogTriggerState) => ReactElement<any, string | JSXElementConstructor<any>> | null;
318
+
319
+ /**
320
+ * Create the state required to render Dialog.
321
+ *
322
+ * The returned state can be modified with hooks such as useDialogStyles_unstable,
323
+ * before being passed to renderDialog_unstable.
324
+ *
325
+ * @param props - props from this instance of Dialog
326
+ */
327
+ export declare const useDialog_unstable: (props: DialogProps) => DialogState;
328
+
329
+ /**
330
+ * Create the state required to render DialogActions.
331
+ *
332
+ * The returned state can be modified with hooks such as useDialogActionsStyles_unstable,
333
+ * before being passed to renderDialogActions_unstable.
334
+ *
335
+ * @param props - props from this instance of DialogActions
336
+ * @param ref - reference to root HTMLElement of DialogActions
337
+ */
338
+ export declare const useDialogActions_unstable: (props: DialogActionsProps, ref: React_2.Ref<HTMLElement>) => DialogActionsState;
339
+
340
+ /**
341
+ * Apply styling to the DialogActions slots based on the state
342
+ */
343
+ export declare const useDialogActionsStyles_unstable: (state: DialogActionsState) => DialogActionsState;
344
+
345
+ /**
346
+ * Create the state required to render DialogBody.
347
+ *
348
+ * The returned state can be modified with hooks such as useDialogBodyStyles_unstable,
349
+ * before being passed to renderDialogBody_unstable.
350
+ *
351
+ * @param props - props from this instance of DialogBody
352
+ * @param ref - reference to root HTMLElement of DialogBody
353
+ */
354
+ export declare const useDialogBody_unstable: (props: DialogBodyProps, ref: React_2.Ref<HTMLElement>) => DialogBodyState;
355
+
356
+ /**
357
+ * Apply styling to the DialogBody slots based on the state
358
+ */
359
+ export declare const useDialogBodyStyles_unstable: (state: DialogBodyState) => DialogBodyState;
360
+
361
+ /**
362
+ * Apply styling to the Dialog slots based on the state
363
+ */
364
+ export declare const useDialogStyles_unstable: (state: DialogState) => DialogState;
365
+
366
+ /**
367
+ * Create the state required to render DialogSurface.
368
+ *
369
+ * The returned state can be modified with hooks such as useDialogSurfaceStyles_unstable,
370
+ * before being passed to renderDialogSurface_unstable.
371
+ *
372
+ * @param props - props from this instance of DialogSurface
373
+ * @param ref - reference to root HTMLElement of DialogSurface
374
+ */
375
+ export declare const useDialogSurface_unstable: (props: DialogSurfaceProps, ref: React_2.Ref<HTMLElement>) => DialogSurfaceState;
376
+
377
+ /**
378
+ * Apply styling to the DialogSurface slots based on the state
379
+ */
380
+ export declare const useDialogSurfaceStyles_unstable: (state: DialogSurfaceState) => DialogSurfaceState;
381
+
382
+ /**
383
+ * Create the state required to render DialogTitle.
384
+ *
385
+ * The returned state can be modified with hooks such as useDialogTitleStyles_unstable,
386
+ * before being passed to renderDialogTitle_unstable.
387
+ *
388
+ * @param props - props from this instance of DialogTitle
389
+ * @param ref - reference to root HTMLElement of DialogTitle
390
+ */
391
+ export declare const useDialogTitle_unstable: (props: DialogTitleProps, ref: React_2.Ref<HTMLElement>) => DialogTitleState;
392
+
393
+ /**
394
+ * Apply styling to the DialogTitle slots based on the state
395
+ */
396
+ export declare const useDialogTitleStyles_unstable: (state: DialogTitleState) => DialogTitleState;
397
+
398
+ /**
399
+ * Create the state required to render DialogTrigger.
400
+ * Clones the only child component and adds necessary event handling behaviours to open a popup Dialog
401
+ *
402
+ * @param props - props from this instance of DialogTrigger
403
+ */
404
+ export declare const useDialogTrigger_unstable: (props: DialogTriggerProps) => DialogTriggerState;
405
+
406
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.18.1"
9
+ }
10
+ ]
11
+ }
package/lib/Dialog.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './components/Dialog/index';
2
+ //# sourceMappingURL=Dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dialog.js","sourceRoot":"../src/","sources":["Dialog.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC","sourcesContent":["export * from './components/Dialog/index';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './components/DialogActions/index';
2
+ //# sourceMappingURL=DialogActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogActions.js","sourceRoot":"../src/","sources":["DialogActions.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC","sourcesContent":["export * from './components/DialogActions/index';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './components/DialogBody/index';
2
+ //# sourceMappingURL=DialogBody.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogBody.js","sourceRoot":"../src/","sources":["DialogBody.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC","sourcesContent":["export * from './components/DialogBody/index';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './components/DialogSurface/index';
2
+ //# sourceMappingURL=DialogSurface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogSurface.js","sourceRoot":"../src/","sources":["DialogSurface.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC","sourcesContent":["export * from './components/DialogSurface/index';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './components/DialogTitle/index';
2
+ //# sourceMappingURL=DialogTitle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogTitle.js","sourceRoot":"../src/","sources":["DialogTitle.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC","sourcesContent":["export * from './components/DialogTitle/index';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './components/DialogTrigger/index';
2
+ //# sourceMappingURL=DialogTrigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogTrigger.js","sourceRoot":"../src/","sources":["DialogTrigger.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC","sourcesContent":["export * from './components/DialogTrigger/index';\n"]}
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { useDialog_unstable } from './useDialog';
3
+ import { renderDialog_unstable } from './renderDialog';
4
+ import { useDialogStyles_unstable } from './useDialogStyles';
5
+ import { useDialogContextValues_unstable } from './useDialogContextValues';
6
+ /**
7
+ * The `Dialog` root level component serves as an interface for interaction with all possible behaviors exposed.
8
+ * It provides context down the hierarchy to `children` compound components to allow functionality.
9
+ * This component expects to receive as children either a `DialogSurface` or a `DialogTrigger`
10
+ * and a `DialogSurface` (or some component that will eventually render one of those compound components)
11
+ * in this specific order
12
+ */
13
+
14
+ export const Dialog = /*#__PURE__*/React.memo(props => {
15
+ const state = useDialog_unstable(props);
16
+ const contextValues = useDialogContextValues_unstable(state);
17
+ useDialogStyles_unstable(state);
18
+ return renderDialog_unstable(state, contextValues);
19
+ });
20
+ Dialog.displayName = 'Dialog';
21
+ //# sourceMappingURL=Dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,kBAAT,QAAmC,aAAnC;AACA,SAAS,qBAAT,QAAsC,gBAAtC;AACA,SAAS,wBAAT,QAAyC,mBAAzC;AAEA,SAAS,+BAAT,QAAgD,0BAAhD;AAEA;;;;;;AAMG;;AACH,OAAO,MAAM,MAAM,gBAA0B,KAAK,CAAC,IAAN,CAAW,KAAK,IAAG;EAC9D,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAD,CAAhC;EACA,MAAM,aAAa,GAAG,+BAA+B,CAAC,KAAD,CAArD;EAEA,wBAAwB,CAAC,KAAD,CAAxB;EACA,OAAO,qBAAqB,CAAC,KAAD,EAAQ,aAAR,CAA5B;AACD,CAN4C,CAAtC;AAQP,MAAM,CAAC,WAAP,GAAqB,QAArB","sourcesContent":["import * as React from 'react';\nimport { useDialog_unstable } from './useDialog';\nimport { renderDialog_unstable } from './renderDialog';\nimport { useDialogStyles_unstable } from './useDialogStyles';\nimport type { DialogProps } from './Dialog.types';\nimport { useDialogContextValues_unstable } from './useDialogContextValues';\n\n/**\n * The `Dialog` root level component serves as an interface for interaction with all possible behaviors exposed.\n * It provides context down the hierarchy to `children` compound components to allow functionality.\n * This component expects to receive as children either a `DialogSurface` or a `DialogTrigger`\n * and a `DialogSurface` (or some component that will eventually render one of those compound components)\n * in this specific order\n */\nexport const Dialog: React.FC<DialogProps> = React.memo(props => {\n const state = useDialog_unstable(props);\n const contextValues = useDialogContextValues_unstable(state);\n\n useDialogStyles_unstable(state);\n return renderDialog_unstable(state, contextValues);\n});\n\nDialog.displayName = 'Dialog';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Dialog.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dialog.types.js","sourceRoot":"../src/","sources":["components/Dialog/Dialog.types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { DialogContextValue, DialogSurfaceContextValue } from '../../contexts';\n\nexport type DialogSlots = {\n /**\n * Dimmed background of dialog.\n * The default overlay is rendered as a `<div>` with styling.\n * This slot expects a `<div>` element which will replace the default overlay.\n * The overlay should have `aria-hidden=\"true\"`.\n */\n overlay?: Slot<'div'>;\n};\n\nexport type DialogOpenChangeEvent = React.KeyboardEvent | React.MouseEvent | KeyboardEvent;\n\nexport type DialogOpenChangeData =\n | { type: 'escapeKeyDown'; open: boolean; event: React.KeyboardEvent }\n /**\n * document escape keydown defers from internal escape keydown events because of the synthetic event API\n */\n | { type: 'documentEscapeKeyDown'; open: boolean; event: KeyboardEvent }\n | { type: 'overlayClick'; open: boolean; event: React.MouseEvent }\n | { type: 'triggerClick'; open: boolean; event: React.MouseEvent };\n\nexport type DialogModalType = 'modal' | 'non-modal' | 'alert';\n\nexport type DialogContextValues = {\n dialog: DialogContextValue;\n /**\n * dialogSurface context is provided by Dialog as false\n * to ensure components inside Dialog but outside DialogSurface will consume this as false\n */\n dialogSurface: DialogSurfaceContextValue;\n};\n\nexport type DialogProps = ComponentProps<Partial<DialogSlots>> & {\n /**\n * Dialog variations.\n *\n * `modal`: When this type of dialog is open, the rest of the page is dimmed out and cannot be interacted with.\n * The tab sequence is kept within the dialog and moving the focus outside\n * the dialog will imply closing it. This is the default type of the component.\n *\n * `non-modal`: When a non-modal dialog is open, the rest of the page is not dimmed out\n * and users can interact with the rest of the page.\n * This also implies that the tab focus can move outside the dialog when it reaches the last focusable element.\n *\n * `alert`: is a special type of modal dialogs that interrupts the user's workflow\n * to communicate an important message or ask for a decision.\n * Unlike a typical modal dialog, the user must take an action through the options given to dismiss the dialog,\n * and it cannot be dismissed through the dimmed background or escape key.\n *\n * @default modal\n */\n modalType?: DialogModalType;\n /**\n * Controls the open state of the dialog\n * @default false\n */\n open?: boolean;\n /**\n * Default value for the uncontrolled open state of the dialog.\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Callback fired when the component changes value from open state.\n *\n * @param event - a React's Synthetic event or a KeyboardEvent in case of `documentEscapeKeyDown`\n * @param data - A data object with relevant information, such as open value and type\n */\n onOpenChange?: (event: DialogOpenChangeEvent, data: DialogOpenChangeData) => void;\n /**\n * Can contain two children including {@link DialogTrigger} and {@link DialogSurface}.\n * Alternatively can only contain {@link DialogSurface} if using trigger outside dialog, or controlling state.\n */\n children: [JSX.Element, JSX.Element] | JSX.Element;\n};\n\nexport type DialogState = ComponentState<DialogSlots> &\n DialogContextValue & {\n content: React.ReactNode;\n trigger: React.ReactNode;\n };\n"]}
@@ -0,0 +1,6 @@
1
+ export * from './Dialog';
2
+ export * from './Dialog.types';
3
+ export * from './renderDialog';
4
+ export * from './useDialog';
5
+ export * from './useDialogStyles';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Dialog/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC","sourcesContent":["export * from './Dialog';\nexport * from './Dialog.types';\nexport * from './renderDialog';\nexport * from './useDialog';\nexport * from './useDialogStyles';\n"]}
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { getSlots } from '@fluentui/react-utilities';
3
+ import { Portal } from '@fluentui/react-portal';
4
+ import { DialogProvider, DialogSurfaceProvider } from '../../contexts';
5
+ /**
6
+ * Render the final JSX of Dialog
7
+ */
8
+
9
+ export const renderDialog_unstable = (state, contextValues) => {
10
+ const {
11
+ content,
12
+ trigger,
13
+ open
14
+ } = state;
15
+ const {
16
+ slots,
17
+ slotProps
18
+ } = getSlots(state);
19
+ return /*#__PURE__*/React.createElement(DialogProvider, {
20
+ value: contextValues.dialog
21
+ }, /*#__PURE__*/React.createElement(DialogSurfaceProvider, {
22
+ value: contextValues.dialogSurface
23
+ }, trigger, open && /*#__PURE__*/React.createElement(Portal, null, slots.overlay && /*#__PURE__*/React.createElement(slots.overlay, { ...slotProps.overlay
24
+ }), content)));
25
+ };
26
+ //# sourceMappingURL=renderDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Dialog/renderDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AACA,SAAS,MAAT,QAAuB,wBAAvB;AACA,SAAS,cAAT,EAAyB,qBAAzB,QAAsD,gBAAtD;AAGA;;AAEG;;AACH,OAAO,MAAM,qBAAqB,GAAG,CAAC,KAAD,EAAqB,aAArB,KAA2D;EAC9F,MAAM;IAAE,OAAF;IAAW,OAAX;IAAoB;EAApB,IAA6B,KAAnC;EACA,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,QAAQ,CAAc,KAAd,CAArC;EAEA,oBACE,KAAA,CAAA,aAAA,CAAC,cAAD,EAAe;IAAC,KAAK,EAAE,aAAa,CAAC;EAAtB,CAAf,eACE,KAAA,CAAA,aAAA,CAAC,qBAAD,EAAsB;IAAC,KAAK,EAAE,aAAa,CAAC;EAAtB,CAAtB,EACG,OADH,EAEG,IAAI,iBACH,KAAA,CAAA,aAAA,CAAC,MAAD,EAAO,IAAP,EACG,KAAK,CAAC,OAAN,iBAAiB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAK,SAAS,CAAC;EAAf,CAAd,CADpB,EAEG,OAFH,CAHJ,CADF,CADF;AAaD,CAjBM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { Portal } from '@fluentui/react-portal';\nimport { DialogProvider, DialogSurfaceProvider } from '../../contexts';\nimport type { DialogState, DialogSlots, DialogContextValues } from './Dialog.types';\n\n/**\n * Render the final JSX of Dialog\n */\nexport const renderDialog_unstable = (state: DialogState, contextValues: DialogContextValues) => {\n const { content, trigger, open } = state;\n const { slots, slotProps } = getSlots<DialogSlots>(state);\n\n return (\n <DialogProvider value={contextValues.dialog}>\n <DialogSurfaceProvider value={contextValues.dialogSurface}>\n {trigger}\n {open && (\n <Portal>\n {slots.overlay && <slots.overlay {...slotProps.overlay} />}\n {content}\n </Portal>\n )}\n </DialogSurfaceProvider>\n </DialogProvider>\n );\n};\n"],"sourceRoot":"../src/"}