@vaadin/component-base 24.4.0-dev.4b20a0c55.3 → 24.4.0-rc1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/component-base",
|
|
3
|
-
"version": "24.4.0-
|
|
3
|
+
"version": "24.4.0-rc1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@vaadin/testing-helpers": "^0.6.0",
|
|
43
43
|
"sinon": "^13.0.2"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "a81e3b927d44c56613fa4e1307494a2acc81005f"
|
|
46
46
|
}
|
|
@@ -16,6 +16,13 @@ export class Cache {
|
|
|
16
16
|
*/
|
|
17
17
|
context;
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* The number of items.
|
|
21
|
+
*
|
|
22
|
+
* @type {number}
|
|
23
|
+
*/
|
|
24
|
+
size = 0;
|
|
25
|
+
|
|
19
26
|
/**
|
|
20
27
|
* The number of items to display per page.
|
|
21
28
|
*
|
|
@@ -51,14 +58,6 @@ export class Cache {
|
|
|
51
58
|
*/
|
|
52
59
|
__subCacheByIndex = {};
|
|
53
60
|
|
|
54
|
-
/**
|
|
55
|
-
* The number of items.
|
|
56
|
-
*
|
|
57
|
-
* @type {number}
|
|
58
|
-
* @private
|
|
59
|
-
*/
|
|
60
|
-
__size = 0;
|
|
61
|
-
|
|
62
61
|
/**
|
|
63
62
|
* The total number of items, including items from expanded sub-caches.
|
|
64
63
|
*
|
|
@@ -137,44 +136,6 @@ export class Cache {
|
|
|
137
136
|
return this.flatSize;
|
|
138
137
|
}
|
|
139
138
|
|
|
140
|
-
/**
|
|
141
|
-
* The number of items.
|
|
142
|
-
*
|
|
143
|
-
* @return {number}
|
|
144
|
-
*/
|
|
145
|
-
get size() {
|
|
146
|
-
return this.__size;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Sets the number of items.
|
|
151
|
-
*
|
|
152
|
-
* @param {number} size
|
|
153
|
-
*/
|
|
154
|
-
set size(size) {
|
|
155
|
-
const oldSize = this.__size;
|
|
156
|
-
if (oldSize === size) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
this.__size = size;
|
|
161
|
-
|
|
162
|
-
if (this.context.placeholder !== undefined) {
|
|
163
|
-
this.items.length = size;
|
|
164
|
-
for (let i = 0; i < size; i++) {
|
|
165
|
-
// eslint-disable-next-line logical-assignment-operators
|
|
166
|
-
this.items[i] = this.items[i] || this.context.placeholder;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
Object.keys(this.pendingRequests).forEach((page) => {
|
|
171
|
-
const startIndex = parseInt(page) * this.pageSize;
|
|
172
|
-
if (startIndex >= this.size) {
|
|
173
|
-
delete this.pendingRequests[page];
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
139
|
/**
|
|
179
140
|
* Recalculates the flattened size for the cache and its descendant caches recursively.
|
|
180
141
|
*/
|
|
@@ -65,20 +65,12 @@ export class DataProviderController extends EventTarget {
|
|
|
65
65
|
*/
|
|
66
66
|
rootCache;
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
* A placeholder item that is used to indicate that the item is not loaded yet.
|
|
70
|
-
*
|
|
71
|
-
* @type {undefined | object}
|
|
72
|
-
*/
|
|
73
|
-
placeholder;
|
|
74
|
-
|
|
75
|
-
constructor(host, { size, pageSize, isExpanded, getItemId, placeholder, dataProvider, dataProviderParams }) {
|
|
68
|
+
constructor(host, { size, pageSize, isExpanded, getItemId, dataProvider, dataProviderParams }) {
|
|
76
69
|
super();
|
|
77
70
|
this.host = host;
|
|
78
71
|
this.pageSize = pageSize;
|
|
79
72
|
this.getItemId = getItemId;
|
|
80
73
|
this.isExpanded = isExpanded;
|
|
81
|
-
this.placeholder = placeholder;
|
|
82
74
|
this.dataProvider = dataProvider;
|
|
83
75
|
this.dataProviderParams = dataProviderParams;
|
|
84
76
|
this.rootCache = this.__createRootCache(size);
|
|
@@ -95,7 +87,6 @@ export class DataProviderController extends EventTarget {
|
|
|
95
87
|
get __cacheContext() {
|
|
96
88
|
return {
|
|
97
89
|
isExpanded: this.isExpanded,
|
|
98
|
-
placeholder: this.placeholder,
|
|
99
90
|
// The controller instance is needed to ensure deprecated cache methods work.
|
|
100
91
|
__controller: this,
|
|
101
92
|
};
|
|
@@ -196,7 +187,7 @@ export class DataProviderController extends EventTarget {
|
|
|
196
187
|
ensureFlatIndexLoaded(flatIndex) {
|
|
197
188
|
const { cache, page, item } = this.getFlatIndexContext(flatIndex);
|
|
198
189
|
|
|
199
|
-
if (
|
|
190
|
+
if (!item) {
|
|
200
191
|
this.__loadCachePage(cache, page);
|
|
201
192
|
}
|
|
202
193
|
}
|
|
@@ -211,7 +202,7 @@ export class DataProviderController extends EventTarget {
|
|
|
211
202
|
ensureFlatIndexHierarchy(flatIndex) {
|
|
212
203
|
const { cache, item, index } = this.getFlatIndexContext(flatIndex);
|
|
213
204
|
|
|
214
|
-
if (
|
|
205
|
+
if (item && this.isExpanded(item) && !cache.getSubCache(index)) {
|
|
215
206
|
const subCache = cache.createSubCache(index);
|
|
216
207
|
this.__loadCachePage(subCache, 0);
|
|
217
208
|
}
|
|
@@ -250,14 +241,14 @@ export class DataProviderController extends EventTarget {
|
|
|
250
241
|
return;
|
|
251
242
|
}
|
|
252
243
|
|
|
253
|
-
cache.setPage(page, items);
|
|
254
|
-
|
|
255
244
|
if (size !== undefined) {
|
|
256
245
|
cache.size = size;
|
|
257
246
|
} else if (params.parentItem) {
|
|
258
247
|
cache.size = items.length;
|
|
259
248
|
}
|
|
260
249
|
|
|
250
|
+
cache.setPage(page, items);
|
|
251
|
+
|
|
261
252
|
this.recalculateFlatSize();
|
|
262
253
|
|
|
263
254
|
this.dispatchEvent(new CustomEvent('page-received'));
|
|
@@ -273,9 +264,4 @@ export class DataProviderController extends EventTarget {
|
|
|
273
264
|
|
|
274
265
|
this.dataProvider(params, callback);
|
|
275
266
|
}
|
|
276
|
-
|
|
277
|
-
/** @private */
|
|
278
|
-
__isPlaceholder(item) {
|
|
279
|
-
return this.placeholder ? item === this.placeholder : !item;
|
|
280
|
-
}
|
|
281
267
|
}
|
package/src/define.js
CHANGED
|
@@ -69,7 +69,7 @@ export const OverlayClassMixin = (superclass) =>
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// Add new classes based on the overlayClass
|
|
72
|
-
const classesToAdd = typeof overlayClass === 'string' ? overlayClass.split(' ') : [];
|
|
72
|
+
const classesToAdd = typeof overlayClass === 'string' ? overlayClass.split(' ').filter(Boolean) : [];
|
|
73
73
|
if (classesToAdd.length > 0) {
|
|
74
74
|
classList.add(...classesToAdd);
|
|
75
75
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/* eslint-disable @typescript-eslint/member-ordering */
|
|
7
7
|
// https://github.com/vaadin/eslint-config-vaadin/issues/33
|
|
8
|
-
import { animationFrame, timeOut } from './async.js';
|
|
8
|
+
import { animationFrame, microTask, timeOut } from './async.js';
|
|
9
9
|
import { isSafari } from './browser-utils.js';
|
|
10
10
|
import { Debouncer, flush } from './debounce.js';
|
|
11
11
|
import { ironList } from './iron-list-core.js';
|
|
@@ -353,6 +353,9 @@ export class IronListAdapter {
|
|
|
353
353
|
// Schedule and flush a resize handler
|
|
354
354
|
this._resizeHandler();
|
|
355
355
|
flush();
|
|
356
|
+
// Schedule an update to ensure item positions are correct after subsequent size changes
|
|
357
|
+
// Fix for https://github.com/vaadin/flow-components/issues/6269
|
|
358
|
+
this._debounce('_update', this._update, microTask);
|
|
356
359
|
}
|
|
357
360
|
|
|
358
361
|
/** @private */
|
|
@@ -797,7 +800,7 @@ export class IronListAdapter {
|
|
|
797
800
|
this.__skipNextVirtualIndexAdjust = false;
|
|
798
801
|
} else if (Math.abs(delta) > 10000) {
|
|
799
802
|
// Process a large scroll position change
|
|
800
|
-
const scale = this._scrollTop / (this.scrollTarget.scrollHeight - this.scrollTarget.
|
|
803
|
+
const scale = this._scrollTop / (this.scrollTarget.scrollHeight - this.scrollTarget.clientHeight);
|
|
801
804
|
this._vidxOffset = Math.round(scale * maxOffset);
|
|
802
805
|
} else {
|
|
803
806
|
// Make sure user can always swipe/wheel scroll to the start and end
|