@vaadin/component-base 23.3.0-alpha2 → 24.0.0-alpha1

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": "23.3.0-alpha2",
3
+ "version": "24.0.0-alpha1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -42,5 +42,5 @@
42
42
  "@vaadin/testing-helpers": "^0.3.2",
43
43
  "sinon": "^13.0.2"
44
44
  },
45
- "gitHead": "ae61027c62ffa7f7d70cfc50e43f333addfc74b6"
45
+ "gitHead": "427527c27c4b27822d61fd41d38d7b170134770b"
46
46
  }
@@ -3,9 +3,8 @@
3
3
  * Copyright (c) 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
-
7
- import { animationFrame } from '@vaadin/component-base/src/async.js';
8
- import { Debouncer } from '@vaadin/component-base/src/debounce.js';
6
+ import { animationFrame } from './async.js';
7
+ import { Debouncer } from './debounce.js';
9
8
 
10
9
  const region = document.createElement('div');
11
10
 
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { addListener } from '@vaadin/component-base/src/gestures.js';
7
6
  import { DisabledMixin } from './disabled-mixin.js';
7
+ import { addListener } from './gestures.js';
8
8
  import { KeyboardMixin } from './keyboard-mixin.js';
9
9
 
10
10
  /**
package/src/dir-mixin.js CHANGED
@@ -9,6 +9,7 @@ import { DirHelper } from './dir-helper.js';
9
9
  * Array of Vaadin custom element classes that have been subscribed to the dir changes.
10
10
  */
11
11
  const directionSubscribers = [];
12
+
12
13
  function directionUpdater() {
13
14
  const documentDir = getDocumentDir();
14
15
  directionSubscribers.forEach((element) => {
@@ -74,7 +75,7 @@ export const DirMixin = (superClass) =>
74
75
  connectedCallback() {
75
76
  super.connectedCallback();
76
77
 
77
- if (!this.hasAttribute('dir')) {
78
+ if (!this.hasAttribute('dir') || this.__restoreSubscription) {
78
79
  this.__subscribe();
79
80
  alignDirs(this, getDocumentDir(), null);
80
81
  }
@@ -100,15 +101,15 @@ export const DirMixin = (superClass) =>
100
101
  this.__subscribe();
101
102
  alignDirs(this, documentDir, newValue);
102
103
  } else if (newDiffValue) {
103
- this.__subscribe(false);
104
+ this.__unsubscribe();
104
105
  }
105
106
  }
106
107
 
107
108
  /** @protected */
108
109
  disconnectedCallback() {
109
110
  super.disconnectedCallback();
110
- this.__subscribe(false);
111
- this.removeAttribute('dir');
111
+ this.__restoreSubscription = directionSubscribers.includes(this);
112
+ this.__unsubscribe();
112
113
  }
113
114
 
114
115
  /** @protected */
@@ -133,12 +134,15 @@ export const DirMixin = (superClass) =>
133
134
  }
134
135
 
135
136
  /** @private */
136
- __subscribe(push = true) {
137
- if (push) {
138
- if (!directionSubscribers.includes(this)) {
139
- directionSubscribers.push(this);
140
- }
141
- } else if (directionSubscribers.includes(this)) {
137
+ __subscribe() {
138
+ if (!directionSubscribers.includes(this)) {
139
+ directionSubscribers.push(this);
140
+ }
141
+ }
142
+
143
+ /** @private */
144
+ __unsubscribe() {
145
+ if (directionSubscribers.includes(this)) {
142
146
  directionSubscribers.splice(directionSubscribers.indexOf(this), 1);
143
147
  }
144
148
  }
@@ -39,7 +39,7 @@ const registered = new Set();
39
39
  export const ElementMixin = (superClass) =>
40
40
  class VaadinElementMixin extends DirMixin(superClass) {
41
41
  static get version() {
42
- return '23.3.0-alpha2';
42
+ return '24.0.0-alpha1';
43
43
  }
44
44
 
45
45
  /** @protected */
@@ -67,7 +67,9 @@ export class TooltipController extends SlotController {
67
67
  setOpened(opened: boolean): void;
68
68
 
69
69
  /**
70
- * Set position on the slotted tooltip.
70
+ * Set default position for the slotted tooltip.
71
+ * This can be overridden by setting the position
72
+ * using corresponding property or attribute.
71
73
  */
72
74
  setPosition(position: TooltipPosition): void;
73
75
 
@@ -39,7 +39,7 @@ export class TooltipController extends SlotController {
39
39
  }
40
40
 
41
41
  if (this.position !== undefined) {
42
- this.__updatePosition(tooltipNode, this.position);
42
+ tooltipNode._position = this.position;
43
43
  }
44
44
 
45
45
  if (this.shouldShow !== undefined) {
@@ -87,13 +87,18 @@ export class TooltipController extends SlotController {
87
87
  }
88
88
 
89
89
  /**
90
- * Set position on the slotted tooltip.
90
+ * Set default position for the slotted tooltip.
91
+ * This can be overridden by setting the position
92
+ * using corresponding property or attribute.
91
93
  * @param {string} position
92
94
  */
93
95
  setPosition(position) {
94
96
  this.position = position;
95
97
 
96
- this.__updatePosition(this.node, position);
98
+ const tooltipNode = this.node;
99
+ if (tooltipNode) {
100
+ tooltipNode._position = position;
101
+ }
97
102
  }
98
103
 
99
104
  /**
@@ -122,11 +127,4 @@ export class TooltipController extends SlotController {
122
127
  tooltipNode.target = target;
123
128
  }
124
129
  }
125
-
126
- /** @private */
127
- __updatePosition(node, position) {
128
- if (node && !node.hasAttribute('position')) {
129
- node.position = position;
130
- }
131
- }
132
130
  }
@@ -155,6 +155,10 @@ export class IronListAdapter {
155
155
  // Assign a temporary placeholder sizing to elements that would otherwise end up having
156
156
  // no height.
157
157
  el.style.paddingTop = `${this.__placeholderHeight}px`;
158
+
159
+ // Manually schedule the resize handler to make sure the placeholder padding is
160
+ // cleared in case the resize observer never triggers.
161
+ requestAnimationFrame(() => this._resizeHandler());
158
162
  } else {
159
163
  // Add element height to the queue
160
164
  this.__elementHeightQueue.push(elementHeight);
@@ -349,6 +353,12 @@ export class IronListAdapter {
349
353
  }
350
354
 
351
355
  this.__previousScrollTop = this._scrollTop;
356
+
357
+ // If the first visible index is not 0 when scrolled to the top,
358
+ // add some scroll offset to enable the user to continue scrolling.
359
+ if (this._scrollTop === 0 && this.firstVisibleIndex !== 0) {
360
+ this._scrollTop = 1;
361
+ }
352
362
  }
353
363
 
354
364
  /** @private */