Files
t/ts/slinput.ts

41 lines
877 B
TypeScript
Raw Normal View History

import { waitForAnimationFrame } from "./event";
2024-12-22 10:23:37 -08:00
import { SLElem } from "./slelem";
import { SLIcon } from "./slicon";
export class SLInput extends SLElem {
constructor() {
super("sl-input");
}
addIcon(name: string, slot: "prefix" | "suffix"): SLIcon {
2024-12-22 10:23:37 -08:00
const icon = new SLIcon(name);
icon.setSlot(slot);
this.append(icon);
return icon;
}
addPrefixIcon(name: string): SLIcon {
2024-12-22 10:23:37 -08:00
return this.addIcon(name, "prefix");
}
addSuffixIcon(name: string): SLIcon {
2024-12-22 10:23:37 -08:00
return this.addIcon(name, "suffix");
}
clear() {
2024-12-22 10:23:37 -08:00
(this.elem as HTMLInputElement).value = "";
}
getValue(): string {
2024-12-22 10:23:37 -08:00
return (this.elem as HTMLInputElement).value;
}
focus() {
2024-12-22 10:23:37 -08:00
(this.elem as HTMLInputElement).focus();
}
setPill() {
2024-12-22 10:23:37 -08:00
this.setAttribute("pill", "");
}
}