@vaadin/field-highlighter 25.0.0-alpha7 → 25.0.0-alpha9

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/field-highlighter",
3
- "version": "25.0.0-alpha7",
3
+ "version": "25.0.0-alpha9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -33,29 +33,29 @@
33
33
  "field"
34
34
  ],
35
35
  "dependencies": {
36
- "@vaadin/a11y-base": "25.0.0-alpha7",
37
- "@vaadin/component-base": "25.0.0-alpha7",
38
- "@vaadin/overlay": "25.0.0-alpha7",
39
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha7",
40
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha7",
36
+ "@vaadin/a11y-base": "25.0.0-alpha9",
37
+ "@vaadin/component-base": "25.0.0-alpha9",
38
+ "@vaadin/overlay": "25.0.0-alpha9",
39
+ "@vaadin/vaadin-lumo-styles": "25.0.0-alpha9",
40
+ "@vaadin/vaadin-themable-mixin": "25.0.0-alpha9",
41
41
  "lit": "^3.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@vaadin/chai-plugins": "25.0.0-alpha7",
45
- "@vaadin/checkbox": "25.0.0-alpha7",
46
- "@vaadin/checkbox-group": "25.0.0-alpha7",
47
- "@vaadin/date-picker": "25.0.0-alpha7",
48
- "@vaadin/date-time-picker": "25.0.0-alpha7",
49
- "@vaadin/item": "25.0.0-alpha7",
50
- "@vaadin/list-box": "25.0.0-alpha7",
51
- "@vaadin/radio-group": "25.0.0-alpha7",
52
- "@vaadin/select": "25.0.0-alpha7",
53
- "@vaadin/test-runner-commands": "25.0.0-alpha7",
44
+ "@vaadin/chai-plugins": "25.0.0-alpha9",
45
+ "@vaadin/checkbox": "25.0.0-alpha9",
46
+ "@vaadin/checkbox-group": "25.0.0-alpha9",
47
+ "@vaadin/date-picker": "25.0.0-alpha9",
48
+ "@vaadin/date-time-picker": "25.0.0-alpha9",
49
+ "@vaadin/item": "25.0.0-alpha9",
50
+ "@vaadin/list-box": "25.0.0-alpha9",
51
+ "@vaadin/radio-group": "25.0.0-alpha9",
52
+ "@vaadin/select": "25.0.0-alpha9",
53
+ "@vaadin/test-runner-commands": "25.0.0-alpha9",
54
54
  "@vaadin/testing-helpers": "^2.0.0",
55
- "@vaadin/text-area": "25.0.0-alpha7",
56
- "@vaadin/text-field": "25.0.0-alpha7",
57
- "@vaadin/time-picker": "25.0.0-alpha7",
55
+ "@vaadin/text-area": "25.0.0-alpha9",
56
+ "@vaadin/text-field": "25.0.0-alpha9",
57
+ "@vaadin/time-picker": "25.0.0-alpha9",
58
58
  "sinon": "^18.0.0"
59
59
  },
60
- "gitHead": "87f72707ce6866892f8be5782fa0da008e87dcbc"
60
+ "gitHead": "bbe4720721e0955ffc87a79b412bee38b1f0eb1e"
61
61
  }
@@ -3,6 +3,7 @@
3
3
  * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
+ import { isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
6
7
  import { ComponentObserver } from './vaadin-component-observer.js';
7
8
 
8
9
  export class DatePickerObserver extends ComponentObserver {
@@ -10,7 +11,6 @@ export class DatePickerObserver extends ComponentObserver {
10
11
  super(datePicker);
11
12
 
12
13
  this.datePicker = datePicker;
13
- this.fullscreenFocus = false;
14
14
  this.blurWhileOpened = false;
15
15
 
16
16
  this.addListeners(datePicker);
@@ -19,14 +19,6 @@ export class DatePickerObserver extends ComponentObserver {
19
19
  addListeners(datePicker) {
20
20
  this.overlay = datePicker.$.overlay;
21
21
 
22
- // Fullscreen date picker calls blur() to avoid focusing of the input:
23
- // 1. first time when focus event is fired (before opening the overlay),
24
- // 2. second time after the overlay is open, see "_onOverlayOpened".
25
- // Here we set the flag to ignore related focusout events and then to
26
- // mark date picker as being edited by user (to show field highlight).
27
- // We have to use capture phase in order to catch this event early.
28
- datePicker.addEventListener('blur', (event) => this.onBlur(event), true);
29
-
30
22
  datePicker.addEventListener('opened-changed', (event) => this.onOpenedChanged(event));
31
23
 
32
24
  this.overlay.addEventListener('focusout', (event) => this.onOverlayFocusOut(event));
@@ -40,14 +32,17 @@ export class DatePickerObserver extends ComponentObserver {
40
32
  return this.datePicker._overlayContent && this.datePicker._overlayContent.contains(node);
41
33
  }
42
34
 
43
- onBlur(event) {
35
+ isFullscreen() {
44
36
  const datePicker = this.datePicker;
45
- if (datePicker._fullscreen && !this.isEventInOverlay(event.relatedTarget)) {
46
- this.fullscreenFocus = true;
47
- }
37
+ return datePicker._noInput && !isKeyboardActive();
48
38
  }
49
39
 
50
40
  onFocusIn(event) {
41
+ if (this.isEventInOverlay(event.target)) {
42
+ // Focus moves to the overlay, do nothing.
43
+ return;
44
+ }
45
+
51
46
  if (this.isEventInOverlay(event.relatedTarget)) {
52
47
  // Focus returns from the overlay, do nothing.
53
48
  return;
@@ -63,9 +58,17 @@ export class DatePickerObserver extends ComponentObserver {
63
58
  }
64
59
 
65
60
  onFocusOut(event) {
66
- if (this.fullscreenFocus || this.isEventInOverlay(event.relatedTarget)) {
67
- // Do nothing, overlay is opening.
68
- } else if (!this.datePicker.opened) {
61
+ if (this.isEventInOverlay(event.target) && this.component.contains(event.relatedTarget)) {
62
+ // Focus returns from the overlay, do nothing.
63
+ return;
64
+ }
65
+
66
+ if (this.isEventInOverlay(event.relatedTarget)) {
67
+ // Focus moves to the overlay, do nothing.
68
+ return;
69
+ }
70
+
71
+ if (!this.datePicker.opened) {
69
72
  // Field blur when closed.
70
73
  this.hideOutline(this.datePicker);
71
74
  } else {
@@ -83,8 +86,7 @@ export class DatePickerObserver extends ComponentObserver {
83
86
  }
84
87
 
85
88
  onOpenedChanged(event) {
86
- if (event.detail.value === true && this.fullscreenFocus) {
87
- this.fullscreenFocus = false;
89
+ if (event.detail.value === true && this.isFullscreen()) {
88
90
  this.showOutline(this.datePicker);
89
91
  }
90
92
 
@@ -13,7 +13,12 @@ export class SelectObserver extends FieldObserver {
13
13
  }
14
14
 
15
15
  onFocusIn(event) {
16
- if (this.overlay.contains(event.relatedTarget)) {
16
+ if (this.overlay._contentRoot.contains(event.target)) {
17
+ // Focus moves to the overlay item, do nothing.
18
+ return;
19
+ }
20
+
21
+ if (this.overlay._contentRoot.contains(event.relatedTarget)) {
17
22
  // Focus returns on item select, do nothing.
18
23
  return;
19
24
  }
@@ -22,10 +27,16 @@ export class SelectObserver extends FieldObserver {
22
27
  }
23
28
 
24
29
  onFocusOut(event) {
25
- if (this.overlay.contains(event.relatedTarget)) {
26
- // Do nothing, overlay is opening.
30
+ if (this.overlay._contentRoot.contains(event.relatedTarget)) {
31
+ // Focus moves to the overlay on opening, do nothing.
27
32
  return;
28
33
  }
34
+
35
+ if (this.overlay._contentRoot.contains(event.target) && this.component.contains(event.relatedTarget)) {
36
+ // Focus returns from the overlay on closing, do nothing.
37
+ return;
38
+ }
39
+
29
40
  super.onFocusOut(event);
30
41
  }
31
42
  }
@@ -15,7 +15,7 @@ const userTagsOverlay = css`
15
15
  overflow: visible;
16
16
  }
17
17
 
18
- ::slotted([part='tags']) {
18
+ [part='content'] {
19
19
  display: flex;
20
20
  flex-direction: column;
21
21
  align-items: flex-start;
@@ -19,7 +19,7 @@ import { fieldOutlineStyles } from './styles/vaadin-field-outline-core-styles.js
19
19
  * @mixes ThemableMixin
20
20
  * @private
21
21
  */
22
- export class FieldOutline extends ThemableMixin(DirMixin(LumoInjectionMixin(PolylitMixin(LitElement)))) {
22
+ export class FieldOutline extends ThemableMixin(DirMixin(PolylitMixin(LumoInjectionMixin(LitElement)))) {
23
23
  static get is() {
24
24
  return 'vaadin-field-outline';
25
25
  }
@@ -20,7 +20,7 @@ import { userTagStyles } from './styles/vaadin-user-tag-core-styles.js';
20
20
  * @mixes ThemableMixin
21
21
  * @private
22
22
  */
23
- export class UserTag extends ThemableMixin(DirMixin(LumoInjectionMixin(PolylitMixin(LitElement)))) {
23
+ export class UserTag extends ThemableMixin(DirMixin(PolylitMixin(LumoInjectionMixin(LitElement)))) {
24
24
  static get is() {
25
25
  return 'vaadin-user-tag';
26
26
  }
@@ -25,7 +25,7 @@ import { userTagsOverlayStyles } from './styles/vaadin-user-tags-overlay-core-st
25
25
  * @private
26
26
  */
27
27
  class UserTagsOverlay extends PositionMixin(
28
- OverlayMixin(DirMixin(ThemableMixin(LumoInjectionMixin(PolylitMixin(LitElement))))),
28
+ OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))),
29
29
  ) {
30
30
  static get is() {
31
31
  return 'vaadin-user-tags-overlay';
@@ -38,7 +38,6 @@ class UserTagsOverlay extends PositionMixin(
38
38
  /** @protected */
39
39
  render() {
40
40
  return html`
41
- <div id="backdrop" part="backdrop" ?hidden="${!this.withBackdrop}"></div>
42
41
  <div part="overlay" id="overlay">
43
42
  <div part="content" id="content">
44
43
  <slot></slot>
@@ -46,11 +46,14 @@ export class UserTags extends PolylitMixin(LitElement) {
46
46
  return html`
47
47
  <vaadin-user-tags-overlay
48
48
  id="overlay"
49
+ exportparts="overlay:user-tags-overlay, content:user-tags-content"
49
50
  modeless
50
51
  .opened="${this.opened}"
51
52
  no-vertical-overlap
52
53
  @vaadin-overlay-open="${this._onOverlayOpen}"
53
- ></vaadin-user-tags-overlay>
54
+ >
55
+ <slot></slot>
56
+ </vaadin-user-tags-overlay>
54
57
  `;
55
58
  }
56
59
 
@@ -137,7 +140,8 @@ export class UserTags extends PolylitMixin(LitElement) {
137
140
 
138
141
  /** @protected */
139
142
  get wrapper() {
140
- return this.$.overlay.querySelector('[part="tags"]');
143
+ // Used by Collaboration Kit util
144
+ return this;
141
145
  }
142
146
 
143
147
  /** @protected */
@@ -162,15 +166,8 @@ export class UserTags extends PolylitMixin(LitElement) {
162
166
  ready() {
163
167
  super.ready();
164
168
 
165
- this.$.overlay.renderer = (root) => {
166
- if (!root.firstChild) {
167
- const tags = document.createElement('div');
168
- tags.setAttribute('part', 'tags');
169
- root.appendChild(tags);
170
- }
171
- };
172
-
173
- this.$.overlay.requestContentUpdate();
169
+ // Export user tags overlay parts for styling
170
+ this.setAttribute('exportparts', 'user-tags-overlay, user-tags-content');
174
171
  }
175
172
 
176
173
  /** @private */
@@ -222,6 +219,7 @@ export class UserTags extends PolylitMixin(LitElement) {
222
219
 
223
220
  createUserTag(user) {
224
221
  const tag = document.createElement('vaadin-user-tag');
222
+ tag.setAttribute('part', 'user-tag');
225
223
  tag.name = user.name;
226
224
  tag.uid = user.id;
227
225
  tag.colorIndex = user.colorIndex;
@@ -229,7 +227,7 @@ export class UserTags extends PolylitMixin(LitElement) {
229
227
  }
230
228
 
231
229
  getTagForUser(user) {
232
- return Array.from(this.wrapper.children).find((tag) => tag.uid === user.id);
230
+ return Array.from(this.children).find((tag) => tag.uid === user.id);
233
231
  }
234
232
 
235
233
  getChangedTags(addedUsers, removedUsers) {
@@ -239,21 +237,19 @@ export class UserTags extends PolylitMixin(LitElement) {
239
237
  }
240
238
 
241
239
  applyTagsStart({ added, removed }) {
242
- const wrapper = this.wrapper;
243
240
  removed.forEach((tag) => {
244
241
  if (tag) {
245
242
  tag.classList.add('removing');
246
243
  tag.classList.remove('show');
247
244
  }
248
245
  });
249
- added.forEach((tag) => wrapper.insertBefore(tag, wrapper.firstChild));
246
+ added.forEach((tag) => this.insertBefore(tag, this.firstChild));
250
247
  }
251
248
 
252
249
  applyTagsEnd({ added, removed }) {
253
- const wrapper = this.wrapper;
254
250
  removed.forEach((tag) => {
255
- if (tag && tag.parentNode === wrapper) {
256
- wrapper.removeChild(tag);
251
+ if (tag && tag.parentNode === this) {
252
+ this.removeChild(tag);
257
253
  }
258
254
  });
259
255
  added.forEach((tag) => tag && tag.classList.add('show'));
@@ -329,7 +325,7 @@ export class UserTags extends PolylitMixin(LitElement) {
329
325
  /** @private */
330
326
  _onOverlayOpen() {
331
327
  // Animate all tags except removing ones
332
- Array.from(this.wrapper.children).forEach((tag) => {
328
+ Array.from(this.children).forEach((tag) => {
333
329
  if (!tag.classList.contains('removing')) {
334
330
  tag.classList.add('show');
335
331
  }
@@ -338,17 +334,16 @@ export class UserTags extends PolylitMixin(LitElement) {
338
334
 
339
335
  flashTags(added) {
340
336
  this.flashing = true;
341
- const wrapper = this.wrapper;
342
337
 
343
338
  // Hide existing tags
344
- const hidden = Array.from(wrapper.children);
339
+ const hidden = Array.from(this.children);
345
340
  hidden.forEach((tag) => {
346
341
  tag.style.display = 'none';
347
342
  });
348
343
 
349
344
  // Render new tags
350
345
  added.forEach((tag) => {
351
- wrapper.insertBefore(tag, wrapper.firstChild);
346
+ this.insertBefore(tag, this.firstChild);
352
347
  });
353
348
 
354
349
  this.flashPromise = new Promise((resolve) => {