@vaadin/avatar
Advanced tools
Comparing version 24.7.0-alpha8 to 24.7.0-alpha9
{ | ||
"name": "@vaadin/avatar", | ||
"version": "24.7.0-alpha8", | ||
"version": "24.7.0-alpha9", | ||
"publishConfig": { | ||
@@ -41,13 +41,13 @@ "access": "public" | ||
"@polymer/polymer": "^3.0.0", | ||
"@vaadin/a11y-base": "24.7.0-alpha8", | ||
"@vaadin/component-base": "24.7.0-alpha8", | ||
"@vaadin/tooltip": "24.7.0-alpha8", | ||
"@vaadin/vaadin-lumo-styles": "24.7.0-alpha8", | ||
"@vaadin/vaadin-material-styles": "24.7.0-alpha8", | ||
"@vaadin/vaadin-themable-mixin": "24.7.0-alpha8", | ||
"@vaadin/a11y-base": "24.7.0-alpha9", | ||
"@vaadin/component-base": "24.7.0-alpha9", | ||
"@vaadin/tooltip": "24.7.0-alpha9", | ||
"@vaadin/vaadin-lumo-styles": "24.7.0-alpha9", | ||
"@vaadin/vaadin-material-styles": "24.7.0-alpha9", | ||
"@vaadin/vaadin-themable-mixin": "24.7.0-alpha9", | ||
"lit": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@vaadin/chai-plugins": "24.7.0-alpha8", | ||
"@vaadin/test-runner-commands": "24.7.0-alpha8", | ||
"@vaadin/chai-plugins": "24.7.0-alpha9", | ||
"@vaadin/test-runner-commands": "24.7.0-alpha9", | ||
"@vaadin/testing-helpers": "^1.1.0", | ||
@@ -60,3 +60,3 @@ "sinon": "^18.0.0" | ||
], | ||
"gitHead": "d015035192480fcc8cc9df5d00a950f177b83c32" | ||
"gitHead": "b0a16c6ed7fc50a22a42dcab0649d74f4c300485" | ||
} |
@@ -8,6 +8,7 @@ /** | ||
import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js'; | ||
import type { I18nMixinClass, PartialI18n } from '@vaadin/component-base/src/i18n-mixin.js'; | ||
export interface AvatarI18n { | ||
export type AvatarI18n = PartialI18n<{ | ||
anonymous: string; | ||
} | ||
}>; | ||
@@ -19,3 +20,3 @@ /** | ||
base: T, | ||
): Constructor<AvatarMixinClass> & Constructor<FocusMixinClass> & T; | ||
): Constructor<AvatarMixinClass> & Constructor<I18nMixinClass<AvatarI18n>> & Constructor<FocusMixinClass> & T; | ||
@@ -47,8 +48,7 @@ export declare class AvatarMixinClass { | ||
/** | ||
* The object used to localize this component. | ||
* To change the default localization, replace the entire | ||
* _i18n_ object or just the property you want to modify. | ||
* The object used to localize this component. To change the default | ||
* localization, replace this with an object that provides all properties, or | ||
* just the individual properties you want to change. | ||
* | ||
* The object has the following JSON structure and default values: | ||
* | ||
* ``` | ||
@@ -55,0 +55,0 @@ * { |
@@ -7,3 +7,8 @@ /** | ||
import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js'; | ||
import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js'; | ||
const DEFAULT_I18N = { | ||
anonymous: 'anonymous', | ||
}; | ||
/** | ||
@@ -16,3 +21,3 @@ * A mixin providing common avatar functionality. | ||
export const AvatarMixin = (superClass) => | ||
class AvatarMixinClass extends FocusMixin(superClass) { | ||
class AvatarMixinClass extends I18nMixin(DEFAULT_I18N, FocusMixin(superClass)) { | ||
static get properties() { | ||
@@ -57,28 +62,2 @@ return { | ||
/** | ||
* The object used to localize this component. | ||
* To change the default localization, replace the entire | ||
* _i18n_ object or just the property you want to modify. | ||
* | ||
* The object has the following JSON structure and default values: | ||
* | ||
* ``` | ||
* { | ||
* // Translation of the anonymous user avatar tooltip. | ||
* anonymous: 'anonymous' | ||
* } | ||
* ``` | ||
* | ||
* @type {!AvatarI18n} | ||
* @default {English/US} | ||
*/ | ||
i18n: { | ||
type: Object, | ||
value: () => { | ||
return { | ||
anonymous: 'anonymous', | ||
}; | ||
}, | ||
}, | ||
/** | ||
* When true, the avatar has tooltip shown on hover and focus. | ||
@@ -112,3 +91,3 @@ * The tooltip text is based on the `name` and `abbr` properties. | ||
'__imgOrAbbrOrNameChanged(img, abbr, name)', | ||
'__i18nChanged(i18n)', | ||
'__i18nChanged(__effectiveI18n)', | ||
'__tooltipChanged(__tooltipNode, name, abbr)', | ||
@@ -118,2 +97,24 @@ ]; | ||
/** | ||
* The object used to localize this component. To change the default | ||
* localization, replace this with an object that provides all properties, or | ||
* just the individual properties you want to change. | ||
* | ||
* The object has the following JSON structure and default values: | ||
* ``` | ||
* { | ||
* // Translation of the anonymous user avatar tooltip. | ||
* anonymous: 'anonymous' | ||
* } | ||
* ``` | ||
* @return {!AvatarI18n} | ||
*/ | ||
get i18n() { | ||
return super.i18n; | ||
} | ||
set i18n(value) { | ||
super.i18n = value; | ||
} | ||
/** @protected */ | ||
@@ -220,4 +221,4 @@ ready() { | ||
/** @private */ | ||
__i18nChanged(i18n) { | ||
if (i18n && i18n.anonymous) { | ||
__i18nChanged(effectiveI18n) { | ||
if (effectiveI18n && effectiveI18n.anonymous) { | ||
if (this.__oldAnonymous && this.__tooltipNode && this.__tooltipNode.text === this.__oldAnonymous) { | ||
@@ -227,3 +228,3 @@ this.__setTooltip(); | ||
this.__oldAnonymous = i18n.anonymous; | ||
this.__oldAnonymous = effectiveI18n.anonymous; | ||
} | ||
@@ -243,3 +244,3 @@ } | ||
if (tooltipNode) { | ||
tooltipNode.text = tooltip || this.i18n.anonymous; | ||
tooltipNode.text = tooltip || this.__effectiveI18n.anonymous; | ||
} | ||
@@ -246,0 +247,0 @@ } |
{ | ||
"$schema": "https://json.schemastore.org/web-types", | ||
"name": "@vaadin/avatar", | ||
"version": "24.7.0-alpha8", | ||
"version": "24.7.0-alpha9", | ||
"description-markup": "markdown", | ||
@@ -83,2 +83,11 @@ "contributions": { | ||
{ | ||
"name": "i18n", | ||
"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```", | ||
"value": { | ||
"type": [ | ||
"AvatarI18n" | ||
] | ||
} | ||
}, | ||
{ | ||
"name": "img", | ||
@@ -128,11 +137,2 @@ "description": "The path to the image", | ||
{ | ||
"name": "i18n", | ||
"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```", | ||
"value": { | ||
"type": [ | ||
"AvatarI18n" | ||
] | ||
} | ||
}, | ||
{ | ||
"name": "withTooltip", | ||
@@ -139,0 +139,0 @@ "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.", |
{ | ||
"$schema": "https://json.schemastore.org/web-types", | ||
"name": "@vaadin/avatar", | ||
"version": "24.7.0-alpha8", | ||
"version": "24.7.0-alpha9", | ||
"description-markup": "markdown", | ||
@@ -30,2 +30,9 @@ "framework": "lit", | ||
{ | ||
"name": ".i18n", | ||
"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```", | ||
"value": { | ||
"kind": "expression" | ||
} | ||
}, | ||
{ | ||
"name": ".img", | ||
@@ -57,9 +64,2 @@ "description": "The path to the image", | ||
} | ||
}, | ||
{ | ||
"name": ".i18n", | ||
"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```", | ||
"value": { | ||
"kind": "expression" | ||
} | ||
} | ||
@@ -66,0 +66,0 @@ ] |
47555
945
+ Added@vaadin/a11y-base@24.7.0-alpha9(transitive)
+ Added@vaadin/component-base@24.7.0-alpha9(transitive)
+ Added@vaadin/icon@24.7.0-alpha9(transitive)
+ Added@vaadin/lit-renderer@24.7.0-alpha9(transitive)
+ Added@vaadin/overlay@24.7.0-alpha9(transitive)
+ Added@vaadin/popover@24.7.0-alpha9(transitive)
+ Added@vaadin/tooltip@24.7.0-alpha9(transitive)
+ Added@vaadin/vaadin-lumo-styles@24.7.0-alpha9(transitive)
+ Added@vaadin/vaadin-material-styles@24.7.0-alpha9(transitive)
+ Added@vaadin/vaadin-themable-mixin@24.7.0-alpha9(transitive)
- Removed@vaadin/a11y-base@24.7.0-alpha8(transitive)
- Removed@vaadin/component-base@24.7.0-alpha8(transitive)
- Removed@vaadin/icon@24.7.0-alpha8(transitive)
- Removed@vaadin/lit-renderer@24.7.0-alpha8(transitive)
- Removed@vaadin/overlay@24.7.0-alpha8(transitive)
- Removed@vaadin/popover@24.7.0-alpha8(transitive)
- Removed@vaadin/tooltip@24.7.0-alpha8(transitive)
- Removed@vaadin/vaadin-lumo-styles@24.7.0-alpha8(transitive)
- Removed@vaadin/vaadin-material-styles@24.7.0-alpha8(transitive)
- Removed@vaadin/vaadin-themable-mixin@24.7.0-alpha8(transitive)