@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/helper-text-mixin.js
DELETED
|
@@ -1,144 +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 { SlotMixin } from '@vaadin/component-base/src/slot-mixin.js';
|
|
8
|
-
|
|
9
|
-
const HelperTextMixinImplementation = (superclass) =>
|
|
10
|
-
class HelperTextMixinClass extends SlotMixin(superclass) {
|
|
11
|
-
static get properties() {
|
|
12
|
-
return {
|
|
13
|
-
/**
|
|
14
|
-
* String used for the helper text.
|
|
15
|
-
* @attr {string} helper-text
|
|
16
|
-
*/
|
|
17
|
-
helperText: {
|
|
18
|
-
type: String,
|
|
19
|
-
observer: '_helperTextChanged'
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
/** @protected */
|
|
23
|
-
_helperId: String
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get slots() {
|
|
28
|
-
return {
|
|
29
|
-
...super.slots,
|
|
30
|
-
helper: () => {
|
|
31
|
-
const helper = document.createElement('div');
|
|
32
|
-
helper.textContent = this.helperText;
|
|
33
|
-
return helper;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** @protected */
|
|
39
|
-
get _helperNode() {
|
|
40
|
-
return this._getDirectSlotChild('helper');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
constructor() {
|
|
44
|
-
super();
|
|
45
|
-
|
|
46
|
-
// Ensure every instance has unique ID
|
|
47
|
-
const uniqueId = (HelperTextMixinClass._uniqueId = 1 + HelperTextMixinClass._uniqueId || 0);
|
|
48
|
-
this._helperId = `helper-${this.localName}-${uniqueId}`;
|
|
49
|
-
|
|
50
|
-
// Save generated ID to restore later
|
|
51
|
-
this.__savedHelperId = this._helperId;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** @protected */
|
|
55
|
-
connectedCallback() {
|
|
56
|
-
super.connectedCallback();
|
|
57
|
-
|
|
58
|
-
if (this._helperNode) {
|
|
59
|
-
this._currentHelper = this._helperNode;
|
|
60
|
-
this._helperNode.id = this._helperId;
|
|
61
|
-
|
|
62
|
-
this._applyCustomHelper();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** @protected */
|
|
67
|
-
ready() {
|
|
68
|
-
super.ready();
|
|
69
|
-
|
|
70
|
-
this.__helperSlot = this.shadowRoot.querySelector('[name="helper"]');
|
|
71
|
-
this.__helperSlot.addEventListener('slotchange', this.__onHelperSlotChange.bind(this));
|
|
72
|
-
this.__helperIdObserver = new MutationObserver((mutationRecord) => {
|
|
73
|
-
mutationRecord.forEach((mutation) => {
|
|
74
|
-
// only handle helper nodes
|
|
75
|
-
if (
|
|
76
|
-
mutation.type === 'attributes' &&
|
|
77
|
-
mutation.attributeName === 'id' &&
|
|
78
|
-
mutation.target === this._currentHelper &&
|
|
79
|
-
mutation.target.id !== this.__savedHelperId
|
|
80
|
-
) {
|
|
81
|
-
this.__updateHelperId(mutation.target);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
this.__helperIdObserver.observe(this, { attributes: true, subtree: true });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** @private */
|
|
90
|
-
__updateHelperId(customHelper) {
|
|
91
|
-
let newId;
|
|
92
|
-
|
|
93
|
-
if (customHelper.id) {
|
|
94
|
-
newId = customHelper.id;
|
|
95
|
-
} else {
|
|
96
|
-
newId = this.__savedHelperId;
|
|
97
|
-
customHelper.id = newId;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
this._helperId = newId;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** @private */
|
|
104
|
-
__onHelperSlotChange() {
|
|
105
|
-
// Check fot slotted element node that is not the one created by this mixin.
|
|
106
|
-
const customHelper = this.__helperSlot
|
|
107
|
-
.assignedElements({ flatten: true })
|
|
108
|
-
.find((node) => node !== this._currentHelper);
|
|
109
|
-
|
|
110
|
-
if (customHelper) {
|
|
111
|
-
this.__updateHelperId(customHelper);
|
|
112
|
-
|
|
113
|
-
if (this._currentHelper.isConnected) {
|
|
114
|
-
this._currentHelper.remove();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
this._applyCustomHelper();
|
|
118
|
-
|
|
119
|
-
this._currentHelper = customHelper;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/** @protected */
|
|
124
|
-
_applyCustomHelper() {
|
|
125
|
-
const helper = this._helperNode.textContent;
|
|
126
|
-
if (helper !== this.helperText) {
|
|
127
|
-
this.helperText = helper;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** @protected */
|
|
132
|
-
_helperTextChanged(helper) {
|
|
133
|
-
if (this._helperNode) {
|
|
134
|
-
this._helperNode.textContent = helper;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
this.toggleAttribute('has-helper', Boolean(helper));
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* A mixin to provide helper text via corresponding property or named slot.
|
|
143
|
-
*/
|
|
144
|
-
export const HelperTextMixin = dedupingMixin(HelperTextMixinImplementation);
|
|
@@ -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 { SlotMixin } from '@vaadin/component-base/src/slot-mixin.js';
|
|
7
|
-
import { DelegateFocusMixin } from './delegate-focus-mixin.js';
|
|
8
|
-
import { InputMixin } from './input-mixin.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A mixin to add `<input>` element to the corresponding named slot.
|
|
12
|
-
*/
|
|
13
|
-
declare function InputSlotMixin<T extends new (...args: any[]) => {}>(base: T): T & InputSlotMixinConstructor;
|
|
14
|
-
|
|
15
|
-
interface InputSlotMixinConstructor {
|
|
16
|
-
new (...args: any[]): InputSlotMixin;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface InputSlotMixin extends DelegateFocusMixin, InputMixin, SlotMixin {
|
|
20
|
-
/**
|
|
21
|
-
* String used to define input type.
|
|
22
|
-
*/
|
|
23
|
-
readonly type: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { InputSlotMixinConstructor, InputSlotMixin };
|
package/src/input-slot-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 { SlotMixin } from '@vaadin/component-base/src/slot-mixin.js';
|
|
8
|
-
import { DelegateFocusMixin } from './delegate-focus-mixin.js';
|
|
9
|
-
import { InputMixin } from './input-mixin.js';
|
|
10
|
-
|
|
11
|
-
const InputSlotMixinImplementation = (superclass) =>
|
|
12
|
-
class InputSlotMixinClass extends DelegateFocusMixin(InputMixin(SlotMixin(superclass))) {
|
|
13
|
-
static get properties() {
|
|
14
|
-
/**
|
|
15
|
-
* String used to define input type.
|
|
16
|
-
*/
|
|
17
|
-
return {
|
|
18
|
-
type: {
|
|
19
|
-
type: String,
|
|
20
|
-
readOnly: true
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get slots() {
|
|
26
|
-
return {
|
|
27
|
-
...super.slots,
|
|
28
|
-
input: () => {
|
|
29
|
-
const native = document.createElement('input');
|
|
30
|
-
const value = this.getAttribute('value');
|
|
31
|
-
if (value) {
|
|
32
|
-
native.setAttribute('value', value);
|
|
33
|
-
}
|
|
34
|
-
const name = this.getAttribute('name');
|
|
35
|
-
if (name) {
|
|
36
|
-
native.setAttribute('name', name);
|
|
37
|
-
}
|
|
38
|
-
if (this.type) {
|
|
39
|
-
native.setAttribute('type', this.type);
|
|
40
|
-
}
|
|
41
|
-
return native;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
constructor() {
|
|
47
|
-
super();
|
|
48
|
-
|
|
49
|
-
// Ensure every instance has unique ID
|
|
50
|
-
const uniqueId = (InputSlotMixinClass._uniqueId = 1 + InputSlotMixinClass._uniqueId || 0);
|
|
51
|
-
this._inputId = `${this.localName}-${uniqueId}`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** @protected */
|
|
55
|
-
ready() {
|
|
56
|
-
super.ready();
|
|
57
|
-
|
|
58
|
-
const inputNode = this._getDirectSlotChild('input');
|
|
59
|
-
if (inputNode) {
|
|
60
|
-
inputNode.id = this._inputId;
|
|
61
|
-
|
|
62
|
-
this._setInputElement(inputNode);
|
|
63
|
-
this._setFocusElement(inputNode);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* A mixin to add `<input>` element to the corresponding named slot.
|
|
70
|
-
*/
|
|
71
|
-
export const InputSlotMixin = dedupingMixin(InputSlotMixinImplementation);
|
|
@@ -1,21 +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
|
-
import { DelegateFocusMixin } from './delegate-focus-mixin.js';
|
|
8
|
-
import { InputMixin } from './input-mixin.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A mixin to add `<textarea>` element to the corresponding named slot.
|
|
12
|
-
*/
|
|
13
|
-
declare function TextAreaSlotMixin<T extends new (...args: any[]) => {}>(base: T): T & TextAreaSlotMixinConstructor;
|
|
14
|
-
|
|
15
|
-
interface TextAreaSlotMixinConstructor {
|
|
16
|
-
new (...args: any[]): TextAreaSlotMixin;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface TextAreaSlotMixin extends DelegateFocusMixin, InputMixin, SlotMixin {}
|
|
20
|
-
|
|
21
|
-
export { TextAreaSlotMixinConstructor, TextAreaSlotMixin };
|
|
@@ -1,56 +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 { SlotMixin } from '@vaadin/component-base/src/slot-mixin.js';
|
|
8
|
-
import { DelegateFocusMixin } from './delegate-focus-mixin.js';
|
|
9
|
-
import { InputMixin } from './input-mixin.js';
|
|
10
|
-
|
|
11
|
-
const TextAreaSlotMixinImplementation = (superclass) =>
|
|
12
|
-
class TextAreaSlotMixinClass extends DelegateFocusMixin(InputMixin(SlotMixin(superclass))) {
|
|
13
|
-
get slots() {
|
|
14
|
-
return {
|
|
15
|
-
...super.slots,
|
|
16
|
-
textarea: () => {
|
|
17
|
-
const native = document.createElement('textarea');
|
|
18
|
-
const value = this.getAttribute('value');
|
|
19
|
-
if (value) {
|
|
20
|
-
native.value = value;
|
|
21
|
-
}
|
|
22
|
-
const name = this.getAttribute('name');
|
|
23
|
-
if (name) {
|
|
24
|
-
native.setAttribute('name', name);
|
|
25
|
-
}
|
|
26
|
-
return native;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
constructor() {
|
|
32
|
-
super();
|
|
33
|
-
|
|
34
|
-
// Ensure every instance has unique ID
|
|
35
|
-
const uniqueId = (TextAreaSlotMixinClass._uniqueId = 1 + TextAreaSlotMixinClass._uniqueId || 0);
|
|
36
|
-
this._textareaId = `${this.localName}-${uniqueId}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** @protected */
|
|
40
|
-
ready() {
|
|
41
|
-
super.ready();
|
|
42
|
-
|
|
43
|
-
const textArea = this._getDirectSlotChild('textarea');
|
|
44
|
-
if (textArea) {
|
|
45
|
-
textArea.id = this._textareaId;
|
|
46
|
-
|
|
47
|
-
this._setInputElement(textArea);
|
|
48
|
-
this._setFocusElement(textArea);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* A mixin to add `<textarea>` element to the corresponding named slot.
|
|
55
|
-
*/
|
|
56
|
-
export const TextAreaSlotMixin = dedupingMixin(TextAreaSlotMixinImplementation);
|
|
@@ -1,21 +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 { CharLengthMixin } from './char-length-mixin.js';
|
|
7
|
-
import { InputFieldMixin } from './input-field-mixin.js';
|
|
8
|
-
import { PatternMixin } from './pattern-mixin.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A mixin to provide validation constraints for vaadin-text-field and related components.
|
|
12
|
-
*/
|
|
13
|
-
declare function TextFieldMixin<T extends new (...args: any[]) => {}>(base: T): T & TextFieldMixinConstructor;
|
|
14
|
-
|
|
15
|
-
interface TextFieldMixinConstructor {
|
|
16
|
-
new (...args: any[]): TextFieldMixin;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface TextFieldMixin extends CharLengthMixin, InputFieldMixin, PatternMixin {}
|
|
20
|
-
|
|
21
|
-
export { TextFieldMixin, TextFieldMixinConstructor };
|
package/src/text-field-mixin.js
DELETED
|
@@ -1,17 +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 { CharLengthMixin } from './char-length-mixin.js';
|
|
8
|
-
import { InputFieldMixin } from './input-field-mixin.js';
|
|
9
|
-
import { PatternMixin } from './pattern-mixin.js';
|
|
10
|
-
|
|
11
|
-
const TextFieldMixinImplementation = (superclass) =>
|
|
12
|
-
class TextFieldMixinClass extends InputFieldMixin(CharLengthMixin(PatternMixin(superclass))) {};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A mixin to provide validation constraints for vaadin-text-field and related components.
|
|
16
|
-
*/
|
|
17
|
-
export const TextFieldMixin = dedupingMixin(TextFieldMixinImplementation);
|