@vaadin/component-base 23.3.3 → 24.0.0-alpha10

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 +21 -11
  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 +1 -1
  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 +6 -2
  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
package/index.d.ts CHANGED
@@ -8,5 +8,4 @@ export { FocusTrapController } from './src/focus-trap-controller.js';
8
8
  export { KeyboardMixin } from './src/keyboard-mixin.js';
9
9
  export { ResizeMixin } from './src/resize-mixin.js';
10
10
  export { SlotController } from './src/slot-controller.js';
11
- export { SlotMixin } from './src/slot-mixin.js';
12
11
  export { TabindexMixin } from './src/tabindex-mixin.js';
package/index.js CHANGED
@@ -7,5 +7,4 @@ export { FocusMixin } from './src/focus-mixin.js';
7
7
  export { FocusTrapController } from './src/focus-trap-controller.js';
8
8
  export { KeyboardMixin } from './src/keyboard-mixin.js';
9
9
  export { SlotController } from './src/slot-controller.js';
10
- export { SlotMixin } from './src/slot-mixin.js';
11
10
  export { TabindexMixin } from './src/tabindex-mixin.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/component-base",
3
- "version": "23.3.3",
3
+ "version": "24.0.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -42,5 +42,5 @@
42
42
  "@vaadin/testing-helpers": "^0.3.2",
43
43
  "sinon": "^13.0.2"
44
44
  },
45
- "gitHead": "1529ed623e053d28a3c1c66af55ebe402743ddd0"
45
+ "gitHead": "2e04534d8b47bcd216f89b5f849bafef1a73b174"
46
46
  }
@@ -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
 
@@ -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 { animationFrame } from './async.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 { 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 { DisabledMixin } from './disabled-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
 
@@ -10,20 +10,20 @@ const testPlatform = (regexp) => regexp.test(navigator.platform);
10
10
 
11
11
  const testVendor = (regexp) => regexp.test(navigator.vendor);
12
12
 
13
- export const isAndroid = testUserAgent(/Android/);
13
+ export const isAndroid = testUserAgent(/Android/u);
14
14
 
15
- export const isChrome = testUserAgent(/Chrome/) && testVendor(/Google Inc/);
15
+ export const isChrome = testUserAgent(/Chrome/u) && testVendor(/Google Inc/u);
16
16
 
17
- export const isFirefox = testUserAgent(/Firefox/);
17
+ export const isFirefox = testUserAgent(/Firefox/u);
18
18
 
19
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);
20
+ export const isIPad = testPlatform(/^iPad/u) || (testPlatform(/^Mac/u) && navigator.maxTouchPoints > 1);
21
21
 
22
- export const isIPhone = testPlatform(/^iPhone/);
22
+ export const isIPhone = testPlatform(/^iPhone/u);
23
23
 
24
24
  export const isIOS = isIPhone || isIPad;
25
25
 
26
- export const isSafari = testUserAgent(/^((?!chrome|android).)*safari/i);
26
+ export const isSafari = testUserAgent(/^((?!chrome|android).)*safari/iu);
27
27
 
28
28
  export const isTouch = (() => {
29
29
  try {
@@ -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,48 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 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 { DisabledMixinClass } from './disabled-mixin.js';
8
+ import type { FocusMixinClass } from './focus-mixin.js';
9
+ import type { TabindexMixinClass } from './tabindex-mixin.js';
10
+
11
+ /**
12
+ * A mixin to forward focus to an element in the light DOM.
13
+ */
14
+ export declare function DelegateFocusMixin<T extends Constructor<HTMLElement>>(
15
+ base: T,
16
+ ): Constructor<DelegateFocusMixinClass> &
17
+ Constructor<DisabledMixinClass> &
18
+ Constructor<FocusMixinClass> &
19
+ Constructor<TabindexMixinClass> &
20
+ T;
21
+
22
+ export declare class DelegateFocusMixinClass {
23
+ /**
24
+ * Specify that this control should have input focus when the page loads.
25
+ */
26
+ autofocus: boolean;
27
+
28
+ /**
29
+ * A reference to the focusable element controlled by the mixin.
30
+ * It can be an input, textarea, button or any element with tabindex > -1.
31
+ *
32
+ * Any component implementing this mixin is expected to provide it
33
+ * by using `this._setFocusElement(input)` Polymer API.
34
+ */
35
+ readonly focusElement: HTMLElement | null | undefined;
36
+
37
+ protected _addFocusListeners(element: HTMLElement): void;
38
+
39
+ protected _removeFocusListeners(element: HTMLElement): void;
40
+
41
+ protected _focusElementChanged(element: HTMLElement, oldElement: HTMLElement): void;
42
+
43
+ protected _onBlur(event: FocusEvent): void;
44
+
45
+ protected _onFocus(event: FocusEvent): void;
46
+
47
+ protected _setFocusElement(element: HTMLElement): void;
48
+ }
@@ -0,0 +1,228 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2023 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
+ import { FocusMixin } from './focus-mixin.js';
8
+ import { TabindexMixin } from './tabindex-mixin.js';
9
+
10
+ /**
11
+ * A mixin to forward focus to an element in the light DOM.
12
+ *
13
+ * @polymerMixin
14
+ * @mixes FocusMixin
15
+ * @mixes TabindexMixin
16
+ */
17
+ export const DelegateFocusMixin = dedupingMixin(
18
+ (superclass) =>
19
+ class DelegateFocusMixinClass extends FocusMixin(TabindexMixin(superclass)) {
20
+ static get properties() {
21
+ return {
22
+ /**
23
+ * Specify that this control should have input focus when the page loads.
24
+ */
25
+ autofocus: {
26
+ type: Boolean,
27
+ },
28
+
29
+ /**
30
+ * A reference to the focusable element controlled by the mixin.
31
+ * It can be an input, textarea, button or any element with tabindex > -1.
32
+ *
33
+ * Any component implementing this mixin is expected to provide it
34
+ * by using `this._setFocusElement(input)` Polymer API.
35
+ *
36
+ * Toggling `tabindex` attribute on the host element propagates its value to `focusElement`.
37
+ *
38
+ * @protected
39
+ * @type {!HTMLElement}
40
+ */
41
+ focusElement: {
42
+ type: Object,
43
+ readOnly: true,
44
+ observer: '_focusElementChanged',
45
+ },
46
+
47
+ /**
48
+ * Override the property from `TabIndexMixin`
49
+ * to ensure the `tabindex` attribute of the focus element
50
+ * will be restored to `0` after re-enabling the element.
51
+ *
52
+ * @protected
53
+ * @override
54
+ */
55
+ _lastTabIndex: {
56
+ value: 0,
57
+ },
58
+ };
59
+ }
60
+
61
+ constructor() {
62
+ super();
63
+
64
+ this._boundOnBlur = this._onBlur.bind(this);
65
+ this._boundOnFocus = this._onFocus.bind(this);
66
+ }
67
+
68
+ /** @protected */
69
+ ready() {
70
+ super.ready();
71
+
72
+ if (this.autofocus && !this.disabled) {
73
+ requestAnimationFrame(() => {
74
+ this.focus();
75
+ this.setAttribute('focus-ring', '');
76
+ });
77
+ }
78
+ }
79
+
80
+ /**
81
+ * @protected
82
+ * @override
83
+ */
84
+ focus() {
85
+ if (!this.focusElement || this.disabled) {
86
+ return;
87
+ }
88
+
89
+ this.focusElement.focus();
90
+ this._setFocused(true);
91
+ }
92
+
93
+ /**
94
+ * @protected
95
+ * @override
96
+ */
97
+ blur() {
98
+ if (!this.focusElement) {
99
+ return;
100
+ }
101
+ this.focusElement.blur();
102
+ this._setFocused(false);
103
+ }
104
+
105
+ /**
106
+ * @protected
107
+ * @override
108
+ */
109
+ click() {
110
+ if (this.focusElement && !this.disabled) {
111
+ this.focusElement.click();
112
+ }
113
+ }
114
+
115
+ /** @protected */
116
+ _focusElementChanged(element, oldElement) {
117
+ if (element) {
118
+ element.disabled = this.disabled;
119
+ this._addFocusListeners(element);
120
+ this.__forwardTabIndex(this.tabindex);
121
+ } else if (oldElement) {
122
+ this._removeFocusListeners(oldElement);
123
+ }
124
+ }
125
+
126
+ /**
127
+ * @param {HTMLElement} element
128
+ * @protected
129
+ */
130
+ _addFocusListeners(element) {
131
+ element.addEventListener('blur', this._boundOnBlur);
132
+ element.addEventListener('focus', this._boundOnFocus);
133
+ }
134
+
135
+ /**
136
+ * @param {HTMLElement} element
137
+ * @protected
138
+ */
139
+ _removeFocusListeners(element) {
140
+ element.removeEventListener('blur', this._boundOnBlur);
141
+ element.removeEventListener('focus', this._boundOnFocus);
142
+ }
143
+
144
+ /**
145
+ * Focus event does not bubble, so we dispatch it manually
146
+ * on the host element to support adding focus listeners
147
+ * when the focusable element is placed in light DOM.
148
+ * @param {FocusEvent} event
149
+ * @protected
150
+ */
151
+ _onFocus(event) {
152
+ event.stopPropagation();
153
+ this.dispatchEvent(new Event('focus'));
154
+ }
155
+
156
+ /**
157
+ * Blur event does not bubble, so we dispatch it manually
158
+ * on the host element to support adding blur listeners
159
+ * when the focusable element is placed in light DOM.
160
+ * @param {FocusEvent} event
161
+ * @protected
162
+ */
163
+ _onBlur(event) {
164
+ event.stopPropagation();
165
+ this.dispatchEvent(new Event('blur'));
166
+ }
167
+
168
+ /**
169
+ * @param {Event} event
170
+ * @return {boolean}
171
+ * @protected
172
+ * @override
173
+ */
174
+ _shouldSetFocus(event) {
175
+ return event.target === this.focusElement;
176
+ }
177
+
178
+ /**
179
+ * @param {boolean} disabled
180
+ * @param {boolean} oldDisabled
181
+ * @protected
182
+ * @override
183
+ */
184
+ _disabledChanged(disabled, oldDisabled) {
185
+ super._disabledChanged(disabled, oldDisabled);
186
+
187
+ if (this.focusElement) {
188
+ this.focusElement.disabled = disabled;
189
+ }
190
+
191
+ if (disabled) {
192
+ this.blur();
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Override an observer from `TabindexMixin`.
198
+ * Do not call super to remove tabindex attribute
199
+ * from the host after it has been forwarded.
200
+ * @param {string} tabindex
201
+ * @protected
202
+ * @override
203
+ */
204
+ _tabindexChanged(tabindex) {
205
+ this.__forwardTabIndex(tabindex);
206
+ }
207
+
208
+ /** @private */
209
+ __forwardTabIndex(tabindex) {
210
+ if (tabindex !== undefined && this.focusElement) {
211
+ this.focusElement.tabIndex = tabindex;
212
+
213
+ // Preserve tabindex="-1" on the host element
214
+ if (tabindex !== -1) {
215
+ this.tabindex = undefined;
216
+ }
217
+ }
218
+
219
+ if (this.disabled && tabindex) {
220
+ // If tabindex attribute was changed while component was disabled
221
+ if (tabindex !== -1) {
222
+ this._lastTabIndex = tabindex;
223
+ }
224
+ this.tabindex = undefined;
225
+ }
226
+ }
227
+ },
228
+ );
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 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
+
8
+ /**
9
+ * A mixin to delegate properties and attributes to a target element.
10
+ */
11
+ export declare function DelegateStateMixin<T extends Constructor<HTMLElement>>(
12
+ base: T,
13
+ ): Constructor<DelegateStateMixinClass> & T;
14
+
15
+ export declare class DelegateStateMixinClass {
16
+ /**
17
+ * A target element to which attributes and properties are delegated.
18
+ */
19
+ stateTarget: HTMLElement | null;
20
+ }
@@ -0,0 +1,125 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2023 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 to delegate properties and attributes to a target element.
10
+ *
11
+ * @polymerMixin
12
+ */
13
+ export const DelegateStateMixin = dedupingMixin(
14
+ (superclass) =>
15
+ class DelegateStateMixinClass extends superclass {
16
+ static get properties() {
17
+ return {
18
+ /**
19
+ * A target element to which attributes and properties are delegated.
20
+ * @protected
21
+ */
22
+ stateTarget: {
23
+ type: Object,
24
+ observer: '_stateTargetChanged',
25
+ },
26
+ };
27
+ }
28
+
29
+ /**
30
+ * An array of the host attributes to delegate to the target element.
31
+ */
32
+ static get delegateAttrs() {
33
+ return [];
34
+ }
35
+
36
+ /**
37
+ * An array of the host properties to delegate to the target element.
38
+ */
39
+ static get delegateProps() {
40
+ return [];
41
+ }
42
+
43
+ /** @protected */
44
+ ready() {
45
+ super.ready();
46
+
47
+ this._createDelegateAttrsObserver();
48
+ this._createDelegatePropsObserver();
49
+ }
50
+
51
+ /** @protected */
52
+ _stateTargetChanged(target) {
53
+ if (target) {
54
+ this._ensureAttrsDelegated();
55
+ this._ensurePropsDelegated();
56
+ }
57
+ }
58
+
59
+ /** @protected */
60
+ _createDelegateAttrsObserver() {
61
+ this._createMethodObserver(`_delegateAttrsChanged(${this.constructor.delegateAttrs.join(', ')})`);
62
+ }
63
+
64
+ /** @protected */
65
+ _createDelegatePropsObserver() {
66
+ this._createMethodObserver(`_delegatePropsChanged(${this.constructor.delegateProps.join(', ')})`);
67
+ }
68
+
69
+ /** @protected */
70
+ _ensureAttrsDelegated() {
71
+ this.constructor.delegateAttrs.forEach((name) => {
72
+ this._delegateAttribute(name, this[name]);
73
+ });
74
+ }
75
+
76
+ /** @protected */
77
+ _ensurePropsDelegated() {
78
+ this.constructor.delegateProps.forEach((name) => {
79
+ this._delegateProperty(name, this[name]);
80
+ });
81
+ }
82
+
83
+ /** @protected */
84
+ _delegateAttrsChanged(...values) {
85
+ this.constructor.delegateAttrs.forEach((name, index) => {
86
+ this._delegateAttribute(name, values[index]);
87
+ });
88
+ }
89
+
90
+ /** @protected */
91
+ _delegatePropsChanged(...values) {
92
+ this.constructor.delegateProps.forEach((name, index) => {
93
+ this._delegateProperty(name, values[index]);
94
+ });
95
+ }
96
+
97
+ /** @protected */
98
+ _delegateAttribute(name, value) {
99
+ if (!this.stateTarget) {
100
+ return;
101
+ }
102
+
103
+ if (name === 'invalid') {
104
+ this._delegateAttribute('aria-invalid', value ? 'true' : false);
105
+ }
106
+
107
+ if (typeof value === 'boolean') {
108
+ this.stateTarget.toggleAttribute(name, value);
109
+ } else if (value) {
110
+ this.stateTarget.setAttribute(name, value);
111
+ } else {
112
+ this.stateTarget.removeAttribute(name);
113
+ }
114
+ }
115
+
116
+ /** @protected */
117
+ _delegateProperty(name, value) {
118
+ if (!this.stateTarget) {
119
+ return;
120
+ }
121
+
122
+ this.stateTarget[name] = value;
123
+ }
124
+ },
125
+ );
@@ -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';
@@ -11,7 +11,5 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
11
11
  export declare function DirMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<DirMixinClass> & T;
12
12
 
13
13
  export declare class DirMixinClass {
14
- protected __getNormalizedScrollLeft(element: Element | null): number;
15
-
16
- protected __setNormalizedScrollLeft(element: Element | null, scrollLeft: number): void;
14
+ protected readonly __isRTL: boolean;
17
15
  }
package/src/dir-mixin.js CHANGED
@@ -1,9 +1,8 @@
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
- import { DirHelper } from './dir-helper.js';
7
6
 
8
7
  /**
9
8
  * Array of Vaadin custom element classes that have been subscribed to the dir changes.
@@ -17,8 +16,6 @@ function directionUpdater() {
17
16
  });
18
17
  }
19
18
 
20
- let scrollType;
21
-
22
19
  const directionObserver = new MutationObserver(directionUpdater);
23
20
  directionObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['dir'] });
24
21
 
@@ -62,13 +59,12 @@ export const DirMixin = (superClass) =>
62
59
  };
63
60
  }
64
61
 
65
- /** @protected */
66
- static finalize() {
67
- super.finalize();
68
-
69
- if (!scrollType) {
70
- scrollType = DirHelper.detectScrollType();
71
- }
62
+ /**
63
+ * @return {boolean}
64
+ * @protected
65
+ */
66
+ get __isRTL() {
67
+ return this.getAttribute('dir') === 'rtl';
72
68
  }
73
69
 
74
70
  /** @protected */
@@ -146,22 +142,4 @@ export const DirMixin = (superClass) =>
146
142
  directionSubscribers.splice(directionSubscribers.indexOf(this), 1);
147
143
  }
148
144
  }
149
-
150
- /**
151
- * @param {Element} element
152
- * @return {number}
153
- * @protected
154
- */
155
- __getNormalizedScrollLeft(element) {
156
- return DirHelper.getNormalizedScrollLeft(scrollType, this.getAttribute('dir') || 'ltr', element);
157
- }
158
-
159
- /**
160
- * @param {Element} element
161
- * @param {number} scrollLeft
162
- * @protected
163
- */
164
- __setNormalizedScrollLeft(element, scrollLeft) {
165
- return DirHelper.setNormalizedScrollLeft(scrollType, this.getAttribute('dir') || 'ltr', element, scrollLeft);
166
- }
167
145
  };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ /**
8
+ * Get the scrollLeft value of the element relative to the direction
9
+ */
10
+ export declare function getNormalizedScrollLeft(element: HTMLElement, direction: string | null): number;
11
+
12
+ /**
13
+ * Set the scrollLeft value of the element relative to the direction
14
+ */
15
+ export declare function setNormalizedScrollLeft(
16
+ element: HTMLElement,
17
+ direction: string | null,
18
+ scrollLeft: number,
19
+ ): void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ /**
8
+ * Get the scrollLeft value of the element relative to the direction
9
+ *
10
+ * @param {HTMLElement} element
11
+ * @param {string} direction current direction of the element
12
+ * @return {number} the scrollLeft value.
13
+ */
14
+ export function getNormalizedScrollLeft(element, direction) {
15
+ const { scrollLeft } = element;
16
+ if (direction !== 'rtl') {
17
+ return scrollLeft;
18
+ }
19
+
20
+ return element.scrollWidth - element.clientWidth + scrollLeft;
21
+ }
22
+
23
+ /**
24
+ * Set the scrollLeft value of the element relative to the direction
25
+ *
26
+ * @param {HTMLElement} element
27
+ * @param {string} direction current direction of the element
28
+ * @param {number} scrollLeft the scrollLeft value to be set
29
+ */
30
+ export function setNormalizedScrollLeft(element, direction, scrollLeft) {
31
+ if (direction !== 'rtl') {
32
+ element.scrollLeft = scrollLeft;
33
+ } else {
34
+ element.scrollLeft = element.clientWidth - element.scrollWidth + scrollLeft;
35
+ }
36
+ }
@@ -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';