@ultraviolet/ui 1.15.0 → 1.15.1
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/dist/index.d.ts
CHANGED
|
@@ -1503,7 +1503,7 @@ type ModalProps = {
|
|
|
1503
1503
|
hideOnClickOutside?: boolean;
|
|
1504
1504
|
preventBodyScroll?: boolean;
|
|
1505
1505
|
ariaLabel?: string;
|
|
1506
|
-
disclosure?:
|
|
1506
|
+
disclosure?: ReactElement | ((state: ModalState) => ReactElement);
|
|
1507
1507
|
isClosable?: boolean;
|
|
1508
1508
|
onClose?: () => void;
|
|
1509
1509
|
onBeforeClose?: () => Promise<void> | void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, isValidElement, cloneElement, createRef } from 'react';
|
|
1
|
+
import { useEffect, useMemo, isValidElement, cloneElement, createRef } from 'react';
|
|
2
2
|
|
|
3
3
|
const Disclosure = _ref => {
|
|
4
4
|
let {
|
|
@@ -17,25 +17,27 @@ const Disclosure = _ref => {
|
|
|
17
17
|
element?.removeEventListener('click', handleOpen);
|
|
18
18
|
};
|
|
19
19
|
}, [handleOpen, disclosureRef]);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const finalDisclosure = useMemo(() => {
|
|
21
|
+
if (typeof disclosure === 'function') {
|
|
22
|
+
return disclosure({
|
|
23
|
+
visible,
|
|
24
|
+
onClose: handleClose,
|
|
25
|
+
toggle,
|
|
26
|
+
onOpen: handleOpen,
|
|
27
|
+
modalId: id,
|
|
28
|
+
hide: handleClose
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return disclosure;
|
|
32
|
+
}, [disclosure, handleOpen, handleClose, id, toggle, visible]);
|
|
33
|
+
if (! /*#__PURE__*/isValidElement(finalDisclosure)) {
|
|
34
|
+
return null;
|
|
29
35
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'aria-haspopup': 'dialog'
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
36
|
+
return /*#__PURE__*/cloneElement(finalDisclosure, {
|
|
37
|
+
ref: disclosureRef,
|
|
38
|
+
'aria-controls': id,
|
|
39
|
+
'aria-haspopup': 'dialog'
|
|
40
|
+
});
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
export { Disclosure };
|