@vaadin/field-base 22.0.2 → 23.0.0-alpha4
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/LICENSE +1 -1
- package/package.json +4 -3
- package/src/checked-mixin.d.ts +1 -1
- package/src/checked-mixin.js +1 -1
- package/src/delegate-focus-mixin.d.ts +1 -1
- package/src/delegate-focus-mixin.js +1 -1
- package/src/delegate-state-mixin.d.ts +1 -1
- package/src/delegate-state-mixin.js +1 -1
- package/src/field-aria-controller.d.ts +1 -1
- package/src/field-aria-controller.js +5 -8
- package/src/field-mixin.d.ts +3 -1
- package/src/field-mixin.js +35 -185
- package/src/helper-controller.d.ts +23 -0
- package/src/helper-controller.js +185 -0
- package/src/input-constraints-mixin.d.ts +1 -1
- package/src/input-constraints-mixin.js +2 -3
- package/src/input-control-mixin.d.ts +1 -1
- package/src/input-control-mixin.js +1 -1
- package/src/input-controller.d.ts +1 -1
- package/src/input-controller.js +1 -1
- package/src/input-field-mixin.d.ts +1 -1
- package/src/input-field-mixin.js +1 -1
- package/src/input-mixin.d.ts +1 -1
- package/src/input-mixin.js +1 -1
- package/src/label-controller.d.ts +26 -0
- package/src/label-controller.js +186 -0
- package/src/label-mixin.d.ts +4 -3
- package/src/label-mixin.js +10 -49
- package/src/labelled-input-controller.d.ts +1 -1
- package/src/labelled-input-controller.js +17 -4
- package/src/pattern-mixin.d.ts +1 -1
- package/src/pattern-mixin.js +1 -2
- package/src/shadow-focus-mixin.d.ts +1 -1
- package/src/shadow-focus-mixin.js +1 -1
- package/src/slot-label-mixin.d.ts +1 -1
- package/src/slot-label-mixin.js +1 -14
- package/src/slot-styles-mixin.d.ts +1 -1
- package/src/slot-styles-mixin.js +1 -1
- package/src/slot-target-mixin.d.ts +1 -1
- package/src/slot-target-mixin.js +1 -1
- package/src/styles/clear-button-styles.d.ts +1 -1
- package/src/styles/clear-button-styles.js +1 -1
- package/src/styles/field-shared-styles.d.ts +1 -1
- package/src/styles/field-shared-styles.js +1 -1
- package/src/styles/input-field-container-styles.d.ts +1 -1
- package/src/styles/input-field-container-styles.js +1 -1
- package/src/styles/input-field-shared-styles.d.ts +1 -1
- package/src/styles/input-field-shared-styles.js +1 -1
- package/src/text-area-controller.d.ts +1 -1
- package/src/text-area-controller.js +1 -1
- package/src/utils.d.ts +16 -0
- package/src/utils.js +56 -0
- package/src/validate-mixin.d.ts +1 -1
- package/src/validate-mixin.js +1 -1
- package/src/virtual-keyboard-controller.d.ts +14 -0
- package/src/virtual-keyboard-controller.js +38 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
package/src/utils.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Adds a value to an attribute containing space-delimited values.
|
|
9
|
+
*/
|
|
10
|
+
export declare function addValueToAttribute(element: HTMLElement, attr: string, value: string): void;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Removes a value from an attribute containing space-delimited values.
|
|
14
|
+
* If the value is the last one, the whole attribute is removed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function removeValueFromAttribute(element: HTMLElement, attr: string, value: string): void;
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} value
|
|
9
|
+
* @return {Set<string>}
|
|
10
|
+
*/
|
|
11
|
+
function deserializeAttributeValue(value) {
|
|
12
|
+
if (!value) {
|
|
13
|
+
return new Set();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return new Set(value.split(' '));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {Set<string>} values
|
|
21
|
+
* @return {string}
|
|
22
|
+
*/
|
|
23
|
+
function serializeAttributeValue(values) {
|
|
24
|
+
return [...values].join(' ');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Adds a value to an attribute containing space-delimited values.
|
|
29
|
+
*
|
|
30
|
+
* @param {HTMLElement} element
|
|
31
|
+
* @param {string} attr
|
|
32
|
+
* @param {string} value
|
|
33
|
+
*/
|
|
34
|
+
export function addValueToAttribute(element, attr, value) {
|
|
35
|
+
const values = deserializeAttributeValue(element.getAttribute(attr));
|
|
36
|
+
values.add(value);
|
|
37
|
+
element.setAttribute(attr, serializeAttributeValue(values));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Removes a value from an attribute containing space-delimited values.
|
|
42
|
+
* If the value is the last one, the whole attribute is removed.
|
|
43
|
+
*
|
|
44
|
+
* @param {HTMLElement} element
|
|
45
|
+
* @param {string} attr
|
|
46
|
+
* @param {string} value
|
|
47
|
+
*/
|
|
48
|
+
export function removeValueFromAttribute(element, attr, value) {
|
|
49
|
+
const values = deserializeAttributeValue(element.getAttribute(attr));
|
|
50
|
+
values.delete(value);
|
|
51
|
+
if (values.size === 0) {
|
|
52
|
+
element.removeAttribute(attr);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
element.setAttribute(attr, serializeAttributeValue(values));
|
|
56
|
+
}
|
package/src/validate-mixin.d.ts
CHANGED
package/src/validate-mixin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { ReactiveController } from 'lit';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A controller which prevents the virtual keyboard from showing up on mobile devices
|
|
10
|
+
* when the field's overlay is closed.
|
|
11
|
+
*/
|
|
12
|
+
export class VirtualKeyboardController implements ReactiveController {
|
|
13
|
+
constructor(host: { inputElement?: HTMLElement; opened: boolean } & HTMLElement);
|
|
14
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A controller which prevents the virtual keyboard from showing up on mobile devices
|
|
9
|
+
* when the field's overlay is closed.
|
|
10
|
+
*/
|
|
11
|
+
export class VirtualKeyboardController {
|
|
12
|
+
/**
|
|
13
|
+
* @param {{ inputElement?: HTMLElement; opened: boolean } & HTMLElement} host
|
|
14
|
+
*/
|
|
15
|
+
constructor(host) {
|
|
16
|
+
this.host = host;
|
|
17
|
+
|
|
18
|
+
host.addEventListener('opened-changed', () => {
|
|
19
|
+
if (!host.opened) {
|
|
20
|
+
// Prevent opening the virtual keyboard when the input gets re-focused on dropdown close
|
|
21
|
+
this.__setVirtualKeyboardEnabled(false);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Re-enable virtual keyboard on blur, so it gets opened when the field is focused again
|
|
26
|
+
host.addEventListener('blur', () => this.__setVirtualKeyboardEnabled(true));
|
|
27
|
+
|
|
28
|
+
// Re-enable the virtual keyboard whenever the field is touched
|
|
29
|
+
host.addEventListener('touchstart', () => this.__setVirtualKeyboardEnabled(true));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** @private */
|
|
33
|
+
__setVirtualKeyboardEnabled(value) {
|
|
34
|
+
if (this.host.inputElement) {
|
|
35
|
+
this.host.inputElement.inputMode = value ? '' : 'none';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|