@vaadin/combo-box 24.0.0-alpha12 → 24.0.0-alpha13
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 +13 -13
- package/src/vaadin-combo-box-item-mixin.d.ts +65 -0
- package/src/vaadin-combo-box-item-mixin.js +127 -0
- package/src/vaadin-combo-box-item.d.ts +45 -0
- package/src/vaadin-combo-box-item.js +3 -114
- package/src/vaadin-combo-box-mixin.d.ts +3 -11
- package/src/vaadin-combo-box-mixin.js +1 -1
- package/src/vaadin-combo-box-overlay-mixin.d.ts +11 -0
- package/src/vaadin-combo-box-overlay-mixin.js +60 -0
- package/src/vaadin-combo-box-overlay.d.ts +20 -0
- package/src/vaadin-combo-box-overlay.js +9 -48
- package/src/vaadin-combo-box-scroller-mixin.d.ts +82 -0
- package/src/vaadin-combo-box-scroller-mixin.js +361 -0
- package/src/vaadin-combo-box-scroller.d.ts +19 -0
- package/src/vaadin-combo-box-scroller.js +5 -346
- package/theme/lumo/vaadin-combo-box-item-styles.js +2 -0
- package/theme/lumo/vaadin-combo-box-light.js +1 -1
- package/theme/lumo/{vaadin-combo-box-dropdown-styles.js → vaadin-combo-box-overlay-styles.js} +21 -13
- package/theme/lumo/vaadin-combo-box.js +1 -1
- package/theme/material/vaadin-combo-box-item-styles.js +2 -0
- package/theme/material/vaadin-combo-box-light.js +1 -1
- package/theme/material/{vaadin-combo-box-dropdown-styles.js → vaadin-combo-box-overlay-styles.js} +20 -9
- package/theme/material/vaadin-combo-box.js +1 -1
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/combo-box",
|
|
3
|
-
"version": "24.0.0-
|
|
3
|
+
"version": "24.0.0-alpha13",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,20 +38,20 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
40
|
"@polymer/polymer": "^3.0.0",
|
|
41
|
-
"@vaadin/component-base": "24.0.0-
|
|
42
|
-
"@vaadin/field-base": "24.0.0-
|
|
43
|
-
"@vaadin/input-container": "24.0.0-
|
|
44
|
-
"@vaadin/item": "24.0.0-
|
|
45
|
-
"@vaadin/lit-renderer": "24.0.0-
|
|
46
|
-
"@vaadin/overlay": "24.0.0-
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "24.0.0-
|
|
48
|
-
"@vaadin/vaadin-material-styles": "24.0.0-
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "24.0.0-
|
|
41
|
+
"@vaadin/component-base": "24.0.0-alpha13",
|
|
42
|
+
"@vaadin/field-base": "24.0.0-alpha13",
|
|
43
|
+
"@vaadin/input-container": "24.0.0-alpha13",
|
|
44
|
+
"@vaadin/item": "24.0.0-alpha13",
|
|
45
|
+
"@vaadin/lit-renderer": "24.0.0-alpha13",
|
|
46
|
+
"@vaadin/overlay": "24.0.0-alpha13",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha13",
|
|
48
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha13",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha13"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@esm-bundle/chai": "^4.3.4",
|
|
53
|
-
"@vaadin/testing-helpers": "^0.
|
|
54
|
-
"@vaadin/text-field": "24.0.0-
|
|
53
|
+
"@vaadin/testing-helpers": "^0.4.0",
|
|
54
|
+
"@vaadin/text-field": "24.0.0-alpha13",
|
|
55
55
|
"lit": "^2.0.0",
|
|
56
56
|
"sinon": "^13.0.2"
|
|
57
57
|
},
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"web-types.json",
|
|
60
60
|
"web-types.lit.json"
|
|
61
61
|
],
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "a423ad309c12b4e4f847737ee9f491f83ea60ff0"
|
|
63
63
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2015 - 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
|
+
export type ComboBoxDefaultItem = any;
|
|
9
|
+
|
|
10
|
+
export interface ComboBoxItemModel<TItem> {
|
|
11
|
+
index: number;
|
|
12
|
+
item: TItem;
|
|
13
|
+
selected: boolean;
|
|
14
|
+
focused: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type ComboBoxItemRenderer<TItem, TOwner> = (
|
|
18
|
+
root: HTMLElement,
|
|
19
|
+
owner: TOwner,
|
|
20
|
+
model: ComboBoxItemModel<TItem>,
|
|
21
|
+
) => void;
|
|
22
|
+
|
|
23
|
+
export declare function ComboBoxItemMixin<TItem, TOwner, T extends Constructor<HTMLElement>>(
|
|
24
|
+
base: T,
|
|
25
|
+
): Constructor<ComboBoxItemMixinClass<TItem, TOwner>> & T;
|
|
26
|
+
|
|
27
|
+
export declare class ComboBoxItemMixinClass<TItem, TOwner> {
|
|
28
|
+
/**
|
|
29
|
+
* The item to render.
|
|
30
|
+
*/
|
|
31
|
+
index: number;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The item to render.
|
|
35
|
+
*/
|
|
36
|
+
item: TItem;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The text to render in the item.
|
|
40
|
+
*/
|
|
41
|
+
label: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* True when item is selected.
|
|
45
|
+
*/
|
|
46
|
+
selected: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* True when item is focused.
|
|
50
|
+
*/
|
|
51
|
+
focused: boolean;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Custom function for rendering the item content.
|
|
55
|
+
*/
|
|
56
|
+
renderer: ComboBoxItemRenderer<TItem, TOwner>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Requests an update for the content of the item.
|
|
60
|
+
* While performing the update, it invokes the renderer passed in the `renderer` property.
|
|
61
|
+
*
|
|
62
|
+
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
|
|
63
|
+
*/
|
|
64
|
+
requestContentUpdate(): void;
|
|
65
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @polymerMixin
|
|
9
|
+
*/
|
|
10
|
+
export const ComboBoxItemMixin = (superClass) =>
|
|
11
|
+
class ComboBoxItemMixinClass extends superClass {
|
|
12
|
+
static get properties() {
|
|
13
|
+
return {
|
|
14
|
+
/**
|
|
15
|
+
* The index of the item.
|
|
16
|
+
*/
|
|
17
|
+
index: {
|
|
18
|
+
type: Number,
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The item to render.
|
|
23
|
+
*/
|
|
24
|
+
item: {
|
|
25
|
+
type: Object,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The text to render in the item.
|
|
30
|
+
*/
|
|
31
|
+
label: {
|
|
32
|
+
type: String,
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* True when item is selected.
|
|
37
|
+
*/
|
|
38
|
+
selected: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
value: false,
|
|
41
|
+
reflectToAttribute: true,
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* True when item is focused.
|
|
46
|
+
*/
|
|
47
|
+
focused: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
value: false,
|
|
50
|
+
reflectToAttribute: true,
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Custom function for rendering the item content.
|
|
55
|
+
*/
|
|
56
|
+
renderer: {
|
|
57
|
+
type: Function,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static get observers() {
|
|
63
|
+
return ['__rendererOrItemChanged(renderer, index, item.*, selected, focused)', '__updateLabel(label, renderer)'];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** @protected */
|
|
67
|
+
connectedCallback() {
|
|
68
|
+
super.connectedCallback();
|
|
69
|
+
|
|
70
|
+
this._owner = this.parentNode.owner;
|
|
71
|
+
|
|
72
|
+
const hostDir = this._owner.getAttribute('dir');
|
|
73
|
+
if (hostDir) {
|
|
74
|
+
this.setAttribute('dir', hostDir);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Requests an update for the content of the item.
|
|
80
|
+
* While performing the update, it invokes the renderer passed in the `renderer` property.
|
|
81
|
+
*
|
|
82
|
+
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
|
|
83
|
+
*/
|
|
84
|
+
requestContentUpdate() {
|
|
85
|
+
if (!this.renderer) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const model = {
|
|
90
|
+
index: this.index,
|
|
91
|
+
item: this.item,
|
|
92
|
+
focused: this.focused,
|
|
93
|
+
selected: this.selected,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
this.renderer(this, this._owner, model);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** @private */
|
|
100
|
+
__rendererOrItemChanged(renderer, index, item) {
|
|
101
|
+
if (item === undefined || index === undefined) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (this._oldRenderer !== renderer) {
|
|
106
|
+
this.innerHTML = '';
|
|
107
|
+
// Whenever a Lit-based renderer is used, it assigns a Lit part to the node it was rendered into.
|
|
108
|
+
// When clearing the rendered content, this part needs to be manually disposed of.
|
|
109
|
+
// Otherwise, using a Lit-based renderer on the same node will throw an exception or render nothing afterward.
|
|
110
|
+
delete this._$litPart$;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (renderer) {
|
|
114
|
+
this._oldRenderer = renderer;
|
|
115
|
+
this.requestContentUpdate();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** @private */
|
|
120
|
+
__updateLabel(label, renderer) {
|
|
121
|
+
if (renderer) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
this.textContent = label;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { DirMixinClass } from '@vaadin/component-base/src/dir-mixin.js';
|
|
7
|
+
import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
|
+
import type { ComboBox } from './vaadin-combo-box.js';
|
|
9
|
+
import type { ComboBoxDefaultItem, ComboBoxItemMixinClass } from './vaadin-combo-box-item-mixin.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* An item element used by the `<vaadin-combo-box>` dropdown.
|
|
13
|
+
*
|
|
14
|
+
* ### Styling
|
|
15
|
+
*
|
|
16
|
+
* The following shadow DOM parts are available for styling:
|
|
17
|
+
*
|
|
18
|
+
* Part name | Description
|
|
19
|
+
* ------------|--------------
|
|
20
|
+
* `checkmark` | The graphical checkmark shown for a selected item
|
|
21
|
+
* `content` | The element that wraps the item content
|
|
22
|
+
*
|
|
23
|
+
* The following state attributes are exposed for styling:
|
|
24
|
+
*
|
|
25
|
+
* Attribute | Description
|
|
26
|
+
* -------------|-------------
|
|
27
|
+
* `selected` | Set when the item is selected
|
|
28
|
+
* `focused` | Set when the item is focused
|
|
29
|
+
*
|
|
30
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
31
|
+
*/
|
|
32
|
+
declare class ComboBoxItem extends HTMLElement {}
|
|
33
|
+
|
|
34
|
+
interface ComboBoxItem<TItem = ComboBoxDefaultItem>
|
|
35
|
+
extends ComboBoxItemMixinClass<TItem, ComboBox>,
|
|
36
|
+
DirMixinClass,
|
|
37
|
+
ThemableMixinClass {}
|
|
38
|
+
|
|
39
|
+
declare global {
|
|
40
|
+
interface HTMLElementTagNameMap {
|
|
41
|
+
'vaadin-combo-box-item': ComboBoxItem;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { ComboBoxItem };
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
7
7
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
8
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
|
+
import { ComboBoxItemMixin } from './vaadin-combo-box-item-mixin.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* An item element used by the `<vaadin-combo-box>` dropdown.
|
|
@@ -28,11 +29,12 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
28
29
|
*
|
|
29
30
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
30
31
|
*
|
|
32
|
+
* @mixes ComboBoxItemMixin
|
|
31
33
|
* @mixes ThemableMixin
|
|
32
34
|
* @mixes DirMixin
|
|
33
35
|
* @private
|
|
34
36
|
*/
|
|
35
|
-
export class ComboBoxItem extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
37
|
+
export class ComboBoxItem extends ComboBoxItemMixin(ThemableMixin(DirMixin(PolymerElement))) {
|
|
36
38
|
static get template() {
|
|
37
39
|
return html`
|
|
38
40
|
<style>
|
|
@@ -54,119 +56,6 @@ export class ComboBoxItem extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
54
56
|
static get is() {
|
|
55
57
|
return 'vaadin-combo-box-item';
|
|
56
58
|
}
|
|
57
|
-
|
|
58
|
-
static get properties() {
|
|
59
|
-
return {
|
|
60
|
-
/**
|
|
61
|
-
* The index of the item
|
|
62
|
-
*/
|
|
63
|
-
index: Number,
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* The item to render
|
|
67
|
-
* @type {(String|Object)}
|
|
68
|
-
*/
|
|
69
|
-
item: Object,
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The text label corresponding to the item
|
|
73
|
-
*/
|
|
74
|
-
label: String,
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* True when item is selected
|
|
78
|
-
*/
|
|
79
|
-
selected: {
|
|
80
|
-
type: Boolean,
|
|
81
|
-
value: false,
|
|
82
|
-
reflectToAttribute: true,
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* True when item is focused
|
|
87
|
-
*/
|
|
88
|
-
focused: {
|
|
89
|
-
type: Boolean,
|
|
90
|
-
value: false,
|
|
91
|
-
reflectToAttribute: true,
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Custom function for rendering the content of the `<vaadin-combo-box-item>` propagated from the combo box element.
|
|
96
|
-
*/
|
|
97
|
-
renderer: Function,
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Saved instance of a custom renderer function.
|
|
101
|
-
*/
|
|
102
|
-
_oldRenderer: Function,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
static get observers() {
|
|
107
|
-
return ['__rendererOrItemChanged(renderer, index, item.*, selected, focused)', '__updateLabel(label, renderer)'];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
connectedCallback() {
|
|
111
|
-
super.connectedCallback();
|
|
112
|
-
|
|
113
|
-
this._comboBox = this.parentNode.comboBox;
|
|
114
|
-
|
|
115
|
-
const hostDir = this._comboBox.getAttribute('dir');
|
|
116
|
-
if (hostDir) {
|
|
117
|
-
this.setAttribute('dir', hostDir);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Requests an update for the content of the item.
|
|
123
|
-
* While performing the update, it invokes the renderer passed in the `renderer` property.
|
|
124
|
-
*
|
|
125
|
-
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
|
|
126
|
-
*/
|
|
127
|
-
requestContentUpdate() {
|
|
128
|
-
if (!this.renderer) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const model = {
|
|
133
|
-
index: this.index,
|
|
134
|
-
item: this.item,
|
|
135
|
-
focused: this.focused,
|
|
136
|
-
selected: this.selected,
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
this.renderer(this, this._comboBox, model);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** @private */
|
|
143
|
-
__rendererOrItemChanged(renderer, index, item) {
|
|
144
|
-
if (item === undefined || index === undefined) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (this._oldRenderer !== renderer) {
|
|
149
|
-
this.innerHTML = '';
|
|
150
|
-
// Whenever a Lit-based renderer is used, it assigns a Lit part to the node it was rendered into.
|
|
151
|
-
// When clearing the rendered content, this part needs to be manually disposed of.
|
|
152
|
-
// Otherwise, using a Lit-based renderer on the same node will throw an exception or render nothing afterward.
|
|
153
|
-
delete this._$litPart$;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (renderer) {
|
|
157
|
-
this._oldRenderer = renderer;
|
|
158
|
-
this.requestContentUpdate();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/** @private */
|
|
163
|
-
__updateLabel(label, renderer) {
|
|
164
|
-
if (renderer) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
this.textContent = label;
|
|
169
|
-
}
|
|
170
59
|
}
|
|
171
60
|
|
|
172
61
|
customElements.define(ComboBoxItem.is, ComboBoxItem);
|
|
@@ -9,19 +9,11 @@ import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mix
|
|
|
9
9
|
import type { OverlayClassMixinClass } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
10
10
|
import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
11
11
|
import type { ComboBox } from './vaadin-combo-box.js';
|
|
12
|
+
import type { ComboBoxDefaultItem, ComboBoxItemModel, ComboBoxItemRenderer } from './vaadin-combo-box-item-mixin.js';
|
|
12
13
|
|
|
13
|
-
export type ComboBoxDefaultItem
|
|
14
|
+
export type { ComboBoxDefaultItem, ComboBoxItemModel };
|
|
14
15
|
|
|
15
|
-
export
|
|
16
|
-
index: number;
|
|
17
|
-
item: TItem;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type ComboBoxRenderer<TItem> = (
|
|
21
|
-
root: HTMLElement,
|
|
22
|
-
comboBox: ComboBox<TItem>,
|
|
23
|
-
model: ComboBoxItemModel<TItem>,
|
|
24
|
-
) => void;
|
|
16
|
+
export type ComboBoxRenderer<TItem> = ComboBoxItemRenderer<TItem, ComboBox<TItem>>;
|
|
25
17
|
|
|
26
18
|
export declare function ComboBoxMixin<TItem, T extends Constructor<HTMLElement>>(
|
|
27
19
|
base: T,
|
|
@@ -472,7 +472,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
472
472
|
|
|
473
473
|
const scroller = overlay.querySelector(scrollerTag);
|
|
474
474
|
|
|
475
|
-
scroller.
|
|
475
|
+
scroller.owner = host || this;
|
|
476
476
|
scroller.getItemLabel = this._getItemLabel.bind(this);
|
|
477
477
|
scroller.addEventListener('selection-changed', this._boundOverlaySelectedItemChanged);
|
|
478
478
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2015 - 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 { PositionMixinClass } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
|
|
8
|
+
|
|
9
|
+
export declare function ComboBoxOverlayMixin<T extends Constructor<HTMLElement>>(
|
|
10
|
+
base: T,
|
|
11
|
+
): Constructor<PositionMixinClass> & T;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @polymerMixin
|
|
10
|
+
* @mixes PositionMixin
|
|
11
|
+
*/
|
|
12
|
+
export const ComboBoxOverlayMixin = (superClass) =>
|
|
13
|
+
class ComboBoxOverlayMixin extends PositionMixin(superClass) {
|
|
14
|
+
static get observers() {
|
|
15
|
+
return ['_setOverlayWidth(positionTarget, opened)'];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** @protected */
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
super.connectedCallback();
|
|
21
|
+
|
|
22
|
+
const comboBox = this._comboBox;
|
|
23
|
+
|
|
24
|
+
const hostDir = comboBox && comboBox.getAttribute('dir');
|
|
25
|
+
if (hostDir) {
|
|
26
|
+
this.setAttribute('dir', hostDir);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Override method inherited from `Overlay`
|
|
32
|
+
* to not close on position target click.
|
|
33
|
+
*
|
|
34
|
+
* @param {Event} event
|
|
35
|
+
* @return {boolean}
|
|
36
|
+
* @protected
|
|
37
|
+
*/
|
|
38
|
+
_shouldCloseOnOutsideClick(event) {
|
|
39
|
+
const eventPath = event.composedPath();
|
|
40
|
+
return !eventPath.includes(this.positionTarget) && !eventPath.includes(this);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @private */
|
|
44
|
+
_setOverlayWidth(positionTarget, opened) {
|
|
45
|
+
if (positionTarget && opened) {
|
|
46
|
+
const propPrefix = this.localName;
|
|
47
|
+
this.style.setProperty(`--_${propPrefix}-default-width`, `${positionTarget.clientWidth}px`);
|
|
48
|
+
|
|
49
|
+
const customWidth = getComputedStyle(this._comboBox).getPropertyValue(`--${propPrefix}-width`);
|
|
50
|
+
|
|
51
|
+
if (customWidth === '') {
|
|
52
|
+
this.style.removeProperty(`--${propPrefix}-width`);
|
|
53
|
+
} else {
|
|
54
|
+
this.style.setProperty(`--${propPrefix}-width`, customWidth);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this._updatePosition();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { Overlay } from '@vaadin/overlay/src/vaadin-overlay.js';
|
|
7
|
+
import { ComboBoxOverlayMixin } from './vaadin-combo-box-overlay-mixin.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* An element used internally by `<vaadin-combo-box>`. Not intended to be used separately.
|
|
11
|
+
*/
|
|
12
|
+
declare class ComboBoxOverlay extends ComboBoxOverlayMixin(Overlay) {}
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementTagNameMap {
|
|
16
|
+
'vaadin-combo-box-overlay': ComboBoxOverlay;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { ComboBoxOverlay };
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { Overlay } from '@vaadin/overlay/src/vaadin-overlay.js';
|
|
7
|
-
import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
|
|
8
7
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
|
+
import { ComboBoxOverlayMixin } from './vaadin-combo-box-overlay-mixin.js';
|
|
9
9
|
|
|
10
10
|
registerStyles(
|
|
11
11
|
'vaadin-combo-box-overlay',
|
|
@@ -29,9 +29,10 @@ let memoizedTemplate;
|
|
|
29
29
|
* An element used internally by `<vaadin-combo-box>`. Not intended to be used separately.
|
|
30
30
|
*
|
|
31
31
|
* @extends Overlay
|
|
32
|
+
* @mixes ComboBoxOverlayMixin
|
|
32
33
|
* @private
|
|
33
34
|
*/
|
|
34
|
-
export class ComboBoxOverlay extends
|
|
35
|
+
export class ComboBoxOverlay extends ComboBoxOverlayMixin(Overlay) {
|
|
35
36
|
static get is() {
|
|
36
37
|
return 'vaadin-combo-box-overlay';
|
|
37
38
|
}
|
|
@@ -39,57 +40,17 @@ export class ComboBoxOverlay extends PositionMixin(Overlay) {
|
|
|
39
40
|
static get template() {
|
|
40
41
|
if (!memoizedTemplate) {
|
|
41
42
|
memoizedTemplate = super.template.cloneNode(true);
|
|
42
|
-
memoizedTemplate.content.querySelector('[part~="overlay"]').removeAttribute('tabindex');
|
|
43
|
-
}
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
static get observers() {
|
|
49
|
-
return ['_setOverlayWidth(positionTarget, opened)'];
|
|
50
|
-
}
|
|
44
|
+
const overlay = memoizedTemplate.content.querySelector('[part~="overlay"]');
|
|
45
|
+
overlay.removeAttribute('tabindex');
|
|
51
46
|
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
const loader = document.createElement('div');
|
|
48
|
+
loader.setAttribute('part', 'loader');
|
|
54
49
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const hostDir = comboBox && comboBox.getAttribute('dir');
|
|
58
|
-
if (hostDir) {
|
|
59
|
-
this.setAttribute('dir', hostDir);
|
|
50
|
+
overlay.insertBefore(loader, overlay.firstElementChild);
|
|
60
51
|
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
ready() {
|
|
64
|
-
super.ready();
|
|
65
|
-
const loader = document.createElement('div');
|
|
66
|
-
loader.setAttribute('part', 'loader');
|
|
67
|
-
const content = this.shadowRoot.querySelector('[part~="content"]');
|
|
68
|
-
content.parentNode.insertBefore(loader, content);
|
|
69
|
-
}
|
|
70
52
|
|
|
71
|
-
|
|
72
|
-
const eventPath = event.composedPath();
|
|
73
|
-
if (!eventPath.includes(this.positionTarget) && !eventPath.includes(this)) {
|
|
74
|
-
this.close();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
_setOverlayWidth(positionTarget, opened) {
|
|
79
|
-
if (positionTarget && opened) {
|
|
80
|
-
const propPrefix = this.localName;
|
|
81
|
-
this.style.setProperty(`--_${propPrefix}-default-width`, `${positionTarget.clientWidth}px`);
|
|
82
|
-
|
|
83
|
-
const customWidth = getComputedStyle(this._comboBox).getPropertyValue(`--${propPrefix}-width`);
|
|
84
|
-
|
|
85
|
-
if (customWidth === '') {
|
|
86
|
-
this.style.removeProperty(`--${propPrefix}-width`);
|
|
87
|
-
} else {
|
|
88
|
-
this.style.setProperty(`--${propPrefix}-width`, customWidth);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
this._updatePosition();
|
|
92
|
-
}
|
|
53
|
+
return memoizedTemplate;
|
|
93
54
|
}
|
|
94
55
|
}
|
|
95
56
|
|