@vaadin/component-base 25.2.0-alpha10 → 25.2.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.
@@ -104,7 +104,7 @@
104
104
  "declarations": [
105
105
  {
106
106
  "kind": "mixin",
107
- "description": "A mixin that allows to set partial I18N properties.",
107
+ "description": "A mixin that allows to set partial I18N properties.\n\nSubclasses provide their default values by overriding the\n`defaultI18n` static getter:\n\n```js\nstatic get defaultI18n() {\n return { foo: 'Foo', bar: 'Bar' };\n}\n```",
108
108
  "name": "I18nMixin",
109
109
  "members": [
110
110
  {
@@ -129,9 +129,6 @@
129
129
  }
130
130
  ],
131
131
  "parameters": [
132
- {
133
- "name": "defaultI18n"
134
- },
135
132
  {
136
133
  "name": "superClass"
137
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/component-base",
3
- "version": "25.2.0-alpha10",
3
+ "version": "25.2.0-alpha11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,11 +38,11 @@
38
38
  "lit": "^3.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@vaadin/chai-plugins": "25.2.0-alpha10",
42
- "@vaadin/test-runner-commands": "25.2.0-alpha10",
41
+ "@vaadin/chai-plugins": "25.2.0-alpha11",
42
+ "@vaadin/test-runner-commands": "25.2.0-alpha11",
43
43
  "@vaadin/testing-helpers": "^2.0.0",
44
44
  "sinon": "^21.0.2"
45
45
  },
46
46
  "customElements": "custom-elements.json",
47
- "gitHead": "1303b6a3eeecb44a9d26f2b53cb56d9e906febdf"
47
+ "gitHead": "fdc37e932709f95491a027aeb2090911cb7528c6"
48
48
  }
@@ -3,7 +3,6 @@
3
3
  * Copyright (c) 2021 - 2026 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import type { ReactiveController } from 'lit';
7
6
  import type { Cache } from './cache.js';
8
7
  import type { getFlatIndexByPath, getFlatIndexContext, getItemContext } from './helpers.js';
9
8
 
@@ -23,10 +22,7 @@ export type DataProvider<TItem, TDataProviderParams extends Record<string, unkno
23
22
  /**
24
23
  * A controller that stores and manages items loaded with a data provider.
25
24
  */
26
- export class DataProviderController<
27
- TItem,
28
- TDataProviderParams extends Record<string, unknown>,
29
- > implements ReactiveController {
25
+ export class DataProviderController<TItem, TDataProviderParams extends Record<string, unknown>> extends EventTarget {
30
26
  /**
31
27
  * The controller host element.
32
28
  */
@@ -94,10 +90,6 @@ export class DataProviderController<
94
90
  */
95
91
  get flatSize(): number;
96
92
 
97
- hostConnected(): void;
98
-
99
- hostDisconnected(): void;
100
-
101
93
  /**
102
94
  * Whether the root cache or any of its decendant caches have pending requests.
103
95
  */
package/src/define.js CHANGED
@@ -13,7 +13,7 @@ function dashToCamelCase(dash) {
13
13
 
14
14
  const experimentalMap = {};
15
15
 
16
- export function defineCustomElement(CustomElement, version = '25.2.0-alpha10') {
16
+ export function defineCustomElement(CustomElement, version = '25.2.0-alpha11') {
17
17
  Object.defineProperty(CustomElement, 'version', {
18
18
  get() {
19
19
  return version;
@@ -7,8 +7,6 @@ import { dedupeMixin } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  /**
9
9
  * A mixin to delegate properties and attributes to a target element.
10
- *
11
- * @polymerMixin
12
10
  */
13
11
  const DelegateStateMixinImplementation = (superclass) => {
14
12
  return class DelegateStateMixinClass extends superclass {
package/src/dir-mixin.js CHANGED
@@ -33,8 +33,6 @@ directionObserver.observe(document.documentElement, { attributes: true, attribut
33
33
 
34
34
  /**
35
35
  * A mixin to handle `dir` attribute based on the one set on the `<html>` element.
36
- *
37
- * @polymerMixin
38
36
  */
39
37
  export const DirMixin = (superClass) =>
40
38
  class VaadinDirMixin extends superClass {
@@ -31,10 +31,6 @@ let statsJob;
31
31
 
32
32
  const registered = new Set();
33
33
 
34
- /**
35
- * @polymerMixin
36
- * @mixes DirMixin
37
- */
38
34
  export const ElementMixin = (superClass) =>
39
35
  class VaadinElementMixin extends DirMixin(superClass) {
40
36
  /** @protected */
package/src/gestures.js CHANGED
@@ -121,7 +121,7 @@ function hasLeftMouseButton(ev) {
121
121
  // instead we use ev.buttons (bitmask of buttons) or fall back to ev.which (deprecated, 0 for no buttons, 1 for left button)
122
122
  if (type === 'mousemove') {
123
123
  // Allow undefined for testing events
124
- let buttons = ev.buttons === undefined ? 1 : ev.buttons;
124
+ let buttons = ev.buttons ?? 1;
125
125
  if (ev instanceof window.MouseEvent && !MOUSE_HAS_BUTTONS) {
126
126
  buttons = MOUSE_WHICH_TO_BUTTONS[ev.which] || 0;
127
127
  }
@@ -129,7 +129,7 @@ function hasLeftMouseButton(ev) {
129
129
  return Boolean(buttons & 1);
130
130
  }
131
131
  // Allow undefined for testing events
132
- const button = ev.button === undefined ? 0 : ev.button;
132
+ const button = ev.button ?? 0;
133
133
  // Ev.button is 0 in mousedown/mouseup/click for left button activation
134
134
  return button === 0;
135
135
  }
@@ -8,8 +8,7 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
8
8
  /**
9
9
  * A mixin that allows to set partial I18N properties.
10
10
  */
11
- export declare function I18nMixin<I, T extends Constructor<HTMLElement>>(
12
- defaultI18n: I,
11
+ export declare function I18nMixin<T extends Constructor<HTMLElement>, I = unknown>(
13
12
  superclass: T,
14
13
  ): Constructor<I18nMixinClass<I>> & T;
15
14
 
package/src/i18n-mixin.js CHANGED
@@ -35,9 +35,16 @@ function deepMerge(target, ...sources) {
35
35
  /**
36
36
  * A mixin that allows to set partial I18N properties.
37
37
  *
38
- * @polymerMixin
38
+ * Subclasses provide their default values by overriding the
39
+ * `defaultI18n` static getter:
40
+ *
41
+ * ```js
42
+ * static get defaultI18n() {
43
+ * return { foo: 'Foo', bar: 'Bar' };
44
+ * }
45
+ * ```
39
46
  */
40
- export const I18nMixin = (defaultI18n, superClass) =>
47
+ export const I18nMixin = (superClass) =>
41
48
  class I18nMixinClass extends superClass {
42
49
  static get properties() {
43
50
  return {
@@ -55,10 +62,20 @@ export const I18nMixin = (defaultI18n, superClass) =>
55
62
  };
56
63
  }
57
64
 
65
+ /**
66
+ * Default I18N values. Must be overridden by subclasses with actual defaults.
67
+ *
68
+ * @protected
69
+ * @return {Object}
70
+ */
71
+ static get defaultI18n() {
72
+ return {};
73
+ }
74
+
58
75
  constructor() {
59
76
  super();
60
77
 
61
- this.i18n = deepMerge({}, defaultI18n);
78
+ this.i18n = deepMerge({}, this.constructor.defaultI18n);
62
79
  }
63
80
 
64
81
  /**
@@ -80,6 +97,6 @@ export const I18nMixin = (defaultI18n, superClass) =>
80
97
  return;
81
98
  }
82
99
  this.__customI18n = value;
83
- this.__effectiveI18n = deepMerge({}, defaultI18n, this.__customI18n);
100
+ this.__effectiveI18n = deepMerge({}, this.constructor.defaultI18n, this.__customI18n);
84
101
  }
85
102
  };
@@ -7,8 +7,6 @@
7
7
  /**
8
8
  * A mixin that forwards CSS class names to the internal overlay element
9
9
  * by setting the `overlayClass` property or `overlay-class` attribute.
10
- *
11
- * @polymerMixin
12
10
  */
13
11
  export const OverlayClassMixin = (superclass) =>
14
12
  class OverlayClassMixinClass extends superclass {
@@ -26,8 +26,6 @@ const observer = new ResizeObserver((entries) => {
26
26
 
27
27
  /**
28
28
  * A mixin that uses a ResizeObserver to listen to host size changes.
29
- *
30
- * @polymerMixin
31
29
  */
32
30
  const ResizeMixinImplementation = (superclass) =>
33
31
  class ResizeMixinClass extends superclass {
@@ -9,13 +9,13 @@
9
9
  */
10
10
  export class SlotObserver {
11
11
  constructor(slot, callback, forceInitial) {
12
- /** @type HTMLSlotElement */
12
+ /** @type {HTMLSlotElement} */
13
13
  this.slot = slot;
14
14
 
15
- /** @type Function */
15
+ /** @type {Function} */
16
16
  this.callback = callback;
17
17
 
18
- /** @type boolean */
18
+ /** @type {boolean} */
19
19
  this.forceInitial = forceInitial;
20
20
 
21
21
  /** @type {Node[]} */
@@ -39,8 +39,6 @@ function insertStyles(styles, root) {
39
39
  /**
40
40
  * Mixin to insert styles into the outer scope to handle slotted components.
41
41
  * This is useful e.g. to hide native `<input type="number">` controls.
42
- *
43
- * @polymerMixin
44
42
  */
45
43
  const SlotStylesMixinImplementation = (superclass) =>
46
44
  class SlotStylesMixinClass extends superclass {
@@ -23,6 +23,8 @@ type TooltipPosition =
23
23
  * A controller that manages the slotted tooltip element.
24
24
  */
25
25
  export class TooltipController extends SlotController {
26
+ constructor(host: HTMLElement);
27
+
26
28
  /**
27
29
  * An HTML element for linking with the tooltip overlay
28
30
  * via `aria-describedby` attribute used by screen readers.
@@ -515,11 +515,19 @@ export class IronListAdapter {
515
515
 
516
516
  /** @private */
517
517
  __getFocusedElement(visibleElements = this.__getVisibleElements()) {
518
- return visibleElements.find(
519
- (element) =>
520
- element.contains(this.elementsContainer.getRootNode().activeElement) ||
521
- element.contains(this.scrollTarget.getRootNode().activeElement),
522
- );
518
+ // `document.activeElement` retargets to the outermost shadow host when
519
+ // focus lives in a nested shadow tree. Descend through nested shadow
520
+ // roots' `activeElement`s to reach the real focused node, then walk up
521
+ // the flattened tree (via `assignedSlot`/`parentNode`/`host`) until a
522
+ // visible row is reached.
523
+ let node = document.activeElement;
524
+ while (node?.shadowRoot?.activeElement) {
525
+ node = node.shadowRoot.activeElement;
526
+ }
527
+ while (node && !visibleElements.includes(node)) {
528
+ node = node.assignedSlot || node.parentNode || node.host;
529
+ }
530
+ return node;
523
531
  }
524
532
 
525
533
  /** @private */