@vaadin/avatar-group 24.0.0-alpha1 → 24.0.0-alpha3
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 +11 -10
- package/src/vaadin-avatar-group.js +36 -54
- package/web-types.json +3 -3
- package/web-types.lit.json +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/avatar-group",
|
|
3
|
-
"version": "24.0.0-
|
|
3
|
+
"version": "24.0.0-alpha3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,14 +37,15 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@polymer/polymer": "^3.0.0",
|
|
40
|
-
"@vaadin/avatar": "24.0.0-
|
|
41
|
-
"@vaadin/component-base": "24.0.0-
|
|
42
|
-
"@vaadin/item": "24.0.0-
|
|
43
|
-
"@vaadin/list-box": "24.0.0-
|
|
44
|
-
"@vaadin/overlay": "24.0.0-
|
|
45
|
-
"@vaadin/vaadin-lumo-styles": "24.0.0-
|
|
46
|
-
"@vaadin/vaadin-material-styles": "24.0.0-
|
|
47
|
-
"@vaadin/vaadin-themable-mixin": "24.0.0-
|
|
40
|
+
"@vaadin/avatar": "24.0.0-alpha3",
|
|
41
|
+
"@vaadin/component-base": "24.0.0-alpha3",
|
|
42
|
+
"@vaadin/item": "24.0.0-alpha3",
|
|
43
|
+
"@vaadin/list-box": "24.0.0-alpha3",
|
|
44
|
+
"@vaadin/overlay": "24.0.0-alpha3",
|
|
45
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha3",
|
|
46
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha3",
|
|
47
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha3",
|
|
48
|
+
"lit": "^2.0.0"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@esm-bundle/chai": "^4.3.4",
|
|
@@ -55,5 +56,5 @@
|
|
|
55
56
|
"web-types.json",
|
|
56
57
|
"web-types.lit.json"
|
|
57
58
|
],
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "7a013a3c5a56abd61dd4f7773c6ec77c3541bdf2"
|
|
59
60
|
}
|
|
@@ -9,7 +9,8 @@ import '@vaadin/list-box/src/vaadin-list-box.js';
|
|
|
9
9
|
import './vaadin-avatar-group-overlay.js';
|
|
10
10
|
import { calculateSplices } from '@polymer/polymer/lib/utils/array-splice.js';
|
|
11
11
|
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
12
|
-
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
12
|
+
import { html as legacyHtml, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
13
|
+
import { html, render } from 'lit';
|
|
13
14
|
import { announce } from '@vaadin/component-base/src/a11y-announcer.js';
|
|
14
15
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
15
16
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
@@ -65,7 +66,7 @@ const MINIMUM_DISPLAYED_AVATARS = 2;
|
|
|
65
66
|
*/
|
|
66
67
|
class AvatarGroup extends ResizeMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement)))) {
|
|
67
68
|
static get template() {
|
|
68
|
-
return
|
|
69
|
+
return legacyHtml`
|
|
69
70
|
<style>
|
|
70
71
|
:host {
|
|
71
72
|
display: block;
|
|
@@ -268,7 +269,7 @@ class AvatarGroup extends ResizeMixin(ElementMixin(ThemableMixin(ControllerMixin
|
|
|
268
269
|
'__itemsChanged(items.splices, items.*)',
|
|
269
270
|
'__i18nItemsChanged(i18n.*, items.length)',
|
|
270
271
|
'__updateAvatarsTheme(_overflow, _avatars, _theme)',
|
|
271
|
-
'__updateAvatars(items.*, __itemsInView, maxItemsVisible)',
|
|
272
|
+
'__updateAvatars(items.*, __itemsInView, maxItemsVisible, _overflow, i18n)',
|
|
272
273
|
'__updateOverflowAbbr(_overflow, items.length, __itemsInView, maxItemsVisible)',
|
|
273
274
|
'__updateOverflowHidden(_overflow, items.length, __itemsInView, __maxReached)',
|
|
274
275
|
'__updateOverflowTooltip(_overflowTooltip, items.length, __itemsInView, maxItemsVisible)',
|
|
@@ -279,11 +280,8 @@ class AvatarGroup extends ResizeMixin(ElementMixin(ThemableMixin(ControllerMixin
|
|
|
279
280
|
ready() {
|
|
280
281
|
super.ready();
|
|
281
282
|
|
|
282
|
-
this._overflowController = new SlotController(
|
|
283
|
-
|
|
284
|
-
'overflow',
|
|
285
|
-
() => document.createElement('vaadin-avatar'),
|
|
286
|
-
(_, overflow) => {
|
|
283
|
+
this._overflowController = new SlotController(this, 'overflow', 'vaadin-avatar', {
|
|
284
|
+
initializer: (overflow) => {
|
|
287
285
|
overflow.setAttribute('aria-haspopup', 'listbox');
|
|
288
286
|
overflow.setAttribute('aria-expanded', 'false');
|
|
289
287
|
overflow.addEventListener('click', (e) => this._onOverflowClick(e));
|
|
@@ -296,7 +294,7 @@ class AvatarGroup extends ResizeMixin(ElementMixin(ThemableMixin(ControllerMixin
|
|
|
296
294
|
this._overflow = overflow;
|
|
297
295
|
this._overflowTooltip = tooltip;
|
|
298
296
|
},
|
|
299
|
-
);
|
|
297
|
+
});
|
|
300
298
|
this.addController(this._overflowController);
|
|
301
299
|
|
|
302
300
|
this.$.overlay.renderer = this.__overlayRenderer.bind(this);
|
|
@@ -343,21 +341,6 @@ class AvatarGroup extends ResizeMixin(ElementMixin(ThemableMixin(ControllerMixin
|
|
|
343
341
|
});
|
|
344
342
|
}
|
|
345
343
|
|
|
346
|
-
/** @private */
|
|
347
|
-
__createAvatar(item) {
|
|
348
|
-
const avatar = document.createElement('vaadin-avatar');
|
|
349
|
-
avatar.name = item.name;
|
|
350
|
-
avatar.abbr = item.abbr;
|
|
351
|
-
avatar.img = item.img;
|
|
352
|
-
avatar.colorIndex = item.colorIndex;
|
|
353
|
-
|
|
354
|
-
avatar.withTooltip = true;
|
|
355
|
-
avatar.i18n = this.i18n;
|
|
356
|
-
avatar._item = item;
|
|
357
|
-
|
|
358
|
-
return avatar;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
344
|
/** @private */
|
|
362
345
|
__createItemElement(item) {
|
|
363
346
|
const itemElement = document.createElement('vaadin-item');
|
|
@@ -431,41 +414,40 @@ class AvatarGroup extends ResizeMixin(ElementMixin(ThemableMixin(ControllerMixin
|
|
|
431
414
|
}
|
|
432
415
|
|
|
433
416
|
/** @private */
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
417
|
+
__renderAvatars(items) {
|
|
418
|
+
render(
|
|
419
|
+
html`
|
|
420
|
+
${items.map(
|
|
421
|
+
(item) =>
|
|
422
|
+
html`
|
|
423
|
+
<vaadin-avatar
|
|
424
|
+
.name="${item.name}"
|
|
425
|
+
.abbr="${item.abbr}"
|
|
426
|
+
.img="${item.img}"
|
|
427
|
+
.colorIndex="${item.colorIndex}"
|
|
428
|
+
.i18n="${this.i18n}"
|
|
429
|
+
with-tooltip
|
|
430
|
+
></vaadin-avatar>
|
|
431
|
+
`,
|
|
432
|
+
)}
|
|
433
|
+
`,
|
|
434
|
+
this,
|
|
435
|
+
{ renderBefore: this._overflow },
|
|
436
|
+
);
|
|
437
|
+
}
|
|
440
438
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
439
|
+
/** @private */
|
|
440
|
+
__updateAvatars(arr, itemsInView, maxItemsVisible, overflow) {
|
|
441
|
+
if (!overflow) {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
444
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
if (removed.includes(item)) {
|
|
448
|
-
avatar.remove();
|
|
449
|
-
} else if (added.includes(item)) {
|
|
450
|
-
added.splice(added.indexOf(item), 1);
|
|
451
|
-
}
|
|
452
|
-
});
|
|
445
|
+
const items = arr.base || [];
|
|
446
|
+
const limit = this.__getLimit(items.length, itemsInView, maxItemsVisible);
|
|
453
447
|
|
|
454
|
-
|
|
455
|
-
}
|
|
448
|
+
this.__renderAvatars(limit ? items.slice(0, limit) : items);
|
|
456
449
|
|
|
457
450
|
this._avatars = [...this.querySelectorAll('vaadin-avatar')];
|
|
458
|
-
this.__oldAvatarItems = newItems;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/** @private */
|
|
462
|
-
__addAvatars(itemsToAdd, allItems) {
|
|
463
|
-
itemsToAdd.forEach((item) => {
|
|
464
|
-
const avatar = this.__createAvatar(item);
|
|
465
|
-
const nextItem = allItems[allItems.indexOf(item) + 1];
|
|
466
|
-
const nextAvatar = this._avatars.find((el) => el._item === nextItem);
|
|
467
|
-
this.insertBefore(avatar, nextAvatar || this._overflow);
|
|
468
|
-
});
|
|
469
451
|
}
|
|
470
452
|
|
|
471
453
|
/** @private */
|
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.0.0-
|
|
4
|
+
"version": "24.0.0-alpha3",
|
|
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.0.0-
|
|
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.0.0-alpha3/#/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.0.0-alpha3/#/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/custom-theme/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.0.0-alpha3/#/elements/vaadin-overlay).",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "max-items-visible",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"properties": [
|
|
38
38
|
{
|
|
39
39
|
"name": "items",
|
|
40
|
-
"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.0.0-
|
|
40
|
+
"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.0.0-alpha3/#/elements/vaadin-avatar#property-name),\n[`abbr`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha3/#/elements/vaadin-avatar#property-abbr), [`img`](#/elements/vaadin-avatar#property-img)\nand [`colorIndex`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha3/#/elements/vaadin-avatar#property-colorIndex) properties on the\nstamped avatars.\n\n#### Example\n\n```js\ngroup.items = [\n {\n name: 'User name',\n img: 'url-to-image.png'\n },\n {\n abbr: 'JD',\n colorIndex: 1\n },\n];\n```",
|
|
41
41
|
"value": {
|
|
42
42
|
"type": [
|
|
43
43
|
"Array.<AvatarGroupItem>",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/avatar-group",
|
|
4
|
-
"version": "24.0.0-
|
|
4
|
+
"version": "24.0.0-alpha3",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,12 +16,12 @@
|
|
|
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.0.0-
|
|
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.0.0-alpha3/#/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.0.0-alpha3/#/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/custom-theme/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.0.0-alpha3/#/elements/vaadin-overlay).",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
23
23
|
"name": ".items",
|
|
24
|
-
"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.0.0-
|
|
24
|
+
"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.0.0-alpha3/#/elements/vaadin-avatar#property-name),\n[`abbr`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha3/#/elements/vaadin-avatar#property-abbr), [`img`](#/elements/vaadin-avatar#property-img)\nand [`colorIndex`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha3/#/elements/vaadin-avatar#property-colorIndex) properties on the\nstamped avatars.\n\n#### Example\n\n```js\ngroup.items = [\n {\n name: 'User name',\n img: 'url-to-image.png'\n },\n {\n abbr: 'JD',\n colorIndex: 1\n },\n];\n```",
|
|
25
25
|
"value": {
|
|
26
26
|
"kind": "expression"
|
|
27
27
|
}
|