@vaadin/component-base 24.0.0-alpha1 → 24.0.0-alpha11

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.
Files changed (65) hide show
  1. package/index.d.ts +0 -1
  2. package/index.js +0 -1
  3. package/package.json +2 -2
  4. package/src/a11y-announcer.d.ts +1 -1
  5. package/src/a11y-announcer.js +1 -1
  6. package/src/active-mixin.d.ts +1 -1
  7. package/src/active-mixin.js +1 -1
  8. package/src/browser-utils.js +7 -7
  9. package/src/controller-mixin.d.ts +1 -1
  10. package/src/controller-mixin.js +1 -1
  11. package/src/delegate-focus-mixin.d.ts +48 -0
  12. package/src/delegate-focus-mixin.js +228 -0
  13. package/src/delegate-state-mixin.d.ts +20 -0
  14. package/src/delegate-state-mixin.js +125 -0
  15. package/src/dir-mixin.d.ts +2 -4
  16. package/src/dir-mixin.js +7 -29
  17. package/src/dir-utils.d.ts +19 -0
  18. package/src/dir-utils.js +36 -0
  19. package/src/disabled-mixin.d.ts +1 -1
  20. package/src/disabled-mixin.js +1 -1
  21. package/src/dom-utils.d.ts +1 -1
  22. package/src/dom-utils.js +1 -1
  23. package/src/element-mixin.d.ts +1 -1
  24. package/src/element-mixin.js +11 -5
  25. package/src/focus-mixin.d.ts +1 -1
  26. package/src/focus-mixin.js +1 -1
  27. package/src/focus-trap-controller.d.ts +1 -1
  28. package/src/focus-trap-controller.js +22 -22
  29. package/src/focus-utils.d.ts +1 -1
  30. package/src/focus-utils.js +1 -1
  31. package/src/gestures.js +1 -1
  32. package/src/iron-list-core.js +32 -12
  33. package/src/keyboard-direction-mixin.d.ts +1 -1
  34. package/src/keyboard-direction-mixin.js +12 -12
  35. package/src/keyboard-mixin.d.ts +1 -1
  36. package/src/keyboard-mixin.js +1 -1
  37. package/src/list-mixin.d.ts +50 -0
  38. package/src/list-mixin.js +343 -0
  39. package/src/media-query-controller.d.ts +1 -1
  40. package/src/media-query-controller.js +1 -1
  41. package/src/overflow-controller.d.ts +1 -1
  42. package/src/overflow-controller.js +3 -3
  43. package/src/overlay-class-mixin.d.ts +33 -0
  44. package/src/overlay-class-mixin.js +79 -0
  45. package/src/polylit-mixin.d.ts +1 -1
  46. package/src/polylit-mixin.js +9 -4
  47. package/src/resize-mixin.d.ts +1 -1
  48. package/src/resize-mixin.js +11 -21
  49. package/src/slot-child-observe-controller.d.ts +28 -0
  50. package/src/slot-child-observe-controller.js +176 -0
  51. package/src/slot-controller.d.ts +33 -5
  52. package/src/slot-controller.js +103 -40
  53. package/src/tabindex-mixin.d.ts +1 -1
  54. package/src/tabindex-mixin.js +1 -1
  55. package/src/templates.js +1 -1
  56. package/src/tooltip-controller.d.ts +1 -1
  57. package/src/tooltip-controller.js +1 -1
  58. package/src/unique-id-utils.d.ts +1 -1
  59. package/src/unique-id-utils.js +1 -1
  60. package/src/virtualizer-iron-list-adapter.js +67 -9
  61. package/src/virtualizer.js +18 -18
  62. package/src/dir-helper.d.ts +0 -42
  63. package/src/dir-helper.js +0 -93
  64. package/src/slot-mixin.d.ts +0 -18
  65. package/src/slot-mixin.js +0 -60
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
package/src/dom-utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 '../custom_typings/vaadin-usage-statistics.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 { setCancelSyntheticClickEvents } from '@polymer/polymer/lib/utils/settings.js';
@@ -15,14 +15,20 @@ import { DirMixin } from './dir-mixin.js';
15
15
  // for buttons that are based on `[role=button]` e.g vaadin-button.
16
16
  setCancelSyntheticClickEvents(false);
17
17
 
18
- window.Vaadin = window.Vaadin || {};
18
+ if (!window.Vaadin) {
19
+ window.Vaadin = {};
20
+ }
19
21
 
20
22
  /**
21
23
  * Array of Vaadin custom element classes that have been finalized.
22
24
  */
23
- window.Vaadin.registrations = window.Vaadin.registrations || [];
25
+ if (!window.Vaadin.registrations) {
26
+ window.Vaadin.registrations = [];
27
+ }
24
28
 
25
- window.Vaadin.developmentModeCallback = window.Vaadin.developmentModeCallback || {};
29
+ if (!window.Vaadin.developmentModeCallback) {
30
+ window.Vaadin.developmentModeCallback = {};
31
+ }
26
32
 
27
33
  window.Vaadin.developmentModeCallback['vaadin-usage-statistics'] = function () {
28
34
  usageStatistics();
@@ -39,7 +45,7 @@ const registered = new Set();
39
45
  export const ElementMixin = (superClass) =>
40
46
  class VaadinElementMixin extends DirMixin(superClass) {
41
47
  static get version() {
42
- return '24.0.0-alpha1';
48
+ return '24.0.0-alpha11';
43
49
  }
44
50
 
45
51
  /** @protected */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { ReactiveController } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 { getFocusableElements, isElementFocused } from './focus-utils.js';
@@ -33,6 +33,27 @@ export class FocusTrapController {
33
33
  this.__onKeyDown = this.__onKeyDown.bind(this);
34
34
  }
35
35
 
36
+ /**
37
+ * An array of tab-ordered focusable elements inside the trap node.
38
+ *
39
+ * @return {HTMLElement[]}
40
+ * @private
41
+ */
42
+ get __focusableElements() {
43
+ return getFocusableElements(this.__trapNode);
44
+ }
45
+
46
+ /**
47
+ * The index of the element inside the trap node that currently has focus.
48
+ *
49
+ * @return {HTMLElement | undefined}
50
+ * @private
51
+ */
52
+ get __focusedElementIndex() {
53
+ const focusableElements = this.__focusableElements;
54
+ return focusableElements.indexOf(focusableElements.filter(isElementFocused).pop());
55
+ }
56
+
36
57
  hostConnected() {
37
58
  document.addEventListener('keydown', this.__onKeyDown);
38
59
  }
@@ -131,25 +152,4 @@ export class FocusTrapController {
131
152
  element.select();
132
153
  }
133
154
  }
134
-
135
- /**
136
- * An array of tab-ordered focusable elements inside the trap node.
137
- *
138
- * @return {HTMLElement[]}
139
- * @private
140
- */
141
- get __focusableElements() {
142
- return getFocusableElements(this.__trapNode);
143
- }
144
-
145
- /**
146
- * The index of the element inside the trap node that currently has focus.
147
- *
148
- * @return {HTMLElement | undefined}
149
- * @private
150
- */
151
- get __focusedElementIndex() {
152
- const focusableElements = this.__focusableElements;
153
- return focusableElements.indexOf(focusableElements.filter(isElementFocused).pop());
154
- }
155
155
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
package/src/gestures.js CHANGED
@@ -90,7 +90,7 @@ function PASSIVE_TOUCH(eventName) {
90
90
  }
91
91
 
92
92
  // Check for touch-only devices
93
- const IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);
93
+ const IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/u);
94
94
 
95
95
  // Defined at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute
96
96
  /** @type {!Object<boolean>} */
@@ -10,12 +10,22 @@
10
10
  import { animationFrame, idlePeriod, microTask } from './async.js';
11
11
  import { Debouncer, enqueueDebouncer, flush } from './debounce.js';
12
12
 
13
- const IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);
13
+ const IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/u);
14
14
  const IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8;
15
15
  const DEFAULT_PHYSICAL_COUNT = 3;
16
16
 
17
17
  /**
18
- * @private
18
+ * DO NOT EDIT THIS FILE!
19
+ *
20
+ * This file includes the iron-list scrolling engine copied from
21
+ * https://github.com/PolymerElements/iron-list/blob/master/iron-list.js
22
+ *
23
+ * If something in the scrolling engine needs to be changed
24
+ * for the virtualizer's purposes, override a function
25
+ * in virtualizer-iron-list-adapter.js instead of changing it here.
26
+ *
27
+ * This will allow us to keep the iron-list code here as close to
28
+ * the original as possible.
19
29
  */
20
30
  export const ironList = {
21
31
  /**
@@ -491,9 +501,12 @@ export const ironList = {
491
501
  this._physicalIndexForKey = {};
492
502
  this._firstVisibleIndexVal = null;
493
503
  this._lastVisibleIndexVal = null;
494
- this._physicalCount = this._physicalCount || 0;
495
- this._physicalItems = this._physicalItems || [];
496
- this._physicalSizes = this._physicalSizes || [];
504
+ if (!this._physicalItems) {
505
+ this._physicalItems = [];
506
+ }
507
+ if (!this._physicalSizes) {
508
+ this._physicalSizes = [];
509
+ }
497
510
  this._physicalStart = 0;
498
511
  if (this._scrollTop > this._scrollOffset) {
499
512
  this._resetScrollPosition(0);
@@ -635,16 +648,21 @@ export const ironList = {
635
648
  * @param {boolean=} forceUpdate If true, updates the height no matter what.
636
649
  */
637
650
  _updateScrollerSize(forceUpdate) {
638
- this._estScrollHeight =
651
+ const estScrollHeight =
639
652
  this._physicalBottom +
640
653
  Math.max(this._virtualCount - this._physicalCount - this._virtualStart, 0) * this._physicalAverage;
641
654
 
642
- forceUpdate = forceUpdate || this._scrollHeight === 0;
643
- forceUpdate = forceUpdate || this._scrollPosition >= this._estScrollHeight - this._physicalSize;
655
+ this._estScrollHeight = estScrollHeight;
656
+
644
657
  // Amortize height adjustment, so it won't trigger large repaints too often.
645
- if (forceUpdate || Math.abs(this._estScrollHeight - this._scrollHeight) >= this._viewportHeight) {
646
- this.$.items.style.height = `${this._estScrollHeight}px`;
647
- this._scrollHeight = this._estScrollHeight;
658
+ if (
659
+ forceUpdate ||
660
+ this._scrollHeight === 0 ||
661
+ this._scrollPosition >= estScrollHeight - this._physicalSize ||
662
+ Math.abs(estScrollHeight - this._scrollHeight) >= this._viewportHeight
663
+ ) {
664
+ this.$.items.style.height = `${estScrollHeight}px`;
665
+ this._scrollHeight = estScrollHeight;
648
666
  }
649
667
  },
650
668
 
@@ -740,7 +758,9 @@ export const ironList = {
740
758
  },
741
759
 
742
760
  _debounce(name, cb, asyncModule) {
743
- this._debouncers = this._debouncers || {};
761
+ if (!this._debouncers) {
762
+ this._debouncers = {};
763
+ }
744
764
  this._debouncers[name] = Debouncer.debounce(this._debouncers[name], asyncModule, cb.bind(this));
745
765
  enqueueDebouncer(this._debouncers[name]);
746
766
  },
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2023 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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2023 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 { isElementFocused, isElementHidden } from './focus-utils.js';
@@ -14,17 +14,6 @@ import { KeyboardMixin } from './keyboard-mixin.js';
14
14
  */
15
15
  export const KeyboardDirectionMixin = (superclass) =>
16
16
  class KeyboardDirectionMixinClass extends KeyboardMixin(superclass) {
17
- /** @protected */
18
- focus() {
19
- const items = this._getItems();
20
- if (Array.isArray(items)) {
21
- const idx = this._getAvailableIndex(items, 0, null, (item) => !isElementHidden(item));
22
- if (idx >= 0) {
23
- items[idx].focus();
24
- }
25
- }
26
- }
27
-
28
17
  /**
29
18
  * @return {Element | null}
30
19
  * @protected
@@ -41,6 +30,17 @@ export const KeyboardDirectionMixin = (superclass) =>
41
30
  return true;
42
31
  }
43
32
 
33
+ /** @protected */
34
+ focus() {
35
+ const items = this._getItems();
36
+ if (Array.isArray(items)) {
37
+ const idx = this._getAvailableIndex(items, 0, null, (item) => !isElementHidden(item));
38
+ if (idx >= 0) {
39
+ items[idx].focus();
40
+ }
41
+ }
42
+ }
43
+
44
44
  /**
45
45
  * Get the list of items participating in keyboard navigation.
46
46
  * By default, it treats all the light DOM children as items.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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,50 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { KeyboardDirectionMixinClass } from './keyboard-direction-mixin.js';
8
+ import type { KeyboardMixinClass } from './keyboard-mixin.js';
9
+
10
+ /**
11
+ * A mixin for list elements, facilitating navigation and selection of items.
12
+ */
13
+ export declare function ListMixin<T extends Constructor<HTMLElement>>(
14
+ base: T,
15
+ ): Constructor<KeyboardDirectionMixinClass> & Constructor<KeyboardMixinClass> & Constructor<ListMixinClass> & T;
16
+
17
+ export declare class ListMixinClass {
18
+ /**
19
+ * Used for mixin detection because `instanceof` does not work with mixins.
20
+ */
21
+ _hasVaadinListMixin: boolean;
22
+
23
+ /**
24
+ * The index of the item selected in the items array.
25
+ * Note: Not updated when used in `multiple` selection mode.
26
+ */
27
+ selected: number | null | undefined;
28
+
29
+ /**
30
+ * Define how items are disposed in the dom.
31
+ * Possible values are: `horizontal|vertical`.
32
+ * It also changes navigation keys from left/right to up/down.
33
+ */
34
+ orientation: 'horizontal' | 'vertical';
35
+
36
+ /**
37
+ * The list of items from which a selection can be made.
38
+ * It is populated from the elements passed to the light DOM,
39
+ * and updated dynamically when adding or removing items.
40
+ *
41
+ * The item elements must implement `Vaadin.ItemMixin`.
42
+ *
43
+ * Note: unlike `<vaadin-combo-box>`, this property is read-only,
44
+ * so if you want to provide items by iterating array of data,
45
+ * you have to use `dom-repeat` and place it to the light DOM.
46
+ */
47
+ readonly items: Element[] | undefined;
48
+
49
+ protected readonly _scrollerElement: HTMLElement;
50
+ }