dry-ux 1.68.0 → 1.70.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 +10 -0
- package/dist/ui-utils/Modal.d.ts +0 -1
- package/dist/ui-utils/Modal.js +3 -17
- package/dist/ui-utils/UIUtilProvider.d.ts +2 -2
- package/dist/ui-utils/UIUtilProvider.js +3 -2
- package/dist/ui-utils/ViewportDetect.d.ts +10 -1
- package/dist/ui-utils/ViewportDetect.js +23 -2
- package/package.json +1 -1
package/dist/styles/modal.css
CHANGED
|
@@ -59,6 +59,16 @@
|
|
|
59
59
|
left: 50%!important;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
.dry-ux-modal-backdrop {
|
|
63
|
+
position: fixed!important;
|
|
64
|
+
top: 0!important;
|
|
65
|
+
left: 0!important;
|
|
66
|
+
width: 100vw!important;
|
|
67
|
+
height: 100vh!important;
|
|
68
|
+
z-index: 1040!important;
|
|
69
|
+
opacity: 0.5!important;
|
|
70
|
+
}
|
|
71
|
+
|
|
62
72
|
@media only screen and (max-width: 767px) {
|
|
63
73
|
.dry-ux-overlay-content {
|
|
64
74
|
width: 90%;
|
package/dist/ui-utils/Modal.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export type ModalProps = {
|
|
|
9
9
|
[selector: string]: React.CSSProperties;
|
|
10
10
|
};
|
|
11
11
|
defaultModalStyles?: boolean;
|
|
12
|
-
setBackdropHeight?: boolean;
|
|
13
12
|
centered?: boolean;
|
|
14
13
|
onOpen?: (modal: Pick<PopUpOptions, "title" | "trackingId">) => void;
|
|
15
14
|
onClose?: (modal: Pick<PopUpOptions, "title" | "trackingId">) => void;
|
package/dist/ui-utils/Modal.js
CHANGED
|
@@ -5,19 +5,12 @@ const react_bootstrap_1 = require("react-bootstrap");
|
|
|
5
5
|
require("../styles/modal.css");
|
|
6
6
|
const classSet_1 = require("../helpers/classSet");
|
|
7
7
|
const ActionsOverlay_1 = require("./ActionsOverlay");
|
|
8
|
-
const
|
|
9
|
-
const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, options: { content, footerContent, cssClass = "", closeBtn, title, width, onClose, titleCloseBtn = true, centered, trackingId, actions = [], }, }, config: { defaultModalStyles = false, styles = {}, setBackdropHeight = true, centered: globalCentered, onOpen, onClose: globalOnClose, }, }) => {
|
|
8
|
+
const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, options: { content, footerContent, cssClass = "", closeBtn, title, width, onClose, titleCloseBtn = true, centered, trackingId, actions = [], }, }, config: { defaultModalStyles = false, styles = {}, centered: globalCentered, onOpen, onClose: globalOnClose }, }) => {
|
|
10
9
|
const isCentered = centered !== null && centered !== void 0 ? centered : globalCentered;
|
|
11
|
-
const { height: documentHeight } = (0, utilities_1.useDimensions)();
|
|
12
10
|
const applyStyles = React.useCallback(() => {
|
|
13
11
|
document.querySelectorAll(".modal-dialog").forEach((el) => {
|
|
14
12
|
el.style.width = typeof width == "number" ? `${width}px` : width;
|
|
15
13
|
});
|
|
16
|
-
if (setBackdropHeight) {
|
|
17
|
-
document
|
|
18
|
-
.querySelectorAll(".modal-backdrop")
|
|
19
|
-
.forEach((el) => (el.style.height = `${document.documentElement.clientHeight}px`));
|
|
20
|
-
}
|
|
21
14
|
Object.keys(styles).forEach(selector => {
|
|
22
15
|
document.querySelectorAll(selector).forEach((el) => {
|
|
23
16
|
Object.keys(styles[selector]).forEach(style => {
|
|
@@ -25,7 +18,7 @@ const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, opt
|
|
|
25
18
|
});
|
|
26
19
|
});
|
|
27
20
|
});
|
|
28
|
-
}, [width, styles
|
|
21
|
+
}, [width, styles]);
|
|
29
22
|
React.useEffect(() => {
|
|
30
23
|
if (shown) {
|
|
31
24
|
applyStyles();
|
|
@@ -35,13 +28,6 @@ const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, opt
|
|
|
35
28
|
globalOnClose === null || globalOnClose === void 0 ? void 0 : globalOnClose({ title, trackingId });
|
|
36
29
|
}
|
|
37
30
|
}, [shown, width, defaultModalStyles]);
|
|
38
|
-
React.useEffect(() => {
|
|
39
|
-
if (setBackdropHeight) {
|
|
40
|
-
document
|
|
41
|
-
.querySelectorAll(".modal-backdrop")
|
|
42
|
-
.forEach((el) => (el.style.height = `${documentHeight}px`));
|
|
43
|
-
}
|
|
44
|
-
}, [documentHeight, setBackdropHeight]);
|
|
45
31
|
const onHide = () => {
|
|
46
32
|
handleClose(id, false, true);
|
|
47
33
|
onClose && onClose();
|
|
@@ -75,7 +61,7 @@ const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, opt
|
|
|
75
61
|
}
|
|
76
62
|
} }, content)));
|
|
77
63
|
}, [actions, toggleOverlay, onHide, closeBtn]);
|
|
78
|
-
return (React.createElement(react_bootstrap_1.Modal, { onHide: onHide, show: shown, animation: true, autoFocus: true, keyboard: false, className: modalCssClass,
|
|
64
|
+
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
65
|
overlay && (React.createElement("div", { className: "dry-ux-overlay" },
|
|
80
66
|
React.createElement("div", { className: "dry-ux-overlay-content" }, overlay))),
|
|
81
67
|
!!title && (React.createElement(react_bootstrap_1.Modal.Header, { closeButton: titleCloseBtn, onHide: onHide },
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Content, IUIUtilLoader, PopUp, PopUpAction, PopUpInstance, PopUpOptions, UIUtilModal, UIUtilPrompt } from "./UIUtil.interface";
|
|
3
3
|
import "../types";
|
|
4
|
-
import {
|
|
4
|
+
import { CurrentViewport } from "./ViewportDetect";
|
|
5
5
|
export interface IUIUtilProviderState {
|
|
6
6
|
modal: UIUtilModal;
|
|
7
7
|
prompt: UIUtilPrompt;
|
|
8
8
|
customLoader: IUIUtilLoader;
|
|
9
9
|
loader: Pick<IUIUtilLoader, "show" | "hide">;
|
|
10
|
-
viewport
|
|
10
|
+
viewport: CurrentViewport;
|
|
11
11
|
}
|
|
12
12
|
export declare const UIUtilContext: React.Context<IUIUtilProviderState>;
|
|
13
13
|
export declare const useUIUtilContext: () => IUIUtilProviderState;
|
|
@@ -31,6 +31,7 @@ const defaultState = {
|
|
|
31
31
|
show: null,
|
|
32
32
|
hide: null,
|
|
33
33
|
},
|
|
34
|
+
viewport: new ViewportDetect_1.CurrentViewport(undefined),
|
|
34
35
|
};
|
|
35
36
|
exports.UIUtilContext = React.createContext(defaultState);
|
|
36
37
|
const useUIUtilContext = () => React.useContext(exports.UIUtilContext);
|
|
@@ -173,8 +174,8 @@ class UIUtilProvider extends React.PureComponent {
|
|
|
173
174
|
}
|
|
174
175
|
render() {
|
|
175
176
|
return (React.createElement(exports.UIUtilContext.Provider, { value: this.state },
|
|
176
|
-
this.props.
|
|
177
|
-
this.props.
|
|
177
|
+
this.props.children,
|
|
178
|
+
this.props.viewportDetect && React.createElement(ViewportDetect_1.ViewportDetect, { onChange: viewport => this.setState({ viewport }) })));
|
|
178
179
|
}
|
|
179
180
|
}
|
|
180
181
|
exports.UIUtilProvider = UIUtilProvider;
|
|
@@ -6,6 +6,15 @@ export declare enum Viewport {
|
|
|
6
6
|
MD = "md",
|
|
7
7
|
LG = "lg"
|
|
8
8
|
}
|
|
9
|
+
export declare class CurrentViewport {
|
|
10
|
+
private _current;
|
|
11
|
+
constructor(_current: Viewport);
|
|
12
|
+
get isXS(): boolean;
|
|
13
|
+
get isSM(): boolean;
|
|
14
|
+
get isMD(): boolean;
|
|
15
|
+
get isLG(): boolean;
|
|
16
|
+
get current(): Viewport;
|
|
17
|
+
}
|
|
9
18
|
export declare const ViewportDetect: React.FC<{
|
|
10
|
-
onChange: (
|
|
19
|
+
onChange: (current: CurrentViewport) => void;
|
|
11
20
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ViewportDetect = exports.Viewport = void 0;
|
|
3
|
+
exports.ViewportDetect = exports.CurrentViewport = exports.Viewport = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
5
|
require("../styles/viewport.css");
|
|
6
6
|
const utilities_1 = require("../helpers/utilities");
|
|
@@ -11,6 +11,27 @@ var Viewport;
|
|
|
11
11
|
Viewport["MD"] = "md";
|
|
12
12
|
Viewport["LG"] = "lg";
|
|
13
13
|
})(Viewport || (exports.Viewport = Viewport = {}));
|
|
14
|
+
class CurrentViewport {
|
|
15
|
+
constructor(_current) {
|
|
16
|
+
this._current = _current;
|
|
17
|
+
}
|
|
18
|
+
get isXS() {
|
|
19
|
+
return this._current === Viewport.XS;
|
|
20
|
+
}
|
|
21
|
+
get isSM() {
|
|
22
|
+
return this._current === Viewport.SM;
|
|
23
|
+
}
|
|
24
|
+
get isMD() {
|
|
25
|
+
return this._current === Viewport.MD;
|
|
26
|
+
}
|
|
27
|
+
get isLG() {
|
|
28
|
+
return this._current === Viewport.LG;
|
|
29
|
+
}
|
|
30
|
+
get current() {
|
|
31
|
+
return this._current;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.CurrentViewport = CurrentViewport;
|
|
14
35
|
const DetectionElement = ({ viewport, onVisibilityChange, }) => {
|
|
15
36
|
const ref = React.useRef(null);
|
|
16
37
|
const isVisible = (0, utilities_1.useIsVisible)(ref);
|
|
@@ -22,7 +43,7 @@ const DetectionElement = ({ viewport, onVisibilityChange, }) => {
|
|
|
22
43
|
exports.ViewportDetect = React.memo(({ onChange }) => {
|
|
23
44
|
const onVisibilityChange = (viewport, isVisible) => {
|
|
24
45
|
if (isVisible) {
|
|
25
|
-
onChange(viewport);
|
|
46
|
+
onChange(new CurrentViewport(viewport));
|
|
26
47
|
}
|
|
27
48
|
};
|
|
28
49
|
return (React.createElement(React.Fragment, null, Object.keys(Viewport)
|