@24i/bigscreen-sdk 1.0.16-alpha.2314 → 1.0.16
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/package.json
CHANGED
|
@@ -10,11 +10,15 @@ type Props = {
|
|
|
10
10
|
isFocusable?: boolean;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
type RenderFunction = (ref:Reference) => JSX.Element;
|
|
14
|
+
|
|
13
15
|
export class ModalService extends Component<Props> {
|
|
14
16
|
private openState = false;
|
|
15
17
|
|
|
16
18
|
private readonly rootRef = createRef<HTMLDivElement>();
|
|
17
19
|
|
|
20
|
+
private readonly modalQueue: RenderFunction[] = [];
|
|
21
|
+
|
|
18
22
|
modalRef = createRef<any>();
|
|
19
23
|
|
|
20
24
|
static defaultProps = {
|
|
@@ -40,7 +44,19 @@ export class ModalService extends Component<Props> {
|
|
|
40
44
|
return this.modalRef;
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
private enqueueModal(modal: RenderFunction) {
|
|
48
|
+
this.modalQueue.push(modal);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private dequeueModal() {
|
|
52
|
+
return this.modalQueue.shift();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
open<T extends IModal>(render: (ref: Reference<T>) => JSX.Element, queueModal = false) {
|
|
56
|
+
if (queueModal && this.openState) {
|
|
57
|
+
this.enqueueModal(render);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
44
60
|
const { isFocusable } = this.props;
|
|
45
61
|
this.openState = true;
|
|
46
62
|
this.clearMount(
|
|
@@ -60,6 +76,8 @@ export class ModalService extends Component<Props> {
|
|
|
60
76
|
if (isFocusable) {
|
|
61
77
|
focusCandidate();
|
|
62
78
|
}
|
|
79
|
+
const modalFromQueue = this.dequeueModal();
|
|
80
|
+
if (modalFromQueue) this.open(modalFromQueue);
|
|
63
81
|
}
|
|
64
82
|
|
|
65
83
|
isOpen() {
|