@web-atoms/web-controls 2.6.5 → 2.6.6
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/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.js +174 -166
- 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
|
@@ -10,1121 +10,1156 @@ import { AtomControl } from "@web-atoms/core/dist/web/controls/AtomControl.js";
|
|
|
10
10
|
import { PopupWindow } from "@web-atoms/core/dist/web/services/PopupService.js";
|
|
11
11
|
import MergeNode from "./MergeNode.js";
|
|
12
12
|
import ItemPath from "./ItemPath.js";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
13
|
+
ESMPack.installStyleSheet(import.meta.resolve("./styles/popup.global.css"));
|
|
14
|
+
ESMPack.installStyleSheet(import.meta.resolve("./styles/suggestion-popup.global.css"));
|
|
15
|
+
ESMPack.installStyleSheet(import.meta.resolve("./styles/repeater.global.css"));
|
|
16
16
|
import { ChildEnumerator } from "@web-atoms/core/dist/web/core/AtomUI.js";
|
|
17
17
|
import DataAttributes from "../DataAttributes.js";
|
|
18
18
|
import AtomPopover from "./elements/AtomPopover.js";
|
|
19
19
|
import sleep from "@web-atoms/core/dist/core/sleep.js";
|
|
20
|
-
export const getParentRepeaterItem =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
if (eventName === undefined) {
|
|
39
|
-
const itemClickEvent = target.getAttribute("data-click-event");
|
|
40
|
-
if (itemClickEvent) {
|
|
41
|
-
eventName = itemClickEvent.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
target = target.parentElement;
|
|
20
|
+
export const getParentRepeaterItem = target => {
|
|
21
|
+
let eventName;
|
|
22
|
+
let repeater;
|
|
23
|
+
let index;
|
|
24
|
+
let root;
|
|
25
|
+
while (target) {
|
|
26
|
+
const a = target.atomControl;
|
|
27
|
+
if (a !== undefined && a instanceof AtomRepeater) {
|
|
28
|
+
repeater = a;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
if (index === undefined) {
|
|
32
|
+
const itemIndex = target.getAttribute("data-item-index");
|
|
33
|
+
if (typeof itemIndex !== "undefined") {
|
|
34
|
+
root = target;
|
|
35
|
+
index = ~~itemIndex;
|
|
36
|
+
}
|
|
45
37
|
}
|
|
46
|
-
if (
|
|
47
|
-
|
|
38
|
+
if (eventName === undefined) {
|
|
39
|
+
const itemClickEvent = target.getAttribute("data-click-event");
|
|
40
|
+
if (itemClickEvent) {
|
|
41
|
+
eventName = itemClickEvent.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
42
|
+
}
|
|
48
43
|
}
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
target = target.parentElement;
|
|
45
|
+
}
|
|
46
|
+
if (index === void 0 || repeater === void 0) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
const item = repeater.items[~~index];
|
|
50
|
+
return [eventName, repeater, item, index, root];
|
|
51
51
|
};
|
|
52
52
|
export const MatchTrue = (...a) => true;
|
|
53
53
|
export const MatchFalse = (...a) => false;
|
|
54
|
-
export const ArrowToString =
|
|
54
|
+
export const ArrowToString = item => item.label?.toString() ?? item.toString();
|
|
55
55
|
export const MatchCaseInsensitive = (textField = ArrowToString) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
return s => {
|
|
57
|
+
if (!s) {
|
|
58
|
+
return MatchTrue;
|
|
59
|
+
}
|
|
60
|
+
const r = StringHelper.createContainsRegExp(s);
|
|
61
|
+
return item => r.test(textField(item));
|
|
62
|
+
};
|
|
63
63
|
};
|
|
64
64
|
export const MatchAnyCaseInsensitive = (textField = ArrowToString) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
return s => {
|
|
66
|
+
if (!s) {
|
|
67
|
+
return MatchTrue;
|
|
68
|
+
}
|
|
69
|
+
const r = StringHelper.createContainsAnyWordRegExp(s);
|
|
70
|
+
return item => r.test(textField(item));
|
|
71
|
+
};
|
|
72
72
|
};
|
|
73
|
-
export const SameObjectValue =
|
|
73
|
+
export const SameObjectValue = item => item;
|
|
74
74
|
export function askSuggestion(items, itemRenderer, match, options) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
class Suggestions extends PopupWindow {
|
|
76
|
+
create() {
|
|
77
|
+
this.title = options?.title ?? "Select";
|
|
78
|
+
this.render(XNode.create("div", {
|
|
79
|
+
"data-repeater-popup": "popup"
|
|
80
|
+
}, XNode.create("input", {
|
|
81
|
+
type: "search",
|
|
82
|
+
value: Bind.twoWaysImmediate(() => this.search),
|
|
83
|
+
autofocus: true
|
|
84
|
+
}), XNode.create("div", {
|
|
85
|
+
class: "items"
|
|
86
|
+
}, XNode.create(AtomRepeater, {
|
|
87
|
+
class: "presenter",
|
|
88
|
+
itemRenderer: itemRenderer,
|
|
89
|
+
visibilityFilter: Bind.oneWay(() => match(this.search)),
|
|
90
|
+
eventItemClick: e => {
|
|
91
|
+
this.close(e.detail);
|
|
92
|
+
},
|
|
93
|
+
items: items
|
|
94
|
+
}))));
|
|
85
95
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
options
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
options.maxWidth = "90%";
|
|
94
|
-
options.minWidth = "300px";
|
|
95
|
-
}
|
|
96
|
-
if (typeof options.height === "undefined") {
|
|
97
|
-
options.height = "80%";
|
|
98
|
-
}
|
|
96
|
+
}
|
|
97
|
+
__decorate([BindableProperty, __metadata("design:type", String)], Suggestions.prototype, "search", void 0);
|
|
98
|
+
options ??= {};
|
|
99
|
+
if (typeof options.maximize === "undefined") {
|
|
100
|
+
if (typeof options.width === "undefined") {
|
|
101
|
+
options.maxWidth = "90%";
|
|
102
|
+
options.minWidth = "300px";
|
|
99
103
|
}
|
|
100
|
-
|
|
104
|
+
if (typeof options.height === "undefined") {
|
|
105
|
+
options.height = "80%";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return Suggestions.showModal(options);
|
|
101
109
|
}
|
|
102
110
|
export function askSuggestionPopup(opener, items, itemRenderer, match, selectedItem) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
init() {
|
|
111
|
-
const disableSearch = opener.disableSearch;
|
|
112
|
-
this.renderer = XNode.create("div", { "data-suggestion-popup": "suggestion-popup" },
|
|
113
|
-
!disableSearch && XNode.create("input", { type: "search", value: Bind.sourceTwoWays(opener, (x) => x.source.search), eventKeydown: (e) => this.onKey(e), autofocus: true }),
|
|
114
|
-
XNode.create("div", { class: "items" },
|
|
115
|
-
XNode.create(AtomRepeater, { class: "presenter", selectedItem: Bind.source(this, (x) => x.source.anchorItem), itemRenderer: itemRenderer, visibilityFilter: Bind.source(opener, (x) => match(x.source.search)), presenter: Bind.presenter((c) => this.repeater = c), eventItemClick: (e) => {
|
|
116
|
-
this.anchorItem = e.detail;
|
|
117
|
-
setTimeout(() => this.close(e.detail), 50);
|
|
118
|
-
}, items: Bind.source(opener, (x) => x.source.items) })));
|
|
119
|
-
if (disableSearch) {
|
|
120
|
-
const { input } = opener;
|
|
121
|
-
if (input) {
|
|
122
|
-
this.disposables.add(opener.bindEvent(input, "keydown", (e) => this.onKey(e)));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
async cancelSelection() {
|
|
127
|
-
await sleep(100);
|
|
128
|
-
if (!this.removed) {
|
|
129
|
-
this.close(opener.selectedItem);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
onKey(e) {
|
|
133
|
-
const suggested = match ? opener.items?.filter(match(opener.search)) : opener.items;
|
|
134
|
-
switch (e.key) {
|
|
135
|
-
case "Escape":
|
|
136
|
-
this.cancelSelection().catch(console.error);
|
|
137
|
-
return;
|
|
138
|
-
case "Tab":
|
|
139
|
-
case "Enter":
|
|
140
|
-
const anchorItem = this.anchorItem;
|
|
141
|
-
if (!anchorItem) {
|
|
142
|
-
if (e.key === "Tab") {
|
|
143
|
-
e.preventDefault();
|
|
144
|
-
this.cancelSelection().catch(console.error);
|
|
145
|
-
}
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
this.anchorIndex = 0;
|
|
149
|
-
setTimeout(() => this.close(anchorItem), 10);
|
|
150
|
-
this.anchorItem = null;
|
|
151
|
-
opener.search = "";
|
|
152
|
-
e.preventDefault();
|
|
153
|
-
break;
|
|
154
|
-
case "ArrowDown":
|
|
155
|
-
if (suggested) {
|
|
156
|
-
if (!this.anchorItem) {
|
|
157
|
-
this.anchorIndex = 0;
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
if (this.anchorIndex < suggested.length - 1) {
|
|
161
|
-
this.anchorIndex++;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
this.anchorItem = suggested[this.anchorIndex];
|
|
165
|
-
if (this.anchorItem) {
|
|
166
|
-
const current = this.repeater.elementForItem(this.anchorItem);
|
|
167
|
-
current?.scrollIntoView({ behavior: "auto", block: "center", inline: "nearest" });
|
|
168
|
-
}
|
|
169
|
-
e.preventDefault();
|
|
170
|
-
}
|
|
171
|
-
break;
|
|
172
|
-
case "ArrowUp":
|
|
173
|
-
if (suggested) {
|
|
174
|
-
if (!this.anchorItem) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (this.anchorIndex) {
|
|
178
|
-
this.anchorIndex--;
|
|
179
|
-
}
|
|
180
|
-
this.anchorItem = suggested[this.anchorIndex];
|
|
181
|
-
if (this.anchorItem) {
|
|
182
|
-
const current = this.repeater.elementForItem(this.anchorItem);
|
|
183
|
-
current?.scrollIntoView({ behavior: "auto", block: "center", inline: "nearest" });
|
|
184
|
-
}
|
|
185
|
-
e.preventDefault();
|
|
186
|
-
}
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
111
|
+
const itemsInOpener = "items" in opener;
|
|
112
|
+
class Suggestions extends AtomPopover {
|
|
113
|
+
constructor() {
|
|
114
|
+
super(...arguments);
|
|
115
|
+
this.anchorItem = null;
|
|
116
|
+
this.anchorIndex = null;
|
|
190
117
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
118
|
+
init() {
|
|
119
|
+
const disableSearch = opener.disableSearch;
|
|
120
|
+
this.renderer = XNode.create("div", {
|
|
121
|
+
"data-suggestion-popup": "suggestion-popup"
|
|
122
|
+
}, !disableSearch && XNode.create("input", {
|
|
123
|
+
type: "search",
|
|
124
|
+
value: Bind.sourceTwoWays(opener, x => x.source.search),
|
|
125
|
+
eventKeydown: e => this.onKey(e),
|
|
126
|
+
autofocus: true
|
|
127
|
+
}), XNode.create("div", {
|
|
128
|
+
class: "items"
|
|
129
|
+
}, XNode.create(AtomRepeater, {
|
|
130
|
+
class: "presenter",
|
|
131
|
+
selectedItem: Bind.source(this, x => x.source.anchorItem),
|
|
132
|
+
itemRenderer: itemRenderer,
|
|
133
|
+
visibilityFilter: Bind.source(opener, x => match(x.source.search)),
|
|
134
|
+
presenter: Bind.presenter(c => this.repeater = c),
|
|
135
|
+
eventItemClick: e => {
|
|
136
|
+
this.anchorItem = e.detail;
|
|
137
|
+
setTimeout(() => this.close(e.detail), 50);
|
|
138
|
+
},
|
|
139
|
+
items: Bind.source(opener, x => x.source.items)
|
|
140
|
+
})));
|
|
141
|
+
if (disableSearch) {
|
|
142
|
+
const {
|
|
143
|
+
input
|
|
144
|
+
} = opener;
|
|
145
|
+
if (input) {
|
|
146
|
+
this.disposables.add(opener.bindEvent(input, "keydown", e => this.onKey(e)));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async cancelSelection() {
|
|
151
|
+
await sleep(100);
|
|
152
|
+
if (!this.removed) {
|
|
153
|
+
this.close(opener.selectedItem);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
onKey(e) {
|
|
157
|
+
const suggested = match ? opener.items?.filter(match(opener.search)) : opener.items;
|
|
158
|
+
switch (e.key) {
|
|
159
|
+
case "Escape":
|
|
160
|
+
this.cancelSelection().catch(console.error);
|
|
161
|
+
return;
|
|
162
|
+
case "Tab":
|
|
163
|
+
case "Enter":
|
|
164
|
+
const anchorItem = this.anchorItem;
|
|
165
|
+
if (!anchorItem) {
|
|
166
|
+
if (e.key === "Tab") {
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
this.cancelSelection().catch(console.error);
|
|
218
169
|
}
|
|
219
|
-
|
|
220
|
-
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
this.anchorIndex = 0;
|
|
173
|
+
setTimeout(() => this.close(anchorItem), 10);
|
|
174
|
+
this.anchorItem = null;
|
|
175
|
+
opener.search = "";
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
break;
|
|
178
|
+
case "ArrowDown":
|
|
179
|
+
if (suggested) {
|
|
180
|
+
if (!this.anchorItem) {
|
|
181
|
+
this.anchorIndex = 0;
|
|
182
|
+
} else {
|
|
183
|
+
if (this.anchorIndex < suggested.length - 1) {
|
|
184
|
+
this.anchorIndex++;
|
|
185
|
+
}
|
|
221
186
|
}
|
|
222
|
-
|
|
223
|
-
|
|
187
|
+
this.anchorItem = suggested[this.anchorIndex];
|
|
188
|
+
if (this.anchorItem) {
|
|
189
|
+
const current = this.repeater.elementForItem(this.anchorItem);
|
|
190
|
+
current?.scrollIntoView({
|
|
191
|
+
behavior: "auto",
|
|
192
|
+
block: "center",
|
|
193
|
+
inline: "nearest"
|
|
194
|
+
});
|
|
224
195
|
}
|
|
225
|
-
|
|
226
|
-
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
case "ArrowUp":
|
|
200
|
+
if (suggested) {
|
|
201
|
+
if (!this.anchorItem) {
|
|
202
|
+
return;
|
|
227
203
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
si.push(...items);
|
|
231
|
-
si.refresh();
|
|
204
|
+
if (this.anchorIndex) {
|
|
205
|
+
this.anchorIndex--;
|
|
232
206
|
}
|
|
233
|
-
|
|
207
|
+
this.anchorItem = suggested[this.anchorIndex];
|
|
208
|
+
if (this.anchorItem) {
|
|
209
|
+
const current = this.repeater.elementForItem(this.anchorItem);
|
|
210
|
+
current?.scrollIntoView({
|
|
211
|
+
behavior: "auto",
|
|
212
|
+
block: "center",
|
|
213
|
+
inline: "nearest"
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
}
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
234
220
|
}
|
|
221
|
+
}
|
|
222
|
+
return Suggestions.show(opener.element, {
|
|
223
|
+
"anchor-left": "parent-left"
|
|
224
|
+
});
|
|
235
225
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
226
|
+
export function SelectorCheckBox({
|
|
227
|
+
text,
|
|
228
|
+
icon = "far fa-square",
|
|
229
|
+
iconSelected = "fas fa-check-square",
|
|
230
|
+
...a
|
|
231
|
+
}, ...nodes) {
|
|
232
|
+
if (text) {
|
|
233
|
+
return XNode.create("label", {
|
|
234
|
+
"data-selector": "check-box",
|
|
235
|
+
...a
|
|
236
|
+
}, XNode.create("i", {
|
|
237
|
+
class: icon,
|
|
238
|
+
"data-click-event": "item-select"
|
|
239
|
+
}), XNode.create("i", {
|
|
240
|
+
class: iconSelected,
|
|
241
|
+
"data-click-event": "item-deselect"
|
|
242
|
+
}), XNode.create("span", {
|
|
243
|
+
"data-no-wrap": "true",
|
|
244
|
+
text: text
|
|
245
|
+
}), ...nodes);
|
|
246
|
+
}
|
|
247
|
+
return XNode.create("label", {
|
|
248
|
+
"data-selector": "check-box",
|
|
249
|
+
...a
|
|
250
|
+
}, XNode.create("i", {
|
|
251
|
+
class: icon,
|
|
252
|
+
"data-click-event": "item-select"
|
|
253
|
+
}), XNode.create("i", {
|
|
254
|
+
class: iconSelected,
|
|
255
|
+
"data-click-event": "item-deselect"
|
|
256
|
+
}), ...nodes);
|
|
255
257
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
+
class SelectAllControl extends AtomControl {
|
|
259
|
+
preCreate() {
|
|
260
|
+
this.element.setAttribute("data-select-all", "select-all");
|
|
261
|
+
this.items = [];
|
|
262
|
+
this.selectedItems = [];
|
|
263
|
+
this.render(XNode.create(SelectAllControl, {
|
|
264
|
+
"data-is-selected": Bind.oneWay(() => this.items.length > 0 && this.items.length === this.selectedItems.length, false)
|
|
265
|
+
}));
|
|
266
|
+
this.bindEvent(this.element, "click", () => {
|
|
267
|
+
const si = this.selectedItems;
|
|
268
|
+
const items = this.items;
|
|
269
|
+
if (!si) {
|
|
258
270
|
return;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
}
|
|
272
|
+
if (!items) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (items.length === 0) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (items.length === si.length) {
|
|
279
|
+
si.clear();
|
|
280
|
+
} else {
|
|
281
|
+
si.length = 0;
|
|
282
|
+
si.push(...items);
|
|
283
|
+
si.refresh();
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
274
287
|
}
|
|
275
|
-
|
|
276
|
-
|
|
288
|
+
__decorate([BindableProperty, __metadata("design:type", Array)], SelectAllControl.prototype, "items", void 0);
|
|
289
|
+
__decorate([BindableProperty, __metadata("design:type", Array)], SelectAllControl.prototype, "selectedItems", void 0);
|
|
290
|
+
export function SelectAll({
|
|
291
|
+
text = "Select All",
|
|
292
|
+
icon = "far fa-square",
|
|
293
|
+
iconSelected = "fas fa-check-square",
|
|
294
|
+
...a
|
|
295
|
+
}, ...nodes) {
|
|
296
|
+
if (text) {
|
|
297
|
+
return XNode.create(SelectAllControl, {
|
|
298
|
+
for: "label",
|
|
299
|
+
...a
|
|
300
|
+
}, XNode.create("i", {
|
|
301
|
+
class: icon,
|
|
302
|
+
"data-ui-type": "item-select"
|
|
303
|
+
}), XNode.create("i", {
|
|
304
|
+
class: iconSelected,
|
|
305
|
+
"data-ui-type": "item-deselect"
|
|
306
|
+
}), XNode.create("span", {
|
|
307
|
+
"data-no-wrap": "true",
|
|
308
|
+
text: text
|
|
309
|
+
}));
|
|
310
|
+
}
|
|
311
|
+
return XNode.create(SelectAllControl, {
|
|
312
|
+
for: "label",
|
|
313
|
+
...a
|
|
314
|
+
}, XNode.create("i", {
|
|
315
|
+
class: icon,
|
|
316
|
+
"data-ui-type": "item-select"
|
|
317
|
+
}), XNode.create("i", {
|
|
318
|
+
class: iconSelected,
|
|
319
|
+
"data-ui-type": "item-deselect"
|
|
320
|
+
}), ...nodes);
|
|
321
|
+
}
|
|
322
|
+
export function disposeChildren(owner, e) {
|
|
323
|
+
if (!e) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
let s = e.firstElementChild;
|
|
327
|
+
while (s) {
|
|
328
|
+
const c = s;
|
|
329
|
+
s = s.nextElementSibling;
|
|
330
|
+
const ac = c.atomControl;
|
|
277
331
|
if (ac) {
|
|
278
|
-
|
|
279
|
-
|
|
332
|
+
ac.dispose();
|
|
333
|
+
continue;
|
|
280
334
|
}
|
|
281
|
-
disposeChildren(owner,
|
|
282
|
-
owner.unbind(
|
|
283
|
-
owner.unbindEvent(
|
|
284
|
-
|
|
335
|
+
disposeChildren(owner, c);
|
|
336
|
+
owner.unbind(c);
|
|
337
|
+
owner.unbindEvent(c);
|
|
338
|
+
}
|
|
339
|
+
e.innerHTML = "";
|
|
340
|
+
}
|
|
341
|
+
export function disposeChild(owner, e) {
|
|
342
|
+
const ac = e.atomControl;
|
|
343
|
+
if (ac) {
|
|
344
|
+
ac.dispose();
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
disposeChildren(owner, e);
|
|
348
|
+
owner.unbind(e);
|
|
349
|
+
owner.unbindEvent(e);
|
|
350
|
+
e.remove();
|
|
285
351
|
}
|
|
286
352
|
export function defaultComparer(left, right) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
353
|
+
if (left && right) {
|
|
354
|
+
if (left instanceof Date) {
|
|
355
|
+
if (right instanceof Date) {
|
|
356
|
+
return left.getTime() === right.getTime();
|
|
357
|
+
}
|
|
358
|
+
return false;
|
|
294
359
|
}
|
|
295
|
-
|
|
360
|
+
}
|
|
361
|
+
return left === right;
|
|
296
362
|
}
|
|
297
|
-
const getFirstChild =
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
363
|
+
const getFirstChild = container => {
|
|
364
|
+
let child = container.firstElementChild;
|
|
365
|
+
while (child && !child.hasAttribute("data-item-index")) {
|
|
366
|
+
child = child.nextElementSibling;
|
|
367
|
+
}
|
|
368
|
+
return child;
|
|
303
369
|
};
|
|
304
370
|
function updateDragDrop(e, force = false) {
|
|
305
|
-
|
|
306
|
-
|
|
371
|
+
if (!e) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (force) {
|
|
375
|
+
e.draggable = false;
|
|
376
|
+
} else {
|
|
377
|
+
force = e.draggable;
|
|
378
|
+
}
|
|
379
|
+
e = e.firstElementChild;
|
|
380
|
+
while (e) {
|
|
381
|
+
updateDragDrop(e, force);
|
|
382
|
+
e = e.nextElementSibling;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
export default class AtomRepeater extends AtomControl {
|
|
386
|
+
constructor() {
|
|
387
|
+
super(...arguments);
|
|
388
|
+
this.bubbleEvents = true;
|
|
389
|
+
}
|
|
390
|
+
static from(element) {
|
|
391
|
+
while (element) {
|
|
392
|
+
const {
|
|
393
|
+
atomControl
|
|
394
|
+
} = element;
|
|
395
|
+
if (atomControl instanceof AtomRepeater) {
|
|
396
|
+
return atomControl;
|
|
397
|
+
}
|
|
398
|
+
element = element.parentElement;
|
|
307
399
|
}
|
|
308
|
-
|
|
309
|
-
|
|
400
|
+
}
|
|
401
|
+
static itemFromElement(e, ar = this.from(e)) {
|
|
402
|
+
const da = new DataAttributes(e, ar);
|
|
403
|
+
const recreate = da.get("data-recreate");
|
|
404
|
+
const header = da.get("data-header");
|
|
405
|
+
const footer = da.get("data-footer");
|
|
406
|
+
const itemIndex = da.get("data-item-index");
|
|
407
|
+
const itemPath = da.get("data-item-path");
|
|
408
|
+
let clickEvent = da.get("data-click-event") || (header ? "headerClick" : footer ? "footerClick" : "itemClick");
|
|
409
|
+
clickEvent = clickEvent.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
410
|
+
const index = ~~itemIndex;
|
|
411
|
+
const item = ar.items[index];
|
|
412
|
+
let nestedItem = null;
|
|
413
|
+
if (item) {
|
|
414
|
+
if (itemPath || false) {
|
|
415
|
+
nestedItem = ItemPath.get(item, itemPath.trim());
|
|
416
|
+
}
|
|
310
417
|
}
|
|
311
|
-
|
|
312
|
-
|
|
418
|
+
return {
|
|
419
|
+
recreate,
|
|
420
|
+
header,
|
|
421
|
+
footer,
|
|
422
|
+
itemPath,
|
|
423
|
+
itemIndex,
|
|
424
|
+
item,
|
|
425
|
+
nestedItem,
|
|
426
|
+
clickEvent,
|
|
427
|
+
target: e
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
set refreshEventScope(v) {
|
|
431
|
+
this.registerDisposable(v.listen(ce => {
|
|
432
|
+
this.refreshItem(ce.detail);
|
|
433
|
+
}));
|
|
434
|
+
}
|
|
435
|
+
get allSelected() {
|
|
436
|
+
const selectedItems = this.selectedItems;
|
|
437
|
+
const items = this.items;
|
|
438
|
+
if (!(items && selectedItems)) {
|
|
439
|
+
return false;
|
|
313
440
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
441
|
+
return items.length && items.length === selectedItems.length;
|
|
442
|
+
}
|
|
443
|
+
get value() {
|
|
444
|
+
if (this.initialValue !== undefined) {
|
|
445
|
+
return this.initialValue;
|
|
318
446
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
super(...arguments);
|
|
323
|
-
this.bubbleEvents = true;
|
|
324
|
-
}
|
|
325
|
-
static from(element) {
|
|
326
|
-
while (element) {
|
|
327
|
-
const { atomControl } = element;
|
|
328
|
-
if (atomControl instanceof AtomRepeater) {
|
|
329
|
-
return atomControl;
|
|
330
|
-
}
|
|
331
|
-
element = element.parentElement;
|
|
332
|
-
}
|
|
447
|
+
const sp = this.selectedItem;
|
|
448
|
+
if (sp === undefined) {
|
|
449
|
+
return sp;
|
|
333
450
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
set refreshEventScope(v) {
|
|
366
|
-
this.registerDisposable(v.listen((ce) => {
|
|
367
|
-
this.refreshItem(ce.detail);
|
|
368
|
-
}));
|
|
369
|
-
}
|
|
370
|
-
get allSelected() {
|
|
371
|
-
const selectedItems = this.selectedItems;
|
|
451
|
+
const vp = this.valuePath ?? SameObjectValue;
|
|
452
|
+
return vp(sp);
|
|
453
|
+
}
|
|
454
|
+
set value(v) {
|
|
455
|
+
this.initialValue = v;
|
|
456
|
+
if (!this.items || !this.items.length) {
|
|
457
|
+
AtomBinder.refreshValue(this, "value");
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const vp = this.valuePath ?? SameObjectValue;
|
|
461
|
+
const c = this.comparer ?? defaultComparer;
|
|
462
|
+
const selectedItem = this.items.find(item => c(vp(item), v));
|
|
463
|
+
this.selectedItem = selectedItem;
|
|
464
|
+
delete this.initialValue;
|
|
465
|
+
}
|
|
466
|
+
get selectedItem() {
|
|
467
|
+
return this.selectedItems?.[0];
|
|
468
|
+
}
|
|
469
|
+
set selectedItem(value) {
|
|
470
|
+
const si = this.selectedItems ??= [];
|
|
471
|
+
const first = si[0];
|
|
472
|
+
if (value === first) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
si.set(0, value);
|
|
476
|
+
}
|
|
477
|
+
onPropertyChanged(name) {
|
|
478
|
+
switch (name) {
|
|
479
|
+
case "items":
|
|
480
|
+
this.itemsDisposable?.dispose();
|
|
372
481
|
const items = this.items;
|
|
373
|
-
|
|
374
|
-
|
|
482
|
+
const d = items?.watch((target, type, index, item) => {
|
|
483
|
+
switch (type) {
|
|
484
|
+
case "add":
|
|
485
|
+
case "remove":
|
|
486
|
+
case "set":
|
|
487
|
+
this.updatePartial(type, index, item);
|
|
488
|
+
break;
|
|
489
|
+
default:
|
|
490
|
+
this.updateItems();
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
this.dispatchCustomEvent("items-updated", {
|
|
494
|
+
type,
|
|
495
|
+
items,
|
|
496
|
+
index
|
|
497
|
+
});
|
|
498
|
+
AtomBinder.refreshValue(this, "selectedItem");
|
|
499
|
+
AtomBinder.refreshValue(this, "value");
|
|
500
|
+
});
|
|
501
|
+
if (d) {
|
|
502
|
+
this.itemsDisposable = this.registerDisposable(d);
|
|
503
|
+
}
|
|
504
|
+
const iv = this.initialValue;
|
|
505
|
+
if (iv) {
|
|
506
|
+
this.value = iv;
|
|
507
|
+
}
|
|
508
|
+
this.updateItems();
|
|
509
|
+
this.dispatchCustomEvent("items-updated", {
|
|
510
|
+
type: "reset",
|
|
511
|
+
items,
|
|
512
|
+
index: 0
|
|
513
|
+
});
|
|
514
|
+
if (this.scrollToSelection) {
|
|
515
|
+
this.bringSelectionIntoView();
|
|
375
516
|
}
|
|
376
|
-
|
|
517
|
+
break;
|
|
518
|
+
case "selectedItems":
|
|
519
|
+
this.selectedItemsDisposable?.dispose();
|
|
520
|
+
const selectedItems = this.selectedItems;
|
|
521
|
+
const sd = selectedItems?.watch(() => {
|
|
522
|
+
this.updateClasses();
|
|
523
|
+
if (this.scrollToSelection) {
|
|
524
|
+
this.bringSelectionIntoView();
|
|
525
|
+
}
|
|
526
|
+
if (this.selectedItem) {
|
|
527
|
+
delete this.initialValue;
|
|
528
|
+
}
|
|
529
|
+
AtomBinder.refreshValue(this, "selectedItem");
|
|
530
|
+
AtomBinder.refreshValue(this, "value");
|
|
531
|
+
AtomBinder.refreshValue(this, "allSelected");
|
|
532
|
+
this.dispatchCustomEvent("selection-updated", selectedItems);
|
|
533
|
+
});
|
|
534
|
+
if (sd) {
|
|
535
|
+
this.selectedItemsDisposable = this.registerDisposable(sd);
|
|
536
|
+
}
|
|
537
|
+
this.updateClasses();
|
|
538
|
+
this.dispatchCustomEvent("selection-updated", selectedItems);
|
|
539
|
+
AtomBinder.refreshValue(this, "allSelected");
|
|
540
|
+
break;
|
|
541
|
+
case "itemRenderer":
|
|
542
|
+
case "watch":
|
|
543
|
+
this.updateItems();
|
|
544
|
+
break;
|
|
545
|
+
case "visibilityFilter":
|
|
546
|
+
this.updateVisibility();
|
|
547
|
+
break;
|
|
548
|
+
case "header":
|
|
549
|
+
case "headerRenderer":
|
|
550
|
+
this.updateHeaderFooter("header", this.headerPresenter, this.header, this.headerRenderer, true);
|
|
551
|
+
break;
|
|
552
|
+
case "footer":
|
|
553
|
+
case "footerRenderer":
|
|
554
|
+
this.updateHeaderFooter("footer", this.footerPresenter, this.footer, this.footerRenderer);
|
|
555
|
+
break;
|
|
377
556
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return vp(sp);
|
|
557
|
+
}
|
|
558
|
+
bringSelectionIntoView(force) {
|
|
559
|
+
if (force) {
|
|
560
|
+
const selection = this.selectedItem;
|
|
561
|
+
if (selection) {
|
|
562
|
+
const element = this.elementForItem(selection);
|
|
563
|
+
element?.scrollIntoView();
|
|
564
|
+
}
|
|
565
|
+
return;
|
|
388
566
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
if (!this.items || !this.items.length) {
|
|
392
|
-
AtomBinder.refreshValue(this, "value");
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
const vp = this.valuePath ?? SameObjectValue;
|
|
396
|
-
const c = this.comparer ?? defaultComparer;
|
|
397
|
-
const selectedItem = this.items.find((item) => c(vp(item), v));
|
|
398
|
-
this.selectedItem = selectedItem;
|
|
399
|
-
delete this.initialValue;
|
|
567
|
+
if (this.bringIntoViewId) {
|
|
568
|
+
clearTimeout(this.bringIntoViewId);
|
|
400
569
|
}
|
|
401
|
-
|
|
402
|
-
|
|
570
|
+
this.bringIntoViewId = setTimeout(() => {
|
|
571
|
+
clearTimeout(this.bringIntoViewId);
|
|
572
|
+
this.bringIntoViewId = undefined;
|
|
573
|
+
this.bringSelectionIntoView(true);
|
|
574
|
+
}, 100);
|
|
575
|
+
}
|
|
576
|
+
forEach(action, container) {
|
|
577
|
+
container ??= this.itemsPresenter ?? this.element;
|
|
578
|
+
const items = this.items;
|
|
579
|
+
let start = getFirstChild(container);
|
|
580
|
+
while (start) {
|
|
581
|
+
const index = start.getAttribute("data-item-index");
|
|
582
|
+
const item = items[~~index];
|
|
583
|
+
action(item, start);
|
|
584
|
+
start = start.nextElementSibling;
|
|
403
585
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
this.dispatchCustomEvent("items-updated", { type, items, index });
|
|
429
|
-
AtomBinder.refreshValue(this, "selectedItem");
|
|
430
|
-
AtomBinder.refreshValue(this, "value");
|
|
431
|
-
});
|
|
432
|
-
if (d) {
|
|
433
|
-
this.itemsDisposable = this.registerDisposable(d);
|
|
434
|
-
}
|
|
435
|
-
const iv = this.initialValue;
|
|
436
|
-
if (iv) {
|
|
437
|
-
this.value = iv;
|
|
438
|
-
}
|
|
439
|
-
this.updateItems();
|
|
440
|
-
this.dispatchCustomEvent("items-updated", { type: "reset", items, index: 0 });
|
|
441
|
-
if (this.scrollToSelection) {
|
|
442
|
-
this.bringSelectionIntoView();
|
|
443
|
-
}
|
|
444
|
-
break;
|
|
445
|
-
case "selectedItems":
|
|
446
|
-
this.selectedItemsDisposable?.dispose();
|
|
447
|
-
const selectedItems = this.selectedItems;
|
|
448
|
-
const sd = selectedItems?.watch(() => {
|
|
449
|
-
this.updateClasses();
|
|
450
|
-
if (this.scrollToSelection) {
|
|
451
|
-
this.bringSelectionIntoView();
|
|
452
|
-
}
|
|
453
|
-
if (this.selectedItem) {
|
|
454
|
-
delete this.initialValue;
|
|
455
|
-
}
|
|
456
|
-
AtomBinder.refreshValue(this, "selectedItem");
|
|
457
|
-
AtomBinder.refreshValue(this, "value");
|
|
458
|
-
AtomBinder.refreshValue(this, "allSelected");
|
|
459
|
-
this.dispatchCustomEvent("selection-updated", selectedItems);
|
|
460
|
-
});
|
|
461
|
-
if (sd) {
|
|
462
|
-
this.selectedItemsDisposable = this.registerDisposable(sd);
|
|
463
|
-
}
|
|
464
|
-
this.updateClasses();
|
|
465
|
-
this.dispatchCustomEvent("selection-updated", selectedItems);
|
|
466
|
-
AtomBinder.refreshValue(this, "allSelected");
|
|
467
|
-
break;
|
|
468
|
-
case "itemRenderer":
|
|
469
|
-
case "watch":
|
|
470
|
-
this.updateItems();
|
|
471
|
-
break;
|
|
472
|
-
case "visibilityFilter":
|
|
473
|
-
this.updateVisibility();
|
|
474
|
-
break;
|
|
475
|
-
case "header":
|
|
476
|
-
case "headerRenderer":
|
|
477
|
-
this.updateHeaderFooter("header", this.headerPresenter, this.header, this.headerRenderer, true);
|
|
478
|
-
break;
|
|
479
|
-
case "footer":
|
|
480
|
-
case "footerRenderer":
|
|
481
|
-
this.updateHeaderFooter("footer", this.footerPresenter, this.footer, this.footerRenderer);
|
|
482
|
-
break;
|
|
483
|
-
}
|
|
586
|
+
}
|
|
587
|
+
*any(fx, itemSelector, container) {
|
|
588
|
+
container ??= this.itemsPresenter ?? this.element;
|
|
589
|
+
const items = this.items;
|
|
590
|
+
let node = getFirstChild(container);
|
|
591
|
+
while (node) {
|
|
592
|
+
const index = node.getAttribute("data-item-index");
|
|
593
|
+
const item = items[~~index];
|
|
594
|
+
let element = node;
|
|
595
|
+
if (itemSelector) {
|
|
596
|
+
element = element.querySelector(itemSelector);
|
|
597
|
+
}
|
|
598
|
+
const ie = {
|
|
599
|
+
item,
|
|
600
|
+
element
|
|
601
|
+
};
|
|
602
|
+
if (fx) {
|
|
603
|
+
if (fx(item)) {
|
|
604
|
+
yield ie;
|
|
605
|
+
}
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
yield ie;
|
|
609
|
+
node = node.nextElementSibling;
|
|
484
610
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
clearTimeout(this.bringIntoViewId);
|
|
499
|
-
this.bringIntoViewId = undefined;
|
|
500
|
-
this.bringSelectionIntoView(true);
|
|
501
|
-
}, 100);
|
|
502
|
-
}
|
|
503
|
-
forEach(action, container) {
|
|
504
|
-
container ??= this.itemsPresenter ?? this.element;
|
|
505
|
-
const items = this.items;
|
|
506
|
-
let start = getFirstChild(container);
|
|
507
|
-
while (start) {
|
|
508
|
-
const index = start.getAttribute("data-item-index");
|
|
509
|
-
const item = items[~~index];
|
|
510
|
-
action(item, start);
|
|
511
|
-
start = start.nextElementSibling;
|
|
512
|
-
}
|
|
611
|
+
}
|
|
612
|
+
*all(container) {
|
|
613
|
+
container ??= this.itemsPresenter ?? this.element;
|
|
614
|
+
const items = this.items;
|
|
615
|
+
let element = getFirstChild(container);
|
|
616
|
+
while (element) {
|
|
617
|
+
const index = element.getAttribute("data-item-index");
|
|
618
|
+
const item = items[~~index];
|
|
619
|
+
yield {
|
|
620
|
+
item,
|
|
621
|
+
element
|
|
622
|
+
};
|
|
623
|
+
element = element.nextElementSibling;
|
|
513
624
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
yield ie;
|
|
529
|
-
}
|
|
530
|
-
continue;
|
|
531
|
-
}
|
|
532
|
-
yield ie;
|
|
533
|
-
node = node.nextElementSibling;
|
|
534
|
-
}
|
|
625
|
+
}
|
|
626
|
+
elementAt(index, container) {
|
|
627
|
+
container ??= this.itemsPresenter ?? this.element;
|
|
628
|
+
const indexText = index.toString();
|
|
629
|
+
const element = ChildEnumerator.find(container, e => e.getAttribute("data-item-index") === indexText);
|
|
630
|
+
return element;
|
|
631
|
+
}
|
|
632
|
+
elementForItem(itemToFind, container) {
|
|
633
|
+
const index = this.items.indexOf(itemToFind);
|
|
634
|
+
return this.elementAt(index, container);
|
|
635
|
+
}
|
|
636
|
+
refreshItem(item, fx, index = -1) {
|
|
637
|
+
if (index === -1) {
|
|
638
|
+
index = this.items.indexOf(item);
|
|
535
639
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
const item = items[~~index];
|
|
543
|
-
yield { item, element };
|
|
544
|
-
element = element.nextElementSibling;
|
|
545
|
-
}
|
|
640
|
+
if (fx?.then) {
|
|
641
|
+
const finalize = v => {
|
|
642
|
+
this.refreshItem(item, v, index);
|
|
643
|
+
};
|
|
644
|
+
fx.then(finalize, finalize);
|
|
645
|
+
return;
|
|
546
646
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
const element = ChildEnumerator.find(container, (e) => e.getAttribute("data-item-index") === indexText);
|
|
551
|
-
return element;
|
|
647
|
+
if (fx instanceof MergeNode) {
|
|
648
|
+
this.mergeItem(index, fx);
|
|
649
|
+
return;
|
|
552
650
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
651
|
+
this.updatePartial("set", index, item);
|
|
652
|
+
}
|
|
653
|
+
mergeItem(index, m) {
|
|
654
|
+
const item = this.items[index];
|
|
655
|
+
if (!item) {
|
|
656
|
+
return;
|
|
556
657
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
}
|
|
561
|
-
if (fx?.then) {
|
|
562
|
-
const finalize = (v) => {
|
|
563
|
-
this.refreshItem(item, v, index);
|
|
564
|
-
};
|
|
565
|
-
fx.then(finalize, finalize);
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
if (fx instanceof MergeNode) {
|
|
569
|
-
this.mergeItem(index, fx);
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
this.updatePartial("set", index, item);
|
|
658
|
+
if (m.classes?.[0]?.remove) {
|
|
659
|
+
this.items.removeAt(index);
|
|
660
|
+
return;
|
|
573
661
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
const
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
}
|
|
620
|
-
continue;
|
|
621
|
-
}
|
|
622
|
-
let targetPrevious = targetElement.querySelector(iterator.after);
|
|
623
|
-
for (const i of Array.from(targetElement.querySelectorAll(iterator.replace))) {
|
|
624
|
-
i.remove();
|
|
625
|
-
}
|
|
626
|
-
for (const i of Array.from(sourceElement.querySelectorAll(iterator.replace))) {
|
|
627
|
-
targetPrevious.insertAdjacentElement("afterend", i);
|
|
628
|
-
targetPrevious = i;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
this.dispose(sourceElement);
|
|
632
|
-
sourceElement.remove();
|
|
662
|
+
const container = this.itemsPresenter ?? this.element;
|
|
663
|
+
const node = this.itemRenderer(item, index, this);
|
|
664
|
+
const sourceElement = document.createElement("div");
|
|
665
|
+
sourceElement.style.display = "none";
|
|
666
|
+
container.appendChild(sourceElement);
|
|
667
|
+
this.render(node, sourceElement);
|
|
668
|
+
const targetElement = this.elementAt(index);
|
|
669
|
+
for (const iterator of m.classes) {
|
|
670
|
+
if (typeof iterator === "string") {
|
|
671
|
+
const source = sourceElement.querySelectorAll(iterator);
|
|
672
|
+
const target = targetElement.querySelectorAll(iterator);
|
|
673
|
+
for (let i = 0; i < source.length && i < target.length; i++) {
|
|
674
|
+
const element = source[i];
|
|
675
|
+
const te = target[i];
|
|
676
|
+
for (const name of te.getAttributeNames()) {
|
|
677
|
+
te.removeAttribute(name);
|
|
678
|
+
}
|
|
679
|
+
te.innerHTML = element.innerHTML;
|
|
680
|
+
for (const name of element.getAttributeNames()) {
|
|
681
|
+
te.setAttribute(name, element.getAttribute(name));
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
if (iterator.parent) {
|
|
687
|
+
const targetParent = /self|\*/.test(iterator.parent) ? targetElement : targetElement.querySelector(iterator.parent);
|
|
688
|
+
if (!targetParent) {
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
for (const i of Array.from(targetElement.querySelectorAll(iterator.replace))) {
|
|
692
|
+
i.remove();
|
|
693
|
+
}
|
|
694
|
+
for (const i of Array.from(sourceElement.querySelectorAll(iterator.replace))) {
|
|
695
|
+
targetParent.appendChild(i);
|
|
696
|
+
}
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
let targetPrevious = targetElement.querySelector(iterator.after);
|
|
700
|
+
for (const i of Array.from(targetElement.querySelectorAll(iterator.replace))) {
|
|
701
|
+
i.remove();
|
|
702
|
+
}
|
|
703
|
+
for (const i of Array.from(sourceElement.querySelectorAll(iterator.replace))) {
|
|
704
|
+
targetPrevious.insertAdjacentElement("afterend", i);
|
|
705
|
+
targetPrevious = i;
|
|
706
|
+
}
|
|
633
707
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
container ??= this.itemsPresenter ?? this.element;
|
|
644
|
-
let start = getFirstChild(container);
|
|
645
|
-
let ei;
|
|
646
|
-
while (start) {
|
|
647
|
-
ei = ~~start.getAttribute("data-item-index");
|
|
648
|
-
if (ei === index) {
|
|
649
|
-
break;
|
|
650
|
-
}
|
|
651
|
-
start = start.nextElementSibling;
|
|
652
|
-
}
|
|
653
|
-
if (key !== "add" && !start) {
|
|
654
|
-
return;
|
|
655
|
-
}
|
|
656
|
-
const vp = this.valuePath ?? ((it) => it);
|
|
657
|
-
const si = (this.selectedItems ?? []).map(vp);
|
|
658
|
-
const isRemove = key === "remove";
|
|
659
|
-
if (isRemove || key === "set") {
|
|
660
|
-
const current = start;
|
|
661
|
-
start = start.nextElementSibling;
|
|
662
|
-
const ac = current.atomControl;
|
|
663
|
-
if (ac) {
|
|
664
|
-
ac.dispose();
|
|
665
|
-
}
|
|
666
|
-
else {
|
|
667
|
-
this.unbind(current);
|
|
668
|
-
this.unbindEvent(current);
|
|
669
|
-
}
|
|
670
|
-
current.remove();
|
|
671
|
-
}
|
|
672
|
-
const end = this.footerElement?.parentElement === container ? this.footerElement : null;
|
|
673
|
-
if (!isRemove) {
|
|
674
|
-
const en = ir(item, index, this);
|
|
675
|
-
const ea = en.attributes ??= {};
|
|
676
|
-
const v = vp(item);
|
|
677
|
-
const e = document.createElement(ea.for ?? en.name ?? "div");
|
|
678
|
-
e.setAttribute("data-item-index", `${index++}`);
|
|
679
|
-
if (si.indexOf(v) !== -1) {
|
|
680
|
-
e.setAttribute("data-selected-item", "true");
|
|
681
|
-
}
|
|
682
|
-
else {
|
|
683
|
-
e.removeAttribute("data-selected-item");
|
|
684
|
-
}
|
|
685
|
-
if (this.enableDragDrop) {
|
|
686
|
-
updateDragDrop(e);
|
|
687
|
-
}
|
|
688
|
-
if (start) {
|
|
689
|
-
container.insertBefore(e, start);
|
|
690
|
-
}
|
|
691
|
-
else if (end) {
|
|
692
|
-
container.insertBefore(e, end);
|
|
693
|
-
}
|
|
694
|
-
else {
|
|
695
|
-
container.appendChild(e);
|
|
696
|
-
}
|
|
697
|
-
this.render(en, e, this.creator || this);
|
|
698
|
-
}
|
|
699
|
-
while (start) {
|
|
700
|
-
const ci = items[index];
|
|
701
|
-
const cv = vp(ci);
|
|
702
|
-
start.setAttribute("data-item-index", `${index++}`);
|
|
703
|
-
if (si.indexOf(cv) !== -1) {
|
|
704
|
-
start.setAttribute("data-selected-item", "true");
|
|
705
|
-
}
|
|
706
|
-
else {
|
|
707
|
-
start.removeAttribute("data-selected-item");
|
|
708
|
-
}
|
|
709
|
-
start = start.nextElementSibling;
|
|
710
|
-
if (start?.hasAttribute("data-footer")) {
|
|
711
|
-
break;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
708
|
+
this.dispose(sourceElement);
|
|
709
|
+
sourceElement.remove();
|
|
710
|
+
}
|
|
711
|
+
updatePartial(key, index, item, container) {
|
|
712
|
+
const items = this.items;
|
|
713
|
+
if (!items) {
|
|
714
|
+
return;
|
|
714
715
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
this.deferredUpdateId = setTimeout(() => {
|
|
721
|
-
this.deferredUpdateId = 0;
|
|
722
|
-
this.updateItems(container, true);
|
|
723
|
-
}, 1);
|
|
724
|
-
return;
|
|
725
|
-
}
|
|
726
|
-
container ??= this.itemsPresenter ?? this.element;
|
|
727
|
-
if (!container) {
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
disposeChildren(this, container);
|
|
731
|
-
this.onPropertyChanged("header");
|
|
732
|
-
const ir = this.itemRenderer;
|
|
733
|
-
if (!ir) {
|
|
734
|
-
this.onPropertyChanged("footer");
|
|
735
|
-
return;
|
|
736
|
-
}
|
|
737
|
-
const items = this.items;
|
|
738
|
-
if (!items) {
|
|
739
|
-
this.onPropertyChanged("footer");
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
const vp = this.valuePath ?? ((it) => it);
|
|
743
|
-
const si = (this.selectedItems ?? []).map(vp);
|
|
744
|
-
let i = 0;
|
|
745
|
-
for (const iterator of items) {
|
|
746
|
-
const index = i++;
|
|
747
|
-
const e = ir(iterator, index, this);
|
|
748
|
-
const ea = e.attributes ??= {};
|
|
749
|
-
const v = vp(iterator);
|
|
750
|
-
const element = document.createElement(ea.for ?? e.name ?? "div");
|
|
751
|
-
element.setAttribute("data-item-index", `${index}`);
|
|
752
|
-
if (si.indexOf(v) !== -1) {
|
|
753
|
-
element.setAttribute("data-selected-item", "true");
|
|
754
|
-
}
|
|
755
|
-
else {
|
|
756
|
-
element.removeAttribute("data-selected-item");
|
|
757
|
-
}
|
|
758
|
-
this.render(e, element, this.creator || this);
|
|
759
|
-
if (this.enableDragDrop) {
|
|
760
|
-
updateDragDrop(element);
|
|
761
|
-
}
|
|
762
|
-
container.appendChild(element);
|
|
763
|
-
}
|
|
764
|
-
this.onPropertyChanged("footer");
|
|
716
|
+
const ir = this.itemRenderer;
|
|
717
|
+
if (!ir) {
|
|
718
|
+
return;
|
|
765
719
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
720
|
+
container ??= this.itemsPresenter ?? this.element;
|
|
721
|
+
let start = getFirstChild(container);
|
|
722
|
+
let ei;
|
|
723
|
+
while (start) {
|
|
724
|
+
ei = ~~start.getAttribute("data-item-index");
|
|
725
|
+
if (ei === index) {
|
|
726
|
+
break;
|
|
727
|
+
}
|
|
728
|
+
start = start.nextElementSibling;
|
|
772
729
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
this.mergeOnRefresh = false;
|
|
776
|
-
this.selectOnClick = false;
|
|
777
|
-
this.element.setAttribute("data-click-event", "item-click");
|
|
730
|
+
if (key !== "add" && !start) {
|
|
731
|
+
return;
|
|
778
732
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
const items = this.items;
|
|
794
|
-
let element = getFirstChild(container);
|
|
795
|
-
const vp = this.valuePath ?? ((i) => i);
|
|
796
|
-
const si = (this.selectedItems ?? []).map(vp);
|
|
797
|
-
while (element) {
|
|
798
|
-
const index = ~~element.getAttribute("data-item-index");
|
|
799
|
-
const item = items[index];
|
|
800
|
-
const v = vp(item);
|
|
801
|
-
if (si.indexOf(v) !== -1) {
|
|
802
|
-
element.setAttribute("data-selected-item", "true");
|
|
803
|
-
}
|
|
804
|
-
else {
|
|
805
|
-
element.removeAttribute("data-selected-item");
|
|
806
|
-
}
|
|
807
|
-
element = element.nextElementSibling;
|
|
808
|
-
}
|
|
733
|
+
const vp = this.valuePath ?? (it => it);
|
|
734
|
+
const si = (this.selectedItems ?? []).map(vp);
|
|
735
|
+
const isRemove = key === "remove";
|
|
736
|
+
if (isRemove || key === "set") {
|
|
737
|
+
const current = start;
|
|
738
|
+
start = start.nextElementSibling;
|
|
739
|
+
const ac = current.atomControl;
|
|
740
|
+
if (ac) {
|
|
741
|
+
ac.dispose();
|
|
742
|
+
} else {
|
|
743
|
+
this.unbind(current);
|
|
744
|
+
this.unbindEvent(current);
|
|
745
|
+
}
|
|
746
|
+
current.remove();
|
|
809
747
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
748
|
+
const end = this.footerElement?.parentElement === container ? this.footerElement : null;
|
|
749
|
+
if (!isRemove) {
|
|
750
|
+
const en = ir(item, index, this);
|
|
751
|
+
const ea = en.attributes ??= {};
|
|
752
|
+
const v = vp(item);
|
|
753
|
+
const e = document.createElement(ea.for ?? en.name ?? "div");
|
|
754
|
+
e.setAttribute("data-item-index", `${index++}`);
|
|
755
|
+
if (si.indexOf(v) !== -1) {
|
|
756
|
+
e.setAttribute("data-selected-item", "true");
|
|
757
|
+
} else {
|
|
758
|
+
e.removeAttribute("data-selected-item");
|
|
759
|
+
}
|
|
760
|
+
if (this.enableDragDrop) {
|
|
761
|
+
updateDragDrop(e);
|
|
762
|
+
}
|
|
763
|
+
if (start) {
|
|
764
|
+
container.insertBefore(e, start);
|
|
765
|
+
} else if (end) {
|
|
766
|
+
container.insertBefore(e, end);
|
|
767
|
+
} else {
|
|
768
|
+
container.appendChild(e);
|
|
769
|
+
}
|
|
770
|
+
this.render(en, e, this.creator || this);
|
|
826
771
|
}
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
else {
|
|
841
|
-
current = presenter.lastElementChild;
|
|
842
|
-
while (current && current.dataset[name] !== name) {
|
|
843
|
-
current = current.previousElementSibling;
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
if (current) {
|
|
847
|
-
disposeChild(this, current);
|
|
848
|
-
this[name + "Element"] = null;
|
|
849
|
-
}
|
|
850
|
-
if (!(item && itemRenderer)) {
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
853
|
-
const node = itemRenderer(item);
|
|
854
|
-
const element = document.createElement(node.attributes?.for ?? node.name ?? "div");
|
|
855
|
-
element.dataset[name] = name;
|
|
856
|
-
this.render(node, element, this.creator || this);
|
|
857
|
-
if (insert) {
|
|
858
|
-
presenter.insertBefore(element, presenter.firstElementChild);
|
|
859
|
-
}
|
|
860
|
-
else {
|
|
861
|
-
presenter.appendChild(element);
|
|
862
|
-
}
|
|
863
|
-
this[name + "Element"] = element;
|
|
864
|
-
}
|
|
865
|
-
dispatchHeaderFooterEvent(eventName, type, recreate, originalTarget) {
|
|
866
|
-
const detail = this[type];
|
|
867
|
-
const ce = new CustomEvent(eventName ?? `${type}Click`, {
|
|
868
|
-
detail,
|
|
869
|
-
bubbles: this.bubbleEvents,
|
|
870
|
-
cancelable: true
|
|
871
|
-
});
|
|
872
|
-
originalTarget.dispatchEvent(ce);
|
|
873
|
-
if (ce.defaultPrevented || !ce.executed) {
|
|
874
|
-
return;
|
|
875
|
-
}
|
|
876
|
-
if (recreate) {
|
|
877
|
-
this.onPropertyChanged(type);
|
|
878
|
-
}
|
|
772
|
+
while (start) {
|
|
773
|
+
const ci = items[index];
|
|
774
|
+
const cv = vp(ci);
|
|
775
|
+
start.setAttribute("data-item-index", `${index++}`);
|
|
776
|
+
if (si.indexOf(cv) !== -1) {
|
|
777
|
+
start.setAttribute("data-selected-item", "true");
|
|
778
|
+
} else {
|
|
779
|
+
start.removeAttribute("data-selected-item");
|
|
780
|
+
}
|
|
781
|
+
start = start.nextElementSibling;
|
|
782
|
+
if (start?.hasAttribute("data-footer")) {
|
|
783
|
+
break;
|
|
784
|
+
}
|
|
879
785
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
786
|
+
}
|
|
787
|
+
updateItems(container, force) {
|
|
788
|
+
if (this.deferUpdates && !force) {
|
|
789
|
+
if (this.deferredUpdateId) {
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
this.deferredUpdateId = setTimeout(() => {
|
|
793
|
+
this.deferredUpdateId = 0;
|
|
794
|
+
this.updateItems(container, true);
|
|
795
|
+
}, 1);
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
container ??= this.itemsPresenter ?? this.element;
|
|
799
|
+
if (!container) {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
disposeChildren(this, container);
|
|
803
|
+
this.onPropertyChanged("header");
|
|
804
|
+
const ir = this.itemRenderer;
|
|
805
|
+
if (!ir) {
|
|
806
|
+
this.onPropertyChanged("footer");
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
const items = this.items;
|
|
810
|
+
if (!items) {
|
|
811
|
+
this.onPropertyChanged("footer");
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
const vp = this.valuePath ?? (it => it);
|
|
815
|
+
const si = (this.selectedItems ?? []).map(vp);
|
|
816
|
+
let i = 0;
|
|
817
|
+
for (const iterator of items) {
|
|
818
|
+
const index = i++;
|
|
819
|
+
const e = ir(iterator, index, this);
|
|
820
|
+
const ea = e.attributes ??= {};
|
|
821
|
+
const v = vp(iterator);
|
|
822
|
+
const element = document.createElement(ea.for ?? e.name ?? "div");
|
|
823
|
+
element.setAttribute("data-item-index", `${index}`);
|
|
824
|
+
if (si.indexOf(v) !== -1) {
|
|
825
|
+
element.setAttribute("data-selected-item", "true");
|
|
826
|
+
} else {
|
|
827
|
+
element.removeAttribute("data-selected-item");
|
|
828
|
+
}
|
|
829
|
+
this.render(e, element, this.creator || this);
|
|
830
|
+
if (this.enableDragDrop) {
|
|
831
|
+
updateDragDrop(element);
|
|
832
|
+
}
|
|
833
|
+
container.appendChild(element);
|
|
834
|
+
}
|
|
835
|
+
this.onPropertyChanged("footer");
|
|
836
|
+
}
|
|
837
|
+
render(node, e, creator) {
|
|
838
|
+
if (!this.creator && this !== creator) {
|
|
839
|
+
this.creator = creator;
|
|
840
|
+
}
|
|
841
|
+
this.render = super.render;
|
|
842
|
+
return super.render(node, e, creator);
|
|
843
|
+
}
|
|
844
|
+
preCreate() {
|
|
845
|
+
this.orderBy = null;
|
|
846
|
+
this.mergeOnRefresh = false;
|
|
847
|
+
this.selectOnClick = false;
|
|
848
|
+
this.element.setAttribute("data-click-event", "item-click");
|
|
849
|
+
}
|
|
850
|
+
dispatchCustomEvent(type, detail) {
|
|
851
|
+
if (!this.element) {
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
const eventName = this.element.getAttribute("data-" + type + "-event");
|
|
855
|
+
type = StringHelper.fromHyphenToCamel(eventName ?? type);
|
|
856
|
+
this.element.dispatchEvent(new CustomEvent(type, {
|
|
857
|
+
detail,
|
|
858
|
+
bubbles: eventName !== null,
|
|
859
|
+
cancelable: true
|
|
860
|
+
}));
|
|
861
|
+
}
|
|
862
|
+
updateClasses() {
|
|
863
|
+
const container = this.itemsPresenter ?? this.element;
|
|
864
|
+
const items = this.items;
|
|
865
|
+
let element = getFirstChild(container);
|
|
866
|
+
const vp = this.valuePath ?? (i => i);
|
|
867
|
+
const si = (this.selectedItems ?? []).map(vp);
|
|
868
|
+
while (element) {
|
|
869
|
+
const index = ~~element.getAttribute("data-item-index");
|
|
870
|
+
const item = items[index];
|
|
871
|
+
const v = vp(item);
|
|
872
|
+
if (si.indexOf(v) !== -1) {
|
|
873
|
+
element.setAttribute("data-selected-item", "true");
|
|
874
|
+
} else {
|
|
875
|
+
element.removeAttribute("data-selected-item");
|
|
876
|
+
}
|
|
877
|
+
element = element.nextElementSibling;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
updateVisibility() {
|
|
881
|
+
const container = this.itemsPresenter ?? this.element;
|
|
882
|
+
const items = this.items;
|
|
883
|
+
let element = container.firstElementChild;
|
|
884
|
+
const vf = this.visibilityFilter ?? MatchTrue;
|
|
885
|
+
while (element) {
|
|
886
|
+
const index = ~~element.getAttribute("data-item-index");
|
|
887
|
+
const item = items[index];
|
|
888
|
+
if (vf(item)) {
|
|
889
|
+
element.removeAttribute("data-ui-display");
|
|
890
|
+
} else {
|
|
891
|
+
element.setAttribute("data-ui-display", "none");
|
|
892
|
+
}
|
|
893
|
+
element = element.nextElementSibling;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
updateHeaderFooter(name, presenter, item, itemRenderer, insert) {
|
|
897
|
+
presenter ??= this.itemsPresenter ??= this.element;
|
|
898
|
+
if (!presenter) {
|
|
899
|
+
this[name + "Element"] = null;
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
let current;
|
|
903
|
+
if (insert) {
|
|
904
|
+
current = presenter.firstElementChild;
|
|
905
|
+
while (current && current.dataset[name] !== name) {
|
|
906
|
+
current = current.nextElementSibling;
|
|
907
|
+
}
|
|
908
|
+
} else {
|
|
909
|
+
current = presenter.lastElementChild;
|
|
910
|
+
while (current && current.dataset[name] !== name) {
|
|
911
|
+
current = current.previousElementSibling;
|
|
912
|
+
}
|
|
917
913
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
914
|
+
if (current) {
|
|
915
|
+
disposeChild(this, current);
|
|
916
|
+
this[name + "Element"] = null;
|
|
917
|
+
}
|
|
918
|
+
if (!(item && itemRenderer)) {
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
const node = itemRenderer(item);
|
|
922
|
+
const element = document.createElement(node.attributes?.for ?? node.name ?? "div");
|
|
923
|
+
element.dataset[name] = name;
|
|
924
|
+
this.render(node, element, this.creator || this);
|
|
925
|
+
if (insert) {
|
|
926
|
+
presenter.insertBefore(element, presenter.firstElementChild);
|
|
927
|
+
} else {
|
|
928
|
+
presenter.appendChild(element);
|
|
929
|
+
}
|
|
930
|
+
this[name + "Element"] = element;
|
|
931
|
+
}
|
|
932
|
+
dispatchHeaderFooterEvent(eventName, type, recreate, originalTarget) {
|
|
933
|
+
const detail = this[type];
|
|
934
|
+
const ce = new CustomEvent(eventName ?? `${type}Click`, {
|
|
935
|
+
detail,
|
|
936
|
+
bubbles: this.bubbleEvents,
|
|
937
|
+
cancelable: true
|
|
938
|
+
});
|
|
939
|
+
originalTarget.dispatchEvent(ce);
|
|
940
|
+
if (ce.defaultPrevented || !ce.executed) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
if (recreate) {
|
|
944
|
+
this.onPropertyChanged(type);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
dispatchItemEvent(eventName, item, recreate, originalTarget, nestedItem) {
|
|
948
|
+
const ce = new CustomEvent(eventName ?? "itemClick", {
|
|
949
|
+
detail: nestedItem ?? item,
|
|
950
|
+
bubbles: this.bubbleEvents,
|
|
951
|
+
cancelable: true
|
|
952
|
+
});
|
|
953
|
+
originalTarget.dispatchEvent(ce);
|
|
954
|
+
if (!ce.defaultPrevented) {
|
|
955
|
+
if (this.selectOnClick || eventName === "itemSelect" || eventName === "itemDeselect") {
|
|
956
|
+
const si = this.selectedItems ??= [];
|
|
957
|
+
if (si) {
|
|
958
|
+
const index = si.indexOf(item);
|
|
959
|
+
if (index === -1) {
|
|
960
|
+
if (this.allowMultipleSelection) {
|
|
961
|
+
si.add(item);
|
|
962
|
+
} else {
|
|
963
|
+
si.set(0, item);
|
|
927
964
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
this.dispatchHeaderFooterEvent(clickEvent, header, recreate, e.target);
|
|
932
|
-
}
|
|
933
|
-
if (footer) {
|
|
934
|
-
this.dispatchHeaderFooterEvent(clickEvent, footer, recreate, e.target);
|
|
965
|
+
} else {
|
|
966
|
+
si.removeAt(index);
|
|
967
|
+
}
|
|
935
968
|
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
if (ce.defaultPrevented || !ce.executed) {
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
const promise = ce.promise;
|
|
975
|
+
if (recreate) {
|
|
976
|
+
this.refreshItem(item, promise);
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
if (promise) {
|
|
980
|
+
promise.then(r => r instanceof MergeNode && this.refreshItem(item, r));
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
dispatchClickEvent(e, data) {
|
|
984
|
+
const {
|
|
985
|
+
recreate,
|
|
986
|
+
header,
|
|
987
|
+
footer,
|
|
988
|
+
itemIndex,
|
|
989
|
+
itemPath,
|
|
990
|
+
clickEvent,
|
|
991
|
+
item,
|
|
992
|
+
nestedItem
|
|
993
|
+
} = AtomRepeater.itemFromElement(e.target, this);
|
|
994
|
+
if (itemIndex !== void 0) {
|
|
995
|
+
if (item) {
|
|
996
|
+
if (nestedItem) {
|
|
997
|
+
this.dispatchItemEvent(clickEvent, item, recreate, e.target, nestedItem);
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
this.dispatchItemEvent(clickEvent, item, recreate, e.target);
|
|
1001
|
+
}
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
if (header) {
|
|
1005
|
+
this.dispatchHeaderFooterEvent(clickEvent, header, recreate, e.target);
|
|
936
1006
|
}
|
|
1007
|
+
if (footer) {
|
|
1008
|
+
this.dispatchHeaderFooterEvent(clickEvent, footer, recreate, e.target);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
937
1011
|
}
|
|
938
|
-
__decorate([
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
], AtomRepeater.prototype, "
|
|
942
|
-
__decorate([
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
], AtomRepeater.prototype, "
|
|
946
|
-
__decorate([
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
], AtomRepeater.prototype, "
|
|
950
|
-
__decorate([
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
], AtomRepeater.prototype, "
|
|
954
|
-
__decorate([
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
], AtomRepeater.prototype, "items", void 0);
|
|
958
|
-
__decorate([
|
|
959
|
-
BindableProperty,
|
|
960
|
-
__metadata("design:type", Object)
|
|
961
|
-
], AtomRepeater.prototype, "watch", void 0);
|
|
962
|
-
__decorate([
|
|
963
|
-
BindableProperty,
|
|
964
|
-
__metadata("design:type", Function)
|
|
965
|
-
], AtomRepeater.prototype, "visibilityFilter", void 0);
|
|
966
|
-
__decorate([
|
|
967
|
-
BindableProperty,
|
|
968
|
-
__metadata("design:type", Function)
|
|
969
|
-
], AtomRepeater.prototype, "enableFunc", void 0);
|
|
970
|
-
__decorate([
|
|
971
|
-
BindableProperty,
|
|
972
|
-
__metadata("design:type", Function)
|
|
973
|
-
], AtomRepeater.prototype, "itemRenderer", void 0);
|
|
974
|
-
__decorate([
|
|
975
|
-
BindableProperty,
|
|
976
|
-
__metadata("design:type", Function)
|
|
977
|
-
], AtomRepeater.prototype, "valuePath", void 0);
|
|
978
|
-
__decorate([
|
|
979
|
-
BindableProperty,
|
|
980
|
-
__metadata("design:type", Function)
|
|
981
|
-
], AtomRepeater.prototype, "comparer", void 0);
|
|
982
|
-
__decorate([
|
|
983
|
-
BindableProperty,
|
|
984
|
-
__metadata("design:type", Boolean)
|
|
985
|
-
], AtomRepeater.prototype, "deferUpdates", void 0);
|
|
986
|
-
__decorate([
|
|
987
|
-
BindableProperty,
|
|
988
|
-
__metadata("design:type", Object)
|
|
989
|
-
], AtomRepeater.prototype, "header", void 0);
|
|
990
|
-
__decorate([
|
|
991
|
-
BindableProperty,
|
|
992
|
-
__metadata("design:type", Object)
|
|
993
|
-
], AtomRepeater.prototype, "headerRenderer", void 0);
|
|
994
|
-
__decorate([
|
|
995
|
-
BindableProperty,
|
|
996
|
-
__metadata("design:type", Object)
|
|
997
|
-
], AtomRepeater.prototype, "footer", void 0);
|
|
998
|
-
__decorate([
|
|
999
|
-
BindableProperty,
|
|
1000
|
-
__metadata("design:type", Object)
|
|
1001
|
-
], AtomRepeater.prototype, "footerRenderer", void 0);
|
|
1002
|
-
__decorate([
|
|
1003
|
-
BindableProperty,
|
|
1004
|
-
__metadata("design:type", Object)
|
|
1005
|
-
], AtomRepeater.prototype, "enableDragDrop", void 0);
|
|
1006
|
-
__decorate([
|
|
1007
|
-
BindableProperty,
|
|
1008
|
-
__metadata("design:type", Object)
|
|
1009
|
-
], AtomRepeater.prototype, "orderBy", void 0);
|
|
1010
|
-
__decorate([
|
|
1011
|
-
WatchProperty,
|
|
1012
|
-
__metadata("design:type", Object),
|
|
1013
|
-
__metadata("design:paramtypes", [])
|
|
1014
|
-
], AtomRepeater.prototype, "allSelected", null);
|
|
1012
|
+
__decorate([BindableProperty, __metadata("design:type", Boolean)], AtomRepeater.prototype, "allowMultipleSelection", void 0);
|
|
1013
|
+
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "selectOnClick", void 0);
|
|
1014
|
+
__decorate([BindableProperty, __metadata("design:type", Array)], AtomRepeater.prototype, "selectedItems", void 0);
|
|
1015
|
+
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "itemsPresenter", void 0);
|
|
1016
|
+
__decorate([BindableProperty, __metadata("design:type", Array)], AtomRepeater.prototype, "items", void 0);
|
|
1017
|
+
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "watch", void 0);
|
|
1018
|
+
__decorate([BindableProperty, __metadata("design:type", Function)], AtomRepeater.prototype, "visibilityFilter", void 0);
|
|
1019
|
+
__decorate([BindableProperty, __metadata("design:type", Function)], AtomRepeater.prototype, "enableFunc", void 0);
|
|
1020
|
+
__decorate([BindableProperty, __metadata("design:type", Function)], AtomRepeater.prototype, "itemRenderer", void 0);
|
|
1021
|
+
__decorate([BindableProperty, __metadata("design:type", Function)], AtomRepeater.prototype, "valuePath", void 0);
|
|
1022
|
+
__decorate([BindableProperty, __metadata("design:type", Function)], AtomRepeater.prototype, "comparer", void 0);
|
|
1023
|
+
__decorate([BindableProperty, __metadata("design:type", Boolean)], AtomRepeater.prototype, "deferUpdates", void 0);
|
|
1024
|
+
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "header", void 0);
|
|
1025
|
+
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "headerRenderer", void 0);
|
|
1026
|
+
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "footer", void 0);
|
|
1027
|
+
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "footerRenderer", void 0);
|
|
1028
|
+
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "enableDragDrop", void 0);
|
|
1029
|
+
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "orderBy", void 0);
|
|
1030
|
+
__decorate([WatchProperty, __metadata("design:type", Object), __metadata("design:paramtypes", [])], AtomRepeater.prototype, "allSelected", null);
|
|
1015
1031
|
let hoverItem = {
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1032
|
+
repeater: null,
|
|
1033
|
+
target: null,
|
|
1034
|
+
item: null,
|
|
1035
|
+
placeholder: null
|
|
1020
1036
|
};
|
|
1021
|
-
document.body.addEventListener("dragstart",
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
placeholder.style.width = target.offsetWidth + "px";
|
|
1034
|
-
placeholder.style.height = target.offsetHeight + "px";
|
|
1035
|
-
placeholder.style.backgroundColor = Colors.lightGray.toString();
|
|
1036
|
-
placeholder.style.border = "solid 1px gray";
|
|
1037
|
-
placeholder.style.borderRadius = "10px";
|
|
1038
|
-
hoverItem = {
|
|
1039
|
-
repeater,
|
|
1040
|
-
target,
|
|
1041
|
-
item,
|
|
1042
|
-
placeholder,
|
|
1043
|
-
};
|
|
1044
|
-
e.dataTransfer.dropEffect = "move";
|
|
1045
|
-
setTimeout(() => {
|
|
1046
|
-
target.style.display = "none";
|
|
1047
|
-
target.parentElement.insertBefore(placeholder, target);
|
|
1048
|
-
}, 0);
|
|
1037
|
+
document.body.addEventListener("dragstart", e => {
|
|
1038
|
+
const {
|
|
1039
|
+
target
|
|
1040
|
+
} = e;
|
|
1041
|
+
if (target.draggable) {
|
|
1042
|
+
const ri = getParentRepeaterItem(target);
|
|
1043
|
+
if (!ri) {
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
const [type, repeater, item, index] = ri;
|
|
1047
|
+
if (!repeater || !repeater.enableDragDrop) {
|
|
1048
|
+
return;
|
|
1049
1049
|
}
|
|
1050
|
+
const placeholder = document.createElement("div");
|
|
1051
|
+
placeholder.style.width = target.offsetWidth + "px";
|
|
1052
|
+
placeholder.style.height = target.offsetHeight + "px";
|
|
1053
|
+
placeholder.style.backgroundColor = Colors.lightGray.toString();
|
|
1054
|
+
placeholder.style.border = "solid 1px gray";
|
|
1055
|
+
placeholder.style.borderRadius = "10px";
|
|
1056
|
+
hoverItem = {
|
|
1057
|
+
repeater,
|
|
1058
|
+
target,
|
|
1059
|
+
item,
|
|
1060
|
+
placeholder
|
|
1061
|
+
};
|
|
1062
|
+
e.dataTransfer.dropEffect = "move";
|
|
1063
|
+
setTimeout(() => {
|
|
1064
|
+
target.style.display = "none";
|
|
1065
|
+
target.parentElement.insertBefore(placeholder, target);
|
|
1066
|
+
}, 0);
|
|
1067
|
+
}
|
|
1050
1068
|
});
|
|
1051
|
-
document.body.addEventListener("dragend",
|
|
1052
|
-
|
|
1053
|
-
|
|
1069
|
+
document.body.addEventListener("dragend", e => {
|
|
1070
|
+
if (!hoverItem?.placeholder) {
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
const {
|
|
1074
|
+
item,
|
|
1075
|
+
placeholder,
|
|
1076
|
+
repeater
|
|
1077
|
+
} = hoverItem;
|
|
1078
|
+
let start = placeholder;
|
|
1079
|
+
let index = -1;
|
|
1080
|
+
while (start) {
|
|
1081
|
+
const itemIndex = start.previousElementSibling?.dataset?.itemIndex;
|
|
1082
|
+
if (itemIndex !== void 0) {
|
|
1083
|
+
index = ~~itemIndex;
|
|
1054
1084
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
let index = -1;
|
|
1058
|
-
while (start) {
|
|
1059
|
-
const itemIndex = start.previousElementSibling?.dataset?.itemIndex;
|
|
1060
|
-
if (itemIndex !== void 0) {
|
|
1061
|
-
index = ~~itemIndex;
|
|
1062
|
-
}
|
|
1063
|
-
if (start.parentElement.atomControl) {
|
|
1064
|
-
break;
|
|
1065
|
-
}
|
|
1066
|
-
start = start.parentElement;
|
|
1067
|
-
}
|
|
1068
|
-
const targetRepeater = start.parentElement.atomControl;
|
|
1069
|
-
placeholder.remove();
|
|
1070
|
-
hoverItem.placeholder = null;
|
|
1071
|
-
repeater.items.remove(item);
|
|
1072
|
-
index++;
|
|
1073
|
-
const ce = new CustomEvent("itemDropped", { detail: { item, index } });
|
|
1074
|
-
if (ce.defaultPrevented) {
|
|
1075
|
-
return;
|
|
1085
|
+
if (start.parentElement.atomControl) {
|
|
1086
|
+
break;
|
|
1076
1087
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1088
|
+
start = start.parentElement;
|
|
1089
|
+
}
|
|
1090
|
+
const targetRepeater = start.parentElement.atomControl;
|
|
1091
|
+
placeholder.remove();
|
|
1092
|
+
hoverItem.placeholder = null;
|
|
1093
|
+
repeater.items.remove(item);
|
|
1094
|
+
index++;
|
|
1095
|
+
const ce = new CustomEvent("itemDropped", {
|
|
1096
|
+
detail: {
|
|
1097
|
+
item,
|
|
1098
|
+
index
|
|
1083
1099
|
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1100
|
+
});
|
|
1101
|
+
if (ce.defaultPrevented) {
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
const {
|
|
1105
|
+
detail
|
|
1106
|
+
} = ce;
|
|
1107
|
+
targetRepeater.items.insert(detail.index, detail.item);
|
|
1108
|
+
});
|
|
1109
|
+
const dragOver = e => {
|
|
1110
|
+
if (!e.dataTransfer) {
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
if (hoverItem) {
|
|
1114
|
+
const {
|
|
1115
|
+
placeholder
|
|
1116
|
+
} = hoverItem;
|
|
1117
|
+
if (!placeholder) {
|
|
1118
|
+
return;
|
|
1092
1119
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
return;
|
|
1120
|
+
if (e.target === placeholder) {
|
|
1121
|
+
return;
|
|
1096
1122
|
}
|
|
1097
|
-
|
|
1098
|
-
|
|
1123
|
+
}
|
|
1124
|
+
const ri = getParentRepeaterItem(e.target);
|
|
1125
|
+
if (!ri) {
|
|
1126
|
+
return;
|
|
1127
|
+
}
|
|
1128
|
+
const [type, repeater, item, index, target] = ri;
|
|
1129
|
+
if (!repeater) {
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
if (hoverItem) {
|
|
1133
|
+
const {
|
|
1134
|
+
placeholder
|
|
1135
|
+
} = hoverItem;
|
|
1136
|
+
e.preventDefault();
|
|
1137
|
+
const mp = {
|
|
1138
|
+
x: e.clientX,
|
|
1139
|
+
y: e.clientY
|
|
1140
|
+
};
|
|
1141
|
+
const isBefore = (co, n) => n.x <= co.x + co.width * 0.3 || n.y <= co.y + co.height * 0.3;
|
|
1142
|
+
const isAfter = (co, n) => n.x >= co.x + co.width * 0.7 || n.y >= co.y + co.height * 0.7;
|
|
1143
|
+
const targetBounds = target.getBoundingClientRect();
|
|
1144
|
+
if (isAfter(targetBounds, mp)) {
|
|
1145
|
+
const next = target.nextElementSibling;
|
|
1146
|
+
if (next === placeholder) {
|
|
1099
1147
|
return;
|
|
1148
|
+
}
|
|
1149
|
+
placeholder.remove();
|
|
1150
|
+
target.insertAdjacentElement("afterend", placeholder);
|
|
1151
|
+
return;
|
|
1100
1152
|
}
|
|
1101
|
-
if (
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
const mp = { x: e.clientX, y: e.clientY };
|
|
1105
|
-
const isBefore = (co, n) => n.x <= (co.x + (co.width * 0.3)) || n.y <= (co.y + (co.height * 0.3));
|
|
1106
|
-
const isAfter = (co, n) => n.x >= (co.x + (co.width * 0.7)) || n.y >= (co.y + (co.height * 0.7));
|
|
1107
|
-
const targetBounds = target.getBoundingClientRect();
|
|
1108
|
-
if (isAfter(targetBounds, mp)) {
|
|
1109
|
-
const next = target.nextElementSibling;
|
|
1110
|
-
if (next === placeholder) {
|
|
1111
|
-
return;
|
|
1112
|
-
}
|
|
1113
|
-
placeholder.remove();
|
|
1114
|
-
target.insertAdjacentElement("afterend", placeholder);
|
|
1115
|
-
return;
|
|
1116
|
-
}
|
|
1117
|
-
if (isBefore(targetBounds, mp)) {
|
|
1118
|
-
const previous = target.previousElementSibling;
|
|
1119
|
-
if (previous === placeholder) {
|
|
1120
|
-
return;
|
|
1121
|
-
}
|
|
1122
|
-
placeholder.remove();
|
|
1123
|
-
target.insertAdjacentElement("beforebegin", placeholder);
|
|
1124
|
-
}
|
|
1153
|
+
if (isBefore(targetBounds, mp)) {
|
|
1154
|
+
const previous = target.previousElementSibling;
|
|
1155
|
+
if (previous === placeholder) {
|
|
1125
1156
|
return;
|
|
1157
|
+
}
|
|
1158
|
+
placeholder.remove();
|
|
1159
|
+
target.insertAdjacentElement("beforebegin", placeholder);
|
|
1126
1160
|
}
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1127
1163
|
};
|
|
1128
1164
|
document.body.addEventListener("dragover", dragOver);
|
|
1129
|
-
document.body.addEventListener("dragenter", dragOver);
|
|
1130
|
-
//# sourceMappingURL=AtomRepeater.js.map
|
|
1165
|
+
document.body.addEventListener("dragenter", dragOver);
|