@vaadin/component-base 24.4.0-dev.223e39f050 → 24.4.0-dev.4b20a0c55.3

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.
Files changed (50) hide show
  1. package/package.json +2 -2
  2. package/src/browser-utils.js +1 -1
  3. package/src/controller-mixin.d.ts +1 -1
  4. package/src/controller-mixin.js +1 -1
  5. package/src/data-provider-controller/cache.d.ts +1 -1
  6. package/src/data-provider-controller/cache.js +3 -5
  7. package/src/data-provider-controller/data-provider-controller.d.ts +1 -1
  8. package/src/data-provider-controller/data-provider-controller.js +1 -11
  9. package/src/data-provider-controller/helpers.d.ts +1 -1
  10. package/src/data-provider-controller/helpers.js +1 -1
  11. package/src/define.d.ts +1 -1
  12. package/src/define.js +2 -2
  13. package/src/delegate-state-mixin.d.ts +1 -1
  14. package/src/delegate-state-mixin.js +1 -1
  15. package/src/dir-mixin.d.ts +1 -1
  16. package/src/dir-mixin.js +1 -1
  17. package/src/dir-utils.d.ts +1 -1
  18. package/src/dir-utils.js +1 -1
  19. package/src/dom-utils.d.ts +1 -1
  20. package/src/dom-utils.js +1 -1
  21. package/src/element-mixin.d.ts +1 -1
  22. package/src/element-mixin.js +1 -1
  23. package/src/media-query-controller.d.ts +1 -1
  24. package/src/media-query-controller.js +1 -1
  25. package/src/overflow-controller.d.ts +1 -1
  26. package/src/overflow-controller.js +1 -1
  27. package/src/overlay-class-mixin.d.ts +1 -1
  28. package/src/overlay-class-mixin.js +1 -1
  29. package/src/path-utils.d.ts +1 -1
  30. package/src/path-utils.js +1 -1
  31. package/src/polylit-mixin.d.ts +1 -1
  32. package/src/polylit-mixin.js +24 -1
  33. package/src/resize-mixin.d.ts +1 -1
  34. package/src/resize-mixin.js +1 -1
  35. package/src/slot-child-observe-controller.d.ts +1 -1
  36. package/src/slot-child-observe-controller.js +1 -1
  37. package/src/slot-controller.d.ts +1 -1
  38. package/src/slot-controller.js +1 -1
  39. package/src/slot-observer.d.ts +1 -1
  40. package/src/slot-observer.js +1 -1
  41. package/src/slot-styles-mixin.d.ts +1 -1
  42. package/src/slot-styles-mixin.js +1 -1
  43. package/src/templates.js +1 -1
  44. package/src/tooltip-controller.d.ts +1 -1
  45. package/src/tooltip-controller.js +1 -1
  46. package/src/unique-id-utils.d.ts +1 -1
  47. package/src/unique-id-utils.js +1 -1
  48. package/src/url-utils.d.ts +8 -4
  49. package/src/url-utils.js +31 -9
  50. package/src/virtualizer-iron-list-adapter.js +119 -33
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/component-base",
3
- "version": "24.4.0-dev.223e39f050",
3
+ "version": "24.4.0-dev.4b20a0c55.3",
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": "5e2e3bfc811c95aed9354235fab93fdbf43eb354"
45
+ "gitHead": "41cf17453d7506fb635c088a0425e20b6e82b89b"
46
46
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { DataProviderCallback } from './data-provider-controller.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { getFlatIndexContext } from './helpers.js';
@@ -140,8 +140,7 @@ export class Cache {
140
140
  /**
141
141
  * The number of items.
142
142
  *
143
- * @type {number}
144
- * @private
143
+ * @return {number}
145
144
  */
146
145
  get size() {
147
146
  return this.__size;
@@ -150,8 +149,7 @@ export class Cache {
150
149
  /**
151
150
  * Sets the number of items.
152
151
  *
153
- * @type {number}
154
- * @private
152
+ * @param {number} size
155
153
  */
156
154
  set size(size) {
157
155
  const oldSize = this.__size;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { ReactiveController } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { Cache } from './cache.js';
@@ -65,13 +65,6 @@ export class DataProviderController extends EventTarget {
65
65
  */
66
66
  rootCache;
67
67
 
68
- /**
69
- * Indicates whether any data has been loaded since the last cache clear.
70
- *
71
- * @type {boolean}
72
- */
73
- hasData = false;
74
-
75
68
  /**
76
69
  * A placeholder item that is used to indicate that the item is not loaded yet.
77
70
  *
@@ -149,7 +142,6 @@ export class DataProviderController extends EventTarget {
149
142
  */
150
143
  clearCache() {
151
144
  this.rootCache = this.__createRootCache(this.rootCache.size);
152
- this.hasData = false;
153
145
  }
154
146
 
155
147
  /**
@@ -268,8 +260,6 @@ export class DataProviderController extends EventTarget {
268
260
 
269
261
  this.recalculateFlatSize();
270
262
 
271
- this.hasData = true;
272
-
273
263
  this.dispatchEvent(new CustomEvent('page-received'));
274
264
 
275
265
  delete cache.pendingRequests[page];
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Cache } from './cache.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
package/src/define.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  export interface CustomElementType extends CustomElementConstructor {
package/src/define.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -9,7 +9,7 @@ export function defineCustomElement(CustomElement) {
9
9
  if (!defined) {
10
10
  Object.defineProperty(CustomElement, 'version', {
11
11
  get() {
12
- return '24.4.0-alpha1';
12
+ return '24.4.0-dev.4b20a0c55.3';
13
13
  },
14
14
  });
15
15
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
package/src/dir-mixin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
package/src/dir-utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
package/src/dom-utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import '../custom_typings/vaadin-usage-statistics.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { setCancelSyntheticClickEvents } from '@polymer/polymer/lib/utils/settings.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { ReactiveController } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { ReactiveController } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { animationFrame } from './async.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2023 Vaadin Ltd.
3
+ * Copyright (c) 2023 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2023 Vaadin Ltd.
3
+ * Copyright (c) 2023 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2023 Vaadin Ltd.
3
+ * Copyright (c) 2023 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
package/src/path-utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2023 Vaadin Ltd.
3
+ * Copyright (c) 2023 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { dedupeMixin } from '@open-wc/dedupe-mixin';
@@ -93,6 +93,9 @@ const PolylitMixinImplementation = (superclass) => {
93
93
 
94
94
  let result = defaultDescriptor;
95
95
 
96
+ // Set the key for this property
97
+ this.getOrCreateMap('__propKeys').set(name, key);
98
+
96
99
  if (options.sync) {
97
100
  result = {
98
101
  get: defaultDescriptor.get,
@@ -232,6 +235,26 @@ const PolylitMixinImplementation = (superclass) => {
232
235
  }
233
236
  }
234
237
 
238
+ /**
239
+ * Set several properties at once and perform synchronous update.
240
+ * @protected
241
+ */
242
+ setProperties(props) {
243
+ Object.entries(props).forEach(([name, value]) => {
244
+ // Use private key and not setter to not trigger
245
+ // update for properties marked as `sync: true`.
246
+ const key = this.constructor.__propKeys.get(name);
247
+ const oldValue = this[key];
248
+ this[key] = value;
249
+ this.requestUpdate(name, oldValue);
250
+ });
251
+
252
+ // Perform sync update
253
+ if (this.hasUpdated) {
254
+ this.performUpdate();
255
+ }
256
+ }
257
+
235
258
  /** @protected */
236
259
  _createMethodObserver(observer) {
237
260
  const dynamicObservers = getOrCreateMap(this, '__dynamicObservers');
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { SlotController } from './slot-controller.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { SlotController } from './slot-controller.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { ReactiveController } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { isEmptyTextNode } from './dom-utils.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2023 Vaadin Ltd.
3
+ * Copyright (c) 2023 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2023 Vaadin Ltd.
3
+ * Copyright (c) 2023 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
package/src/templates.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { SlotController } from './slot-controller.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { SlotController } from './slot-controller.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,11 +1,15 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2023 Vaadin Ltd.
3
+ * Copyright (c) 2023 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
7
7
  /**
8
- * Check if two paths can be resolved as URLs
9
- * with the same origin and pathname.
8
+ * Checks if two paths match based on their origin, pathname, and query parameters.
9
+ *
10
+ * The function matches an actual URL against an expected URL to see if they share
11
+ * the same base origin (like https://example.com), the same path (like /path/to/page),
12
+ * and if the actual URL contains at least all the query parameters with the same values
13
+ * from the expected URL.
10
14
  */
11
- export declare function matchPaths(path1: string, path2: string): boolean;
15
+ export declare function matchPaths(actual: string, expected: string): boolean;
package/src/url-utils.js CHANGED
@@ -1,19 +1,41 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2023 Vaadin Ltd.
3
+ * Copyright (c) 2023 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
7
7
  /**
8
- * Check if two paths can be resolved as URLs
9
- * with the same origin and pathname.
8
+ * Checks if one set of URL parameters contains all the parameters
9
+ * with the same values from another set.
10
10
  *
11
- * @param {string} path1
12
- * @param {string} path2
11
+ * @param {URLSearchParams} actual
12
+ * @param {URLSearchParams} expected
13
13
  */
14
- export function matchPaths(path1, path2) {
14
+ function containsQueryParams(actual, expected) {
15
+ return [...expected.entries()].every(([key, value]) => {
16
+ return actual.getAll(key).includes(value);
17
+ });
18
+ }
19
+
20
+ /**
21
+ * Checks if two paths match based on their origin, pathname, and query parameters.
22
+ *
23
+ * The function matches an actual URL against an expected URL to see if they share
24
+ * the same base origin (like https://example.com), the same path (like /path/to/page),
25
+ * and if the actual URL contains at least all the query parameters with the same values
26
+ * from the expected URL.
27
+ *
28
+ * @param {string} actual The actual URL to match.
29
+ * @param {string} expected The expected URL to match.
30
+ */
31
+ export function matchPaths(actual, expected) {
15
32
  const base = document.baseURI;
16
- const url1 = new URL(path1, base);
17
- const url2 = new URL(path2, base);
18
- return url1.origin === url2.origin && url1.pathname === url2.pathname;
33
+ const actualUrl = new URL(actual, base);
34
+ const expectedUrl = new URL(expected, base);
35
+
36
+ return (
37
+ actualUrl.origin === expectedUrl.origin &&
38
+ actualUrl.pathname === expectedUrl.pathname &&
39
+ containsQueryParams(actualUrl.searchParams, expectedUrl.searchParams)
40
+ );
19
41
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2024 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  /* eslint-disable @typescript-eslint/member-ordering */
@@ -55,6 +55,13 @@ export class IronListAdapter {
55
55
  this._scrollLineHeight = this._getScrollLineHeight();
56
56
  this.scrollTarget.addEventListener('wheel', (e) => this.__onWheel(e));
57
57
 
58
+ this.scrollTarget.addEventListener('virtualizer-element-focused', (e) => this.__onElementFocused(e));
59
+ this.elementsContainer.addEventListener('focusin', (e) => {
60
+ this.scrollTarget.dispatchEvent(
61
+ new CustomEvent('virtualizer-element-focused', { detail: { element: this.__getFocusedElement() } }),
62
+ );
63
+ });
64
+
58
65
  if (this.reorderElements) {
59
66
  // Reordering the physical elements cancels the user's grab of the scroll bar handle on Safari.
60
67
  // Need to defer reordering until the user lets go of the scroll bar handle.
@@ -82,6 +89,10 @@ export class IronListAdapter {
82
89
  return this.lastVisibleIndex + this._vidxOffset;
83
90
  }
84
91
 
92
+ get _maxVirtualIndexOffset() {
93
+ return this.size - this._virtualCount;
94
+ }
95
+
85
96
  __hasPlaceholders() {
86
97
  return this.__getVisibleElements().some((el) => el.__virtualizerPlaceholder);
87
98
  }
@@ -106,7 +117,7 @@ export class IronListAdapter {
106
117
  let targetVirtualIndex = Math.floor((index / this.size) * this._virtualCount);
107
118
  if (this._virtualCount - targetVirtualIndex < visibleElementCount) {
108
119
  targetVirtualIndex = this._virtualCount - (this.size - index);
109
- this._vidxOffset = this.size - this._virtualCount;
120
+ this._vidxOffset = this._maxVirtualIndexOffset;
110
121
  } else if (targetVirtualIndex < visibleElementCount) {
111
122
  if (index < OFFSET_ADJUST_MIN_THRESHOLD) {
112
123
  targetVirtualIndex = index;
@@ -136,7 +147,6 @@ export class IronListAdapter {
136
147
  }
137
148
 
138
149
  flush() {
139
- const startPhysicalCount = this._physicalCount;
140
150
  // The scroll target is hidden.
141
151
  if (this.scrollTarget.offsetHeight === 0) {
142
152
  return;
@@ -154,11 +164,6 @@ export class IronListAdapter {
154
164
  if (this.__debouncerWheelAnimationFrame) {
155
165
  this.__debouncerWheelAnimationFrame.flush();
156
166
  }
157
-
158
- if (this._physicalCount !== startPhysicalCount) {
159
- // Flushing again until physical count stabilizes fixes https://github.com/vaadin/flow-components/issues/5595#issuecomment-1770278913
160
- this.flush();
161
- }
162
167
  }
163
168
 
164
169
  update(startIndex = 0, endIndex = this.size - 1) {
@@ -227,6 +232,7 @@ export class IronListAdapter {
227
232
  // Clean up temporary placeholder sizing
228
233
  if (el.__virtualizerPlaceholder) {
229
234
  el.style.paddingTop = '';
235
+ el.style.opacity = '';
230
236
  el.__virtualizerPlaceholder = false;
231
237
  }
232
238
 
@@ -251,6 +257,7 @@ export class IronListAdapter {
251
257
  // Assign a temporary placeholder sizing to elements that would otherwise end up having
252
258
  // no height.
253
259
  el.style.paddingTop = `${this.__placeholderHeight}px`;
260
+ el.style.opacity = '0';
254
261
  el.__virtualizerPlaceholder = true;
255
262
 
256
263
  // Manually schedule the resize handler to make sure the placeholder padding is
@@ -297,24 +304,41 @@ export class IronListAdapter {
297
304
  this._debouncers._increasePoolIfNeeded.cancel();
298
305
  }
299
306
 
307
+ // Prevent element update while the scroll position is being restored
308
+ this.__preventElementUpdates = true;
309
+
310
+ // Record the scroll position before changing the size
311
+ let fvi; // First visible index
312
+ let fviOffsetBefore; // Scroll offset of the first visible index
313
+ if (size > 0) {
314
+ fvi = this.adjustedFirstVisibleIndex;
315
+ fviOffsetBefore = this.__getIndexScrollOffset(fvi);
316
+ }
317
+
300
318
  // Change the size
301
319
  this.__size = size;
302
320
 
303
- if (!this._physicalItems) {
304
- // Not initialized yet
305
- this._itemsChanged({
306
- path: 'items',
307
- });
308
- this.__preventElementUpdates = true;
309
- flush();
310
- this.__preventElementUpdates = false;
311
- } else {
312
- // Already initialized, just update _virtualCount
313
- this._updateScrollerSize();
314
- this._virtualCount = this.items.length;
315
- this._render();
321
+ this._itemsChanged({
322
+ path: 'items',
323
+ });
324
+ flush();
325
+
326
+ // Try to restore the scroll position if the new size is larger than 0
327
+ if (size > 0) {
328
+ fvi = Math.min(fvi, size - 1);
329
+ // Note, calling scrollToIndex also updates the virtual index offset,
330
+ // causing the virtualizer to add more items when size is increased,
331
+ // and remove exceeding items when size is decreased.
332
+ this.scrollToIndex(fvi);
333
+
334
+ const fviOffsetAfter = this.__getIndexScrollOffset(fvi);
335
+ if (fviOffsetBefore !== undefined && fviOffsetAfter !== undefined) {
336
+ this._scrollTop += fviOffsetBefore - fviOffsetAfter;
337
+ }
316
338
  }
317
339
 
340
+ this.__preventElementUpdates = false;
341
+
318
342
  // When reducing size while invisible, iron-list does not update items, so
319
343
  // their hidden state is not updated and their __lastUpdatedIndex is not
320
344
  // reset. In that case force an update here.
@@ -326,8 +350,7 @@ export class IronListAdapter {
326
350
  requestAnimationFrame(() => this._resizeHandler());
327
351
  }
328
352
 
329
- // Schedule and flush a resize handler. This will cause a
330
- // re-render for the elements.
353
+ // Schedule and flush a resize handler
331
354
  this._resizeHandler();
332
355
  flush();
333
356
  }
@@ -425,6 +448,75 @@ export class IronListAdapter {
425
448
  /** @private */
426
449
  toggleScrollListener() {}
427
450
 
451
+ /** @private */
452
+ __getFocusedElement(visibleElements = this.__getVisibleElements()) {
453
+ return visibleElements.find(
454
+ (element) =>
455
+ element.contains(this.elementsContainer.getRootNode().activeElement) ||
456
+ element.contains(this.scrollTarget.getRootNode().activeElement),
457
+ );
458
+ }
459
+
460
+ /** @private */
461
+ __nextFocusableSiblingMissing(focusedElement, visibleElements) {
462
+ return (
463
+ // Check if focused element is the last visible DOM element
464
+ visibleElements.indexOf(focusedElement) === visibleElements.length - 1 &&
465
+ // ...while there are more items available
466
+ this.size > focusedElement.__virtualIndex + 1
467
+ );
468
+ }
469
+
470
+ /** @private */
471
+ __previousFocusableSiblingMissing(focusedElement, visibleElements) {
472
+ return (
473
+ // Check if focused element is the first visible DOM element
474
+ visibleElements.indexOf(focusedElement) === 0 &&
475
+ // ...while there are preceding items available
476
+ focusedElement.__virtualIndex > 0
477
+ );
478
+ }
479
+
480
+ /** @private */
481
+ __onElementFocused(e) {
482
+ if (!this.reorderElements) {
483
+ return;
484
+ }
485
+
486
+ const focusedElement = e.detail.element;
487
+ if (!focusedElement) {
488
+ return;
489
+ }
490
+
491
+ // User has tabbed to or within a virtualizer element.
492
+ // Check if a next or previous focusable sibling is missing while it should be there (so the user can continue tabbing).
493
+ // The focusable sibling might be missing due to the elements not yet being in the correct DOM order.
494
+ // First try flushing (which also flushes any active __scrollReorderDebouncer).
495
+ const visibleElements = this.__getVisibleElements();
496
+ if (
497
+ this.__previousFocusableSiblingMissing(focusedElement, visibleElements) ||
498
+ this.__nextFocusableSiblingMissing(focusedElement, visibleElements)
499
+ ) {
500
+ this.flush();
501
+ }
502
+
503
+ // If the focusable sibling is still missing (because the focused element is at the edge of the viewport and
504
+ // the virtual scrolling logic hasn't had the need to recycle elements), scroll the virtualizer just enough to
505
+ // have the focusable sibling inside the visible viewport to force the virtualizer to recycle.
506
+ const reorderedVisibleElements = this.__getVisibleElements();
507
+ if (this.__nextFocusableSiblingMissing(focusedElement, reorderedVisibleElements)) {
508
+ this._scrollTop +=
509
+ Math.ceil(focusedElement.getBoundingClientRect().bottom) -
510
+ Math.floor(this.scrollTarget.getBoundingClientRect().bottom - 1);
511
+ this.flush();
512
+ } else if (this.__previousFocusableSiblingMissing(focusedElement, reorderedVisibleElements)) {
513
+ this._scrollTop -=
514
+ Math.ceil(this.scrollTarget.getBoundingClientRect().top + 1) -
515
+ Math.floor(focusedElement.getBoundingClientRect().top);
516
+ this.flush();
517
+ }
518
+ }
519
+
428
520
  _scrollHandler() {
429
521
  // The scroll target is hidden.
430
522
  if (this.scrollTarget.offsetHeight === 0) {
@@ -662,13 +754,7 @@ export class IronListAdapter {
662
754
 
663
755
  // Which row to use as a target?
664
756
  const visibleElements = this.__getVisibleElements();
665
-
666
- const elementWithFocus = visibleElements.find(
667
- (element) =>
668
- element.contains(this.elementsContainer.getRootNode().activeElement) ||
669
- element.contains(this.scrollTarget.getRootNode().activeElement),
670
- );
671
- const targetElement = elementWithFocus || visibleElements[0];
757
+ const targetElement = this.__getFocusedElement(visibleElements) || visibleElements[0];
672
758
  if (!targetElement) {
673
759
  // All elements are hidden, don't reorder
674
760
  return;
@@ -703,6 +789,8 @@ export class IronListAdapter {
703
789
 
704
790
  /** @private */
705
791
  _adjustVirtualIndexOffset(delta) {
792
+ const maxOffset = this._maxVirtualIndexOffset;
793
+
706
794
  if (this._virtualCount >= this.size) {
707
795
  this._vidxOffset = 0;
708
796
  } else if (this.__skipNextVirtualIndexAdjust) {
@@ -710,8 +798,7 @@ export class IronListAdapter {
710
798
  } else if (Math.abs(delta) > 10000) {
711
799
  // Process a large scroll position change
712
800
  const scale = this._scrollTop / (this.scrollTarget.scrollHeight - this.scrollTarget.offsetHeight);
713
- const offset = scale * this.size;
714
- this._vidxOffset = Math.round(offset - scale * this._virtualCount);
801
+ this._vidxOffset = Math.round(scale * maxOffset);
715
802
  } else {
716
803
  // Make sure user can always swipe/wheel scroll to the start and end
717
804
  const oldOffset = this._vidxOffset;
@@ -730,7 +817,6 @@ export class IronListAdapter {
730
817
  }
731
818
 
732
819
  // Near end
733
- const maxOffset = this.size - this._virtualCount;
734
820
  if (this._scrollTop >= this._maxScrollTop && this._maxScrollTop > 0) {
735
821
  this._vidxOffset = maxOffset;
736
822
  if (oldOffset !== this._vidxOffset) {