@vaadin/avatar-group 24.8.4 → 25.0.0-alpha10

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.
Files changed (33) hide show
  1. package/README.md +0 -23
  2. package/package.json +17 -18
  3. package/src/styles/vaadin-avatar-group-base-styles.js +63 -0
  4. package/src/styles/vaadin-avatar-group-core-styles.d.ts +8 -0
  5. package/src/{vaadin-avatar-group-styles.js → styles/vaadin-avatar-group-core-styles.js} +6 -13
  6. package/src/styles/vaadin-avatar-group-menu-base-styles.js +21 -0
  7. package/src/styles/vaadin-avatar-group-menu-core-styles.js +8 -0
  8. package/src/styles/vaadin-avatar-group-menu-item-base-styles.js +17 -0
  9. package/src/styles/vaadin-avatar-group-menu-item-core-styles.js +8 -0
  10. package/src/vaadin-avatar-group-menu-item.js +11 -12
  11. package/src/vaadin-avatar-group-menu.d.ts +1 -2
  12. package/src/vaadin-avatar-group-menu.js +16 -26
  13. package/src/vaadin-avatar-group-mixin.js +106 -145
  14. package/src/vaadin-avatar-group-overlay.js +14 -10
  15. package/src/vaadin-avatar-group.d.ts +5 -4
  16. package/src/vaadin-avatar-group.js +33 -18
  17. package/web-types.json +3 -3
  18. package/web-types.lit.json +3 -3
  19. package/src/vaadin-lit-avatar-group-menu-item.js +0 -60
  20. package/src/vaadin-lit-avatar-group-menu.js +0 -87
  21. package/src/vaadin-lit-avatar-group-overlay.js +0 -48
  22. package/src/vaadin-lit-avatar-group.js +0 -65
  23. package/theme/lumo/vaadin-lit-avatar-group.d.ts +0 -3
  24. package/theme/lumo/vaadin-lit-avatar-group.js +0 -3
  25. package/theme/material/vaadin-avatar-group-styles.d.ts +0 -1
  26. package/theme/material/vaadin-avatar-group-styles.js +0 -78
  27. package/theme/material/vaadin-avatar-group.d.ts +0 -3
  28. package/theme/material/vaadin-avatar-group.js +0 -3
  29. package/theme/material/vaadin-lit-avatar-group.d.ts +0 -3
  30. package/theme/material/vaadin-lit-avatar-group.js +0 -3
  31. package/vaadin-lit-avatar-group.d.ts +0 -1
  32. package/vaadin-lit-avatar-group.js +0 -2
  33. /package/src/{vaadin-avatar-group-styles.d.ts → styles/vaadin-avatar-group-base-styles.d.ts} +0 -0
@@ -64,7 +64,6 @@ export const AvatarGroupMixin = (superClass) =>
64
64
  */
65
65
  items: {
66
66
  type: Array,
67
- observer: '__itemsChanged',
68
67
  sync: true,
69
68
  },
70
69
 
@@ -79,13 +78,6 @@ export const AvatarGroupMixin = (superClass) =>
79
78
  sync: true,
80
79
  },
81
80
 
82
- /** @private */
83
- _avatars: {
84
- type: Array,
85
- value: () => [],
86
- sync: true,
87
- },
88
-
89
81
  /** @private */
90
82
  __itemsInView: {
91
83
  type: Number,
@@ -93,23 +85,14 @@ export const AvatarGroupMixin = (superClass) =>
93
85
  sync: true,
94
86
  },
95
87
 
96
- /** @private */
97
- _overflow: {
98
- type: Object,
99
- sync: true,
100
- },
101
-
102
88
  /** @private */
103
89
  _overflowItems: {
104
90
  type: Array,
105
- observer: '__overflowItemsChanged',
106
- computed: '__computeOverflowItems(items, __itemsInView, maxItemsVisible)',
107
91
  },
108
92
 
109
93
  /** @private */
110
- _overflowTooltip: {
111
- type: Object,
112
- sync: true,
94
+ _overflowLimit: {
95
+ type: Number,
113
96
  },
114
97
 
115
98
  /** @private */
@@ -120,17 +103,6 @@ export const AvatarGroupMixin = (superClass) =>
120
103
  };
121
104
  }
122
105
 
123
- static get observers() {
124
- return [
125
- '__i18nItemsChanged(__effectiveI18n, items)',
126
- '__openedChanged(_opened, _overflow)',
127
- '__updateAvatarsTheme(_overflow, _avatars, _theme)',
128
- '__updateAvatars(items, __itemsInView, maxItemsVisible, _overflow, __effectiveI18n)',
129
- '__updateOverflowAvatar(_overflow, items, __itemsInView, maxItemsVisible)',
130
- '__updateOverflowTooltip(_overflowTooltip, items, __itemsInView, maxItemsVisible)',
131
- ];
132
- }
133
-
134
106
  /**
135
107
  * The object used to localize this component. To change the default
136
108
  * localization, replace this with an object that provides all properties, or
@@ -167,10 +139,22 @@ export const AvatarGroupMixin = (superClass) =>
167
139
  super.i18n = value;
168
140
  }
169
141
 
142
+ /** @protected */
143
+ get _avatars() {
144
+ return [...this.children].filter((node) => node.localName === 'vaadin-avatar');
145
+ }
146
+
170
147
  /** @protected */
171
148
  ready() {
172
149
  super.ready();
173
150
 
151
+ this._menuController = new SlotController(this, 'overlay', 'vaadin-avatar-group-menu', {
152
+ initializer: (menu) => {
153
+ menu.addEventListener('keydown', this._onListKeyDown.bind(this));
154
+ this._menuElement = menu;
155
+ },
156
+ });
157
+
174
158
  this._overflowController = new SlotController(this, 'overflow', 'vaadin-avatar', {
175
159
  initializer: (overflow) => {
176
160
  overflow.setAttribute('role', 'button');
@@ -187,11 +171,11 @@ export const AvatarGroupMixin = (superClass) =>
187
171
  this._overflowTooltip = tooltip;
188
172
  },
189
173
  });
174
+
175
+ this.addController(this._menuController);
190
176
  this.addController(this._overflowController);
191
177
 
192
- const overlay = this.$.overlay;
193
- overlay.renderer = this.__overlayRenderer.bind(this);
194
- this._overlayElement = overlay;
178
+ this._overlayElement = this.$.overlay;
195
179
  }
196
180
 
197
181
  /** @protected */
@@ -201,65 +185,92 @@ export const AvatarGroupMixin = (superClass) =>
201
185
  this._opened = false;
202
186
  }
203
187
 
204
- /** @private */
205
- __getMessage(user, action) {
206
- return action.replace('{user}', user.name || user.abbr || this.__effectiveI18n.anonymous);
207
- }
208
-
209
- /**
210
- * Renders items when they are provided by the `items` property and clears the content otherwise.
211
- * @param {!HTMLElement} root
212
- * @param {!Select} _select
213
- * @private
214
- */
215
- __overlayRenderer(root) {
216
- let menu = root.firstElementChild;
217
- if (!menu) {
218
- menu = document.createElement('vaadin-avatar-group-menu');
219
- menu.addEventListener('keydown', (event) => this._onListKeyDown(event));
220
- root.appendChild(menu);
188
+ /** @protected */
189
+ willUpdate(props) {
190
+ super.willUpdate(props);
191
+
192
+ if (props.has('items') || props.has('__itemsInView') || props.has('maxItemsVisible')) {
193
+ // Calculate overflow limit only once to reuse it in updated() observers
194
+ const count = Array.isArray(this.items) ? this.items.length : 0;
195
+ const limit = this.__getLimit(count, this.__itemsInView, this.maxItemsVisible);
196
+ this._overflowLimit = limit;
197
+ this._overflowItems = limit ? this.items.slice(limit) : [];
221
198
  }
199
+ }
222
200
 
223
- menu.textContent = '';
201
+ /** @protected */
202
+ updated(props) {
203
+ super.updated(props);
224
204
 
225
- if (!this._overflowItems) {
226
- return;
205
+ if (props.has('items')) {
206
+ this.__itemsChanged(this.items, props.get('items'));
227
207
  }
228
208
 
229
- this._overflowItems.forEach((item) => {
230
- menu.appendChild(this.__createItemElement(item));
231
- });
232
- }
233
-
234
- /** @private */
235
- __createItemElement(item) {
236
- const itemElement = document.createElement('vaadin-avatar-group-menu-item');
209
+ if (props.has('items') || props.has('_overflowLimit') || props.has('__effectiveI18n') || props.has('_theme')) {
210
+ const limit = this._overflowLimit;
211
+ this.__renderAvatars(limit ? this.items.slice(0, limit) : this.items || []);
212
+ }
237
213
 
238
- const avatar = document.createElement('vaadin-avatar');
239
- itemElement.appendChild(avatar);
214
+ if (props.has('items') || props.has('_overflowLimit')) {
215
+ this.__updateOverflowTooltip(this.items, this._overflowLimit);
216
+ this.__updateOverflowAvatar(this.items, this._overflowLimit, this.__itemsInView);
217
+ }
240
218
 
241
- avatar.setAttribute('aria-hidden', 'true');
242
- avatar.setAttribute('tabindex', '-1');
243
- avatar.i18n = this.__effectiveI18n;
219
+ if (props.has('__effectiveI18n') || props.has('items')) {
220
+ this.__i18nItemsChanged(this.__effectiveI18n, this.items);
221
+ }
244
222
 
245
- if (this._theme) {
246
- avatar.setAttribute('theme', this._theme);
223
+ if (props.has('_opened')) {
224
+ this.__openedChanged(this._opened, props.get('_opened'));
247
225
  }
248
226
 
249
- avatar.name = item.name;
250
- avatar.abbr = item.abbr;
251
- avatar.img = item.img;
252
- avatar.colorIndex = item.colorIndex;
253
- if (item.className) {
254
- avatar.className = item.className;
227
+ if (props.has('_theme')) {
228
+ if (this._theme) {
229
+ this._overflow.setAttribute('theme', this._theme);
230
+ } else {
231
+ this._overflow.removeAttribute('theme');
232
+ }
255
233
  }
256
234
 
257
- if (item.name) {
258
- const text = document.createTextNode(item.name);
259
- itemElement.appendChild(text);
235
+ if (props.has('_overflowItems') || props.has('__effectiveI18n') || props.has('_theme')) {
236
+ this.__renderMenu();
260
237
  }
238
+ }
261
239
 
262
- return itemElement;
240
+ /** @private */
241
+ __getMessage(user, action) {
242
+ return action.replace('{user}', user.name || user.abbr || this.__effectiveI18n.anonymous);
243
+ }
244
+
245
+ /**
246
+ * Renders items when they are provided by the `items` property and clears the content otherwise.
247
+ * @private
248
+ */
249
+ __renderMenu() {
250
+ render(
251
+ html`
252
+ ${(this._overflowItems || []).map(
253
+ (item) => html`
254
+ <vaadin-avatar-group-menu-item>
255
+ <vaadin-avatar
256
+ .name="${item.name}"
257
+ .abbr="${item.abbr}"
258
+ .img="${item.img}"
259
+ .colorIndex="${item.colorIndex}"
260
+ .i18n="${this.__effectiveI18n}"
261
+ class="${ifDefined(item.className)}"
262
+ theme="${ifDefined(this._theme)}"
263
+ aria-hidden="true"
264
+ tabindex="-1"
265
+ ></vaadin-avatar>
266
+ ${item.name || ''}
267
+ </vaadin-avatar-group-menu-item>
268
+ `,
269
+ )}
270
+ `,
271
+ this._menuElement,
272
+ { host: this },
273
+ );
263
274
  }
264
275
 
265
276
  /** @private */
@@ -323,6 +334,7 @@ export const AvatarGroupMixin = (superClass) =>
323
334
  .img="${item.img}"
324
335
  .colorIndex="${item.colorIndex}"
325
336
  .i18n="${this.__effectiveI18n}"
337
+ theme="${ifDefined(this._theme)}"
326
338
  class="${ifDefined(item.className)}"
327
339
  with-tooltip
328
340
  ></vaadin-avatar>
@@ -335,56 +347,25 @@ export const AvatarGroupMixin = (superClass) =>
335
347
  }
336
348
 
337
349
  /** @private */
338
- __updateAvatars(items, itemsInView, maxItemsVisible, overflow) {
339
- if (!overflow || !Array.isArray(items)) {
340
- return;
341
- }
342
-
343
- const limit = this.__getLimit(items.length, itemsInView, maxItemsVisible);
344
-
345
- this.__renderAvatars(limit ? items.slice(0, limit) : items);
346
-
347
- this._avatars = [...this.querySelectorAll('vaadin-avatar')];
348
- }
349
-
350
- /** @private */
351
- __computeOverflowItems(items, itemsInView, maxItemsVisible) {
352
- const count = Array.isArray(items) ? items.length : 0;
353
- const limit = this.__getLimit(count, itemsInView, maxItemsVisible);
354
- return limit ? items.slice(limit) : [];
355
- }
356
-
357
- /** @private */
358
- __updateOverflowAvatar(overflow, items, itemsInView, maxItemsVisible) {
350
+ __updateOverflowAvatar(items, limit, itemsInView) {
351
+ const overflow = this._overflow;
359
352
  if (overflow) {
360
353
  const count = Array.isArray(items) ? items.length : 0;
361
- const maxReached = maxItemsVisible != null && count > this.__getMax(maxItemsVisible);
354
+ const maxReached = this.maxItemsVisible != null && count > this.__getMax(this.maxItemsVisible);
362
355
 
363
- overflow.abbr = `+${count - this.__getLimit(count, itemsInView, maxItemsVisible)}`;
364
- overflow.toggleAttribute('hidden', !maxReached && !(itemsInView && itemsInView < count));
365
- }
366
- }
367
-
368
- /** @private */
369
- __updateAvatarsTheme(overflow, avatars, theme) {
370
- if (overflow) {
371
- [overflow, ...avatars].forEach((avatar) => {
372
- if (theme) {
373
- avatar.setAttribute('theme', theme);
374
- } else {
375
- avatar.removeAttribute('theme');
376
- }
377
- });
356
+ overflow.abbr = `+${count - limit}`;
357
+ const hasOverflow = maxReached || (itemsInView && itemsInView < count);
358
+ overflow.toggleAttribute('hidden', !hasOverflow);
359
+ this.toggleAttribute('has-overflow', hasOverflow);
378
360
  }
379
361
  }
380
362
 
381
363
  /** @private */
382
- __updateOverflowTooltip(tooltip, items, itemsInView, maxItemsVisible) {
383
- if (!tooltip || !Array.isArray(items)) {
364
+ __updateOverflowTooltip(items, limit) {
365
+ if (!Array.isArray(items)) {
384
366
  return;
385
367
  }
386
368
 
387
- const limit = this.__getLimit(items.length, itemsInView, maxItemsVisible);
388
369
  if (limit == null) {
389
370
  return;
390
371
  }
@@ -397,7 +378,7 @@ export const AvatarGroupMixin = (superClass) =>
397
378
  }
398
379
  }
399
380
 
400
- tooltip.text = result.join('\n');
381
+ this._overflowTooltip.text = result.join('\n');
401
382
  }
402
383
 
403
384
  /** @private */
@@ -466,41 +447,21 @@ export const AvatarGroupMixin = (superClass) =>
466
447
  if (effectiveI18n.activeUsers[field]) {
467
448
  this.setAttribute('aria-label', effectiveI18n.activeUsers[field].replace('{count}', count || 0));
468
449
  }
469
-
470
- this._avatars.forEach((avatar) => {
471
- avatar.i18n = effectiveI18n;
472
- });
473
450
  }
474
451
  }
475
452
 
476
453
  /** @private */
477
- __openedChanged(opened, overflow) {
478
- if (!overflow) {
479
- return;
480
- }
481
-
454
+ __openedChanged(opened, oldOpened) {
482
455
  if (opened) {
483
- if (!this._menuElement) {
484
- this._menuElement = this.$.overlay.querySelector('vaadin-avatar-group-menu');
485
- }
486
-
487
- this._openedWithFocusRing = overflow.hasAttribute('focus-ring');
488
- } else if (this.__oldOpened) {
489
- overflow.focus();
456
+ this._openedWithFocusRing = this._overflow.hasAttribute('focus-ring');
457
+ } else if (oldOpened) {
458
+ this._overflow.focus();
490
459
  if (this._openedWithFocusRing) {
491
- overflow.setAttribute('focus-ring', '');
460
+ this._overflow.setAttribute('focus-ring', '');
492
461
  }
493
462
  }
494
463
 
495
- overflow.setAttribute('aria-expanded', opened === true);
496
- this.__oldOpened = opened;
497
- }
498
-
499
- /** @private */
500
- __overflowItemsChanged(items, oldItems) {
501
- if (items || oldItems) {
502
- this.$.overlay.requestContentUpdate();
503
- }
464
+ this._overflow.setAttribute('aria-expanded', opened === true);
504
465
  }
505
466
 
506
467
  /** @private */
@@ -3,17 +3,15 @@
3
3
  * Copyright (c) 2020 - 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';
10
+ import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-core-styles.js';
9
11
  import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
10
12
  import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
11
- import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
12
- import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
-
14
- registerStyles('vaadin-avatar-group-overlay', [overlayStyles], {
15
- moduleId: 'vaadin-avatar-group-overlay-styles',
16
- });
13
+ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
14
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
17
15
 
18
16
  /**
19
17
  * An element used internally by `<vaadin-avatar-group>`. Not intended to be used separately.
@@ -26,14 +24,20 @@ registerStyles('vaadin-avatar-group-overlay', [overlayStyles], {
26
24
  * @mixes ThemableMixin
27
25
  * @private
28
26
  */
29
- class AvatarGroupOverlay extends PositionMixin(OverlayMixin(DirMixin(ThemableMixin(PolymerElement)))) {
27
+ class AvatarGroupOverlay extends PositionMixin(
28
+ OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))),
29
+ ) {
30
30
  static get is() {
31
31
  return 'vaadin-avatar-group-overlay';
32
32
  }
33
33
 
34
- static get template() {
34
+ static get styles() {
35
+ return overlayStyles;
36
+ }
37
+
38
+ /** @protected */
39
+ render() {
35
40
  return html`
36
- <div id="backdrop" part="backdrop" hidden$="[[!withBackdrop]]"></div>
37
41
  <div part="overlay" id="overlay" tabindex="0">
38
42
  <div part="content" id="content">
39
43
  <slot></slot>
@@ -4,7 +4,6 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { AvatarI18n } from '@vaadin/avatar/src/vaadin-avatar.js';
7
- import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
8
7
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
9
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
9
  import { AvatarGroupI18n, AvatarGroupItem, AvatarGroupMixin } from './vaadin-avatar-group-mixin.js';
@@ -16,13 +15,13 @@ export { AvatarGroupI18n, AvatarGroupItem, AvatarI18n };
16
15
  *
17
16
  * To create the avatar group, first add the component to the page:
18
17
  *
19
- * ```
18
+ * ```html
20
19
  * <vaadin-avatar-group></vaadin-avatar-group>
21
20
  * ```
22
21
  *
23
22
  * And then use [`items`](#/elements/vaadin-avatar-group#property-items) property to initialize the structure:
24
23
  *
25
- * ```
24
+ * ```js
26
25
  * document.querySelector('vaadin-avatar-group').items = [
27
26
  * {name: 'John Doe'},
28
27
  * {abbr: 'AB'}
@@ -36,6 +35,8 @@ export { AvatarGroupI18n, AvatarGroupItem, AvatarI18n };
36
35
  * Part name | Description
37
36
  * ----------- | ---------------
38
37
  * `container` | The container element
38
+ * `overlay` | The overflow avatar menu overlay
39
+ * `content` | The overflow avatar menu overlay content
39
40
  *
40
41
  * See the [`<vaadin-avatar>`](#/elements/vaadin-avatar) documentation for the available
41
42
  * state attributes and stylable shadow parts of avatar elements.
@@ -51,7 +52,7 @@ export { AvatarGroupI18n, AvatarGroupItem, AvatarI18n };
51
52
  * - `<vaadin-avatar-group-menu>` - has the same API as [`<vaadin-list-box>`](#/elements/vaadin-list-box).
52
53
  * - `<vaadin-avatar-group-menu-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
53
54
  */
54
- declare class AvatarGroup extends AvatarGroupMixin(ElementMixin(ThemableMixin(ControllerMixin(HTMLElement)))) {}
55
+ declare class AvatarGroup extends AvatarGroupMixin(ElementMixin(ThemableMixin(HTMLElement))) {}
55
56
 
56
57
  declare global {
57
58
  interface HTMLElementTagNameMap {
@@ -8,28 +8,27 @@ import '@vaadin/tooltip/src/vaadin-tooltip.js';
8
8
  import './vaadin-avatar-group-menu.js';
9
9
  import './vaadin-avatar-group-menu-item.js';
10
10
  import './vaadin-avatar-group-overlay.js';
11
- import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
12
- import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
11
+ import { html, LitElement } from 'lit';
13
12
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
14
13
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
15
- import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
15
+ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
16
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
17
+ import { avatarGroupStyles } from './styles/vaadin-avatar-group-core-styles.js';
16
18
  import { AvatarGroupMixin } from './vaadin-avatar-group-mixin.js';
17
- import { avatarGroupStyles } from './vaadin-avatar-group-styles.js';
18
-
19
- registerStyles('vaadin-avatar-group', avatarGroupStyles, { moduleId: 'vaadin-avatar-group-styles' });
20
19
 
21
20
  /**
22
21
  * `<vaadin-avatar-group>` is a Web Component providing avatar group displaying functionality.
23
22
  *
24
23
  * To create the avatar group, first add the component to the page:
25
24
  *
26
- * ```
25
+ * ```html
27
26
  * <vaadin-avatar-group></vaadin-avatar-group>
28
27
  * ```
29
28
  *
30
29
  * And then use [`items`](#/elements/vaadin-avatar-group#property-items) property to initialize the structure:
31
30
  *
32
- * ```
31
+ * ```js
33
32
  * document.querySelector('vaadin-avatar-group').items = [
34
33
  * {name: 'John Doe'},
35
34
  * {abbr: 'AB'}
@@ -43,6 +42,8 @@ registerStyles('vaadin-avatar-group', avatarGroupStyles, { moduleId: 'vaadin-ava
43
42
  * Part name | Description
44
43
  * ----------- | ---------------
45
44
  * `container` | The container element
45
+ * `overlay` | The overflow avatar menu overlay
46
+ * `content` | The overflow avatar menu overlay content
46
47
  *
47
48
  * See the [`<vaadin-avatar>`](#/elements/vaadin-avatar) documentation for the available
48
49
  * state attributes and stylable shadow parts of avatar elements.
@@ -60,13 +61,21 @@ registerStyles('vaadin-avatar-group', avatarGroupStyles, { moduleId: 'vaadin-ava
60
61
  *
61
62
  * @customElement
62
63
  * @extends HTMLElement
63
- * @mixes ControllerMixin
64
64
  * @mixes ElementMixin
65
65
  * @mixes AvatarGroupMixin
66
66
  * @mixes ThemableMixin
67
67
  */
68
- class AvatarGroup extends AvatarGroupMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement)))) {
69
- static get template() {
68
+ class AvatarGroup extends AvatarGroupMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
69
+ static get is() {
70
+ return 'vaadin-avatar-group';
71
+ }
72
+
73
+ static get styles() {
74
+ return avatarGroupStyles;
75
+ }
76
+
77
+ /** @protected */
78
+ render() {
70
79
  return html`
71
80
  <div id="container" part="container">
72
81
  <slot></slot>
@@ -74,17 +83,23 @@ class AvatarGroup extends AvatarGroupMixin(ElementMixin(ThemableMixin(Controller
74
83
  </div>
75
84
  <vaadin-avatar-group-overlay
76
85
  id="overlay"
77
- opened="{{_opened}}"
78
- position-target="[[_overflow]]"
86
+ .owner="${this}"
87
+ .opened="${this._opened}"
88
+ .positionTarget="${this._overflow}"
79
89
  no-vertical-overlap
80
- on-vaadin-overlay-close="_onVaadinOverlayClose"
81
- on-vaadin-overlay-open="_onVaadinOverlayOpen"
82
- ></vaadin-avatar-group-overlay>
90
+ exportparts="overlay, content"
91
+ @vaadin-overlay-close="${this._onVaadinOverlayClose}"
92
+ @vaadin-overlay-open="${this._onVaadinOverlayOpen}"
93
+ @opened-changed="${this._onOpenedChanged}"
94
+ >
95
+ <slot name="overlay"></slot>
96
+ </vaadin-avatar-group-overlay>
83
97
  `;
84
98
  }
85
99
 
86
- static get is() {
87
- return 'vaadin-avatar-group';
100
+ /** @private */
101
+ _onOpenedChanged(event) {
102
+ this._opened = event.detail.value;
88
103
  }
89
104
  }
90
105
 
package/web-types.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/avatar-group",
4
- "version": "24.8.4",
4
+ "version": "25.0.0-alpha10",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "elements": [
9
9
  {
10
10
  "name": "vaadin-avatar-group",
11
- "description": "`<vaadin-avatar-group>` is a Web Component providing avatar group displaying functionality.\n\nTo create the avatar group, first add the component to the page:\n\n```\n<vaadin-avatar-group></vaadin-avatar-group>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-avatar-group#property-items) property to initialize the structure:\n\n```\ndocument.querySelector('vaadin-avatar-group').items = [\n {name: 'John Doe'},\n {abbr: 'AB'}\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n----------- | ---------------\n`container` | The container element\n\nSee the [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-avatar) documentation for the available\nstate attributes and stylable shadow parts of avatar elements.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-avatar-group>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-avatar-group-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-overlay).\n- `<vaadin-avatar-group-menu>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-list-box).\n- `<vaadin-avatar-group-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-item).",
11
+ "description": "`<vaadin-avatar-group>` is a Web Component providing avatar group displaying functionality.\n\nTo create the avatar group, first add the component to the page:\n\n```html\n<vaadin-avatar-group></vaadin-avatar-group>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-avatar-group#property-items) property to initialize the structure:\n\n```js\ndocument.querySelector('vaadin-avatar-group').items = [\n {name: 'John Doe'},\n {abbr: 'AB'}\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n----------- | ---------------\n`container` | The container element\n`overlay` | The overflow avatar menu overlay\n`content` | The overflow avatar menu overlay content\n\nSee the [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-avatar) documentation for the available\nstate attributes and stylable shadow parts of avatar elements.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-avatar-group>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-avatar-group-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-overlay).\n- `<vaadin-avatar-group-menu>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-list-box).\n- `<vaadin-avatar-group-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-item).",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "i18n",
@@ -77,7 +77,7 @@
77
77
  },
78
78
  {
79
79
  "name": "items",
80
- "description": "An array containing the items which will be stamped as avatars.\n\nThe items objects allow to configure [`name`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-avatar#property-name),\n[`abbr`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-avatar#property-abbr), [`img`](#/elements/vaadin-avatar#property-img)\nand [`colorIndex`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-avatar#property-colorIndex) properties on the\nstamped avatars, and set `className` to provide CSS class names.\n\n#### Example\n\n```js\ngroup.items = [\n {\n name: 'User name',\n img: 'url-to-image.png',\n className: 'even'\n },\n {\n abbr: 'JD',\n colorIndex: 1,\n className: 'odd'\n },\n];\n```",
80
+ "description": "An array containing the items which will be stamped as avatars.\n\nThe items objects allow to configure [`name`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-avatar#property-name),\n[`abbr`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-avatar#property-abbr), [`img`](#/elements/vaadin-avatar#property-img)\nand [`colorIndex`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-avatar#property-colorIndex) properties on the\nstamped avatars, and set `className` to provide CSS class names.\n\n#### Example\n\n```js\ngroup.items = [\n {\n name: 'User name',\n img: 'url-to-image.png',\n className: 'even'\n },\n {\n abbr: 'JD',\n colorIndex: 1,\n className: 'odd'\n },\n];\n```",
81
81
  "value": {
82
82
  "type": [
83
83
  "Array.<AvatarGroupItem>",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/avatar-group",
4
- "version": "24.8.4",
4
+ "version": "25.0.0-alpha10",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -16,7 +16,7 @@
16
16
  "elements": [
17
17
  {
18
18
  "name": "vaadin-avatar-group",
19
- "description": "`<vaadin-avatar-group>` is a Web Component providing avatar group displaying functionality.\n\nTo create the avatar group, first add the component to the page:\n\n```\n<vaadin-avatar-group></vaadin-avatar-group>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-avatar-group#property-items) property to initialize the structure:\n\n```\ndocument.querySelector('vaadin-avatar-group').items = [\n {name: 'John Doe'},\n {abbr: 'AB'}\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n----------- | ---------------\n`container` | The container element\n\nSee the [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-avatar) documentation for the available\nstate attributes and stylable shadow parts of avatar elements.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-avatar-group>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-avatar-group-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-overlay).\n- `<vaadin-avatar-group-menu>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-list-box).\n- `<vaadin-avatar-group-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-item).",
19
+ "description": "`<vaadin-avatar-group>` is a Web Component providing avatar group displaying functionality.\n\nTo create the avatar group, first add the component to the page:\n\n```html\n<vaadin-avatar-group></vaadin-avatar-group>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-avatar-group#property-items) property to initialize the structure:\n\n```js\ndocument.querySelector('vaadin-avatar-group').items = [\n {name: 'John Doe'},\n {abbr: 'AB'}\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n----------- | ---------------\n`container` | The container element\n`overlay` | The overflow avatar menu overlay\n`content` | The overflow avatar menu overlay content\n\nSee the [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-avatar) documentation for the available\nstate attributes and stylable shadow parts of avatar elements.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-avatar-group>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-avatar-group-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-overlay).\n- `<vaadin-avatar-group-menu>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-list-box).\n- `<vaadin-avatar-group-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-item).",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {
@@ -35,7 +35,7 @@
35
35
  },
36
36
  {
37
37
  "name": ".items",
38
- "description": "An array containing the items which will be stamped as avatars.\n\nThe items objects allow to configure [`name`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-avatar#property-name),\n[`abbr`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-avatar#property-abbr), [`img`](#/elements/vaadin-avatar#property-img)\nand [`colorIndex`](https://cdn.vaadin.com/vaadin-web-components/24.8.4/#/elements/vaadin-avatar#property-colorIndex) properties on the\nstamped avatars, and set `className` to provide CSS class names.\n\n#### Example\n\n```js\ngroup.items = [\n {\n name: 'User name',\n img: 'url-to-image.png',\n className: 'even'\n },\n {\n abbr: 'JD',\n colorIndex: 1,\n className: 'odd'\n },\n];\n```",
38
+ "description": "An array containing the items which will be stamped as avatars.\n\nThe items objects allow to configure [`name`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-avatar#property-name),\n[`abbr`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-avatar#property-abbr), [`img`](#/elements/vaadin-avatar#property-img)\nand [`colorIndex`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-avatar#property-colorIndex) properties on the\nstamped avatars, and set `className` to provide CSS class names.\n\n#### Example\n\n```js\ngroup.items = [\n {\n name: 'User name',\n img: 'url-to-image.png',\n className: 'even'\n },\n {\n abbr: 'JD',\n colorIndex: 1,\n className: 'odd'\n },\n];\n```",
39
39
  "value": {
40
40
  "kind": "expression"
41
41
  }