UNPKG

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