@vaadin/component-base 23.2.16 → 23.2.18

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 (70) hide show
  1. package/custom_typings/vaadin-usage-statistics.d.ts +2 -2
  2. package/index.d.ts +1 -0
  3. package/index.js +1 -0
  4. package/package.json +3 -3
  5. package/src/a11y-announcer.d.ts +1 -1
  6. package/src/a11y-announcer.js +1 -1
  7. package/src/active-mixin.d.ts +1 -1
  8. package/src/active-mixin.js +1 -1
  9. package/src/async.d.ts +0 -3
  10. package/src/async.js +1 -2
  11. package/src/browser-utils.js +7 -7
  12. package/src/controller-mixin.d.ts +1 -1
  13. package/src/controller-mixin.js +1 -1
  14. package/src/debounce.js +2 -2
  15. package/src/dir-helper.d.ts +42 -0
  16. package/src/dir-helper.js +93 -0
  17. package/src/dir-mixin.d.ts +4 -2
  18. package/src/dir-mixin.js +39 -17
  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 -6
  22. package/src/dom-utils.js +1 -11
  23. package/src/element-mixin.d.ts +1 -1
  24. package/src/element-mixin.js +5 -11
  25. package/src/focus-mixin.d.ts +1 -1
  26. package/src/focus-mixin.js +2 -2
  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 +57 -57
  31. package/src/gestures.d.ts +12 -6
  32. package/src/gestures.js +4 -6
  33. package/src/iron-list-core.js +11 -21
  34. package/src/keyboard-mixin.d.ts +1 -1
  35. package/src/keyboard-mixin.js +1 -1
  36. package/src/media-query-controller.d.ts +1 -1
  37. package/src/media-query-controller.js +1 -1
  38. package/src/overflow-controller.d.ts +1 -1
  39. package/src/overflow-controller.js +3 -3
  40. package/src/polylit-mixin.d.ts +3 -3
  41. package/src/polylit-mixin.js +4 -9
  42. package/src/resize-mixin.d.ts +1 -1
  43. package/src/resize-mixin.js +21 -11
  44. package/src/slot-controller.d.ts +5 -33
  45. package/src/slot-controller.js +40 -103
  46. package/src/slot-mixin.d.ts +18 -0
  47. package/src/slot-mixin.js +60 -0
  48. package/src/tabindex-mixin.d.ts +1 -1
  49. package/src/tabindex-mixin.js +1 -1
  50. package/src/templates.js +1 -1
  51. package/src/unique-id-utils.d.ts +1 -1
  52. package/src/unique-id-utils.js +1 -1
  53. package/src/virtualizer-iron-list-adapter.js +2 -6
  54. package/src/virtualizer.js +18 -18
  55. package/src/delegate-focus-mixin.d.ts +0 -48
  56. package/src/delegate-focus-mixin.js +0 -228
  57. package/src/delegate-state-mixin.d.ts +0 -20
  58. package/src/delegate-state-mixin.js +0 -125
  59. package/src/dir-utils.d.ts +0 -19
  60. package/src/dir-utils.js +0 -36
  61. package/src/keyboard-direction-mixin.d.ts +0 -41
  62. package/src/keyboard-direction-mixin.js +0 -192
  63. package/src/list-mixin.d.ts +0 -57
  64. package/src/list-mixin.js +0 -354
  65. package/src/overlay-class-mixin.d.ts +0 -33
  66. package/src/overlay-class-mixin.js +0 -79
  67. package/src/slot-child-observe-controller.d.ts +0 -28
  68. package/src/slot-child-observe-controller.js +0 -176
  69. package/src/tooltip-controller.d.ts +0 -86
  70. package/src/tooltip-controller.js +0 -130
@@ -1,176 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2022 - 2023 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { SlotController } from './slot-controller.js';
7
-
8
- /**
9
- * A controller that observes slotted element mutations, especially ID attribute
10
- * and the text content, and fires an event to notify host element about those.
11
- */
12
- export class SlotChildObserveController extends SlotController {
13
- constructor(host, slot, tagName, config = {}) {
14
- super(host, slot, tagName, { ...config, useUniqueId: true });
15
- }
16
-
17
- /**
18
- * Override to initialize the newly added custom node.
19
- *
20
- * @param {Node} node
21
- * @protected
22
- * @override
23
- */
24
- initCustomNode(node) {
25
- this.__updateNodeId(node);
26
- this.__notifyChange(node);
27
- }
28
-
29
- /**
30
- * Override to notify the controller host about removal of
31
- * the custom node, and to apply the default one if needed.
32
- *
33
- * @param {Node} _node
34
- * @protected
35
- * @override
36
- */
37
- teardownNode(_node) {
38
- const node = this.getSlotChild();
39
-
40
- // Custom node is added to the slot
41
- if (node && node !== this.defaultNode) {
42
- this.__notifyChange(node);
43
- } else {
44
- this.restoreDefaultNode();
45
- this.updateDefaultNode(this.node);
46
- }
47
- }
48
-
49
- /**
50
- * Override method inherited from `SlotMixin`
51
- * to set ID attribute on the default node.
52
- *
53
- * @return {Node}
54
- * @protected
55
- * @override
56
- */
57
- attachDefaultNode() {
58
- const node = super.attachDefaultNode();
59
-
60
- if (node) {
61
- this.__updateNodeId(node);
62
- }
63
-
64
- return node;
65
- }
66
-
67
- /**
68
- * Override to restore default node when a custom one is removed.
69
- *
70
- * @protected
71
- */
72
- restoreDefaultNode() {
73
- // To be implemented
74
- }
75
-
76
- /**
77
- * Override to update default node text on property change.
78
- *
79
- * @param {Node} node
80
- * @protected
81
- */
82
- updateDefaultNode(node) {
83
- this.__notifyChange(node);
84
- }
85
-
86
- /**
87
- * Setup the mutation observer on the node to update ID and notify host.
88
- * Node doesn't get observed automatically until this method is called.
89
- *
90
- * @param {Node} node
91
- * @protected
92
- */
93
- observeNode(node) {
94
- // Stop observing the previous node, if any.
95
- if (this.__nodeObserver) {
96
- this.__nodeObserver.disconnect();
97
- }
98
-
99
- this.__nodeObserver = new MutationObserver((mutations) => {
100
- mutations.forEach((mutation) => {
101
- const target = mutation.target;
102
-
103
- // Ensure the mutation target is the currently connected node
104
- // to ignore async mutations dispatched for removed element.
105
- const isCurrentNodeMutation = target === this.node;
106
-
107
- if (mutation.type === 'attributes') {
108
- // We use attributeFilter to only observe ID mutation,
109
- // no need to check for attribute name separately.
110
- if (isCurrentNodeMutation) {
111
- this.__updateNodeId(target);
112
- }
113
- } else if (isCurrentNodeMutation || target.parentElement === this.node) {
114
- // Node text content has changed.
115
- this.__notifyChange(this.node);
116
- }
117
- });
118
- });
119
-
120
- // Observe changes to node ID attribute, text content and children.
121
- this.__nodeObserver.observe(node, {
122
- attributes: true,
123
- attributeFilter: ['id'],
124
- childList: true,
125
- subtree: true,
126
- characterData: true,
127
- });
128
- }
129
-
130
- /**
131
- * Returns true if a node is an HTML element with children,
132
- * or is a defined custom element, or has non-empty text.
133
- *
134
- * @param {Node} node
135
- * @return {boolean}
136
- * @private
137
- */
138
- __hasContent(node) {
139
- if (!node) {
140
- return false;
141
- }
142
-
143
- return (
144
- (node.nodeType === Node.ELEMENT_NODE && (customElements.get(node.localName) || node.children.length > 0)) ||
145
- (node.textContent && node.textContent.trim() !== '')
146
- );
147
- }
148
-
149
- /**
150
- * Fire an event to notify the controller host about node changes.
151
- *
152
- * @param {Node} node
153
- * @private
154
- */
155
- __notifyChange(node) {
156
- this.dispatchEvent(
157
- new CustomEvent('slot-content-changed', {
158
- detail: { hasContent: this.__hasContent(node), node },
159
- }),
160
- );
161
- }
162
-
163
- /**
164
- * Set default ID on the node in case it is an HTML element.
165
- *
166
- * @param {Node} node
167
- * @private
168
- */
169
- __updateNodeId(node) {
170
- // When in multiple mode, only set ID attribute on the element in default slot.
171
- const isFirstNode = !this.nodes || node === this.nodes[0];
172
- if (node.nodeType === Node.ELEMENT_NODE && isFirstNode && !node.id) {
173
- node.id = this.defaultId;
174
- }
175
- }
176
- }
@@ -1,86 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2022 - 2023 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { SlotController } from './slot-controller.js';
7
-
8
- type TooltipPosition =
9
- | 'bottom-end'
10
- | 'bottom-start'
11
- | 'bottom'
12
- | 'end-bottom'
13
- | 'end-top'
14
- | 'end'
15
- | 'start-bottom'
16
- | 'start-top'
17
- | 'start'
18
- | 'top-end'
19
- | 'top-start'
20
- | 'top';
21
-
22
- /**
23
- * A controller that manages the slotted tooltip element.
24
- */
25
- export class TooltipController extends SlotController {
26
- /**
27
- * Object with properties passed to `generator`
28
- * function to be used for generating tooltip text.
29
- */
30
- context: Record<string, unknown>;
31
-
32
- /**
33
- * When true, the tooltip is controlled programmatically
34
- * instead of reacting to focus and mouse events.
35
- */
36
- manual: boolean;
37
-
38
- /**
39
- * When true, the tooltip is opened programmatically.
40
- * Only works if `manual` is set to `true`.
41
- */
42
- opened: boolean;
43
-
44
- /**
45
- * Position of the tooltip with respect to its target.
46
- */
47
- position: TooltipPosition;
48
-
49
- /**
50
- * An HTML element to attach the tooltip to.
51
- */
52
- target: HTMLElement;
53
-
54
- /**
55
- * Set a context object to be used by generator.
56
- */
57
- setContext(context: Record<string, unknown>): void;
58
-
59
- /**
60
- * Toggle manual state on the slotted tooltip.
61
- */
62
- setManual(manual: boolean): void;
63
-
64
- /**
65
- * Toggle opened state on the slotted tooltip.
66
- */
67
- setOpened(opened: boolean): void;
68
-
69
- /**
70
- * Set default position for the slotted tooltip.
71
- * This can be overridden by setting the position
72
- * using corresponding property or attribute.
73
- */
74
- setPosition(position: TooltipPosition): void;
75
-
76
- /**
77
- * Set function used to detect whether to show
78
- * the tooltip based on a condition.
79
- */
80
- setShouldShow(shouldShow: (target: HTMLElement) => boolean): void;
81
-
82
- /**
83
- * Set an HTML element to attach the tooltip to.
84
- */
85
- setTarget(target: HTMLElement): void;
86
- }
@@ -1,130 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2022 - 2023 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { SlotController } from './slot-controller.js';
7
-
8
- /**
9
- * A controller that manages the slotted tooltip element.
10
- */
11
- export class TooltipController extends SlotController {
12
- constructor(host) {
13
- // Do not provide slot factory to create tooltip lazily.
14
- super(host, 'tooltip');
15
-
16
- this.setTarget(host);
17
- }
18
-
19
- /**
20
- * Override to initialize the newly added custom tooltip.
21
- *
22
- * @param {Node} tooltipNode
23
- * @protected
24
- * @override
25
- */
26
- initCustomNode(tooltipNode) {
27
- tooltipNode.target = this.target;
28
-
29
- if (this.context !== undefined) {
30
- tooltipNode.context = this.context;
31
- }
32
-
33
- if (this.manual !== undefined) {
34
- tooltipNode.manual = this.manual;
35
- }
36
-
37
- if (this.opened !== undefined) {
38
- tooltipNode.opened = this.opened;
39
- }
40
-
41
- if (this.position !== undefined) {
42
- tooltipNode._position = this.position;
43
- }
44
-
45
- if (this.shouldShow !== undefined) {
46
- tooltipNode.shouldShow = this.shouldShow;
47
- }
48
- }
49
-
50
- /**
51
- * Set a context object to be used by generator.
52
- * @param {object} context
53
- */
54
- setContext(context) {
55
- this.context = context;
56
-
57
- const tooltipNode = this.node;
58
- if (tooltipNode) {
59
- tooltipNode.context = context;
60
- }
61
- }
62
-
63
- /**
64
- * Toggle manual state on the slotted tooltip.
65
- * @param {boolean} manual
66
- */
67
- setManual(manual) {
68
- this.manual = manual;
69
-
70
- const tooltipNode = this.node;
71
- if (tooltipNode) {
72
- tooltipNode.manual = manual;
73
- }
74
- }
75
-
76
- /**
77
- * Toggle opened state on the slotted tooltip.
78
- * @param {boolean} opened
79
- */
80
- setOpened(opened) {
81
- this.opened = opened;
82
-
83
- const tooltipNode = this.node;
84
- if (tooltipNode) {
85
- tooltipNode.opened = opened;
86
- }
87
- }
88
-
89
- /**
90
- * Set default position for the slotted tooltip.
91
- * This can be overridden by setting the position
92
- * using corresponding property or attribute.
93
- * @param {string} position
94
- */
95
- setPosition(position) {
96
- this.position = position;
97
-
98
- const tooltipNode = this.node;
99
- if (tooltipNode) {
100
- tooltipNode._position = position;
101
- }
102
- }
103
-
104
- /**
105
- * Set function used to detect whether to show
106
- * the tooltip based on a condition.
107
- * @param {Function} shouldShow
108
- */
109
- setShouldShow(shouldShow) {
110
- this.shouldShow = shouldShow;
111
-
112
- const tooltipNode = this.node;
113
- if (tooltipNode) {
114
- tooltipNode.shouldShow = shouldShow;
115
- }
116
- }
117
-
118
- /**
119
- * Set an HTML element to attach the tooltip to.
120
- * @param {HTMLElement} target
121
- */
122
- setTarget(target) {
123
- this.target = target;
124
-
125
- const tooltipNode = this.node;
126
- if (tooltipNode) {
127
- tooltipNode.target = target;
128
- }
129
- }
130
- }