@vaadin/field-base 22.0.0-alpha5 → 22.0.0-alpha9
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 +7 -15
- package/index.js +7 -15
- 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 +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 +107 -64
- 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 +125 -80
- 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.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 +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 -26
- package/src/active-mixin.js +0 -106
- 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/disabled-mixin.d.ts +0 -23
- package/src/disabled-mixin.js +0 -60
- 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/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/keyboard-mixin.d.ts +0 -32
- package/src/keyboard-mixin.js +0 -51
- package/src/slot-mixin.d.ts +0 -23
- package/src/slot-mixin.js +0 -49
- 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
|
@@ -0,0 +1,29 @@
|
|
|
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 { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const fieldShared = css`
|
|
9
|
+
:host {
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
outline: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:host::before {
|
|
15
|
+
content: '\\2003';
|
|
16
|
+
width: 0;
|
|
17
|
+
display: inline-block;
|
|
18
|
+
/* Size and position this element on the same vertical position as the input-field element
|
|
19
|
+
to make vertical align for the host element work as expected */
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:host([hidden]) {
|
|
23
|
+
display: none !important;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host(:not([has-label])) [part='label'] {
|
|
27
|
+
display: none;
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const inputFieldContainer = css`
|
|
9
|
+
[class$='container'] {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
min-width: 100%;
|
|
13
|
+
max-width: 100%;
|
|
14
|
+
width: var(--vaadin-field-default-width, 12em);
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
@@ -0,0 +1,10 @@
|
|
|
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 { clearButton } from './clear-button-styles.js';
|
|
7
|
+
import { fieldShared } from './field-shared-styles.js';
|
|
8
|
+
import { inputFieldContainer } from './input-field-container-styles.js';
|
|
9
|
+
|
|
10
|
+
export const inputFieldShared = [fieldShared, inputFieldContainer, clearButton];
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { SlotController } from './slot-controller.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A controller to create and initialize slotted `<textarea>` element.
|
|
10
|
+
*/
|
|
11
|
+
export class TextAreaController implements SlotController {}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { SlotController } from './slot-controller.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A controller to create and initialize slotted `<textarea>` element.
|
|
10
|
+
*/
|
|
11
|
+
export class TextAreaController extends SlotController {
|
|
12
|
+
constructor(host, callback) {
|
|
13
|
+
super(host, [
|
|
14
|
+
'textarea',
|
|
15
|
+
() => document.createElement('textarea'),
|
|
16
|
+
(host, node) => {
|
|
17
|
+
const value = host.getAttribute('value');
|
|
18
|
+
if (value) {
|
|
19
|
+
node.value = value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const name = host.getAttribute('name');
|
|
23
|
+
if (name) {
|
|
24
|
+
node.setAttribute('name', name);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Ensure every instance has unique ID
|
|
28
|
+
const uniqueId = (TextAreaController._uniqueTextAreaId = 1 + TextAreaController._uniqueInputId || 0);
|
|
29
|
+
host._textareaId = `${host.localName}-${uniqueId}`;
|
|
30
|
+
node.id = host._textareaId;
|
|
31
|
+
|
|
32
|
+
if (typeof callback == 'function') {
|
|
33
|
+
callback(node);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/validate-mixin.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { SlotMixin } from './slot-mixin.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* A mixin to provide required state and validation logic.
|
|
@@ -14,7 +13,7 @@ interface ValidateMixinConstructor {
|
|
|
14
13
|
new (...args: any[]): ValidateMixin;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
interface ValidateMixin
|
|
16
|
+
interface ValidateMixin {
|
|
18
17
|
/**
|
|
19
18
|
* Set to true when the field is invalid.
|
|
20
19
|
*/
|
|
@@ -25,13 +24,6 @@ interface ValidateMixin extends SlotMixin {
|
|
|
25
24
|
*/
|
|
26
25
|
required: boolean;
|
|
27
26
|
|
|
28
|
-
/**
|
|
29
|
-
* Error to show when the field is invalid.
|
|
30
|
-
*
|
|
31
|
-
* @attr {string} error-message
|
|
32
|
-
*/
|
|
33
|
-
errorMessage: string;
|
|
34
|
-
|
|
35
27
|
/**
|
|
36
28
|
* Returns true if field is valid, and sets `invalid` based on the field validity.
|
|
37
29
|
*/
|
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
|
-
ready() {
|
|
73
|
-
super.ready();
|
|
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,26 +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
|
-
import { KeyboardMixin } from './keyboard-mixin.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A mixin to toggle the `active` attribute.
|
|
11
|
-
*
|
|
12
|
-
* The attribute is set whenever the user activates the element by a pointer
|
|
13
|
-
* or presses an activation key on the element from the keyboard.
|
|
14
|
-
*
|
|
15
|
-
* The attribute is removed as soon as the element is deactivated
|
|
16
|
-
* by the pointer or by releasing the activation key.
|
|
17
|
-
*/
|
|
18
|
-
declare function ActiveMixin<T extends new (...args: any[]) => {}>(base: T): T & ActiveMixinConstructor;
|
|
19
|
-
|
|
20
|
-
interface ActiveMixinConstructor {
|
|
21
|
-
new (...args: any[]): ActiveMixin;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface ActiveMixin extends DisabledMixin, KeyboardMixin {}
|
|
25
|
-
|
|
26
|
-
export { ActiveMixinConstructor, ActiveMixin };
|
package/src/active-mixin.js
DELETED
|
@@ -1,106 +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 { KeyboardMixin } from './keyboard-mixin.js';
|
|
9
|
-
import { DisabledMixin } from './disabled-mixin.js';
|
|
10
|
-
|
|
11
|
-
const ActiveMixinImplementation = (superclass) =>
|
|
12
|
-
class ActiveMixinClass extends DisabledMixin(GestureEventListeners(KeyboardMixin(superclass))) {
|
|
13
|
-
/**
|
|
14
|
-
* An array of activation keys.
|
|
15
|
-
*
|
|
16
|
-
* See possible values here:
|
|
17
|
-
* https://developer.mozilla.org/ru/docs/Web/API/KeyboardEvent/key/Key_Values
|
|
18
|
-
*
|
|
19
|
-
* @protected
|
|
20
|
-
* @return {!Array<!string>}
|
|
21
|
-
*/
|
|
22
|
-
get _activeKeys() {
|
|
23
|
-
return [' '];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** @protected */
|
|
27
|
-
ready() {
|
|
28
|
-
super.ready();
|
|
29
|
-
|
|
30
|
-
this._addEventListenerToNode(this, 'down', () => {
|
|
31
|
-
if (this.disabled) return;
|
|
32
|
-
|
|
33
|
-
this._setActive(true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
this._addEventListenerToNode(this, 'up', () => {
|
|
37
|
-
this._setActive(false);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
this.addEventListener('blur', () => {
|
|
41
|
-
this._setActive(false);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** @protected */
|
|
46
|
-
disconnectedCallback() {
|
|
47
|
-
super.disconnectedCallback();
|
|
48
|
-
|
|
49
|
-
// When the element is disconnecting from the DOM at the moment being active,
|
|
50
|
-
// the `active` attribute needs to be manually removed from the element.
|
|
51
|
-
// Otherwise, it will preserve on the element until the element is activated once again.
|
|
52
|
-
// The case reproduces for `<vaadin-date-picker>` when closing on `Cancel` or `Today` click.
|
|
53
|
-
this._setActive(false);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Sets the `active` attribute on the element if an activation key is pressed.
|
|
58
|
-
*
|
|
59
|
-
* @param {KeyboardEvent} event
|
|
60
|
-
* @protected
|
|
61
|
-
* @override
|
|
62
|
-
*/
|
|
63
|
-
_onKeyDown(event) {
|
|
64
|
-
super._onKeyDown(event);
|
|
65
|
-
|
|
66
|
-
if (!this.disabled && this._activeKeys.includes(event.key)) {
|
|
67
|
-
this._setActive(true);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Removes the `active` attribute from the element if the activation key is released.
|
|
73
|
-
*
|
|
74
|
-
* @param {KeyboardEvent} event
|
|
75
|
-
* @protected
|
|
76
|
-
* @override
|
|
77
|
-
*/
|
|
78
|
-
_onKeyUp(event) {
|
|
79
|
-
super._onKeyUp(event);
|
|
80
|
-
|
|
81
|
-
if (this._activeKeys.includes(event.key)) {
|
|
82
|
-
this._setActive(false);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Toggles the `active` attribute on the element.
|
|
88
|
-
*
|
|
89
|
-
* @param {boolean} active
|
|
90
|
-
* @protected
|
|
91
|
-
*/
|
|
92
|
-
_setActive(active) {
|
|
93
|
-
this.toggleAttribute('active', active);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* A mixin to toggle the `active` attribute.
|
|
99
|
-
*
|
|
100
|
-
* The attribute is set whenever the user activates the element by a pointer
|
|
101
|
-
* or presses an activation key on the element from the keyboard.
|
|
102
|
-
*
|
|
103
|
-
* The attribute is removed as soon as the element is deactivated
|
|
104
|
-
* by the pointer or by releasing the activation key.
|
|
105
|
-
*/
|
|
106
|
-
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 { 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 { InputMixin } from './input-mixin.js';
|
|
7
|
-
import { KeyboardMixin } from './keyboard-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 };
|