@vaadin/field-base 23.3.0-alpha5 → 24.0.0-alpha2
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 +3 -3
- package/src/input-mixin.js +6 -0
- package/src/pattern-mixin.d.ts +1 -9
- package/src/pattern-mixin.js +1 -49
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/field-base",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "24.0.0-alpha2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
34
34
|
"@polymer/polymer": "^3.0.0",
|
|
35
|
-
"@vaadin/component-base": "
|
|
35
|
+
"@vaadin/component-base": "24.0.0-alpha2",
|
|
36
36
|
"lit": "^2.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
41
41
|
"sinon": "^13.0.2"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "0c16c01a6807e629a84f5a982793afecc1a7ced0"
|
|
44
44
|
}
|
package/src/input-mixin.js
CHANGED
|
@@ -77,6 +77,12 @@ export const InputMixin = dedupingMixin(
|
|
|
77
77
|
*/
|
|
78
78
|
clear() {
|
|
79
79
|
this.value = '';
|
|
80
|
+
|
|
81
|
+
// Clear the input immediately without waiting for the observer.
|
|
82
|
+
// Otherwise, when using Lit, the old value would be restored.
|
|
83
|
+
if (this.inputElement) {
|
|
84
|
+
this.inputElement.value = '';
|
|
85
|
+
}
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
/**
|
package/src/pattern-mixin.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { InputMixinClass } from './input-mixin.js';
|
|
|
11
11
|
import type { ValidateMixinClass } from './validate-mixin.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* A mixin to provide `pattern`
|
|
14
|
+
* A mixin to provide `pattern` property.
|
|
15
15
|
*/
|
|
16
16
|
export declare function PatternMixin<T extends Constructor<HTMLElement>>(
|
|
17
17
|
base: T,
|
|
@@ -29,12 +29,4 @@ export declare class PatternMixinClass {
|
|
|
29
29
|
* The pattern must match the entire value, not just some subset.
|
|
30
30
|
*/
|
|
31
31
|
pattern: string;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* When set to true, user is prevented from typing a value that
|
|
35
|
-
* conflicts with the given `pattern`.
|
|
36
|
-
* @attr {boolean} prevent-invalid-input
|
|
37
|
-
* @deprecated Please use `allowedCharPattern` instead.
|
|
38
|
-
*/
|
|
39
|
-
preventInvalidInput: boolean | null | undefined;
|
|
40
32
|
}
|
package/src/pattern-mixin.js
CHANGED
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
7
|
-
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
8
6
|
import { InputConstraintsMixin } from './input-constraints-mixin.js';
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
|
-
* A mixin to provide `pattern`
|
|
9
|
+
* A mixin to provide `pattern` property.
|
|
12
10
|
*
|
|
13
11
|
* @polymerMixin
|
|
14
12
|
* @mixes InputConstraintsMixin
|
|
@@ -24,17 +22,6 @@ export const PatternMixin = (superclass) =>
|
|
|
24
22
|
pattern: {
|
|
25
23
|
type: String,
|
|
26
24
|
},
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* When set to true, user is prevented from typing a value that
|
|
30
|
-
* conflicts with the given `pattern`.
|
|
31
|
-
* @attr {boolean} prevent-invalid-input
|
|
32
|
-
* @deprecated Please use `allowedCharPattern` instead.
|
|
33
|
-
*/
|
|
34
|
-
preventInvalidInput: {
|
|
35
|
-
type: Boolean,
|
|
36
|
-
observer: '_preventInvalidInputChanged',
|
|
37
|
-
},
|
|
38
25
|
};
|
|
39
26
|
}
|
|
40
27
|
|
|
@@ -45,39 +32,4 @@ export const PatternMixin = (superclass) =>
|
|
|
45
32
|
static get constraints() {
|
|
46
33
|
return [...super.constraints, 'pattern'];
|
|
47
34
|
}
|
|
48
|
-
|
|
49
|
-
/** @private */
|
|
50
|
-
_checkInputValue() {
|
|
51
|
-
if (this.preventInvalidInput) {
|
|
52
|
-
const input = this.inputElement;
|
|
53
|
-
if (input && input.value.length > 0 && !this.checkValidity()) {
|
|
54
|
-
input.value = this.value || '';
|
|
55
|
-
// Add input-prevented attribute for 200ms
|
|
56
|
-
this.setAttribute('input-prevented', '');
|
|
57
|
-
this._inputDebouncer = Debouncer.debounce(this._inputDebouncer, timeOut.after(200), () => {
|
|
58
|
-
this.removeAttribute('input-prevented');
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {Event} event
|
|
66
|
-
* @protected
|
|
67
|
-
* @override
|
|
68
|
-
*/
|
|
69
|
-
_onInput(event) {
|
|
70
|
-
this._checkInputValue();
|
|
71
|
-
|
|
72
|
-
super._onInput(event);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** @private */
|
|
76
|
-
_preventInvalidInputChanged(preventInvalidInput) {
|
|
77
|
-
if (preventInvalidInput) {
|
|
78
|
-
console.warn(
|
|
79
|
-
`WARNING: Since Vaadin 23.2, "preventInvalidInput" is deprecated. Please use "allowedCharPattern" instead.`,
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
35
|
};
|