@vaadin/component-base 23.2.16 → 23.2.17
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/custom_typings/vaadin-usage-statistics.d.ts +2 -2
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +3 -3
- package/src/a11y-announcer.d.ts +1 -1
- package/src/a11y-announcer.js +1 -1
- package/src/active-mixin.d.ts +1 -1
- package/src/active-mixin.js +1 -1
- package/src/async.d.ts +0 -3
- package/src/async.js +1 -2
- package/src/browser-utils.js +7 -7
- package/src/controller-mixin.d.ts +1 -1
- package/src/controller-mixin.js +1 -1
- package/src/debounce.js +2 -2
- package/src/dir-helper.d.ts +42 -0
- package/src/dir-helper.js +93 -0
- package/src/dir-mixin.d.ts +4 -2
- package/src/dir-mixin.js +39 -17
- package/src/disabled-mixin.d.ts +1 -1
- package/src/disabled-mixin.js +1 -1
- package/src/dom-utils.d.ts +1 -6
- package/src/dom-utils.js +1 -11
- package/src/element-mixin.d.ts +1 -1
- package/src/element-mixin.js +5 -11
- package/src/focus-mixin.d.ts +1 -1
- package/src/focus-mixin.js +2 -2
- package/src/focus-trap-controller.d.ts +1 -1
- package/src/focus-trap-controller.js +22 -22
- package/src/focus-utils.d.ts +1 -1
- package/src/focus-utils.js +57 -57
- package/src/gestures.d.ts +12 -6
- package/src/gestures.js +4 -6
- package/src/iron-list-core.js +11 -21
- package/src/keyboard-mixin.d.ts +1 -1
- package/src/keyboard-mixin.js +1 -1
- package/src/media-query-controller.d.ts +1 -1
- package/src/media-query-controller.js +1 -1
- package/src/overflow-controller.d.ts +1 -1
- package/src/overflow-controller.js +3 -3
- package/src/polylit-mixin.d.ts +3 -3
- package/src/polylit-mixin.js +4 -9
- package/src/resize-mixin.d.ts +1 -1
- package/src/resize-mixin.js +21 -11
- package/src/slot-controller.d.ts +5 -33
- package/src/slot-controller.js +40 -103
- package/src/slot-mixin.d.ts +18 -0
- package/src/slot-mixin.js +60 -0
- package/src/tabindex-mixin.d.ts +1 -1
- package/src/tabindex-mixin.js +1 -1
- package/src/templates.js +1 -1
- package/src/unique-id-utils.d.ts +1 -1
- package/src/unique-id-utils.js +1 -1
- package/src/virtualizer-iron-list-adapter.js +2 -6
- package/src/virtualizer.js +18 -18
- package/src/delegate-focus-mixin.d.ts +0 -48
- package/src/delegate-focus-mixin.js +0 -228
- package/src/delegate-state-mixin.d.ts +0 -20
- package/src/delegate-state-mixin.js +0 -125
- package/src/dir-utils.d.ts +0 -19
- package/src/dir-utils.js +0 -36
- package/src/keyboard-direction-mixin.d.ts +0 -41
- package/src/keyboard-direction-mixin.js +0 -192
- package/src/list-mixin.d.ts +0 -57
- package/src/list-mixin.js +0 -354
- package/src/overlay-class-mixin.d.ts +0 -33
- package/src/overlay-class-mixin.js +0 -79
- package/src/slot-child-observe-controller.d.ts +0 -28
- package/src/slot-child-observe-controller.js +0 -176
- package/src/tooltip-controller.d.ts +0 -86
- package/src/tooltip-controller.js +0 -130
package/src/focus-utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -61,6 +61,24 @@ function isElementHiddenDirectly(element) {
|
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Returns the normalized element tabindex. If not focusable, returns -1.
|
|
66
|
+
* It checks for the attribute "tabindex" instead of the element property
|
|
67
|
+
* `tabIndex` since browsers assign different values to it.
|
|
68
|
+
* e.g. in Firefox `<div contenteditable>` has `tabIndex = -1`
|
|
69
|
+
*
|
|
70
|
+
* @param {HTMLElement} element
|
|
71
|
+
* @return {number}
|
|
72
|
+
*/
|
|
73
|
+
function normalizeTabIndex(element) {
|
|
74
|
+
if (!isElementFocusable(element)) {
|
|
75
|
+
return -1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const tabIndex = element.getAttribute('tabindex') || 0;
|
|
79
|
+
return Number(tabIndex);
|
|
80
|
+
}
|
|
81
|
+
|
|
64
82
|
/**
|
|
65
83
|
* Returns if element `a` has lower tab order compared to element `b`
|
|
66
84
|
* (both elements are assumed to be focusable and tabbable).
|
|
@@ -120,6 +138,42 @@ function sortElementsByTabIndex(elements) {
|
|
|
120
138
|
return mergeSortByTabIndex(left, right);
|
|
121
139
|
}
|
|
122
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Searches for nodes that are tabbable and adds them to the `result` array.
|
|
143
|
+
* Returns if the `result` array needs to be sorted by tabindex.
|
|
144
|
+
*
|
|
145
|
+
* @param {Node} node The starting point for the search; added to `result` if tabbable.
|
|
146
|
+
* @param {HTMLElement[]} result
|
|
147
|
+
* @return {boolean}
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
function collectFocusableNodes(node, result) {
|
|
151
|
+
if (node.nodeType !== Node.ELEMENT_NODE || isElementHiddenDirectly(node)) {
|
|
152
|
+
// Don't traverse children if the node is not an HTML element or not visible.
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const element = /** @type {HTMLElement} */ (node);
|
|
157
|
+
const tabIndex = normalizeTabIndex(element);
|
|
158
|
+
let needsSort = tabIndex > 0;
|
|
159
|
+
if (tabIndex >= 0) {
|
|
160
|
+
result.push(element);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
let children = [];
|
|
164
|
+
if (element.localName === 'slot') {
|
|
165
|
+
children = element.assignedNodes({ flatten: true });
|
|
166
|
+
} else {
|
|
167
|
+
// Use shadow root if possible, will check for distributed nodes.
|
|
168
|
+
children = (element.shadowRoot || element).children;
|
|
169
|
+
}
|
|
170
|
+
[...children].forEach((child) => {
|
|
171
|
+
// Ensure method is always invoked to collect focusable children.
|
|
172
|
+
needsSort = collectFocusableNodes(child, result) || needsSort;
|
|
173
|
+
});
|
|
174
|
+
return needsSort;
|
|
175
|
+
}
|
|
176
|
+
|
|
123
177
|
/**
|
|
124
178
|
* Returns true if the element is hidden, false otherwise.
|
|
125
179
|
*
|
|
@@ -185,60 +239,6 @@ export function isElementFocused(element) {
|
|
|
185
239
|
return element.getRootNode().activeElement === element;
|
|
186
240
|
}
|
|
187
241
|
|
|
188
|
-
/**
|
|
189
|
-
* Returns the normalized element tabindex. If not focusable, returns -1.
|
|
190
|
-
* It checks for the attribute "tabindex" instead of the element property
|
|
191
|
-
* `tabIndex` since browsers assign different values to it.
|
|
192
|
-
* e.g. in Firefox `<div contenteditable>` has `tabIndex = -1`
|
|
193
|
-
*
|
|
194
|
-
* @param {HTMLElement} element
|
|
195
|
-
* @return {number}
|
|
196
|
-
*/
|
|
197
|
-
function normalizeTabIndex(element) {
|
|
198
|
-
if (!isElementFocusable(element)) {
|
|
199
|
-
return -1;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const tabIndex = element.getAttribute('tabindex') || 0;
|
|
203
|
-
return Number(tabIndex);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Searches for nodes that are tabbable and adds them to the `result` array.
|
|
208
|
-
* Returns if the `result` array needs to be sorted by tabindex.
|
|
209
|
-
*
|
|
210
|
-
* @param {Node} node The starting point for the search; added to `result` if tabbable.
|
|
211
|
-
* @param {HTMLElement[]} result
|
|
212
|
-
* @return {boolean}
|
|
213
|
-
* @private
|
|
214
|
-
*/
|
|
215
|
-
function collectFocusableNodes(node, result) {
|
|
216
|
-
if (node.nodeType !== Node.ELEMENT_NODE || isElementHiddenDirectly(node)) {
|
|
217
|
-
// Don't traverse children if the node is not an HTML element or not visible.
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const element = /** @type {HTMLElement} */ (node);
|
|
222
|
-
const tabIndex = normalizeTabIndex(element);
|
|
223
|
-
let needsSort = tabIndex > 0;
|
|
224
|
-
if (tabIndex >= 0) {
|
|
225
|
-
result.push(element);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
let children = [];
|
|
229
|
-
if (element.localName === 'slot') {
|
|
230
|
-
children = element.assignedNodes({ flatten: true });
|
|
231
|
-
} else {
|
|
232
|
-
// Use shadow root if possible, will check for distributed nodes.
|
|
233
|
-
children = (element.shadowRoot || element).children;
|
|
234
|
-
}
|
|
235
|
-
[...children].forEach((child) => {
|
|
236
|
-
// Ensure method is always invoked to collect focusable children.
|
|
237
|
-
needsSort = collectFocusableNodes(child, result) || needsSort;
|
|
238
|
-
});
|
|
239
|
-
return needsSort;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
242
|
/**
|
|
243
243
|
* Returns a tab-ordered array of focusable elements for a root element.
|
|
244
244
|
* The resulting array will include the root element if it is focusable.
|
|
@@ -251,8 +251,8 @@ function collectFocusableNodes(node, result) {
|
|
|
251
251
|
export function getFocusableElements(element) {
|
|
252
252
|
const focusableElements = [];
|
|
253
253
|
const needsSortByTabIndex = collectFocusableNodes(element, focusableElements);
|
|
254
|
-
// If there is at least one element with tabindex > 0,
|
|
255
|
-
//
|
|
254
|
+
// If there is at least one element with tabindex > 0, we need to sort
|
|
255
|
+
// the final array by tabindex.≈
|
|
256
256
|
if (needsSortByTabIndex) {
|
|
257
257
|
return sortElementsByTabIndex(focusableElements);
|
|
258
258
|
}
|
package/src/gestures.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ 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
10
|
|
|
11
|
+
export { deepTargetFind };
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
14
|
* Finds the element rendered on the screen at the provided coordinates.
|
|
13
15
|
*
|
|
@@ -18,7 +20,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|
|
18
20
|
* found at the screen position given.
|
|
19
21
|
*/
|
|
20
22
|
declare function deepTargetFind(x: number, y: number): Element | null;
|
|
21
|
-
|
|
23
|
+
|
|
24
|
+
export { addListener };
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* Adds an event listener to a node for the given gesture type.
|
|
@@ -26,7 +29,8 @@ export { deepTargetFind };
|
|
|
26
29
|
* @returns Returns true if a gesture event listener was added.
|
|
27
30
|
*/
|
|
28
31
|
declare function addListener(node: EventTarget, evType: string, handler: (p0: Event) => void): boolean;
|
|
29
|
-
|
|
32
|
+
|
|
33
|
+
export { removeListener };
|
|
30
34
|
|
|
31
35
|
/**
|
|
32
36
|
* Removes an event listener from a node for the given gesture type.
|
|
@@ -34,14 +38,16 @@ export { addListener };
|
|
|
34
38
|
* @returns Returns true if a gesture event listener was removed.
|
|
35
39
|
*/
|
|
36
40
|
declare function removeListener(node: EventTarget, evType: string, handler: (p0: Event) => void): boolean;
|
|
37
|
-
|
|
41
|
+
|
|
42
|
+
export { register };
|
|
38
43
|
|
|
39
44
|
/**
|
|
40
45
|
* Registers a new gesture event recognizer for adding new custom
|
|
41
46
|
* gesture event types.
|
|
42
47
|
*/
|
|
43
48
|
declare function register(recog: GestureRecognizer): void;
|
|
44
|
-
|
|
49
|
+
|
|
50
|
+
export { setTouchAction };
|
|
45
51
|
|
|
46
52
|
/**
|
|
47
53
|
* Sets scrolling direction on node.
|
|
@@ -50,13 +56,13 @@ export { register };
|
|
|
50
56
|
* adding event listeners.
|
|
51
57
|
*/
|
|
52
58
|
declare function setTouchAction(node: EventTarget, value: string): void;
|
|
53
|
-
|
|
59
|
+
|
|
60
|
+
export { prevent };
|
|
54
61
|
|
|
55
62
|
/**
|
|
56
63
|
* Prevents the dispatch and default action of the given event name.
|
|
57
64
|
*/
|
|
58
65
|
declare function prevent(evName: string): void;
|
|
59
|
-
export { prevent };
|
|
60
66
|
|
|
61
67
|
export interface GestureRecognizer {
|
|
62
68
|
reset(): void;
|
package/src/gestures.js
CHANGED
|
@@ -8,8 +8,6 @@ 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
10
|
|
|
11
|
-
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* @fileoverview
|
|
15
13
|
*
|
|
@@ -92,7 +90,7 @@ function PASSIVE_TOUCH(eventName) {
|
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
// Check for touch-only devices
|
|
95
|
-
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/);
|
|
96
94
|
|
|
97
95
|
// Defined at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute
|
|
98
96
|
/** @type {!Object<boolean>} */
|
|
@@ -470,9 +468,9 @@ function _remove(node, evType, handler) {
|
|
|
470
468
|
*/
|
|
471
469
|
export function register(recog) {
|
|
472
470
|
recognizers.push(recog);
|
|
473
|
-
recog.emits.
|
|
474
|
-
gestures[
|
|
475
|
-
}
|
|
471
|
+
for (let i = 0; i < recog.emits.length; i++) {
|
|
472
|
+
gestures[recog.emits[i]] = recog;
|
|
473
|
+
}
|
|
476
474
|
}
|
|
477
475
|
|
|
478
476
|
/**
|
package/src/iron-list-core.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
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+)/);
|
|
14
14
|
const IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8;
|
|
15
15
|
const DEFAULT_PHYSICAL_COUNT = 3;
|
|
16
16
|
|
|
@@ -502,12 +502,9 @@ export const ironList = {
|
|
|
502
502
|
this._physicalIndexForKey = {};
|
|
503
503
|
this._firstVisibleIndexVal = null;
|
|
504
504
|
this._lastVisibleIndexVal = null;
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
if (!this._physicalSizes) {
|
|
509
|
-
this._physicalSizes = [];
|
|
510
|
-
}
|
|
505
|
+
this._physicalCount = this._physicalCount || 0;
|
|
506
|
+
this._physicalItems = this._physicalItems || [];
|
|
507
|
+
this._physicalSizes = this._physicalSizes || [];
|
|
511
508
|
this._physicalStart = 0;
|
|
512
509
|
if (this._scrollTop > this._scrollOffset) {
|
|
513
510
|
this._resetScrollPosition(0);
|
|
@@ -616,21 +613,16 @@ export const ironList = {
|
|
|
616
613
|
* @param {boolean=} forceUpdate If true, updates the height no matter what.
|
|
617
614
|
*/
|
|
618
615
|
_updateScrollerSize(forceUpdate) {
|
|
619
|
-
|
|
616
|
+
this._estScrollHeight =
|
|
620
617
|
this._physicalBottom +
|
|
621
618
|
Math.max(this._virtualCount - this._physicalCount - this._virtualStart, 0) * this._physicalAverage;
|
|
622
619
|
|
|
623
|
-
this.
|
|
624
|
-
|
|
620
|
+
forceUpdate = forceUpdate || this._scrollHeight === 0;
|
|
621
|
+
forceUpdate = forceUpdate || this._scrollPosition >= this._estScrollHeight - this._physicalSize;
|
|
625
622
|
// Amortize height adjustment, so it won't trigger large repaints too often.
|
|
626
|
-
if (
|
|
627
|
-
|
|
628
|
-
this._scrollHeight
|
|
629
|
-
this._scrollPosition >= estScrollHeight - this._physicalSize ||
|
|
630
|
-
Math.abs(estScrollHeight - this._scrollHeight) >= this._viewportHeight
|
|
631
|
-
) {
|
|
632
|
-
this.$.items.style.height = `${estScrollHeight}px`;
|
|
633
|
-
this._scrollHeight = estScrollHeight;
|
|
623
|
+
if (forceUpdate || Math.abs(this._estScrollHeight - this._scrollHeight) >= this._viewportHeight) {
|
|
624
|
+
this.$.items.style.height = `${this._estScrollHeight}px`;
|
|
625
|
+
this._scrollHeight = this._estScrollHeight;
|
|
634
626
|
}
|
|
635
627
|
},
|
|
636
628
|
|
|
@@ -726,9 +718,7 @@ export const ironList = {
|
|
|
726
718
|
},
|
|
727
719
|
|
|
728
720
|
_debounce(name, cb, asyncModule) {
|
|
729
|
-
|
|
730
|
-
this._debouncers = {};
|
|
731
|
-
}
|
|
721
|
+
this._debouncers = this._debouncers || {};
|
|
732
722
|
this._debouncers[name] = Debouncer.debounce(this._debouncers[name], asyncModule, cb.bind(this));
|
|
733
723
|
enqueueDebouncer(this._debouncers[name]);
|
|
734
724
|
},
|
package/src/keyboard-mixin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 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';
|
package/src/keyboard-mixin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 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 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 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 { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
|
|
@@ -92,7 +92,7 @@ export class OverflowController {
|
|
|
92
92
|
overflow += ' top';
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
if (
|
|
95
|
+
if (target.scrollTop < target.scrollHeight - target.clientHeight) {
|
|
96
96
|
overflow += ' bottom';
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -101,7 +101,7 @@ export class OverflowController {
|
|
|
101
101
|
overflow += ' start';
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
if (
|
|
104
|
+
if (scrollLeft < target.scrollWidth - target.clientWidth) {
|
|
105
105
|
overflow += ' end';
|
|
106
106
|
}
|
|
107
107
|
|
package/src/polylit-mixin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 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';
|
|
@@ -14,10 +14,10 @@ export declare class PolylitMixinClass {
|
|
|
14
14
|
/**
|
|
15
15
|
* Reads a value from a path.
|
|
16
16
|
*/
|
|
17
|
-
protected _get(root:
|
|
17
|
+
protected _get(root: Object, path: String): any;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Sets a value to a path.
|
|
21
21
|
*/
|
|
22
|
-
protected _set(root:
|
|
22
|
+
protected _set(root: Object, path: String, value: any): void;
|
|
23
23
|
}
|
package/src/polylit-mixin.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 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 { dedupeMixin } from '@open-wc/dedupe-mixin';
|
|
7
7
|
|
|
8
8
|
const caseMap = {};
|
|
9
9
|
|
|
10
|
-
const CAMEL_TO_DASH = /([A-Z])/
|
|
10
|
+
const CAMEL_TO_DASH = /([A-Z])/g;
|
|
11
11
|
|
|
12
12
|
function camelToDash(camel) {
|
|
13
|
-
|
|
14
|
-
caseMap[camel] = camel.replace(CAMEL_TO_DASH, '-$1').toLowerCase();
|
|
15
|
-
}
|
|
13
|
+
caseMap[camel] = caseMap[camel] || camel.replace(CAMEL_TO_DASH, '-$1').toLowerCase();
|
|
16
14
|
return caseMap[camel];
|
|
17
15
|
}
|
|
18
16
|
|
|
@@ -171,10 +169,7 @@ const PolylitMixinImplementation = (superclass) => {
|
|
|
171
169
|
firstUpdated() {
|
|
172
170
|
super.firstUpdated();
|
|
173
171
|
|
|
174
|
-
|
|
175
|
-
this.$ = {};
|
|
176
|
-
}
|
|
177
|
-
|
|
172
|
+
this.$ = this.$ || {};
|
|
178
173
|
this.shadowRoot.querySelectorAll('[id]').forEach((node) => {
|
|
179
174
|
this.$[node.id] = node;
|
|
180
175
|
});
|
package/src/resize-mixin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 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';
|
package/src/resize-mixin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 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';
|
|
@@ -28,16 +28,6 @@ const observer = new ResizeObserver((entries) => {
|
|
|
28
28
|
export const ResizeMixin = dedupingMixin(
|
|
29
29
|
(superclass) =>
|
|
30
30
|
class ResizeMixinClass extends superclass {
|
|
31
|
-
/**
|
|
32
|
-
* When true, the parent element resize will be also observed.
|
|
33
|
-
* Override this getter and return `true` to enable this.
|
|
34
|
-
*
|
|
35
|
-
* @protected
|
|
36
|
-
*/
|
|
37
|
-
get _observeParent() {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
31
|
/** @protected */
|
|
42
32
|
connectedCallback() {
|
|
43
33
|
super.connectedCallback();
|
|
@@ -77,6 +67,16 @@ export const ResizeMixin = dedupingMixin(
|
|
|
77
67
|
}
|
|
78
68
|
}
|
|
79
69
|
|
|
70
|
+
/**
|
|
71
|
+
* When true, the parent element resize will be also observed.
|
|
72
|
+
* Override this getter and return `true` to enable this.
|
|
73
|
+
*
|
|
74
|
+
* @protected
|
|
75
|
+
*/
|
|
76
|
+
get _observeParent() {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
80
|
/**
|
|
81
81
|
* A handler invoked on host resize. By default, it does nothing.
|
|
82
82
|
* Override the method to implement your own behavior.
|
|
@@ -86,5 +86,15 @@ export const ResizeMixin = dedupingMixin(
|
|
|
86
86
|
_onResize(_contentRect) {
|
|
87
87
|
// To be implemented.
|
|
88
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Since Vaadin 23, `notifyResize()` is deprecated. The component uses a
|
|
92
|
+
* ResizeObserver internally and doesn't need to be explicitly notified of resizes.
|
|
93
|
+
*/
|
|
94
|
+
notifyResize() {
|
|
95
|
+
console.warn(
|
|
96
|
+
`WARNING: Since Vaadin 23, notifyResize() is deprecated. The component uses a ResizeObserver internally and doesn't need to be explicitly notified of resizes.`,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
89
99
|
},
|
|
90
100
|
);
|
package/src/slot-controller.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
3
|
+
* Copyright (c) 2021 - 2022 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';
|
|
@@ -16,16 +16,8 @@ export class SlotController extends EventTarget implements ReactiveController {
|
|
|
16
16
|
*/
|
|
17
17
|
node: HTMLElement;
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* The list of slotted nodes managed by the controller.
|
|
21
|
-
* Only used when `multiple` property is set to `true`.
|
|
22
|
-
*/
|
|
23
|
-
nodes: HTMLElement[];
|
|
24
|
-
|
|
25
19
|
protected initialized: boolean;
|
|
26
20
|
|
|
27
|
-
protected multiple: boolean;
|
|
28
|
-
|
|
29
21
|
protected defaultNode: Node;
|
|
30
22
|
|
|
31
23
|
protected defaultId: string;
|
|
@@ -33,40 +25,20 @@ export class SlotController extends EventTarget implements ReactiveController {
|
|
|
33
25
|
constructor(
|
|
34
26
|
host: HTMLElement,
|
|
35
27
|
slotName: string,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
observe?: boolean;
|
|
40
|
-
useUniqueId?: boolean;
|
|
41
|
-
initializer?(host: HTMLElement, node: HTMLElement): void;
|
|
42
|
-
},
|
|
28
|
+
slotFactory?: () => HTMLElement,
|
|
29
|
+
slotInitializer?: (host: HTMLElement, node: HTMLElement) => void,
|
|
30
|
+
useUniqueId?: boolean,
|
|
43
31
|
);
|
|
44
32
|
|
|
45
33
|
hostConnected(): void;
|
|
46
34
|
|
|
47
|
-
/**
|
|
48
|
-
* Return the list of nodes matching the slot managed by the controller.
|
|
49
|
-
*/
|
|
50
|
-
getSlotChildren(): Node[];
|
|
51
|
-
|
|
52
35
|
/**
|
|
53
36
|
* Return a reference to the node managed by the controller.
|
|
54
37
|
*/
|
|
55
38
|
getSlotChild(): Node;
|
|
56
39
|
|
|
57
|
-
/**
|
|
58
|
-
* Create and attach default node using the provided tag name, if any.
|
|
59
|
-
*/
|
|
60
40
|
protected attachDefaultNode(): Node | undefined;
|
|
61
41
|
|
|
62
|
-
/**
|
|
63
|
-
* Run both `initCustomNode` and `initNode` for a custom slotted node.
|
|
64
|
-
*/
|
|
65
|
-
protected initAddedNode(node: Node): void;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Run `slotInitializer` for the node managed by the controller.
|
|
69
|
-
*/
|
|
70
42
|
protected initNode(node: Node): void;
|
|
71
43
|
|
|
72
44
|
/**
|
|
@@ -82,5 +54,5 @@ export class SlotController extends EventTarget implements ReactiveController {
|
|
|
82
54
|
/**
|
|
83
55
|
* Setup the observer to manage slot content changes.
|
|
84
56
|
*/
|
|
85
|
-
protected
|
|
57
|
+
protected observe(): void;
|
|
86
58
|
}
|