-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
index.ts
55 lines (46 loc) · 1.53 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { html, LitElement } from 'lit'
import { property } from 'lit/decorators.js'
import '../../components/wui-icon/index.js'
import '../../components/wui-text/index.js'
import { resetStyles } from '../../utils/ThemeUtil.js'
import { customElement } from '../../utils/WebComponentsUtil.js'
import '../wui-input-text/index.js'
import styles from './styles.js'
import { ifDefined } from 'lit/directives/if-defined.js'
@customElement('wui-email-input')
export class WuiEmailInput extends LitElement {
public static override styles = [resetStyles, styles]
// -- State & Properties -------------------------------- //
@property() public errorMessage?: string
@property({ type: Boolean }) public disabled = false
@property() public value?: string
@property() public tabIdx?: number
// -- Render -------------------------------------------- //
public override render() {
return html`
<wui-input-text
type="email"
placeholder="Email"
icon="mail"
size="mdl"
.disabled=${this.disabled}
.value=${this.value}
data-testid="wui-email-input"
tabIdx=${ifDefined(this.tabIdx)}
></wui-input-text>
${this.templateError()}
`
}
// -- Private ------------------------------------------- //
private templateError() {
if (this.errorMessage) {
return html`<wui-text variant="tiny-500" color="error-100">${this.errorMessage}</wui-text>`
}
return null
}
}
declare global {
interface HTMLElementTagNameMap {
'wui-email-input': WuiEmailInput
}
}