feat(ui): Add support for Custom Modal component in Modal Service (#4752)

This commit is contained in:
Abhijith Sb authored and GitHub committed 2025-02-04 08:51:23 -05:00
1 parent 8788dae6a4
commit 2c183aa4a7
4 files changed
+33 -4

No files matched your search

@@ -16,6 +16,7 @@ const name = 'uiModalService';
const serviceImplementation = {
_hide: () => console.warn('hide() NOT IMPLEMENTED'),
_show: () => console.warn('show() NOT IMPLEMENTED'),
_customComponent: null,
};
class UIModalService {
@@ -45,6 +46,8 @@ class UIModalService {
movable = false,
containerDimensions = null,
contentDimensions = null,
shouldCloseOnOverlayClick = true,
shouldCloseImmediately = false,
}) {
return serviceImplementation._show({
content,
@@ -57,6 +60,8 @@ class UIModalService {
movable,
containerDimensions,
contentDimensions,
shouldCloseOnOverlayClick,
shouldCloseImmediately,
});
}
@@ -69,6 +74,15 @@ class UIModalService {
return serviceImplementation._hide();
}
/**
* This provides flexibility in customizing the Modal's default component
*
* @returns {React.Component}
*/
getCustomComponent() {
return serviceImplementation._customComponent;
}
/**
*
*
@@ -77,13 +91,20 @@ class UIModalService {
* show: showImplementation,
* }
*/
setServiceImplementation({ hide: hideImplementation, show: showImplementation }) {
setServiceImplementation({
hide: hideImplementation,
show: showImplementation,
customComponent: customComponentImplementation,
}) {
if (hideImplementation) {
serviceImplementation._hide = hideImplementation;
}
if (showImplementation) {
serviceImplementation._show = showImplementation;
}
if (customComponentImplementation) {
serviceImplementation._customComponent = customComponentImplementation;
}
}
}