forked from vaadin/vaadin-combo-box
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vaadin-combo-box-item.html
94 lines (81 loc) · 2.11 KB
/
vaadin-combo-box-item.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
<!--
@license
Copyright (c) 2017 Vaadin Ltd.
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
-->
<!--
@element vaadin-combo-box-item
-->
<link rel="import" href="../polymer/polymer.html">
<dom-module id="vaadin-combo-box-item">
<template>
<style>
:host {
align-items: center;
display: flex;
height: 26px;
}
</style>
[[label]]
</template>
</dom-module>
<script>
Polymer({
is: 'vaadin-combo-box-item',
properties: {
/**
* The index of the item
*/
index: Number,
/**
* The item to render
* @type {(String|Object)}
*/
item: Object,
/**
* The text label corresponding to the item
*/
label: String,
/**
* True when item is selected
*/
selected: {
type: Boolean,
value: false,
reflectToAttribute: true
},
/**
* True when item is focused
*/
focused: {
type: Boolean,
value: false,
reflectToAttribute: true
},
/**
* The template instance corresponding to the item
*/
_itemTemplateInstance: Object
},
observers: [
'_updateTemplateInstanceVariable("index", index, _itemTemplateInstance)',
'_updateTemplateInstanceVariable("item", item, _itemTemplateInstance)',
'_updateTemplateInstanceVariable("selected", selected, _itemTemplateInstance)',
'_updateTemplateInstanceVariable("focused", focused, _itemTemplateInstance)'
],
attached: function() {
if (!this._itemTemplateInstance) {
var comboBox = this.domHost.dataHost;
comboBox._ensureTemplatized();
if (comboBox._itemTemplate) {
this._itemTemplateInstance = comboBox.stamp();
Polymer.dom(this.root).textContent = '';
Polymer.dom(this.root).appendChild(this._itemTemplateInstance.root);
}
}
},
_updateTemplateInstanceVariable: function(variable, value, _itemTemplateInstance) {
this._itemTemplateInstance[variable] = value;
}
});
</script>