@vaadin/field-highlighter 24.7.0-alpha6 → 24.7.0-alpha8

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": "24.7.0-alpha6",
3
+ "version": "24.7.0-alpha8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,30 +34,31 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@polymer/polymer": "^3.0.0",
37
- "@vaadin/a11y-base": "24.7.0-alpha6",
38
- "@vaadin/component-base": "24.7.0-alpha6",
39
- "@vaadin/overlay": "24.7.0-alpha6",
40
- "@vaadin/vaadin-lumo-styles": "24.7.0-alpha6",
41
- "@vaadin/vaadin-material-styles": "24.7.0-alpha6",
42
- "@vaadin/vaadin-themable-mixin": "24.7.0-alpha6",
37
+ "@vaadin/a11y-base": "24.7.0-alpha8",
38
+ "@vaadin/component-base": "24.7.0-alpha8",
39
+ "@vaadin/overlay": "24.7.0-alpha8",
40
+ "@vaadin/vaadin-lumo-styles": "24.7.0-alpha8",
41
+ "@vaadin/vaadin-material-styles": "24.7.0-alpha8",
42
+ "@vaadin/vaadin-themable-mixin": "24.7.0-alpha8",
43
43
  "lit": "^3.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@vaadin/chai-plugins": "24.7.0-alpha6",
47
- "@vaadin/checkbox": "24.7.0-alpha6",
48
- "@vaadin/checkbox-group": "24.7.0-alpha6",
49
- "@vaadin/combo-box": "24.7.0-alpha6",
50
- "@vaadin/date-picker": "24.7.0-alpha6",
51
- "@vaadin/date-time-picker": "24.7.0-alpha6",
52
- "@vaadin/item": "24.7.0-alpha6",
53
- "@vaadin/list-box": "24.7.0-alpha6",
54
- "@vaadin/radio-group": "24.7.0-alpha6",
55
- "@vaadin/select": "24.7.0-alpha6",
46
+ "@vaadin/chai-plugins": "24.7.0-alpha8",
47
+ "@vaadin/checkbox": "24.7.0-alpha8",
48
+ "@vaadin/checkbox-group": "24.7.0-alpha8",
49
+ "@vaadin/combo-box": "24.7.0-alpha8",
50
+ "@vaadin/date-picker": "24.7.0-alpha8",
51
+ "@vaadin/date-time-picker": "24.7.0-alpha8",
52
+ "@vaadin/item": "24.7.0-alpha8",
53
+ "@vaadin/list-box": "24.7.0-alpha8",
54
+ "@vaadin/radio-group": "24.7.0-alpha8",
55
+ "@vaadin/select": "24.7.0-alpha8",
56
+ "@vaadin/test-runner-commands": "24.7.0-alpha8",
56
57
  "@vaadin/testing-helpers": "^1.1.0",
57
- "@vaadin/text-area": "24.7.0-alpha6",
58
- "@vaadin/text-field": "24.7.0-alpha6",
59
- "@vaadin/time-picker": "24.7.0-alpha6",
58
+ "@vaadin/text-area": "24.7.0-alpha8",
59
+ "@vaadin/text-field": "24.7.0-alpha8",
60
+ "@vaadin/time-picker": "24.7.0-alpha8",
60
61
  "sinon": "^18.0.0"
61
62
  },
62
- "gitHead": "6255a512997a648da91fed37de4d5000809eaebf"
63
+ "gitHead": "d015035192480fcc8cc9df5d00a950f177b83c32"
63
64
  }
@@ -65,7 +65,7 @@ export const userTagsOverlayStyles = css`
65
65
  box-shadow: none;
66
66
  }
67
67
 
68
- [part='overlay'] {
68
+ :scope [part='overlay'] {
69
69
  box-shadow: none;
70
70
  background: transparent;
71
71
  position: relative;
@@ -86,7 +86,7 @@ export const userTagsOverlayStyles = css`
86
86
  right: -4px;
87
87
  }
88
88
 
89
- [part='content'] {
89
+ :scope [part='content'] {
90
90
  padding: 0;
91
91
  }
92
92
 
@@ -3,9 +3,10 @@
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 { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
6
+ import { html, LitElement } from 'lit';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
9
10
  import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
11
  import { fieldOutlineStyles } from './vaadin-field-highlighter-styles.js';
11
12
 
@@ -19,15 +20,11 @@ registerStyles('vaadin-field-outline', fieldOutlineStyles, { moduleId: 'vaadin-f
19
20
  * @mixes ThemableMixin
20
21
  * @private
21
22
  */
22
- export class FieldOutline extends ThemableMixin(DirMixin(PolymerElement)) {
23
+ export class FieldOutline extends ThemableMixin(DirMixin(PolylitMixin(LitElement))) {
23
24
  static get is() {
24
25
  return 'vaadin-field-outline';
25
26
  }
26
27
 
27
- static get template() {
28
- return html``;
29
- }
30
-
31
28
  static get properties() {
32
29
  return {
33
30
  /**
@@ -37,10 +34,16 @@ export class FieldOutline extends ThemableMixin(DirMixin(PolymerElement)) {
37
34
  type: Object,
38
35
  value: null,
39
36
  observer: '_userChanged',
37
+ sync: true,
40
38
  },
41
39
  };
42
40
  }
43
41
 
42
+ /** @protected */
43
+ render() {
44
+ return html``;
45
+ }
46
+
44
47
  /** @protected */
45
48
  ready() {
46
49
  super.ready();
@@ -3,14 +3,13 @@
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 { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
6
+ import { html, LitElement } from 'lit';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
- import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
11
  import { userTagStyles } from './vaadin-field-highlighter-styles.js';
11
12
 
12
- registerStyles('vaadin-user-tag', userTagStyles, { moduleId: 'vaadin-user-tag-styles' });
13
-
14
13
  /**
15
14
  * An element used internally by `<vaadin-field-highlighter>`. Not intended to be used separately.
16
15
  *
@@ -20,13 +19,18 @@ registerStyles('vaadin-user-tag', userTagStyles, { moduleId: 'vaadin-user-tag-st
20
19
  * @mixes ThemableMixin
21
20
  * @private
22
21
  */
23
- export class UserTag extends ThemableMixin(DirMixin(PolymerElement)) {
22
+ export class UserTag extends ThemableMixin(DirMixin(PolylitMixin(LitElement))) {
24
23
  static get is() {
25
24
  return 'vaadin-user-tag';
26
25
  }
27
26
 
28
- static get template() {
29
- return html`<div part="name">[[name]]</div>`;
27
+ static get styles() {
28
+ return userTagStyles;
29
+ }
30
+
31
+ /** @protected */
32
+ render() {
33
+ return html`<div part="name">${this.name}</div>`;
30
34
  }
31
35
 
32
36
  static get properties() {
@@ -3,17 +3,16 @@
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 { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
6
+ import { html, LitElement } from 'lit';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
9
10
  import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
10
11
  import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
11
12
  import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
12
- import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
14
  import { userTagsOverlayStyles } from './vaadin-field-highlighter-styles.js';
14
15
 
15
- registerStyles('vaadin-user-tags-overlay', [overlayStyles, userTagsOverlayStyles]);
16
-
17
16
  /**
18
17
  * An element used internally by `<vaadin-field-highlighter>`. Not intended to be used separately.
19
18
  *
@@ -25,14 +24,19 @@ registerStyles('vaadin-user-tags-overlay', [overlayStyles, userTagsOverlayStyles
25
24
  * @mixes ThemableMixin
26
25
  * @private
27
26
  */
28
- class UserTagsOverlay extends PositionMixin(OverlayMixin(DirMixin(ThemableMixin(PolymerElement)))) {
27
+ class UserTagsOverlay extends PositionMixin(OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement))))) {
29
28
  static get is() {
30
29
  return 'vaadin-user-tags-overlay';
31
30
  }
32
31
 
33
- static get template() {
32
+ static get styles() {
33
+ return [overlayStyles, userTagsOverlayStyles];
34
+ }
35
+
36
+ /** @protected */
37
+ render() {
34
38
  return html`
35
- <div id="backdrop" part="backdrop" hidden$="[[!withBackdrop]]"></div>
39
+ <div id="backdrop" part="backdrop" ?hidden="${!this.withBackdrop}"></div>
36
40
  <div part="overlay" id="overlay">
37
41
  <div part="content" id="content">
38
42
  <slot></slot>
@@ -5,11 +5,11 @@
5
5
  */
6
6
  import './vaadin-user-tag.js';
7
7
  import './vaadin-user-tags-overlay.js';
8
- import { calculateSplices } from '@polymer/polymer/lib/utils/array-splice.js';
9
- import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
8
+ import { css, html, LitElement } from 'lit';
10
9
  import { timeOut } from '@vaadin/component-base/src/async.js';
11
10
  import { Debouncer } from '@vaadin/component-base/src/debounce.js';
12
11
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
12
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
13
13
 
14
14
  const listenOnce = (elem, type) => {
15
15
  return new Promise((resolve) => {
@@ -28,24 +28,28 @@ const listenOnce = (elem, type) => {
28
28
  * @extends HTMLElement
29
29
  * @private
30
30
  */
31
- export class UserTags extends PolymerElement {
31
+ export class UserTags extends PolylitMixin(LitElement) {
32
32
  static get is() {
33
33
  return 'vaadin-user-tags';
34
34
  }
35
35
 
36
- static get template() {
36
+ static get styles() {
37
+ return css`
38
+ :host {
39
+ position: absolute;
40
+ }
41
+ `;
42
+ }
43
+
44
+ /** @protected */
45
+ render() {
37
46
  return html`
38
- <style>
39
- :host {
40
- position: absolute;
41
- }
42
- </style>
43
47
  <vaadin-user-tags-overlay
44
48
  id="overlay"
45
49
  modeless
46
- opened="[[opened]]"
50
+ .opened="${this.opened}"
47
51
  no-vertical-overlap
48
- on-vaadin-overlay-open="_onOverlayOpen"
52
+ @vaadin-overlay-open="${this._onOverlayOpen}"
49
53
  ></vaadin-user-tags-overlay>
50
54
  `;
51
55
  }
@@ -68,6 +72,7 @@ export class UserTags extends PolymerElement {
68
72
  opened: {
69
73
  type: Boolean,
70
74
  value: false,
75
+ sync: true,
71
76
  },
72
77
 
73
78
  /**
@@ -233,27 +238,6 @@ export class UserTags extends PolymerElement {
233
238
  return { added, removed };
234
239
  }
235
240
 
236
- getChangedUsers(users, splices) {
237
- const usersToAdd = [];
238
- const usersToRemove = [];
239
-
240
- splices.forEach((splice) => {
241
- splice.removed.forEach((user) => {
242
- usersToRemove.push(user);
243
- });
244
-
245
- for (let i = splice.addedCount - 1; i >= 0; i--) {
246
- usersToAdd.push(users[splice.index + i]);
247
- }
248
- });
249
-
250
- // Filter out users that are only moved
251
- const addedUsers = usersToAdd.filter((u) => !usersToRemove.some((u2) => u.id === u2.id));
252
- const removedUsers = usersToRemove.filter((u) => !usersToAdd.some((u2) => u.id === u2.id));
253
-
254
- return { addedUsers, removedUsers };
255
- }
256
-
257
241
  applyTagsStart({ added, removed }) {
258
242
  const wrapper = this.wrapper;
259
243
  removed.forEach((tag) => {
@@ -279,12 +263,22 @@ export class UserTags extends PolymerElement {
279
263
  // Apply pending change if needed
280
264
  this.requestContentUpdate();
281
265
 
282
- const splices = calculateSplices(users, this.users);
283
- if (splices.length === 0) {
284
- return;
266
+ let addedUsers = [];
267
+ let removedUsers = [];
268
+
269
+ const hasNewUsers = Array.isArray(users);
270
+ const hasOldUsers = Array.isArray(this.users);
271
+
272
+ if (hasOldUsers) {
273
+ const newUserIds = (users || []).map((user) => user.id);
274
+ removedUsers = this.users.filter((item) => !newUserIds.includes(item.id));
275
+ }
276
+
277
+ if (hasNewUsers) {
278
+ const oldUserIds = (this.users || []).map((user) => user.id);
279
+ addedUsers = users.filter((item) => !oldUserIds.includes(item.id)).reverse();
285
280
  }
286
281
 
287
- const { addedUsers, removedUsers } = this.getChangedUsers(users, splices);
288
282
  if (addedUsers.length === 0 && removedUsers.length === 0) {
289
283
  return;
290
284
  }
@@ -300,7 +294,7 @@ export class UserTags extends PolymerElement {
300
294
 
301
295
  this.__flashQueue.forEach((tags) => {
302
296
  if (tags.some((tag) => tag.uid === user.id)) {
303
- this.splice('__flashQueue', i, 1);
297
+ this.__flashQueue = this.__flashQueue.filter((_, index) => index !== i);
304
298
  }
305
299
  });
306
300
  });
@@ -323,7 +317,7 @@ export class UserTags extends PolymerElement {
323
317
 
324
318
  if (this.flashing || !this.__isTargetVisible) {
325
319
  // Schedule next flash later
326
- this.push('__flashQueue', addedTags);
320
+ this.__flashQueue = [...this.__flashQueue, addedTags];
327
321
  } else {
328
322
  this.flashTags(addedTags);
329
323
  }
@@ -394,7 +388,7 @@ export class UserTags extends PolymerElement {
394
388
  }).then(() => {
395
389
  if (this.__flashQueue.length > 0) {
396
390
  const tags = this.__flashQueue[0];
397
- this.splice('__flashQueue', 0, 1);
391
+ this.__flashQueue = [...this.__flashQueue].slice(1);
398
392
  this.flashTags(tags);
399
393
  }
400
394
  });
@@ -416,7 +410,7 @@ export class UserTags extends PolymerElement {
416
410
  this.applyTagsStart(changed);
417
411
 
418
412
  this._debounceRender = Debouncer.debounce(this._debounceRender, timeOut.after(this.duration), () => {
419
- this.set('users', users);
413
+ this.users = users;
420
414
 
421
415
  this.applyTagsEnd(changed);
422
416
 
@@ -428,7 +422,7 @@ export class UserTags extends PolymerElement {
428
422
 
429
423
  updateTagsSync(users, changed) {
430
424
  this.applyTagsStart(changed);
431
- this.set('users', users);
425
+ this.users = users;
432
426
  this.applyTagsEnd(changed);
433
427
  }
434
428