@ringcentral/juno 1.11.2 → 1.11.3-beta.5620-d9154e6b
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/README.md +0 -10
- package/components/Dialog/Dialog.d.ts +17 -4
- package/components/Dialog/Dialog.js +21 -8
- package/components/Dialog/DialogActions/DialogActions.d.ts +15 -5
- package/components/Dialog/DialogActions/DialogActions.js +13 -7
- package/components/Dialog/DialogActions/styles/DialogActionsStyle.js +20 -8
- package/components/Dialog/DialogActions/utils/DialogActionsUtils.d.ts +2 -2
- package/components/Dialog/DialogActions/utils/DialogActionsUtils.js +2 -5
- package/components/Dialog/DialogContent/DialogContent.d.ts +4 -4
- package/components/Dialog/DialogContent/DialogContent.js +5 -6
- package/components/Dialog/DialogContent/styles/DialogContentStyle.js +2 -4
- package/components/Dialog/DialogContent/utils/DialogContentUtils.d.ts +1 -2
- package/components/Dialog/DialogContent/utils/DialogContentUtils.js +6 -6
- package/components/Dialog/DialogContentText/DialogContentText.d.ts +4 -3
- package/components/Dialog/DialogContentText/DialogContentText.js +9 -8
- package/components/Dialog/DialogContentText/styles/DialogContentTextStyle.js +4 -2
- package/components/Dialog/DialogTitle/DialogTitle.d.ts +4 -4
- package/components/Dialog/DialogTitle/DialogTitle.js +6 -7
- package/components/Dialog/DialogTitle/styles/DialogTitleStyle.js +4 -5
- package/components/Dialog/DialogTitle/utils/DialogTitleUtils.d.ts +4 -2
- package/components/Dialog/DialogTitle/utils/DialogTitleUtils.js +6 -5
- package/components/Dialog/utils/DialogContext.d.ts +15 -0
- package/components/Dialog/utils/DialogContext.js +33 -0
- package/components/Dialog/utils/index.d.ts +1 -0
- package/components/Dialog/utils/index.js +1 -0
- package/components/Downshift/Downshift.d.ts +23 -2
- package/components/Downshift/Downshift.js +11 -8
- package/components/Downshift/SuggestionList/SuggestionList.d.ts +6 -4
- package/components/Downshift/SuggestionList/SuggestionList.js +17 -10
- package/components/Downshift/SuggestionList/utils/SuggestionListUtils.d.ts +1 -1
- package/components/Downshift/SuggestionList/utils/SuggestionListUtils.js +1 -1
- package/components/Downshift/utils/useDownshift.d.ts +3 -2
- package/components/Downshift/utils/useDownshift.js +7 -3
- package/components/Downshift/utils/useDownshiftGroup.d.ts +6 -4
- package/components/Downshift/utils/useDownshiftGroup.js +31 -9
- package/components/Forms/Picker/DatePicker/Calendar.js +5 -4
- package/components/Forms/Picker/DatePicker/DatePickerHeader.js +1 -1
- package/components/Forms/Picker/DatePicker/styles/StyledDatePickerHeader.d.ts +1 -1
- package/components/Forms/Picker/DatePicker/styles/StyledDatePickerHeader.js +1 -1
- package/components/Forms/Switch/styles/SwitchStyle.js +1 -1
- package/components/Icon/assets/icon-add-reactions.svg +5 -1
- package/components/Icon/assets/icon-connect.svg +5 -0
- package/components/Icon/assets/icon-customize-tabs.svg +5 -0
- package/components/Icon/icon-symbol.d.ts +1 -1
- package/components/Icon/icon-symbol.js +1 -1
- package/components/List/ListItem/ListItem.js +0 -1
- package/components/List/ListItem/styles/ListItemStyle.js +1 -1
- package/components/PopupBox/PopupBox.d.ts +2 -2
- package/components/PopupBox/PopupBox.js +8 -10
- package/components/PortalHost/Connectable/Connectable.d.ts +11 -0
- package/components/PortalHost/Connectable/Connectable.js +50 -0
- package/components/PortalHost/Connectable/ThrottleScheduler.d.ts +8 -0
- package/components/PortalHost/Connectable/ThrottleScheduler.js +27 -0
- package/components/PortalHost/Connectable/index.d.ts +3 -0
- package/components/PortalHost/Connectable/index.js +8 -0
- package/components/PortalHost/Connectable/types.d.ts +7 -0
- package/components/PortalHost/Connectable/types.js +3 -0
- package/components/PortalHost/PortalHost.d.ts +7 -0
- package/components/PortalHost/PortalHost.js +44 -0
- package/components/PortalHost/PortalManager/PortalManager.d.ts +65 -0
- package/components/PortalHost/PortalManager/PortalManager.js +274 -0
- package/components/PortalHost/PortalManager/PortalStore.d.ts +20 -0
- package/components/PortalHost/PortalManager/PortalStore.js +134 -0
- package/components/PortalHost/PortalManager/index.d.ts +4 -0
- package/components/PortalHost/PortalManager/index.js +9 -0
- package/components/PortalHost/PortalManager/types.d.ts +86 -0
- package/components/PortalHost/PortalManager/types.js +3 -0
- package/components/PortalHost/PortalManager/utils.d.ts +8 -0
- package/components/PortalHost/PortalManager/utils.js +19 -0
- package/components/PortalHost/PortalRenderer.d.ts +10 -0
- package/components/PortalHost/PortalRenderer.js +43 -0
- package/components/PortalHost/context/PortalIDContext.d.ts +5 -0
- package/components/PortalHost/context/PortalIDContext.js +5 -0
- package/components/PortalHost/context/PortalManagerContext.d.ts +6 -0
- package/components/PortalHost/context/PortalManagerContext.js +5 -0
- package/components/PortalHost/context/index.d.ts +2 -0
- package/components/PortalHost/context/index.js +7 -0
- package/components/PortalHost/index.d.ts +4 -0
- package/components/PortalHost/index.js +9 -0
- package/components/PortalHost/utils/index.d.ts +2 -0
- package/components/PortalHost/utils/index.js +7 -0
- package/components/PortalHost/utils/usePortalManagerWithID.d.ts +8 -0
- package/components/PortalHost/utils/usePortalManagerWithID.js +12 -0
- package/components/PortalHost/utils/useUnmountPortalHandler.d.ts +5 -0
- package/components/PortalHost/utils/useUnmountPortalHandler.js +16 -0
- package/components/Snackbar/Snackbar.js +4 -2
- package/components/Virtuoso/utils/useHighlightScroll.d.ts +2 -1
- package/components/Virtuoso/utils/useHighlightScroll.js +4 -2
- package/components/index.d.ts +2 -1
- package/components/index.js +2 -1
- package/es6/components/Dialog/Dialog.js +22 -10
- package/es6/components/Dialog/DialogActions/DialogActions.js +11 -5
- package/es6/components/Dialog/DialogActions/styles/DialogActionsStyle.js +19 -7
- package/es6/components/Dialog/DialogActions/utils/DialogActionsUtils.js +2 -5
- package/es6/components/Dialog/DialogContent/DialogContent.js +3 -4
- package/es6/components/Dialog/DialogContent/styles/DialogContentStyle.js +3 -5
- package/es6/components/Dialog/DialogContent/utils/DialogContentUtils.js +6 -6
- package/es6/components/Dialog/DialogContentText/DialogContentText.js +7 -6
- package/es6/components/Dialog/DialogContentText/styles/DialogContentTextStyle.js +4 -2
- package/es6/components/Dialog/DialogTitle/DialogTitle.js +5 -6
- package/es6/components/Dialog/DialogTitle/styles/DialogTitleStyle.js +4 -5
- package/es6/components/Dialog/DialogTitle/utils/DialogTitleUtils.js +6 -5
- package/es6/components/Dialog/utils/DialogContext.js +31 -0
- package/es6/components/Dialog/utils/index.js +1 -0
- package/es6/components/Downshift/Downshift.js +11 -8
- package/es6/components/Downshift/SuggestionList/SuggestionList.js +17 -10
- package/es6/components/Downshift/SuggestionList/utils/SuggestionListUtils.js +1 -1
- package/es6/components/Downshift/utils/useDownshift.js +7 -3
- package/es6/components/Downshift/utils/useDownshiftGroup.js +33 -11
- package/es6/components/Forms/Picker/DatePicker/Calendar.js +6 -5
- package/es6/components/Forms/Picker/DatePicker/DatePickerHeader.js +1 -1
- package/es6/components/Forms/Picker/DatePicker/styles/StyledDatePickerHeader.js +2 -2
- package/es6/components/Forms/Switch/styles/SwitchStyle.js +1 -1
- package/es6/components/Icon/assets/icon-add-reactions.svg +5 -1
- package/es6/components/Icon/assets/icon-connect.svg +5 -0
- package/es6/components/Icon/assets/icon-customize-tabs.svg +5 -0
- package/es6/components/Icon/icon-symbol.js +1 -1
- package/es6/components/List/ListItem/ListItem.js +0 -1
- package/es6/components/List/ListItem/styles/ListItemStyle.js +1 -1
- package/es6/components/PopupBox/PopupBox.js +8 -10
- package/es6/components/PortalHost/Connectable/Connectable.js +48 -0
- package/es6/components/PortalHost/Connectable/ThrottleScheduler.js +25 -0
- package/es6/components/PortalHost/Connectable/index.js +3 -0
- package/es6/components/PortalHost/Connectable/types.js +1 -0
- package/es6/components/PortalHost/PortalHost.js +35 -0
- package/es6/components/PortalHost/PortalManager/PortalManager.js +272 -0
- package/es6/components/PortalHost/PortalManager/PortalStore.js +132 -0
- package/es6/components/PortalHost/PortalManager/index.js +4 -0
- package/es6/components/PortalHost/PortalManager/types.js +1 -0
- package/es6/components/PortalHost/PortalManager/utils.js +17 -0
- package/es6/components/PortalHost/PortalRenderer.js +34 -0
- package/es6/components/PortalHost/context/PortalIDContext.js +3 -0
- package/es6/components/PortalHost/context/PortalManagerContext.js +3 -0
- package/es6/components/PortalHost/context/index.js +2 -0
- package/es6/components/PortalHost/index.js +4 -0
- package/es6/components/PortalHost/utils/index.js +2 -0
- package/es6/components/PortalHost/utils/usePortalManagerWithID.js +10 -0
- package/es6/components/PortalHost/utils/useUnmountPortalHandler.js +14 -0
- package/es6/components/Snackbar/Snackbar.js +4 -2
- package/es6/components/Virtuoso/utils/useHighlightScroll.js +4 -2
- package/es6/components/index.js +2 -1
- package/es6/icon/AddReactions.js +3 -1
- package/es6/icon/Connect.js +17 -0
- package/es6/icon/CustomizeTabs.js +17 -0
- package/es6/icon/index.js +2 -1
- package/es6/icons/icon-add-reactions.svg +5 -1
- package/es6/icons/icon-connect.svg +5 -0
- package/es6/icons/icon-customize-tabs.svg +5 -0
- package/icon/AddReactions.js +3 -1
- package/icon/{MenuFax.d.ts → Connect.d.ts} +2 -2
- package/icon/{MenuFax.js → Connect.js} +5 -5
- package/icon/CustomizeTabs.d.ts +3 -0
- package/icon/CustomizeTabs.js +26 -0
- package/icon/index.d.ts +2 -1
- package/icon/index.js +4 -2
- package/icons/icon-add-reactions.svg +5 -1
- package/icons/icon-connect.svg +5 -0
- package/icons/icon-customize-tabs.svg +5 -0
- package/package.json +1 -1
- package/components/Icon/assets/icon-menu-fax.svg +0 -5
- package/es6/components/Icon/assets/icon-menu-fax.svg +0 -5
- package/es6/icon/MenuFax.js +0 -17
- package/es6/icons/icon-menu-fax.svg +0 -5
- package/icons/icon-menu-fax.svg +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var ConnectSymbol = Symbol('connect');
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
18
|
+
import { ConnectSymbol } from './Connectable';
|
|
19
|
+
import { RcPortalRenderer } from './PortalRenderer';
|
|
20
|
+
import { PortalManagerProvider } from './context';
|
|
21
|
+
var RcPortalHost = function (_a) {
|
|
22
|
+
var manager = _a.manager;
|
|
23
|
+
var _b = __read(useState([]), 2), portals = _b[0], setPortals = _b[1];
|
|
24
|
+
// prevent manager change
|
|
25
|
+
var managerRef = useRef(manager);
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
var disconnectHandler = managerRef.current[ConnectSymbol](function (portalDescriptors) {
|
|
28
|
+
setPortals(portalDescriptors);
|
|
29
|
+
});
|
|
30
|
+
return disconnectHandler;
|
|
31
|
+
}, []);
|
|
32
|
+
return (React.createElement(PortalManagerProvider, { value: managerRef.current }, portals.map(function (portal) { return (React.createElement(RcPortalRenderer, { key: portal.id, portalDescriptor: portal })); })));
|
|
33
|
+
};
|
|
34
|
+
RcPortalHost.displayName = 'RcPortalHost';
|
|
35
|
+
export { RcPortalHost };
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
var __assign = (this && this.__assign) || function () {
|
|
15
|
+
__assign = Object.assign || function(t) {
|
|
16
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
17
|
+
s = arguments[i];
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
return __assign.apply(this, arguments);
|
|
24
|
+
};
|
|
25
|
+
var __values = (this && this.__values) || function(o) {
|
|
26
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
27
|
+
if (m) return m.call(o);
|
|
28
|
+
if (o && typeof o.length === "number") return {
|
|
29
|
+
next: function () {
|
|
30
|
+
if (o && i >= o.length) o = void 0;
|
|
31
|
+
return { value: o && o[i++], done: !o };
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
35
|
+
};
|
|
36
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
37
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
38
|
+
if (!m) return o;
|
|
39
|
+
var i = m.call(o), r, ar = [], e;
|
|
40
|
+
try {
|
|
41
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
42
|
+
}
|
|
43
|
+
catch (error) { e = { error: error }; }
|
|
44
|
+
finally {
|
|
45
|
+
try {
|
|
46
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
47
|
+
}
|
|
48
|
+
finally { if (e) throw e.error; }
|
|
49
|
+
}
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
import { logInDev } from '../../../foundation';
|
|
53
|
+
import { Connectable, ConnectSymbol, ThrottleScheduler, } from '../Connectable';
|
|
54
|
+
import { PortalStore } from './PortalStore';
|
|
55
|
+
import { UnmountSymbol, } from './types';
|
|
56
|
+
import { createPromise, UniqIdUtil } from './utils';
|
|
57
|
+
var PortalManager = /** @class */ (function (_super) {
|
|
58
|
+
__extends(PortalManager, _super);
|
|
59
|
+
function PortalManager(scheduler) {
|
|
60
|
+
if (scheduler === void 0) { scheduler = new ThrottleScheduler(); }
|
|
61
|
+
var _this = _super.call(this, scheduler) || this;
|
|
62
|
+
/**
|
|
63
|
+
* you can custom your manager by control this
|
|
64
|
+
*/
|
|
65
|
+
_this.portalStore = new PortalStore();
|
|
66
|
+
_this._feedbackMap = new Map();
|
|
67
|
+
_this._uniqIdUtils = new UniqIdUtil();
|
|
68
|
+
_this.portalStore[ConnectSymbol](function (portals) { return _this.emit(portals); });
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* open a component with portal (Dialog, snackbar, modal...)
|
|
73
|
+
* @param Component the component you want to open
|
|
74
|
+
* @param options some options (id, props...)
|
|
75
|
+
*/
|
|
76
|
+
PortalManager.prototype.open = function (Component, options) {
|
|
77
|
+
var _this = this;
|
|
78
|
+
if (options === void 0) { options = {}; }
|
|
79
|
+
var _id = options.id, props = options.props, data = options.data;
|
|
80
|
+
var id = _id !== null && _id !== void 0 ? _id : this._uniqIdUtils.get();
|
|
81
|
+
var currPortal = this.portalStore.get(id);
|
|
82
|
+
// portalWithSameID opened
|
|
83
|
+
if (currPortal === null || currPortal === void 0 ? void 0 : currPortal.open) {
|
|
84
|
+
logInDev({
|
|
85
|
+
component: 'RcPortalHost',
|
|
86
|
+
message: "open the portal with id('" + id + "') failed, this portal is already open",
|
|
87
|
+
});
|
|
88
|
+
return currPortal.portalController;
|
|
89
|
+
}
|
|
90
|
+
var portalDescriptor = this.createPortalDescriptor({
|
|
91
|
+
Component: Component,
|
|
92
|
+
id: id,
|
|
93
|
+
props: props,
|
|
94
|
+
data: data,
|
|
95
|
+
});
|
|
96
|
+
// portalWithSameID closed and not unmount
|
|
97
|
+
if (currPortal) {
|
|
98
|
+
// when closing (Animating), trigger open again.
|
|
99
|
+
currPortal.portalController.onClosed.then(function () {
|
|
100
|
+
_this._openPortal(portalDescriptor);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// portalWithSameID unmounted
|
|
104
|
+
else {
|
|
105
|
+
this._openPortal(portalDescriptor);
|
|
106
|
+
}
|
|
107
|
+
return portalDescriptor.portalController;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* close all
|
|
111
|
+
*/
|
|
112
|
+
PortalManager.prototype.closeAll = function () {
|
|
113
|
+
var _this = this;
|
|
114
|
+
this.portalStore.batch(function (store) {
|
|
115
|
+
var e_1, _a;
|
|
116
|
+
try {
|
|
117
|
+
for (var _b = __values(_this.portalStore.portals), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
118
|
+
var portal = _c.value;
|
|
119
|
+
store.addOrUpdate(__assign(__assign({}, portal), { open: false }));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
123
|
+
finally {
|
|
124
|
+
try {
|
|
125
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
126
|
+
}
|
|
127
|
+
finally { if (e_1) throw e_1.error; }
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* get portal controller which on top
|
|
133
|
+
*/
|
|
134
|
+
PortalManager.prototype.getTop = function () {
|
|
135
|
+
var _a;
|
|
136
|
+
return (_a = this.portalStore.lastPortal) === null || _a === void 0 ? void 0 : _a.portalController;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* get portal controller by id
|
|
140
|
+
*/
|
|
141
|
+
PortalManager.prototype.getByID = function (id) {
|
|
142
|
+
var _a;
|
|
143
|
+
return (_a = this.portalStore.get(id)) === null || _a === void 0 ? void 0 : _a.portalController;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* check if it's opened by id. equal 'portalController.isOpened'
|
|
147
|
+
*/
|
|
148
|
+
PortalManager.prototype.isOpened = function (id) {
|
|
149
|
+
var portal = this.portalStore.get(id);
|
|
150
|
+
return Boolean(portal === null || portal === void 0 ? void 0 : portal.open);
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* check if it's on top by id. equal 'portalController.isTop'
|
|
154
|
+
*/
|
|
155
|
+
PortalManager.prototype.isTop = function (id) {
|
|
156
|
+
var _a;
|
|
157
|
+
return ((_a = this.portalStore.lastPortal) === null || _a === void 0 ? void 0 : _a.id) === id;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* for RC component (Modal, component based on modal, snackbar).
|
|
161
|
+
* invoke this function would set 'open' prop to be false
|
|
162
|
+
* then unmount component after animation finish
|
|
163
|
+
*
|
|
164
|
+
* for non-RC component, you need unmount by self or call unmount directly
|
|
165
|
+
*
|
|
166
|
+
* equal 'portalController.close()'
|
|
167
|
+
*/
|
|
168
|
+
PortalManager.prototype.closeByID = function (id, feedback) {
|
|
169
|
+
var portal = this.portalStore.get(id);
|
|
170
|
+
if (!(portal === null || portal === void 0 ? void 0 : portal.open)) {
|
|
171
|
+
logInDev({
|
|
172
|
+
component: 'RcPortalHost',
|
|
173
|
+
message: 'close portal failed, this portal is already closed',
|
|
174
|
+
});
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
this._feedbackMap.set(portal.id, feedback);
|
|
178
|
+
this.portalStore.addOrUpdate(__assign(__assign({}, portal), { open: false }));
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* invoke this to close portal is not recommend, will loss close animation
|
|
182
|
+
*
|
|
183
|
+
* this function just help you unmount component after close animation finish
|
|
184
|
+
*
|
|
185
|
+
* RC component (Modal, component based on modal, snackbar) would invoke this after close animation finish
|
|
186
|
+
*/
|
|
187
|
+
PortalManager.prototype[UnmountSymbol] = function (id) {
|
|
188
|
+
var portal = this.portalStore.get(id);
|
|
189
|
+
if (!portal) {
|
|
190
|
+
logInDev({
|
|
191
|
+
component: 'RcPortalHost',
|
|
192
|
+
message: 'unmount portal failed, this portal is already unmount',
|
|
193
|
+
});
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
this.portalStore.delete(portal.id);
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* update props by id, equal 'portalController.updateProps(newProps)'
|
|
200
|
+
*/
|
|
201
|
+
PortalManager.prototype.updatePropsByID = function (id, props) {
|
|
202
|
+
var portal = this.portalStore.get(id);
|
|
203
|
+
if (!(portal === null || portal === void 0 ? void 0 : portal.open)) {
|
|
204
|
+
logInDev({
|
|
205
|
+
component: 'RcPortalHost',
|
|
206
|
+
message: 'update props failed, this portal is already closed',
|
|
207
|
+
});
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
this.portalStore.addOrUpdate(__assign(__assign({}, portal), { props: props }));
|
|
211
|
+
};
|
|
212
|
+
PortalManager.prototype.onConnected = function () {
|
|
213
|
+
_super.prototype.onConnected.call(this);
|
|
214
|
+
// prevent invoke 'open()' fail before PortalHost connect this
|
|
215
|
+
this.portalStore.forceEmit();
|
|
216
|
+
};
|
|
217
|
+
PortalManager.prototype.onDisconnected = function () {
|
|
218
|
+
_super.prototype.onDisconnected.call(this);
|
|
219
|
+
// clean all portal after PortalHost disconnect this
|
|
220
|
+
this.portalStore.clear();
|
|
221
|
+
this._feedbackMap.clear();
|
|
222
|
+
};
|
|
223
|
+
PortalManager.prototype._openPortal = function (portal) {
|
|
224
|
+
this.portalStore.addOrUpdate(portal);
|
|
225
|
+
};
|
|
226
|
+
PortalManager.prototype.createPortalDescriptor = function (_a) {
|
|
227
|
+
var _this = this;
|
|
228
|
+
var props = _a.props, data = _a.data, Component = _a.Component, id = _a.id;
|
|
229
|
+
var _b = __read(createPromise(), 2), onOpened = _b[0], resolveOnOpened = _b[1];
|
|
230
|
+
var _c = __read(createPromise(), 2), onClosed = _c[0], resolveOnClosed = _c[1];
|
|
231
|
+
var isTop = function () { return _this.isTop(id); };
|
|
232
|
+
var isOpened = function () { return _this.isOpened(id); };
|
|
233
|
+
var portalController = {
|
|
234
|
+
id: id,
|
|
235
|
+
onOpened: onOpened,
|
|
236
|
+
onClosed: onClosed,
|
|
237
|
+
close: function (feedback) {
|
|
238
|
+
_this.closeByID(id, feedback);
|
|
239
|
+
},
|
|
240
|
+
updateProps: function (newProps) {
|
|
241
|
+
_this.updatePropsByID(id, newProps);
|
|
242
|
+
},
|
|
243
|
+
data: data,
|
|
244
|
+
get isOpened() {
|
|
245
|
+
return isOpened();
|
|
246
|
+
},
|
|
247
|
+
get isTop() {
|
|
248
|
+
return isTop();
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
var portalDescriptor = {
|
|
252
|
+
id: id,
|
|
253
|
+
Component: Component,
|
|
254
|
+
onMounted: function () {
|
|
255
|
+
resolveOnOpened();
|
|
256
|
+
},
|
|
257
|
+
onUnmounted: function () {
|
|
258
|
+
var feedback = _this._feedbackMap.get(id);
|
|
259
|
+
resolveOnClosed(feedback);
|
|
260
|
+
},
|
|
261
|
+
props: props,
|
|
262
|
+
onClose: function (feedback) {
|
|
263
|
+
_this.closeByID(id, feedback);
|
|
264
|
+
},
|
|
265
|
+
open: true,
|
|
266
|
+
portalController: portalController,
|
|
267
|
+
};
|
|
268
|
+
return portalDescriptor;
|
|
269
|
+
};
|
|
270
|
+
return PortalManager;
|
|
271
|
+
}(Connectable));
|
|
272
|
+
export { PortalManager };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
var __values = (this && this.__values) || function(o) {
|
|
15
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
16
|
+
if (m) return m.call(o);
|
|
17
|
+
if (o && typeof o.length === "number") return {
|
|
18
|
+
next: function () {
|
|
19
|
+
if (o && i >= o.length) o = void 0;
|
|
20
|
+
return { value: o && o[i++], done: !o };
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
24
|
+
};
|
|
25
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
26
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
27
|
+
if (!m) return o;
|
|
28
|
+
var i = m.call(o), r, ar = [], e;
|
|
29
|
+
try {
|
|
30
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
31
|
+
}
|
|
32
|
+
catch (error) { e = { error: error }; }
|
|
33
|
+
finally {
|
|
34
|
+
try {
|
|
35
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
36
|
+
}
|
|
37
|
+
finally { if (e) throw e.error; }
|
|
38
|
+
}
|
|
39
|
+
return ar;
|
|
40
|
+
};
|
|
41
|
+
var __spread = (this && this.__spread) || function () {
|
|
42
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
43
|
+
return ar;
|
|
44
|
+
};
|
|
45
|
+
import { Connectable } from '../Connectable';
|
|
46
|
+
var PortalStore = /** @class */ (function (_super) {
|
|
47
|
+
__extends(PortalStore, _super);
|
|
48
|
+
function PortalStore() {
|
|
49
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
50
|
+
_this._portalMap = new Map();
|
|
51
|
+
_this._batchMode = false;
|
|
52
|
+
return _this;
|
|
53
|
+
}
|
|
54
|
+
Object.defineProperty(PortalStore.prototype, "size", {
|
|
55
|
+
get: function () {
|
|
56
|
+
return this._portalMap.size;
|
|
57
|
+
},
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(PortalStore.prototype, "lastPortal", {
|
|
62
|
+
get: function () {
|
|
63
|
+
var e_1, _a;
|
|
64
|
+
var lastPortal;
|
|
65
|
+
try {
|
|
66
|
+
for (var _b = __values(this.portals), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
67
|
+
var portal = _c.value;
|
|
68
|
+
lastPortal = portal;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
72
|
+
finally {
|
|
73
|
+
try {
|
|
74
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
75
|
+
}
|
|
76
|
+
finally { if (e_1) throw e_1.error; }
|
|
77
|
+
}
|
|
78
|
+
return lastPortal;
|
|
79
|
+
},
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(PortalStore.prototype, "portals", {
|
|
84
|
+
get: function () {
|
|
85
|
+
return this._portalMap.values();
|
|
86
|
+
},
|
|
87
|
+
enumerable: true,
|
|
88
|
+
configurable: true
|
|
89
|
+
});
|
|
90
|
+
PortalStore.prototype.addOrUpdate = function (portal) {
|
|
91
|
+
this._portalMap.set(portal.id, portal);
|
|
92
|
+
if (!this._batchMode)
|
|
93
|
+
this._emitChanges();
|
|
94
|
+
};
|
|
95
|
+
PortalStore.prototype.delete = function (id) {
|
|
96
|
+
this._portalMap.delete(id);
|
|
97
|
+
if (!this._batchMode)
|
|
98
|
+
this._emitChanges();
|
|
99
|
+
};
|
|
100
|
+
PortalStore.prototype.clear = function () {
|
|
101
|
+
this._portalMap.clear();
|
|
102
|
+
if (!this._batchMode)
|
|
103
|
+
this._emitChanges();
|
|
104
|
+
};
|
|
105
|
+
PortalStore.prototype.has = function (id) {
|
|
106
|
+
return this._portalMap.has(id);
|
|
107
|
+
};
|
|
108
|
+
PortalStore.prototype.get = function (id) {
|
|
109
|
+
return this._portalMap.get(id);
|
|
110
|
+
};
|
|
111
|
+
PortalStore.prototype.batch = function (handle) {
|
|
112
|
+
this._batchMode = true;
|
|
113
|
+
try {
|
|
114
|
+
handle(this);
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
this._batchMode = false;
|
|
118
|
+
this._emitChanges();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* just notify portal host rerender view
|
|
123
|
+
*/
|
|
124
|
+
PortalStore.prototype.forceEmit = function () {
|
|
125
|
+
this._emitChanges();
|
|
126
|
+
};
|
|
127
|
+
PortalStore.prototype._emitChanges = function () {
|
|
128
|
+
this.emit(__spread(this.portals));
|
|
129
|
+
};
|
|
130
|
+
return PortalStore;
|
|
131
|
+
}(Connectable));
|
|
132
|
+
export { PortalStore };
|