@vaadin/component-base 22.0.0-beta1 → 22.0.1
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/README.md +7 -2
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +4 -3
- package/src/active-mixin.d.ts +23 -8
- package/src/browser-utils.js +35 -0
- package/src/controller-mixin.d.ts +28 -0
- package/src/controller-mixin.js +67 -0
- package/src/dir-mixin.d.ts +5 -12
- package/src/disabled-mixin.d.ts +5 -8
- package/src/element-mixin.d.ts +12 -12
- package/src/element-mixin.js +1 -41
- package/src/focus-mixin.d.ts +7 -10
- package/src/focus-mixin.js +11 -3
- package/src/iron-list-core.js +2 -2
- package/src/keyboard-mixin.d.ts +5 -10
- package/src/slot-mixin.d.ts +4 -9
- package/src/tabindex-mixin.d.ts +14 -10
- package/src/tabindex-mixin.js +1 -1
- package/src/virtualizer-iron-list-adapter.js +11 -5
package/README.md
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
# @vaadin/component-base
|
|
2
2
|
|
|
3
|
-
A set of mixins used by Vaadin components.
|
|
3
|
+
A set of helpers and mixins used by Vaadin components.
|
|
4
|
+
|
|
5
|
+
## Contributing
|
|
6
|
+
|
|
7
|
+
Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/overview) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
|
|
4
8
|
|
|
5
9
|
## License
|
|
6
10
|
|
|
7
11
|
Apache License 2.0
|
|
8
12
|
|
|
9
|
-
Vaadin collects development time
|
|
13
|
+
Vaadin collects usage statistics at development time to improve this product.
|
|
14
|
+
For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ActiveMixin } from './src/active-mixin.js';
|
|
2
|
+
export { ControllerMixin } from './src/controller-mixin.js';
|
|
2
3
|
export { DirMixin } from './src/dir-mixin.js';
|
|
3
4
|
export { DisabledMixin } from './src/disabled-mixin.js';
|
|
4
5
|
export { ElementMixin } from './src/element-mixin.js';
|
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ActiveMixin } from './src/active-mixin.js';
|
|
2
|
+
export { ControllerMixin } from './src/controller-mixin.js';
|
|
2
3
|
export { DirMixin } from './src/dir-mixin.js';
|
|
3
4
|
export { DisabledMixin } from './src/disabled-mixin.js';
|
|
4
5
|
export { ElementMixin } from './src/element-mixin.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/component-base",
|
|
3
|
-
"version": "22.0.
|
|
3
|
+
"version": "22.0.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"web-component"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
33
34
|
"@polymer/polymer": "^3.0.0",
|
|
34
35
|
"@vaadin/vaadin-development-mode-detector": "^2.0.0",
|
|
35
36
|
"@vaadin/vaadin-usage-statistics": "^2.1.0",
|
|
@@ -37,8 +38,8 @@
|
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@esm-bundle/chai": "^4.3.4",
|
|
40
|
-
"@vaadin/testing-helpers": "^0.3.
|
|
41
|
+
"@vaadin/testing-helpers": "^0.3.2",
|
|
41
42
|
"sinon": "^9.2.4"
|
|
42
43
|
},
|
|
43
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "2b0a2bff0369d6020f7cc33ad35506aa2d1f6f68"
|
|
44
45
|
}
|
package/src/active-mixin.d.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
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 {
|
|
7
|
-
import {
|
|
6
|
+
import { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import { DisabledMixinClass } from './disabled-mixin.js';
|
|
8
|
+
import { KeyboardMixinClass } from './keyboard-mixin.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* A mixin to toggle the `active` attribute.
|
|
@@ -15,12 +16,26 @@ import { KeyboardMixin } from './keyboard-mixin.js';
|
|
|
15
16
|
* The attribute is removed as soon as the element is deactivated
|
|
16
17
|
* by the pointer or by releasing the activation key.
|
|
17
18
|
*/
|
|
18
|
-
declare function ActiveMixin<T extends
|
|
19
|
+
export declare function ActiveMixin<T extends Constructor<HTMLElement>>(
|
|
20
|
+
base: T
|
|
21
|
+
): T & Constructor<ActiveMixinClass> & Constructor<DisabledMixinClass> & Constructor<KeyboardMixinClass>;
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
export declare class ActiveMixinClass {
|
|
24
|
+
/**
|
|
25
|
+
* An array of activation keys.
|
|
26
|
+
*
|
|
27
|
+
* See possible values here:
|
|
28
|
+
* https://developer.mozilla.org/ru/docs/Web/API/KeyboardEvent/key/Key_Values
|
|
29
|
+
*/
|
|
30
|
+
protected readonly _activeKeys: string[];
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Override to define if the component needs to be activated.
|
|
34
|
+
*/
|
|
35
|
+
protected _shouldSetFocus(event: KeyboardEvent | MouseEvent): boolean;
|
|
25
36
|
|
|
26
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Toggles the `active` attribute on the element.
|
|
39
|
+
*/
|
|
40
|
+
protected _setActive(active: boolean): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
const testUserAgent = (regexp) => regexp.test(navigator.userAgent);
|
|
8
|
+
|
|
9
|
+
const testPlatform = (regexp) => regexp.test(navigator.platform);
|
|
10
|
+
|
|
11
|
+
const testVendor = (regexp) => regexp.test(navigator.vendor);
|
|
12
|
+
|
|
13
|
+
export const isAndroid = testUserAgent(/Android/);
|
|
14
|
+
|
|
15
|
+
export const isChrome = testUserAgent(/Chrome/) && testVendor(/Google Inc/);
|
|
16
|
+
|
|
17
|
+
export const isFirefox = testUserAgent(/Firefox/);
|
|
18
|
+
|
|
19
|
+
// iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
20
|
+
export const isIPad = testPlatform(/^iPad/) || (testPlatform(/^Mac/) && navigator.maxTouchPoints > 1);
|
|
21
|
+
|
|
22
|
+
export const isIPhone = testPlatform(/^iPhone/);
|
|
23
|
+
|
|
24
|
+
export const isIOS = isIPhone || isIPad;
|
|
25
|
+
|
|
26
|
+
export const isSafari = testUserAgent(/^((?!chrome|android).)*safari/i);
|
|
27
|
+
|
|
28
|
+
export const isTouch = (() => {
|
|
29
|
+
try {
|
|
30
|
+
document.createEvent('TouchEvent');
|
|
31
|
+
return true;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
})();
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A mixin for connecting controllers to the element.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ControllerMixin<T extends Constructor<HTMLElement>>(
|
|
13
|
+
superclass: T
|
|
14
|
+
): T & Constructor<ControllerMixinClass>;
|
|
15
|
+
|
|
16
|
+
export declare class ControllerMixinClass
|
|
17
|
+
implements Pick<ReactiveControllerHost, 'addController' | 'removeController'>
|
|
18
|
+
{
|
|
19
|
+
/**
|
|
20
|
+
* Registers a controller to participate in the element update cycle.
|
|
21
|
+
*/
|
|
22
|
+
addController(controller: ReactiveController): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Removes a controller from the element.
|
|
26
|
+
*/
|
|
27
|
+
removeController(controller: ReactiveController): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* A mixin for connecting controllers to the element.
|
|
10
|
+
*
|
|
11
|
+
* @polymerMixin
|
|
12
|
+
*/
|
|
13
|
+
export const ControllerMixin = dedupingMixin(
|
|
14
|
+
(superClass) =>
|
|
15
|
+
class ControllerMixinClass extends superClass {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @type {Set<import('lit').ReactiveController>}
|
|
21
|
+
*/
|
|
22
|
+
this.__controllers = new Set();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @protected */
|
|
26
|
+
connectedCallback() {
|
|
27
|
+
super.connectedCallback();
|
|
28
|
+
|
|
29
|
+
this.__controllers.forEach((c) => {
|
|
30
|
+
c.hostConnected && c.hostConnected();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @protected */
|
|
35
|
+
disconnectedCallback() {
|
|
36
|
+
super.disconnectedCallback();
|
|
37
|
+
|
|
38
|
+
this.__controllers.forEach((c) => {
|
|
39
|
+
c.hostDisconnected && c.hostDisconnected();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Registers a controller to participate in the element update cycle.
|
|
45
|
+
*
|
|
46
|
+
* @param {import('lit').ReactiveController} controller
|
|
47
|
+
* @protected
|
|
48
|
+
*/
|
|
49
|
+
addController(controller) {
|
|
50
|
+
this.__controllers.add(controller);
|
|
51
|
+
// Call hostConnected if a controller is added after the element is attached.
|
|
52
|
+
if (this.$ !== undefined && this.isConnected && controller.hostConnected) {
|
|
53
|
+
controller.hostConnected();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Removes a controller from the element.
|
|
59
|
+
*
|
|
60
|
+
* @param {import('lit').ReactiveController} controller
|
|
61
|
+
* @protected
|
|
62
|
+
*/
|
|
63
|
+
removeController(controller) {
|
|
64
|
+
this.__controllers.delete(controller);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
);
|
package/src/dir-mixin.d.ts
CHANGED
|
@@ -3,22 +3,15 @@
|
|
|
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 { Constructor } from '@open-wc/dedupe-mixin';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A mixin to handle `dir` attribute based on the one set on the `<html>` element.
|
|
9
10
|
*/
|
|
10
|
-
declare function DirMixin<T extends
|
|
11
|
+
export declare function DirMixin<T extends Constructor<HTMLElement>>(base: T): T & Constructor<DirMixinClass>;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
export declare class DirMixinClass {
|
|
14
|
+
protected __getNormalizedScrollLeft(element: Element | null): number;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
protected __setNormalizedScrollLeft(element: Element | null, scrollLeft: number): void;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
interface DirMixin {
|
|
19
|
-
__getNormalizedScrollLeft(element: Element | null): number;
|
|
20
|
-
|
|
21
|
-
__setNormalizedScrollLeft(element: Element | null, scrollLeft: number): void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { DirMixin, DirMixinConstructor };
|
package/src/disabled-mixin.d.ts
CHANGED
|
@@ -3,21 +3,18 @@
|
|
|
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 { Constructor } from '@open-wc/dedupe-mixin';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A mixin to provide disabled property for field components.
|
|
9
10
|
*/
|
|
10
|
-
declare function DisabledMixin<T extends
|
|
11
|
+
export declare function DisabledMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<DisabledMixinClass> & T;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
new (...args: any[]): DisabledMixin;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface DisabledMixin {
|
|
13
|
+
export declare class DisabledMixinClass {
|
|
17
14
|
/**
|
|
18
15
|
* If true, the user cannot interact with this element.
|
|
19
16
|
*/
|
|
20
17
|
disabled: boolean;
|
|
21
|
-
}
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
protected _disabledChanged(disabled: boolean, oldDisabled: boolean): void;
|
|
20
|
+
}
|
package/src/element-mixin.d.ts
CHANGED
|
@@ -3,20 +3,20 @@
|
|
|
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 { ReactiveControllerHost } from 'lit';
|
|
7
6
|
import '../custom_typings/vaadin-usage-statistics.js';
|
|
8
7
|
import '../custom_typings/vaadin.js';
|
|
9
|
-
import {
|
|
8
|
+
import { Constructor } from '@open-wc/dedupe-mixin';
|
|
9
|
+
import { DirMixinClass } from './dir-mixin.js';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
finalize(): void;
|
|
18
|
-
}
|
|
11
|
+
/**
|
|
12
|
+
* A mixin providing common logic for Vaadin components.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ElementMixin<T extends Constructor<HTMLElement>>(
|
|
15
|
+
superclass: T
|
|
16
|
+
): T & Constructor<DirMixinClass> & Constructor<ElementMixinClass>;
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
export declare class ElementMixinClass {
|
|
19
|
+
static version: string;
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
protected static finalize(): void;
|
|
22
|
+
}
|
package/src/element-mixin.js
CHANGED
|
@@ -32,7 +32,7 @@ const registered = new Set();
|
|
|
32
32
|
export const ElementMixin = (superClass) =>
|
|
33
33
|
class VaadinElementMixin extends DirMixin(superClass) {
|
|
34
34
|
static get version() {
|
|
35
|
-
return '22.0.
|
|
35
|
+
return '22.0.1';
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/** @protected */
|
|
@@ -58,50 +58,10 @@ export const ElementMixin = (superClass) =>
|
|
|
58
58
|
constructor() {
|
|
59
59
|
super();
|
|
60
60
|
|
|
61
|
-
this.__controllers = new Set();
|
|
62
|
-
|
|
63
61
|
if (document.doctype === null) {
|
|
64
62
|
console.warn(
|
|
65
63
|
'Vaadin components require the "standards mode" declaration. Please add <!DOCTYPE html> to the HTML document.'
|
|
66
64
|
);
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
|
-
|
|
70
|
-
/** @protected */
|
|
71
|
-
connectedCallback() {
|
|
72
|
-
super.connectedCallback();
|
|
73
|
-
|
|
74
|
-
this.__controllers.forEach((c) => {
|
|
75
|
-
c.hostConnected && c.hostConnected();
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** @protected */
|
|
80
|
-
disconnectedCallback() {
|
|
81
|
-
super.disconnectedCallback();
|
|
82
|
-
|
|
83
|
-
this.__controllers.forEach((c) => {
|
|
84
|
-
c.hostDisconnected && c.hostDisconnected();
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Registers a controller to participate in the element update cycle.
|
|
90
|
-
* @protected
|
|
91
|
-
*/
|
|
92
|
-
addController(controller) {
|
|
93
|
-
this.__controllers.add(controller);
|
|
94
|
-
// Call hostConnected if a controller is added after the element is attached.
|
|
95
|
-
if (this.$ !== undefined && this.isConnected && controller.hostConnected) {
|
|
96
|
-
controller.hostConnected();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Removes a controller from the element.
|
|
102
|
-
* @protected
|
|
103
|
-
*/
|
|
104
|
-
removeController(controller) {
|
|
105
|
-
this.__controllers.delete(controller);
|
|
106
|
-
}
|
|
107
67
|
};
|
package/src/focus-mixin.d.ts
CHANGED
|
@@ -3,31 +3,28 @@
|
|
|
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 { Constructor } from '@open-wc/dedupe-mixin';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A mixin to handle `focused` and `focus-ring` attributes based on focus.
|
|
9
10
|
*/
|
|
10
|
-
declare function FocusMixin<T extends
|
|
11
|
+
export declare function FocusMixin<T extends Constructor<HTMLElement>>(base: T): T & Constructor<FocusMixinClass>;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
13
|
+
export declare class FocusMixinClass {
|
|
14
|
+
protected readonly _keyboardActive: boolean;
|
|
15
15
|
|
|
16
|
-
interface FocusMixin {
|
|
17
16
|
/**
|
|
18
17
|
* Override to change how focused and focus-ring attributes are set.
|
|
19
18
|
*/
|
|
20
|
-
_setFocused(focused: boolean): void;
|
|
19
|
+
protected _setFocused(focused: boolean): void;
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Override to define if the field receives focus based on the event.
|
|
24
23
|
*/
|
|
25
|
-
_shouldSetFocus(event: FocusEvent): boolean;
|
|
24
|
+
protected _shouldSetFocus(event: FocusEvent): boolean;
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
27
|
* Override to define if the field loses focus based on the event.
|
|
29
28
|
*/
|
|
30
|
-
_shouldRemoveFocus(event: FocusEvent): boolean;
|
|
29
|
+
protected _shouldRemoveFocus(event: FocusEvent): boolean;
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
export { FocusMixinConstructor, FocusMixin };
|
package/src/focus-mixin.js
CHANGED
|
@@ -35,6 +35,14 @@ window.addEventListener(
|
|
|
35
35
|
export const FocusMixin = dedupingMixin(
|
|
36
36
|
(superclass) =>
|
|
37
37
|
class FocusMixinClass extends superclass {
|
|
38
|
+
/**
|
|
39
|
+
* @protected
|
|
40
|
+
* @return {boolean}
|
|
41
|
+
*/
|
|
42
|
+
get _keyboardActive() {
|
|
43
|
+
return keyboardActive;
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
/** @protected */
|
|
39
47
|
ready() {
|
|
40
48
|
this.addEventListener('focusin', (e) => {
|
|
@@ -78,13 +86,13 @@ export const FocusMixin = dedupingMixin(
|
|
|
78
86
|
|
|
79
87
|
// focus-ring is true when the element was focused from the keyboard.
|
|
80
88
|
// Focus Ring [A11ycasts]: https://youtu.be/ilj2P5-5CjI
|
|
81
|
-
this.toggleAttribute('focus-ring', focused &&
|
|
89
|
+
this.toggleAttribute('focus-ring', focused && this._keyboardActive);
|
|
82
90
|
}
|
|
83
91
|
|
|
84
92
|
/**
|
|
85
93
|
* Override to define if the field receives focus based on the event.
|
|
86
94
|
*
|
|
87
|
-
* @param {FocusEvent}
|
|
95
|
+
* @param {FocusEvent} _event
|
|
88
96
|
* @return {boolean}
|
|
89
97
|
* @protected
|
|
90
98
|
*/
|
|
@@ -95,7 +103,7 @@ export const FocusMixin = dedupingMixin(
|
|
|
95
103
|
/**
|
|
96
104
|
* Override to define if the field loses focus based on the event.
|
|
97
105
|
*
|
|
98
|
-
* @param {FocusEvent}
|
|
106
|
+
* @param {FocusEvent} _event
|
|
99
107
|
* @return {boolean}
|
|
100
108
|
* @protected
|
|
101
109
|
*/
|
package/src/iron-list-core.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* Code distributed by Google as part of the polymer project is also
|
|
8
8
|
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { animationFrame, idlePeriod, microTask } from './async.js';
|
|
11
|
+
import { Debouncer, enqueueDebouncer, flush } from './debounce.js';
|
|
12
12
|
|
|
13
13
|
const IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);
|
|
14
14
|
const IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8;
|
package/src/keyboard-mixin.d.ts
CHANGED
|
@@ -3,30 +3,25 @@
|
|
|
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 { Constructor } from '@open-wc/dedupe-mixin';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A mixin that manages keyboard handling.
|
|
9
10
|
* The mixin subscribes to the keyboard events while an actual implementation
|
|
10
11
|
* for the event handlers is left to the client (a component or another mixin).
|
|
11
12
|
*/
|
|
12
|
-
declare function KeyboardMixin<T extends
|
|
13
|
+
export declare function KeyboardMixin<T extends Constructor<HTMLElement>>(base: T): T & Constructor<KeyboardMixinClass>;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
new (...args: any[]): KeyboardMixin;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface KeyboardMixin {
|
|
15
|
+
export declare class KeyboardMixinClass {
|
|
19
16
|
/**
|
|
20
17
|
* A handler for the `keydown` event. By default, it does nothing.
|
|
21
18
|
* Override the method to implement your own behavior.
|
|
22
19
|
*/
|
|
23
|
-
_onKeyDown(event: KeyboardEvent): void;
|
|
20
|
+
protected _onKeyDown(event: KeyboardEvent): void;
|
|
24
21
|
|
|
25
22
|
/**
|
|
26
23
|
* A handler for the `keyup` event. By default, it does nothing.
|
|
27
24
|
* Override the method to implement your own behavior.
|
|
28
25
|
*/
|
|
29
|
-
_onKeyUp(event: KeyboardEvent): void;
|
|
26
|
+
protected _onKeyUp(event: KeyboardEvent): void;
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
export { KeyboardMixinConstructor, KeyboardMixin };
|
package/src/slot-mixin.d.ts
CHANGED
|
@@ -3,21 +3,16 @@
|
|
|
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 { Constructor } from '@open-wc/dedupe-mixin';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A mixin to provide content for named slots defined by component.
|
|
9
10
|
*/
|
|
10
|
-
declare function SlotMixin<T extends
|
|
11
|
+
export declare function SlotMixin<T extends Constructor<HTMLElement>>(base: T): T & Constructor<SlotMixinClass>;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
new (...args: any[]): SlotMixin;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface SlotMixin {
|
|
13
|
+
export declare class SlotMixinClass {
|
|
17
14
|
/**
|
|
18
15
|
* List of named slots to initialize.
|
|
19
16
|
*/
|
|
20
|
-
readonly slots: Record<string, () => HTMLElement>;
|
|
17
|
+
protected readonly slots: Record<string, () => HTMLElement>;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
export { SlotMixinConstructor, SlotMixin };
|
package/src/tabindex-mixin.d.ts
CHANGED
|
@@ -3,27 +3,31 @@
|
|
|
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 {
|
|
6
|
+
import { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import { DisabledMixinClass } from './disabled-mixin.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
* A mixin to
|
|
10
|
+
* A mixin to toggle the `tabindex` attribute.
|
|
10
11
|
*
|
|
11
12
|
* By default, the attribute is set to 0 that makes the element focusable.
|
|
12
13
|
*
|
|
13
14
|
* The attribute is set to -1 whenever the user disables the element
|
|
14
15
|
* and restored with the last known value once the element is enabled.
|
|
15
16
|
*/
|
|
16
|
-
declare function TabindexMixin<T extends
|
|
17
|
+
export declare function TabindexMixin<T extends Constructor<HTMLElement>>(
|
|
18
|
+
base: T
|
|
19
|
+
): T & Constructor<DisabledMixinClass> & Constructor<TabindexMixinClass>;
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
new (...args: any[]): TabindexMixin;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface TabindexMixin extends DisabledMixin {
|
|
21
|
+
export declare class TabindexMixinClass {
|
|
23
22
|
/**
|
|
24
23
|
* Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
|
|
25
24
|
*/
|
|
26
25
|
tabindex: number | undefined | null;
|
|
27
|
-
}
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
/**
|
|
28
|
+
* When the user has changed tabindex while the element is disabled,
|
|
29
|
+
* the observer reverts tabindex to -1 and rather saves the new tabindex value to apply it later.
|
|
30
|
+
* The new value will be applied as soon as the element becomes enabled.
|
|
31
|
+
*/
|
|
32
|
+
protected _tabindexChanged(tabindex: number | undefined | null): void;
|
|
33
|
+
}
|
package/src/tabindex-mixin.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { animationFrame, timeOut } from './async.js';
|
|
7
|
+
import { isSafari } from './browser-utils.js';
|
|
8
|
+
import { Debouncer, flush } from './debounce.js';
|
|
3
9
|
import { ironList } from './iron-list-core.js';
|
|
4
10
|
|
|
5
11
|
// iron-list can by default handle sizes up to around 100000.
|
|
@@ -20,8 +26,6 @@ export class IronListAdapter {
|
|
|
20
26
|
// Iron-list uses this value to determine how many pages of elements to render
|
|
21
27
|
this._maxPages = 1.3;
|
|
22
28
|
|
|
23
|
-
this.__safari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
24
|
-
|
|
25
29
|
this.timeouts = {
|
|
26
30
|
SCROLL_REORDER: 500,
|
|
27
31
|
IGNORE_WHEEL: 500
|
|
@@ -268,6 +272,8 @@ export class IronListAdapter {
|
|
|
268
272
|
if (!el.hidden) {
|
|
269
273
|
el.__virtualIndex = vidx + (this._vidxOffset || 0);
|
|
270
274
|
this.__updateElement(el, el.__virtualIndex);
|
|
275
|
+
} else {
|
|
276
|
+
delete el.__lastUpdatedIndex;
|
|
271
277
|
}
|
|
272
278
|
}, itemSet);
|
|
273
279
|
}
|
|
@@ -447,7 +453,7 @@ export class IronListAdapter {
|
|
|
447
453
|
// Due to a rendering bug, reordering the rows can make parts of the scroll target disappear
|
|
448
454
|
// on Safari when using sticky positioning in case the scroll target is inside a flexbox.
|
|
449
455
|
// This issue manifests with grid (the header can disappear if grid is used inside a flexbox)
|
|
450
|
-
if (
|
|
456
|
+
if (isSafari) {
|
|
451
457
|
const { transform } = this.scrollTarget.style;
|
|
452
458
|
this.scrollTarget.style.transform = 'translateZ(0)';
|
|
453
459
|
setTimeout(() => (this.scrollTarget.style.transform = transform));
|