@vaadin/field-base 22.0.0-alpha3 → 22.0.0-alpha7
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 +9 -14
- package/index.js +9 -14
- package/package.json +24 -18
- package/src/aria-label-controller.d.ts +11 -0
- package/src/aria-label-controller.js +53 -0
- package/src/checked-mixin.d.ts +21 -0
- package/src/checked-mixin.js +54 -0
- package/src/delegate-focus-mixin.d.ts +2 -2
- package/src/delegate-focus-mixin.js +150 -133
- package/src/delegate-state-mixin.d.ts +23 -0
- package/src/delegate-state-mixin.js +125 -0
- package/src/field-mixin.d.ts +39 -0
- package/src/field-mixin.js +317 -0
- package/src/input-constraints-mixin.d.ts +2 -1
- package/src/input-constraints-mixin.js +105 -53
- package/src/input-control-mixin.d.ts +52 -0
- package/src/input-control-mixin.js +170 -0
- package/src/input-controller.d.ts +11 -0
- package/src/input-controller.js +35 -0
- package/src/input-field-mixin.d.ts +2 -16
- package/src/input-field-mixin.js +20 -97
- package/src/input-mixin.d.ts +1 -1
- package/src/input-mixin.js +156 -145
- package/src/label-mixin.d.ts +2 -2
- package/src/label-mixin.js +73 -60
- package/src/pattern-mixin.d.ts +2 -2
- package/src/pattern-mixin.js +13 -13
- package/src/shadow-focus-mixin.d.ts +21 -0
- package/src/shadow-focus-mixin.js +87 -0
- package/src/slot-controller.d.ts +8 -0
- package/src/slot-controller.js +36 -0
- package/src/slot-label-mixin.d.ts +20 -0
- package/src/slot-label-mixin.js +38 -0
- package/src/slot-styles-mixin.d.ts +24 -0
- package/src/slot-styles-mixin.js +76 -0
- package/src/slot-target-mixin.d.ts +32 -0
- package/src/slot-target-mixin.js +110 -0
- package/src/styles/clear-button-styles.d.ts +8 -0
- package/src/styles/clear-button-styles.js +21 -0
- package/src/styles/field-shared-styles.d.ts +8 -0
- package/src/styles/field-shared-styles.js +29 -0
- package/src/styles/input-field-container-styles.d.ts +8 -0
- package/src/styles/input-field-container-styles.js +16 -0
- package/src/styles/input-field-shared-styles.d.ts +8 -0
- package/src/styles/input-field-shared-styles.js +10 -0
- package/src/text-area-controller.d.ts +11 -0
- package/src/text-area-controller.js +38 -0
- package/src/validate-mixin.d.ts +1 -9
- package/src/validate-mixin.js +43 -118
- package/src/active-mixin.d.ts +0 -25
- package/src/active-mixin.js +0 -84
- package/src/aria-label-mixin.d.ts +0 -20
- package/src/aria-label-mixin.js +0 -71
- package/src/char-length-mixin.d.ts +0 -30
- package/src/char-length-mixin.js +0 -42
- package/src/clear-button-mixin.d.ts +0 -27
- package/src/clear-button-mixin.js +0 -80
- package/src/disabled-mixin.d.ts +0 -23
- package/src/disabled-mixin.js +0 -48
- package/src/field-aria-mixin.d.ts +0 -24
- package/src/field-aria-mixin.js +0 -61
- package/src/focus-mixin.d.ts +0 -33
- package/src/focus-mixin.js +0 -104
- package/src/forward-input-props-mixin.d.ts +0 -41
- package/src/forward-input-props-mixin.js +0 -110
- package/src/helper-text-mixin.d.ts +0 -24
- package/src/helper-text-mixin.js +0 -109
- package/src/input-slot-mixin.d.ts +0 -26
- package/src/input-slot-mixin.js +0 -71
- package/src/slot-mixin.d.ts +0 -23
- package/src/slot-mixin.js +0 -55
- package/src/tabindex-mixin.d.ts +0 -29
- package/src/tabindex-mixin.js +0 -78
- package/src/text-area-slot-mixin.d.ts +0 -21
- package/src/text-area-slot-mixin.js +0 -56
- package/src/text-field-mixin.d.ts +0 -21
- package/src/text-field-mixin.js +0 -17
package/src/validate-mixin.js
CHANGED
|
@@ -4,128 +4,53 @@
|
|
|
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 { SlotMixin } from './slot-mixin.js';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
type: String
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get slots() {
|
|
43
|
-
return {
|
|
44
|
-
...super.slots,
|
|
45
|
-
'error-message': () => {
|
|
46
|
-
const error = document.createElement('div');
|
|
47
|
-
error.textContent = this.errorMessage;
|
|
48
|
-
error.setAttribute('aria-live', 'assertive');
|
|
49
|
-
return error;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static get observers() {
|
|
55
|
-
return ['_updateErrorMessage(invalid, errorMessage)'];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** @protected */
|
|
59
|
-
get _errorNode() {
|
|
60
|
-
return this._getDirectSlotChild('error-message');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
constructor() {
|
|
64
|
-
super();
|
|
65
|
-
|
|
66
|
-
// Ensure every instance has unique ID
|
|
67
|
-
const uniqueId = (ValidateMixinClass._uniqueId = 1 + ValidateMixinClass._uniqueId || 0);
|
|
68
|
-
this._errorId = `error-${this.localName}-${uniqueId}`;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** @protected */
|
|
72
|
-
connectedCallback() {
|
|
73
|
-
super.connectedCallback();
|
|
74
|
-
|
|
75
|
-
if (this._errorNode) {
|
|
76
|
-
this._errorNode.id = this._errorId;
|
|
77
|
-
|
|
78
|
-
this._applyCustomError();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Returns true if field is valid, and sets `invalid` based on the field validity.
|
|
84
|
-
*
|
|
85
|
-
* @return {boolean} True if the value is valid.
|
|
86
|
-
*/
|
|
87
|
-
validate() {
|
|
88
|
-
return !(this.invalid = !this.checkValidity());
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Returns true if the field value satisfies all constraints (if any).
|
|
93
|
-
*
|
|
94
|
-
* @return {boolean}
|
|
95
|
-
*/
|
|
96
|
-
checkValidity() {
|
|
97
|
-
return !this.required || !!this.value;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** @protected */
|
|
101
|
-
_applyCustomError() {
|
|
102
|
-
const error = this.__errorMessage;
|
|
103
|
-
if (error && error !== this.errorMessage) {
|
|
104
|
-
this.errorMessage = error;
|
|
105
|
-
delete this.__errorMessage;
|
|
8
|
+
/**
|
|
9
|
+
* A mixin to provide required state and validation logic.
|
|
10
|
+
*
|
|
11
|
+
* @polymerMixin
|
|
12
|
+
*/
|
|
13
|
+
export const ValidateMixin = dedupingMixin(
|
|
14
|
+
(superclass) =>
|
|
15
|
+
class ValidateMixinClass extends superclass {
|
|
16
|
+
static get properties() {
|
|
17
|
+
return {
|
|
18
|
+
/**
|
|
19
|
+
* Set to true when the field is invalid.
|
|
20
|
+
*/
|
|
21
|
+
invalid: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
reflectToAttribute: true,
|
|
24
|
+
notify: true,
|
|
25
|
+
value: false
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Specifies that the user must fill in a value.
|
|
30
|
+
*/
|
|
31
|
+
required: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
reflectToAttribute: true
|
|
34
|
+
}
|
|
35
|
+
};
|
|
106
36
|
}
|
|
107
|
-
}
|
|
108
37
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return;
|
|
38
|
+
/**
|
|
39
|
+
* Returns true if field is valid, and sets `invalid` based on the field validity.
|
|
40
|
+
*
|
|
41
|
+
* @return {boolean} True if the value is valid.
|
|
42
|
+
*/
|
|
43
|
+
validate() {
|
|
44
|
+
return !(this.invalid = !this.checkValidity());
|
|
116
45
|
}
|
|
117
46
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Returns true if the field value satisfies all constraints (if any).
|
|
49
|
+
*
|
|
50
|
+
* @return {boolean}
|
|
51
|
+
*/
|
|
52
|
+
checkValidity() {
|
|
53
|
+
return !this.required || !!this.value;
|
|
121
54
|
}
|
|
122
|
-
const hasError = Boolean(invalid && errorMessage);
|
|
123
|
-
this._errorNode.textContent = hasError ? errorMessage : '';
|
|
124
|
-
this.toggleAttribute('has-error-message', hasError);
|
|
125
55
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* A mixin to provide required state and validation logic.
|
|
130
|
-
*/
|
|
131
|
-
export const ValidateMixin = dedupingMixin(ValidateMixinImplementation);
|
|
56
|
+
);
|
package/src/active-mixin.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { DisabledMixin } from './disabled-mixin.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A mixin to toggle the `active` attribute.
|
|
10
|
-
*
|
|
11
|
-
* The attribute is set whenever the user activates the element by a pointer
|
|
12
|
-
* or presses an activation key on the element from the keyboard.
|
|
13
|
-
*
|
|
14
|
-
* The attribute is removed as soon as the element is deactivated
|
|
15
|
-
* by the pointer or by releasing the activation key.
|
|
16
|
-
*/
|
|
17
|
-
declare function ActiveMixin<T extends new (...args: any[]) => {}>(base: T): T & ActiveMixinConstructor;
|
|
18
|
-
|
|
19
|
-
interface ActiveMixinConstructor {
|
|
20
|
-
new (...args: any[]): ActiveMixin;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface ActiveMixin extends DisabledMixin {}
|
|
24
|
-
|
|
25
|
-
export { ActiveMixinConstructor, ActiveMixin };
|
package/src/active-mixin.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
7
|
-
import { GestureEventListeners } from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
|
8
|
-
import { DisabledMixin } from './disabled-mixin.js';
|
|
9
|
-
|
|
10
|
-
const ActiveMixinImplementation = (superclass) =>
|
|
11
|
-
class ActiveMixinClass extends DisabledMixin(GestureEventListeners(superclass)) {
|
|
12
|
-
/**
|
|
13
|
-
* An array of activation keys.
|
|
14
|
-
*
|
|
15
|
-
* See possible values here:
|
|
16
|
-
* https://developer.mozilla.org/ru/docs/Web/API/KeyboardEvent/key/Key_Values
|
|
17
|
-
*
|
|
18
|
-
* @protected
|
|
19
|
-
* @return {!Array<!string>}
|
|
20
|
-
*/
|
|
21
|
-
get _activeKeys() {
|
|
22
|
-
return ['Enter', ' '];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** @protected */
|
|
26
|
-
ready() {
|
|
27
|
-
super.ready();
|
|
28
|
-
|
|
29
|
-
// POINTERDOWN
|
|
30
|
-
this._addEventListenerToNode(this, 'down', () => {
|
|
31
|
-
if (this.disabled) return;
|
|
32
|
-
|
|
33
|
-
this.setAttribute('active', '');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// POINTERUP
|
|
37
|
-
this._addEventListenerToNode(this, 'up', () => {
|
|
38
|
-
this.removeAttribute('active');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// KEYDOWN
|
|
42
|
-
this.addEventListener('keydown', (event) => {
|
|
43
|
-
if (this.disabled) return;
|
|
44
|
-
|
|
45
|
-
if (this._activeKeys.includes(event.key)) {
|
|
46
|
-
this.setAttribute('active', '');
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// KEYUP
|
|
51
|
-
this.addEventListener('keyup', (event) => {
|
|
52
|
-
if (this._activeKeys.includes(event.key)) {
|
|
53
|
-
this.removeAttribute('active');
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// BLUR
|
|
58
|
-
this.addEventListener('blur', () => {
|
|
59
|
-
this.removeAttribute('active');
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** @protected */
|
|
64
|
-
disconnectedCallback() {
|
|
65
|
-
super.disconnectedCallback();
|
|
66
|
-
|
|
67
|
-
// When the element is disconnecting from the DOM at the moment being active,
|
|
68
|
-
// the `active` attribute needs to be manually removed from the element.
|
|
69
|
-
// Otherwise, it will preserve on the element until the element is activated once again.
|
|
70
|
-
// The case reproduces for `<vaadin-date-picker>` when closing on `Cancel` or `Today` click.
|
|
71
|
-
this.removeAttribute('active');
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* A mixin to toggle the `active` attribute.
|
|
77
|
-
*
|
|
78
|
-
* The attribute is set whenever the user activates the element by a pointer
|
|
79
|
-
* or presses an activation key on the element from the keyboard.
|
|
80
|
-
*
|
|
81
|
-
* The attribute is removed as soon as the element is deactivated
|
|
82
|
-
* by the pointer or by releasing the activation key.
|
|
83
|
-
*/
|
|
84
|
-
export const ActiveMixin = dedupingMixin(ActiveMixinImplementation);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { LabelMixin } from './label-mixin.js';
|
|
7
|
-
import { InputMixin } from './input-mixin.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A mixin to link an input element with a slotted `<label>` element.
|
|
11
|
-
*/
|
|
12
|
-
declare function AriaLabelMixin<T extends new (...args: any[]) => {}>(base: T): T & AriaLabelMixinConstructor;
|
|
13
|
-
|
|
14
|
-
interface AriaLabelMixinConstructor {
|
|
15
|
-
new (...args: any[]): AriaLabelMixin;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface AriaLabelMixin extends InputMixin, LabelMixin {}
|
|
19
|
-
|
|
20
|
-
export { AriaLabelMixin, AriaLabelMixinConstructor };
|
package/src/aria-label-mixin.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
7
|
-
import { LabelMixin } from './label-mixin.js';
|
|
8
|
-
import { InputMixin } from './input-mixin.js';
|
|
9
|
-
|
|
10
|
-
const AriaLabelMixinImplementation = (superclass) =>
|
|
11
|
-
class AriaLabelMixinClass extends InputMixin(LabelMixin(superclass)) {
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
|
|
15
|
-
this.__preventDuplicateLabelClick = this.__preventDuplicateLabelClick.bind(this);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** @protected */
|
|
19
|
-
connectedCallback() {
|
|
20
|
-
super.connectedCallback();
|
|
21
|
-
|
|
22
|
-
if (this._labelNode) {
|
|
23
|
-
this._labelNode.addEventListener('click', this.__preventDuplicateLabelClick);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** @protected */
|
|
28
|
-
disconnectedCallback() {
|
|
29
|
-
super.disconnectedCallback();
|
|
30
|
-
|
|
31
|
-
if (this._labelNode) {
|
|
32
|
-
this._labelNode.removeEventListener('click', this.__preventDuplicateLabelClick);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Override an observer from `InputMixin`.
|
|
38
|
-
* @protected
|
|
39
|
-
* @override
|
|
40
|
-
*/
|
|
41
|
-
_inputElementChanged(input) {
|
|
42
|
-
super._inputElementChanged(input);
|
|
43
|
-
|
|
44
|
-
if (input) {
|
|
45
|
-
input.setAttribute('aria-labelledby', this._labelId);
|
|
46
|
-
|
|
47
|
-
this._labelNode.setAttribute('for', input.id);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The native platform fires an event for both the click on the label, and also
|
|
53
|
-
* the subsequent click on the native input element caused by label click.
|
|
54
|
-
* This results in two click events arriving at the host, but we only want one.
|
|
55
|
-
* This method prevents the duplicate click and ensures the correct isTrusted event
|
|
56
|
-
* with the correct event.target arrives at the host.
|
|
57
|
-
* @private
|
|
58
|
-
*/
|
|
59
|
-
__preventDuplicateLabelClick() {
|
|
60
|
-
const inputClickHandler = (e) => {
|
|
61
|
-
e.stopImmediatePropagation();
|
|
62
|
-
this.inputElement.removeEventListener('click', inputClickHandler);
|
|
63
|
-
};
|
|
64
|
-
this.inputElement.addEventListener('click', inputClickHandler);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* A mixin to link an input element with a slotted `<label>` element.
|
|
70
|
-
*/
|
|
71
|
-
export const AriaLabelMixin = dedupingMixin(AriaLabelMixinImplementation);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { ForwardInputPropsMixin } from './forward-input-props-mixin.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A mixin to provide `minlength` and `maxlength` properties
|
|
10
|
-
* for components that use `<input>` or `<textarea>`.
|
|
11
|
-
*/
|
|
12
|
-
declare function CharLengthMixin<T extends new (...args: any[]) => {}>(base: T): T & CharLengthMixinConstructor;
|
|
13
|
-
|
|
14
|
-
interface CharLengthMixinConstructor {
|
|
15
|
-
new (...args: any[]): CharLengthMixin;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface CharLengthMixin extends ForwardInputPropsMixin {
|
|
19
|
-
/**
|
|
20
|
-
* Maximum number of characters (in Unicode code points) that the user can enter.
|
|
21
|
-
*/
|
|
22
|
-
maxlength: number | null | undefined;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Minimum number of characters (in Unicode code points) that the user can enter.
|
|
26
|
-
*/
|
|
27
|
-
minlength: number | null | undefined;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { CharLengthMixin, CharLengthMixinConstructor };
|
package/src/char-length-mixin.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
7
|
-
import { ForwardInputPropsMixin } from './forward-input-props-mixin.js';
|
|
8
|
-
|
|
9
|
-
const CharLengthMixinImplementation = (superclass) =>
|
|
10
|
-
class CharLengthMixinClass extends ForwardInputPropsMixin(superclass) {
|
|
11
|
-
static get properties() {
|
|
12
|
-
return {
|
|
13
|
-
/**
|
|
14
|
-
* Maximum number of characters (in Unicode code points) that the user can enter.
|
|
15
|
-
*/
|
|
16
|
-
maxlength: {
|
|
17
|
-
type: Number
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Minimum number of characters (in Unicode code points) that the user can enter.
|
|
22
|
-
*/
|
|
23
|
-
minlength: {
|
|
24
|
-
type: Number
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static get forwardProps() {
|
|
30
|
-
return [...super.forwardProps, 'maxlength', 'minlength'];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static get constraints() {
|
|
34
|
-
return [...super.constraints, 'maxlength', 'minlength'];
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* A mixin to provide `minlength` and `maxlength` properties
|
|
40
|
-
* for components that use `<input>` or `<textarea>`.
|
|
41
|
-
*/
|
|
42
|
-
export const CharLengthMixin = dedupingMixin(CharLengthMixinImplementation);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { InputMixin } from './input-mixin.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A mixin to add clear button support to field components.
|
|
10
|
-
*/
|
|
11
|
-
declare function ClearButtonMixin<T extends new (...args: any[]) => {}>(base: T): T & ClearButtonMixinConstructor;
|
|
12
|
-
|
|
13
|
-
interface ClearButtonMixinConstructor {
|
|
14
|
-
new (...args: any[]): ClearButtonMixin;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface ClearButtonMixin extends InputMixin {
|
|
18
|
-
/**
|
|
19
|
-
* Set to true to display the clear icon which clears the input.
|
|
20
|
-
* @attr {boolean} clear-button-visible
|
|
21
|
-
*/
|
|
22
|
-
clearButtonVisible: boolean;
|
|
23
|
-
|
|
24
|
-
readonly _clearOnEsc: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { ClearButtonMixin, ClearButtonMixinConstructor };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
7
|
-
import { InputMixin } from './input-mixin.js';
|
|
8
|
-
|
|
9
|
-
const ClearButtonMixinImplementation = (superclass) =>
|
|
10
|
-
class ClearButtonMixinClass extends InputMixin(superclass) {
|
|
11
|
-
static get properties() {
|
|
12
|
-
return {
|
|
13
|
-
/**
|
|
14
|
-
* Set to true to display the clear icon which clears the input.
|
|
15
|
-
* @attr {boolean} clear-button-visible
|
|
16
|
-
*/
|
|
17
|
-
clearButtonVisible: {
|
|
18
|
-
type: Boolean,
|
|
19
|
-
reflectToAttribute: true,
|
|
20
|
-
value: false
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Any element extending this mixin is required to implement this getter.
|
|
27
|
-
* It returns the reference to the clear button element.
|
|
28
|
-
* @protected
|
|
29
|
-
* @return {Element | null | undefined}
|
|
30
|
-
*/
|
|
31
|
-
get clearElement() {
|
|
32
|
-
console.warn(`Please implement the 'clearElement' property in <${this.localName}>`);
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** @protected */
|
|
37
|
-
get _clearOnEsc() {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** @protected */
|
|
42
|
-
ready() {
|
|
43
|
-
super.ready();
|
|
44
|
-
|
|
45
|
-
this.addEventListener('keydown', (e) => this._onKeyDown(e));
|
|
46
|
-
|
|
47
|
-
if (this.clearElement) {
|
|
48
|
-
this.clearElement.addEventListener('click', (e) => this._onClearButtonClick(e));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @param {Event} event
|
|
54
|
-
* @protected
|
|
55
|
-
*/
|
|
56
|
-
_onClearButtonClick(event) {
|
|
57
|
-
event.preventDefault();
|
|
58
|
-
this.inputElement.focus();
|
|
59
|
-
this.clear();
|
|
60
|
-
this.inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
61
|
-
this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {Event} event
|
|
66
|
-
* @protected
|
|
67
|
-
*/
|
|
68
|
-
_onKeyDown(event) {
|
|
69
|
-
if (event.key === 'Escape' && this.clearButtonVisible && this._clearOnEsc) {
|
|
70
|
-
const dispatchChange = !!this.value;
|
|
71
|
-
this.clear();
|
|
72
|
-
dispatchChange && this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* A mixin to add clear button support to field components.
|
|
79
|
-
*/
|
|
80
|
-
export const ClearButtonMixin = dedupingMixin(ClearButtonMixinImplementation);
|
package/src/disabled-mixin.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A mixin to provide disabled property for field components.
|
|
9
|
-
*/
|
|
10
|
-
declare function DisabledMixin<T extends new (...args: any[]) => {}>(base: T): T & DisabledMixinConstructor;
|
|
11
|
-
|
|
12
|
-
interface DisabledMixinConstructor {
|
|
13
|
-
new (...args: any[]): DisabledMixin;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface DisabledMixin {
|
|
17
|
-
/**
|
|
18
|
-
* If true, the user cannot interact with this element.
|
|
19
|
-
*/
|
|
20
|
-
disabled: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { DisabledMixinConstructor, DisabledMixin };
|
package/src/disabled-mixin.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
7
|
-
|
|
8
|
-
const DisabledMixinImplementation = (superclass) =>
|
|
9
|
-
class DisabledMixinClass extends superclass {
|
|
10
|
-
static get properties() {
|
|
11
|
-
return {
|
|
12
|
-
/**
|
|
13
|
-
* If true, the user cannot interact with this element.
|
|
14
|
-
*/
|
|
15
|
-
disabled: {
|
|
16
|
-
type: Boolean,
|
|
17
|
-
value: false,
|
|
18
|
-
observer: '_disabledChanged',
|
|
19
|
-
reflectToAttribute: true
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param {boolean} disabled
|
|
26
|
-
* @protected
|
|
27
|
-
*/
|
|
28
|
-
_disabledChanged(disabled) {
|
|
29
|
-
this._setAriaDisabled(disabled);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @param {boolean} disabled
|
|
34
|
-
* @protected
|
|
35
|
-
*/
|
|
36
|
-
_setAriaDisabled(disabled) {
|
|
37
|
-
if (disabled) {
|
|
38
|
-
this.setAttribute('aria-disabled', 'true');
|
|
39
|
-
} else {
|
|
40
|
-
this.removeAttribute('aria-disabled');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* A mixin to provide disabled property for field components.
|
|
47
|
-
*/
|
|
48
|
-
export const DisabledMixin = dedupingMixin(DisabledMixinImplementation);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { HelperTextMixin } from './helper-text-mixin.js';
|
|
7
|
-
import { ValidateMixin } from './validate-mixin.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A mixin to handle field ARIA attributes based on the label, error message and helper text.
|
|
11
|
-
*/
|
|
12
|
-
declare function FieldAriaMixin<T extends new (...args: any[]) => {}>(base: T): T & FieldAriaMixinConstructor;
|
|
13
|
-
|
|
14
|
-
interface FieldAriaMixinConstructor {
|
|
15
|
-
new (...args: any[]): FieldAriaMixin;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface FieldAriaMixin extends HelperTextMixin, ValidateMixin {
|
|
19
|
-
readonly _ariaTarget: HTMLElement;
|
|
20
|
-
|
|
21
|
-
readonly _ariaAttr: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { FieldAriaMixin, FieldAriaMixinConstructor };
|