dry-ux 1.67.0 → 1.68.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/helpers/utilities.d.ts +1 -1
- package/dist/helpers/utilities.js +10 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/provider.d.ts +4 -0
- package/dist/provider.js +1 -1
- package/dist/styles/viewport.css +66 -0
- package/dist/ui-utils/Modal.js +10 -1
- package/dist/ui-utils/UIUtilProvider.d.ts +5 -1
- package/dist/ui-utils/UIUtilProvider.js +4 -1
- package/dist/ui-utils/ViewportDetect.d.ts +11 -0
- package/dist/ui-utils/ViewportDetect.js +31 -0
- package/package.json +1 -1
|
@@ -113,7 +113,7 @@ export declare const usePubSub: <T>() => {
|
|
|
113
113
|
usePub: () => <TName extends keyof T, TPayload extends T[TName]>(event: TName, data?: TPayload) => void;
|
|
114
114
|
useSub: <TName extends keyof T, TPayload_1 extends T[TName]>(event: TName, callback: (data: TPayload_1) => void) => () => void;
|
|
115
115
|
};
|
|
116
|
-
export declare const
|
|
116
|
+
export declare const useDimensions: (ref?: React.MutableRefObject<HTMLElement>) => {
|
|
117
117
|
width: number;
|
|
118
118
|
height: number;
|
|
119
119
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useDimensions = exports.usePubSub = exports.useIsVisible = exports.tryParseJson = exports.Deferred = exports.getUrlParams = exports.insertUrlParams = exports.insertUrlParam = exports.toHashCode = exports.StorageUtils = exports.fnWithAuthCheck = exports.formatDollar = exports.useCountdown = exports.importStyleSheet = exports.importScript = exports.preventDefault = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
5
|
/**
|
|
6
6
|
* Returns a function that will call the given handler and prevent the default event behavior.
|
|
@@ -282,22 +282,17 @@ const usePubSub = () => {
|
|
|
282
282
|
return { usePub, useSub };
|
|
283
283
|
};
|
|
284
284
|
exports.usePubSub = usePubSub;
|
|
285
|
-
const
|
|
285
|
+
const useDimensions = (ref) => {
|
|
286
286
|
const [size, setSize] = React.useState({ width: 0, height: 0 });
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
setSize({ width: myRef.current.offsetWidth, height: myRef.current.offsetHeight });
|
|
290
|
-
}
|
|
291
|
-
}, [myRef]);
|
|
287
|
+
const element = (ref === null || ref === void 0 ? void 0 : ref.current) || document.documentElement;
|
|
288
|
+
const handleResize = React.useCallback(() => setSize({ width: element.clientWidth, height: element.clientHeight }), [element]);
|
|
292
289
|
React.useEffect(() => {
|
|
293
|
-
|
|
294
|
-
window.addEventListener("
|
|
290
|
+
const controller = new AbortController();
|
|
291
|
+
window.addEventListener("load", handleResize, { signal: controller.signal });
|
|
292
|
+
window.addEventListener("resize", handleResize, { signal: controller.signal });
|
|
295
293
|
handleResize();
|
|
296
|
-
return () =>
|
|
297
|
-
|
|
298
|
-
window.removeEventListener("resize", handleResize);
|
|
299
|
-
};
|
|
300
|
-
}, [myRef, handleResize]);
|
|
294
|
+
return () => controller.abort();
|
|
295
|
+
}, [ref, handleResize]);
|
|
301
296
|
return size;
|
|
302
297
|
};
|
|
303
|
-
exports.
|
|
298
|
+
exports.useDimensions = useDimensions;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ export { Loader } from "./ui-utils/Loader";
|
|
|
15
15
|
export { Spinner } from "./ui-utils/Spinner";
|
|
16
16
|
export { RenderWhenVisible } from "./ui-utils/RenderWhenVisible";
|
|
17
17
|
export { Validation, Element } from "./enhanced-inputs/Validaition";
|
|
18
|
+
export { Viewport } from "./ui-utils/ViewportDetect";
|
|
18
19
|
export * from "./enhanced-inputs/HTMLInputs";
|
|
19
20
|
export * from "./enhanced-inputs/interface";
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Element = exports.Validation = exports.RenderWhenVisible = exports.Spinner = exports.Loader = exports.ErrorScreen = exports.ErrorBoundary = exports.DajaxiceProxy = exports.unflatten = exports.flatten = exports.classSet = exports.DryUXProvider = exports.Money = exports.DryUXRenderer = exports.DryUXContext = exports.useDryUxContext = void 0;
|
|
17
|
+
exports.Viewport = exports.Element = exports.Validation = exports.RenderWhenVisible = exports.Spinner = exports.Loader = exports.ErrorScreen = exports.ErrorBoundary = exports.DajaxiceProxy = exports.unflatten = exports.flatten = exports.classSet = exports.DryUXProvider = exports.Money = exports.DryUXRenderer = exports.DryUXContext = exports.useDryUxContext = void 0;
|
|
18
18
|
var UIUtilProvider_1 = require("./ui-utils/UIUtilProvider");
|
|
19
19
|
Object.defineProperty(exports, "useDryUxContext", { enumerable: true, get: function () { return UIUtilProvider_1.useUIUtilContext; } });
|
|
20
20
|
Object.defineProperty(exports, "DryUXContext", { enumerable: true, get: function () { return UIUtilProvider_1.UIUtilContext; } });
|
|
@@ -47,5 +47,7 @@ Object.defineProperty(exports, "RenderWhenVisible", { enumerable: true, get: fun
|
|
|
47
47
|
var Validaition_1 = require("./enhanced-inputs/Validaition");
|
|
48
48
|
Object.defineProperty(exports, "Validation", { enumerable: true, get: function () { return Validaition_1.Validation; } });
|
|
49
49
|
Object.defineProperty(exports, "Element", { enumerable: true, get: function () { return Validaition_1.Element; } });
|
|
50
|
+
var ViewportDetect_1 = require("./ui-utils/ViewportDetect");
|
|
51
|
+
Object.defineProperty(exports, "Viewport", { enumerable: true, get: function () { return ViewportDetect_1.Viewport; } });
|
|
50
52
|
__exportStar(require("./enhanced-inputs/HTMLInputs"), exports);
|
|
51
53
|
__exportStar(require("./enhanced-inputs/interface"), exports);
|
package/dist/provider.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ interface IDryUXProviderProps {
|
|
|
10
10
|
* Props to pass to the renderer.
|
|
11
11
|
*/
|
|
12
12
|
rendererProps?: UIUtilRendererProps;
|
|
13
|
+
/**
|
|
14
|
+
* If true, the viewport detection will be enabled.
|
|
15
|
+
*/
|
|
16
|
+
viewportDetect?: boolean;
|
|
13
17
|
children: React.ReactNode;
|
|
14
18
|
}
|
|
15
19
|
export declare const DryUXProvider: React.FC<IDryUXProviderProps>;
|
package/dist/provider.js
CHANGED
|
@@ -4,6 +4,6 @@ exports.DryUXProvider = void 0;
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const UIUtilProvider_1 = require("./ui-utils/UIUtilProvider");
|
|
6
6
|
const UIUtilRenderer_1 = require("./ui-utils/UIUtilRenderer");
|
|
7
|
-
exports.DryUXProvider = React.memo(({ children, noRenderer = false, rendererProps }) => (React.createElement(UIUtilProvider_1.UIUtilProvider,
|
|
7
|
+
exports.DryUXProvider = React.memo(({ children, noRenderer = false, rendererProps, viewportDetect }) => (React.createElement(UIUtilProvider_1.UIUtilProvider, { viewportDetect: viewportDetect },
|
|
8
8
|
children,
|
|
9
9
|
!noRenderer && React.createElement(UIUtilRenderer_1.UIUtilRenderer, Object.assign({}, rendererProps)))));
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.dry-visible-xs,
|
|
2
|
+
.dry-visible-sm,
|
|
3
|
+
.dry-visible-md,
|
|
4
|
+
.dry-visible-lg {
|
|
5
|
+
display: none !important;
|
|
6
|
+
}
|
|
7
|
+
@media (max-width: 767px) {
|
|
8
|
+
.dry-visible-xs {
|
|
9
|
+
display: block !important;
|
|
10
|
+
}
|
|
11
|
+
table.dry-visible-xs {
|
|
12
|
+
display: table;
|
|
13
|
+
}
|
|
14
|
+
tr.dry-visible-xs {
|
|
15
|
+
display: table-row !important;
|
|
16
|
+
}
|
|
17
|
+
th.dry-visible-xs,
|
|
18
|
+
td.dry-visible-xs {
|
|
19
|
+
display: table-cell !important;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
@media (min-width: 768px) and (max-width: 991px) {
|
|
23
|
+
.dry-visible-sm {
|
|
24
|
+
display: block !important;
|
|
25
|
+
}
|
|
26
|
+
table.dry-visible-sm {
|
|
27
|
+
display: table;
|
|
28
|
+
}
|
|
29
|
+
tr.dry-visible-sm {
|
|
30
|
+
display: table-row !important;
|
|
31
|
+
}
|
|
32
|
+
th.dry-visible-sm,
|
|
33
|
+
td.dry-visible-sm {
|
|
34
|
+
display: table-cell !important;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
@media (min-width: 992px) and (max-width: 1199px) {
|
|
38
|
+
.dry-visible-md {
|
|
39
|
+
display: block !important;
|
|
40
|
+
}
|
|
41
|
+
table.dry-visible-md {
|
|
42
|
+
display: table;
|
|
43
|
+
}
|
|
44
|
+
tr.dry-visible-md {
|
|
45
|
+
display: table-row !important;
|
|
46
|
+
}
|
|
47
|
+
th.dry-visible-md,
|
|
48
|
+
td.dry-visible-md {
|
|
49
|
+
display: table-cell !important;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
@media (min-width: 1200px) {
|
|
53
|
+
.dry-visible-lg {
|
|
54
|
+
display: block !important;
|
|
55
|
+
}
|
|
56
|
+
table.dry-visible-lg {
|
|
57
|
+
display: table;
|
|
58
|
+
}
|
|
59
|
+
tr.dry-visible-lg {
|
|
60
|
+
display: table-row !important;
|
|
61
|
+
}
|
|
62
|
+
th.dry-visible-lg,
|
|
63
|
+
td.dry-visible-lg {
|
|
64
|
+
display: table-cell !important;
|
|
65
|
+
}
|
|
66
|
+
}
|
package/dist/ui-utils/Modal.js
CHANGED
|
@@ -5,8 +5,10 @@ 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 utilities_1 = require("../helpers/utilities");
|
|
8
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, }, }) => {
|
|
9
10
|
const isCentered = centered !== null && centered !== void 0 ? centered : globalCentered;
|
|
11
|
+
const { height: documentHeight } = (0, utilities_1.useDimensions)();
|
|
10
12
|
const applyStyles = React.useCallback(() => {
|
|
11
13
|
document.querySelectorAll(".modal-dialog").forEach((el) => {
|
|
12
14
|
el.style.width = typeof width == "number" ? `${width}px` : width;
|
|
@@ -14,7 +16,7 @@ const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, opt
|
|
|
14
16
|
if (setBackdropHeight) {
|
|
15
17
|
document
|
|
16
18
|
.querySelectorAll(".modal-backdrop")
|
|
17
|
-
.forEach((el) => (el.style.height = `${document.
|
|
19
|
+
.forEach((el) => (el.style.height = `${document.documentElement.clientHeight}px`));
|
|
18
20
|
}
|
|
19
21
|
Object.keys(styles).forEach(selector => {
|
|
20
22
|
document.querySelectorAll(selector).forEach((el) => {
|
|
@@ -33,6 +35,13 @@ const Modal = ({ id, instance: { handleClose, toggleOverlay, shown, overlay, opt
|
|
|
33
35
|
globalOnClose === null || globalOnClose === void 0 ? void 0 : globalOnClose({ title, trackingId });
|
|
34
36
|
}
|
|
35
37
|
}, [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]);
|
|
36
45
|
const onHide = () => {
|
|
37
46
|
handleClose(id, false, true);
|
|
38
47
|
onClose && onClose();
|
|
@@ -1,11 +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 { Viewport } from "./ViewportDetect";
|
|
4
5
|
export interface IUIUtilProviderState {
|
|
5
6
|
modal: UIUtilModal;
|
|
6
7
|
prompt: UIUtilPrompt;
|
|
7
8
|
customLoader: IUIUtilLoader;
|
|
8
9
|
loader: Pick<IUIUtilLoader, "show" | "hide">;
|
|
10
|
+
viewport?: Viewport;
|
|
9
11
|
}
|
|
10
12
|
export declare const UIUtilContext: React.Context<IUIUtilProviderState>;
|
|
11
13
|
export declare const useUIUtilContext: () => IUIUtilProviderState;
|
|
@@ -16,7 +18,9 @@ declare const modalId: {
|
|
|
16
18
|
modal: string;
|
|
17
19
|
};
|
|
18
20
|
type ModalId = (typeof modalId)[keyof typeof modalId];
|
|
19
|
-
export declare class UIUtilProvider extends React.PureComponent<{
|
|
21
|
+
export declare class UIUtilProvider extends React.PureComponent<{
|
|
22
|
+
viewportDetect?: boolean;
|
|
23
|
+
}, IUIUtilProviderState> {
|
|
20
24
|
private readonly loader;
|
|
21
25
|
constructor(props: any);
|
|
22
26
|
get modalDefaults(): {
|
|
@@ -5,6 +5,7 @@ const React = require("react");
|
|
|
5
5
|
require("../types");
|
|
6
6
|
const Loader_1 = require("./Loader");
|
|
7
7
|
const ActionsOverlay_1 = require("./ActionsOverlay");
|
|
8
|
+
const ViewportDetect_1 = require("./ViewportDetect");
|
|
8
9
|
const defaultState = {
|
|
9
10
|
modal: {
|
|
10
11
|
show: null,
|
|
@@ -171,7 +172,9 @@ class UIUtilProvider extends React.PureComponent {
|
|
|
171
172
|
return this.getCurrentModal(id);
|
|
172
173
|
}
|
|
173
174
|
render() {
|
|
174
|
-
return React.createElement(exports.UIUtilContext.Provider, { value: this.state },
|
|
175
|
+
return (React.createElement(exports.UIUtilContext.Provider, { value: this.state },
|
|
176
|
+
this.props.viewportDetect && React.createElement(ViewportDetect_1.ViewportDetect, { onChange: viewport => this.setState({ viewport }) }),
|
|
177
|
+
this.props.children));
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
exports.UIUtilProvider = UIUtilProvider;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ViewportDetect = exports.Viewport = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
require("../styles/viewport.css");
|
|
6
|
+
const utilities_1 = require("../helpers/utilities");
|
|
7
|
+
var Viewport;
|
|
8
|
+
(function (Viewport) {
|
|
9
|
+
Viewport["XS"] = "xs";
|
|
10
|
+
Viewport["SM"] = "sm";
|
|
11
|
+
Viewport["MD"] = "md";
|
|
12
|
+
Viewport["LG"] = "lg";
|
|
13
|
+
})(Viewport || (exports.Viewport = Viewport = {}));
|
|
14
|
+
const DetectionElement = ({ viewport, onVisibilityChange, }) => {
|
|
15
|
+
const ref = React.useRef(null);
|
|
16
|
+
const isVisible = (0, utilities_1.useIsVisible)(ref);
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
onVisibilityChange(isVisible);
|
|
19
|
+
}, [isVisible]);
|
|
20
|
+
return React.createElement("div", { ref: ref, className: `dry-visible-${viewport}` });
|
|
21
|
+
};
|
|
22
|
+
exports.ViewportDetect = React.memo(({ onChange }) => {
|
|
23
|
+
const onVisibilityChange = (viewport, isVisible) => {
|
|
24
|
+
if (isVisible) {
|
|
25
|
+
onChange(viewport);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return (React.createElement(React.Fragment, null, Object.keys(Viewport)
|
|
29
|
+
.map(v => Viewport[v])
|
|
30
|
+
.map((viewport) => (React.createElement(DetectionElement, { key: viewport, viewport: viewport, onVisibilityChange: isVisible => onVisibilityChange(viewport, isVisible) })))));
|
|
31
|
+
});
|