From 3f3799543dc68d9d763cd625abf61c74f15832fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davut=20Enes=20Y=C4=B1ld=C4=B1r=C4=B1m?= Date: Thu, 9 Jan 2025 15:55:45 +0300 Subject: [PATCH] refactor: fix review --- playground/template.html | 15 ++++++++++----- src/components/input/bl-input.ts | 9 +++++++-- src/components/textarea/bl-textarea.ts | 2 +- src/generated/locales/tr.ts | 1 + src/utilities/form-control.test.ts | 4 ++-- translations/tr.xlf | 5 +++++ 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/playground/template.html b/playground/template.html index 1b1d23d6..02aa1a0b 100644 --- a/playground/template.html +++ b/playground/template.html @@ -1,10 +1,11 @@ - + Baklava Playground + diff --git a/src/components/input/bl-input.ts b/src/components/input/bl-input.ts index b95bddee..1c704909 100644 --- a/src/components/input/bl-input.ts +++ b/src/components/input/bl-input.ts @@ -3,6 +3,7 @@ import { customElement, property, query, state } from "lit/decorators.js"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { live } from "lit/directives/live.js"; +import { localized, msg } from "@lit/localize"; import { FormControlMixin } from "@open-wc/form-control"; import { submit } from "@open-wc/form-helpers"; import "element-internals-polyfill"; @@ -45,6 +46,7 @@ export type InputSize = "small" | "medium" | "large"; * @cssproperty [--bl-input-padding-end] Sets the padding end */ @customElement("bl-input") +@localized() export default class BlInput extends FormControlMixin(LitElement) { static get styles(): CSSResultGroup { return [style]; @@ -200,7 +202,7 @@ export default class BlInput extends FormControlMixin(LitElement) { } @property({ reflect: true, type: String }) - error: string = ""; + error: string; private _customInvalidText: string; @@ -282,7 +284,10 @@ export default class BlInput extends FormControlMixin(LitElement) { */ async forceCustomError() { await this.updateComplete; - this.setCustomValidity(this.customInvalidText || "An error occurred"); + this.setCustomValidity( + this.customInvalidText || + msg("An error occurred", { desc: "bl-input: default custom error message" }) + ); this.setValue(this.value); this.reportValidity(); } diff --git a/src/components/textarea/bl-textarea.ts b/src/components/textarea/bl-textarea.ts index 2109110b..8b100d1a 100644 --- a/src/components/textarea/bl-textarea.ts +++ b/src/components/textarea/bl-textarea.ts @@ -28,7 +28,7 @@ export default class BlTextarea extends FormControlMixin(LitElement) { validationTarget: HTMLTextAreaElement; @property({ reflect: true, type: String }) - error: string = ""; + error: string; /** * Name of textarea diff --git a/src/generated/locales/tr.ts b/src/generated/locales/tr.ts index 750fcb61..186383c2 100644 --- a/src/generated/locales/tr.ts +++ b/src/generated/locales/tr.ts @@ -10,6 +10,7 @@ export const templates = { 's144508ac0e146c46': `Hiçbir Sonuç Bulunamadı`, +'s3f9c368cd44f682b': `Bir hata oluştu`, 's5d929ff1619ac0c9': `Arama`, 's716a6024e3fe999c': `Göster`, 's76ddb3a843ed8e06': `Aramayı Temizle`, diff --git a/src/utilities/form-control.test.ts b/src/utilities/form-control.test.ts index 171da9de..876fdd9b 100644 --- a/src/utilities/form-control.test.ts +++ b/src/utilities/form-control.test.ts @@ -14,7 +14,7 @@ class MyInvalidInput extends LitElement { validationTarget: HTMLInputElement; @property({ reflect: true, type: String }) - error: string = ""; + error: string; render() { return html``; @@ -27,7 +27,7 @@ class MyCustomErrorInput extends LitElement { validationTarget: HTMLInputElement; @property({ reflect: true, type: String }) - error: string = ""; + error: string; render() { return html``; diff --git a/translations/tr.xlf b/translations/tr.xlf index 64638bb7..977bcba9 100644 --- a/translations/tr.xlf +++ b/translations/tr.xlf @@ -32,6 +32,11 @@ Tümünü Seç bl-select: select all text + + An error occurred + Bir hata oluştu + bl-input: default custom error message +