dry-ux 1.57.0 → 1.59.0
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/ui-utils/Modal.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface IModalProps {
|
|
|
11
11
|
defaultModalStyles?: boolean;
|
|
12
12
|
setBackdropHeight?: boolean;
|
|
13
13
|
centered?: boolean;
|
|
14
|
+
onOpen?: (modal: Pick<PopUpOptions, "title" | "trackingId">) => void;
|
|
15
|
+
onClose?: (modal: Pick<PopUpOptions, "title" | "trackingId">) => void;
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
18
|
declare const Modal: React.FC<IModalProps & {
|
package/dist/ui-utils/Modal.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const react_bootstrap_1 = require("react-bootstrap");
|
|
5
|
-
const Modal = React.memo(({ handleClose, shown, options: { content, footerContent, cssClass, closeBtn, title, width, onClose, titleCloseBtn = true, centered }, config: { defaultModalStyles = false, styles = {}, setBackdropHeight = true, centered: globalCentered }, }) => {
|
|
5
|
+
const Modal = React.memo(({ handleClose, shown, options: { content, footerContent, cssClass, closeBtn, title, width, onClose, titleCloseBtn = true, centered, trackingId, }, config: { defaultModalStyles = false, styles = {}, setBackdropHeight = true, centered: globalCentered, onOpen, onClose: globalOnClose, }, }) => {
|
|
6
6
|
const isCentered = centered !== null && centered !== void 0 ? centered : globalCentered;
|
|
7
7
|
const applyStyles = React.useCallback(() => {
|
|
8
8
|
document.querySelectorAll(".modal-dialog").forEach((el) => {
|
|
@@ -38,6 +38,10 @@ const Modal = React.memo(({ handleClose, shown, options: { content, footerConten
|
|
|
38
38
|
React.useEffect(() => {
|
|
39
39
|
if (shown) {
|
|
40
40
|
applyStyles();
|
|
41
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen({ title, trackingId });
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
globalOnClose === null || globalOnClose === void 0 ? void 0 : globalOnClose({ title, trackingId });
|
|
41
45
|
}
|
|
42
46
|
}, [shown, width, defaultModalStyles]);
|
|
43
47
|
const onHide = () => {
|
|
@@ -53,6 +53,10 @@ export type PopUpOptions = {
|
|
|
53
53
|
* If true, the modal will be centered vertically.
|
|
54
54
|
*/
|
|
55
55
|
centered?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The tracking ID for the modal.
|
|
58
|
+
*/
|
|
59
|
+
trackingId?: string;
|
|
56
60
|
};
|
|
57
61
|
export type ButtonType = "primary" | "secondary" | "info" | "success" | "warning" | "danger";
|
|
58
62
|
export type PopUpAction = {
|
|
@@ -79,6 +79,7 @@ class UIUtilProvider extends React.PureComponent {
|
|
|
79
79
|
} });
|
|
80
80
|
}
|
|
81
81
|
toggleModalInstance(id, shown, destroyOnClose = false) {
|
|
82
|
+
var _a, _b;
|
|
82
83
|
const { modal: { instances }, } = this.state;
|
|
83
84
|
const instance = instances[id];
|
|
84
85
|
if (!instance) {
|
|
@@ -86,6 +87,9 @@ class UIUtilProvider extends React.PureComponent {
|
|
|
86
87
|
}
|
|
87
88
|
// Hide all other instances
|
|
88
89
|
Object.keys(instances).forEach(id => (instances[id].shown = false));
|
|
90
|
+
if (!shown) {
|
|
91
|
+
(_b = (_a = instance.options).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
92
|
+
}
|
|
89
93
|
if (!shown && destroyOnClose && instance.options.destroyOnClose) {
|
|
90
94
|
this.removeModalInstance(id);
|
|
91
95
|
}
|
|
@@ -97,7 +101,10 @@ class UIUtilProvider extends React.PureComponent {
|
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
removeModalInstance(id) {
|
|
104
|
+
var _a, _b;
|
|
100
105
|
const { modal: { instances }, } = this.state;
|
|
106
|
+
const instance = instances[id];
|
|
107
|
+
(_b = (_a = instance.options).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
101
108
|
delete instances[id];
|
|
102
109
|
this.setState({
|
|
103
110
|
modal: Object.assign(Object.assign({}, this.state.modal), { instances }),
|