1
- /* eslint-disable ember/no-classic-components, ember/require-tagless-components, ember/no-component-lifecycle-hooks */
2
- /**
3
- * @module ember-paper
4
- */
5
- import { filter , bool , or } from '@ember/object/computed' ;
1
+ /* eslint-disable ember/no-computed-properties-in-native-classes, ember/no-classic-components, ember/no-component-lifecycle-hooks */
2
+ import { attributeBindings , classNameBindings , tagName , layout as templateLayout } from '@ember-decorators/component' ;
3
+ import { computed } from '@ember/object' ;
4
+ import { or , bool , filter } from '@ember/object/computed' ;
6
5
7
6
import Component from '@ember/component' ;
8
- import { computed } from '@ember/object' ;
9
7
import layout from '../templates/components/paper-item' ;
10
8
import { ParentMixin } from 'ember-composability-tools' ;
11
9
import { invokeAction } from 'ember-paper/utils/invoke-action' ;
@@ -14,78 +12,87 @@ import { invokeAction } from 'ember-paper/utils/invoke-action';
14
12
* @extends Ember.Component
15
13
* @uses ParentMixin
16
14
*/
17
- export default Component . extend ( ParentMixin , {
18
- layout,
19
- tagName : 'md-list-item' ,
20
-
21
- _mouseEnterHandler : undefined ,
22
- _mouseLeaveHandler : undefined ,
15
+ @templateLayout ( layout )
16
+ @tagName ( 'md-list-item' )
17
+ @classNameBindings (
18
+ 'hasProxiedComponent:md-proxy-focus' ,
19
+ 'shouldBeClickable:md-clickable' ,
20
+ 'focused:md-focused' ,
21
+ 'hasPrimaryAction:_md-button-wrap'
22
+ )
23
+ @attributeBindings ( 'role' , 'tabindex' , 'title' )
24
+ export default class PaperItem extends Component . extend ( ParentMixin ) {
25
+ _mouseEnterHandler = undefined ;
26
+ _mouseLeaveHandler = undefined ;
23
27
24
28
// Ripple Overrides
25
29
// disable ripple when we have a primary action or when we don't have a proxied component
26
- noink : computed ( 'hasPrimaryAction' , 'hasProxiedComponent' , function ( ) {
30
+ @computed ( 'hasPrimaryAction' , 'hasProxiedComponent' )
31
+ get noink ( ) {
27
32
return this . hasPrimaryAction || ! this . hasProxiedComponent ;
28
- } ) ,
33
+ }
29
34
30
- classNameBindings : [
31
- 'hasProxiedComponent:md-proxy-focus' , 'shouldBeClickable:md-clickable' ,
32
- 'focused:md-focused' , 'hasPrimaryAction:_md-button-wrap'
33
- ] ,
34
- attributeBindings : [ 'role' , 'tabindex' , 'title' ] ,
35
- role : 'listitem' ,
36
- tabindex : '-1' ,
35
+ role = 'listitem' ;
36
+ tabindex = '-1' ;
37
37
38
- proxiedComponents : filter ( 'childComponents' , function ( c ) {
38
+ @ filter ( 'childComponents' , function ( c ) {
39
39
return ! c . get ( 'skipProxy' ) ;
40
- } ) ,
40
+ } )
41
+ proxiedComponents ;
42
+
43
+ @bool ( 'proxiedComponents.length' )
44
+ hasProxiedComponent ;
41
45
42
- hasProxiedComponent : bool ( 'proxiedComponents.length' ) ,
43
- shouldBeClickable : or ( 'hasProxiedComponent' , 'onClick' ) ,
46
+ @ or ( ' hasProxiedComponent' , 'onClick' )
47
+ shouldBeClickable ;
44
48
45
- hasPrimaryAction : or ( 'onClick' , 'href' ) ,
49
+ @or ( 'onClick' , 'href' )
50
+ hasPrimaryAction ;
46
51
47
- noProxy : computed ( 'hasPrimaryAction' , 'hasProxiedComponent' , function ( ) {
52
+ @computed ( 'hasPrimaryAction' , 'hasProxiedComponent' )
53
+ get noProxy ( ) {
48
54
return ! this . hasPrimaryAction && ! this . hasProxiedComponent ;
49
- } ) ,
55
+ }
50
56
51
- secondaryItem : computed ( 'proxiedComponents.[]' , function ( ) {
57
+ @computed ( 'proxiedComponents.[]' )
58
+ get secondaryItem ( ) {
52
59
let proxiedComponents = this . proxiedComponents ;
53
60
return proxiedComponents . objectAt ( 0 ) ;
54
- } ) ,
61
+ }
55
62
56
63
didInsertElement ( ) {
57
- this . _super ( ...arguments ) ;
64
+ super . didInsertElement ( ...arguments ) ;
58
65
59
66
this . _mouseEnterHandler = this . handleMouseEnter . bind ( this ) ;
60
67
this . _mouseLeaveHandler = this . handleMouseLeave . bind ( this ) ;
61
68
62
69
this . element . addEventListener ( 'mouseenter' , this . _mouseEnterHandler ) ;
63
70
this . element . addEventListener ( 'mouseleave' , this . _mouseLeaveHandler ) ;
64
- } ,
71
+ }
65
72
66
73
willDestroyElement ( ) {
67
- this . _super ( ...arguments ) ;
74
+ super . willDestroyElement ( ...arguments ) ;
68
75
69
76
this . element . removeEventListener ( 'mouseenter' , this . _mouseEnterHandler ) ;
70
77
this . element . removeEventListener ( 'mouseleave' , this . _mouseLeaveHandler ) ;
71
78
72
79
this . _mouseEnterHandler = undefined ;
73
80
this . _mouseLeaveHandler = undefined ;
74
- } ,
81
+ }
75
82
76
83
click ( ) {
77
84
this . proxiedComponents . forEach ( ( component ) => {
78
85
if ( component . processProxy && ! component . get ( 'disabled' ) && ( component . get ( 'bubbles' ) | ! this . hasPrimaryAction ) ) {
79
86
component . processProxy ( ) ;
80
87
}
81
88
} ) ;
82
- } ,
89
+ }
83
90
84
91
handleMouseEnter ( e ) {
85
92
invokeAction ( this , 'onMouseEnter' , e ) ;
86
- } ,
93
+ }
87
94
88
95
handleMouseLeave ( e ) {
89
96
invokeAction ( this , 'onMouseLeave' , e ) ;
90
97
}
91
- } ) ;
98
+ }
0 commit comments