@vaadin/field-base 23.3.3 → 24.0.0-alpha10
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/index.d.ts +0 -3
- package/index.js +0 -3
- package/package.json +3 -3
- package/src/checked-mixin.d.ts +2 -2
- package/src/checked-mixin.js +2 -2
- package/src/error-controller.d.ts +3 -8
- package/src/error-controller.js +53 -65
- package/src/field-aria-controller.d.ts +1 -1
- package/src/field-aria-controller.js +11 -11
- package/src/field-mixin.d.ts +1 -1
- package/src/field-mixin.js +24 -28
- package/src/helper-controller.d.ts +3 -5
- package/src/helper-controller.js +47 -147
- package/src/input-constraints-mixin.d.ts +2 -2
- package/src/input-constraints-mixin.js +2 -2
- package/src/input-control-mixin.d.ts +3 -3
- package/src/input-control-mixin.js +4 -4
- package/src/input-controller.d.ts +1 -1
- package/src/input-controller.js +5 -8
- package/src/input-field-mixin.d.ts +3 -3
- package/src/input-field-mixin.js +10 -10
- package/src/input-mixin.d.ts +1 -1
- package/src/input-mixin.js +17 -11
- package/src/label-controller.d.ts +3 -8
- package/src/label-controller.js +45 -149
- package/src/label-mixin.d.ts +1 -1
- package/src/label-mixin.js +13 -8
- package/src/labelled-input-controller.d.ts +1 -1
- package/src/labelled-input-controller.js +2 -2
- package/src/pattern-mixin.d.ts +3 -11
- package/src/pattern-mixin.js +2 -50
- package/src/slot-styles-mixin.d.ts +1 -1
- package/src/slot-styles-mixin.js +1 -1
- package/src/styles/clear-button-styles.d.ts +1 -1
- package/src/styles/clear-button-styles.js +1 -1
- package/src/styles/field-shared-styles.d.ts +1 -1
- package/src/styles/field-shared-styles.js +1 -1
- package/src/styles/input-field-container-styles.d.ts +1 -1
- package/src/styles/input-field-container-styles.js +1 -1
- package/src/styles/input-field-shared-styles.d.ts +1 -1
- package/src/styles/input-field-shared-styles.js +1 -1
- package/src/text-area-controller.d.ts +1 -1
- package/src/text-area-controller.js +5 -8
- package/src/validate-mixin.d.ts +1 -1
- package/src/validate-mixin.js +1 -1
- package/src/virtual-keyboard-controller.d.ts +1 -1
- package/src/virtual-keyboard-controller.js +1 -1
- package/src/delegate-focus-mixin.d.ts +0 -48
- package/src/delegate-focus-mixin.js +0 -228
- package/src/delegate-state-mixin.d.ts +0 -20
- package/src/delegate-state-mixin.js +0 -125
- package/src/shadow-focus-mixin.d.ts +0 -23
- package/src/shadow-focus-mixin.js +0 -97
- package/src/slot-target-controller.d.ts +0 -31
- package/src/slot-target-controller.js +0 -123
package/src/helper-controller.js
CHANGED
|
@@ -1,189 +1,89 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { SlotChildObserveController } from '@vaadin/component-base/src/slot-child-observe-controller.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A controller that manages the helper node content.
|
|
10
10
|
*/
|
|
11
|
-
export class HelperController extends
|
|
11
|
+
export class HelperController extends SlotChildObserveController {
|
|
12
12
|
constructor(host) {
|
|
13
|
-
// Do not provide
|
|
14
|
-
super(host, 'helper', null
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
get helperId() {
|
|
18
|
-
return this.node && this.node.id;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Override to initialize the newly added custom helper.
|
|
23
|
-
*
|
|
24
|
-
* @param {Node} helperNode
|
|
25
|
-
* @protected
|
|
26
|
-
* @override
|
|
27
|
-
*/
|
|
28
|
-
initCustomNode(helperNode) {
|
|
29
|
-
this.__updateHelperId(helperNode);
|
|
30
|
-
|
|
31
|
-
this.__observeHelper(helperNode);
|
|
32
|
-
|
|
33
|
-
const hasHelper = this.__hasHelper(helperNode);
|
|
34
|
-
this.__toggleHasHelper(hasHelper);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Override to cleanup helper node when it's removed.
|
|
39
|
-
*
|
|
40
|
-
* @param {Node} _node
|
|
41
|
-
* @protected
|
|
42
|
-
* @override
|
|
43
|
-
*/
|
|
44
|
-
teardownNode(_node) {
|
|
45
|
-
// The observer does not exist when the default helper is removed.
|
|
46
|
-
if (this.__helperIdObserver) {
|
|
47
|
-
this.__helperIdObserver.disconnect();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const helperNode = this.getSlotChild();
|
|
51
|
-
|
|
52
|
-
// Custom node is added to helper slot
|
|
53
|
-
if (helperNode && helperNode !== this.defaultNode) {
|
|
54
|
-
const hasHelper = this.__hasHelper(helperNode);
|
|
55
|
-
this.__toggleHasHelper(hasHelper);
|
|
56
|
-
} else {
|
|
57
|
-
// Restore default helper if needed
|
|
58
|
-
this.__applyDefaultHelper(this.helperText, helperNode);
|
|
59
|
-
}
|
|
13
|
+
// Do not provide tag name, as we create helper lazily.
|
|
14
|
+
super(host, 'helper', null);
|
|
60
15
|
}
|
|
61
16
|
|
|
62
17
|
/**
|
|
63
18
|
* Set helper text based on corresponding host property.
|
|
19
|
+
*
|
|
64
20
|
* @param {string} helperText
|
|
65
21
|
*/
|
|
66
22
|
setHelperText(helperText) {
|
|
67
23
|
this.helperText = helperText;
|
|
68
24
|
|
|
25
|
+
// Restore the default helper, if needed.
|
|
69
26
|
const helperNode = this.getSlotChild();
|
|
70
|
-
if (!helperNode || helperNode === this.defaultNode) {
|
|
71
|
-
this.__applyDefaultHelper(helperText, helperNode);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @param {HTMLElement} helperNode
|
|
77
|
-
* @return {boolean}
|
|
78
|
-
* @private
|
|
79
|
-
*/
|
|
80
|
-
__hasHelper(helperNode) {
|
|
81
27
|
if (!helperNode) {
|
|
82
|
-
|
|
28
|
+
this.restoreDefaultNode();
|
|
83
29
|
}
|
|
84
30
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* @param {string} helperText
|
|
94
|
-
* @private
|
|
95
|
-
*/
|
|
96
|
-
__isNotEmpty(helperText) {
|
|
97
|
-
return helperText && helperText.trim() !== '';
|
|
31
|
+
// When default helper is used, update it.
|
|
32
|
+
if (this.node === this.defaultNode) {
|
|
33
|
+
this.updateDefaultNode(this.node);
|
|
34
|
+
}
|
|
98
35
|
}
|
|
99
36
|
|
|
100
37
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
38
|
+
* Override method inherited from `SlotChildObserveController`
|
|
39
|
+
* to create the default helper element lazily as needed.
|
|
40
|
+
*
|
|
41
|
+
* @param {Node | undefined} node
|
|
42
|
+
* @protected
|
|
43
|
+
* @override
|
|
104
44
|
*/
|
|
105
|
-
|
|
106
|
-
const
|
|
45
|
+
restoreDefaultNode() {
|
|
46
|
+
const { helperText } = this;
|
|
107
47
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.
|
|
48
|
+
// No helper yet, create one.
|
|
49
|
+
if (helperText && helperText.trim() !== '') {
|
|
50
|
+
this.tagName = 'div';
|
|
111
51
|
|
|
112
|
-
helperNode = this.attachDefaultNode();
|
|
52
|
+
const helperNode = this.attachDefaultNode();
|
|
113
53
|
|
|
114
|
-
|
|
115
|
-
this.
|
|
54
|
+
// Observe the default node.
|
|
55
|
+
this.observeNode(helperNode);
|
|
116
56
|
}
|
|
117
|
-
|
|
118
|
-
if (helperNode) {
|
|
119
|
-
helperNode.textContent = helperText;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
this.__toggleHasHelper(hasHelperText);
|
|
123
57
|
}
|
|
124
58
|
|
|
125
59
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
60
|
+
* Override method inherited from `SlotChildObserveController`
|
|
61
|
+
* to update the default helper element text content.
|
|
62
|
+
*
|
|
63
|
+
* @param {Node | undefined} node
|
|
64
|
+
* @protected
|
|
65
|
+
* @override
|
|
128
66
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// Ensure the mutation target is the currently connected helper
|
|
135
|
-
// to ignore async mutations dispatched for removed element.
|
|
136
|
-
const isHelperMutation = target === this.node;
|
|
137
|
-
|
|
138
|
-
if (mutation.type === 'attributes') {
|
|
139
|
-
// We use attributeFilter to only observe ID mutation,
|
|
140
|
-
// no need to check for attribute name separately.
|
|
141
|
-
if (isHelperMutation && target.id !== this.defaultId) {
|
|
142
|
-
this.__updateHelperId(target);
|
|
143
|
-
}
|
|
144
|
-
} else if (isHelperMutation || target.parentElement === this.node) {
|
|
145
|
-
// Update has-helper when textContent changes
|
|
146
|
-
const hasHelper = this.__hasHelper(this.node);
|
|
147
|
-
this.__toggleHasHelper(hasHelper);
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
});
|
|
67
|
+
updateDefaultNode(node) {
|
|
68
|
+
if (node) {
|
|
69
|
+
node.textContent = this.helperText;
|
|
70
|
+
}
|
|
151
71
|
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
attributes: true,
|
|
155
|
-
attributeFilter: ['id'],
|
|
156
|
-
childList: true,
|
|
157
|
-
subtree: true,
|
|
158
|
-
characterData: true,
|
|
159
|
-
});
|
|
72
|
+
// Notify the host after update.
|
|
73
|
+
super.updateDefaultNode(node);
|
|
160
74
|
}
|
|
161
75
|
|
|
162
76
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
77
|
+
* Override to observe the newly added custom node.
|
|
78
|
+
*
|
|
79
|
+
* @param {Node} node
|
|
80
|
+
* @protected
|
|
81
|
+
* @override
|
|
165
82
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
// Make it possible for other mixins to observe change
|
|
170
|
-
this.dispatchEvent(
|
|
171
|
-
new CustomEvent('helper-changed', {
|
|
172
|
-
detail: {
|
|
173
|
-
hasHelper,
|
|
174
|
-
node: this.node,
|
|
175
|
-
},
|
|
176
|
-
}),
|
|
177
|
-
);
|
|
178
|
-
}
|
|
83
|
+
initCustomNode(node) {
|
|
84
|
+
// Notify the host about a custom slotted helper.
|
|
85
|
+
super.initCustomNode(node);
|
|
179
86
|
|
|
180
|
-
|
|
181
|
-
* @param {HTMLElement} helperNode
|
|
182
|
-
* @private
|
|
183
|
-
*/
|
|
184
|
-
__updateHelperId(helperNode) {
|
|
185
|
-
if (!helperNode.id) {
|
|
186
|
-
helperNode.id = this.defaultId;
|
|
187
|
-
}
|
|
87
|
+
this.observeNode(node);
|
|
188
88
|
}
|
|
189
89
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
-
import type { DelegateStateMixinClass } from '
|
|
7
|
+
import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
|
|
8
8
|
import type { InputMixinClass } from './input-mixin.js';
|
|
9
9
|
import type { ValidateMixinClass } from './validate-mixin.js';
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
7
|
-
import { DelegateStateMixin } from '
|
|
7
|
+
import { DelegateStateMixin } from '@vaadin/component-base/src/delegate-state-mixin.js';
|
|
8
8
|
import { InputMixin } from './input-mixin.js';
|
|
9
9
|
import { ValidateMixin } from './validate-mixin.js';
|
|
10
10
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
8
|
+
import type { DelegateFocusMixinClass } from '@vaadin/component-base/src/delegate-focus-mixin.js';
|
|
9
|
+
import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
|
|
8
10
|
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
9
11
|
import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
10
12
|
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
11
|
-
import type { DelegateFocusMixinClass } from './delegate-focus-mixin.js';
|
|
12
|
-
import type { DelegateStateMixinClass } from './delegate-state-mixin.js';
|
|
13
13
|
import type { FieldMixinClass } from './field-mixin.js';
|
|
14
14
|
import type { InputConstraintsMixinClass } from './input-constraints-mixin.js';
|
|
15
15
|
import type { InputMixinClass } from './input-mixin.js';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
7
7
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
8
|
+
import { DelegateFocusMixin } from '@vaadin/component-base/src/delegate-focus-mixin.js';
|
|
8
9
|
import { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
9
|
-
import { DelegateFocusMixin } from './delegate-focus-mixin.js';
|
|
10
10
|
import { FieldMixin } from './field-mixin.js';
|
|
11
11
|
import { InputConstraintsMixin } from './input-constraints-mixin.js';
|
|
12
12
|
import { SlotStylesMixin } from './slot-styles-mixin.js';
|
|
@@ -315,8 +315,8 @@ export const InputControlMixin = (superclass) =>
|
|
|
315
315
|
_allowedCharPatternChanged(charPattern) {
|
|
316
316
|
if (charPattern) {
|
|
317
317
|
try {
|
|
318
|
-
this.__allowedCharRegExp = new RegExp(`^${charPattern}
|
|
319
|
-
this.__allowedTextRegExp = new RegExp(`^${charPattern}
|
|
318
|
+
this.__allowedCharRegExp = new RegExp(`^${charPattern}$`, 'u');
|
|
319
|
+
this.__allowedTextRegExp = new RegExp(`^${charPattern}*$`, 'u');
|
|
320
320
|
} catch (e) {
|
|
321
321
|
console.error(e);
|
|
322
322
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
package/src/input-controller.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
@@ -10,11 +10,8 @@ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
|
10
10
|
*/
|
|
11
11
|
export class InputController extends SlotController {
|
|
12
12
|
constructor(host, callback) {
|
|
13
|
-
super(
|
|
14
|
-
host
|
|
15
|
-
'input',
|
|
16
|
-
() => document.createElement('input'),
|
|
17
|
-
(host, node) => {
|
|
13
|
+
super(host, 'input', 'input', {
|
|
14
|
+
initializer: (node, host) => {
|
|
18
15
|
if (host.value) {
|
|
19
16
|
node.setAttribute('value', host.value);
|
|
20
17
|
}
|
|
@@ -29,7 +26,7 @@ export class InputController extends SlotController {
|
|
|
29
26
|
callback(node);
|
|
30
27
|
}
|
|
31
28
|
},
|
|
32
|
-
true,
|
|
33
|
-
);
|
|
29
|
+
useUniqueId: true,
|
|
30
|
+
});
|
|
34
31
|
}
|
|
35
32
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
8
|
+
import type { DelegateFocusMixinClass } from '@vaadin/component-base/src/delegate-focus-mixin.js';
|
|
9
|
+
import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
|
|
8
10
|
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
9
11
|
import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
10
12
|
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
11
|
-
import type { DelegateFocusMixinClass } from './delegate-focus-mixin.js';
|
|
12
|
-
import type { DelegateStateMixinClass } from './delegate-state-mixin.js';
|
|
13
13
|
import type { FieldMixinClass } from './field-mixin.js';
|
|
14
14
|
import type { InputConstraintsMixinClass } from './input-constraints-mixin.js';
|
|
15
15
|
import type { InputControlMixinClass } from './input-control-mixin.js';
|
package/src/input-field-mixin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { InputControlMixin } from './input-control-mixin.js';
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
package/src/input-mixin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
@@ -72,11 +72,27 @@ 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
|
*/
|
|
78
88
|
clear() {
|
|
79
89
|
this.value = '';
|
|
90
|
+
|
|
91
|
+
// Clear the input immediately without waiting for the observer.
|
|
92
|
+
// Otherwise, when using Lit, the old value would be restored.
|
|
93
|
+
if (this.inputElement) {
|
|
94
|
+
this.inputElement.value = '';
|
|
95
|
+
}
|
|
80
96
|
}
|
|
81
97
|
|
|
82
98
|
/**
|
|
@@ -217,16 +233,6 @@ export const InputMixin = dedupingMixin(
|
|
|
217
233
|
this._forwardInputValue(newVal);
|
|
218
234
|
}
|
|
219
235
|
|
|
220
|
-
/**
|
|
221
|
-
* Indicates whether the value is different from the default one.
|
|
222
|
-
* Override if the `value` property has a type other than `string`.
|
|
223
|
-
*
|
|
224
|
-
* @protected
|
|
225
|
-
*/
|
|
226
|
-
get _hasValue() {
|
|
227
|
-
return this.value != null && this.value !== '';
|
|
228
|
-
}
|
|
229
|
-
|
|
230
236
|
/**
|
|
231
237
|
* Sets the `_hasInputValue` property based on the `input` event.
|
|
232
238
|
*
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { SlotChildObserveController } from '@vaadin/component-base/src/slot-child-observe-controller.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A controller to manage the label element.
|
|
10
10
|
*/
|
|
11
|
-
export class LabelController extends
|
|
12
|
-
/**
|
|
13
|
-
* ID attribute value set on the label element.
|
|
14
|
-
*/
|
|
15
|
-
labelId: string;
|
|
16
|
-
|
|
11
|
+
export class LabelController extends SlotChildObserveController {
|
|
17
12
|
/**
|
|
18
13
|
* String used for the label.
|
|
19
14
|
*/
|