@vaadin/field-base 22.0.0-alpha6 → 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 +6 -9
- package/index.js +6 -9
- package/package.json +22 -17
- package/src/aria-label-controller.d.ts +11 -0
- package/src/aria-label-controller.js +53 -0
- package/src/checked-mixin.js +37 -67
- package/src/delegate-focus-mixin.js +147 -131
- package/src/delegate-state-mixin.d.ts +1 -1
- package/src/delegate-state-mixin.js +100 -88
- package/src/field-mixin.d.ts +39 -0
- package/src/field-mixin.js +317 -0
- package/src/input-constraints-mixin.d.ts +4 -2
- package/src/input-constraints-mixin.js +105 -86
- 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 +17 -89
- package/src/input-mixin.d.ts +1 -1
- package/src/input-mixin.js +156 -145
- package/src/label-mixin.d.ts +1 -1
- package/src/label-mixin.js +72 -59
- package/src/pattern-mixin.js +9 -9
- 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.js +38 -31
- package/src/slot-target-mixin.d.ts +8 -19
- package/src/slot-target-mixin.js +93 -73
- 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 -120
- 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 -28
- package/src/clear-button-mixin.js +0 -82
- package/src/delegate-input-state-mixin.d.ts +0 -43
- package/src/delegate-input-state-mixin.js +0 -63
- package/src/field-aria-mixin.d.ts +0 -24
- package/src/field-aria-mixin.js +0 -61
- package/src/helper-text-mixin.d.ts +0 -24
- package/src/helper-text-mixin.js +0 -144
- package/src/input-slot-mixin.d.ts +0 -26
- package/src/input-slot-mixin.js +0 -71
- 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,130 +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 '@vaadin/component-base/src/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
|
-
ready() {
|
|
73
|
-
super.ready();
|
|
74
|
-
|
|
75
|
-
if (this._errorNode) {
|
|
76
|
-
this._errorNode.id = this._errorId;
|
|
77
|
-
|
|
78
|
-
this._applyCustomError();
|
|
79
|
-
|
|
80
|
-
this._updateErrorMessage(this.invalid, this.errorMessage);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Returns true if field is valid, and sets `invalid` based on the field validity.
|
|
86
|
-
*
|
|
87
|
-
* @return {boolean} True if the value is valid.
|
|
88
|
-
*/
|
|
89
|
-
validate() {
|
|
90
|
-
return !(this.invalid = !this.checkValidity());
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Returns true if the field value satisfies all constraints (if any).
|
|
95
|
-
*
|
|
96
|
-
* @return {boolean}
|
|
97
|
-
*/
|
|
98
|
-
checkValidity() {
|
|
99
|
-
return !this.required || !!this.value;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** @protected */
|
|
103
|
-
_applyCustomError() {
|
|
104
|
-
const error = this.__errorMessage;
|
|
105
|
-
if (error && error !== this.errorMessage) {
|
|
106
|
-
this.errorMessage = error;
|
|
107
|
-
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
|
+
};
|
|
108
36
|
}
|
|
109
|
-
}
|
|
110
37
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
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());
|
|
118
45
|
}
|
|
119
46
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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;
|
|
123
54
|
}
|
|
124
|
-
const hasError = Boolean(invalid && errorMessage);
|
|
125
|
-
this._errorNode.textContent = hasError ? errorMessage : '';
|
|
126
|
-
this.toggleAttribute('has-error-message', hasError);
|
|
127
55
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* A mixin to provide required state and validation logic.
|
|
132
|
-
*/
|
|
133
|
-
export const ValidateMixin = dedupingMixin(ValidateMixinImplementation);
|
|
56
|
+
);
|
|
@@ -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 { InputConstraintsMixin } from './input-constraints-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 InputConstraintsMixin {
|
|
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 { InputConstraintsMixin } from './input-constraints-mixin.js';
|
|
8
|
-
|
|
9
|
-
const CharLengthMixinImplementation = (superclass) =>
|
|
10
|
-
class CharLengthMixinClass extends InputConstraintsMixin(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 delegateAttrs() {
|
|
30
|
-
return [...super.delegateAttrs, '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,28 +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 { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
7
|
-
import { InputMixin } from './input-mixin.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A mixin to add clear button support to field components.
|
|
11
|
-
*/
|
|
12
|
-
declare function ClearButtonMixin<T extends new (...args: any[]) => {}>(base: T): T & ClearButtonMixinConstructor;
|
|
13
|
-
|
|
14
|
-
interface ClearButtonMixinConstructor {
|
|
15
|
-
new (...args: any[]): ClearButtonMixin;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface ClearButtonMixin extends InputMixin, KeyboardMixin {
|
|
19
|
-
/**
|
|
20
|
-
* Set to true to display the clear icon which clears the input.
|
|
21
|
-
* @attr {boolean} clear-button-visible
|
|
22
|
-
*/
|
|
23
|
-
clearButtonVisible: boolean;
|
|
24
|
-
|
|
25
|
-
readonly _clearOnEsc: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { ClearButtonMixin, ClearButtonMixinConstructor };
|
|
@@ -1,82 +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 { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
8
|
-
import { InputMixin } from './input-mixin.js';
|
|
9
|
-
|
|
10
|
-
const ClearButtonMixinImplementation = (superclass) =>
|
|
11
|
-
class ClearButtonMixinClass extends InputMixin(KeyboardMixin(superclass)) {
|
|
12
|
-
static get properties() {
|
|
13
|
-
return {
|
|
14
|
-
/**
|
|
15
|
-
* Set to true to display the clear icon which clears the input.
|
|
16
|
-
* @attr {boolean} clear-button-visible
|
|
17
|
-
*/
|
|
18
|
-
clearButtonVisible: {
|
|
19
|
-
type: Boolean,
|
|
20
|
-
reflectToAttribute: true,
|
|
21
|
-
value: false
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Any element extending this mixin is required to implement this getter.
|
|
28
|
-
* It returns the reference to the clear button element.
|
|
29
|
-
* @protected
|
|
30
|
-
* @return {Element | null | undefined}
|
|
31
|
-
*/
|
|
32
|
-
get clearElement() {
|
|
33
|
-
console.warn(`Please implement the 'clearElement' property in <${this.localName}>`);
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** @protected */
|
|
38
|
-
get _clearOnEsc() {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** @protected */
|
|
43
|
-
ready() {
|
|
44
|
-
super.ready();
|
|
45
|
-
|
|
46
|
-
if (this.clearElement) {
|
|
47
|
-
this.clearElement.addEventListener('click', (e) => this._onClearButtonClick(e));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @param {Event} event
|
|
53
|
-
* @protected
|
|
54
|
-
*/
|
|
55
|
-
_onClearButtonClick(event) {
|
|
56
|
-
event.preventDefault();
|
|
57
|
-
this.inputElement.focus();
|
|
58
|
-
this.clear();
|
|
59
|
-
this.inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
60
|
-
this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @param {KeyboardEvent} event
|
|
65
|
-
* @protected
|
|
66
|
-
* @override
|
|
67
|
-
*/
|
|
68
|
-
_onKeyDown(event) {
|
|
69
|
-
super._onKeyDown(event);
|
|
70
|
-
|
|
71
|
-
if (event.key === 'Escape' && this.clearButtonVisible && this._clearOnEsc) {
|
|
72
|
-
const dispatchChange = !!this.value;
|
|
73
|
-
this.clear();
|
|
74
|
-
dispatchChange && this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* A mixin to add clear button support to field components.
|
|
81
|
-
*/
|
|
82
|
-
export const ClearButtonMixin = dedupingMixin(ClearButtonMixinImplementation);
|
|
@@ -1,43 +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 { DelegateStateMixin } from './delegate-state-mixin.js';
|
|
7
|
-
import { InputMixin } from './input-mixin.js';
|
|
8
|
-
import { ValidateMixin } from './validate-mixin.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A mixin to forward properties to the input element.
|
|
12
|
-
*/
|
|
13
|
-
declare function DelegateInputStateMixin<T extends new (...args: any[]) => {}>(
|
|
14
|
-
base: T
|
|
15
|
-
): T & DelegateInputStateMixinConstructor;
|
|
16
|
-
|
|
17
|
-
interface DelegateInputStateMixinConstructor {
|
|
18
|
-
new (...args: any[]): DelegateInputStateMixin;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface DelegateInputStateMixin extends DelegateStateMixin, ValidateMixin, InputMixin {
|
|
22
|
-
/**
|
|
23
|
-
* The name of this field.
|
|
24
|
-
*/
|
|
25
|
-
name: string;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A hint to the user of what can be entered in the field.
|
|
29
|
-
*/
|
|
30
|
-
placeholder: string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* When present, it specifies that the field is read-only.
|
|
34
|
-
*/
|
|
35
|
-
readonly: boolean;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The text usually displayed in a tooltip popup when the mouse is over the field.
|
|
39
|
-
*/
|
|
40
|
-
title: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { DelegateInputStateMixinConstructor, DelegateInputStateMixin };
|
|
@@ -1,63 +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 { DelegateStateMixin } from './delegate-state-mixin.js';
|
|
8
|
-
import { InputMixin } from './input-mixin.js';
|
|
9
|
-
import { ValidateMixin } from './validate-mixin.js';
|
|
10
|
-
|
|
11
|
-
const DelegateInputStateMixinImplementation = (superclass) =>
|
|
12
|
-
class DelegateInputStateMixinClass extends DelegateStateMixin(ValidateMixin(InputMixin(superclass))) {
|
|
13
|
-
static get properties() {
|
|
14
|
-
return {
|
|
15
|
-
/**
|
|
16
|
-
* The name of this field.
|
|
17
|
-
*/
|
|
18
|
-
name: {
|
|
19
|
-
type: String,
|
|
20
|
-
reflectToAttribute: true
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* A hint to the user of what can be entered in the field.
|
|
25
|
-
*/
|
|
26
|
-
placeholder: {
|
|
27
|
-
type: String,
|
|
28
|
-
reflectToAttribute: true
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* When present, it specifies that the field is read-only.
|
|
33
|
-
*/
|
|
34
|
-
readonly: {
|
|
35
|
-
type: Boolean,
|
|
36
|
-
value: false,
|
|
37
|
-
reflectToAttribute: true
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The text usually displayed in a tooltip popup when the mouse is over the field.
|
|
42
|
-
*/
|
|
43
|
-
title: {
|
|
44
|
-
type: String,
|
|
45
|
-
reflectToAttribute: true
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static get delegateAttrs() {
|
|
51
|
-
return ['name', 'type', 'placeholder', 'required', 'readonly', 'invalid', 'title'];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** @protected */
|
|
55
|
-
get _delegateStateTarget() {
|
|
56
|
-
return this.inputElement;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* A mixin to delegate attributes to the input element.
|
|
62
|
-
*/
|
|
63
|
-
export const DelegateInputStateMixin = dedupingMixin(DelegateInputStateMixinImplementation);
|
|
@@ -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 };
|
package/src/field-aria-mixin.js
DELETED
|
@@ -1,61 +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 { HelperTextMixin } from './helper-text-mixin.js';
|
|
8
|
-
import { ValidateMixin } from './validate-mixin.js';
|
|
9
|
-
|
|
10
|
-
const FieldAriaMixinImplementation = (superclass) =>
|
|
11
|
-
class FieldAriaMixinClass extends HelperTextMixin(ValidateMixin(superclass)) {
|
|
12
|
-
/** @protected */
|
|
13
|
-
get _ariaTarget() {
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** @protected */
|
|
18
|
-
get _ariaAttr() {
|
|
19
|
-
return 'aria-describedby';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static get observers() {
|
|
23
|
-
return ['__ariaChanged(invalid, _helperId)'];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** @protected */
|
|
27
|
-
ready() {
|
|
28
|
-
super.ready();
|
|
29
|
-
|
|
30
|
-
this._updateAriaAttribute(this.invalid, this._helperId);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** @protected */
|
|
34
|
-
_updateAriaAttribute(invalid, helperId) {
|
|
35
|
-
const attr = this._ariaAttr;
|
|
36
|
-
|
|
37
|
-
if (this._ariaTarget && attr) {
|
|
38
|
-
// For groups, add all IDs to aria-labelledby rather than aria-describedby -
|
|
39
|
-
// that should guarantee that it's announced when the group is entered.
|
|
40
|
-
const ariaIds = attr === 'aria-describedby' ? [helperId] : [this._labelId, helperId];
|
|
41
|
-
|
|
42
|
-
// Error message ID needs to be dynamically added / removed based on the validity
|
|
43
|
-
// Otherwise assistive technologies would announce the error, even if we hide it.
|
|
44
|
-
if (invalid) {
|
|
45
|
-
ariaIds.push(this._errorId);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
this._ariaTarget.setAttribute(attr, ariaIds.join(' '));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** @private */
|
|
53
|
-
__ariaChanged(invalid, helperId) {
|
|
54
|
-
this._updateAriaAttribute(invalid, helperId);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* A mixin to handle field ARIA attributes based on the label, error message and helper text.
|
|
60
|
-
*/
|
|
61
|
-
export const FieldAriaMixin = dedupingMixin(FieldAriaMixinImplementation);
|
|
@@ -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 { SlotMixin } from '@vaadin/component-base/src/slot-mixin.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A mixin to provide helper text via corresponding property or named slot.
|
|
10
|
-
*/
|
|
11
|
-
declare function HelperTextMixin<T extends new (...args: any[]) => {}>(base: T): T & HelperTextMixinConstructor;
|
|
12
|
-
|
|
13
|
-
interface HelperTextMixinConstructor {
|
|
14
|
-
new (...args: any[]): HelperTextMixin;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface HelperTextMixin extends SlotMixin {
|
|
18
|
-
/**
|
|
19
|
-
* String used for the helper text.
|
|
20
|
-
*/
|
|
21
|
-
helperText: string | null | undefined;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { HelperTextMixinConstructor, HelperTextMixin };
|