@vaadin/message-input
Advanced tools
{ | ||
"name": "@vaadin/message-input", | ||
"version": "24.8.0-alpha3", | ||
"version": "24.8.0-alpha4", | ||
"publishConfig": { | ||
@@ -40,13 +40,13 @@ "access": "public" | ||
"@polymer/polymer": "^3.0.0", | ||
"@vaadin/button": "24.8.0-alpha3", | ||
"@vaadin/component-base": "24.8.0-alpha3", | ||
"@vaadin/text-area": "24.8.0-alpha3", | ||
"@vaadin/vaadin-lumo-styles": "24.8.0-alpha3", | ||
"@vaadin/vaadin-material-styles": "24.8.0-alpha3", | ||
"@vaadin/vaadin-themable-mixin": "24.8.0-alpha3", | ||
"@vaadin/button": "24.8.0-alpha4", | ||
"@vaadin/component-base": "24.8.0-alpha4", | ||
"@vaadin/text-area": "24.8.0-alpha4", | ||
"@vaadin/vaadin-lumo-styles": "24.8.0-alpha4", | ||
"@vaadin/vaadin-material-styles": "24.8.0-alpha4", | ||
"@vaadin/vaadin-themable-mixin": "24.8.0-alpha4", | ||
"lit": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@vaadin/chai-plugins": "24.8.0-alpha3", | ||
"@vaadin/test-runner-commands": "24.8.0-alpha3", | ||
"@vaadin/chai-plugins": "24.8.0-alpha4", | ||
"@vaadin/test-runner-commands": "24.8.0-alpha4", | ||
"@vaadin/testing-helpers": "^1.1.0", | ||
@@ -59,3 +59,3 @@ "sinon": "^18.0.0" | ||
], | ||
"gitHead": "8c49e2337a1905ae68d0d7aee2e672500ea72343" | ||
"gitHead": "88251b4c84ebb8849dde982acb62cc2b20eeec31" | ||
} |
@@ -8,6 +8,7 @@ /** | ||
import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js'; | ||
import type { I18nMixinClass } from '@vaadin/component-base/src/i18n-mixin.js'; | ||
export interface MessageInputI18n { | ||
send: string; | ||
message: string; | ||
send?: string; | ||
message?: string; | ||
} | ||
@@ -17,3 +18,6 @@ | ||
base: T, | ||
): Constructor<ControllerMixinClass> & Constructor<MessageInputMixinClass> & T; | ||
): Constructor<ControllerMixinClass> & | ||
Constructor<I18nMixinClass<MessageInputI18n>> & | ||
Constructor<MessageInputMixinClass> & | ||
T; | ||
@@ -27,8 +31,7 @@ export declare class MessageInputMixinClass { | ||
/** | ||
* The object used to localize this component. | ||
* For changing the default localization, change the entire | ||
* `i18n` object. | ||
* 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: | ||
* | ||
* ``` | ||
@@ -35,0 +38,0 @@ * { |
@@ -7,5 +7,11 @@ /** | ||
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js'; | ||
import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js'; | ||
import { SlotController } from '@vaadin/component-base/src/slot-controller.js'; | ||
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js'; | ||
const DEFAULT_I18N = { | ||
send: 'Send', | ||
message: 'Message', | ||
}; | ||
/** | ||
@@ -16,3 +22,3 @@ * @polymerMixin | ||
export const MessageInputMixin = (superClass) => | ||
class MessageInputMixinClass extends ControllerMixin(superClass) { | ||
class MessageInputMixinClass extends I18nMixin(DEFAULT_I18N, ControllerMixin(superClass)) { | ||
static get properties() { | ||
@@ -30,31 +36,2 @@ return { | ||
/** | ||
* The object used to localize this component. | ||
* For changing the default localization, change the entire | ||
* `i18n` object. | ||
* | ||
* The object has the following JSON structure and default values: | ||
* | ||
* ``` | ||
* { | ||
* // Used as the button label | ||
* send: 'Send', | ||
* | ||
* // Used as the input field's placeholder and aria-label | ||
* message: 'Message' | ||
* } | ||
* ``` | ||
* | ||
* @type {!MessageInputI18n} | ||
* @default {English} | ||
*/ | ||
i18n: { | ||
type: Object, | ||
sync: true, | ||
value: () => ({ | ||
send: 'Send', | ||
message: 'Message', | ||
}), | ||
}, | ||
/** | ||
* Set to true to disable this element. | ||
@@ -86,7 +63,32 @@ * @type {boolean} | ||
return [ | ||
'__buttonPropsChanged(_button, disabled, i18n)', | ||
'__textAreaPropsChanged(_textArea, disabled, i18n, value)', | ||
'__buttonPropsChanged(_button, disabled, __effectiveI18n)', | ||
'__textAreaPropsChanged(_textArea, disabled, __effectiveI18n, value)', | ||
]; | ||
} | ||
/** | ||
* 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: | ||
* ``` | ||
* { | ||
* // Used as the button label | ||
* send: 'Send', | ||
* | ||
* // Used as the input field's placeholder and aria-label | ||
* message: 'Message' | ||
* } | ||
* ``` | ||
* @return {!MessageInputI18n} | ||
*/ | ||
get i18n() { | ||
return super.i18n; | ||
} | ||
set i18n(value) { | ||
super.i18n = value; | ||
} | ||
/** @protected */ | ||
@@ -141,6 +143,6 @@ ready() { | ||
/** @private */ | ||
__buttonPropsChanged(button, disabled, i18n) { | ||
__buttonPropsChanged(button, disabled, effectiveI18n) { | ||
if (button) { | ||
button.disabled = disabled; | ||
button.textContent = i18n.send; | ||
button.textContent = effectiveI18n.send; | ||
} | ||
@@ -150,3 +152,3 @@ } | ||
/** @private */ | ||
__textAreaPropsChanged(textArea, disabled, i18n, value) { | ||
__textAreaPropsChanged(textArea, disabled, effectiveI18n, value) { | ||
if (textArea) { | ||
@@ -156,3 +158,3 @@ textArea.disabled = disabled; | ||
const message = i18n.message; | ||
const message = effectiveI18n.message; | ||
textArea.placeholder = message; | ||
@@ -159,0 +161,0 @@ textArea.accessibleName = message; |
{ | ||
"$schema": "https://json.schemastore.org/web-types", | ||
"name": "@vaadin/message-input", | ||
"version": "24.8.0-alpha3", | ||
"version": "24.8.0-alpha4", | ||
"description-markup": "markdown", | ||
@@ -48,9 +48,7 @@ "contributions": { | ||
{ | ||
"name": "value", | ||
"description": "Current content of the text input field", | ||
"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 // Used as the button label\n send: 'Send',\n\n // Used as the input field's placeholder and aria-label\n message: 'Message'\n}\n```", | ||
"value": { | ||
"type": [ | ||
"string", | ||
"null", | ||
"undefined" | ||
"MessageInputI18n" | ||
] | ||
@@ -60,7 +58,9 @@ } | ||
{ | ||
"name": "i18n", | ||
"description": "The object used to localize this component.\nFor changing the default localization, change the entire\n`i18n` object.\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // Used as the button label\n send: 'Send',\n\n // Used as the input field's placeholder and aria-label\n message: 'Message'\n}\n```", | ||
"name": "value", | ||
"description": "Current content of the text input field", | ||
"value": { | ||
"type": [ | ||
"MessageInputI18n" | ||
"string", | ||
"null", | ||
"undefined" | ||
] | ||
@@ -67,0 +67,0 @@ } |
{ | ||
"$schema": "https://json.schemastore.org/web-types", | ||
"name": "@vaadin/message-input", | ||
"version": "24.8.0-alpha3", | ||
"version": "24.8.0-alpha4", | ||
"description-markup": "markdown", | ||
@@ -30,4 +30,4 @@ "framework": "lit", | ||
{ | ||
"name": ".value", | ||
"description": "Current content of the text input field", | ||
"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 // Used as the button label\n send: 'Send',\n\n // Used as the input field's placeholder and aria-label\n message: 'Message'\n}\n```", | ||
"value": { | ||
@@ -38,4 +38,4 @@ "kind": "expression" | ||
{ | ||
"name": ".i18n", | ||
"description": "The object used to localize this component.\nFor changing the default localization, change the entire\n`i18n` object.\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // Used as the button label\n send: 'Send',\n\n // Used as the input field's placeholder and aria-label\n message: 'Message'\n}\n```", | ||
"name": ".value", | ||
"description": "Current content of the text input field", | ||
"value": { | ||
@@ -42,0 +42,0 @@ "kind": "expression" |
34820
1.35%593
0.51%