@web-atoms/core 2.6.21 → 2.6.25
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/App.d.ts +1 -1
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js.map +1 -1
- package/dist/core/SingleInvoker.d.ts.map +1 -1
- package/dist/core/SingleInvoker.js.map +1 -1
- package/dist/core/sleep.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist-esm/App.d.ts +1 -1
- package/dist-esm/App.d.ts.map +1 -1
- package/dist-esm/App.js +231 -235
- package/dist-esm/App.js.map +1 -1
- package/dist-esm/Atom.js +93 -96
- package/dist-esm/MockApp.js +17 -18
- package/dist-esm/Pack.js +1 -3
- package/dist-esm/core/AtomBinder.js +189 -187
- package/dist-esm/core/AtomComponent.js +479 -502
- package/dist-esm/core/AtomDispatcher.js +46 -48
- package/dist-esm/core/AtomDisposableList.js +24 -25
- package/dist-esm/core/AtomEnumerator.js +15 -16
- package/dist-esm/core/AtomList.js +193 -192
- package/dist-esm/core/AtomLoader.js +229 -215
- package/dist-esm/core/AtomMap.js +7 -8
- package/dist-esm/core/AtomOnce.js +22 -24
- package/dist-esm/core/AtomSelectableList.js +240 -243
- package/dist-esm/core/AtomUri.js +70 -72
- package/dist-esm/core/AtomWatcher.js +105 -111
- package/dist-esm/core/Bind.js +271 -269
- package/dist-esm/core/BindableProperty.js +26 -27
- package/dist-esm/core/CancelTokenFactory.js +21 -24
- package/dist-esm/core/Color.js +1 -2
- package/dist-esm/core/Colors.js +545 -231
- package/dist-esm/core/Command.js +236 -223
- package/dist-esm/core/Defer.js +21 -22
- package/dist-esm/core/EventScope.js +96 -88
- package/dist-esm/core/ExpressionParser.js +132 -144
- package/dist-esm/core/ExtendControl.js +7 -8
- package/dist-esm/core/FormattedError.js +7 -8
- package/dist-esm/core/FormattedString.js +4 -5
- package/dist-esm/core/Hacks.js +41 -42
- package/dist-esm/core/IFetchEvent.js +1 -2
- package/dist-esm/core/IScreen.js +1 -2
- package/dist-esm/core/IValueConverter.js +1 -2
- package/dist-esm/core/InheritedProperty.js +61 -63
- package/dist-esm/core/InjectProperty.js +12 -13
- package/dist-esm/core/KeyValuePairs.js +1 -2
- package/dist-esm/core/Markdown.js +14 -17
- package/dist-esm/core/MarkdownError.js +6 -7
- package/dist-esm/core/PropertyBinding.js +1 -2
- package/dist-esm/core/PropertyMap.js +28 -27
- package/dist-esm/core/Route.js +149 -148
- package/dist-esm/core/SingleInvoker.d.ts.map +1 -1
- package/dist-esm/core/SingleInvoker.js +32 -35
- package/dist-esm/core/SingleInvoker.js.map +1 -1
- package/dist-esm/core/StringHelper.js +49 -51
- package/dist-esm/core/TransientDisposable.js +14 -16
- package/dist-esm/core/WatchProperty.js +18 -17
- package/dist-esm/core/WebImage.js +7 -8
- package/dist-esm/core/XNode.js +134 -117
- package/dist-esm/core/sleep.js +21 -24
- package/dist-esm/core/sleep.js.map +1 -1
- package/dist-esm/core/types.js +102 -103
- package/dist-esm/di/DISingleton.js +7 -5
- package/dist-esm/di/DITransient.js +7 -5
- package/dist-esm/di/IMockOrInject.js +1 -2
- package/dist-esm/di/IServiceProvider.js +1 -2
- package/dist-esm/di/Inject.js +67 -67
- package/dist-esm/di/Register.js +25 -26
- package/dist-esm/di/RegisterScoped.js +4 -3
- package/dist-esm/di/RegisterSingleton.js +4 -3
- package/dist-esm/di/ServiceCollection.js +38 -37
- package/dist-esm/di/ServiceProvider.js +94 -94
- package/dist-esm/di/TypeKey.js +13 -12
- package/dist-esm/services/BusyIndicatorService.js +7 -11
- package/dist-esm/services/CacheService.js +54 -62
- package/dist-esm/services/FetchBuilder.js +327 -278
- package/dist-esm/services/JsonService.js +118 -116
- package/dist-esm/services/MockNavigationService.js +127 -126
- package/dist-esm/services/NavigationService.js +95 -102
- package/dist-esm/services/ReferenceService.js +30 -33
- package/dist-esm/services/http/AjaxOptions.js +1 -3
- package/dist-esm/services/http/JsonError.js +16 -15
- package/dist-esm/services/http/RestService.js +314 -323
- package/dist-esm/style/StyleRule.js +1 -2
- package/dist-esm/test.js +0 -1
- package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist-esm/unit/AtomTest.js +10 -11
- package/dist-esm/view-model/Action.js +258 -223
- package/dist-esm/view-model/AtomViewModel.js +234 -232
- package/dist-esm/view-model/AtomWindowViewModel.js +13 -14
- package/dist-esm/view-model/BindableUrlParameter.js +7 -8
- package/dist-esm/view-model/Delay.js +21 -25
- package/dist-esm/view-model/Disposable.js +28 -29
- package/dist-esm/view-model/Load.js +72 -73
- package/dist-esm/view-model/Once.js +33 -35
- package/dist-esm/view-model/baseTypes.js +4 -5
- package/dist-esm/view-model/bindPromise.js +24 -27
- package/dist-esm/view-model/bindProperty.js +3 -4
- package/dist-esm/view-model/bindUrlParameter.js +39 -43
- package/dist-esm/web/controls/AtomComboBox.js +56 -63
- package/dist-esm/web/controls/AtomControl.js +485 -490
- package/dist-esm/web/controls/AtomGridSplitter.js +57 -50
- package/dist-esm/web/controls/AtomGridView.js +230 -222
- package/dist-esm/web/controls/AtomItemsControl.js +677 -688
- package/dist-esm/web/controls/AtomPage.js +6 -7
- package/dist-esm/web/controls/AtomTemplate.js +1 -3
- package/dist-esm/web/controls/AtomTemplateControl.js +28 -29
- package/dist-esm/web/controls/AtomViewStack.js +19 -20
- package/dist-esm/web/core/AtomUI.js +200 -200
- package/dist-esm/web/core/Encoder.js +142 -152
- package/dist-esm/web/core/HtmlNode.js +141 -139
- package/dist-esm/web/images/Busy.js +1 -2
- package/dist-esm/web/images/BusyDataUrl.js +2 -869
- package/dist-esm/web/images/Button.js +1 -2
- package/dist-esm/web/images/ButtonDataUrl.js +2 -30
- package/dist-esm/web/images/CloseButton.js +1 -2
- package/dist-esm/web/images/CloseButtonDataUrl.js +2 -30
- package/dist-esm/web/images/CloseButtonHover.js +1 -2
- package/dist-esm/web/images/CloseButtonHoverDataUrl.js +2 -24
- package/dist-esm/web/services/LastTarget.js +31 -29
- package/dist-esm/web/services/MarkdownService.js +19 -31
- package/dist-esm/web/services/NotificationPopup.js +28 -21
- package/dist-esm/web/services/PopupService.js +512 -478
- package/dist-esm/web/services/PopupWindow.js +266 -247
- package/dist-esm/web/styles/AtomAlertWindowStyle.js +39 -40
- package/dist-esm/web/styles/AtomFrameStyle.js +15 -16
- package/dist-esm/web/styles/AtomNotificationStyle.js +19 -20
- package/dist-esm/web/styles/AtomPageLinkStyle.js +11 -12
- package/dist-esm/web/styles/AtomPopupStyle.js +9 -10
- package/dist-esm/web/styles/AtomStyle.js +61 -64
- package/dist-esm/web/styles/AtomStyleSheet.js +50 -51
- package/dist-esm/web/styles/AtomWindowStyle.js +116 -117
- package/dist-esm/web/styles/IStyleDeclaration.js +1 -2
- package/dist-esm/web/styles/StyleBuilder.js +79 -80
- package/package.json +3 -1
- package/src/App.ts +1 -1
- package/src/core/SingleInvoker.ts +1 -1
- package/src/core/sleep.ts +1 -1
|
@@ -5,522 +5,556 @@ import XNode from "../../core/XNode.js";
|
|
|
5
5
|
import { AtomControl } from "../controls/AtomControl.js";
|
|
6
6
|
import { LastTarget } from "./LastTarget.js";
|
|
7
7
|
import NotificationPopup from "./NotificationPopup.js";
|
|
8
|
-
import
|
|
8
|
+
ESMPack.installStyleSheet(import.meta.resolve("./PopupService.global.css"));
|
|
9
9
|
import PopupWindowA, { ConfirmPopup } from "./PopupWindow.js";
|
|
10
10
|
export var NotifyType;
|
|
11
11
|
(function (NotifyType) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
NotifyType["Information"] = "info";
|
|
13
|
+
NotifyType["Warning"] = "warn";
|
|
14
|
+
NotifyType["Error"] = "error";
|
|
15
15
|
})(NotifyType || (NotifyType = {}));
|
|
16
16
|
export const PopupWindow = PopupWindowA;
|
|
17
|
-
document.body.addEventListener("click",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
document.body.addEventListener("click", e => {
|
|
18
|
+
if (e.target.offsetParent) {
|
|
19
|
+
PopupService.lastTarget = e.target;
|
|
20
|
+
}
|
|
21
21
|
});
|
|
22
22
|
const popupCss = "web-atoms-popup-local";
|
|
23
23
|
export class PopupControl extends AtomControl {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
24
|
+
static showControl(opener, {
|
|
25
|
+
onClick = "close",
|
|
26
|
+
...options
|
|
27
|
+
} = {}) {
|
|
28
|
+
let openerElement = options?.parentElement;
|
|
29
|
+
let app;
|
|
30
|
+
if (opener instanceof AtomControl) {
|
|
31
|
+
openerElement ??= opener.element;
|
|
32
|
+
app = opener.app;
|
|
33
|
+
} else {
|
|
34
|
+
openerElement ??= opener;
|
|
35
|
+
let start = opener;
|
|
36
|
+
while (!start.atomControl) {
|
|
37
|
+
start = start.parentElement;
|
|
38
|
+
}
|
|
39
|
+
if (!start) {
|
|
40
|
+
return Promise.reject("Could not create popup as target is not attached");
|
|
41
|
+
}
|
|
42
|
+
app = start.atomControl.app;
|
|
43
|
+
}
|
|
44
|
+
const popup = new this(app);
|
|
45
|
+
if (onClick === "close") {
|
|
46
|
+
popup.bindEvent(popup.element, "click", () => setTimeout(() => popup.close(), 10));
|
|
47
|
+
} else if (onClick === "cancel") {
|
|
48
|
+
popup.bindEvent(popup.element, "click", () => setTimeout(() => popup.cancel(), 10));
|
|
49
|
+
}
|
|
50
|
+
const p = PopupService.show(openerElement, popup.element, options);
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
let resolved = false;
|
|
53
|
+
popup.close = r => {
|
|
54
|
+
if (resolved) {
|
|
55
|
+
return;
|
|
45
56
|
}
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
resolved = true;
|
|
58
|
+
PopupService.lastTarget = openerElement;
|
|
59
|
+
resolve(r);
|
|
60
|
+
p.dispose();
|
|
61
|
+
};
|
|
62
|
+
popup.cancel = e => {
|
|
63
|
+
if (resolved) {
|
|
64
|
+
return;
|
|
48
65
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
resolved = true;
|
|
57
|
-
PopupService.lastTarget = openerElement;
|
|
58
|
-
resolve(r);
|
|
59
|
-
p.dispose();
|
|
60
|
-
};
|
|
61
|
-
popup.cancel = (e) => {
|
|
62
|
-
if (resolved) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
resolved = true;
|
|
66
|
-
PopupService.lastTarget = openerElement;
|
|
67
|
-
reject(e);
|
|
68
|
-
p.dispose();
|
|
69
|
-
};
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
66
|
+
resolved = true;
|
|
67
|
+
PopupService.lastTarget = openerElement;
|
|
68
|
+
reject(e);
|
|
69
|
+
p.dispose();
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
}
|
|
72
73
|
}
|
|
73
74
|
function findHostAndPosition(opener) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
75
|
+
let root = opener;
|
|
76
|
+
const body = document.body;
|
|
77
|
+
let rect = opener.getBoundingClientRect();
|
|
78
|
+
const offset = {
|
|
79
|
+
x: rect.left,
|
|
80
|
+
y: rect.top,
|
|
81
|
+
handler: null,
|
|
82
|
+
root
|
|
83
|
+
};
|
|
84
|
+
do {
|
|
85
|
+
root = root.parentElement;
|
|
86
|
+
if (root === body) {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
if (root.parentElement.classList.contains("page-host")) {
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
if (root.classList.contains("popup-host")) {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (root.getAttribute("data-pop-up-host") === "yes") {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
} while (true);
|
|
99
|
+
rect = root.getBoundingClientRect();
|
|
100
|
+
offset.x -= rect.x;
|
|
101
|
+
offset.y -= rect.y;
|
|
102
|
+
offset.root = root;
|
|
103
|
+
return offset;
|
|
103
104
|
}
|
|
104
105
|
function findHost(opener, offset) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
if (host.classList.contains("popup-host")) {
|
|
112
|
-
return host;
|
|
113
|
-
}
|
|
114
|
-
if (host.dataset.popUpHost === "yes") {
|
|
115
|
-
return host;
|
|
116
|
-
}
|
|
117
|
-
const parent = (host.offsetParent ?? host.parentElement);
|
|
118
|
-
host = parent;
|
|
119
|
-
if (host.classList.contains("page-host")) {
|
|
120
|
-
host = current;
|
|
121
|
-
return host;
|
|
122
|
-
}
|
|
123
|
-
if (!host) {
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
if (!offset) {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
offset.x += host.offsetLeft;
|
|
130
|
-
offset.y += host.offsetTop - (parent?.scrollTop ?? 0);
|
|
106
|
+
let host = opener.offsetParent;
|
|
107
|
+
while (host) {
|
|
108
|
+
const current = host;
|
|
109
|
+
if (host === document.body) {
|
|
110
|
+
return host;
|
|
131
111
|
}
|
|
132
|
-
|
|
112
|
+
if (host.classList.contains("popup-host")) {
|
|
113
|
+
return host;
|
|
114
|
+
}
|
|
115
|
+
if (host.dataset.popUpHost === "yes") {
|
|
116
|
+
return host;
|
|
117
|
+
}
|
|
118
|
+
const parent = host.offsetParent ?? host.parentElement;
|
|
119
|
+
host = parent;
|
|
120
|
+
if (host.classList.contains("page-host")) {
|
|
121
|
+
host = current;
|
|
122
|
+
return host;
|
|
123
|
+
}
|
|
124
|
+
if (!host) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (!offset) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
offset.x += host.offsetLeft;
|
|
131
|
+
offset.y += host.offsetTop - (parent?.scrollTop ?? 0);
|
|
132
|
+
}
|
|
133
|
+
return host ?? document.body;
|
|
133
134
|
}
|
|
134
|
-
export const disableContain =
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
ce = ce.parentElement;
|
|
135
|
+
export const disableContain = ce => {
|
|
136
|
+
const containNoneList = [];
|
|
137
|
+
while (ce) {
|
|
138
|
+
const style = window.getComputedStyle(ce);
|
|
139
|
+
const isNotNone = style.contain !== "none";
|
|
140
|
+
if (isNotNone) {
|
|
141
|
+
ce.setAttribute("data-force-contain", "none");
|
|
142
|
+
containNoneList.push(ce);
|
|
144
143
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
ce = ce.parentElement;
|
|
145
|
+
}
|
|
146
|
+
return () => {
|
|
147
|
+
for (const iterator of containNoneList) {
|
|
148
|
+
iterator.removeAttribute("data-force-contain");
|
|
149
|
+
}
|
|
150
|
+
};
|
|
150
151
|
};
|
|
151
152
|
function closeHandler(host, opener, container, close) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
153
|
+
let handler = null;
|
|
154
|
+
handler = e => {
|
|
155
|
+
if (container?.element) {
|
|
156
|
+
const ce = new CustomEvent("outsideClick", {
|
|
157
|
+
detail: e,
|
|
158
|
+
cancelable: true,
|
|
159
|
+
bubbles: true
|
|
160
|
+
});
|
|
161
|
+
container.element.dispatchEvent(ce);
|
|
162
|
+
if (ce.defaultPrevented) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
let start = e.target;
|
|
167
|
+
if (e.defaultPrevented) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
while (start) {
|
|
171
|
+
if (start === host) {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
if (start === opener) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (start === container.element) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
start = start.parentElement;
|
|
181
|
+
}
|
|
182
|
+
close();
|
|
183
|
+
e.preventDefault();
|
|
184
|
+
e.stopImmediatePropagation?.();
|
|
185
|
+
};
|
|
186
|
+
document.body.addEventListener("click", handler, true);
|
|
187
|
+
container.registerDisposable(() => document.body.removeEventListener("click", handler, true));
|
|
188
|
+
const onBack = e => {
|
|
189
|
+
e.preventDefault();
|
|
190
|
+
e.stopImmediatePropagation?.();
|
|
191
|
+
e.stopPropagation();
|
|
192
|
+
close();
|
|
193
|
+
};
|
|
194
|
+
window.addEventListener("backButton", onBack, true);
|
|
195
|
+
container.registerDisposable(() => window.removeEventListener("backButton", onBack, true));
|
|
196
|
+
setTimeout(() => {
|
|
197
|
+
container.registerDisposable(disableContain(container.element));
|
|
198
|
+
}, 10);
|
|
194
199
|
}
|
|
195
200
|
let popupId = 1001;
|
|
196
201
|
export default class PopupService {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
title
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
catch (e) {
|
|
232
|
-
if (CancelToken.isCancelled(e)) {
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
throw e;
|
|
202
|
+
static get lastTarget() {
|
|
203
|
+
return LastTarget.target;
|
|
204
|
+
}
|
|
205
|
+
static set lastTarget(v) {
|
|
206
|
+
LastTarget.target = v;
|
|
207
|
+
}
|
|
208
|
+
static async alert({
|
|
209
|
+
message,
|
|
210
|
+
detail,
|
|
211
|
+
title = "Alert",
|
|
212
|
+
yesLabel = "Ok"
|
|
213
|
+
}) {
|
|
214
|
+
try {
|
|
215
|
+
const isMsgXNode = message instanceof XNode;
|
|
216
|
+
const isDetailXNode = detail && detail instanceof XNode;
|
|
217
|
+
if (isMsgXNode) {
|
|
218
|
+
(message.attributes ??= {})["data-element"] = "message";
|
|
219
|
+
}
|
|
220
|
+
if (isDetailXNode) {
|
|
221
|
+
(detail.attributes ??= {})["data-element"] = "details";
|
|
222
|
+
}
|
|
223
|
+
const popup = class extends ConfirmPopup {
|
|
224
|
+
create() {
|
|
225
|
+
this.render(XNode.create("div", null, isMsgXNode ? message : XNode.create("div", {
|
|
226
|
+
"data-element": "message",
|
|
227
|
+
text: message
|
|
228
|
+
}), detail && (isDetailXNode ? detail : XNode.create("details", {
|
|
229
|
+
"data-element": "details"
|
|
230
|
+
}, XNode.create("pre", {
|
|
231
|
+
text: detail
|
|
232
|
+
})))));
|
|
236
233
|
}
|
|
234
|
+
};
|
|
235
|
+
return await popup.showModal({
|
|
236
|
+
parameters: {
|
|
237
|
+
message,
|
|
238
|
+
detail,
|
|
239
|
+
yesLabel,
|
|
240
|
+
noLabel: ""
|
|
241
|
+
},
|
|
242
|
+
title
|
|
243
|
+
});
|
|
244
|
+
} catch (e) {
|
|
245
|
+
if (CancelToken.isCancelled(e)) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
throw e;
|
|
237
249
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
title
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
catch (e) {
|
|
256
|
-
if (CancelToken.isCancelled(e)) {
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
throw e;
|
|
250
|
+
}
|
|
251
|
+
static async confirm({
|
|
252
|
+
message,
|
|
253
|
+
title = "Confirm",
|
|
254
|
+
yesLabel = "Yes",
|
|
255
|
+
noLabel = "No",
|
|
256
|
+
cancelLabel = null
|
|
257
|
+
}) {
|
|
258
|
+
try {
|
|
259
|
+
const popup = class extends ConfirmPopup {
|
|
260
|
+
create() {
|
|
261
|
+
this.render(XNode.create("div", null, message instanceof XNode ? message : XNode.create("div", {
|
|
262
|
+
text: message
|
|
263
|
+
})));
|
|
260
264
|
}
|
|
265
|
+
};
|
|
266
|
+
return await popup.showModal({
|
|
267
|
+
parameters: {
|
|
268
|
+
message,
|
|
269
|
+
yesLabel,
|
|
270
|
+
noLabel,
|
|
271
|
+
cancelLabel
|
|
272
|
+
},
|
|
273
|
+
title
|
|
274
|
+
});
|
|
275
|
+
} catch (e) {
|
|
276
|
+
if (CancelToken.isCancelled(e)) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
throw e;
|
|
261
280
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
element?.remove();
|
|
283
|
-
element = undefined;
|
|
284
|
-
PopupService.lastTarget = previousTarget;
|
|
285
|
-
try {
|
|
286
|
-
activeElement?.focus();
|
|
287
|
-
}
|
|
288
|
-
catch (error) {
|
|
289
|
-
console.error(error);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}, 1);
|
|
293
|
-
};
|
|
294
|
-
const cancel = (r) => {
|
|
295
|
-
setTimeout(() => {
|
|
296
|
-
if (!resolved) {
|
|
297
|
-
resolved = true;
|
|
298
|
-
setTimeout(reject, 1, r ?? "cancelled");
|
|
299
|
-
if (control.element) {
|
|
300
|
-
control.element.remove();
|
|
301
|
-
control.dispose();
|
|
302
|
-
}
|
|
303
|
-
element?.remove();
|
|
304
|
-
element = undefined;
|
|
305
|
-
PopupService.lastTarget = previousTarget;
|
|
306
|
-
try {
|
|
307
|
-
activeElement?.focus();
|
|
308
|
-
}
|
|
309
|
-
catch (error) {
|
|
310
|
-
console.error(error);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}, 1);
|
|
314
|
-
};
|
|
315
|
-
let isModal = false;
|
|
316
|
-
if (popupOptions) {
|
|
317
|
-
const { width, height, minHeight, maxHeight, minWidth, maxWidth, maximize, title, parameters, cancelToken, modal } = popupOptions;
|
|
318
|
-
if (title) {
|
|
319
|
-
vm.title = title;
|
|
320
|
-
}
|
|
321
|
-
let widthSet = false;
|
|
322
|
-
let heightSet = false;
|
|
323
|
-
if (maximize) {
|
|
324
|
-
element.setAttribute("data-maximize", "true");
|
|
325
|
-
widthSet = heightSet = true;
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
if (width) {
|
|
329
|
-
element.style.width = typeof width === "number" ? width + "px" : width;
|
|
330
|
-
widthSet = true;
|
|
331
|
-
}
|
|
332
|
-
if (height) {
|
|
333
|
-
element.style.height = typeof height === "number" ? height + "px" : height;
|
|
334
|
-
heightSet = true;
|
|
335
|
-
}
|
|
336
|
-
if (minWidth) {
|
|
337
|
-
element.style.minWidth = typeof minWidth === "number" ? minWidth + "px" : minWidth;
|
|
338
|
-
widthSet = true;
|
|
339
|
-
}
|
|
340
|
-
if (minHeight) {
|
|
341
|
-
element.style.minHeight = typeof minHeight === "number" ? minHeight + "px" : minHeight;
|
|
342
|
-
heightSet = true;
|
|
343
|
-
}
|
|
344
|
-
if (maxWidth) {
|
|
345
|
-
element.style.maxWidth = typeof maxWidth === "number" ? maxWidth + "px" : maxWidth;
|
|
346
|
-
widthSet = true;
|
|
347
|
-
}
|
|
348
|
-
if (maxHeight) {
|
|
349
|
-
element.style.maxHeight = typeof maxHeight === "number" ? maxHeight + "px" : maxHeight;
|
|
350
|
-
heightSet = true;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
if (!widthSet) {
|
|
354
|
-
element.setAttribute("data-no-width", "true");
|
|
355
|
-
}
|
|
356
|
-
if (!heightSet) {
|
|
357
|
-
element.setAttribute("data-no-height", "true");
|
|
358
|
-
}
|
|
359
|
-
if (parameters) {
|
|
360
|
-
for (const key in parameters) {
|
|
361
|
-
if (Object.prototype.hasOwnProperty.call(parameters, key)) {
|
|
362
|
-
const e = parameters[key];
|
|
363
|
-
vm[key] = e;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
const init = control.init;
|
|
367
|
-
if (init) {
|
|
368
|
-
const c = control.init();
|
|
369
|
-
if (c?.then) {
|
|
370
|
-
c.then(() => control.element.dispatchEvent(new CustomEvent("popupReady", { bubbles: true })), (error) => {
|
|
371
|
-
control.element.dispatchEvent(new CustomEvent("popupReady", { bubbles: true }));
|
|
372
|
-
if (!CancelToken.isCancelled(error)) {
|
|
373
|
-
console.error(error);
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
setTimeout(() => control.element.dispatchEvent(new CustomEvent("popupReady", { bubbles: true })), 1);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
382
|
-
setTimeout(() => control.element.dispatchEvent(new CustomEvent("popupReady", { bubbles: true })), 1);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
setTimeout(() => control.element.dispatchEvent(new CustomEvent("popupReady", { bubbles: true })), 1);
|
|
387
|
-
}
|
|
388
|
-
cancelToken?.registerForCancel(cancel);
|
|
389
|
-
isModal = modal;
|
|
281
|
+
}
|
|
282
|
+
static showWindow(opener, popupClass, popupOptions) {
|
|
283
|
+
return new Promise((resolve, reject) => {
|
|
284
|
+
const activeElement = document.activeElement;
|
|
285
|
+
const previousTarget = opener;
|
|
286
|
+
const parent = AtomControl.from(opener);
|
|
287
|
+
const control = new popupClass(parent.app, document.createElement("div"));
|
|
288
|
+
const vm = getOwnInheritedProperty(control, "viewModel") ?? ("parameters" in control ? control.parameters ??= {} : control);
|
|
289
|
+
let element = control.element;
|
|
290
|
+
element.style.zIndex = `${popupId++}`;
|
|
291
|
+
let resolved = false;
|
|
292
|
+
const close = r => {
|
|
293
|
+
setTimeout(() => {
|
|
294
|
+
if (!resolved) {
|
|
295
|
+
resolved = true;
|
|
296
|
+
setTimeout(resolve, 1, r);
|
|
297
|
+
if (control.element) {
|
|
298
|
+
control.element.remove();
|
|
299
|
+
control.dispose();
|
|
390
300
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
301
|
+
element?.remove();
|
|
302
|
+
element = undefined;
|
|
303
|
+
PopupService.lastTarget = previousTarget;
|
|
304
|
+
try {
|
|
305
|
+
activeElement?.focus();
|
|
306
|
+
} catch (error) {
|
|
307
|
+
console.error(error);
|
|
398
308
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
control.registerDisposable({
|
|
411
|
-
dispose: () => {
|
|
412
|
-
bg.remove();
|
|
413
|
-
window.removeEventListener("backButton", onBack, true);
|
|
414
|
-
}
|
|
415
|
-
});
|
|
309
|
+
}
|
|
310
|
+
}, 1);
|
|
311
|
+
};
|
|
312
|
+
const cancel = r => {
|
|
313
|
+
setTimeout(() => {
|
|
314
|
+
if (!resolved) {
|
|
315
|
+
resolved = true;
|
|
316
|
+
setTimeout(reject, 1, r ?? "cancelled");
|
|
317
|
+
if (control.element) {
|
|
318
|
+
control.element.remove();
|
|
319
|
+
control.dispose();
|
|
416
320
|
}
|
|
417
|
-
|
|
418
|
-
|
|
321
|
+
element?.remove();
|
|
322
|
+
element = undefined;
|
|
323
|
+
PopupService.lastTarget = previousTarget;
|
|
324
|
+
try {
|
|
325
|
+
activeElement?.focus();
|
|
326
|
+
} catch (error) {
|
|
327
|
+
console.error(error);
|
|
419
328
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
329
|
+
}
|
|
330
|
+
}, 1);
|
|
331
|
+
};
|
|
332
|
+
let isModal = false;
|
|
333
|
+
if (popupOptions) {
|
|
334
|
+
const {
|
|
335
|
+
width,
|
|
336
|
+
height,
|
|
337
|
+
minHeight,
|
|
338
|
+
maxHeight,
|
|
339
|
+
minWidth,
|
|
340
|
+
maxWidth,
|
|
341
|
+
maximize,
|
|
342
|
+
title,
|
|
343
|
+
parameters,
|
|
344
|
+
cancelToken,
|
|
345
|
+
modal
|
|
346
|
+
} = popupOptions;
|
|
347
|
+
if (title) {
|
|
348
|
+
vm.title = title;
|
|
430
349
|
}
|
|
431
|
-
|
|
432
|
-
|
|
350
|
+
let widthSet = false;
|
|
351
|
+
let heightSet = false;
|
|
352
|
+
if (maximize) {
|
|
353
|
+
element.setAttribute("data-maximize", "true");
|
|
354
|
+
widthSet = heightSet = true;
|
|
355
|
+
} else {
|
|
356
|
+
if (width) {
|
|
357
|
+
element.style.width = typeof width === "number" ? width + "px" : width;
|
|
358
|
+
widthSet = true;
|
|
359
|
+
}
|
|
360
|
+
if (height) {
|
|
361
|
+
element.style.height = typeof height === "number" ? height + "px" : height;
|
|
362
|
+
heightSet = true;
|
|
363
|
+
}
|
|
364
|
+
if (minWidth) {
|
|
365
|
+
element.style.minWidth = typeof minWidth === "number" ? minWidth + "px" : minWidth;
|
|
366
|
+
widthSet = true;
|
|
367
|
+
}
|
|
368
|
+
if (minHeight) {
|
|
369
|
+
element.style.minHeight = typeof minHeight === "number" ? minHeight + "px" : minHeight;
|
|
370
|
+
heightSet = true;
|
|
371
|
+
}
|
|
372
|
+
if (maxWidth) {
|
|
373
|
+
element.style.maxWidth = typeof maxWidth === "number" ? maxWidth + "px" : maxWidth;
|
|
374
|
+
widthSet = true;
|
|
375
|
+
}
|
|
376
|
+
if (maxHeight) {
|
|
377
|
+
element.style.maxHeight = typeof maxHeight === "number" ? maxHeight + "px" : maxHeight;
|
|
378
|
+
heightSet = true;
|
|
379
|
+
}
|
|
433
380
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
const previousTarget = opener;
|
|
437
|
-
const container = {
|
|
438
|
-
element: document.createElement("div"),
|
|
439
|
-
disposables: new AtomDisposableList(),
|
|
440
|
-
registerDisposable: null,
|
|
441
|
-
dispose: null,
|
|
442
|
-
};
|
|
443
|
-
container.registerDisposable = (f) => container.disposables.add(f);
|
|
444
|
-
let alignment = options?.alignment ?? "auto";
|
|
445
|
-
if (alignment === "auto") {
|
|
446
|
-
const rect = opener.getBoundingClientRect();
|
|
447
|
-
const w = window.visualViewport.width;
|
|
448
|
-
if (rect.left > w / 2) {
|
|
449
|
-
alignment = "bottomRight";
|
|
450
|
-
}
|
|
381
|
+
if (!widthSet) {
|
|
382
|
+
element.setAttribute("data-no-width", "true");
|
|
451
383
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
container.element._logicalParent = opener;
|
|
455
|
-
container.element.classList.add(popupStyle);
|
|
456
|
-
if (isCenterOfScreen) {
|
|
457
|
-
container.element.dataset.centerPopup = "center";
|
|
384
|
+
if (!heightSet) {
|
|
385
|
+
element.setAttribute("data-no-height", "true");
|
|
458
386
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
container.element.style.top = (opener.offsetTop + opener.offsetHeight) + "px";
|
|
465
|
-
container.element.style.right = "0px";
|
|
466
|
-
container.element.dataset.inlinePopup = "right";
|
|
467
|
-
opener.insertAdjacentElement("afterend", container.element);
|
|
468
|
-
break;
|
|
469
|
-
case "topRight":
|
|
470
|
-
case "right":
|
|
471
|
-
container.element.style.top = (opener.offsetTop) + "px";
|
|
472
|
-
container.element.style.left = (opener.offsetWidth) + "px";
|
|
473
|
-
opener.insertAdjacentElement("afterend", container.element);
|
|
474
|
-
break;
|
|
475
|
-
case "bottomLeft":
|
|
476
|
-
container.element.dataset.inlinePopup = "inline-left";
|
|
477
|
-
container.element.style.top = (opener.offsetTop + opener.offsetHeight) + "px";
|
|
478
|
-
opener.insertAdjacentElement("beforebegin", container.element);
|
|
479
|
-
break;
|
|
480
|
-
default:
|
|
481
|
-
container.element.style.top = (opener.offsetTop + opener.offsetHeight) + "px";
|
|
482
|
-
opener.insertAdjacentElement("afterend", container.element);
|
|
483
|
-
break;
|
|
484
|
-
}
|
|
485
|
-
};
|
|
486
|
-
if (opener.offsetParent !== opener.parentElement) {
|
|
487
|
-
opener.parentElement.style.position = "relative";
|
|
488
|
-
setTimeout(alignPopup, 5);
|
|
387
|
+
if (parameters) {
|
|
388
|
+
for (const key in parameters) {
|
|
389
|
+
if (Object.prototype.hasOwnProperty.call(parameters, key)) {
|
|
390
|
+
const e = parameters[key];
|
|
391
|
+
vm[key] = e;
|
|
489
392
|
}
|
|
490
|
-
|
|
491
|
-
|
|
393
|
+
}
|
|
394
|
+
const init = control.init;
|
|
395
|
+
if (init) {
|
|
396
|
+
const c = control.init();
|
|
397
|
+
if (c?.then) {
|
|
398
|
+
c.then(() => control.element.dispatchEvent(new CustomEvent("popupReady", {
|
|
399
|
+
bubbles: true
|
|
400
|
+
})), error => {
|
|
401
|
+
control.element.dispatchEvent(new CustomEvent("popupReady", {
|
|
402
|
+
bubbles: true
|
|
403
|
+
}));
|
|
404
|
+
if (!CancelToken.isCancelled(error)) {
|
|
405
|
+
console.error(error);
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
} else {
|
|
409
|
+
setTimeout(() => control.element.dispatchEvent(new CustomEvent("popupReady", {
|
|
410
|
+
bubbles: true
|
|
411
|
+
})), 1);
|
|
492
412
|
}
|
|
413
|
+
} else {
|
|
414
|
+
setTimeout(() => control.element.dispatchEvent(new CustomEvent("popupReady", {
|
|
415
|
+
bubbles: true
|
|
416
|
+
})), 1);
|
|
417
|
+
}
|
|
418
|
+
} else {
|
|
419
|
+
setTimeout(() => control.element.dispatchEvent(new CustomEvent("popupReady", {
|
|
420
|
+
bubbles: true
|
|
421
|
+
})), 1);
|
|
493
422
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
423
|
+
cancelToken?.registerForCancel(cancel);
|
|
424
|
+
isModal = modal;
|
|
425
|
+
}
|
|
426
|
+
const host = findHost(opener);
|
|
427
|
+
host.appendChild(control.element);
|
|
428
|
+
vm.cancel = cancel;
|
|
429
|
+
vm.close = close;
|
|
430
|
+
if (vm !== control) {
|
|
431
|
+
control.cancel = cancel;
|
|
432
|
+
control.close = close;
|
|
433
|
+
}
|
|
434
|
+
if (isModal) {
|
|
435
|
+
const bg = document.createElement("div");
|
|
436
|
+
bg.setAttribute("data-window-modal-background", "background");
|
|
437
|
+
host.appendChild(bg);
|
|
438
|
+
const onBack = e => {
|
|
439
|
+
e.preventDefault();
|
|
440
|
+
e.stopImmediatePropagation?.();
|
|
441
|
+
e.stopPropagation();
|
|
442
|
+
control.requestCancel?.();
|
|
512
443
|
};
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
444
|
+
window.addEventListener("backButton", onBack, true);
|
|
445
|
+
control.registerDisposable({
|
|
446
|
+
dispose: () => {
|
|
447
|
+
bg.remove();
|
|
448
|
+
window.removeEventListener("backButton", onBack, true);
|
|
449
|
+
}
|
|
517
450
|
});
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
451
|
+
} else {
|
|
452
|
+
closeHandler(host, opener, control, cancel);
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
static async notify(message, title, type, delay) {
|
|
457
|
+
try {
|
|
458
|
+
const notification = NotificationPopup({
|
|
459
|
+
message,
|
|
460
|
+
type
|
|
461
|
+
});
|
|
462
|
+
const cancelToken = new CancelToken(delay ?? 5000);
|
|
463
|
+
await notification.showWindow(notification, {
|
|
464
|
+
title,
|
|
465
|
+
cancelToken
|
|
466
|
+
});
|
|
467
|
+
} catch (ex) {
|
|
468
|
+
console.error(ex);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
static show(opener, popup, options) {
|
|
472
|
+
const previousTarget = opener;
|
|
473
|
+
const container = {
|
|
474
|
+
element: document.createElement("div"),
|
|
475
|
+
disposables: new AtomDisposableList(),
|
|
476
|
+
registerDisposable: null,
|
|
477
|
+
dispose: null
|
|
478
|
+
};
|
|
479
|
+
container.registerDisposable = f => container.disposables.add(f);
|
|
480
|
+
let alignment = options?.alignment ?? "auto";
|
|
481
|
+
if (alignment === "auto") {
|
|
482
|
+
const rect = opener.getBoundingClientRect();
|
|
483
|
+
const w = window.visualViewport.width;
|
|
484
|
+
if (rect.left > w / 2) {
|
|
485
|
+
alignment = "bottomRight";
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
const isCenterOfScreen = alignment === "centerOfScreen";
|
|
489
|
+
const popupStyle = options?.popupStyle ?? popupCss;
|
|
490
|
+
container.element._logicalParent = opener;
|
|
491
|
+
container.element.classList.add(popupStyle);
|
|
492
|
+
if (isCenterOfScreen) {
|
|
493
|
+
container.element.dataset.centerPopup = "center";
|
|
494
|
+
} else {
|
|
495
|
+
container.element.dataset.inlinePopup = "left";
|
|
496
|
+
const alignPopup = () => {
|
|
497
|
+
switch (alignment) {
|
|
498
|
+
case "bottomRight":
|
|
499
|
+
container.element.style.top = opener.offsetTop + opener.offsetHeight + "px";
|
|
500
|
+
container.element.style.right = "0px";
|
|
501
|
+
container.element.dataset.inlinePopup = "right";
|
|
502
|
+
opener.insertAdjacentElement("afterend", container.element);
|
|
503
|
+
break;
|
|
504
|
+
case "topRight":
|
|
505
|
+
case "right":
|
|
506
|
+
container.element.style.top = opener.offsetTop + "px";
|
|
507
|
+
container.element.style.left = opener.offsetWidth + "px";
|
|
508
|
+
opener.insertAdjacentElement("afterend", container.element);
|
|
509
|
+
break;
|
|
510
|
+
case "bottomLeft":
|
|
511
|
+
container.element.dataset.inlinePopup = "inline-left";
|
|
512
|
+
container.element.style.top = opener.offsetTop + opener.offsetHeight + "px";
|
|
513
|
+
opener.insertAdjacentElement("beforebegin", container.element);
|
|
514
|
+
break;
|
|
515
|
+
default:
|
|
516
|
+
container.element.style.top = opener.offsetTop + opener.offsetHeight + "px";
|
|
517
|
+
opener.insertAdjacentElement("afterend", container.element);
|
|
518
|
+
break;
|
|
521
519
|
}
|
|
522
|
-
|
|
520
|
+
};
|
|
521
|
+
if (opener.offsetParent !== opener.parentElement) {
|
|
522
|
+
opener.parentElement.style.position = "relative";
|
|
523
|
+
setTimeout(alignPopup, 5);
|
|
524
|
+
} else {
|
|
525
|
+
alignPopup();
|
|
526
|
+
}
|
|
523
527
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
528
|
+
const parent = AtomControl.from(opener);
|
|
529
|
+
if (popup instanceof XNode) {
|
|
530
|
+
parent.render(popup, container);
|
|
531
|
+
} else {
|
|
532
|
+
container.element.appendChild(popup);
|
|
533
|
+
}
|
|
534
|
+
const style = container.element.style;
|
|
535
|
+
style.zIndex = `${popupId++}`;
|
|
536
|
+
container.dispose = () => {
|
|
537
|
+
if (!container.disposables) {
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
container.disposables.dispose();
|
|
541
|
+
parent.dispose(container.element);
|
|
542
|
+
container.element.remove();
|
|
543
|
+
container.disposables = null;
|
|
544
|
+
PopupService.lastTarget = previousTarget;
|
|
545
|
+
};
|
|
546
|
+
closeHandler(opener.parentElement, opener, container, () => {
|
|
547
|
+
const e = container.element;
|
|
548
|
+
container.dispose();
|
|
549
|
+
e.remove();
|
|
550
|
+
});
|
|
551
|
+
const ct = options?.cancelToken;
|
|
552
|
+
if (ct) {
|
|
553
|
+
ct.registerForCancel(() => container.dispose());
|
|
554
|
+
}
|
|
555
|
+
return container;
|
|
556
|
+
}
|
|
557
|
+
static {
|
|
558
|
+
this.targetPath = [];
|
|
559
|
+
}
|
|
560
|
+
}
|