@web-atoms/web-controls 2.6.5 → 2.6.7
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/html-editor/InlineHtmlEditor.d.ts +1 -1
- package/dist/html-editor/InlineHtmlEditor.d.ts.map +1 -1
- package/dist/html-editor/InlineHtmlEditor.js +2 -2
- package/dist/html-editor/InlineHtmlEditor.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist-esm/ArrayLike.js +14 -12
- package/dist-esm/DataAttributes.js +18 -19
- package/dist-esm/Focusable.js +10 -11
- package/dist-esm/ModuleFiles.js +43 -42
- package/dist-esm/NumberFormats.js +60 -56
- package/dist-esm/PageNavigator.js +28 -30
- package/dist-esm/animations/Animations.js +36 -33
- package/dist-esm/basic/AtomChips.js +312 -305
- package/dist-esm/basic/AtomRepeater.js +1070 -1035
- package/dist-esm/basic/AtomSuggestions.js +97 -107
- package/dist-esm/basic/AttachedPopup.js +0 -1
- package/dist-esm/basic/Button.js +45 -19
- package/dist-esm/basic/ButtonBar.js +84 -64
- package/dist-esm/basic/Calendar.js +211 -203
- package/dist-esm/basic/CheckBoxList.js +90 -70
- package/dist-esm/basic/Checkbox.js +16 -8
- package/dist-esm/basic/Chip.js +36 -12
- package/dist-esm/basic/ComboBox.js +47 -51
- package/dist-esm/basic/DataGrid.js +258 -252
- package/dist-esm/basic/DateField.js +149 -127
- package/dist-esm/basic/DropDown.js +91 -103
- package/dist-esm/basic/DropDownInput.js +78 -106
- package/dist-esm/basic/Editable.js +82 -77
- package/dist-esm/basic/Expander.js +104 -86
- package/dist-esm/basic/FilesDragDrop.js +84 -80
- package/dist-esm/basic/Form.js +80 -52
- package/dist-esm/basic/FormField.js +164 -106
- package/dist-esm/basic/IElement.js +1 -2
- package/dist-esm/basic/InlinePopup.js +263 -234
- package/dist-esm/basic/InlinePopupButton.js +99 -88
- package/dist-esm/basic/InlinePopupControl.js +24 -23
- package/dist-esm/basic/ItemPath.js +59 -60
- package/dist-esm/basic/LimitedText.js +49 -38
- package/dist-esm/basic/ListRepeater.js +13 -14
- package/dist-esm/basic/MaskedInput.js +37 -29
- package/dist-esm/basic/MaskedInputDiv.js +55 -48
- package/dist-esm/basic/MergeNode.js +64 -35
- package/dist-esm/basic/PasswordBox.js +32 -17
- package/dist-esm/basic/PinchZoomView.js +221 -199
- package/dist-esm/basic/PopupButton.js +39 -16
- package/dist-esm/basic/PopupMenu.js +3 -4
- package/dist-esm/basic/RadioButtonList.js +35 -25
- package/dist-esm/basic/RefreshLock.js +41 -42
- package/dist-esm/basic/Resizable.js +43 -33
- package/dist-esm/basic/Select.js +72 -65
- package/dist-esm/basic/SortByButton.js +41 -31
- package/dist-esm/basic/Swipe.js +91 -84
- package/dist-esm/basic/Switch.js +22 -8
- package/dist-esm/basic/TableRepeater.js +29 -33
- package/dist-esm/basic/TimeEditor.js +97 -52
- package/dist-esm/basic/TitleEditor.js +115 -95
- package/dist-esm/basic/ToggleButtonBar.js +21 -22
- package/dist-esm/basic/Tooltip.js +49 -47
- package/dist-esm/basic/TypeWriter.js +45 -42
- package/dist-esm/basic/UploadEvent.js +211 -178
- package/dist-esm/basic/ZoomView.js +229 -198
- package/dist-esm/basic/combineClasses.js +2 -3
- package/dist-esm/basic/elements/AtomPopover.js +270 -253
- package/dist-esm/basic/elements/getContainingBlock.js +34 -35
- package/dist-esm/basic/elements/relativeRect.js +40 -21
- package/dist-esm/desktop-app/DesktopApp.js +65 -80
- package/dist-esm/desktop-app/MobileDesktopApp.js +20 -23
- package/dist-esm/html-editor/AtomHtmlEditor.js +243 -268
- package/dist-esm/html-editor/HtmlEditorCommands.js +6 -4
- package/dist-esm/html-editor/InlineHtmlEditor.d.ts +1 -1
- package/dist-esm/html-editor/InlineHtmlEditor.d.ts.map +1 -1
- package/dist-esm/html-editor/InlineHtmlEditor.js +175 -167
- package/dist-esm/html-editor/InlineHtmlEditor.js.map +1 -1
- package/dist-esm/html-editor/RangeEditor.js +49 -51
- package/dist-esm/html-editor/commands/AddImage.js +40 -35
- package/dist-esm/html-editor/commands/AddLink.js +56 -54
- package/dist-esm/html-editor/commands/Align.js +24 -7
- package/dist-esm/html-editor/commands/AttachFile.js +23 -13
- package/dist-esm/html-editor/commands/AttachImage.js +35 -25
- package/dist-esm/html-editor/commands/Bold.js +10 -11
- package/dist-esm/html-editor/commands/ChangeColor.js +31 -107
- package/dist-esm/html-editor/commands/ChangeFont.js +42 -42
- package/dist-esm/html-editor/commands/ChangeFontSize.js +15 -5
- package/dist-esm/html-editor/commands/Command.js +34 -16
- package/dist-esm/html-editor/commands/CommandButton.js +51 -32
- package/dist-esm/html-editor/commands/Headings.js +25 -9
- package/dist-esm/html-editor/commands/HorizontalRule.js +9 -10
- package/dist-esm/html-editor/commands/HtmlCommands.js +160 -65
- package/dist-esm/html-editor/commands/IndentLess.js +10 -11
- package/dist-esm/html-editor/commands/IndentMore.js +10 -11
- package/dist-esm/html-editor/commands/Italic.js +10 -11
- package/dist-esm/html-editor/commands/NumberedList.js +10 -11
- package/dist-esm/html-editor/commands/Quote.js +10 -11
- package/dist-esm/html-editor/commands/RemoveFormat.js +10 -11
- package/dist-esm/html-editor/commands/Separator.js +5 -4
- package/dist-esm/html-editor/commands/Source.js +29 -25
- package/dist-esm/html-editor/commands/StrikeThrough.js +10 -11
- package/dist-esm/html-editor/commands/Toolbar.js +6 -4
- package/dist-esm/html-editor/commands/Underline.js +10 -11
- package/dist-esm/html-editor/commands/Unlink.js +10 -9
- package/dist-esm/html-editor/commands/UnorderedList.js +10 -11
- package/dist-esm/mobile-app/BottomPopup.js +137 -148
- package/dist-esm/mobile-app/MasterDetailPage.js +153 -152
- package/dist-esm/mobile-app/MobileApp.js +577 -569
- package/dist-esm/player/AtomVideoPlayer.js +316 -270
- package/dist-esm/player/TrackProgress.js +11 -7
- package/dist-esm/player/input-range-style.js +97 -98
- package/dist-esm/tests/app-test/AppTestApp.js +12 -15
- package/dist-esm/tests/app-test/AppTestApp.pack.js +54 -0
- package/dist-esm/tests/app-test/commands/AppCommands.js +14 -11
- package/dist-esm/tests/app-test/drawer/AppDrawer.js +4 -6
- package/dist-esm/tests/app-test/model/model.js +1 -2
- package/dist-esm/tests/app-test/pages/detail/DetailPage.js +21 -15
- package/dist-esm/tests/app-test/pages/home/HomePage.js +7 -8
- package/dist-esm/tests/app-test/pages/list/ListPage.js +79 -62
- package/dist-esm/tests/basic/PopupTest.js +9 -7
- package/dist-esm/tests/basic/TimeEditorTest.js +5 -9
- package/dist-esm/tests/basic/TimeEditorTest.pack.js +39 -0
- package/dist-esm/tests/basic/TimerTest.js +27 -37
- package/dist-esm/tests/basic/TimerTest.pack.js +40 -0
- package/dist-esm/tests/basic/basic-form/BasicForm.js +47 -27
- package/dist-esm/tests/basic/basic-form/BasicForm.pack.js +44 -0
- package/dist-esm/tests/basic/calendar/BasicCalendarTest.js +5 -9
- package/dist-esm/tests/basic/calendar/BasicCalendarTest.pack.js +53 -0
- package/dist-esm/tests/basic/chips/ChipsTest.js +25 -15
- package/dist-esm/tests/basic/chips/ChipsTest.pack.js +56 -0
- package/dist-esm/tests/basic/data-grid/DataGridTest.js +55 -60
- package/dist-esm/tests/basic/data-grid/DataGridTest.pack.js +58 -0
- package/dist-esm/tests/basic/date/DateFieldTest.js +21 -96
- package/dist-esm/tests/basic/date/DateFieldTest.pack.js +57 -0
- package/dist-esm/tests/basic/drop-down/DropDownTest.js +25 -19
- package/dist-esm/tests/basic/drop-down/DropDownTest.pack.js +52 -0
- package/dist-esm/tests/basic/drop-down-input/DropDownTest.js +32 -32
- package/dist-esm/tests/basic/drop-down-input/DropDownTest.pack.js +54 -0
- package/dist-esm/tests/basic/expander/ExpanderMenuTest.js +20 -14
- package/dist-esm/tests/basic/expander/ExpanderMenuTest.pack.js +38 -0
- package/dist-esm/tests/basic/expander/ExpanderTest.js +11 -12
- package/dist-esm/tests/basic/expander/ExpanderTest.pack.js +38 -0
- package/dist-esm/tests/basic/form2/Form2Test.js +26 -24
- package/dist-esm/tests/basic/form2/Form2Test.pack.js +46 -0
- package/dist-esm/tests/basic/limited-text/LimitedTextTest.js +14 -11
- package/dist-esm/tests/basic/limited-text/LimitedTextTest.pack.js +38 -0
- package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.js +14 -14
- package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.pack.js +38 -0
- package/dist-esm/tests/basic/repeater/DragDropRepater.js +30 -12
- package/dist-esm/tests/basic/repeater/DragDropRepater.pack.js +51 -0
- package/dist-esm/tests/basic/repeater/RepeaterTest.js +45 -35
- package/dist-esm/tests/basic/repeater/RepeaterTest.pack.js +52 -0
- package/dist-esm/tests/basic/swipe/SwipeTest.js +13 -13
- package/dist-esm/tests/basic/swipe/SwipeTest.pack.js +52 -0
- package/dist-esm/tests/basic/switch-test/SwitchTest.js +8 -10
- package/dist-esm/tests/basic/switch-test/SwitchTest.pack.js +38 -0
- package/dist-esm/tests/basic/title-editor/TitleEditorTest.js +8 -9
- package/dist-esm/tests/basic/title-editor/TitleEditorTest.pack.js +38 -0
- package/dist-esm/tests/basic/tooltip/TooltipTest.js +30 -24
- package/dist-esm/tests/basic/tooltip/TooltipTest.pack.js +52 -0
- package/dist-esm/tests/basic/typewriter/TypeWriter.js +10 -9
- package/dist-esm/tests/basic/typewriter/TypeWriter.pack.js +39 -0
- package/dist-esm/tests/basic/video/AtomVideoTest.js +13 -10
- package/dist-esm/tests/basic/video/AtomVideoTest.pack.js +38 -0
- package/dist-esm/tests/basic/zoom/ZoomViewTest.js +13 -13
- package/dist-esm/tests/basic/zoom/ZoomViewTest.pack.js +38 -0
- package/dist-esm/tests/check-box-list/CheckBoxListSample.js +13 -12
- package/dist-esm/tests/check-box-list/CheckBoxListSample.pack.js +52 -0
- package/dist-esm/tests/data-grid/GridTestViewModel.js +203 -227
- package/dist-esm/tests/form/CustomHelp.js +6 -9
- package/dist-esm/tests/form/FormViewModel.js +21 -28
- package/dist-esm/tests/html-editor/HtmlEditorTest.js +7 -37
- package/dist-esm/tests/html-editor/HtmlEditorTest.pack.js +83 -0
- package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.js +9 -38
- package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.pack.js +85 -0
- package/dist-esm/tests/mask/MaskedInputTest.js +11 -12
- package/dist-esm/tests/mask/MaskedInputTest.pack.js +38 -0
- package/dist-esm/tests/mobile-app/DesktopAppTest.js +8 -9
- package/dist-esm/tests/mobile-app/DesktopAppTest.pack.js +60 -0
- package/dist-esm/tests/mobile-app/MobileAppTest.js +64 -53
- package/dist-esm/tests/mobile-app/MobileAppTest.pack.js +55 -0
- package/dist-esm/tests/pop-over/PopOverTest.js +37 -77
- package/dist-esm/tests/switch/SwitchTest.js +9 -8
- package/dist-esm/tests/toggle-view/ToggleViewTest.js +15 -22
- package/dist-esm/tests/toggle-view/ToggleViewTest.pack.js +45 -0
- package/dist-esm/toggle-view/AtomToggleView.js +77 -73
- package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/html-editor/InlineHtmlEditor.tsx +1 -1
|
@@ -2,255 +2,284 @@ import { AtomDisposableList } from "@web-atoms/core/dist/core/AtomDisposableList
|
|
|
2
2
|
import sleep from "@web-atoms/core/dist/core/sleep.js";
|
|
3
3
|
import XNode from "@web-atoms/core/dist/core/XNode.js";
|
|
4
4
|
import { AtomControl, ElementValueSetters } from "@web-atoms/core/dist/web/controls/AtomControl.js";
|
|
5
|
-
import
|
|
5
|
+
ESMPack.installStyleSheet(import.meta.resolve("./styles/inline-popup.global.css"));
|
|
6
6
|
import { StringHelper } from "@web-atoms/core/dist/core/StringHelper.js";
|
|
7
7
|
function closeHandler(opener, container, close) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
while (start) {
|
|
16
|
-
if (start === body) {
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
if (start === opener) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (start === container) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
start = start.parentElement;
|
|
26
|
-
}
|
|
27
|
-
close();
|
|
28
|
-
e.preventDefault();
|
|
29
|
-
e.stopImmediatePropagation?.();
|
|
30
|
-
};
|
|
31
|
-
document.body.addEventListener("click", handler, true);
|
|
32
|
-
let ce = container;
|
|
33
|
-
const containNoneList = [];
|
|
34
|
-
while (ce) {
|
|
35
|
-
const isNotNone = window.getComputedStyle(ce).contain !== "none";
|
|
36
|
-
if (isNotNone) {
|
|
37
|
-
ce.setAttribute("data-force-contain", "none");
|
|
38
|
-
containNoneList.push(ce);
|
|
39
|
-
}
|
|
40
|
-
ce = ce.parentElement;
|
|
8
|
+
let handler = null;
|
|
9
|
+
const body = document.body;
|
|
10
|
+
handler = e => {
|
|
11
|
+
let start = e.target;
|
|
12
|
+
if (e.defaultPrevented) {
|
|
13
|
+
return;
|
|
41
14
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const targetStyle = window.getComputedStyle(targetElement);
|
|
54
|
-
if (!/fixed|absolute|relative/i.test(targetStyle.position)) {
|
|
55
|
-
targetElement.style.position = "relative";
|
|
56
|
-
}
|
|
57
|
-
await sleep(10);
|
|
58
|
-
const container = document.createElement("div");
|
|
59
|
-
container.setAttribute("data-inline-popup", "inline-popup");
|
|
60
|
-
const alignment = StringHelper.fromHyphenToCamel(options.alignment || "none");
|
|
61
|
-
switch (alignment) {
|
|
62
|
-
case "bottomLeft":
|
|
63
|
-
container.style.top = `${5 + targetElement.offsetHeight}px`;
|
|
64
|
-
container.style.left = "5px";
|
|
65
|
-
break;
|
|
66
|
-
case "bottomRight":
|
|
67
|
-
container.style.top = `${5 + targetElement.offsetHeight}px`;
|
|
68
|
-
container.style.right = "5px";
|
|
69
|
-
break;
|
|
70
|
-
case "topRight":
|
|
71
|
-
container.style.top = "5px";
|
|
72
|
-
container.style.left = `${targetElement.offsetWidth}px`;
|
|
73
|
-
break;
|
|
74
|
-
case "above":
|
|
75
|
-
container.style.bottom = `${targetElement.offsetHeight}px`;
|
|
76
|
-
container.style.left = "5px";
|
|
77
|
-
break;
|
|
78
|
-
default:
|
|
79
|
-
container.style.top = `${5 + targetElement.offsetHeight}px`;
|
|
80
|
-
container.style.left = "5px";
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
container._logicalParent = targetElement;
|
|
84
|
-
control.render(XNode.create("div", null,
|
|
85
|
-
" ",
|
|
86
|
-
XNode.create("atom-popup-container", null, node),
|
|
87
|
-
" "), container, control);
|
|
88
|
-
targetElement.insertAdjacentElement("beforeend", container);
|
|
89
|
-
return await new Promise((resolve, reject) => {
|
|
90
|
-
const disposables = new AtomDisposableList();
|
|
91
|
-
disposables.add(() => targetElement.removeAttribute("data-popup-open"));
|
|
92
|
-
let resolved = false;
|
|
93
|
-
const close = (r) => {
|
|
94
|
-
if (resolved) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
resolved = true;
|
|
98
|
-
resolve(r);
|
|
99
|
-
disposables.dispose();
|
|
100
|
-
};
|
|
101
|
-
const cancel = (r = "cancelled") => {
|
|
102
|
-
if (resolved) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
resolved = true;
|
|
106
|
-
reject(r);
|
|
107
|
-
disposables.dispose();
|
|
108
|
-
};
|
|
109
|
-
const firstChild = container.firstElementChild.atomControl;
|
|
110
|
-
if (firstChild instanceof InlinePopup) {
|
|
111
|
-
firstChild.cancel = cancel;
|
|
112
|
-
firstChild.close = close;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
if (options.onClick === void 0) {
|
|
116
|
-
options.onClick = options.defaultOnClick;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
const defaultClose = options.onClick === "close" ? close : cancel;
|
|
120
|
-
const observer = new MutationObserver(() => {
|
|
121
|
-
if (!container.isConnected) {
|
|
122
|
-
defaultClose();
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
observer.observe(targetElement, { childList: true });
|
|
126
|
-
disposables.add(() => {
|
|
127
|
-
observer.disconnect();
|
|
128
|
-
control.dispose(container);
|
|
129
|
-
container.remove();
|
|
130
|
-
});
|
|
131
|
-
if (options.onClick) {
|
|
132
|
-
disposables.add(control.bindEvent(container, "click", async () => {
|
|
133
|
-
await sleep(200);
|
|
134
|
-
defaultClose();
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
137
|
-
options.cancelToken?.registerForCancel(cancel);
|
|
138
|
-
disposables.add(closeHandler(targetElement, container, defaultClose));
|
|
139
|
-
});
|
|
15
|
+
while (start) {
|
|
16
|
+
if (start === body) {
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
if (start === opener) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (start === container) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
start = start.parentElement;
|
|
140
26
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
27
|
+
close();
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
e.stopImmediatePropagation?.();
|
|
30
|
+
};
|
|
31
|
+
document.body.addEventListener("click", handler, true);
|
|
32
|
+
let ce = container;
|
|
33
|
+
const containNoneList = [];
|
|
34
|
+
while (ce) {
|
|
35
|
+
const isNotNone = window.getComputedStyle(ce).contain !== "none";
|
|
36
|
+
if (isNotNone) {
|
|
37
|
+
ce.setAttribute("data-force-contain", "none");
|
|
38
|
+
containNoneList.push(ce);
|
|
144
39
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
start = start.parentElement;
|
|
154
|
-
}
|
|
155
|
-
super.dispatchClickEvent(e, data);
|
|
40
|
+
ce = ce.parentElement;
|
|
41
|
+
}
|
|
42
|
+
return () => {
|
|
43
|
+
document.body.removeEventListener("click", handler, true);
|
|
44
|
+
for (const iterator of containNoneList) {
|
|
45
|
+
iterator.removeAttribute("data-force-contain");
|
|
156
46
|
}
|
|
47
|
+
};
|
|
157
48
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
alignment = start.dataset.alignment;
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
start = start.parentElement;
|
|
49
|
+
export default class InlinePopup extends AtomControl {
|
|
50
|
+
static async show(target, node, options = {}) {
|
|
51
|
+
const targetElement = target.element ?? target;
|
|
52
|
+
const control = target.element ? target : AtomControl.from(target);
|
|
53
|
+
const targetStyle = window.getComputedStyle(targetElement);
|
|
54
|
+
if (!/fixed|absolute|relative/i.test(targetStyle.position)) {
|
|
55
|
+
targetElement.style.position = "relative";
|
|
169
56
|
}
|
|
170
|
-
|
|
171
|
-
|
|
57
|
+
await sleep(10);
|
|
58
|
+
const container = document.createElement("div");
|
|
59
|
+
container.setAttribute("data-inline-popup", "inline-popup");
|
|
60
|
+
const alignment = StringHelper.fromHyphenToCamel(options.alignment || "none");
|
|
61
|
+
switch (alignment) {
|
|
62
|
+
case "bottomLeft":
|
|
63
|
+
container.style.top = `${5 + targetElement.offsetHeight}px`;
|
|
64
|
+
container.style.left = "5px";
|
|
65
|
+
break;
|
|
66
|
+
case "bottomRight":
|
|
67
|
+
container.style.top = `${5 + targetElement.offsetHeight}px`;
|
|
68
|
+
container.style.right = "5px";
|
|
69
|
+
break;
|
|
70
|
+
case "topRight":
|
|
71
|
+
container.style.top = "5px";
|
|
72
|
+
container.style.left = `${targetElement.offsetWidth}px`;
|
|
73
|
+
break;
|
|
74
|
+
case "above":
|
|
75
|
+
container.style.bottom = `${targetElement.offsetHeight}px`;
|
|
76
|
+
container.style.left = "5px";
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
container.style.top = `${5 + targetElement.offsetHeight}px`;
|
|
80
|
+
container.style.left = "5px";
|
|
81
|
+
break;
|
|
172
82
|
}
|
|
173
|
-
|
|
83
|
+
container._logicalParent = targetElement;
|
|
84
|
+
control.render(XNode.create("div", null, " ", XNode.create("atom-popup-container", null, node), " "), container, control);
|
|
85
|
+
targetElement.insertAdjacentElement("beforeend", container);
|
|
86
|
+
return await new Promise((resolve, reject) => {
|
|
87
|
+
const disposables = new AtomDisposableList();
|
|
88
|
+
disposables.add(() => targetElement.removeAttribute("data-popup-open"));
|
|
89
|
+
let resolved = false;
|
|
90
|
+
const close = r => {
|
|
91
|
+
if (resolved) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
resolved = true;
|
|
95
|
+
resolve(r);
|
|
96
|
+
disposables.dispose();
|
|
97
|
+
};
|
|
98
|
+
const cancel = (r = "cancelled") => {
|
|
99
|
+
if (resolved) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
resolved = true;
|
|
103
|
+
reject(r);
|
|
104
|
+
disposables.dispose();
|
|
105
|
+
};
|
|
106
|
+
const firstChild = container.firstElementChild.atomControl;
|
|
107
|
+
if (firstChild instanceof InlinePopup) {
|
|
108
|
+
firstChild.cancel = cancel;
|
|
109
|
+
firstChild.close = close;
|
|
110
|
+
} else {
|
|
111
|
+
if (options.onClick === void 0) {
|
|
112
|
+
options.onClick = options.defaultOnClick;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const defaultClose = options.onClick === "close" ? close : cancel;
|
|
116
|
+
const observer = new MutationObserver(() => {
|
|
117
|
+
if (!container.isConnected) {
|
|
118
|
+
defaultClose();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
observer.observe(targetElement, {
|
|
122
|
+
childList: true
|
|
123
|
+
});
|
|
124
|
+
disposables.add(() => {
|
|
125
|
+
observer.disconnect();
|
|
126
|
+
control.dispose(container);
|
|
127
|
+
container.remove();
|
|
128
|
+
});
|
|
129
|
+
if (options.onClick) {
|
|
130
|
+
disposables.add(control.bindEvent(container, "click", async () => {
|
|
131
|
+
await sleep(200);
|
|
132
|
+
defaultClose();
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
options.cancelToken?.registerForCancel(cancel);
|
|
136
|
+
disposables.add(closeHandler(targetElement, container, defaultClose));
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
static showControl(target, options = {}) {
|
|
140
|
+
const node = XNode.create(this, {});
|
|
141
|
+
return this.show(target, node, options);
|
|
142
|
+
}
|
|
143
|
+
dispatchClickEvent(e, data) {
|
|
144
|
+
let start = this.element.parentElement;
|
|
145
|
+
while (start) {
|
|
146
|
+
const atomControl = AtomControl.from(start);
|
|
147
|
+
if (atomControl) {
|
|
148
|
+
atomControl.dispatchClickEvent(e, data);
|
|
174
149
|
return;
|
|
150
|
+
}
|
|
151
|
+
start = start.parentElement;
|
|
175
152
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
start = start.parentElement;
|
|
191
|
-
}
|
|
153
|
+
super.dispatchClickEvent(e, data);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
document.body.addEventListener("click", e => {
|
|
157
|
+
let start = e.target;
|
|
158
|
+
let popupFactory;
|
|
159
|
+
let alignment;
|
|
160
|
+
while (start) {
|
|
161
|
+
popupFactory = start.popupFactory;
|
|
162
|
+
if (popupFactory) {
|
|
163
|
+
alignment = start.dataset.alignment;
|
|
164
|
+
break;
|
|
192
165
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
166
|
+
start = start.parentElement;
|
|
167
|
+
}
|
|
168
|
+
if (!start) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (start.getAttribute("data-popup-open")) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
start.setAttribute("data-popup-open", "true");
|
|
175
|
+
const control = AtomControl.from(start);
|
|
176
|
+
const app = control.app;
|
|
177
|
+
const target = start;
|
|
178
|
+
const element = control.element;
|
|
179
|
+
let itemIndex;
|
|
180
|
+
let data;
|
|
181
|
+
if (control.items && control.itemRenderer) {
|
|
182
|
+
while (start && start !== element) {
|
|
183
|
+
itemIndex ??= start.getAttribute("data-item-index");
|
|
184
|
+
if (itemIndex) {
|
|
185
|
+
data = control.items[~~itemIndex];
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
start = start.parentElement;
|
|
206
189
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
190
|
+
}
|
|
191
|
+
if (!data) {
|
|
192
|
+
data = new Proxy(target, {
|
|
193
|
+
get(t, p, receiver) {
|
|
194
|
+
let s = target;
|
|
195
|
+
while (s) {
|
|
196
|
+
const v = s.dataset[p];
|
|
197
|
+
if (v !== void 0) {
|
|
198
|
+
return v;
|
|
199
|
+
}
|
|
200
|
+
s = s.parentElement;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const node = popupFactory(data);
|
|
206
|
+
const defaultOnClick = target.getAttribute("data-default-on-click");
|
|
207
|
+
app.runAsync(() => InlinePopup.show(target, node, {
|
|
208
|
+
alignment,
|
|
209
|
+
defaultOnClick
|
|
210
|
+
}));
|
|
210
211
|
});
|
|
211
212
|
ElementValueSetters["data-popup-class"] = (c, e, v) => {
|
|
212
|
-
|
|
213
|
+
e.popupFactory = v;
|
|
213
214
|
};
|
|
214
|
-
export function InlinePopupButton({
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
215
|
+
export function InlinePopupButton({
|
|
216
|
+
text,
|
|
217
|
+
label,
|
|
218
|
+
icon,
|
|
219
|
+
hasBorder = false,
|
|
220
|
+
nodes = [],
|
|
221
|
+
defaultOnClick = "close",
|
|
222
|
+
anchorRight = false,
|
|
223
|
+
alignment,
|
|
224
|
+
popup,
|
|
225
|
+
...a
|
|
226
|
+
}, ...popupNodes) {
|
|
227
|
+
alignment ||= anchorRight ? "bottomRight" : "bottomLeft";
|
|
228
|
+
console.warn(`Deprecated, use AtomPopover instead`);
|
|
229
|
+
if (!a["data-layout"]) {
|
|
230
|
+
if (icon && text) {
|
|
231
|
+
a["data-layout"] = "icon-button";
|
|
232
|
+
} else {
|
|
233
|
+
a["data-layout"] = "button";
|
|
224
234
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
235
|
+
}
|
|
236
|
+
if (popup) {
|
|
237
|
+
return XNode.create("button", {
|
|
238
|
+
"data-popup-class": popup,
|
|
239
|
+
"data-has-border": !!hasBorder,
|
|
240
|
+
"data-inline-popup-button": "inline-popup-button",
|
|
241
|
+
"data-default-on-click": defaultOnClick,
|
|
242
|
+
"data-alignment": alignment,
|
|
243
|
+
...a
|
|
244
|
+
}, icon && XNode.create("i", {
|
|
245
|
+
class: icon
|
|
246
|
+
}), text && XNode.create("span", {
|
|
247
|
+
text: text
|
|
248
|
+
}), label && XNode.create("label", {
|
|
249
|
+
text: text
|
|
250
|
+
}), ...nodes);
|
|
251
|
+
}
|
|
252
|
+
let isOpen = false;
|
|
253
|
+
const done = () => isOpen = false;
|
|
254
|
+
const click = async e => {
|
|
255
|
+
if (isOpen || e.defaultPrevented) {
|
|
256
|
+
return;
|
|
231
257
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
258
|
+
const currentTarget = e.currentTarget;
|
|
259
|
+
currentTarget.setAttribute("data-popup-open", "true");
|
|
260
|
+
const popupNode = popupNodes.length > 1 ? XNode.create("div", null, ...popupNodes) : popupNodes[0];
|
|
261
|
+
try {
|
|
262
|
+
isOpen = true;
|
|
263
|
+
await InlinePopup.show(e.currentTarget, popupNode, {
|
|
264
|
+
defaultOnClick,
|
|
265
|
+
alignment
|
|
266
|
+
});
|
|
267
|
+
} finally {
|
|
268
|
+
done();
|
|
269
|
+
currentTarget.removeAttribute("data-popup-open");
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
return XNode.create("button", {
|
|
273
|
+
"event-click": click,
|
|
274
|
+
"data-has-border": !!hasBorder,
|
|
275
|
+
"data-alignment": alignment,
|
|
276
|
+
"data-inline-popup-button": "inline-popup-button",
|
|
277
|
+
...a
|
|
278
|
+
}, icon && XNode.create("i", {
|
|
279
|
+
class: icon
|
|
280
|
+
}), text && XNode.create("span", {
|
|
281
|
+
text: text
|
|
282
|
+
}), label && XNode.create("label", {
|
|
283
|
+
text: text
|
|
284
|
+
}), ...nodes);
|
|
285
|
+
}
|