@vaadin/field-base 24.0.0-alpha9 → 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 +4 -4
- package/src/clear-button-mixin.d.ts +36 -0
- package/src/clear-button-mixin.js +100 -0
- package/src/field-aria-controller.js +10 -10
- package/src/field-mixin.js +16 -16
- package/src/input-control-mixin.d.ts +3 -7
- package/src/input-control-mixin.js +3 -65
- package/src/input-field-mixin.d.ts +3 -1
- package/src/input-field-mixin.js +9 -9
- package/src/input-mixin.d.ts +2 -2
- package/src/input-mixin.js +10 -10
- package/src/label-mixin.js +10 -10
- package/src/styles/clear-button-styles.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/field-base",
|
|
3
|
-
"version": "24.0.0-
|
|
3
|
+
"version": "24.0.0-beta2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
34
34
|
"@polymer/polymer": "^3.0.0",
|
|
35
|
-
"@vaadin/component-base": "24.0.0-
|
|
35
|
+
"@vaadin/component-base": "24.0.0-beta2",
|
|
36
36
|
"lit": "^2.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@esm-bundle/chai": "^4.3.4",
|
|
40
|
-
"@vaadin/testing-helpers": "^0.
|
|
40
|
+
"@vaadin/testing-helpers": "^0.4.0",
|
|
41
41
|
"sinon": "^13.0.2"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "00086f1f6d487f042f189c9b9ecd7ba736960888"
|
|
44
44
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
8
|
+
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
9
|
+
import type { InputMixinClass } from './input-mixin.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A mixin that manages the clear button.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ClearButtonMixin<T extends Constructor<HTMLElement>>(
|
|
15
|
+
base: T,
|
|
16
|
+
): Constructor<ClearButtonMixinClass> & Constructor<InputMixinClass> & Constructor<KeyboardMixinClass> & T;
|
|
17
|
+
|
|
18
|
+
export declare class ClearButtonMixinClass {
|
|
19
|
+
/**
|
|
20
|
+
* Set to true to display the clear icon which clears the input.
|
|
21
|
+
*
|
|
22
|
+
* It is up to the component to choose where to place the clear icon:
|
|
23
|
+
* in the Shadow DOM or in the light DOM. In any way, a reference to
|
|
24
|
+
* the clear icon element should be provided via the `clearElement` getter.
|
|
25
|
+
*
|
|
26
|
+
* @attr {boolean} clear-button-visible
|
|
27
|
+
*/
|
|
28
|
+
clearButtonVisible: boolean;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Clears the value and dispatches `input` and `change` events
|
|
32
|
+
* on the input element. This method should be called
|
|
33
|
+
* when the clear action originates from the user.
|
|
34
|
+
*/
|
|
35
|
+
protected _onClearAction(): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
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 { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
7
|
+
import { InputMixin } from './input-mixin.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A mixin that manages the clear button.
|
|
11
|
+
*
|
|
12
|
+
* @polymerMixin
|
|
13
|
+
* @mixes InputMixin
|
|
14
|
+
* @mixes KeyboardMixin
|
|
15
|
+
*/
|
|
16
|
+
export const ClearButtonMixin = (superclass) =>
|
|
17
|
+
class ClearButtonMixinClass extends InputMixin(KeyboardMixin(superclass)) {
|
|
18
|
+
static get properties() {
|
|
19
|
+
return {
|
|
20
|
+
/**
|
|
21
|
+
* Set to true to display the clear icon which clears the input.
|
|
22
|
+
*
|
|
23
|
+
* It is up to the component to choose where to place the clear icon:
|
|
24
|
+
* in the Shadow DOM or in the light DOM. In any way, a reference to
|
|
25
|
+
* the clear icon element should be provided via the `clearElement` getter.
|
|
26
|
+
*
|
|
27
|
+
* @attr {boolean} clear-button-visible
|
|
28
|
+
*/
|
|
29
|
+
clearButtonVisible: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
reflectToAttribute: true,
|
|
32
|
+
value: false,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Any element extending this mixin is required to implement this getter.
|
|
39
|
+
* It returns the reference to the clear button element.
|
|
40
|
+
*
|
|
41
|
+
* @protected
|
|
42
|
+
* @return {Element | null | undefined}
|
|
43
|
+
*/
|
|
44
|
+
get clearElement() {
|
|
45
|
+
console.warn(`Please implement the 'clearElement' property in <${this.localName}>`);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** @protected */
|
|
50
|
+
ready() {
|
|
51
|
+
super.ready();
|
|
52
|
+
|
|
53
|
+
if (this.clearElement) {
|
|
54
|
+
this.clearElement.addEventListener('click', (event) => this._onClearButtonClick(event));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {Event} event
|
|
60
|
+
* @protected
|
|
61
|
+
*/
|
|
62
|
+
_onClearButtonClick(event) {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
this.inputElement.focus();
|
|
65
|
+
this._onClearAction();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Override an event listener inherited from `KeydownMixin` to clear on Esc.
|
|
70
|
+
* Components that extend this mixin can prevent this behavior by overriding
|
|
71
|
+
* this method without calling `super._onEscape` to provide custom logic.
|
|
72
|
+
*
|
|
73
|
+
* @param {KeyboardEvent} event
|
|
74
|
+
* @protected
|
|
75
|
+
* @override
|
|
76
|
+
*/
|
|
77
|
+
_onEscape(event) {
|
|
78
|
+
super._onEscape(event);
|
|
79
|
+
|
|
80
|
+
if (this.clearButtonVisible && !!this.value) {
|
|
81
|
+
event.stopPropagation();
|
|
82
|
+
this._onClearAction();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Clears the value and dispatches `input` and `change` events
|
|
88
|
+
* on the input element. This method should be called
|
|
89
|
+
* when the clear action originates from the user.
|
|
90
|
+
*
|
|
91
|
+
* @protected
|
|
92
|
+
*/
|
|
93
|
+
_onClearAction() {
|
|
94
|
+
this.clear();
|
|
95
|
+
// Note, according to the HTML spec, the native change event isn't composed
|
|
96
|
+
// while the input event is composed.
|
|
97
|
+
this.inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
98
|
+
this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
|
|
99
|
+
}
|
|
100
|
+
};
|
|
@@ -15,6 +15,16 @@ export class FieldAriaController {
|
|
|
15
15
|
this.__required = false;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* `true` if the target element is the host component itself, `false` otherwise.
|
|
20
|
+
*
|
|
21
|
+
* @return {boolean}
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
get __isGroupField() {
|
|
25
|
+
return this.__target === this.host;
|
|
26
|
+
}
|
|
27
|
+
|
|
18
28
|
/**
|
|
19
29
|
* Sets a target element to which ARIA attributes are added.
|
|
20
30
|
*
|
|
@@ -81,16 +91,6 @@ export class FieldAriaController {
|
|
|
81
91
|
this.__helperId = helperId;
|
|
82
92
|
}
|
|
83
93
|
|
|
84
|
-
/**
|
|
85
|
-
* `true` if the target element is the host component itself, `false` otherwise.
|
|
86
|
-
*
|
|
87
|
-
* @return {boolean}
|
|
88
|
-
* @private
|
|
89
|
-
*/
|
|
90
|
-
get __isGroupField() {
|
|
91
|
-
return this.__target === this.host;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
94
|
/**
|
|
95
95
|
* @param {string | null | undefined} labelId
|
|
96
96
|
* @param {string | null | undefined} oldLabelId
|
package/src/field-mixin.js
CHANGED
|
@@ -56,22 +56,6 @@ export const FieldMixin = (superclass) =>
|
|
|
56
56
|
return ['_invalidChanged(invalid)', '_requiredChanged(required)'];
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
/**
|
|
60
|
-
* @protected
|
|
61
|
-
* @return {HTMLElement}
|
|
62
|
-
*/
|
|
63
|
-
get _errorNode() {
|
|
64
|
-
return this._errorController.node;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @protected
|
|
69
|
-
* @return {HTMLElement}
|
|
70
|
-
*/
|
|
71
|
-
get _helperNode() {
|
|
72
|
-
return this._helperController.node;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
59
|
constructor() {
|
|
76
60
|
super();
|
|
77
61
|
|
|
@@ -95,6 +79,22 @@ export const FieldMixin = (superclass) =>
|
|
|
95
79
|
});
|
|
96
80
|
}
|
|
97
81
|
|
|
82
|
+
/**
|
|
83
|
+
* @protected
|
|
84
|
+
* @return {HTMLElement}
|
|
85
|
+
*/
|
|
86
|
+
get _errorNode() {
|
|
87
|
+
return this._errorController.node;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @protected
|
|
92
|
+
* @return {HTMLElement}
|
|
93
|
+
*/
|
|
94
|
+
get _helperNode() {
|
|
95
|
+
return this._helperController.node;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
98
|
/** @protected */
|
|
99
99
|
ready() {
|
|
100
100
|
super.ready();
|
|
@@ -10,6 +10,7 @@ import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegat
|
|
|
10
10
|
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
11
11
|
import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
12
12
|
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
13
|
+
import type { ClearButtonMixinClass } from './clear-button-mixin.js';
|
|
13
14
|
import type { FieldMixinClass } from './field-mixin.js';
|
|
14
15
|
import type { InputConstraintsMixinClass } from './input-constraints-mixin.js';
|
|
15
16
|
import type { InputMixinClass } from './input-mixin.js';
|
|
@@ -22,7 +23,8 @@ import type { ValidateMixinClass } from './validate-mixin.js';
|
|
|
22
23
|
*/
|
|
23
24
|
export declare function InputControlMixin<T extends Constructor<HTMLElement>>(
|
|
24
25
|
base: T,
|
|
25
|
-
): Constructor<
|
|
26
|
+
): Constructor<ClearButtonMixinClass> &
|
|
27
|
+
Constructor<ControllerMixinClass> &
|
|
26
28
|
Constructor<DelegateFocusMixinClass> &
|
|
27
29
|
Constructor<DelegateStateMixinClass> &
|
|
28
30
|
Constructor<DisabledMixinClass> &
|
|
@@ -57,12 +59,6 @@ export declare class InputControlMixinClass {
|
|
|
57
59
|
*/
|
|
58
60
|
autoselect: boolean;
|
|
59
61
|
|
|
60
|
-
/**
|
|
61
|
-
* Set to true to display the clear icon which clears the input.
|
|
62
|
-
* @attr {boolean} clear-button-visible
|
|
63
|
-
*/
|
|
64
|
-
clearButtonVisible: boolean;
|
|
65
|
-
|
|
66
62
|
/**
|
|
67
63
|
* The name of this field.
|
|
68
64
|
*/
|
|
@@ -7,6 +7,7 @@ import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
|
7
7
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
8
8
|
import { DelegateFocusMixin } from '@vaadin/component-base/src/delegate-focus-mixin.js';
|
|
9
9
|
import { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
10
|
+
import { ClearButtonMixin } from './clear-button-mixin.js';
|
|
10
11
|
import { FieldMixin } from './field-mixin.js';
|
|
11
12
|
import { InputConstraintsMixin } from './input-constraints-mixin.js';
|
|
12
13
|
import { SlotStylesMixin } from './slot-styles-mixin.js';
|
|
@@ -19,11 +20,12 @@ import { SlotStylesMixin } from './slot-styles-mixin.js';
|
|
|
19
20
|
* @mixes FieldMixin
|
|
20
21
|
* @mixes InputConstraintsMixin
|
|
21
22
|
* @mixes KeyboardMixin
|
|
23
|
+
* @mixes ClearButtonMixin
|
|
22
24
|
* @mixes SlotStylesMixin
|
|
23
25
|
*/
|
|
24
26
|
export const InputControlMixin = (superclass) =>
|
|
25
27
|
class InputControlMixinClass extends SlotStylesMixin(
|
|
26
|
-
DelegateFocusMixin(InputConstraintsMixin(FieldMixin(KeyboardMixin(superclass)))),
|
|
28
|
+
DelegateFocusMixin(InputConstraintsMixin(FieldMixin(ClearButtonMixin(KeyboardMixin(superclass))))),
|
|
27
29
|
) {
|
|
28
30
|
static get properties() {
|
|
29
31
|
return {
|
|
@@ -52,16 +54,6 @@ export const InputControlMixin = (superclass) =>
|
|
|
52
54
|
value: false,
|
|
53
55
|
},
|
|
54
56
|
|
|
55
|
-
/**
|
|
56
|
-
* Set to true to display the clear icon which clears the input.
|
|
57
|
-
* @attr {boolean} clear-button-visible
|
|
58
|
-
*/
|
|
59
|
-
clearButtonVisible: {
|
|
60
|
-
type: Boolean,
|
|
61
|
-
reflectToAttribute: true,
|
|
62
|
-
value: false,
|
|
63
|
-
},
|
|
64
|
-
|
|
65
57
|
/**
|
|
66
58
|
* The name of this field.
|
|
67
59
|
*/
|
|
@@ -109,17 +101,6 @@ export const InputControlMixin = (superclass) =>
|
|
|
109
101
|
this._boundOnBeforeInput = this._onBeforeInput.bind(this);
|
|
110
102
|
}
|
|
111
103
|
|
|
112
|
-
/**
|
|
113
|
-
* Any element extending this mixin is required to implement this getter.
|
|
114
|
-
* It returns the reference to the clear button element.
|
|
115
|
-
* @protected
|
|
116
|
-
* @return {Element | null | undefined}
|
|
117
|
-
*/
|
|
118
|
-
get clearElement() {
|
|
119
|
-
console.warn(`Please implement the 'clearElement' property in <${this.localName}>`);
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
104
|
/** @protected */
|
|
124
105
|
get slotStyles() {
|
|
125
106
|
// Needed for Safari, where ::slotted(...)::placeholder does not work
|
|
@@ -133,25 +114,6 @@ export const InputControlMixin = (superclass) =>
|
|
|
133
114
|
];
|
|
134
115
|
}
|
|
135
116
|
|
|
136
|
-
/** @protected */
|
|
137
|
-
ready() {
|
|
138
|
-
super.ready();
|
|
139
|
-
|
|
140
|
-
if (this.clearElement) {
|
|
141
|
-
this.clearElement.addEventListener('click', (e) => this._onClearButtonClick(e));
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @param {Event} event
|
|
147
|
-
* @protected
|
|
148
|
-
*/
|
|
149
|
-
_onClearButtonClick(event) {
|
|
150
|
-
event.preventDefault();
|
|
151
|
-
this.inputElement.focus();
|
|
152
|
-
this.__clear();
|
|
153
|
-
}
|
|
154
|
-
|
|
155
117
|
/**
|
|
156
118
|
* Override an event listener from `DelegateFocusMixin`.
|
|
157
119
|
* @param {FocusEvent} event
|
|
@@ -166,23 +128,6 @@ export const InputControlMixin = (superclass) =>
|
|
|
166
128
|
}
|
|
167
129
|
}
|
|
168
130
|
|
|
169
|
-
/**
|
|
170
|
-
* Override an event listener inherited from `KeydownMixin` to clear on Esc.
|
|
171
|
-
* Components that extend this mixin can prevent this behavior by overriding
|
|
172
|
-
* this method without calling `super._onEscape` to provide custom logic.
|
|
173
|
-
* @param {KeyboardEvent} event
|
|
174
|
-
* @protected
|
|
175
|
-
* @override
|
|
176
|
-
*/
|
|
177
|
-
_onEscape(event) {
|
|
178
|
-
super._onEscape(event);
|
|
179
|
-
|
|
180
|
-
if (this.clearButtonVisible && !!this.value) {
|
|
181
|
-
event.stopPropagation();
|
|
182
|
-
this.__clear();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
131
|
/**
|
|
187
132
|
* Override an event listener inherited from `InputMixin`
|
|
188
133
|
* to capture native `change` event and make sure that
|
|
@@ -207,13 +152,6 @@ export const InputControlMixin = (superclass) =>
|
|
|
207
152
|
);
|
|
208
153
|
}
|
|
209
154
|
|
|
210
|
-
/** @private */
|
|
211
|
-
__clear() {
|
|
212
|
-
this.clear();
|
|
213
|
-
this.inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
214
|
-
this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
|
|
215
|
-
}
|
|
216
|
-
|
|
217
155
|
/**
|
|
218
156
|
* Override a method from `InputMixin`.
|
|
219
157
|
* @param {!HTMLElement} input
|
|
@@ -10,6 +10,7 @@ import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegat
|
|
|
10
10
|
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
11
11
|
import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
12
12
|
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
13
|
+
import type { ClearButtonMixinClass } from './clear-button-mixin.js';
|
|
13
14
|
import type { FieldMixinClass } from './field-mixin.js';
|
|
14
15
|
import type { InputConstraintsMixinClass } from './input-constraints-mixin.js';
|
|
15
16
|
import type { InputControlMixinClass } from './input-control-mixin.js';
|
|
@@ -23,7 +24,8 @@ import type { ValidateMixinClass } from './validate-mixin.js';
|
|
|
23
24
|
*/
|
|
24
25
|
export declare function InputFieldMixin<T extends Constructor<HTMLElement>>(
|
|
25
26
|
base: T,
|
|
26
|
-
): Constructor<
|
|
27
|
+
): Constructor<ClearButtonMixinClass> &
|
|
28
|
+
Constructor<ControllerMixinClass> &
|
|
27
29
|
Constructor<DelegateFocusMixinClass> &
|
|
28
30
|
Constructor<DelegateStateMixinClass> &
|
|
29
31
|
Constructor<DisabledMixinClass> &
|
package/src/input-field-mixin.js
CHANGED
|
@@ -55,6 +55,15 @@ export const InputFieldMixin = (superclass) =>
|
|
|
55
55
|
return [...super.delegateAttrs, 'autocapitalize', 'autocomplete', 'autocorrect'];
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
// Workaround for https://github.com/Polymer/polymer/issues/5259
|
|
59
|
+
get __data() {
|
|
60
|
+
return this.__dataValue || {};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
set __data(value) {
|
|
64
|
+
this.__dataValue = value;
|
|
65
|
+
}
|
|
66
|
+
|
|
58
67
|
/**
|
|
59
68
|
* @param {HTMLElement} input
|
|
60
69
|
* @protected
|
|
@@ -76,15 +85,6 @@ export const InputFieldMixin = (superclass) =>
|
|
|
76
85
|
}
|
|
77
86
|
}
|
|
78
87
|
|
|
79
|
-
// Workaround for https://github.com/Polymer/polymer/issues/5259
|
|
80
|
-
get __data() {
|
|
81
|
-
return this.__dataValue || {};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
set __data(value) {
|
|
85
|
-
this.__dataValue = value;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
88
|
/**
|
|
89
89
|
* Override an event listener from `FocusMixin`.
|
|
90
90
|
* @param {boolean} focused
|
package/src/input-mixin.d.ts
CHANGED
|
@@ -47,9 +47,9 @@ export declare class InputMixinClass {
|
|
|
47
47
|
|
|
48
48
|
protected _inputElementChanged(input: HTMLElement, oldInput: HTMLElement): void;
|
|
49
49
|
|
|
50
|
-
protected _onChange(event:
|
|
50
|
+
protected _onChange(event: Event): void;
|
|
51
51
|
|
|
52
|
-
protected _onInput(event:
|
|
52
|
+
protected _onInput(event: Event): void;
|
|
53
53
|
|
|
54
54
|
protected _setInputElement(input: HTMLElement): void;
|
|
55
55
|
|
package/src/input-mixin.js
CHANGED
|
@@ -72,6 +72,16 @@ export const InputMixin = dedupingMixin(
|
|
|
72
72
|
this._boundOnChange = this._onChange.bind(this);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Indicates whether the value is different from the default one.
|
|
77
|
+
* Override if the `value` property has a type other than `string`.
|
|
78
|
+
*
|
|
79
|
+
* @protected
|
|
80
|
+
*/
|
|
81
|
+
get _hasValue() {
|
|
82
|
+
return this.value != null && this.value !== '';
|
|
83
|
+
}
|
|
84
|
+
|
|
75
85
|
/**
|
|
76
86
|
* Clear the value of the field.
|
|
77
87
|
*/
|
|
@@ -223,16 +233,6 @@ export const InputMixin = dedupingMixin(
|
|
|
223
233
|
this._forwardInputValue(newVal);
|
|
224
234
|
}
|
|
225
235
|
|
|
226
|
-
/**
|
|
227
|
-
* Indicates whether the value is different from the default one.
|
|
228
|
-
* Override if the `value` property has a type other than `string`.
|
|
229
|
-
*
|
|
230
|
-
* @protected
|
|
231
|
-
*/
|
|
232
|
-
get _hasValue() {
|
|
233
|
-
return this.value != null && this.value !== '';
|
|
234
|
-
}
|
|
235
|
-
|
|
236
236
|
/**
|
|
237
237
|
* Sets the `_hasInputValue` property based on the `input` event.
|
|
238
238
|
*
|
package/src/label-mixin.js
CHANGED
|
@@ -29,6 +29,16 @@ export const LabelMixin = dedupingMixin(
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
constructor() {
|
|
33
|
+
super();
|
|
34
|
+
|
|
35
|
+
this._labelController = new LabelController(this);
|
|
36
|
+
|
|
37
|
+
this._labelController.addEventListener('slot-content-changed', (event) => {
|
|
38
|
+
this.toggleAttribute('has-label', event.detail.hasContent);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
32
42
|
/** @protected */
|
|
33
43
|
get _labelId() {
|
|
34
44
|
const node = this._labelNode;
|
|
@@ -40,16 +50,6 @@ export const LabelMixin = dedupingMixin(
|
|
|
40
50
|
return this._labelController.node;
|
|
41
51
|
}
|
|
42
52
|
|
|
43
|
-
constructor() {
|
|
44
|
-
super();
|
|
45
|
-
|
|
46
|
-
this._labelController = new LabelController(this);
|
|
47
|
-
|
|
48
|
-
this._labelController.addEventListener('slot-content-changed', (event) => {
|
|
49
|
-
this.toggleAttribute('has-label', event.detail.hasContent);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
53
|
/** @protected */
|
|
54
54
|
ready() {
|
|
55
55
|
super.ready();
|