@@ -10,7 +10,7 @@ import './vaadin-login-form-wrapper.js';
1010import { html , PolymerElement } from '@polymer/polymer/polymer-element.js' ;
1111import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js' ;
1212import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js' ;
13- import { LoginMixin } from './vaadin-login-mixin.js' ;
13+ import { LoginFormMixin } from './vaadin-login-form -mixin.js' ;
1414
1515/**
1616 * `<vaadin-login-form>` is a Web Component providing an easy way to require users
@@ -49,9 +49,9 @@ import { LoginMixin } from './vaadin-login-mixin.js';
4949 * @extends HTMLElement
5050 * @mixes ElementMixin
5151 * @mixes ThemableMixin
52- * @mixes LoginMixin
52+ * @mixes LoginFormMixin
5353 */
54- class LoginForm extends LoginMixin ( ElementMixin ( ThemableMixin ( PolymerElement ) ) ) {
54+ class LoginForm extends LoginFormMixin ( ElementMixin ( ThemableMixin ( PolymerElement ) ) ) {
5555 static get template ( ) {
5656 return html `
5757 < style >
@@ -111,19 +111,6 @@ class LoginForm extends LoginMixin(ElementMixin(ThemableMixin(PolymerElement)))
111111 return 'vaadin-login-form' ;
112112 }
113113
114- static get observers ( ) {
115- return [ '_errorChanged(error)' ] ;
116- }
117-
118- /** @protected */
119- connectedCallback ( ) {
120- super . connectedCallback ( ) ;
121-
122- if ( ! this . noAutofocus ) {
123- this . $ . vaadinLoginUsername . focus ( ) ;
124- }
125- }
126-
127114 /**
128115 * @param {StampedTemplate } dom
129116 * @return {null }
@@ -132,74 +119,6 @@ class LoginForm extends LoginMixin(ElementMixin(ThemableMixin(PolymerElement)))
132119 _attachDom ( dom ) {
133120 this . appendChild ( dom ) ;
134121 }
135-
136- /** @private */
137- _errorChanged ( ) {
138- if ( this . error && ! this . _preventAutoEnable ) {
139- this . disabled = false ;
140- }
141- }
142-
143- submit ( ) {
144- const userName = this . $ . vaadinLoginUsername ;
145- const password = this . $ . vaadinLoginPassword ;
146-
147- if ( this . disabled || ! ( userName . validate ( ) && password . validate ( ) ) ) {
148- return ;
149- }
150-
151- this . error = false ;
152- this . disabled = true ;
153-
154- const loginEventDetails = {
155- bubbles : true ,
156- cancelable : true ,
157- detail : {
158- username : userName . value ,
159- password : password . value ,
160- } ,
161- } ;
162-
163- const firedEvent = this . dispatchEvent ( new CustomEvent ( 'login' , loginEventDetails ) ) ;
164- if ( this . action && firedEvent ) {
165- const csrfMetaName = document . querySelector ( 'meta[name=_csrf_parameter]' ) ;
166- const csrfMetaValue = document . querySelector ( 'meta[name=_csrf]' ) ;
167- if ( csrfMetaName && csrfMetaValue ) {
168- this . $ . csrf . name = csrfMetaName . content ;
169- this . $ . csrf . value = csrfMetaValue . content ;
170- }
171- this . querySelector ( 'form' ) . submit ( ) ;
172- }
173- }
174-
175- /** @private */
176- _handleInputKeydown ( e ) {
177- if ( e . key === 'Enter' ) {
178- const { currentTarget : inputActive } = e ;
179- const nextInput =
180- inputActive . id === 'vaadinLoginUsername' ? this . $ . vaadinLoginPassword : this . $ . vaadinLoginUsername ;
181- if ( inputActive . validate ( ) ) {
182- if ( nextInput . checkValidity ( ) ) {
183- this . submit ( ) ;
184- } else {
185- nextInput . focus ( ) ;
186- }
187- }
188- }
189- }
190-
191- /** @private */
192- _handleInputKeyup ( e ) {
193- const input = e . currentTarget ;
194- if ( e . key === 'Tab' && input instanceof HTMLInputElement ) {
195- input . select ( ) ;
196- }
197- }
198-
199- /** @private */
200- _onForgotPasswordClick ( ) {
201- this . dispatchEvent ( new CustomEvent ( 'forgot-password' ) ) ;
202- }
203122}
204123
205124customElements . define ( LoginForm . is , LoginForm ) ;
0 commit comments