-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathpaper-typeahead.html
More file actions
185 lines (174 loc) · 7 KB
/
Copy pathpaper-typeahead.html
File metadata and controls
185 lines (174 loc) · 7 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!--
Copyright 2016 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
### Styling
The following custom properties and mixins are also available for styling:
Custom property | Description | Default
----------------|-------------|----------
`--paper-font-common-base`| default font base | `default`
`--paper-input-container-color`| input container text color | `--secondary-text-color`
`--paper-typeahead-results-layer-max-height` | max height for the results | `auto`
`--paper-typeahead-results` | typeahead result mixin | `{}`
`--paper-typeahead-result-selected-background` | typeahead result selected background | `--paper-indigo-50`
`--paper-typeahead-result-pressed` | paper item pressed mixin | `{}`
`--paper-typeahead-divider-color` | paper item result color divider | `--divider-color`
`--paper-typeahead-result-min-height` | min height of a result | `30px`
`--paper-typeahead-selected-weight` | font-weight of a single result | `normal`
`--paper-typeahead-result-selected` | selected style mixin | `{}`
`--paper-typeahead-result-focused` | focused style mixin | `{}`
`--paper-typeahead-input` | paper-input-container style mixin | `{}`
@demo demo/index.html
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
<link rel="import" href="../iron-behaviors/iron-control-state.html">
<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html">
<link rel="import" href="../iron-input/iron-input.html">
<link rel="import" href="../iron-selector/iron-selector.html">
<link rel="import" href="../paper-input/paper-input-behavior.html">
<link rel="import" href="../paper-input/paper-input-container.html">
<link rel="import" href="../paper-input/paper-input-error.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-material/paper-material.html">
<link rel="import" href="../paper-styles/default-theme.html">
<link rel="import" href="../paper-styles/typography.html">
<dom-module id="paper-typeahead">
<template>
<style>
:host {
@apply --paper-font-common-base;
--paper-input-container-label: {
z-index: -1;
};
--paper-input-container-underline: {
z-index: -1;
};
display: block;
position: relative;
}
input::-webkit-input-placeholder {
color: var(--paper-input-container-color, var(--secondary-text-color));
}
input:-moz-placeholder {
color: var(--paper-input-container-color, var(--secondary-text-color));
}
input::-moz-placeholder {
color: var(--paper-input-container-color, var(--secondary-text-color));
}
input:-ms-input-placeholder {
color: var(--paper-input-container-color, var(--secondary-text-color));
}
paper-input-container {
@apply --paper-typeahead-input;
}
paper-material {
border-radius: 0 0 2px 2px;
width: 100%;
margin-top: -6px;
position: absolute;
overflow: auto;
-webkit-overflow-scrolling: touch;
max-height: var(--paper-typeahead-results-layer-max-height, auto);
@apply --paper-typeahead-results;
}
.iron-selected:not(paper-input-container) {
background: var(--paper-typeahead-result-selected-background, var(--paper-indigo-50));
}
paper-item[pressed] {
@apply --paper-typeahead-result-pressed;
}
paper-item {
cursor: pointer;
position: relative;
background: #fff;
@apply --paper-typeahead-result;
--paper-item-min-height: var(--paper-typeahead-result-min-height, 30px);
--paper-item-selected-weight: var(--paper-typeahead-selected-weight, normal);
--paper-item-selected: var(--paper-typeahead-result-selected);
--paper-item-focused: var(--paper-typeahead-result-focused);
}
paper-item:not(:last-of-type) {
border-bottom: solid 1px var(--paper-typeahead-divider-color, var(--divider-color));
}
paper-item:focus:before {
display: none;
}
[hidden] {
display: none;
}
</style>
<paper-input-container
class="selectable"
no-label-float="[[noLabelFloat]]"
always-float-label="[[_computeAlwaysFloatLabel(alwaysFloatLabel,placeholder)]]"
auto-validate$="[[autoValidate]]"
disabled$="[[disabled]]"
invalid="[[invalid]]">
<slot name="prefix" slot="prefix"></slot>
<label hidden$="[[!label]]" on-tap="_onLabelTap" slot="input">[[label]]</label>
<input
is="iron-input"
id="input"
aria-labelledby$="[[_ariaLabelledBy]]"
aria-describedby$="[[_ariaDescribedBy]]"
disabled$="[[disabled]]"
bind-value="{{value}}"
value="{{typedValue::input}}"
invalid="{{invalid}}"
prevent-invalid-input="[[preventInvalidInput]]"
allowed-pattern="[[allowedPattern]]"
validator="[[validator]]"
type$="[[type]]"
pattern$="[[pattern]]"
required$="[[required]]"
autocomplete$="[[autocomplete]]"
autofocus$="[[autofocus]]"
inputmode$="[[inputmode]]"
minlength$="[[minlength]]"
maxlength$="[[maxlength]]"
min$="[[min]]"
max$="[[max]]"
step$="[[step]]"
name$="[[name]]"
placeholder$="[[placeholder]]"
readonly$="[[readonly]]"
size$="[[size]]"
autocapitalize$="[[autocapitalize]]"
autocorrect$="on"
on-change="_onChange" slot="input">
<slot name="suffix" slot="suffix"></slot>
<paper-input-error tabindex="-1" slot="input">[[errorMessage]]</paper-input-error>
</paper-input-container>
<paper-material
hidden$="[[_hideResults]]"
elevation="[[elevation]]"
on-mousedown="_mouseDownItems"
on-mouseleave="_mouseleaveItems"
tabindex="-1" slot="input">
<iron-selector
id="selector"
selected="{{selected}}"
items="[[selectorItems]]">
<template
is="dom-repeat"
id="item-list"
sort="[[sortFn]]"
items="[[filteredItems]]"
on-dom-change="_updateItems">
<paper-item on-mouseenter="_mouseenterItem" class="result-item selectable" tabindex="-1">
<span>[[getDataDisplayValue(item, dataKey)]]</span>
</paper-item>
</template>
</iron-selector>
</paper-material>
</template>
</dom-module>
<script src="paper-typeahead.js"></script>