@vaadin/component-base 24.7.0-alpha8 → 24.7.0-beta1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/component-base",
3
- "version": "24.7.0-alpha8",
3
+ "version": "24.7.0-beta1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,10 +38,10 @@
38
38
  "lit": "^3.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@vaadin/chai-plugins": "24.7.0-alpha8",
42
- "@vaadin/test-runner-commands": "24.7.0-alpha8",
41
+ "@vaadin/chai-plugins": "24.7.0-beta1",
42
+ "@vaadin/test-runner-commands": "24.7.0-beta1",
43
43
  "@vaadin/testing-helpers": "^1.1.0",
44
44
  "sinon": "^18.0.0"
45
45
  },
46
- "gitHead": "d015035192480fcc8cc9df5d00a950f177b83c32"
46
+ "gitHead": "4043c518ef9b915cde612d2907ddc9bd10e5af17"
47
47
  }
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 = '24.7.0-alpha8') {
16
+ export function defineCustomElement(CustomElement, version = '24.7.0-beta1') {
17
17
  Object.defineProperty(CustomElement, 'version', {
18
18
  get() {
19
19
  return version;
package/src/gestures.js CHANGED
@@ -583,7 +583,6 @@ register({
583
583
  return;
584
584
  }
585
585
  const t = _findOriginalTarget(e);
586
- // eslint-disable-next-line @typescript-eslint/no-this-alias
587
586
  const self = this;
588
587
  const movefn = (e) => {
589
588
  if (!hasLeftMouseButton(e)) {
@@ -694,7 +693,6 @@ register({
694
693
  return;
695
694
  }
696
695
  const t = _findOriginalTarget(e);
697
- // eslint-disable-next-line @typescript-eslint/no-this-alias
698
696
  const self = this;
699
697
  const movefn = (e) => {
700
698
  const x = e.clientX,
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2025 - 2025 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
+
8
+ /**
9
+ * Recursively makes all properties of an i18n object optional.
10
+ *
11
+ * For internal use only.
12
+ */
13
+ export type PartialI18n<T> = T extends object
14
+ ? {
15
+ [P in keyof T]?: PartialI18n<T[P]>;
16
+ }
17
+ : T;
18
+
19
+ /**
20
+ * A mixin that allows to set partial I18N properties.
21
+ */
22
+ export declare function I18nMixin<I, T extends Constructor<HTMLElement>>(
23
+ defaultI18n: I,
24
+ superclass: T,
25
+ ): Constructor<I18nMixinClass<I>> & T;
26
+
27
+ export declare class I18nMixinClass<I> {
28
+ /**
29
+ * The object used to localize this component. To change the default
30
+ * localization, replace this with an object that provides all properties, or
31
+ * just the individual properties you want to change.
32
+ */
33
+ i18n: I;
34
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2025 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ function deepMerge(target, ...sources) {
8
+ const isArray = (item) => Array.isArray(item);
9
+ const isObject = (item) => item && typeof item === 'object' && !isArray(item);
10
+ const merge = (target, source) => {
11
+ if (isObject(source) && isObject(target)) {
12
+ Object.keys(source).forEach((key) => {
13
+ const sourceValue = source[key];
14
+ if (isObject(sourceValue)) {
15
+ if (!target[key]) {
16
+ target[key] = {};
17
+ }
18
+ merge(target[key], sourceValue);
19
+ } else if (isArray(sourceValue)) {
20
+ target[key] = [...sourceValue];
21
+ } else if (sourceValue !== undefined && sourceValue !== null) {
22
+ target[key] = sourceValue;
23
+ }
24
+ });
25
+ }
26
+ };
27
+
28
+ sources.forEach((source) => {
29
+ merge(target, source);
30
+ });
31
+
32
+ return target;
33
+ }
34
+
35
+ /**
36
+ * A mixin that allows to set partial I18N properties.
37
+ *
38
+ * @polymerMixin
39
+ */
40
+ export const I18nMixin = (defaultI18n, superClass) =>
41
+ class I18nMixinClass extends superClass {
42
+ static get properties() {
43
+ return {
44
+ /** @private */
45
+ __effectiveI18n: {
46
+ type: Object,
47
+ sync: true,
48
+ },
49
+ };
50
+ }
51
+
52
+ constructor() {
53
+ super();
54
+
55
+ this.i18n = deepMerge({}, defaultI18n);
56
+ }
57
+
58
+ /**
59
+ * The object used to localize this component. To change the default
60
+ * localization, replace this with an object that provides all properties, or
61
+ * just the individual properties you want to change.
62
+ *
63
+ * Should be overridden by subclasses to provide a custom JSDoc with the
64
+ * default I18N properties.
65
+ *
66
+ * @returns {Object}
67
+ */
68
+ get i18n() {
69
+ return this.__customI18n;
70
+ }
71
+
72
+ /**
73
+ * The object used to localize this component. To change the default
74
+ * localization, replace this with an object that provides all properties, or
75
+ * just the individual properties you want to change.
76
+ *
77
+ * Should be overridden by subclasses to provide a custom JSDoc with the
78
+ * default I18N properties.
79
+ *
80
+ * @param {Object} value
81
+ */
82
+ set i18n(value) {
83
+ this.__customI18n = value;
84
+ this.__effectiveI18n = deepMerge({}, defaultI18n, this.__customI18n);
85
+ }
86
+ };
@@ -3,8 +3,6 @@
3
3
  * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- /* eslint-disable @typescript-eslint/member-ordering */
7
- // https://github.com/vaadin/eslint-config-vaadin/issues/33
8
6
  import { animationFrame, microTask, timeOut } from './async.js';
9
7
  import { isSafari } from './browser-utils.js';
10
8
  import { Debouncer, flush } from './debounce.js';
@@ -52,6 +50,20 @@ export class IronListAdapter {
52
50
  this.__resizeObserver.observe(this.scrollTarget);
53
51
  this.scrollTarget.addEventListener('scroll', () => this._scrollHandler());
54
52
 
53
+ const attachObserver = new ResizeObserver(([{ contentRect }]) => {
54
+ const isHidden = contentRect.width === 0 && contentRect.height === 0;
55
+ if (!isHidden && this.__scrollTargetHidden && this.scrollTarget.scrollTop !== this._scrollPosition) {
56
+ // When removing element from DOM, its scroll position is lost and
57
+ // virtualizer doesn't re-render when adding it to the DOM again.
58
+ // Restore scroll position when the scroll target becomes visible,
59
+ // which is the case e.g. when virtualizer is used inside a dialog.
60
+ this.scrollTarget.scrollTop = this._scrollPosition;
61
+ }
62
+
63
+ this.__scrollTargetHidden = isHidden;
64
+ });
65
+ attachObserver.observe(this.scrollTarget);
66
+
55
67
  this._scrollLineHeight = this._getScrollLineHeight();
56
68
  this.scrollTarget.addEventListener('wheel', (e) => this.__onWheel(e));
57
69