ui-layout-manager-dev 0.0.27-dev → 0.0.29-dev
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/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/LayoutManager/Components/RootContainer/RootContainer.jsx +9 -2
- package/src/components/LayoutManager/Components/RootContainer/RootContainer.scss +13 -0
- package/src/components/LayoutManager/Controller/LayoutController.js +3 -0
- package/src/components/LayoutManager/Providers/ModalProvider.js +20 -2
package/package.json
CHANGED
|
@@ -29,10 +29,16 @@ export const RootContainer = () => {
|
|
|
29
29
|
const rootRef = useRef(null);
|
|
30
30
|
const timerRef = useRef(null);
|
|
31
31
|
const resizingRef = useRef(false);
|
|
32
|
+
const loadingOverlayRef = useRef(null);
|
|
33
|
+
const [showOverlay, setShowOverlay] = useState(true);
|
|
32
34
|
|
|
33
35
|
// Create the container API that will be used by the controller.
|
|
34
36
|
const rootContainerAPI = useRef({});
|
|
35
|
-
rootContainerAPI.current = {
|
|
37
|
+
rootContainerAPI.current = {
|
|
38
|
+
hideOverlay: () => {
|
|
39
|
+
setShowOverlay(false);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
36
42
|
|
|
37
43
|
const [childElements, setChildElements] = useState(null);
|
|
38
44
|
|
|
@@ -118,7 +124,7 @@ export const RootContainer = () => {
|
|
|
118
124
|
observer.disconnect();
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
|
-
}, [layoutController]);
|
|
127
|
+
}, [layoutController, setShowOverlay, showOverlay]);
|
|
122
128
|
|
|
123
129
|
const sensors = useSensors(
|
|
124
130
|
useSensor(PointerSensor, {
|
|
@@ -147,6 +153,7 @@ export const RootContainer = () => {
|
|
|
147
153
|
onDragEnd={dragController.onDragEnd}
|
|
148
154
|
onDragCancel={dragController.onDragCancel}>
|
|
149
155
|
|
|
156
|
+
{showOverlay && <div className="loading-overlay" ref={loadingOverlayRef}></div>}
|
|
150
157
|
<div className="root-container">
|
|
151
158
|
<div ref={rootRef} className="relative-container">
|
|
152
159
|
{childElements}
|
|
@@ -13,6 +13,19 @@
|
|
|
13
13
|
overflow: hidden;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
.loading-overlay {
|
|
17
|
+
position: absolute;
|
|
18
|
+
top: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
background-color: #1a1a1a;
|
|
23
|
+
display: flex;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
align-items: center;
|
|
26
|
+
z-index: 9999;
|
|
27
|
+
}
|
|
28
|
+
|
|
16
29
|
.drag-overlay {
|
|
17
30
|
position: fixed;
|
|
18
31
|
pointer-events: none;
|
|
@@ -185,6 +185,9 @@ export class LayoutController {
|
|
|
185
185
|
case LAYOUT_WORKER_PROTOCOL.INITIALIZE_FLEXBOX:
|
|
186
186
|
transformations = event.data.data;
|
|
187
187
|
this.applyTransformations(transformations, true);
|
|
188
|
+
// TODO: Only make containers visible after the layout
|
|
189
|
+
// is applied to avoid glitchy rendering.
|
|
190
|
+
this.containers["root"].current.hideOverlay();
|
|
188
191
|
break;
|
|
189
192
|
case LAYOUT_WORKER_PROTOCOL.TRANSFORMATIONS:
|
|
190
193
|
transformations = event.data.data;
|
|
@@ -5,6 +5,7 @@ import React, {
|
|
|
5
5
|
useContext,
|
|
6
6
|
useMemo,
|
|
7
7
|
useState,
|
|
8
|
+
useRef
|
|
8
9
|
} from "react";
|
|
9
10
|
|
|
10
11
|
import { createPortal } from "react-dom";
|
|
@@ -19,6 +20,7 @@ const ModalContext = createContext(null);
|
|
|
19
20
|
*/
|
|
20
21
|
export function ModalProvider({ children }) {
|
|
21
22
|
const [modal, setModal] = useState(null);
|
|
23
|
+
const downOnContentRef = useRef(false);
|
|
22
24
|
|
|
23
25
|
// Open a modal with the given content and title. Returns a function to close the modal.
|
|
24
26
|
const openModal = useCallback(( args ) => {
|
|
@@ -43,6 +45,22 @@ export function ModalProvider({ children }) {
|
|
|
43
45
|
setModal(null);
|
|
44
46
|
}, []);
|
|
45
47
|
|
|
48
|
+
|
|
49
|
+
// Prevent close when mouse down first happens on content
|
|
50
|
+
// and then dragged onto backdrop
|
|
51
|
+
const clickedBackdrop = (e) => {
|
|
52
|
+
e.stopPropagation()
|
|
53
|
+
if (!downOnContentRef.current) {
|
|
54
|
+
closeModal();
|
|
55
|
+
}
|
|
56
|
+
downOnContentRef.current = false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const downOnContent = (e) => {
|
|
60
|
+
e.stopPropagation()
|
|
61
|
+
downOnContentRef.current = true;
|
|
62
|
+
}
|
|
63
|
+
|
|
46
64
|
// Render the modal portal
|
|
47
65
|
// TODO: Add support for different sizes
|
|
48
66
|
const getPortal = () => {
|
|
@@ -50,8 +68,8 @@ export function ModalProvider({ children }) {
|
|
|
50
68
|
<>
|
|
51
69
|
{modal && (
|
|
52
70
|
<React.Fragment key={modal.id}>
|
|
53
|
-
<div className="modal-backdrop" onClick={
|
|
54
|
-
<div className="modal-content"
|
|
71
|
+
<div className="modal-backdrop" onClick={clickedBackdrop}>
|
|
72
|
+
<div className="modal-content" onMouseDown={downOnContent}>
|
|
55
73
|
<div className="modal-header">
|
|
56
74
|
<span className="title">{modal.title}</span>
|
|
57
75
|
<XLg className="close-button" onClick={modal.close} />
|