@vaadin/checkbox 24.0.0-beta1 → 24.0.0-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -7
- package/src/vaadin-checkbox-mixin.d.ts +50 -0
- package/src/vaadin-checkbox-mixin.js +121 -0
- package/src/vaadin-checkbox-styles.d.ts +8 -0
- package/src/vaadin-checkbox-styles.js +58 -0
- package/src/vaadin-checkbox.d.ts +11 -11
- package/src/vaadin-checkbox.js +18 -172
- package/web-types.json +28 -28
- package/web-types.lit.json +12 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/checkbox",
|
|
3
|
-
"version": "24.0.0-
|
|
3
|
+
"version": "24.0.0-beta2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
24
|
+
"!src/vaadin-lit-checkbox.d.ts",
|
|
25
|
+
"!src/vaadin-lit-checkbox.js",
|
|
24
26
|
"theme",
|
|
25
27
|
"vaadin-*.d.ts",
|
|
26
28
|
"vaadin-*.js",
|
|
@@ -35,12 +37,14 @@
|
|
|
35
37
|
"polymer"
|
|
36
38
|
],
|
|
37
39
|
"dependencies": {
|
|
40
|
+
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
41
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/component-base": "24.0.0-
|
|
40
|
-
"@vaadin/field-base": "24.0.0-
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "24.0.0-
|
|
42
|
-
"@vaadin/vaadin-material-styles": "24.0.0-
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "24.0.0-
|
|
42
|
+
"@vaadin/component-base": "24.0.0-beta2",
|
|
43
|
+
"@vaadin/field-base": "24.0.0-beta2",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-beta2",
|
|
45
|
+
"@vaadin/vaadin-material-styles": "24.0.0-beta2",
|
|
46
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-beta2",
|
|
47
|
+
"lit": "^2.0.0"
|
|
44
48
|
},
|
|
45
49
|
"devDependencies": {
|
|
46
50
|
"@esm-bundle/chai": "^4.3.4",
|
|
@@ -51,5 +55,5 @@
|
|
|
51
55
|
"web-types.json",
|
|
52
56
|
"web-types.lit.json"
|
|
53
57
|
],
|
|
54
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "00086f1f6d487f042f189c9b9ecd7ba736960888"
|
|
55
59
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import type { ActiveMixinClass } from '@vaadin/component-base/src/active-mixin.js';
|
|
8
|
+
import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
9
|
+
import type { DelegateFocusMixinClass } from '@vaadin/component-base/src/delegate-focus-mixin.js';
|
|
10
|
+
import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
|
|
11
|
+
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
12
|
+
import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
13
|
+
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
14
|
+
import type { CheckedMixinClass } from '@vaadin/field-base/src/checked-mixin.js';
|
|
15
|
+
import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
16
|
+
import type { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A mixin providing common checkbox functionality.
|
|
20
|
+
*/
|
|
21
|
+
export declare function CheckboxMixin<T extends Constructor<HTMLElement>>(
|
|
22
|
+
base: T,
|
|
23
|
+
): Constructor<ActiveMixinClass> &
|
|
24
|
+
Constructor<CheckboxMixinClass> &
|
|
25
|
+
Constructor<CheckedMixinClass> &
|
|
26
|
+
Constructor<ControllerMixinClass> &
|
|
27
|
+
Constructor<DelegateFocusMixinClass> &
|
|
28
|
+
Constructor<DelegateStateMixinClass> &
|
|
29
|
+
Constructor<DisabledMixinClass> &
|
|
30
|
+
Constructor<FocusMixinClass> &
|
|
31
|
+
Constructor<InputMixinClass> &
|
|
32
|
+
Constructor<KeyboardMixinClass> &
|
|
33
|
+
Constructor<LabelMixinClass> &
|
|
34
|
+
T;
|
|
35
|
+
|
|
36
|
+
export declare class CheckboxMixinClass {
|
|
37
|
+
/**
|
|
38
|
+
* True if the checkbox is in the indeterminate state which means
|
|
39
|
+
* it is not possible to say whether it is checked or unchecked.
|
|
40
|
+
* The state is reset once the user switches the checkbox by hand.
|
|
41
|
+
*
|
|
42
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Indeterminate_state_checkboxes
|
|
43
|
+
*/
|
|
44
|
+
indeterminate: boolean;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The name of the checkbox.
|
|
48
|
+
*/
|
|
49
|
+
name: string;
|
|
50
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { ActiveMixin } from '@vaadin/component-base/src/active-mixin.js';
|
|
7
|
+
import { DelegateFocusMixin } from '@vaadin/component-base/src/delegate-focus-mixin.js';
|
|
8
|
+
import { CheckedMixin } from '@vaadin/field-base/src/checked-mixin.js';
|
|
9
|
+
import { InputController } from '@vaadin/field-base/src/input-controller.js';
|
|
10
|
+
import { LabelMixin } from '@vaadin/field-base/src/label-mixin.js';
|
|
11
|
+
import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A mixin providing common checkbox functionality.
|
|
15
|
+
*
|
|
16
|
+
* @polymerMixin
|
|
17
|
+
* @mixes ActiveMixin
|
|
18
|
+
* @mixes CheckedMixin
|
|
19
|
+
* @mixes DelegateFocusMixin
|
|
20
|
+
* @mixes LabelMixin
|
|
21
|
+
*/
|
|
22
|
+
export const CheckboxMixin = (superclass) =>
|
|
23
|
+
class CheckboxMixinClass extends LabelMixin(CheckedMixin(DelegateFocusMixin(ActiveMixin(superclass)))) {
|
|
24
|
+
static get properties() {
|
|
25
|
+
return {
|
|
26
|
+
/**
|
|
27
|
+
* True if the checkbox is in the indeterminate state which means
|
|
28
|
+
* it is not possible to say whether it is checked or unchecked.
|
|
29
|
+
* The state is reset once the user switches the checkbox by hand.
|
|
30
|
+
*
|
|
31
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Indeterminate_state_checkboxes
|
|
32
|
+
*
|
|
33
|
+
* @type {boolean}
|
|
34
|
+
*/
|
|
35
|
+
indeterminate: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
notify: true,
|
|
38
|
+
value: false,
|
|
39
|
+
reflectToAttribute: true,
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The name of the checkbox.
|
|
44
|
+
*
|
|
45
|
+
* @type {string}
|
|
46
|
+
*/
|
|
47
|
+
name: {
|
|
48
|
+
type: String,
|
|
49
|
+
value: '',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** @override */
|
|
55
|
+
static get delegateProps() {
|
|
56
|
+
return [...super.delegateProps, 'indeterminate'];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** @override */
|
|
60
|
+
static get delegateAttrs() {
|
|
61
|
+
return [...super.delegateAttrs, 'name'];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
constructor() {
|
|
65
|
+
super();
|
|
66
|
+
|
|
67
|
+
this._setType('checkbox');
|
|
68
|
+
|
|
69
|
+
// Set the string "on" as the default value for the checkbox following the HTML specification:
|
|
70
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
|
|
71
|
+
this.value = 'on';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** @protected */
|
|
75
|
+
ready() {
|
|
76
|
+
super.ready();
|
|
77
|
+
|
|
78
|
+
this.addController(
|
|
79
|
+
new InputController(this, (input) => {
|
|
80
|
+
this._setInputElement(input);
|
|
81
|
+
this._setFocusElement(input);
|
|
82
|
+
this.stateTarget = input;
|
|
83
|
+
this.ariaTarget = input;
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Override method inherited from `ActiveMixin` to prevent setting
|
|
91
|
+
* `active` attribute when clicking a link placed inside the label.
|
|
92
|
+
*
|
|
93
|
+
* @param {Event} event
|
|
94
|
+
* @return {boolean}
|
|
95
|
+
* @protected
|
|
96
|
+
* @override
|
|
97
|
+
*/
|
|
98
|
+
_shouldSetActive(event) {
|
|
99
|
+
if (event.target.localName === 'a') {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return super._shouldSetActive(event);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Override method inherited from `CheckedMixin` to reset
|
|
108
|
+
* `indeterminate` state checkbox is toggled by the user.
|
|
109
|
+
*
|
|
110
|
+
* @param {boolean} checked
|
|
111
|
+
* @protected
|
|
112
|
+
* @override
|
|
113
|
+
*/
|
|
114
|
+
_toggleChecked(checked) {
|
|
115
|
+
if (this.indeterminate) {
|
|
116
|
+
this.indeterminate = false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
super._toggleChecked(checked);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
7
|
+
|
|
8
|
+
export const checkboxStyles = css`
|
|
9
|
+
:host {
|
|
10
|
+
display: inline-block;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host([hidden]) {
|
|
14
|
+
display: none !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:host([disabled]) {
|
|
18
|
+
-webkit-tap-highlight-color: transparent;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.vaadin-checkbox-container {
|
|
22
|
+
display: grid;
|
|
23
|
+
grid-template-columns: auto 1fr;
|
|
24
|
+
align-items: baseline;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[part='checkbox'],
|
|
28
|
+
::slotted(input),
|
|
29
|
+
::slotted(label) {
|
|
30
|
+
grid-row: 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[part='checkbox'],
|
|
34
|
+
::slotted(input) {
|
|
35
|
+
grid-column: 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[part='checkbox'] {
|
|
39
|
+
width: var(--vaadin-checkbox-size, 1em);
|
|
40
|
+
height: var(--vaadin-checkbox-size, 1em);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[part='checkbox']::before {
|
|
44
|
+
display: block;
|
|
45
|
+
content: '\\202F';
|
|
46
|
+
line-height: var(--vaadin-checkbox-size, 1em);
|
|
47
|
+
contain: paint;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* visually hidden */
|
|
51
|
+
::slotted(input) {
|
|
52
|
+
opacity: 0;
|
|
53
|
+
cursor: inherit;
|
|
54
|
+
margin: 0;
|
|
55
|
+
align-self: stretch;
|
|
56
|
+
-webkit-appearance: none;
|
|
57
|
+
}
|
|
58
|
+
`;
|
package/src/vaadin-checkbox.d.ts
CHANGED
|
@@ -41,20 +41,20 @@ export interface CheckboxEventMap extends HTMLElementEventMap, CheckboxCustomEve
|
|
|
41
41
|
* The following shadow DOM parts are available for styling:
|
|
42
42
|
*
|
|
43
43
|
* Part name | Description
|
|
44
|
-
*
|
|
45
|
-
* `checkbox` | The
|
|
44
|
+
* ------------|-------------
|
|
45
|
+
* `checkbox` | The element representing a stylable custom checkbox.
|
|
46
46
|
*
|
|
47
47
|
* The following state attributes are available for styling:
|
|
48
48
|
*
|
|
49
|
-
* Attribute | Description
|
|
50
|
-
*
|
|
51
|
-
* `active` | Set when the checkbox is
|
|
52
|
-
* `
|
|
53
|
-
* `
|
|
54
|
-
* `
|
|
55
|
-
* `
|
|
56
|
-
* `
|
|
57
|
-
* `has-label` | Set when the checkbox has a label.
|
|
49
|
+
* Attribute | Description
|
|
50
|
+
* ----------------|-------------
|
|
51
|
+
* `active` | Set when the checkbox is activated with mouse, touch or the keyboard.
|
|
52
|
+
* `checked` | Set when the checkbox is checked.
|
|
53
|
+
* `disabled` | Set when the checkbox is disabled.
|
|
54
|
+
* `focus-ring` | Set when the checkbox is focused using the keyboard.
|
|
55
|
+
* `focused` | Set when the checkbox is focused.
|
|
56
|
+
* `indeterminate` | Set when the checkbox is in the indeterminate state.
|
|
57
|
+
* `has-label` | Set when the checkbox has a label.
|
|
58
58
|
*
|
|
59
59
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
60
60
|
*
|
package/src/vaadin-checkbox.js
CHANGED
|
@@ -4,16 +4,13 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
7
|
-
import { ActiveMixin } from '@vaadin/component-base/src/active-mixin.js';
|
|
8
|
-
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
9
|
-
import { DelegateFocusMixin } from '@vaadin/component-base/src/delegate-focus-mixin.js';
|
|
10
7
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
11
8
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
|
+
import { CheckboxMixin } from './vaadin-checkbox-mixin.js';
|
|
11
|
+
import { checkboxStyles } from './vaadin-checkbox-styles.js';
|
|
12
|
+
|
|
13
|
+
registerStyles('vaadin-checkbox', checkboxStyles, { moduleId: 'vaadin-checkbox-styles' });
|
|
17
14
|
|
|
18
15
|
/**
|
|
19
16
|
* `<vaadin-checkbox>` is an input field representing a binary choice.
|
|
@@ -27,20 +24,20 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
27
24
|
* The following shadow DOM parts are available for styling:
|
|
28
25
|
*
|
|
29
26
|
* Part name | Description
|
|
30
|
-
*
|
|
31
|
-
* `checkbox` | The
|
|
27
|
+
* ------------|-------------
|
|
28
|
+
* `checkbox` | The element representing a stylable custom checkbox.
|
|
32
29
|
*
|
|
33
30
|
* The following state attributes are available for styling:
|
|
34
31
|
*
|
|
35
|
-
* Attribute | Description
|
|
36
|
-
*
|
|
37
|
-
* `active` | Set when the checkbox is
|
|
38
|
-
* `
|
|
39
|
-
* `
|
|
40
|
-
* `
|
|
41
|
-
* `
|
|
42
|
-
* `
|
|
43
|
-
* `has-label` | Set when the checkbox has a label.
|
|
32
|
+
* Attribute | Description
|
|
33
|
+
* ----------------|-------------
|
|
34
|
+
* `active` | Set when the checkbox is activated with mouse, touch or the keyboard.
|
|
35
|
+
* `checked` | Set when the checkbox is checked.
|
|
36
|
+
* `disabled` | Set when the checkbox is disabled.
|
|
37
|
+
* `focus-ring` | Set when the checkbox is focused using the keyboard.
|
|
38
|
+
* `focused` | Set when the checkbox is focused.
|
|
39
|
+
* `indeterminate` | Set when the checkbox is in the indeterminate state.
|
|
40
|
+
* `has-label` | Set when the checkbox has a label.
|
|
44
41
|
*
|
|
45
42
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
46
43
|
*
|
|
@@ -48,74 +45,17 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
48
45
|
* @fires {CustomEvent} indeterminate-changed - Fired when the `indeterminate` property changes.
|
|
49
46
|
*
|
|
50
47
|
* @extends HTMLElement
|
|
51
|
-
* @mixes
|
|
48
|
+
* @mixes CheckboxMixin
|
|
52
49
|
* @mixes ThemableMixin
|
|
53
50
|
* @mixes ElementMixin
|
|
54
|
-
* @mixes ActiveMixin
|
|
55
|
-
* @mixes DelegateFocusMixin
|
|
56
|
-
* @mixes CheckedMixin
|
|
57
|
-
* @mixes LabelMixin
|
|
58
51
|
*/
|
|
59
|
-
class Checkbox extends
|
|
60
|
-
CheckedMixin(DelegateFocusMixin(ActiveMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement)))))),
|
|
61
|
-
) {
|
|
52
|
+
export class Checkbox extends CheckboxMixin(ElementMixin(ThemableMixin(PolymerElement))) {
|
|
62
53
|
static get is() {
|
|
63
54
|
return 'vaadin-checkbox';
|
|
64
55
|
}
|
|
65
56
|
|
|
66
57
|
static get template() {
|
|
67
58
|
return html`
|
|
68
|
-
<style>
|
|
69
|
-
:host {
|
|
70
|
-
display: inline-block;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
:host([hidden]) {
|
|
74
|
-
display: none !important;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
:host([disabled]) {
|
|
78
|
-
-webkit-tap-highlight-color: transparent;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.vaadin-checkbox-container {
|
|
82
|
-
display: grid;
|
|
83
|
-
grid-template-columns: auto 1fr;
|
|
84
|
-
align-items: baseline;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
[part='checkbox'],
|
|
88
|
-
::slotted(input),
|
|
89
|
-
::slotted(label) {
|
|
90
|
-
grid-row: 1;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
[part='checkbox'],
|
|
94
|
-
::slotted(input) {
|
|
95
|
-
grid-column: 1;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
[part='checkbox'] {
|
|
99
|
-
width: var(--vaadin-checkbox-size, 1em);
|
|
100
|
-
height: var(--vaadin-checkbox-size, 1em);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
[part='checkbox']::before {
|
|
104
|
-
display: block;
|
|
105
|
-
content: '\\202F';
|
|
106
|
-
line-height: var(--vaadin-checkbox-size, 1em);
|
|
107
|
-
contain: paint;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/* visually hidden */
|
|
111
|
-
::slotted(input) {
|
|
112
|
-
opacity: 0;
|
|
113
|
-
cursor: inherit;
|
|
114
|
-
margin: 0;
|
|
115
|
-
align-self: stretch;
|
|
116
|
-
-webkit-appearance: none;
|
|
117
|
-
}
|
|
118
|
-
</style>
|
|
119
59
|
<div class="vaadin-checkbox-container">
|
|
120
60
|
<div part="checkbox" aria-hidden="true"></div>
|
|
121
61
|
<slot name="input"></slot>
|
|
@@ -125,107 +65,13 @@ class Checkbox extends LabelMixin(
|
|
|
125
65
|
`;
|
|
126
66
|
}
|
|
127
67
|
|
|
128
|
-
static get properties() {
|
|
129
|
-
return {
|
|
130
|
-
/**
|
|
131
|
-
* True if the checkbox is in the indeterminate state which means
|
|
132
|
-
* it is not possible to say whether it is checked or unchecked.
|
|
133
|
-
* The state is reset once the user switches the checkbox by hand.
|
|
134
|
-
*
|
|
135
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Indeterminate_state_checkboxes
|
|
136
|
-
*
|
|
137
|
-
* @type {boolean}
|
|
138
|
-
*/
|
|
139
|
-
indeterminate: {
|
|
140
|
-
type: Boolean,
|
|
141
|
-
notify: true,
|
|
142
|
-
value: false,
|
|
143
|
-
reflectToAttribute: true,
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* The name of the checkbox.
|
|
148
|
-
*
|
|
149
|
-
* @type {string}
|
|
150
|
-
*/
|
|
151
|
-
name: {
|
|
152
|
-
type: String,
|
|
153
|
-
value: '',
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/** @override */
|
|
159
|
-
static get delegateProps() {
|
|
160
|
-
return [...super.delegateProps, 'indeterminate'];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/** @override */
|
|
164
|
-
static get delegateAttrs() {
|
|
165
|
-
return [...super.delegateAttrs, 'name'];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
constructor() {
|
|
169
|
-
super();
|
|
170
|
-
|
|
171
|
-
this._setType('checkbox');
|
|
172
|
-
|
|
173
|
-
// Set the string "on" as the default value for the checkbox following the HTML specification:
|
|
174
|
-
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
|
|
175
|
-
this.value = 'on';
|
|
176
|
-
}
|
|
177
|
-
|
|
178
68
|
/** @protected */
|
|
179
69
|
ready() {
|
|
180
70
|
super.ready();
|
|
181
71
|
|
|
182
|
-
this.addController(
|
|
183
|
-
new InputController(this, (input) => {
|
|
184
|
-
this._setInputElement(input);
|
|
185
|
-
this._setFocusElement(input);
|
|
186
|
-
this.stateTarget = input;
|
|
187
|
-
this.ariaTarget = input;
|
|
188
|
-
}),
|
|
189
|
-
);
|
|
190
|
-
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
191
72
|
this._tooltipController = new TooltipController(this);
|
|
192
73
|
this.addController(this._tooltipController);
|
|
193
74
|
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Extends the method from `ActiveMixin` in order to
|
|
197
|
-
* prevent setting the `active` attribute when interacting with a link inside the label.
|
|
198
|
-
*
|
|
199
|
-
* @param {Event} event
|
|
200
|
-
* @return {boolean}
|
|
201
|
-
* @protected
|
|
202
|
-
* @override
|
|
203
|
-
*/
|
|
204
|
-
_shouldSetActive(event) {
|
|
205
|
-
if (event.target.localName === 'a') {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return super._shouldSetActive(event);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Extends the method from `CheckedMixin` in order to
|
|
214
|
-
* reset the indeterminate state once the user switches the checkbox.
|
|
215
|
-
*
|
|
216
|
-
* @param {boolean} checked
|
|
217
|
-
* @protected
|
|
218
|
-
* @override
|
|
219
|
-
*/
|
|
220
|
-
_toggleChecked(checked) {
|
|
221
|
-
if (this.indeterminate) {
|
|
222
|
-
this.indeterminate = false;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
super._toggleChecked(checked);
|
|
226
|
-
}
|
|
227
75
|
}
|
|
228
76
|
|
|
229
77
|
customElements.define(Checkbox.is, Checkbox);
|
|
230
|
-
|
|
231
|
-
export { Checkbox };
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/checkbox",
|
|
4
|
-
"version": "24.0.0-
|
|
4
|
+
"version": "24.0.0-beta2",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-checkbox",
|
|
11
|
-
"description": "`<vaadin-checkbox>` is an input field representing a binary choice.\n\n```html\n<vaadin-checkbox label=\"I accept the terms and conditions\"></vaadin-checkbox>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n
|
|
11
|
+
"description": "`<vaadin-checkbox>` is an input field representing a binary choice.\n\n```html\n<vaadin-checkbox label=\"I accept the terms and conditions\"></vaadin-checkbox>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n------------|-------------\n`checkbox` | The element representing a stylable custom checkbox.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n----------------|-------------\n`active` | Set when the checkbox is activated with mouse, touch or the keyboard.\n`checked` | Set when the checkbox is checked.\n`disabled` | Set when the checkbox is disabled.\n`focus-ring` | Set when the checkbox is focused using the keyboard.\n`focused` | Set when the checkbox is focused.\n`indeterminate` | Set when the checkbox is in the indeterminate state.\n`has-label` | Set when the checkbox has a label.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "disabled",
|
|
@@ -21,17 +21,6 @@
|
|
|
21
21
|
]
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
{
|
|
25
|
-
"name": "autofocus",
|
|
26
|
-
"description": "Specify that this control should have input focus when the page loads.",
|
|
27
|
-
"value": {
|
|
28
|
-
"type": [
|
|
29
|
-
"boolean",
|
|
30
|
-
"null",
|
|
31
|
-
"undefined"
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
24
|
{
|
|
36
25
|
"name": "value",
|
|
37
26
|
"description": "The value of the field.",
|
|
@@ -52,6 +41,17 @@
|
|
|
52
41
|
]
|
|
53
42
|
}
|
|
54
43
|
},
|
|
44
|
+
{
|
|
45
|
+
"name": "autofocus",
|
|
46
|
+
"description": "Specify that this control should have input focus when the page loads.",
|
|
47
|
+
"value": {
|
|
48
|
+
"type": [
|
|
49
|
+
"boolean",
|
|
50
|
+
"null",
|
|
51
|
+
"undefined"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
55
|
{
|
|
56
56
|
"name": "label",
|
|
57
57
|
"description": "The label text for the input node.\nWhen no light dom defined via [slot=label], this value will be used.",
|
|
@@ -106,17 +106,6 @@
|
|
|
106
106
|
]
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
|
-
{
|
|
110
|
-
"name": "autofocus",
|
|
111
|
-
"description": "Specify that this control should have input focus when the page loads.",
|
|
112
|
-
"value": {
|
|
113
|
-
"type": [
|
|
114
|
-
"boolean",
|
|
115
|
-
"null",
|
|
116
|
-
"undefined"
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
109
|
{
|
|
121
110
|
"name": "value",
|
|
122
111
|
"description": "The value of the field.",
|
|
@@ -137,6 +126,17 @@
|
|
|
137
126
|
]
|
|
138
127
|
}
|
|
139
128
|
},
|
|
129
|
+
{
|
|
130
|
+
"name": "autofocus",
|
|
131
|
+
"description": "Specify that this control should have input focus when the page loads.",
|
|
132
|
+
"value": {
|
|
133
|
+
"type": [
|
|
134
|
+
"boolean",
|
|
135
|
+
"null",
|
|
136
|
+
"undefined"
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
140
|
{
|
|
141
141
|
"name": "label",
|
|
142
142
|
"description": "The label text for the input node.\nWhen no light dom defined via [slot=label], this value will be used.",
|
|
@@ -168,10 +168,6 @@
|
|
|
168
168
|
}
|
|
169
169
|
],
|
|
170
170
|
"events": [
|
|
171
|
-
{
|
|
172
|
-
"name": "indeterminate-changed",
|
|
173
|
-
"description": "Fired when the `indeterminate` property changes."
|
|
174
|
-
},
|
|
175
171
|
{
|
|
176
172
|
"name": "value-changed",
|
|
177
173
|
"description": "Fired when the `value` property changes."
|
|
@@ -179,6 +175,10 @@
|
|
|
179
175
|
{
|
|
180
176
|
"name": "checked-changed",
|
|
181
177
|
"description": "Fired when the `checked` property changes."
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"name": "indeterminate-changed",
|
|
181
|
+
"description": "Fired when the `indeterminate` property changes."
|
|
182
182
|
}
|
|
183
183
|
]
|
|
184
184
|
}
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/checkbox",
|
|
4
|
-
"version": "24.0.0-
|
|
4
|
+
"version": "24.0.0-beta2",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-checkbox",
|
|
19
|
-
"description": "`<vaadin-checkbox>` is an input field representing a binary choice.\n\n```html\n<vaadin-checkbox label=\"I accept the terms and conditions\"></vaadin-checkbox>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n
|
|
19
|
+
"description": "`<vaadin-checkbox>` is an input field representing a binary choice.\n\n```html\n<vaadin-checkbox label=\"I accept the terms and conditions\"></vaadin-checkbox>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n------------|-------------\n`checkbox` | The element representing a stylable custom checkbox.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n----------------|-------------\n`active` | Set when the checkbox is activated with mouse, touch or the keyboard.\n`checked` | Set when the checkbox is checked.\n`disabled` | Set when the checkbox is disabled.\n`focus-ring` | Set when the checkbox is focused using the keyboard.\n`focused` | Set when the checkbox is focused.\n`indeterminate` | Set when the checkbox is in the indeterminate state.\n`has-label` | Set when the checkbox has a label.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
|
-
"name": "?
|
|
31
|
-
"description": "
|
|
30
|
+
"name": "?checked",
|
|
31
|
+
"description": "True if the element is checked.",
|
|
32
32
|
"value": {
|
|
33
33
|
"kind": "expression"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
"name": "?
|
|
38
|
-
"description": "
|
|
37
|
+
"name": "?autofocus",
|
|
38
|
+
"description": "Specify that this control should have input focus when the page loads.",
|
|
39
39
|
"value": {
|
|
40
40
|
"kind": "expression"
|
|
41
41
|
}
|
|
@@ -69,22 +69,22 @@
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
|
-
"name": "@
|
|
73
|
-
"description": "Fired when the `
|
|
72
|
+
"name": "@value-changed",
|
|
73
|
+
"description": "Fired when the `value` property changes.",
|
|
74
74
|
"value": {
|
|
75
75
|
"kind": "expression"
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
|
-
"name": "@
|
|
80
|
-
"description": "Fired when the `
|
|
79
|
+
"name": "@checked-changed",
|
|
80
|
+
"description": "Fired when the `checked` property changes.",
|
|
81
81
|
"value": {
|
|
82
82
|
"kind": "expression"
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
|
-
"name": "@
|
|
87
|
-
"description": "Fired when the `
|
|
86
|
+
"name": "@indeterminate-changed",
|
|
87
|
+
"description": "Fired when the `indeterminate` property changes.",
|
|
88
88
|
"value": {
|
|
89
89
|
"kind": "expression"
|
|
90
90
|
}
|