@vaadin/field-highlighter 23.1.0-alpha4 → 23.1.0-beta3
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 +17 -17
- package/src/fields/vaadin-component-observer.js +3 -3
- package/src/fields/vaadin-date-picker-observer.js +5 -5
- package/src/fields/vaadin-date-time-picker-observer.js +2 -2
- package/src/fields/vaadin-select-observer.js +4 -4
- package/src/vaadin-user-tags-overlay.js +2 -12
- package/src/vaadin-user-tags.js +13 -61
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/field-highlighter",
|
|
3
|
-
"version": "23.1.0-
|
|
3
|
+
"version": "23.1.0-beta3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@polymer/polymer": "^3.0.0",
|
|
37
|
-
"@vaadin/component-base": "23.1.0-
|
|
38
|
-
"@vaadin/vaadin-lumo-styles": "23.1.0-
|
|
39
|
-
"@vaadin/vaadin-material-styles": "23.1.0-
|
|
40
|
-
"@vaadin/vaadin-overlay": "23.1.0-
|
|
41
|
-
"@vaadin/vaadin-themable-mixin": "23.1.0-
|
|
37
|
+
"@vaadin/component-base": "23.1.0-beta3",
|
|
38
|
+
"@vaadin/vaadin-lumo-styles": "23.1.0-beta3",
|
|
39
|
+
"@vaadin/vaadin-material-styles": "23.1.0-beta3",
|
|
40
|
+
"@vaadin/vaadin-overlay": "23.1.0-beta3",
|
|
41
|
+
"@vaadin/vaadin-themable-mixin": "23.1.0-beta3",
|
|
42
42
|
"lit": "^2.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@esm-bundle/chai": "^4.3.4",
|
|
46
|
-
"@vaadin/checkbox": "23.1.0-
|
|
47
|
-
"@vaadin/combo-box": "23.1.0-
|
|
48
|
-
"@vaadin/date-picker": "23.1.0-
|
|
49
|
-
"@vaadin/date-time-picker": "23.1.0-
|
|
50
|
-
"@vaadin/item": "23.1.0-
|
|
51
|
-
"@vaadin/list-box": "23.1.0-
|
|
52
|
-
"@vaadin/radio-group": "23.1.0-
|
|
53
|
-
"@vaadin/select": "23.1.0-
|
|
46
|
+
"@vaadin/checkbox": "23.1.0-beta3",
|
|
47
|
+
"@vaadin/combo-box": "23.1.0-beta3",
|
|
48
|
+
"@vaadin/date-picker": "23.1.0-beta3",
|
|
49
|
+
"@vaadin/date-time-picker": "23.1.0-beta3",
|
|
50
|
+
"@vaadin/item": "23.1.0-beta3",
|
|
51
|
+
"@vaadin/list-box": "23.1.0-beta3",
|
|
52
|
+
"@vaadin/radio-group": "23.1.0-beta3",
|
|
53
|
+
"@vaadin/select": "23.1.0-beta3",
|
|
54
54
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
55
|
-
"@vaadin/text-field": "23.1.0-
|
|
56
|
-
"@vaadin/time-picker": "23.1.0-
|
|
55
|
+
"@vaadin/text-field": "23.1.0-beta3",
|
|
56
|
+
"@vaadin/time-picker": "23.1.0-beta3",
|
|
57
57
|
"sinon": "^13.0.2"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "c787ceb8a312f88631c6d429ff320d5f89b1b838"
|
|
60
60
|
}
|
|
@@ -32,7 +32,7 @@ export class ComponentObserver {
|
|
|
32
32
|
this._tags = tags;
|
|
33
33
|
|
|
34
34
|
component.addEventListener('mouseenter', (event) => {
|
|
35
|
-
//
|
|
35
|
+
// Ignore mouseleave on overlay opening
|
|
36
36
|
if (event.relatedTarget === this._tags.$.overlay) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
@@ -45,7 +45,7 @@ export class ComponentObserver {
|
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
component.addEventListener('mouseleave', (event) => {
|
|
48
|
-
//
|
|
48
|
+
// Ignore mouseleave on overlay opening
|
|
49
49
|
if (event.relatedTarget === this._tags.$.overlay) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
@@ -76,7 +76,7 @@ export class ComponentObserver {
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
this._tags.$.overlay.addEventListener('mouseleave', (event) => {
|
|
79
|
-
//
|
|
79
|
+
// Ignore mouseleave when moving back to field
|
|
80
80
|
if (event.relatedTarget === component) {
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
@@ -45,13 +45,13 @@ export class DatePickerObserver extends ComponentObserver {
|
|
|
45
45
|
|
|
46
46
|
onFocusIn(event) {
|
|
47
47
|
if (event.relatedTarget === this.overlay) {
|
|
48
|
-
//
|
|
48
|
+
// Focus returns from the overlay, do nothing.
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
if (this.blurWhileOpened) {
|
|
53
53
|
this.blurWhileOpened = false;
|
|
54
|
-
//
|
|
54
|
+
// Focus returns from outside the browser tab, ignore.
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -60,9 +60,9 @@ export class DatePickerObserver extends ComponentObserver {
|
|
|
60
60
|
|
|
61
61
|
onFocusOut(event) {
|
|
62
62
|
if (this.fullscreenFocus || event.relatedTarget === this.overlay) {
|
|
63
|
-
//
|
|
63
|
+
// Do nothing, overlay is opening.
|
|
64
64
|
} else if (!this.datePicker.opened) {
|
|
65
|
-
//
|
|
65
|
+
// Field blur when closed.
|
|
66
66
|
this.hideOutline(this.datePicker);
|
|
67
67
|
} else {
|
|
68
68
|
// Focus moves away while still opened, e.g. outside the browser.
|
|
@@ -84,7 +84,7 @@ export class DatePickerObserver extends ComponentObserver {
|
|
|
84
84
|
this.showOutline(this.datePicker);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
//
|
|
87
|
+
// Closing after previously moving focus away.
|
|
88
88
|
if (event.detail.value === false && this.blurWhileOpened) {
|
|
89
89
|
this.blurWhileOpened = false;
|
|
90
90
|
this.hideOutline(this.datePicker);
|
|
@@ -11,7 +11,7 @@ class DateObserver extends DatePickerObserver {
|
|
|
11
11
|
constructor(datePicker, host) {
|
|
12
12
|
super(datePicker);
|
|
13
13
|
|
|
14
|
-
//
|
|
14
|
+
// Fire events on the host
|
|
15
15
|
this.component = host;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -24,7 +24,7 @@ class TimeObserver extends FieldObserver {
|
|
|
24
24
|
constructor(timePicker, host) {
|
|
25
25
|
super(timePicker);
|
|
26
26
|
|
|
27
|
-
//
|
|
27
|
+
// Fire events on the host
|
|
28
28
|
this.component = host;
|
|
29
29
|
this.timePicker = timePicker;
|
|
30
30
|
}
|
|
@@ -17,7 +17,7 @@ export class SelectObserver extends FieldObserver {
|
|
|
17
17
|
super.addListeners(select);
|
|
18
18
|
|
|
19
19
|
select.addEventListener('opened-changed', (event) => {
|
|
20
|
-
//
|
|
20
|
+
// When in phone mode, focus is lost when closing.
|
|
21
21
|
if (select._phone && event.detail.value === false) {
|
|
22
22
|
this.hideOutline(select);
|
|
23
23
|
}
|
|
@@ -26,12 +26,12 @@ export class SelectObserver extends FieldObserver {
|
|
|
26
26
|
|
|
27
27
|
onFocusIn(event) {
|
|
28
28
|
if (this.overlay.contains(event.relatedTarget)) {
|
|
29
|
-
//
|
|
29
|
+
// Focus returns on item select, do nothing.
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
if (!this.component._phone && this.overlay.hasAttribute('closing')) {
|
|
34
|
-
//
|
|
34
|
+
// Focus returns on outside click, do nothing.
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -40,7 +40,7 @@ export class SelectObserver extends FieldObserver {
|
|
|
40
40
|
|
|
41
41
|
onFocusOut(event) {
|
|
42
42
|
if (this.overlay.contains(event.relatedTarget)) {
|
|
43
|
-
//
|
|
43
|
+
// Do nothing, overlay is opening.
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
super.onFocusOut(event);
|
|
@@ -4,17 +4,15 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { OverlayElement } from '@vaadin/vaadin-overlay/src/vaadin-overlay.js';
|
|
7
|
+
import { PositionMixin } from '@vaadin/vaadin-overlay/src/vaadin-overlay-position-mixin.js';
|
|
7
8
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
9
|
|
|
9
10
|
registerStyles(
|
|
10
11
|
'vaadin-user-tags-overlay',
|
|
11
12
|
css`
|
|
12
13
|
:host {
|
|
13
|
-
align-items: stretch;
|
|
14
|
-
justify-content: flex-start;
|
|
15
14
|
background: transparent;
|
|
16
15
|
box-shadow: none;
|
|
17
|
-
bottom: auto;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
[part='overlay'] {
|
|
@@ -42,14 +40,6 @@ registerStyles(
|
|
|
42
40
|
padding: 0;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
:host([dir='rtl']) {
|
|
46
|
-
left: auto;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
:host(:not([dir='rtl'])) {
|
|
50
|
-
right: auto;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
43
|
:host([opening]),
|
|
54
44
|
:host([closing]) {
|
|
55
45
|
animation: 0.14s user-tags-overlay-dummy-animation;
|
|
@@ -73,7 +63,7 @@ registerStyles(
|
|
|
73
63
|
* @extends OverlayElement
|
|
74
64
|
* @private
|
|
75
65
|
*/
|
|
76
|
-
class UserTagsOverlay extends OverlayElement {
|
|
66
|
+
class UserTagsOverlay extends PositionMixin(OverlayElement) {
|
|
77
67
|
static get is() {
|
|
78
68
|
return 'vaadin-user-tags-overlay';
|
|
79
69
|
}
|
package/src/vaadin-user-tags.js
CHANGED
|
@@ -45,6 +45,7 @@ export class UserTags extends PolymerElement {
|
|
|
45
45
|
id="overlay"
|
|
46
46
|
modeless
|
|
47
47
|
opened="[[opened]]"
|
|
48
|
+
no-vertical-overlap
|
|
48
49
|
on-vaadin-overlay-open="_onOverlayOpen"
|
|
49
50
|
></vaadin-user-tags-overlay>
|
|
50
51
|
`;
|
|
@@ -68,7 +69,6 @@ export class UserTags extends PolymerElement {
|
|
|
68
69
|
opened: {
|
|
69
70
|
type: Boolean,
|
|
70
71
|
value: false,
|
|
71
|
-
observer: '_openedChanged',
|
|
72
72
|
},
|
|
73
73
|
|
|
74
74
|
/**
|
|
@@ -85,6 +85,7 @@ export class UserTags extends PolymerElement {
|
|
|
85
85
|
*/
|
|
86
86
|
target: {
|
|
87
87
|
type: Object,
|
|
88
|
+
observer: '__targetChanged',
|
|
88
89
|
},
|
|
89
90
|
|
|
90
91
|
/**
|
|
@@ -103,23 +104,9 @@ export class UserTags extends PolymerElement {
|
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
constructor() {
|
|
107
|
-
super();
|
|
108
|
-
this._boundSetPosition = this._debounceSetPosition.bind(this);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** @protected */
|
|
112
|
-
connectedCallback() {
|
|
113
|
-
super.connectedCallback();
|
|
114
|
-
window.addEventListener('resize', this._boundSetPosition);
|
|
115
|
-
window.addEventListener('scroll', this._boundSetPosition);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
107
|
/** @protected */
|
|
119
108
|
disconnectedCallback() {
|
|
120
109
|
super.disconnectedCallback();
|
|
121
|
-
window.removeEventListener('resize', this._boundSetPosition);
|
|
122
|
-
window.removeEventListener('scroll', this._boundSetPosition);
|
|
123
110
|
this.opened = false;
|
|
124
111
|
}
|
|
125
112
|
|
|
@@ -138,15 +125,8 @@ export class UserTags extends PolymerElement {
|
|
|
138
125
|
}
|
|
139
126
|
|
|
140
127
|
/** @private */
|
|
141
|
-
|
|
142
|
-
this.
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/** @private */
|
|
146
|
-
_openedChanged(opened) {
|
|
147
|
-
if (opened) {
|
|
148
|
-
this._setPosition();
|
|
149
|
-
}
|
|
128
|
+
__targetChanged(target) {
|
|
129
|
+
this.$.overlay.positionTarget = target;
|
|
150
130
|
}
|
|
151
131
|
|
|
152
132
|
/** @private */
|
|
@@ -156,34 +136,6 @@ export class UserTags extends PolymerElement {
|
|
|
156
136
|
}
|
|
157
137
|
}
|
|
158
138
|
|
|
159
|
-
/**
|
|
160
|
-
* Set position of the user tags overlay.
|
|
161
|
-
* TODO: use PositionMixin instead.
|
|
162
|
-
*
|
|
163
|
-
* @private
|
|
164
|
-
*/
|
|
165
|
-
_setPosition() {
|
|
166
|
-
if (!this.opened) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const targetRect = this.target.getBoundingClientRect();
|
|
171
|
-
|
|
172
|
-
const overlayRect = this.$.overlay.getBoundingClientRect();
|
|
173
|
-
|
|
174
|
-
this._translateX =
|
|
175
|
-
this.getAttribute('dir') === 'rtl'
|
|
176
|
-
? targetRect.right - overlayRect.right + (this._translateX || 0)
|
|
177
|
-
: targetRect.left - overlayRect.left + (this._translateX || 0);
|
|
178
|
-
this._translateY = targetRect.top - overlayRect.top + (this._translateY || 0) + targetRect.height;
|
|
179
|
-
|
|
180
|
-
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
181
|
-
this._translateX = Math.round(this._translateX * devicePixelRatio) / devicePixelRatio;
|
|
182
|
-
this._translateY = Math.round(this._translateY * devicePixelRatio) / devicePixelRatio;
|
|
183
|
-
|
|
184
|
-
this.$.overlay.style.transform = `translate3d(${this._translateX}px, ${this._translateY}px, 0)`;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
139
|
get wrapper() {
|
|
188
140
|
return this.$.overlay.content.querySelector('[part="tags"]');
|
|
189
141
|
}
|
|
@@ -220,7 +172,7 @@ export class UserTags extends PolymerElement {
|
|
|
220
172
|
}
|
|
221
173
|
});
|
|
222
174
|
|
|
223
|
-
//
|
|
175
|
+
// Filter out users that are only moved
|
|
224
176
|
const addedUsers = usersToAdd.filter((u) => !usersToRemove.some((u2) => u.id === u2.id));
|
|
225
177
|
const removedUsers = usersToRemove.filter((u) => !usersToAdd.some((u2) => u.id === u2.id));
|
|
226
178
|
|
|
@@ -264,7 +216,7 @@ export class UserTags extends PolymerElement {
|
|
|
264
216
|
|
|
265
217
|
const changedTags = this.getChangedTags(addedUsers, removedUsers);
|
|
266
218
|
|
|
267
|
-
//
|
|
219
|
+
// Check if flash queue contains pending tags for removed users
|
|
268
220
|
if (this._flashQueue.length > 0) {
|
|
269
221
|
for (let i = 0; i < removedUsers.length; i++) {
|
|
270
222
|
if (changedTags.removed[i] === null) {
|
|
@@ -283,7 +235,7 @@ export class UserTags extends PolymerElement {
|
|
|
283
235
|
// Avoid adding to queue if window is not visible.
|
|
284
236
|
const tags = changedTags.added;
|
|
285
237
|
if (this.flashing) {
|
|
286
|
-
//
|
|
238
|
+
// Schedule next flash later
|
|
287
239
|
this.push('_flashQueue', tags);
|
|
288
240
|
} else {
|
|
289
241
|
this.flashTags(tags);
|
|
@@ -296,7 +248,7 @@ export class UserTags extends PolymerElement {
|
|
|
296
248
|
|
|
297
249
|
/** @private */
|
|
298
250
|
_onOverlayOpen() {
|
|
299
|
-
//
|
|
251
|
+
// Animate all tags except removing ones
|
|
300
252
|
Array.from(this.wrapper.children).forEach((tag) => {
|
|
301
253
|
if (!tag.classList.contains('removing')) {
|
|
302
254
|
tag.classList.add('show');
|
|
@@ -308,11 +260,11 @@ export class UserTags extends PolymerElement {
|
|
|
308
260
|
this.flashing = true;
|
|
309
261
|
const wrapper = this.wrapper;
|
|
310
262
|
|
|
311
|
-
//
|
|
263
|
+
// Hide existing tags
|
|
312
264
|
const hidden = Array.from(wrapper.children);
|
|
313
265
|
hidden.forEach((tag) => (tag.style.display = 'none'));
|
|
314
266
|
|
|
315
|
-
//
|
|
267
|
+
// Render new tags
|
|
316
268
|
added.forEach((tag) => {
|
|
317
269
|
wrapper.insertBefore(tag, wrapper.firstChild);
|
|
318
270
|
});
|
|
@@ -320,12 +272,12 @@ export class UserTags extends PolymerElement {
|
|
|
320
272
|
this.flashPromise = new Promise((resolve) => {
|
|
321
273
|
listenOnce(this.$.overlay, 'vaadin-overlay-open').then(() => {
|
|
322
274
|
this._debounceFlashStart = Debouncer.debounce(this._debounceFlashStart, timeOut.after(DURATION + DELAY), () => {
|
|
323
|
-
//
|
|
275
|
+
// Animate disappearing
|
|
324
276
|
if (!this.hasFocus) {
|
|
325
277
|
added.forEach((tag) => tag.classList.remove('show'));
|
|
326
278
|
}
|
|
327
279
|
this._debounceFlashEnd = Debouncer.debounce(this._debounceFlashEnd, timeOut.after(DURATION), () => {
|
|
328
|
-
//
|
|
280
|
+
// Show all tags
|
|
329
281
|
const finishFlash = () => {
|
|
330
282
|
hidden.forEach((tag) => (tag.style.display = 'block'));
|
|
331
283
|
this.flashing = false;
|
|
@@ -335,7 +287,7 @@ export class UserTags extends PolymerElement {
|
|
|
335
287
|
if (this.hasFocus) {
|
|
336
288
|
finishFlash();
|
|
337
289
|
} else {
|
|
338
|
-
//
|
|
290
|
+
// Wait for overlay closing animation to complete
|
|
339
291
|
listenOnce(this.$.overlay, 'animationend').then(() => {
|
|
340
292
|
finishFlash();
|
|
341
293
|
});
|