import { LitElement, html, } from 'lit-element';
import { getComponentSharedStyles, } from '@cells-components/cells-lit-helpers';
import styles from './my-custom-element-styles.js';
import '@bbva-web-components/bbva-form-text/bbva-form-text.js';
import '@bbva-web-components/bbva-form-password/bbva-form-password.js';
import '@bbva-web-components/bbva-button-default/bbva-button-default.js';
import '@bbva-web-components/bbva-progress-content/bbva-progress-content.js';
(...)
static get properties() {
return {
userInputLabel: {
type: String,
attribute: 'user-input-label'
},
userInputValue: {
type: String,
attribute: 'user-input-value'
},
passwordInputLabel: {
type: String,
attribute: 'password-input-label'
},
passwordInputValue: {
type: String,
attribute: 'password-input-value'
},
buttonText: {
type: String,
attribute: 'button-text'
},
loading: {
type: Boolean
}
};
}
constructor() {
super();
this.userInputLabel = 'Username';
this.passwordInputLabel = 'Password';
this.buttonText = 'Submit';
this.loading = false;
}
render() {
return html`
(...)
<form ?hidden="${this.loading}">
<bbva-form-text
label="${this.userInputLabel}"
.value="${this.userInputValue}"
@input="${(e) => this.userInputValue = e.target.value}" //declarando eventos
type="text">
</bbva-form-text>
<bbva-form-password
label="${this.passwordInputLabel}"
.value="${this.passwordInputValue}"
@input="${(e) => this.passwordInputValue = e.target.value}" //declarando eventos
type="password">
</bbva-form-password>
<bbva-button-default type="submit"
?disabled="${!this.userInputValue || !this.userInputValue}"
@click="${this._submit}"> //disparador de eventos
${this.buttonText}
</bbva-button-default>
</form>
<bbva-progress-content ?hidden="${!this.loading}"></bbva-progress-content>
`;
}
//evento
_submit(ev) {
ev.preventDefault();
this.loading = true;
this.dispatchEvent(new CustomEvent('my-custom-element-submit', {
bubbles: true,
composed: true,
detail: {
username: this.userInputValue,
password: this.passwordInputValue
}
}));
}