@vaadin/component-base 25.3.0-alpha2 → 25.3.0-alpha4

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": "25.3.0-alpha2",
3
+ "version": "25.3.0-alpha4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,11 +38,11 @@
38
38
  "lit": "^3.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@vaadin/chai-plugins": "25.3.0-alpha2",
42
- "@vaadin/test-runner-commands": "25.3.0-alpha2",
41
+ "@vaadin/chai-plugins": "25.3.0-alpha4",
42
+ "@vaadin/test-runner-commands": "25.3.0-alpha4",
43
43
  "@vaadin/testing-helpers": "^2.0.0",
44
44
  "sinon": "^22.0.0"
45
45
  },
46
46
  "customElements": "custom-elements.json",
47
- "gitHead": "52eba6153ecf8bfaae44bcb727595e77d90b963c"
47
+ "gitHead": "ff0efcd52d3b8a081e8101d36cf7bef65ed71cb1"
48
48
  }
@@ -15,13 +15,6 @@ export class Cache {
15
15
  */
16
16
  context;
17
17
 
18
- /**
19
- * The number of items to display per page.
20
- *
21
- * @type {number}
22
- */
23
- pageSize;
24
-
25
18
  /**
26
19
  * An array of cached items.
27
20
  *
@@ -50,6 +43,14 @@ export class Cache {
50
43
  */
51
44
  #subCacheByIndex = {};
52
45
 
46
+ /**
47
+ * The number of items per page.
48
+ *
49
+ * @type {number}
50
+ * @private
51
+ */
52
+ #pageSize;
53
+
53
54
  /**
54
55
  * The number of items.
55
56
  *
@@ -123,6 +124,29 @@ export class Cache {
123
124
  return this.#flatSize;
124
125
  }
125
126
 
127
+ /**
128
+ * The number of items per page.
129
+ *
130
+ * @return {number}
131
+ */
132
+ get pageSize() {
133
+ return this.#pageSize;
134
+ }
135
+
136
+ /**
137
+ * Sets the number of items per page for this cache and its descendants.
138
+ * Changing the page size discards all pending page requests.
139
+ *
140
+ * @param {number} pageSize
141
+ */
142
+ set pageSize(pageSize) {
143
+ this.#pageSize = pageSize;
144
+ this.pendingRequests = {};
145
+ this.subCaches.forEach((subCache) => {
146
+ subCache.pageSize = pageSize;
147
+ });
148
+ }
149
+
126
150
  /**
127
151
  * The number of items.
128
152
  *
@@ -29,13 +29,6 @@ export class DataProviderController extends EventTarget {
29
29
  */
30
30
  dataProviderParams;
31
31
 
32
- /**
33
- * A number of items to display per page.
34
- *
35
- * @type {number}
36
- */
37
- pageSize;
38
-
39
32
  /**
40
33
  * A callback that returns whether the given item is expanded.
41
34
  *
@@ -78,14 +71,13 @@ export class DataProviderController extends EventTarget {
78
71
  ) {
79
72
  super();
80
73
  this.host = host;
81
- this.pageSize = pageSize;
82
74
  this.getItemId = getItemId;
83
75
  this.isExpanded = isExpanded;
84
76
  this.placeholder = placeholder;
85
77
  this.isPlaceholder = isPlaceholder;
86
78
  this.dataProvider = dataProvider;
87
79
  this.dataProviderParams = dataProviderParams;
88
- this.rootCache = this.#createRootCache(size);
80
+ this.rootCache = this.#createRootCache(pageSize, size);
89
81
  }
90
82
 
91
83
  /**
@@ -95,6 +87,13 @@ export class DataProviderController extends EventTarget {
95
87
  return this.rootCache.flatSize;
96
88
  }
97
89
 
90
+ /**
91
+ * The number of items per page in the root cache.
92
+ */
93
+ get pageSize() {
94
+ return this.rootCache.pageSize;
95
+ }
96
+
98
97
  /** @private */
99
98
  get #cacheContext() {
100
99
  return {
@@ -113,13 +112,12 @@ export class DataProviderController extends EventTarget {
113
112
  }
114
113
 
115
114
  /**
116
- * Sets the page size and clears the cache.
115
+ * Sets the number of items per page in the root cache and any of its descendants.
117
116
  *
118
117
  * @param {number} pageSize
119
118
  */
120
119
  setPageSize(pageSize) {
121
- this.pageSize = pageSize;
122
- this.clearCache();
120
+ this.rootCache.pageSize = pageSize;
123
121
  }
124
122
 
125
123
  /**
@@ -129,7 +127,6 @@ export class DataProviderController extends EventTarget {
129
127
  */
130
128
  setDataProvider(dataProvider) {
131
129
  this.dataProvider = dataProvider;
132
- this.clearCache();
133
130
  }
134
131
 
135
132
  /**
@@ -143,7 +140,7 @@ export class DataProviderController extends EventTarget {
143
140
  * Clears the cache.
144
141
  */
145
142
  clearCache() {
146
- this.rootCache = this.#createRootCache(this.rootCache.size);
143
+ this.rootCache = this.#createRootCache(this.rootCache.pageSize, this.rootCache.size);
147
144
  }
148
145
 
149
146
  /**
@@ -238,8 +235,8 @@ export class DataProviderController extends EventTarget {
238
235
  }
239
236
 
240
237
  /** @private */
241
- #createRootCache(size) {
242
- return new Cache(this.#cacheContext, this.pageSize, size);
238
+ #createRootCache(pageSize, size) {
239
+ return new Cache(this.#cacheContext, pageSize, size);
243
240
  }
244
241
 
245
242
  /** @private */
@@ -250,7 +247,7 @@ export class DataProviderController extends EventTarget {
250
247
 
251
248
  let params = {
252
249
  page,
253
- pageSize: this.pageSize,
250
+ pageSize: cache.pageSize,
254
251
  parentItem: cache.parentItem,
255
252
  };
256
253
 
package/src/define.js CHANGED
@@ -13,7 +13,7 @@ function dashToCamelCase(dash) {
13
13
 
14
14
  const experimentalMap = {};
15
15
 
16
- export function defineCustomElement(CustomElement, version = '25.3.0-alpha2') {
16
+ export function defineCustomElement(CustomElement, version = '25.3.0-alpha4') {
17
17
  Object.defineProperty(CustomElement, 'version', {
18
18
  get() {
19
19
  return version;
@@ -83,10 +83,12 @@ addGlobalStyles(
83
83
  --_vaadin-icon-arrow-up: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12 7-7 7 7"/><path d="M12 19V5"/></svg>');
84
84
  --_vaadin-icon-calendar: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v4"/><path d="M16 2v4"/><rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/></svg>');
85
85
  --_vaadin-icon-checkmark: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5" /></svg>');
86
+ --_vaadin-icon-checkmark-small: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5" /></svg>');
86
87
  --_vaadin-icon-chevron-down: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>');
87
88
  --_vaadin-icon-chevron-right: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6"/></svg>');
88
89
  --_vaadin-icon-clock: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 6v6l4 2"/><circle cx="12" cy="12" r="10"/></svg>');
89
90
  --_vaadin-icon-cross: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" /></svg>');
91
+ --_vaadin-icon-cross-small: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" /></svg>');
90
92
  --_vaadin-icon-drag: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"><path d="M11 7c0 .82843-.6716 1.5-1.5 1.5C8.67157 8.5 8 7.82843 8 7s.67157-1.5 1.5-1.5c.8284 0 1.5.67157 1.5 1.5Zm0 5c0 .8284-.6716 1.5-1.5 1.5-.82843 0-1.5-.6716-1.5-1.5s.67157-1.5 1.5-1.5c.8284 0 1.5.6716 1.5 1.5Zm0 5c0 .8284-.6716 1.5-1.5 1.5-.82843 0-1.5-.6716-1.5-1.5s.67157-1.5 1.5-1.5c.8284 0 1.5.6716 1.5 1.5Zm5-10c0 .82843-.6716 1.5-1.5 1.5S13 7.82843 13 7s.6716-1.5 1.5-1.5S16 6.17157 16 7Zm0 5c0 .8284-.6716 1.5-1.5 1.5S13 12.8284 13 12s.6716-1.5 1.5-1.5 1.5.6716 1.5 1.5Zm0 5c0 .8284-.6716 1.5-1.5 1.5S13 17.8284 13 17s.6716-1.5 1.5-1.5 1.5.6716 1.5 1.5Z" fill="currentColor"/></svg>');
91
93
  --_vaadin-icon-ellipsis: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>');
92
94
  --_vaadin-icon-eye: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" /></svg>');
@@ -88,7 +88,12 @@ export class IronListAdapter {
88
88
  if (this.reorderElements) {
89
89
  // Reordering the physical elements cancels the user's grab of the scroll bar handle on Safari.
90
90
  // Need to defer reordering until the user lets go of the scroll bar handle.
91
- this.scrollTarget.addEventListener('mousedown', () => {
91
+ this.scrollTarget.addEventListener('mousedown', (event) => {
92
+ // Only handle clicks on the scroll target itself
93
+ if (event.target !== this.scrollTarget) {
94
+ return;
95
+ }
96
+
92
97
  this.__mouseDown = true;
93
98
  });
94
99
  this.scrollTarget.addEventListener('mouseup', () => {