1 | /*
|
2 | Copyright 2013-2015 ASIAL CORPORATION
|
3 | Licensed under the Apache License, Version 2.0 (the "License");
|
4 | you may not use this file except in compliance with the License.
|
5 | You may obtain a copy of the License at
|
6 | http://www.apache.org/licenses/LICENSE-2.0
|
7 | Unless required by applicable law or agreed to in writing, software
|
8 | distributed under the License is distributed on an "AS IS" BASIS,
|
9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10 | See the License for the specific language governing permissions and
|
11 | limitations under the License.
|
12 | */
|
13 |
|
14 | import onsElements from '../ons/elements.js';
|
15 | import BaseInputElement from './base/base-input.js';
|
16 |
|
17 | const scheme = {
|
18 | '.search-input': 'search-input--*'
|
19 | };
|
20 |
|
21 | /**
|
22 | * @element ons-search-input
|
23 | * @category form
|
24 | * @modifier material
|
25 | * [en]Displays a Material Design search input.[/en]
|
26 | * [ja][/ja]
|
27 | * @description
|
28 | * [en]
|
29 | * A search input element. The component will automatically render as a Material Design search input on Android devices.
|
30 | *
|
31 | * Most attributes that can be used for a normal `<input>` element can also be used on the `<ons-search-input>` element.
|
32 | * [/en]
|
33 | * [ja][/ja]
|
34 | * @tutorial vanilla/Reference/search-input
|
35 | * @seealso ons-input
|
36 | * [en]The `<ons-input>` element is used to display a text input.[/en]
|
37 | * [ja][/ja]
|
38 | * @seealso ons-range
|
39 | * [en]The `<ons-range>` element is used to display a range slider.[/en]
|
40 | * [ja][/ja]
|
41 | * @seealso ons-switch
|
42 | * [en]The `<ons-switch>` element is used to display a draggable toggle switch.[/en]
|
43 | * [ja][/ja]
|
44 | * @seealso ons-select
|
45 | * [en]The `<ons-select>` element is used to display a select box.[/en]
|
46 | * [ja][/ja]
|
47 | * @seealso ons-checkbox
|
48 | * [en]The `<ons-checkbox>` element is used to display a checkbox.[/en]
|
49 | * [ja][/ja]
|
50 | * @seealso ons-radio
|
51 | * [en]The `<ons-radio>` element is used to display a radio button.[/en]
|
52 | * [ja][/ja]
|
53 | * @guide theming.html#modifiers [en]More details about the `modifier` attribute[/en][ja]modifier属性の使い方[/ja]
|
54 | * @example
|
55 | * <ons-search-input placeholder="Search"></ons-search-input>
|
56 | */
|
57 | export default class SearchInputElement extends BaseInputElement {
|
58 |
|
59 | get _scheme() {
|
60 | return scheme;
|
61 | }
|
62 |
|
63 | get _template() {
|
64 | return `
|
65 | <input type="${this.type}" class="search-input">
|
66 | `;
|
67 | }
|
68 |
|
69 | get type() {
|
70 | return 'search';
|
71 | }
|
72 |
|
73 | /**
|
74 | * @attribute input-id
|
75 | * @type {String}
|
76 | * @description
|
77 | * [en]Specify the "id" attribute of the inner `<input>` element. This is useful when using `<label for="...">` elements.[/en]
|
78 | * [ja][/ja]
|
79 | */
|
80 |
|
81 | /**
|
82 | * @property value
|
83 | * @type {String}
|
84 | * @description
|
85 | * [en]The current value of the input.[/en]
|
86 | * [ja][/ja]
|
87 | */
|
88 |
|
89 | /**
|
90 | * @property disabled
|
91 | * @type {Boolean}
|
92 | * @description
|
93 | * [en]Whether the input is disabled or not.[/en]
|
94 | * [ja]無効化されている場合に`true`。[/ja]
|
95 | */
|
96 |
|
97 | /**
|
98 | * @method focus
|
99 | * @signature focus()
|
100 | * @description
|
101 | * [en]Focuses the input.[/en]
|
102 | * [ja][/ja]
|
103 | */
|
104 |
|
105 | /**
|
106 | * @method blur
|
107 | * @signature blur()
|
108 | * @description
|
109 | * [en]Removes focus from the input.[/en]
|
110 | * [ja][/ja]
|
111 | */
|
112 | }
|
113 |
|
114 | onsElements.SearchInput = SearchInputElement;
|
115 | customElements.define('ons-search-input', SearchInputElement);
|