-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathdata-table-row.html
114 lines (96 loc) · 2.71 KB
/
data-table-row.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<dom-module id="data-table-row">
<template>
<style is="custom-style">
:host {
display: flex;
flex-direction: column;
opacity: 1;
cursor: pointer;
@apply(--iron-data-table-row);
}
:host([selected]) .cells {
@apply(--iron-data-table-row-selected);
}
:host(:not([header])[even]) {
@apply(--iron-data-table-row-even);
}
:host(:not([header]):not([even])) {
@apply(--iron-data-table-row-odd);
}
:host(:focus) {
outline: none;
@apply(--iron-data-table-row-focused);
}
:host(:not([header]):hover) {
@apply(--iron-data-table-row-hover);
}
:host(:focus):after {
@apply(--iron-data-table-row-focused-after);
}
:host:after {
@apply(--iron-data-table-row-after);
}
.cells {
display: flex;
flex-direction: row;
width: 100%;
}
</style>
<div class="cells">
<content select="data-table-checkbox"></content>
<content select="data-table-cell"></content>
</div>
<div class="details">
<content select="data-table-row-detail"></content>
</div>
</template>
<script>
Polymer({
is: 'data-table-row',
properties: {
beforeBind: Object,
expanded: {
type: Boolean,
reflectToAttribute: true
},
index: Number,
item: Object,
selected: {
type: Boolean,
reflectToAttribute: true
},
_static: {
type: Object,
value: { id: 0 }
}
},
observers: ['_beforeBind(beforeBind, index, item.*, selected, expanded)'],
attached: function() {
if (this.domHost && this.domHost.tagName.toUpperCase() === 'IRON-DATA-TABLE') {
var id = this._static.id++;
var item = this.parentElement;
if (!item._rowId) {
this._contentElement = document.createElement('content');
this._contentElement.setAttribute('select', '#item' + id);
Polymer.dom(item).appendChild(this._contentElement);
this.id = 'item' + id;
item._rowId = id;
Polymer.dom(this.domHost).appendChild(this);
// reset the cached value for shady root owner to make this.domHost
// return correct value.
this._ownerShadyRoot = undefined;
}
}
},
_beforeBind: function(beforeBind, index, item, selected, expanded) {
var data = {
index: index,
item: item.base,
expanded: expanded,
selected: selected
};
beforeBind(data, this);
}
});
</script>
</dom-module>