@@ -8,16 +8,23 @@ import {VirtualizerScrollInstanceProvider} from '../inputs/arrays/ArrayOfObjects
8
8
9
9
const PRESENCE_MARGINS : [ number , number , number , number ] = [ 0 , 0 , 1 , 0 ]
10
10
11
- interface Props {
12
- type : 'popover' | 'dialog'
13
- width : ResponsiveWidthProps [ 'width' ]
11
+ interface SharedProps {
12
+ children ?: ReactNode
14
13
header : string
14
+ width : ResponsiveWidthProps [ 'width' ]
15
+ }
16
+ interface DialogProps extends SharedProps {
17
+ type : 'dialog'
15
18
id ?: string
16
- onClose : ( ) => void
17
- children ?: ReactNode
19
+ autofocus ?: boolean
20
+ onClose ?: ( ) => void
21
+ }
22
+
23
+ interface PopoverProps extends SharedProps {
24
+ type : 'popover'
18
25
// eslint-disable-next-line camelcase
19
26
legacy_referenceElement : HTMLElement | null
20
- autofocus ?: boolean
27
+ onClose : ( ) => void
21
28
}
22
29
23
30
function onDragEnter ( event : DragEvent < HTMLDivElement > ) {
@@ -28,17 +35,13 @@ function onDrop(event: DragEvent<HTMLDivElement>) {
28
35
return event . stopPropagation ( )
29
36
}
30
37
31
- export function EditPortal ( props : Props ) : React . JSX . Element {
32
- const {
33
- children,
34
- header,
35
- id,
36
- legacy_referenceElement : referenceElement ,
37
- onClose,
38
- type,
39
- width,
40
- autofocus,
41
- } = props
38
+ /**
39
+ * @internal
40
+ * Creates a dialog or a popover for editing content.
41
+ * Handles presence and virtual scrolling.
42
+ */
43
+ export function EditPortal ( props : PopoverProps | DialogProps ) : React . JSX . Element {
44
+ const { children, header, onClose, type, width} = props
42
45
const [ documentScrollElement , setDocumentScrollElement ] = useState < HTMLDivElement | null > ( null )
43
46
const containerElement = useRef < HTMLDivElement | null > ( null )
44
47
@@ -55,11 +58,11 @@ export function EditPortal(props: Props): React.JSX.Element {
55
58
containerElement = { containerElement }
56
59
>
57
60
< Dialog
58
- __unstable_autoFocus = { autofocus }
61
+ __unstable_autoFocus = { props . autofocus }
59
62
contentRef = { setDocumentScrollElement }
60
63
data-testid = "edit-portal-dialog"
61
64
header = { header }
62
- id = { id || '' }
65
+ id = { props . id || '' }
63
66
onClickOutside = { onClose }
64
67
onClose = { onClose }
65
68
onDragEnter = { onDragEnter }
@@ -76,7 +79,7 @@ export function EditPortal(props: Props): React.JSX.Element {
76
79
< PopoverDialog
77
80
header = { header }
78
81
onClose = { onClose }
79
- referenceElement = { referenceElement }
82
+ referenceElement = { props . legacy_referenceElement }
80
83
width = { width }
81
84
containerRef = { setDocumentScrollElement }
82
85
>
0 commit comments