Skip to content

Commit

Permalink
chore(input): improve type-safety (#954)
Browse files Browse the repository at this point in the history
improves type safety for
* input
* icon
  • Loading branch information
AykutSarac authored Nov 4, 2024
1 parent aacd375 commit 460ae3a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/components/icon/bl-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const requestMap = new Map<string, Promise<Response>>();
* @tag bl-icon
* @summary Baklava Icon component
*
* @attr [name] Name of the icon to show
* @cssproperty [font-size] Setting size of icon. Default is current font size in DOM place
* @cssproperty [color=currentColor] Setting color of icon
*/
Expand All @@ -26,7 +27,7 @@ export default class BlIcon extends LitElement {
/**
* Name of the icon to show
*/
@property()
@property({ type: String, reflect: true })
get name(): BaklavaIcon {
return this._iconName;
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/input/bl-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe("bl-input", () => {
<legend><span></span></legend>
<input
aria-invalid="false"
autocomplete="on"
id="input"
type="text"
>
Expand Down Expand Up @@ -46,7 +47,7 @@ describe("bl-input", () => {
});

it('should call showPicker if "showPicker" is in HTMLInputElement.prototype', async () => {
const el = await fixture<BlInput>(html`<bl-input type="input"></bl-input>`);
const el = await fixture<BlInput>(html`<bl-input type="text"></bl-input>`);
const spy = stub(el.validationTarget, "showPicker");

el.showPicker();
Expand Down
6 changes: 3 additions & 3 deletions src/components/input/bl-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ export default class BlInput extends FormControlMixin(LitElement) {
* Hints browser to autocomplete this field.
*/
@property({ type: String, reflect: true })
autocomplete: string;
autocomplete: HTMLInputElement["autocomplete"] = "on";

/**
* Sets the input mode of the field for asking browser to show the desired keyboard.
*/
@property({ type: String, reflect: true })
inputmode: "none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url";
inputmode: HTMLInputElement["inputMode"];

/**
* Sets input to get keyboard focus automatically
Expand Down Expand Up @@ -385,7 +385,7 @@ export default class BlInput extends FormControlMixin(LitElement) {
.value=${live(this.value)}
inputmode="${ifDefined(this.inputmode)}"
?autofocus=${this.autofocus}
autocomplete="${ifDefined(this.autocomplete)}"
.autocomplete="${this.autocomplete}"
placeholder="${ifDefined(this.placeholder)}"
minlength="${ifDefined(this.minlength)}"
maxlength="${ifDefined(this.maxlength)}"
Expand Down

0 comments on commit 460ae3a

Please sign in to comment.