@web-atoms/core 2.6.21 → 2.6.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +1 -1
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js.map +1 -1
- package/dist/core/SingleInvoker.d.ts.map +1 -1
- package/dist/core/SingleInvoker.js.map +1 -1
- package/dist/core/sleep.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist-esm/App.d.ts +1 -1
- package/dist-esm/App.d.ts.map +1 -1
- package/dist-esm/App.js +231 -235
- package/dist-esm/App.js.map +1 -1
- package/dist-esm/Atom.js +93 -96
- package/dist-esm/MockApp.js +17 -18
- package/dist-esm/Pack.js +1 -3
- package/dist-esm/core/AtomBinder.js +189 -187
- package/dist-esm/core/AtomComponent.js +479 -502
- package/dist-esm/core/AtomDispatcher.js +46 -48
- package/dist-esm/core/AtomDisposableList.js +24 -25
- package/dist-esm/core/AtomEnumerator.js +15 -16
- package/dist-esm/core/AtomList.js +193 -192
- package/dist-esm/core/AtomLoader.js +229 -215
- package/dist-esm/core/AtomMap.js +7 -8
- package/dist-esm/core/AtomOnce.js +22 -24
- package/dist-esm/core/AtomSelectableList.js +240 -243
- package/dist-esm/core/AtomUri.js +70 -72
- package/dist-esm/core/AtomWatcher.js +105 -111
- package/dist-esm/core/Bind.js +271 -269
- package/dist-esm/core/BindableProperty.js +26 -27
- package/dist-esm/core/CancelTokenFactory.js +21 -24
- package/dist-esm/core/Color.js +1 -2
- package/dist-esm/core/Colors.js +545 -231
- package/dist-esm/core/Command.js +236 -223
- package/dist-esm/core/Defer.js +21 -22
- package/dist-esm/core/EventScope.js +96 -88
- package/dist-esm/core/ExpressionParser.js +132 -144
- package/dist-esm/core/ExtendControl.js +7 -8
- package/dist-esm/core/FormattedError.js +7 -8
- package/dist-esm/core/FormattedString.js +4 -5
- package/dist-esm/core/Hacks.js +41 -42
- package/dist-esm/core/IFetchEvent.js +1 -2
- package/dist-esm/core/IScreen.js +1 -2
- package/dist-esm/core/IValueConverter.js +1 -2
- package/dist-esm/core/InheritedProperty.js +61 -63
- package/dist-esm/core/InjectProperty.js +12 -13
- package/dist-esm/core/KeyValuePairs.js +1 -2
- package/dist-esm/core/Markdown.js +14 -17
- package/dist-esm/core/MarkdownError.js +6 -7
- package/dist-esm/core/PropertyBinding.js +1 -2
- package/dist-esm/core/PropertyMap.js +28 -27
- package/dist-esm/core/Route.js +149 -148
- package/dist-esm/core/SingleInvoker.d.ts.map +1 -1
- package/dist-esm/core/SingleInvoker.js +32 -35
- package/dist-esm/core/SingleInvoker.js.map +1 -1
- package/dist-esm/core/StringHelper.js +49 -51
- package/dist-esm/core/TransientDisposable.js +14 -16
- package/dist-esm/core/WatchProperty.js +18 -17
- package/dist-esm/core/WebImage.js +7 -8
- package/dist-esm/core/XNode.js +134 -117
- package/dist-esm/core/sleep.js +21 -24
- package/dist-esm/core/sleep.js.map +1 -1
- package/dist-esm/core/types.js +102 -103
- package/dist-esm/di/DISingleton.js +7 -5
- package/dist-esm/di/DITransient.js +7 -5
- package/dist-esm/di/IMockOrInject.js +1 -2
- package/dist-esm/di/IServiceProvider.js +1 -2
- package/dist-esm/di/Inject.js +67 -67
- package/dist-esm/di/Register.js +25 -26
- package/dist-esm/di/RegisterScoped.js +4 -3
- package/dist-esm/di/RegisterSingleton.js +4 -3
- package/dist-esm/di/ServiceCollection.js +38 -37
- package/dist-esm/di/ServiceProvider.js +94 -94
- package/dist-esm/di/TypeKey.js +13 -12
- package/dist-esm/services/BusyIndicatorService.js +7 -11
- package/dist-esm/services/CacheService.js +54 -62
- package/dist-esm/services/FetchBuilder.js +327 -278
- package/dist-esm/services/JsonService.js +118 -116
- package/dist-esm/services/MockNavigationService.js +127 -126
- package/dist-esm/services/NavigationService.js +95 -102
- package/dist-esm/services/ReferenceService.js +30 -33
- package/dist-esm/services/http/AjaxOptions.js +1 -3
- package/dist-esm/services/http/JsonError.js +16 -15
- package/dist-esm/services/http/RestService.js +314 -323
- package/dist-esm/style/StyleRule.js +1 -2
- package/dist-esm/test.js +0 -1
- package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist-esm/unit/AtomTest.js +10 -11
- package/dist-esm/view-model/Action.js +258 -223
- package/dist-esm/view-model/AtomViewModel.js +234 -232
- package/dist-esm/view-model/AtomWindowViewModel.js +13 -14
- package/dist-esm/view-model/BindableUrlParameter.js +7 -8
- package/dist-esm/view-model/Delay.js +21 -25
- package/dist-esm/view-model/Disposable.js +28 -29
- package/dist-esm/view-model/Load.js +72 -73
- package/dist-esm/view-model/Once.js +33 -35
- package/dist-esm/view-model/baseTypes.js +4 -5
- package/dist-esm/view-model/bindPromise.js +24 -27
- package/dist-esm/view-model/bindProperty.js +3 -4
- package/dist-esm/view-model/bindUrlParameter.js +39 -43
- package/dist-esm/web/controls/AtomComboBox.js +56 -63
- package/dist-esm/web/controls/AtomControl.js +485 -490
- package/dist-esm/web/controls/AtomGridSplitter.js +57 -50
- package/dist-esm/web/controls/AtomGridView.js +230 -222
- package/dist-esm/web/controls/AtomItemsControl.js +677 -688
- package/dist-esm/web/controls/AtomPage.js +6 -7
- package/dist-esm/web/controls/AtomTemplate.js +1 -3
- package/dist-esm/web/controls/AtomTemplateControl.js +28 -29
- package/dist-esm/web/controls/AtomViewStack.js +19 -20
- package/dist-esm/web/core/AtomUI.js +200 -200
- package/dist-esm/web/core/Encoder.js +142 -152
- package/dist-esm/web/core/HtmlNode.js +141 -139
- package/dist-esm/web/images/Busy.js +1 -2
- package/dist-esm/web/images/BusyDataUrl.js +2 -869
- package/dist-esm/web/images/Button.js +1 -2
- package/dist-esm/web/images/ButtonDataUrl.js +2 -30
- package/dist-esm/web/images/CloseButton.js +1 -2
- package/dist-esm/web/images/CloseButtonDataUrl.js +2 -30
- package/dist-esm/web/images/CloseButtonHover.js +1 -2
- package/dist-esm/web/images/CloseButtonHoverDataUrl.js +2 -24
- package/dist-esm/web/services/LastTarget.js +31 -29
- package/dist-esm/web/services/MarkdownService.js +19 -31
- package/dist-esm/web/services/NotificationPopup.js +28 -21
- package/dist-esm/web/services/PopupService.js +512 -478
- package/dist-esm/web/services/PopupWindow.js +266 -247
- package/dist-esm/web/styles/AtomAlertWindowStyle.js +39 -40
- package/dist-esm/web/styles/AtomFrameStyle.js +15 -16
- package/dist-esm/web/styles/AtomNotificationStyle.js +19 -20
- package/dist-esm/web/styles/AtomPageLinkStyle.js +11 -12
- package/dist-esm/web/styles/AtomPopupStyle.js +9 -10
- package/dist-esm/web/styles/AtomStyle.js +61 -64
- package/dist-esm/web/styles/AtomStyleSheet.js +50 -51
- package/dist-esm/web/styles/AtomWindowStyle.js +116 -117
- package/dist-esm/web/styles/IStyleDeclaration.js +1 -2
- package/dist-esm/web/styles/StyleBuilder.js +79 -80
- package/package.json +3 -1
- package/src/App.ts +1 -1
- package/src/core/SingleInvoker.ts +1 -1
- package/src/core/sleep.ts +1 -1
|
@@ -5,702 +5,691 @@ import XNode from "../../core/XNode.js";
|
|
|
5
5
|
import { AtomUI, ChildEnumerator } from "../../web/core/AtomUI.js";
|
|
6
6
|
import { AtomControl } from "./AtomControl.js";
|
|
7
7
|
export class AtomItemsControl extends AtomControl {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
items = items.map((m) => m[this.valuePath]);
|
|
37
|
-
if (this.valueSeparator) {
|
|
38
|
-
items = items.join(this.valueSeparator);
|
|
39
|
-
}
|
|
40
|
-
return items;
|
|
41
|
-
}
|
|
42
|
-
let s = this.selectedItem;
|
|
43
|
-
if (!s) {
|
|
44
|
-
if (this.mValue !== undefined) {
|
|
45
|
-
return this.mValue;
|
|
46
|
-
}
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
if (this.valuePath) {
|
|
50
|
-
s = s[this.valuePath];
|
|
51
|
-
}
|
|
52
|
-
return s;
|
|
53
|
-
}
|
|
54
|
-
set value(v) {
|
|
55
|
-
this.mValue = v;
|
|
56
|
-
const dataItems = this.items;
|
|
57
|
-
if (!dataItems) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const sItems = this.selectedItems;
|
|
61
|
-
if (v === undefined || v === null) {
|
|
62
|
-
AtomBinder.clear(sItems);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (this.allowMultipleSelection && this.valueSeparator) {
|
|
66
|
-
if (typeof v !== "string") {
|
|
67
|
-
v = "" + v;
|
|
68
|
-
}
|
|
69
|
-
v = v.split(this.valueSeparator);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
v = [v];
|
|
73
|
-
}
|
|
74
|
-
sItems.length = 0;
|
|
75
|
-
const vp = this.valuePath;
|
|
76
|
-
for (const item of v) {
|
|
77
|
-
const dataItem = dataItems.find((i) => i[vp] == v);
|
|
78
|
-
if (dataItem) {
|
|
79
|
-
sItems.push(dataItem);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
AtomBinder.refreshItems(sItems);
|
|
83
|
-
}
|
|
84
|
-
get items() {
|
|
85
|
-
return this.mItems;
|
|
86
|
-
}
|
|
87
|
-
set items(v) {
|
|
88
|
-
if (this.mItemsDisposable) {
|
|
89
|
-
this.mItemsDisposable.dispose();
|
|
90
|
-
this.mItemsDisposable = null;
|
|
91
|
-
}
|
|
92
|
-
this.mItems = v;
|
|
93
|
-
if (v != null) {
|
|
94
|
-
this.mItemsDisposable = this.registerDisposable(AtomBinder.add_CollectionChanged(v, (target, key, index, item) => {
|
|
95
|
-
this.onCollectionChangedInternal(key, index, item);
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
AtomBinder.refreshValue(this, "items");
|
|
99
|
-
}
|
|
100
|
-
get selectedItem() {
|
|
101
|
-
if (this.selectedItems.length > 0) {
|
|
102
|
-
return this.selectedItems[0];
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.mValue = undefined;
|
|
11
|
+
this.mFilter = undefined;
|
|
12
|
+
this.mFirstChild = null;
|
|
13
|
+
this.mLastChild = null;
|
|
14
|
+
this.mScrollerSetup = false;
|
|
15
|
+
this.mScopes = null;
|
|
16
|
+
this.mItemsDisposable = null;
|
|
17
|
+
this.isUpdating = false;
|
|
18
|
+
}
|
|
19
|
+
static {
|
|
20
|
+
this.itemTemplate = XNode.prepare("itemTemplate", true, true);
|
|
21
|
+
}
|
|
22
|
+
get itemsPresenter() {
|
|
23
|
+
return this.mItemsPresenter || (this.mItemsPresenter = this.element);
|
|
24
|
+
}
|
|
25
|
+
set itemsPresenter(v) {
|
|
26
|
+
this.mItemsPresenter = v;
|
|
27
|
+
AtomBinder.refreshValue(this, "itemsPresenter");
|
|
28
|
+
}
|
|
29
|
+
get value() {
|
|
30
|
+
if (this.allowMultipleSelection) {
|
|
31
|
+
let items = this.mSelectedItems;
|
|
32
|
+
if (items.length === 0) {
|
|
33
|
+
if (this.mValue !== undefined) {
|
|
34
|
+
return this.mValue;
|
|
103
35
|
}
|
|
104
36
|
return null;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
this.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
37
|
+
}
|
|
38
|
+
items = items.map(m => m[this.valuePath]);
|
|
39
|
+
if (this.valueSeparator) {
|
|
40
|
+
items = items.join(this.valueSeparator);
|
|
41
|
+
}
|
|
42
|
+
return items;
|
|
43
|
+
}
|
|
44
|
+
let s = this.selectedItem;
|
|
45
|
+
if (!s) {
|
|
46
|
+
if (this.mValue !== undefined) {
|
|
47
|
+
return this.mValue;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (this.valuePath) {
|
|
52
|
+
s = s[this.valuePath];
|
|
53
|
+
}
|
|
54
|
+
return s;
|
|
55
|
+
}
|
|
56
|
+
set value(v) {
|
|
57
|
+
this.mValue = v;
|
|
58
|
+
const dataItems = this.items;
|
|
59
|
+
if (!dataItems) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const sItems = this.selectedItems;
|
|
63
|
+
if (v === undefined || v === null) {
|
|
64
|
+
AtomBinder.clear(sItems);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (this.allowMultipleSelection && this.valueSeparator) {
|
|
68
|
+
if (typeof v !== "string") {
|
|
69
|
+
v = "" + v;
|
|
70
|
+
}
|
|
71
|
+
v = v.split(this.valueSeparator);
|
|
72
|
+
} else {
|
|
73
|
+
v = [v];
|
|
74
|
+
}
|
|
75
|
+
sItems.length = 0;
|
|
76
|
+
const vp = this.valuePath;
|
|
77
|
+
for (const item of v) {
|
|
78
|
+
const dataItem = dataItems.find(i => i[vp] == v);
|
|
79
|
+
if (dataItem) {
|
|
80
|
+
sItems.push(dataItem);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
AtomBinder.refreshItems(sItems);
|
|
84
|
+
}
|
|
85
|
+
get items() {
|
|
86
|
+
return this.mItems;
|
|
87
|
+
}
|
|
88
|
+
set items(v) {
|
|
89
|
+
if (this.mItemsDisposable) {
|
|
90
|
+
this.mItemsDisposable.dispose();
|
|
91
|
+
this.mItemsDisposable = null;
|
|
92
|
+
}
|
|
93
|
+
this.mItems = v;
|
|
94
|
+
if (v != null) {
|
|
95
|
+
this.mItemsDisposable = this.registerDisposable(AtomBinder.add_CollectionChanged(v, (target, key, index, item) => {
|
|
96
|
+
this.onCollectionChangedInternal(key, index, item);
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
AtomBinder.refreshValue(this, "items");
|
|
100
|
+
}
|
|
101
|
+
get selectedItem() {
|
|
102
|
+
if (this.selectedItems.length > 0) {
|
|
103
|
+
return this.selectedItems[0];
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
set selectedItem(value) {
|
|
108
|
+
if (value !== undefined && value !== null) {
|
|
109
|
+
this.mSelectedItems.length = 1;
|
|
110
|
+
this.mSelectedItems[0] = value;
|
|
111
|
+
} else {
|
|
112
|
+
this.mSelectedItems.length = 0;
|
|
113
|
+
}
|
|
114
|
+
AtomBinder.refreshItems(this.mSelectedItems);
|
|
115
|
+
}
|
|
116
|
+
get selectedItems() {
|
|
117
|
+
return this.mSelectedItems || (this.selectedItems = []);
|
|
118
|
+
}
|
|
119
|
+
set selectedItems(v) {
|
|
120
|
+
if (this.mSelectedItemsWatcher) {
|
|
121
|
+
this.mSelectedItemsWatcher.dispose();
|
|
122
|
+
this.mSelectedItemsWatcher = null;
|
|
123
|
+
}
|
|
124
|
+
this.mSelectedItems = v;
|
|
125
|
+
if (v) {
|
|
126
|
+
this.mSelectedItemsWatcher = this.registerDisposable(AtomBinder.add_CollectionChanged(v, (t, k, i, item) => {
|
|
127
|
+
this.onSelectedItemsChanged(k, i, item);
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
get selectedIndex() {
|
|
132
|
+
if (!this.mItems) {
|
|
133
|
+
return -1;
|
|
134
|
+
}
|
|
135
|
+
const item = this.selectedItem;
|
|
136
|
+
return this.mItems.indexOf(item);
|
|
137
|
+
}
|
|
138
|
+
set selectedIndex(n) {
|
|
139
|
+
if (!this.mItems) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (n <= -1 || n >= this.mItems.length) {
|
|
143
|
+
this.selectedItem = null;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.selectedItem = this.mItems[n];
|
|
147
|
+
}
|
|
148
|
+
hasProperty(name) {
|
|
149
|
+
if (/^(items|itemsPresenter|value|valuePath|valueSeparator|label|labelPath|selectedItems|selectedItem|selectedIndex|uiVirtualize|viewModel|localViewModel|data)$/.test(name)) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
return super.hasProperty(name);
|
|
153
|
+
}
|
|
154
|
+
dispose(e) {
|
|
155
|
+
this.items = null;
|
|
156
|
+
this.selectedItems = null;
|
|
157
|
+
super.dispose(e);
|
|
158
|
+
}
|
|
159
|
+
onPropertyChanged(name) {
|
|
160
|
+
switch (name) {
|
|
161
|
+
case "itemsPresenter":
|
|
162
|
+
case "itemTemplate":
|
|
163
|
+
case "labelPath":
|
|
164
|
+
case "valuePath":
|
|
165
|
+
case "items":
|
|
166
|
+
case "filter":
|
|
167
|
+
case "sort":
|
|
168
|
+
if (this.mItems) {
|
|
169
|
+
this.invalidateItems();
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
set selectAll(v) {
|
|
175
|
+
if (v === undefined || v === null) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
this.mSelectedItems.length = 0;
|
|
179
|
+
const items = this.mItems;
|
|
180
|
+
if (v && items) {
|
|
181
|
+
for (const itm of items) {
|
|
182
|
+
this.mSelectedItems.push(itm);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
this.mSelectAll = true;
|
|
186
|
+
AtomBinder.refreshItems(this.mSelectedItems);
|
|
187
|
+
}
|
|
188
|
+
resetVirtualContainer() {
|
|
189
|
+
const ip = this.itemsPresenter;
|
|
190
|
+
if (ip) {
|
|
191
|
+
this.disposeChildren(ip);
|
|
192
|
+
}
|
|
193
|
+
this.mFirstChild = null;
|
|
194
|
+
this.mLastChild = null;
|
|
195
|
+
this.mScrollerSetup = false;
|
|
196
|
+
this.mScopes = null;
|
|
197
|
+
this.unbindEvent(this.mVirtualContainer, "scroll");
|
|
198
|
+
}
|
|
199
|
+
postVirtualCollectionChanged() {
|
|
200
|
+
this.app.callLater(() => {
|
|
201
|
+
this.onVirtualCollectionChanged();
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
onVirtualCollectionChanged() {
|
|
205
|
+
const ip = this.itemsPresenter;
|
|
206
|
+
const items = this.items;
|
|
207
|
+
if (!items.length) {
|
|
208
|
+
this.resetVirtualContainer();
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
this.validateScroller();
|
|
212
|
+
const fc = this.mFirstChild;
|
|
213
|
+
const lc = this.mLastChild;
|
|
214
|
+
const vc = this.mVirtualContainer;
|
|
215
|
+
const vcHeight = AtomUI.innerHeight(vc);
|
|
216
|
+
const vcScrollHeight = vc.scrollHeight;
|
|
217
|
+
if (isNaN(vcHeight) || vcHeight <= 0 || vcScrollHeight <= 0) {
|
|
218
|
+
setTimeout(() => {
|
|
219
|
+
this.onVirtualCollectionChanged();
|
|
220
|
+
}, 1000);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const vcWidth = AtomUI.innerWidth(vc);
|
|
224
|
+
let avgHeight = this.mAvgHeight;
|
|
225
|
+
let avgWidth = this.mAvgWidth;
|
|
226
|
+
const itemsHeight = vc.scrollHeight - AtomUI.outerHeight(fc) - AtomUI.outerHeight(lc);
|
|
227
|
+
const itemsWidth = AtomUI.innerWidth(ip);
|
|
228
|
+
const element = this.element;
|
|
229
|
+
let ce;
|
|
230
|
+
let ae = new AtomEnumerator(items);
|
|
231
|
+
if (this.mTraining) {
|
|
232
|
+
if (vcHeight >= itemsHeight) {
|
|
233
|
+
ce = lc.previousElementSibling;
|
|
234
|
+
if (ce !== fc) {
|
|
235
|
+
const data = ce.atomControl.data;
|
|
236
|
+
while (ae.next()) {
|
|
237
|
+
if (ae.current === data) {
|
|
238
|
+
break;
|
|
248
239
|
}
|
|
249
|
-
|
|
250
|
-
let totalVisibleItems = 0;
|
|
251
|
-
ce = fc.nextElementSibling;
|
|
252
|
-
let allHeight = 0;
|
|
253
|
-
let allWidth = 0;
|
|
254
|
-
while (ce !== lc) {
|
|
255
|
-
totalVisibleItems++;
|
|
256
|
-
allHeight += AtomUI.outerHeight(ce);
|
|
257
|
-
allWidth += AtomUI.outerWidth(ce);
|
|
258
|
-
ce = ce.nextElementSibling;
|
|
259
|
-
}
|
|
260
|
-
avgHeight = allHeight / totalVisibleItems;
|
|
261
|
-
avgWidth = allWidth / totalVisibleItems;
|
|
262
|
-
totalVisibleItems--;
|
|
263
|
-
this.mAvgHeight = avgHeight;
|
|
264
|
-
this.mAvgWidth = avgWidth;
|
|
265
|
-
const columns = Math.floor(vcWidth / avgWidth);
|
|
266
|
-
const allRows = Math.ceil(items.length / columns);
|
|
267
|
-
const visibleRows = Math.ceil(totalVisibleItems / columns);
|
|
268
|
-
console.log({
|
|
269
|
-
avgWidth,
|
|
270
|
-
avgHeight,
|
|
271
|
-
totalVisibleItems,
|
|
272
|
-
allRows,
|
|
273
|
-
columns
|
|
274
|
-
});
|
|
275
|
-
this.mAllRows = allRows;
|
|
276
|
-
this.mColumns = columns;
|
|
277
|
-
this.mVisibleRows = visibleRows;
|
|
278
|
-
this.mVisibleHeight = visibleRows * avgHeight;
|
|
279
|
-
lc.style.height = ((allRows - visibleRows + 1) * avgHeight) + "px";
|
|
280
|
-
this.mTraining = false;
|
|
281
|
-
this.mReady = true;
|
|
282
|
-
this.postVirtualCollectionChanged();
|
|
283
|
-
}
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
const self = this;
|
|
287
|
-
this.lastScrollTop = vc.scrollTop;
|
|
288
|
-
if (this.mIsChanging) {
|
|
289
|
-
return;
|
|
240
|
+
}
|
|
290
241
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (itemIndex >= items.length) {
|
|
297
|
-
this.mIsChanging = false;
|
|
298
|
-
return;
|
|
242
|
+
if (ae.next()) {
|
|
243
|
+
const data = ae.current;
|
|
244
|
+
const elementChild = this.createChild(null, data);
|
|
245
|
+
ip.insertBefore(elementChild.element, lc);
|
|
246
|
+
this.postVirtualCollectionChanged();
|
|
299
247
|
}
|
|
300
|
-
|
|
301
|
-
|
|
248
|
+
} else {
|
|
249
|
+
let totalVisibleItems = 0;
|
|
302
250
|
ce = fc.nextElementSibling;
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if (firstItem !== lastItem) {
|
|
306
|
-
const firstVisibleIndex = items.indexOf(firstItem.atomControl.data);
|
|
307
|
-
const lastVisibleIndex = items.indexOf(lastItem.atomControl.data);
|
|
308
|
-
console.log({
|
|
309
|
-
firstVisibleIndex,
|
|
310
|
-
firstIndex,
|
|
311
|
-
lastVisibleIndex,
|
|
312
|
-
lastIndex
|
|
313
|
-
});
|
|
314
|
-
if (firstIndex >= firstVisibleIndex && lastIndex <= lastVisibleIndex) {
|
|
315
|
-
console.log("All items are visible...");
|
|
316
|
-
this.mIsChanging = false;
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
const remove = [];
|
|
321
|
-
const cache = {};
|
|
251
|
+
let allHeight = 0;
|
|
252
|
+
let allWidth = 0;
|
|
322
253
|
while (ce !== lc) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
const data = ae.current;
|
|
343
|
-
let elementChild = cache[index2];
|
|
344
|
-
if (elementChild && element.atomControl.data === data) {
|
|
345
|
-
cache[index2] = null;
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
elementChild = this.createChild(null, data).element;
|
|
349
|
-
}
|
|
350
|
-
elementChild.before = after;
|
|
351
|
-
add.push(elementChild);
|
|
352
|
-
after = elementChild;
|
|
353
|
-
last = index2;
|
|
354
|
-
}
|
|
355
|
-
const h = (this.mAllRows - block * 3) * avgHeight - index * this.mVisibleHeight;
|
|
356
|
-
console.log("last child height = " + h);
|
|
357
|
-
this.app.callLater(() => {
|
|
358
|
-
const oldHeight = AtomUI.outerHeight(fc);
|
|
359
|
-
const newHeight = index * this.mVisibleHeight;
|
|
360
|
-
const diff = newHeight - oldHeight;
|
|
361
|
-
const oldScrollTop = vc.scrollTop;
|
|
362
|
-
const a = new AtomEnumerator(add);
|
|
363
|
-
while (a.next()) {
|
|
364
|
-
const ec = a.current;
|
|
365
|
-
ip.insertBefore(ec, ec.before.nextElementSibling);
|
|
366
|
-
ec.before = null;
|
|
367
|
-
}
|
|
368
|
-
fc.style.height = newHeight + "px";
|
|
369
|
-
for (const iterator of remove) {
|
|
370
|
-
if (!iterator.before) {
|
|
371
|
-
iterator.atomControl.dispose();
|
|
372
|
-
}
|
|
373
|
-
iterator.remove();
|
|
374
|
-
}
|
|
375
|
-
lc.style.height = h + "px";
|
|
376
|
-
console.log(`Old: ${oldScrollTop} Diff: ${diff} Old Height: ${oldHeight} Height: ${newHeight}`);
|
|
377
|
-
this.mIsChanging = false;
|
|
254
|
+
totalVisibleItems++;
|
|
255
|
+
allHeight += AtomUI.outerHeight(ce);
|
|
256
|
+
allWidth += AtomUI.outerWidth(ce);
|
|
257
|
+
ce = ce.nextElementSibling;
|
|
258
|
+
}
|
|
259
|
+
avgHeight = allHeight / totalVisibleItems;
|
|
260
|
+
avgWidth = allWidth / totalVisibleItems;
|
|
261
|
+
totalVisibleItems--;
|
|
262
|
+
this.mAvgHeight = avgHeight;
|
|
263
|
+
this.mAvgWidth = avgWidth;
|
|
264
|
+
const columns = Math.floor(vcWidth / avgWidth);
|
|
265
|
+
const allRows = Math.ceil(items.length / columns);
|
|
266
|
+
const visibleRows = Math.ceil(totalVisibleItems / columns);
|
|
267
|
+
console.log({
|
|
268
|
+
avgWidth,
|
|
269
|
+
avgHeight,
|
|
270
|
+
totalVisibleItems,
|
|
271
|
+
allRows,
|
|
272
|
+
columns
|
|
378
273
|
});
|
|
379
|
-
this.
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
if (
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
this.labelPath = "label";
|
|
545
|
-
this.version = 1;
|
|
546
|
-
this.autoScrollToSelection = false;
|
|
547
|
-
this.sort = null;
|
|
548
|
-
this.valueSeparator = ", ";
|
|
549
|
-
this.uiVirtualize = false;
|
|
274
|
+
this.mAllRows = allRows;
|
|
275
|
+
this.mColumns = columns;
|
|
276
|
+
this.mVisibleRows = visibleRows;
|
|
277
|
+
this.mVisibleHeight = visibleRows * avgHeight;
|
|
278
|
+
lc.style.height = (allRows - visibleRows + 1) * avgHeight + "px";
|
|
279
|
+
this.mTraining = false;
|
|
280
|
+
this.mReady = true;
|
|
281
|
+
this.postVirtualCollectionChanged();
|
|
282
|
+
}
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const self = this;
|
|
286
|
+
this.lastScrollTop = vc.scrollTop;
|
|
287
|
+
if (this.mIsChanging) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
this.mIsChanging = true;
|
|
291
|
+
const block = Math.floor(this.mVisibleHeight / avgHeight);
|
|
292
|
+
const itemsInBlock = this.mVisibleRows * this.mColumns;
|
|
293
|
+
const index = Math.floor(vc.scrollTop / this.mVisibleHeight);
|
|
294
|
+
const itemIndex = index * itemsInBlock;
|
|
295
|
+
if (itemIndex >= items.length) {
|
|
296
|
+
this.mIsChanging = false;
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const lastIndex = Math.min((Math.max(index, 0) + 3) * itemsInBlock - 1, items.length - 1);
|
|
300
|
+
const firstIndex = Math.max(0, index * itemsInBlock);
|
|
301
|
+
ce = fc.nextElementSibling;
|
|
302
|
+
const firstItem = fc.nextElementSibling;
|
|
303
|
+
const lastItem = lc.previousElementSibling;
|
|
304
|
+
if (firstItem !== lastItem) {
|
|
305
|
+
const firstVisibleIndex = items.indexOf(firstItem.atomControl.data);
|
|
306
|
+
const lastVisibleIndex = items.indexOf(lastItem.atomControl.data);
|
|
307
|
+
console.log({
|
|
308
|
+
firstVisibleIndex,
|
|
309
|
+
firstIndex,
|
|
310
|
+
lastVisibleIndex,
|
|
311
|
+
lastIndex
|
|
312
|
+
});
|
|
313
|
+
if (firstIndex >= firstVisibleIndex && lastIndex <= lastVisibleIndex) {
|
|
314
|
+
console.log("All items are visible...");
|
|
315
|
+
this.mIsChanging = false;
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const remove = [];
|
|
320
|
+
const cache = {};
|
|
321
|
+
while (ce !== lc) {
|
|
322
|
+
const c = ce;
|
|
323
|
+
ce = ce.nextElementSibling;
|
|
324
|
+
const s = items.indexOf(c.atomControl.data);
|
|
325
|
+
cache[s] = c;
|
|
326
|
+
remove.push(c);
|
|
327
|
+
}
|
|
328
|
+
this.app.dispatcher.pause();
|
|
329
|
+
ae = new AtomEnumerator(items);
|
|
330
|
+
for (let i = 0; i < firstIndex; i++) {
|
|
331
|
+
ae.next();
|
|
332
|
+
}
|
|
333
|
+
let after = fc;
|
|
334
|
+
let last = null;
|
|
335
|
+
const add = [];
|
|
336
|
+
for (let i = firstIndex; i <= lastIndex; i++) {
|
|
337
|
+
if (!ae.next()) {
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
const index2 = ae.currentIndex;
|
|
341
|
+
const data = ae.current;
|
|
342
|
+
let elementChild = cache[index2];
|
|
343
|
+
if (elementChild && element.atomControl.data === data) {
|
|
344
|
+
cache[index2] = null;
|
|
345
|
+
} else {
|
|
346
|
+
elementChild = this.createChild(null, data).element;
|
|
347
|
+
}
|
|
348
|
+
elementChild.before = after;
|
|
349
|
+
add.push(elementChild);
|
|
350
|
+
after = elementChild;
|
|
351
|
+
last = index2;
|
|
352
|
+
}
|
|
353
|
+
const h = (this.mAllRows - block * 3) * avgHeight - index * this.mVisibleHeight;
|
|
354
|
+
console.log("last child height = " + h);
|
|
355
|
+
this.app.callLater(() => {
|
|
356
|
+
const oldHeight = AtomUI.outerHeight(fc);
|
|
357
|
+
const newHeight = index * this.mVisibleHeight;
|
|
358
|
+
const diff = newHeight - oldHeight;
|
|
359
|
+
const oldScrollTop = vc.scrollTop;
|
|
360
|
+
const a = new AtomEnumerator(add);
|
|
361
|
+
while (a.next()) {
|
|
362
|
+
const ec = a.current;
|
|
363
|
+
ip.insertBefore(ec, ec.before.nextElementSibling);
|
|
364
|
+
ec.before = null;
|
|
365
|
+
}
|
|
366
|
+
fc.style.height = newHeight + "px";
|
|
367
|
+
for (const iterator of remove) {
|
|
368
|
+
if (!iterator.before) {
|
|
369
|
+
iterator.atomControl.dispose();
|
|
370
|
+
}
|
|
371
|
+
iterator.remove();
|
|
372
|
+
}
|
|
373
|
+
lc.style.height = h + "px";
|
|
374
|
+
console.log(`Old: ${oldScrollTop} Diff: ${diff} Old Height: ${oldHeight} Height: ${newHeight}`);
|
|
375
|
+
this.mIsChanging = false;
|
|
376
|
+
});
|
|
377
|
+
this.app.dispatcher.start();
|
|
378
|
+
AtomBinder.refreshValue(this, "childAtomControls");
|
|
379
|
+
}
|
|
380
|
+
isSelected(item) {
|
|
381
|
+
let selectedItem = null;
|
|
382
|
+
for (const iterator of this.mSelectedItems) {
|
|
383
|
+
selectedItem = iterator;
|
|
384
|
+
if (selectedItem === item) {
|
|
385
|
+
return true;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
bringIntoView(data) {
|
|
391
|
+
this.app.callLater(() => {
|
|
392
|
+
for (let item of ChildEnumerator.enumerate(this.itemsPresenter || this.element)) {
|
|
393
|
+
const dataItem = item.atomControl ? item.atomControl.data : item;
|
|
394
|
+
if (dataItem === data) {
|
|
395
|
+
item.scrollIntoView();
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
bringSelectionIntoView() {
|
|
402
|
+
if (this.uiVirtualize) {
|
|
403
|
+
const index = this.selectedIndex;
|
|
404
|
+
if (!this.mReady) {
|
|
405
|
+
setTimeout(() => {
|
|
406
|
+
this.bringSelectionIntoView();
|
|
407
|
+
}, 1000);
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
const avgHeight = this.mAvgHeight;
|
|
411
|
+
const vcHeight = AtomUI.innerHeight(this.mVirtualContainer);
|
|
412
|
+
const block = Math.ceil(vcHeight / avgHeight);
|
|
413
|
+
const itemsInBlock = block * this.mColumns;
|
|
414
|
+
const scrollTop = Math.floor(index / itemsInBlock);
|
|
415
|
+
AtomUI.scrollTop(this.mVirtualContainer, scrollTop * vcHeight);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
for (let item of ChildEnumerator.enumerate(this.itemsPresenter || this.element)) {
|
|
419
|
+
const dataItem = item.atomControl ? item.atomControl.data : item;
|
|
420
|
+
if (this.isSelected(dataItem)) {
|
|
421
|
+
setTimeout(() => {
|
|
422
|
+
item.scrollIntoView();
|
|
423
|
+
}, 1000);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
updateSelectionBindings() {
|
|
429
|
+
this.version = this.version + 1;
|
|
430
|
+
if (this.mSelectedItems && this.mSelectedItems.length) {
|
|
431
|
+
this.mValue = undefined;
|
|
432
|
+
}
|
|
433
|
+
AtomBinder.refreshValue(this, "value");
|
|
434
|
+
AtomBinder.refreshValue(this, "selectedItem");
|
|
435
|
+
AtomBinder.refreshValue(this, "selectedItems");
|
|
436
|
+
AtomBinder.refreshValue(this, "selectedIndex");
|
|
437
|
+
if (!this.mSelectedItems.length) {
|
|
438
|
+
if (this.mSelectAll === true) {
|
|
550
439
|
this.mSelectAll = false;
|
|
551
|
-
this
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
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
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
440
|
+
AtomBinder.refreshValue(this, "selectAll");
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
onSelectedItemsChanged(type, index, item) {
|
|
445
|
+
if (!this.mOnUIChanged) {
|
|
446
|
+
if (this.autoScrollToSelection) {
|
|
447
|
+
this.bringSelectionIntoView();
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
this.updateSelectionBindings();
|
|
451
|
+
}
|
|
452
|
+
hasItems() {
|
|
453
|
+
return this.mItems !== undefined && this.mItems !== null;
|
|
454
|
+
}
|
|
455
|
+
invalidateItems() {
|
|
456
|
+
if (this.pendingInits || this.isUpdating) {
|
|
457
|
+
setTimeout(() => {
|
|
458
|
+
this.invalidateItems();
|
|
459
|
+
}, 5);
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
if (this.itemsInvalidated) {
|
|
463
|
+
clearTimeout(this.itemsInvalidated);
|
|
464
|
+
this.itemsInvalidated = 0;
|
|
465
|
+
}
|
|
466
|
+
this.itemsInvalidated = setTimeout(() => {
|
|
467
|
+
this.itemsInvalidated = 0;
|
|
468
|
+
this.onCollectionChangedInternal("refresh", -1, null);
|
|
469
|
+
}, 5);
|
|
470
|
+
}
|
|
471
|
+
onCollectionChanged(key, index, item) {
|
|
472
|
+
if (!this.mItems) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
if (!this.itemTemplate) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
if (!this.itemsPresenter) {
|
|
479
|
+
this.itemsPresenter = this.element;
|
|
480
|
+
}
|
|
481
|
+
this.version = this.version + 1;
|
|
482
|
+
if (/reset|refresh/i.test(key)) {
|
|
483
|
+
this.resetVirtualContainer();
|
|
484
|
+
}
|
|
485
|
+
if (/remove/gi.test(key)) {
|
|
486
|
+
const ip = this.itemsPresenter || this.element;
|
|
487
|
+
for (let ce of ChildEnumerator.enumerate(ip)) {
|
|
488
|
+
const c = ce;
|
|
489
|
+
if (c.atomControl && c.atomControl.data === item) {
|
|
490
|
+
c.atomControl.dispose();
|
|
491
|
+
ce.remove();
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
if (this.uiVirtualize) {
|
|
498
|
+
this.onVirtualCollectionChanged();
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
const parentScope = undefined;
|
|
502
|
+
let items = this.mFilter ? this.mItems.filter(this.mFilter) : this.mItems;
|
|
503
|
+
let s = this.sort;
|
|
504
|
+
if (s) {
|
|
505
|
+
if (typeof s === "string") {
|
|
506
|
+
const sp = s;
|
|
507
|
+
s = (l, r) => {
|
|
508
|
+
const lv = (l[sp] || "").toString();
|
|
509
|
+
const rv = (r[sp] || "").toString();
|
|
510
|
+
return lv.toLowerCase().localeCompare(rv.toLowerCase());
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
items = items.sort(s);
|
|
514
|
+
}
|
|
515
|
+
if (/add/gi.test(key)) {
|
|
516
|
+
const lastItem = items[index];
|
|
517
|
+
let last = this.itemsPresenter.children.item(index);
|
|
518
|
+
const df2 = document.createDocumentFragment();
|
|
519
|
+
this.createChild(df2, lastItem);
|
|
520
|
+
if (last) {
|
|
521
|
+
this.itemsPresenter.insertBefore(df2, last);
|
|
522
|
+
} else {
|
|
523
|
+
this.itemsPresenter.appendChild(df2);
|
|
524
|
+
}
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const element = this.itemsPresenter;
|
|
528
|
+
this.disposeChildren(this.itemsPresenter);
|
|
529
|
+
const added = [];
|
|
530
|
+
const ip = this.itemsPresenter || this.element;
|
|
531
|
+
for (const mItem of items) {
|
|
532
|
+
const data = mItem;
|
|
533
|
+
const ac = this.createChild(null, data);
|
|
534
|
+
ip.appendChild(ac.element);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
preCreate() {
|
|
538
|
+
this.mAllowSelectFirst = false;
|
|
539
|
+
this.allowMultipleSelection = false;
|
|
540
|
+
this.valuePath = "value";
|
|
541
|
+
this.labelPath = "label";
|
|
542
|
+
this.version = 1;
|
|
543
|
+
this.autoScrollToSelection = false;
|
|
544
|
+
this.sort = null;
|
|
545
|
+
this.valueSeparator = ", ";
|
|
546
|
+
this.uiVirtualize = false;
|
|
547
|
+
this.mSelectAll = false;
|
|
548
|
+
this.mItems = null;
|
|
549
|
+
this.selectedItems = [];
|
|
550
|
+
this.itemTemplate = AtomItemsControlItemTemplate;
|
|
551
|
+
super.preCreate();
|
|
552
|
+
}
|
|
553
|
+
onCollectionChangedInternal(key, index, item) {
|
|
554
|
+
const value = this.value;
|
|
555
|
+
try {
|
|
556
|
+
this.isUpdating = true;
|
|
557
|
+
this.onCollectionChanged(key, index, item);
|
|
558
|
+
if (value) {
|
|
559
|
+
if (!(value || this.mAllowSelectFirst)) {
|
|
560
|
+
AtomBinder.clear(this.mSelectedItems);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (value != null) {
|
|
564
|
+
this.value = value;
|
|
565
|
+
if (this.selectedIndex !== -1) {
|
|
566
|
+
return;
|
|
567
|
+
} else {
|
|
568
|
+
this.mValue = undefined;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
} finally {
|
|
572
|
+
this.app.callLater(() => {
|
|
573
|
+
this.isUpdating = false;
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
set allowSelectFirst(b) {
|
|
578
|
+
b = b ? b !== "false" : b;
|
|
579
|
+
this.mAllowSelectFirst = b;
|
|
580
|
+
}
|
|
581
|
+
set filter(f) {
|
|
582
|
+
if (f === this.mFilter) {
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
this.mFilter = f;
|
|
586
|
+
AtomBinder.refreshValue(this, "filter");
|
|
587
|
+
}
|
|
588
|
+
onScroll() {
|
|
589
|
+
if (this.scrollTimeout) {
|
|
590
|
+
clearTimeout(this.scrollTimeout);
|
|
591
|
+
}
|
|
592
|
+
this.scrollTimeout = setTimeout(() => {
|
|
593
|
+
this.scrollTimeout = 0;
|
|
594
|
+
this.onVirtualCollectionChanged();
|
|
595
|
+
}, 10);
|
|
596
|
+
}
|
|
597
|
+
toggleSelection(data) {
|
|
598
|
+
this.mOnUIChanged = true;
|
|
599
|
+
this.mValue = undefined;
|
|
600
|
+
if (this.allowMultipleSelection) {
|
|
601
|
+
if (this.mSelectedItems.indexOf(data) !== -1) {
|
|
602
|
+
AtomBinder.removeItem(this.mSelectedItems, data);
|
|
603
|
+
} else {
|
|
604
|
+
AtomBinder.addItem(this.mSelectedItems, data);
|
|
605
|
+
}
|
|
606
|
+
} else {
|
|
607
|
+
this.mSelectedItems.length = 1;
|
|
608
|
+
this.mSelectedItems[0] = data;
|
|
609
|
+
AtomBinder.refreshItems(this.mSelectedItems);
|
|
610
|
+
}
|
|
611
|
+
this.mOnUIChanged = false;
|
|
612
|
+
}
|
|
613
|
+
validateScroller() {
|
|
614
|
+
if (this.mScrollerSetup) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
const ip = this.itemsPresenter;
|
|
618
|
+
const e = this.element;
|
|
619
|
+
let vc = this.mVirtualContainer;
|
|
620
|
+
if (!vc) {
|
|
621
|
+
if (ip === e && !/table/i.test(e.nodeName)) {
|
|
622
|
+
throw new Error("virtualContainer presenter not found," + "you must put itemsPresenter inside a virtualContainer in order for Virtualization to work");
|
|
623
|
+
} else {
|
|
624
|
+
vc = this.mVirtualContainer = this.element;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
vc.style.overflow = "auto";
|
|
628
|
+
this.bindEvent(vc, "scroll", () => {
|
|
629
|
+
this.onScroll();
|
|
630
|
+
});
|
|
631
|
+
ip.style.overflow = "hidden";
|
|
632
|
+
const isTable = /tbody/i.test(ip.nodeName);
|
|
633
|
+
let fc;
|
|
634
|
+
let lc;
|
|
635
|
+
if (isTable) {
|
|
636
|
+
fc = document.createElement("TR");
|
|
637
|
+
lc = document.createElement("TR");
|
|
638
|
+
} else {
|
|
639
|
+
fc = document.createElement("DIV");
|
|
640
|
+
lc = document.createElement("DIV");
|
|
641
|
+
}
|
|
642
|
+
fc.classList.add("sticky");
|
|
643
|
+
fc.classList.add("first-child");
|
|
644
|
+
lc.classList.add("sticky");
|
|
645
|
+
lc.classList.add("last-child");
|
|
646
|
+
fc.style.position = "relative";
|
|
647
|
+
fc.style.height = "0";
|
|
648
|
+
fc.style.width = "100%";
|
|
649
|
+
fc.style.clear = "both";
|
|
650
|
+
lc.style.position = "relative";
|
|
651
|
+
lc.style.height = "0";
|
|
652
|
+
lc.style.width = "100%";
|
|
653
|
+
lc.style.clear = "both";
|
|
654
|
+
this.mFirstChild = fc;
|
|
655
|
+
this.mLastChild = lc;
|
|
656
|
+
ip.appendChild(fc);
|
|
657
|
+
ip.appendChild(lc);
|
|
658
|
+
this.mTraining = true;
|
|
659
|
+
this.mScrollerSetup = true;
|
|
660
|
+
}
|
|
661
|
+
createChild(df, data) {
|
|
662
|
+
const t = this.itemTemplate;
|
|
663
|
+
const ac = this.app.resolve(t, true);
|
|
664
|
+
const e = ac.element;
|
|
665
|
+
e._logicalParent = this.element;
|
|
666
|
+
e._templateParent = this;
|
|
667
|
+
if (df) {
|
|
668
|
+
df.appendChild(ac.element);
|
|
669
|
+
}
|
|
670
|
+
ac.data = data;
|
|
671
|
+
this.element.dispatchEvent(new CustomEvent("item-created", {
|
|
672
|
+
bubbles: false,
|
|
673
|
+
cancelable: false,
|
|
674
|
+
detail: data
|
|
675
|
+
}));
|
|
676
|
+
return ac;
|
|
677
|
+
}
|
|
678
|
+
disposeChildren(e) {
|
|
679
|
+
for (let iterator of ChildEnumerator.enumerate(e)) {
|
|
680
|
+
const ac = iterator.atomControl;
|
|
681
|
+
if (ac) {
|
|
682
|
+
ac.dispose();
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
e.innerHTML = "";
|
|
686
|
+
}
|
|
697
687
|
}
|
|
698
688
|
class AtomItemsControlItemTemplate extends AtomControl {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
}
|
|
706
|
-
//# sourceMappingURL=AtomItemsControl.js.map
|
|
689
|
+
create() {
|
|
690
|
+
this.runAfterInit(() => {
|
|
691
|
+
const tp = this.element._templateParent;
|
|
692
|
+
this.element.textContent = this.data[tp.valuePath];
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
}
|