-
Notifications
You must be signed in to change notification settings - Fork 332
/
paper-item.js
74 lines (62 loc) · 2.15 KB
/
paper-item.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* @module ember-paper
*/
import { filter, bool, or } from '@ember/object/computed';
import Component from '@ember/component';
import { computed } from '@ember/object';
import layout from '../templates/components/paper-item';
import RippleMixin from '../mixins/ripple-mixin';
import { ParentMixin } from 'ember-composability-tools';
import { invokeAction } from 'ember-invoke-action';
/**
* @class PaperItem
* @extends Ember.Component
* @uses ParentMixin
* @uses RippleMixin
*/
export default Component.extend(RippleMixin, ParentMixin, {
layout,
tagName: 'md-list-item',
// Ripple Overrides
rippleContainerSelector: '.md-no-style',
// disable ripple when we have a primary action or when we don't have a proxied component
noink: computed('hasPrimaryAction', 'hasProxiedComponent', function() {
return this.get('hasPrimaryAction') || !this.get('hasProxiedComponent');
}),
center: false,
dimBackground: true,
outline: false,
classNameBindings: [
'hasProxiedComponent:md-proxy-focus', 'shouldBeClickable:md-clickable',
'focused:md-focused', 'hasPrimaryAction:_md-button-wrap'
],
attributeBindings: ['role', 'tabindex', 'title'],
role: 'listitem',
tabindex: '-1',
proxiedComponents: filter('childComponents', function(c) {
return !c.get('skipProxy');
}),
hasProxiedComponent: bool('proxiedComponents.length'),
shouldBeClickable: or('hasProxiedComponent', 'onClick'),
hasPrimaryAction: or('onClick', 'href'),
noProxy: computed('hasPrimaryAction', 'hasProxiedComponent', function() {
return !this.get('hasPrimaryAction') && !this.get('hasProxiedComponent');
}),
secondaryItem: computed('proxiedComponents.[]', function() {
let proxiedComponents = this.get('proxiedComponents');
return proxiedComponents.objectAt(0);
}),
click() {
this.get('proxiedComponents').forEach((component) => {
if (component.processProxy && !component.get('disabled') && (component.get('bubbles') | !this.get('hasPrimaryAction'))) {
component.processProxy();
}
});
},
mouseEnter(e) {
invokeAction(this, 'onMouseEnter', e);
},
mouseLeave(e) {
invokeAction(this, 'onMouseLeave', e);
}
});