@vaadin/avatar 24.7.0-alpha8 → 24.7.0-beta1

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",
3
- "version": "24.7.0-alpha8",
3
+ "version": "24.7.0-beta1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,17 +38,17 @@
38
38
  "dependencies": {
39
39
  "@open-wc/dedupe-mixin": "^1.3.0",
40
40
  "@polymer/polymer": "^3.0.0",
41
- "@vaadin/a11y-base": "24.7.0-alpha8",
42
- "@vaadin/component-base": "24.7.0-alpha8",
43
- "@vaadin/tooltip": "24.7.0-alpha8",
44
- "@vaadin/vaadin-lumo-styles": "24.7.0-alpha8",
45
- "@vaadin/vaadin-material-styles": "24.7.0-alpha8",
46
- "@vaadin/vaadin-themable-mixin": "24.7.0-alpha8",
41
+ "@vaadin/a11y-base": "24.7.0-beta1",
42
+ "@vaadin/component-base": "24.7.0-beta1",
43
+ "@vaadin/tooltip": "24.7.0-beta1",
44
+ "@vaadin/vaadin-lumo-styles": "24.7.0-beta1",
45
+ "@vaadin/vaadin-material-styles": "24.7.0-beta1",
46
+ "@vaadin/vaadin-themable-mixin": "24.7.0-beta1",
47
47
  "lit": "^3.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@vaadin/chai-plugins": "24.7.0-alpha8",
51
- "@vaadin/test-runner-commands": "24.7.0-alpha8",
50
+ "@vaadin/chai-plugins": "24.7.0-beta1",
51
+ "@vaadin/test-runner-commands": "24.7.0-beta1",
52
52
  "@vaadin/testing-helpers": "^1.1.0",
53
53
  "sinon": "^18.0.0"
54
54
  },
@@ -56,5 +56,5 @@
56
56
  "web-types.json",
57
57
  "web-types.lit.json"
58
58
  ],
59
- "gitHead": "d015035192480fcc8cc9df5d00a950f177b83c32"
59
+ "gitHead": "4043c518ef9b915cde612d2907ddc9bd10e5af17"
60
60
  }
@@ -5,17 +5,18 @@
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
  import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
8
+ import type { I18nMixinClass, PartialI18n } from '@vaadin/component-base/src/i18n-mixin.js';
8
9
 
9
- export interface AvatarI18n {
10
+ export type AvatarI18n = PartialI18n<{
10
11
  anonymous: string;
11
- }
12
+ }>;
12
13
 
13
14
  /**
14
15
  * A mixin providing common avatar functionality.
15
16
  */
16
17
  export declare function AvatarMixin<T extends Constructor<HTMLElement>>(
17
18
  base: T,
18
- ): Constructor<AvatarMixinClass> & Constructor<FocusMixinClass> & T;
19
+ ): Constructor<AvatarMixinClass> & Constructor<I18nMixinClass<AvatarI18n>> & Constructor<FocusMixinClass> & T;
19
20
 
20
21
  export declare class AvatarMixinClass {
21
22
  /**
@@ -42,12 +43,11 @@ export declare class AvatarMixinClass {
42
43
  colorIndex: number | null | undefined;
43
44
 
44
45
  /**
45
- * The object used to localize this component.
46
- * To change the default localization, replace the entire
47
- * _i18n_ object or just the property you want to modify.
46
+ * The object used to localize this component. To change the default
47
+ * localization, replace this with an object that provides all properties, or
48
+ * just the individual properties you want to change.
48
49
  *
49
50
  * The object has the following JSON structure and default values:
50
- *
51
51
  * ```
52
52
  * {
53
53
  * // Translation of the anonymous user avatar tooltip.
@@ -4,6 +4,11 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
7
+ import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js';
8
+
9
+ const DEFAULT_I18N = {
10
+ anonymous: 'anonymous',
11
+ };
7
12
 
8
13
  /**
9
14
  * A mixin providing common avatar functionality.
@@ -12,7 +17,7 @@ import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
12
17
  * @mixes FocusMixin
13
18
  */
14
19
  export const AvatarMixin = (superClass) =>
15
- class AvatarMixinClass extends FocusMixin(superClass) {
20
+ class AvatarMixinClass extends I18nMixin(DEFAULT_I18N, FocusMixin(superClass)) {
16
21
  static get properties() {
17
22
  return {
18
23
  /**
@@ -51,32 +56,6 @@ export const AvatarMixin = (superClass) =>
51
56
  observer: '__colorIndexChanged',
52
57
  },
53
58
 
54
- /**
55
- * The object used to localize this component.
56
- * To change the default localization, replace the entire
57
- * _i18n_ object or just the property you want to modify.
58
- *
59
- * The object has the following JSON structure and default values:
60
- *
61
- * ```
62
- * {
63
- * // Translation of the anonymous user avatar tooltip.
64
- * anonymous: 'anonymous'
65
- * }
66
- * ```
67
- *
68
- * @type {!AvatarI18n}
69
- * @default {English/US}
70
- */
71
- i18n: {
72
- type: Object,
73
- value: () => {
74
- return {
75
- anonymous: 'anonymous',
76
- };
77
- },
78
- },
79
-
80
59
  /**
81
60
  * When true, the avatar has tooltip shown on hover and focus.
82
61
  * The tooltip text is based on the `name` and `abbr` properties.
@@ -106,11 +85,33 @@ export const AvatarMixin = (superClass) =>
106
85
  static get observers() {
107
86
  return [
108
87
  '__imgOrAbbrOrNameChanged(img, abbr, name)',
109
- '__i18nChanged(i18n)',
88
+ '__i18nChanged(__effectiveI18n)',
110
89
  '__tooltipChanged(__tooltipNode, name, abbr)',
111
90
  ];
112
91
  }
113
92
 
93
+ /**
94
+ * The object used to localize this component. To change the default
95
+ * localization, replace this with an object that provides all properties, or
96
+ * just the individual properties you want to change.
97
+ *
98
+ * The object has the following JSON structure and default values:
99
+ * ```
100
+ * {
101
+ * // Translation of the anonymous user avatar tooltip.
102
+ * anonymous: 'anonymous'
103
+ * }
104
+ * ```
105
+ * @return {!AvatarI18n}
106
+ */
107
+ get i18n() {
108
+ return super.i18n;
109
+ }
110
+
111
+ set i18n(value) {
112
+ super.i18n = value;
113
+ }
114
+
114
115
  /** @protected */
115
116
  ready() {
116
117
  super.ready();
@@ -212,13 +213,13 @@ export const AvatarMixin = (superClass) =>
212
213
  }
213
214
 
214
215
  /** @private */
215
- __i18nChanged(i18n) {
216
- if (i18n && i18n.anonymous) {
216
+ __i18nChanged(effectiveI18n) {
217
+ if (effectiveI18n && effectiveI18n.anonymous) {
217
218
  if (this.__oldAnonymous && this.__tooltipNode && this.__tooltipNode.text === this.__oldAnonymous) {
218
219
  this.__setTooltip();
219
220
  }
220
221
 
221
- this.__oldAnonymous = i18n.anonymous;
222
+ this.__oldAnonymous = effectiveI18n.anonymous;
222
223
  }
223
224
  }
224
225
 
@@ -233,7 +234,7 @@ export const AvatarMixin = (superClass) =>
233
234
  __setTooltip(tooltip) {
234
235
  const tooltipNode = this.__tooltipNode;
235
236
  if (tooltipNode) {
236
- tooltipNode.text = tooltip || this.i18n.anonymous;
237
+ tooltipNode.text = tooltip || this.__effectiveI18n.anonymous;
237
238
  }
238
239
  }
239
240
 
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/avatar",
4
- "version": "24.7.0-alpha8",
4
+ "version": "24.7.0-beta1",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -79,6 +79,15 @@
79
79
  ],
80
80
  "js": {
81
81
  "properties": [
82
+ {
83
+ "name": "i18n",
84
+ "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```\n{\n // Translation of the anonymous user avatar tooltip.\n anonymous: 'anonymous'\n}\n```",
85
+ "value": {
86
+ "type": [
87
+ "AvatarI18n"
88
+ ]
89
+ }
90
+ },
82
91
  {
83
92
  "name": "img",
84
93
  "description": "The path to the image",
@@ -123,15 +132,6 @@
123
132
  ]
124
133
  }
125
134
  },
126
- {
127
- "name": "i18n",
128
- "description": "The object used to localize this component.\nTo change the default localization, replace the entire\n_i18n_ object or just the property you want to modify.\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // Translation of the anonymous user avatar tooltip.\n anonymous: 'anonymous'\n}\n```",
129
- "value": {
130
- "type": [
131
- "AvatarI18n"
132
- ]
133
- }
134
- },
135
135
  {
136
136
  "name": "withTooltip",
137
137
  "description": "When true, the avatar has tooltip shown on hover and focus.\nThe tooltip text is based on the `name` and `abbr` properties.\nWhen neither is provided, `i18n.anonymous` is used instead.",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/avatar",
4
- "version": "24.7.0-alpha8",
4
+ "version": "24.7.0-beta1",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -26,6 +26,13 @@
26
26
  "kind": "expression"
27
27
  }
28
28
  },
29
+ {
30
+ "name": ".i18n",
31
+ "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```\n{\n // Translation of the anonymous user avatar tooltip.\n anonymous: 'anonymous'\n}\n```",
32
+ "value": {
33
+ "kind": "expression"
34
+ }
35
+ },
29
36
  {
30
37
  "name": ".img",
31
38
  "description": "The path to the image",
@@ -53,13 +60,6 @@
53
60
  "value": {
54
61
  "kind": "expression"
55
62
  }
56
- },
57
- {
58
- "name": ".i18n",
59
- "description": "The object used to localize this component.\nTo change the default localization, replace the entire\n_i18n_ object or just the property you want to modify.\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // Translation of the anonymous user avatar tooltip.\n anonymous: 'anonymous'\n}\n```",
60
- "value": {
61
- "kind": "expression"
62
- }
63
63
  }
64
64
  ]
65
65
  }