@vaadin/avatar-group 24.0.0-alpha1 → 24.0.0-alpha2

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/avatar-group",
3
- "version": "24.0.0-alpha1",
3
+ "version": "24.0.0-alpha2",
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-alpha1",
41
- "@vaadin/component-base": "24.0.0-alpha1",
42
- "@vaadin/item": "24.0.0-alpha1",
43
- "@vaadin/list-box": "24.0.0-alpha1",
44
- "@vaadin/overlay": "24.0.0-alpha1",
45
- "@vaadin/vaadin-lumo-styles": "24.0.0-alpha1",
46
- "@vaadin/vaadin-material-styles": "24.0.0-alpha1",
47
- "@vaadin/vaadin-themable-mixin": "24.0.0-alpha1"
40
+ "@vaadin/avatar": "24.0.0-alpha2",
41
+ "@vaadin/component-base": "24.0.0-alpha2",
42
+ "@vaadin/item": "24.0.0-alpha2",
43
+ "@vaadin/list-box": "24.0.0-alpha2",
44
+ "@vaadin/overlay": "24.0.0-alpha2",
45
+ "@vaadin/vaadin-lumo-styles": "24.0.0-alpha2",
46
+ "@vaadin/vaadin-material-styles": "24.0.0-alpha2",
47
+ "@vaadin/vaadin-themable-mixin": "24.0.0-alpha2",
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": "427527c27c4b27822d61fd41d38d7b170134770b"
59
+ "gitHead": "0c16c01a6807e629a84f5a982793afecc1a7ced0"
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 html`
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)',
@@ -343,21 +344,6 @@ class AvatarGroup extends ResizeMixin(ElementMixin(ThemableMixin(ControllerMixin
343
344
  });
344
345
  }
345
346
 
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
347
  /** @private */
362
348
  __createItemElement(item) {
363
349
  const itemElement = document.createElement('vaadin-item');
@@ -431,41 +417,40 @@ class AvatarGroup extends ResizeMixin(ElementMixin(ThemableMixin(ControllerMixin
431
417
  }
432
418
 
433
419
  /** @private */
434
- __updateAvatars(arr, itemsInView, maxItemsVisible) {
435
- const items = arr.base || [];
436
- const limit = this.__getLimit(items.length, itemsInView, maxItemsVisible);
437
-
438
- const newItems = limit ? items.slice(0, limit) : items;
439
- const oldItems = this.__oldAvatarItems || [];
420
+ __renderAvatars(items) {
421
+ render(
422
+ html`
423
+ ${items.map(
424
+ (item) =>
425
+ html`
426
+ <vaadin-avatar
427
+ .name="${item.name}"
428
+ .abbr="${item.abbr}"
429
+ .img="${item.img}"
430
+ .colorIndex="${item.colorIndex}"
431
+ .i18n="${this.i18n}"
432
+ with-tooltip
433
+ ></vaadin-avatar>
434
+ `,
435
+ )}
436
+ `,
437
+ this,
438
+ { renderBefore: this._overflow },
439
+ );
440
+ }
440
441
 
441
- if (newItems.length || oldItems.length) {
442
- const removed = oldItems.filter((item) => !newItems.includes(item));
443
- const added = [...newItems];
442
+ /** @private */
443
+ __updateAvatars(arr, itemsInView, maxItemsVisible, overflow) {
444
+ if (!overflow) {
445
+ return;
446
+ }
444
447
 
445
- this._avatars.forEach((avatar) => {
446
- const item = avatar._item;
447
- if (removed.includes(item)) {
448
- avatar.remove();
449
- } else if (added.includes(item)) {
450
- added.splice(added.indexOf(item), 1);
451
- }
452
- });
448
+ const items = arr.base || [];
449
+ const limit = this.__getLimit(items.length, itemsInView, maxItemsVisible);
453
450
 
454
- this.__addAvatars(added, newItems);
455
- }
451
+ this.__renderAvatars(limit ? items.slice(0, limit) : items);
456
452
 
457
453
  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
454
  }
470
455
 
471
456
  /** @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-alpha1",
4
+ "version": "24.0.0-alpha2",
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-alpha1/#/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-alpha1/#/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-alpha1/#/elements/vaadin-overlay).",
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-alpha2/#/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-alpha2/#/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-alpha2/#/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-alpha1/#/elements/vaadin-avatar#property-name),\n[`abbr`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-avatar#property-abbr), [`img`](#/elements/vaadin-avatar#property-img)\nand [`colorIndex`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/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```",
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-alpha2/#/elements/vaadin-avatar#property-name),\n[`abbr`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha2/#/elements/vaadin-avatar#property-abbr), [`img`](#/elements/vaadin-avatar#property-img)\nand [`colorIndex`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha2/#/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>",
@@ -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-alpha1",
4
+ "version": "24.0.0-alpha2",
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-alpha1/#/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-alpha1/#/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-alpha1/#/elements/vaadin-overlay).",
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-alpha2/#/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-alpha2/#/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-alpha2/#/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-alpha1/#/elements/vaadin-avatar#property-name),\n[`abbr`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-avatar#property-abbr), [`img`](#/elements/vaadin-avatar#property-img)\nand [`colorIndex`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/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```",
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-alpha2/#/elements/vaadin-avatar#property-name),\n[`abbr`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha2/#/elements/vaadin-avatar#property-abbr), [`img`](#/elements/vaadin-avatar#property-img)\nand [`colorIndex`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha2/#/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
  }