dry-ux 1.88.0 → 1.89.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/styles/modal.css
CHANGED
|
@@ -72,6 +72,35 @@
|
|
|
72
72
|
cursor: move;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
.dry-ux-modal .modal-header .dry-ux-modal-header-right {
|
|
76
|
+
float: right;
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
gap: 4px;
|
|
80
|
+
margin-top: -2px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.dry-ux-modal .modal-header .dry-ux-modal-header-right .close {
|
|
84
|
+
float: none;
|
|
85
|
+
margin-top: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.dry-ux-modal .modal-header .dry-ux-modal-header-action {
|
|
89
|
+
background: none;
|
|
90
|
+
border: none;
|
|
91
|
+
padding: 0 3px;
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
line-height: 1;
|
|
94
|
+
color: inherit;
|
|
95
|
+
opacity: 0.4;
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.dry-ux-modal .modal-header .dry-ux-modal-header-action:hover {
|
|
101
|
+
opacity: 1;
|
|
102
|
+
}
|
|
103
|
+
|
|
75
104
|
.dry-ux-modal-backdrop {
|
|
76
105
|
position: fixed!important;
|
|
77
106
|
top: 0!important;
|
package/dist/ui-utils/Modal.js
CHANGED
|
@@ -12,7 +12,7 @@ const useDraggable_1 = require("./useDraggable");
|
|
|
12
12
|
* @param {ModalProps} props - The props for the Modal component.
|
|
13
13
|
* @returns {JSX.Element} The Modal component.
|
|
14
14
|
*/
|
|
15
|
-
const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, key: instanceKey, options: { content, footerContent, cssClass = "", closeBtn, title, width, onClose, titleCloseBtn = true, centered, trackingId, draggable, actions = [], }, }, config: { defaultModalStyles = false, styles = {}, centered: globalCentered, draggable: globalDraggable, onOpen, onClose: globalOnClose, }, providerId, debug, }) => {
|
|
15
|
+
const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, key: instanceKey, options: { content, footerContent, cssClass = "", closeBtn, title, width, onClose, titleCloseBtn = true, centered, trackingId, draggable, actions = [], headerActions = [], }, }, config: { defaultModalStyles = false, styles = {}, centered: globalCentered, draggable: globalDraggable, onOpen, onClose: globalOnClose, }, providerId, debug, }) => {
|
|
16
16
|
const isCentered = centered !== null && centered !== void 0 ? centered : globalCentered;
|
|
17
17
|
const isDraggable = !!(draggable !== null && draggable !== void 0 ? draggable : globalDraggable) && !!title;
|
|
18
18
|
const draggableClass = isDraggable ? `dry-ux-draggable-${id}` : "";
|
|
@@ -78,8 +78,15 @@ const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, key
|
|
|
78
78
|
return (React.createElement(react_bootstrap_1.Modal, { onHide: onHide, show: shown, animation: true, autoFocus: true, keyboard: false, className: modalCssClass, backdropClassName: "dry-ux-modal-backdrop", backdrop: "static" },
|
|
79
79
|
overlay && (React.createElement("div", { className: "dry-ux-overlay" },
|
|
80
80
|
React.createElement("div", { className: "dry-ux-overlay-content" }, overlay))),
|
|
81
|
-
!!title && (React.createElement(react_bootstrap_1.Modal.Header, { closeButton: titleCloseBtn, onHide: onHide },
|
|
82
|
-
React.createElement(
|
|
81
|
+
(!!title || !!(headerActions === null || headerActions === void 0 ? void 0 : headerActions.length)) && (React.createElement(react_bootstrap_1.Modal.Header, { closeButton: !(headerActions === null || headerActions === void 0 ? void 0 : headerActions.length) && titleCloseBtn, onHide: onHide },
|
|
82
|
+
!!(headerActions === null || headerActions === void 0 ? void 0 : headerActions.length) && (React.createElement("div", { className: "dry-ux-modal-header-right" },
|
|
83
|
+
headerActions.map(({ content: actionContent, onClick, title: actionTitle, className = "" }, index) => (React.createElement("button", { key: index, className: (0, classSet_1.classSet)({
|
|
84
|
+
"dry-ux-modal-header-action": true,
|
|
85
|
+
[className]: !!className,
|
|
86
|
+
}), onClick: onClick, title: actionTitle, type: "button" }, actionContent))),
|
|
87
|
+
titleCloseBtn && (React.createElement("button", { type: "button", className: "close", onClick: onHide },
|
|
88
|
+
React.createElement("span", { "aria-hidden": "true" }, "\u00D7"))))),
|
|
89
|
+
!!title && React.createElement(react_bootstrap_1.Modal.Title, null, title))),
|
|
83
90
|
React.createElement(react_bootstrap_1.Modal.Body, null, contentToRender),
|
|
84
91
|
showFooter && (React.createElement(react_bootstrap_1.Modal.Footer, null,
|
|
85
92
|
footerContent,
|
|
@@ -91,6 +91,27 @@ export type PopUpInstance = {
|
|
|
91
91
|
*/
|
|
92
92
|
toggleOverlay: (id: string, content?: Content) => void;
|
|
93
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
* Represents an action displayed in the modal header (next to the close button).
|
|
96
|
+
*/
|
|
97
|
+
export type PopUpHeaderAction = {
|
|
98
|
+
/**
|
|
99
|
+
* The content to display in the header action button.
|
|
100
|
+
*/
|
|
101
|
+
content: Content;
|
|
102
|
+
/**
|
|
103
|
+
* Function to call when the header action is clicked.
|
|
104
|
+
*/
|
|
105
|
+
onClick?: () => void;
|
|
106
|
+
/**
|
|
107
|
+
* Tooltip text for the header action button.
|
|
108
|
+
*/
|
|
109
|
+
title?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Additional CSS class for the header action button.
|
|
112
|
+
*/
|
|
113
|
+
className?: string;
|
|
114
|
+
};
|
|
94
115
|
/**
|
|
95
116
|
* Represents an action for a PopUp.
|
|
96
117
|
*/
|
|
@@ -172,6 +193,10 @@ export type PopUpOptions = {
|
|
|
172
193
|
* If true, the modal will be shown.
|
|
173
194
|
*/
|
|
174
195
|
actions?: PopUpAction[];
|
|
196
|
+
/**
|
|
197
|
+
* Actions rendered in the modal header, next to the close button.
|
|
198
|
+
*/
|
|
199
|
+
headerActions?: PopUpHeaderAction[];
|
|
175
200
|
};
|
|
176
201
|
/**
|
|
177
202
|
* Represents a utility for managing UI modals.
|
|
@@ -77,18 +77,18 @@ const breakpoints = [
|
|
|
77
77
|
* @returns {null} This component renders nothing.
|
|
78
78
|
*/
|
|
79
79
|
exports.ViewportDetect = React.memo(({ onChange }) => {
|
|
80
|
+
const onChangeRef = React.useRef(onChange);
|
|
81
|
+
onChangeRef.current = onChange;
|
|
80
82
|
React.useEffect(() => {
|
|
81
83
|
const listeners = [];
|
|
82
84
|
breakpoints.forEach(({ viewport, query }) => {
|
|
83
85
|
const mql = window.matchMedia(query);
|
|
84
86
|
const handler = (e) => {
|
|
85
87
|
if (e.matches) {
|
|
86
|
-
|
|
88
|
+
onChangeRef.current(new CurrentViewport(viewport));
|
|
87
89
|
}
|
|
88
90
|
};
|
|
89
|
-
// Check initial state
|
|
90
91
|
handler(mql);
|
|
91
|
-
// Listen for changes
|
|
92
92
|
mql.addEventListener("change", handler);
|
|
93
93
|
listeners.push({ mql, handler });
|
|
94
94
|
});
|
|
@@ -97,6 +97,6 @@ exports.ViewportDetect = React.memo(({ onChange }) => {
|
|
|
97
97
|
mql.removeEventListener("change", handler);
|
|
98
98
|
});
|
|
99
99
|
};
|
|
100
|
-
}, [
|
|
100
|
+
}, []);
|
|
101
101
|
return null;
|
|
102
102
|
});
|