@vaadin/combo-box 24.4.0-dev.b3e1d14600 → 24.5.0-alpha1
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/README.md +0 -1
- package/package.json +16 -14
- package/src/lit/renderer-directives.d.ts +1 -1
- package/src/lit/renderer-directives.js +1 -1
- package/src/vaadin-combo-box-data-provider-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-data-provider-mixin.js +116 -120
- package/src/vaadin-combo-box-item-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-item-mixin.js +2 -2
- package/src/vaadin-combo-box-item.d.ts +1 -1
- package/src/vaadin-combo-box-item.js +1 -1
- package/src/vaadin-combo-box-light-mixin.d.ts +26 -0
- package/src/vaadin-combo-box-light-mixin.js +140 -0
- package/src/vaadin-combo-box-light.d.ts +3 -8
- package/src/vaadin-combo-box-light.js +4 -128
- package/src/vaadin-combo-box-mixin.d.ts +9 -1
- package/src/vaadin-combo-box-mixin.js +112 -33
- package/src/vaadin-combo-box-overlay-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-overlay-mixin.js +1 -1
- package/src/vaadin-combo-box-overlay.d.ts +1 -1
- package/src/vaadin-combo-box-overlay.js +1 -1
- package/src/vaadin-combo-box-placeholder.js +1 -1
- package/src/vaadin-combo-box-scroller-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-scroller-mixin.js +65 -16
- package/src/vaadin-combo-box-scroller.d.ts +1 -1
- package/src/vaadin-combo-box-scroller.js +1 -1
- package/src/vaadin-combo-box.d.ts +1 -1
- package/src/vaadin-combo-box.js +1 -1
- package/src/vaadin-lit-combo-box-item.js +50 -0
- package/src/vaadin-lit-combo-box-light.js +58 -0
- package/src/vaadin-lit-combo-box-overlay.js +76 -0
- package/src/vaadin-lit-combo-box-scroller.js +59 -0
- package/src/vaadin-lit-combo-box.js +170 -0
- package/theme/lumo/vaadin-combo-box-item-styles.d.ts +5 -0
- package/theme/lumo/vaadin-combo-box-item-styles.js +2 -4
- package/theme/lumo/vaadin-combo-box-light.d.ts +3 -0
- package/theme/lumo/vaadin-combo-box-overlay-styles.d.ts +6 -0
- package/theme/lumo/vaadin-combo-box-styles.d.ts +2 -0
- package/theme/lumo/vaadin-combo-box.d.ts +4 -0
- package/theme/lumo/vaadin-lit-combo-box-light.d.ts +3 -0
- package/theme/lumo/vaadin-lit-combo-box-light.js +3 -0
- package/theme/lumo/vaadin-lit-combo-box.d.ts +4 -0
- package/theme/lumo/vaadin-lit-combo-box.js +4 -0
- package/theme/material/vaadin-combo-box-item-styles.d.ts +5 -0
- package/theme/material/vaadin-combo-box-light.d.ts +3 -0
- package/theme/material/vaadin-combo-box-overlay-styles.d.ts +4 -0
- package/theme/material/vaadin-combo-box-styles.d.ts +3 -0
- package/theme/material/vaadin-combo-box.d.ts +4 -0
- package/web-types.json +1210 -0
- package/web-types.lit.json +587 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 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 { get } from '@vaadin/component-base/src/path-utils.js';
|
|
@@ -21,6 +21,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
21
21
|
*/
|
|
22
22
|
items: {
|
|
23
23
|
type: Array,
|
|
24
|
+
sync: true,
|
|
24
25
|
observer: '__itemsChanged',
|
|
25
26
|
},
|
|
26
27
|
|
|
@@ -30,6 +31,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
30
31
|
*/
|
|
31
32
|
focusedIndex: {
|
|
32
33
|
type: Number,
|
|
34
|
+
sync: true,
|
|
33
35
|
observer: '__focusedIndexChanged',
|
|
34
36
|
},
|
|
35
37
|
|
|
@@ -38,6 +40,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
38
40
|
*/
|
|
39
41
|
loading: {
|
|
40
42
|
type: Boolean,
|
|
43
|
+
sync: true,
|
|
41
44
|
observer: '__loadingChanged',
|
|
42
45
|
},
|
|
43
46
|
|
|
@@ -47,6 +50,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
47
50
|
*/
|
|
48
51
|
opened: {
|
|
49
52
|
type: Boolean,
|
|
53
|
+
sync: true,
|
|
50
54
|
observer: '__openedChanged',
|
|
51
55
|
},
|
|
52
56
|
|
|
@@ -55,9 +59,21 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
55
59
|
*/
|
|
56
60
|
selectedItem: {
|
|
57
61
|
type: Object,
|
|
62
|
+
sync: true,
|
|
58
63
|
observer: '__selectedItemChanged',
|
|
59
64
|
},
|
|
60
65
|
|
|
66
|
+
/**
|
|
67
|
+
* A function used to generate CSS class names for dropdown
|
|
68
|
+
* items based on the item. The return value should be the
|
|
69
|
+
* generated class name as a string, or multiple class names
|
|
70
|
+
* separated by whitespace characters.
|
|
71
|
+
*/
|
|
72
|
+
itemClassNameGenerator: {
|
|
73
|
+
type: Object,
|
|
74
|
+
observer: '__itemClassNameGeneratorChanged',
|
|
75
|
+
},
|
|
76
|
+
|
|
61
77
|
/**
|
|
62
78
|
* Path for the id of the item, used to detect whether the item is selected.
|
|
63
79
|
*/
|
|
@@ -84,6 +100,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
84
100
|
*/
|
|
85
101
|
renderer: {
|
|
86
102
|
type: Object,
|
|
103
|
+
sync: true,
|
|
87
104
|
observer: '__rendererChanged',
|
|
88
105
|
},
|
|
89
106
|
|
|
@@ -132,21 +149,21 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
132
149
|
this.addEventListener('click', (e) => e.stopPropagation());
|
|
133
150
|
|
|
134
151
|
this.__patchWheelOverScrolling();
|
|
135
|
-
|
|
136
|
-
this.__virtualizer = new Virtualizer({
|
|
137
|
-
createElements: this.__createElements.bind(this),
|
|
138
|
-
updateElement: this._updateElement.bind(this),
|
|
139
|
-
elementsContainer: this,
|
|
140
|
-
scrollTarget: this,
|
|
141
|
-
scrollContainer: this.$.selector,
|
|
142
|
-
});
|
|
143
152
|
}
|
|
144
153
|
|
|
145
154
|
/**
|
|
146
|
-
*
|
|
155
|
+
* Updates the virtualizer's size and items.
|
|
147
156
|
*/
|
|
148
157
|
requestContentUpdate() {
|
|
149
|
-
if (this.__virtualizer) {
|
|
158
|
+
if (!this.__virtualizer) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (this.items) {
|
|
163
|
+
this.__virtualizer.size = this.items.length;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (this.opened) {
|
|
150
167
|
this.__virtualizer.update();
|
|
151
168
|
}
|
|
152
169
|
}
|
|
@@ -157,7 +174,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
157
174
|
* @param {number} index
|
|
158
175
|
*/
|
|
159
176
|
scrollIntoView(index) {
|
|
160
|
-
if (!(this.opened && index >= 0)) {
|
|
177
|
+
if (!this.__virtualizer || !(this.opened && index >= 0)) {
|
|
161
178
|
return;
|
|
162
179
|
}
|
|
163
180
|
|
|
@@ -208,11 +225,21 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
208
225
|
return item === selectedItem;
|
|
209
226
|
}
|
|
210
227
|
|
|
228
|
+
/** @private */
|
|
229
|
+
__initVirtualizer() {
|
|
230
|
+
this.__virtualizer = new Virtualizer({
|
|
231
|
+
createElements: this.__createElements.bind(this),
|
|
232
|
+
updateElement: this._updateElement.bind(this),
|
|
233
|
+
elementsContainer: this,
|
|
234
|
+
scrollTarget: this,
|
|
235
|
+
scrollContainer: this.$.selector,
|
|
236
|
+
reorderElements: true,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
211
240
|
/** @private */
|
|
212
241
|
__itemsChanged(items) {
|
|
213
|
-
if (this.__virtualizer
|
|
214
|
-
this.__virtualizer.size = items.length;
|
|
215
|
-
this.__virtualizer.flush();
|
|
242
|
+
if (items && this.__virtualizer) {
|
|
216
243
|
this.requestContentUpdate();
|
|
217
244
|
}
|
|
218
245
|
}
|
|
@@ -225,6 +252,10 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
225
252
|
/** @private */
|
|
226
253
|
__openedChanged(opened) {
|
|
227
254
|
if (opened) {
|
|
255
|
+
if (!this.__virtualizer) {
|
|
256
|
+
this.__initVirtualizer();
|
|
257
|
+
}
|
|
258
|
+
|
|
228
259
|
this.requestContentUpdate();
|
|
229
260
|
}
|
|
230
261
|
}
|
|
@@ -234,6 +265,13 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
234
265
|
this.requestContentUpdate();
|
|
235
266
|
}
|
|
236
267
|
|
|
268
|
+
/** @private */
|
|
269
|
+
__itemClassNameGeneratorChanged(generator, oldGenerator) {
|
|
270
|
+
if (generator || oldGenerator) {
|
|
271
|
+
this.requestContentUpdate();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
237
275
|
/** @private */
|
|
238
276
|
__focusedIndexChanged(index, oldIndex) {
|
|
239
277
|
if (index !== oldIndex) {
|
|
@@ -285,6 +323,18 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
285
323
|
focused: !this.loading && focusedIndex === index,
|
|
286
324
|
});
|
|
287
325
|
|
|
326
|
+
if (typeof this.itemClassNameGenerator === 'function') {
|
|
327
|
+
el.className = this.itemClassNameGenerator(item);
|
|
328
|
+
} else if (el.className !== '') {
|
|
329
|
+
el.className = '';
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// NOTE: in PolylitMixin, setProperties() waits for `hasUpdated` to be set.
|
|
333
|
+
// However, this causes issues with virtualizer. So we enforce sync update.
|
|
334
|
+
if (el.performUpdate && !el.hasUpdated) {
|
|
335
|
+
el.performUpdate();
|
|
336
|
+
}
|
|
337
|
+
|
|
288
338
|
el.id = `${this.__hostTagName}-item-${index}`;
|
|
289
339
|
el.setAttribute('role', index !== undefined ? 'option' : false);
|
|
290
340
|
el.setAttribute('aria-selected', selected.toString());
|
|
@@ -345,7 +395,6 @@ export const ComboBoxScrollerMixin = (superClass) =>
|
|
|
345
395
|
new CustomEvent('index-requested', {
|
|
346
396
|
detail: {
|
|
347
397
|
index,
|
|
348
|
-
currentScrollerPos: this._oldScrollerPosition,
|
|
349
398
|
},
|
|
350
399
|
}),
|
|
351
400
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 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 { ComboBoxScrollerMixin } from './vaadin-combo-box-overlay-mixin.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 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 { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 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 { DelegateFocusMixinClass } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 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 '@vaadin/input-container/src/vaadin-input-container.js';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css, html, LitElement } from 'lit';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
+
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
|
+
import { ComboBoxItemMixin } from './vaadin-combo-box-item-mixin.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* LitElement based version of `<vaadin-combo-box-item>` web component.
|
|
15
|
+
*
|
|
16
|
+
* ## Disclaimer
|
|
17
|
+
*
|
|
18
|
+
* This component is an experiment not intended for publishing to npm.
|
|
19
|
+
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
20
|
+
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
21
|
+
*/
|
|
22
|
+
export class ComboBoxItem extends ComboBoxItemMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
|
|
23
|
+
static get is() {
|
|
24
|
+
return 'vaadin-combo-box-item';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static get styles() {
|
|
28
|
+
return css`
|
|
29
|
+
:host {
|
|
30
|
+
display: block;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host([hidden]) {
|
|
34
|
+
display: none;
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** @protected */
|
|
40
|
+
render() {
|
|
41
|
+
return html`
|
|
42
|
+
<span part="checkmark" aria-hidden="true"></span>
|
|
43
|
+
<div part="content">
|
|
44
|
+
<slot></slot>
|
|
45
|
+
</div>
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
defineCustomElement(ComboBoxItem);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import './vaadin-lit-combo-box-item.js';
|
|
7
|
+
import './vaadin-lit-combo-box-overlay.js';
|
|
8
|
+
import './vaadin-lit-combo-box-scroller.js';
|
|
9
|
+
import { css, html, LitElement } from 'lit';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
12
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
13
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
14
|
+
import { ComboBoxLightMixin } from './vaadin-combo-box-light-mixin.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* LitElement based version of `<vaadin-combo-box-light>` web component.
|
|
18
|
+
*
|
|
19
|
+
* ## Disclaimer
|
|
20
|
+
*
|
|
21
|
+
* This component is an experiment not intended for publishing to npm.
|
|
22
|
+
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
23
|
+
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
24
|
+
*/
|
|
25
|
+
class ComboBoxLight extends ComboBoxLightMixin(ThemableMixin(PolylitMixin(LitElement))) {
|
|
26
|
+
static get is() {
|
|
27
|
+
return 'vaadin-combo-box-light';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static get styles() {
|
|
31
|
+
return css`
|
|
32
|
+
:host([opened]) {
|
|
33
|
+
pointer-events: auto;
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @protected */
|
|
39
|
+
render() {
|
|
40
|
+
return html`
|
|
41
|
+
<slot></slot>
|
|
42
|
+
|
|
43
|
+
<vaadin-combo-box-overlay
|
|
44
|
+
id="overlay"
|
|
45
|
+
.opened="${this._overlayOpened}"
|
|
46
|
+
?loading="${this.loading}"
|
|
47
|
+
theme="${ifDefined(this._theme)}"
|
|
48
|
+
.positionTarget="${this.inputElement}"
|
|
49
|
+
.restoreFocusNode="${this.inputElement}"
|
|
50
|
+
no-vertical-overlap
|
|
51
|
+
></vaadin-combo-box-overlay>
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
defineCustomElement(ComboBoxLight);
|
|
57
|
+
|
|
58
|
+
export { ComboBoxLight };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css, html, LitElement } from 'lit';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
+
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
+
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
|
|
11
|
+
import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
|
|
12
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
|
+
import { ComboBoxOverlayMixin } from './vaadin-combo-box-overlay-mixin.js';
|
|
14
|
+
|
|
15
|
+
const comboBoxOverlayStyles = css`
|
|
16
|
+
#overlay {
|
|
17
|
+
width: var(--vaadin-combo-box-overlay-width, var(--_vaadin-combo-box-overlay-default-width, auto));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[part='content'] {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
height: 100%;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An element used internally by `<vaadin-combo-box>`. Not intended to be used separately.
|
|
29
|
+
*
|
|
30
|
+
* @extends HTMLElement
|
|
31
|
+
* @mixes ComboBoxOverlayMixin
|
|
32
|
+
* @mixes DirMixin
|
|
33
|
+
* @mixes OverlayMixin
|
|
34
|
+
* @mixes ThemableMixin
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
export class ComboBoxOverlay extends ComboBoxOverlayMixin(
|
|
38
|
+
OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement)))),
|
|
39
|
+
) {
|
|
40
|
+
static get is() {
|
|
41
|
+
return 'vaadin-combo-box-overlay';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static get styles() {
|
|
45
|
+
return [overlayStyles, comboBoxOverlayStyles, comboBoxOverlayStyles];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static get properties() {
|
|
49
|
+
return {
|
|
50
|
+
/**
|
|
51
|
+
* When true, the overlay is visible and attached to body.
|
|
52
|
+
* This property config is overridden to set `sync: true`.
|
|
53
|
+
*/
|
|
54
|
+
opened: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
notify: true,
|
|
57
|
+
observer: '_openedChanged',
|
|
58
|
+
reflectToAttribute: true,
|
|
59
|
+
sync: true,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** @protected */
|
|
65
|
+
render() {
|
|
66
|
+
return html`
|
|
67
|
+
<div id="backdrop" part="backdrop" hidden></div>
|
|
68
|
+
<div part="overlay" id="overlay">
|
|
69
|
+
<div part="loader"></div>
|
|
70
|
+
<div part="content" id="content"><slot></slot></div>
|
|
71
|
+
</div>
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
defineCustomElement(ComboBoxOverlay);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css, html, LitElement } from 'lit';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
+
import { ComboBoxScrollerMixin } from './vaadin-combo-box-scroller-mixin.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* An element used internally by `<vaadin-combo-box>`. Not intended to be used separately.
|
|
13
|
+
*
|
|
14
|
+
* @extends HTMLElement
|
|
15
|
+
* @mixes ComboBoxScrollerMixin
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
export class ComboBoxScroller extends ComboBoxScrollerMixin(PolylitMixin(LitElement)) {
|
|
19
|
+
static get is() {
|
|
20
|
+
return 'vaadin-combo-box-scroller';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static get styles() {
|
|
24
|
+
return css`
|
|
25
|
+
:host {
|
|
26
|
+
display: block;
|
|
27
|
+
min-height: 1px;
|
|
28
|
+
overflow: auto;
|
|
29
|
+
|
|
30
|
+
/* Fixes item background from getting on top of scrollbars on Safari */
|
|
31
|
+
transform: translate3d(0, 0, 0);
|
|
32
|
+
|
|
33
|
+
/* Enable momentum scrolling on iOS */
|
|
34
|
+
-webkit-overflow-scrolling: touch;
|
|
35
|
+
|
|
36
|
+
/* Fixes scrollbar disappearing when 'Show scroll bars: Always' enabled in Safari */
|
|
37
|
+
box-shadow: 0 0 0 white;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#selector {
|
|
41
|
+
border-width: var(--_vaadin-combo-box-items-container-border-width);
|
|
42
|
+
border-style: var(--_vaadin-combo-box-items-container-border-style);
|
|
43
|
+
border-color: var(--_vaadin-combo-box-items-container-border-color, transparent);
|
|
44
|
+
position: relative;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** @protected */
|
|
50
|
+
render() {
|
|
51
|
+
return html`
|
|
52
|
+
<div id="selector">
|
|
53
|
+
<slot></slot>
|
|
54
|
+
</div>
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
defineCustomElement(ComboBoxScroller);
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import '@vaadin/input-container/src/vaadin-lit-input-container.js';
|
|
7
|
+
import './vaadin-lit-combo-box-item.js';
|
|
8
|
+
import './vaadin-lit-combo-box-overlay.js';
|
|
9
|
+
import './vaadin-lit-combo-box-scroller.js';
|
|
10
|
+
import { css, html, LitElement } from 'lit';
|
|
11
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
12
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
13
|
+
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
14
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
15
|
+
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
16
|
+
import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
17
|
+
import { InputController } from '@vaadin/field-base/src/input-controller.js';
|
|
18
|
+
import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
|
|
19
|
+
import { PatternMixin } from '@vaadin/field-base/src/pattern-mixin.js';
|
|
20
|
+
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
21
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
22
|
+
import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin.js';
|
|
23
|
+
import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* LitElement based version of `<vaadin-combo-box>` web component.
|
|
27
|
+
*
|
|
28
|
+
* ## Disclaimer
|
|
29
|
+
*
|
|
30
|
+
* This component is an experiment not intended for publishing to npm.
|
|
31
|
+
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
32
|
+
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
33
|
+
*/
|
|
34
|
+
class ComboBox extends ComboBoxDataProviderMixin(
|
|
35
|
+
ComboBoxMixin(PatternMixin(InputControlMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement)))))),
|
|
36
|
+
) {
|
|
37
|
+
static get is() {
|
|
38
|
+
return 'vaadin-combo-box';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static get styles() {
|
|
42
|
+
return [
|
|
43
|
+
inputFieldShared,
|
|
44
|
+
css`
|
|
45
|
+
:host([opened]) {
|
|
46
|
+
pointer-events: auto;
|
|
47
|
+
}
|
|
48
|
+
`,
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static get properties() {
|
|
53
|
+
return {
|
|
54
|
+
/**
|
|
55
|
+
* @protected
|
|
56
|
+
*/
|
|
57
|
+
_positionTarget: {
|
|
58
|
+
type: Object,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Used by `InputControlMixin` as a reference to the clear button element.
|
|
65
|
+
* @protected
|
|
66
|
+
* @return {!HTMLElement}
|
|
67
|
+
*/
|
|
68
|
+
get clearElement() {
|
|
69
|
+
return this.$.clearButton;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** @protected */
|
|
73
|
+
render() {
|
|
74
|
+
return html`
|
|
75
|
+
<div class="vaadin-combo-box-container">
|
|
76
|
+
<div part="label">
|
|
77
|
+
<slot name="label"></slot>
|
|
78
|
+
<span part="required-indicator" aria-hidden="true" @click="${this.focus}"></span>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<vaadin-input-container
|
|
82
|
+
part="input-field"
|
|
83
|
+
.readonly="${this.readonly}"
|
|
84
|
+
.disabled="${this.disabled}"
|
|
85
|
+
.invalid="${this.invalid}"
|
|
86
|
+
theme="${ifDefined(this._theme)}"
|
|
87
|
+
>
|
|
88
|
+
<slot name="prefix" slot="prefix"></slot>
|
|
89
|
+
<slot name="input"></slot>
|
|
90
|
+
<div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
|
|
91
|
+
<div id="toggleButton" part="toggle-button" slot="suffix" aria-hidden="true"></div>
|
|
92
|
+
</vaadin-input-container>
|
|
93
|
+
|
|
94
|
+
<div part="helper-text">
|
|
95
|
+
<slot name="helper"></slot>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<div part="error-message">
|
|
99
|
+
<slot name="error-message"></slot>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<vaadin-combo-box-overlay
|
|
104
|
+
id="overlay"
|
|
105
|
+
.opened="${this._overlayOpened}"
|
|
106
|
+
?loading="${this.loading}"
|
|
107
|
+
theme="${ifDefined(this._theme)}"
|
|
108
|
+
.positionTarget="${this._positionTarget}"
|
|
109
|
+
.restoreFocusNode="${this.inputElement}"
|
|
110
|
+
no-vertical-overlap
|
|
111
|
+
></vaadin-combo-box-overlay>
|
|
112
|
+
|
|
113
|
+
<slot name="tooltip"></slot>
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** @protected */
|
|
118
|
+
ready() {
|
|
119
|
+
super.ready();
|
|
120
|
+
|
|
121
|
+
this.addController(
|
|
122
|
+
new InputController(this, (input) => {
|
|
123
|
+
this._setInputElement(input);
|
|
124
|
+
this._setFocusElement(input);
|
|
125
|
+
this.stateTarget = input;
|
|
126
|
+
this.ariaTarget = input;
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
130
|
+
|
|
131
|
+
this._tooltipController = new TooltipController(this);
|
|
132
|
+
this.addController(this._tooltipController);
|
|
133
|
+
this._tooltipController.setPosition('top');
|
|
134
|
+
this._tooltipController.setShouldShow((target) => !target.opened);
|
|
135
|
+
|
|
136
|
+
this._positionTarget = this.shadowRoot.querySelector('[part="input-field"]');
|
|
137
|
+
this._toggleElement = this.$.toggleButton;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Override the method from `InputControlMixin`
|
|
142
|
+
* to stop event propagation to prevent `ComboBoxMixin`
|
|
143
|
+
* from handling this click event also on its own.
|
|
144
|
+
*
|
|
145
|
+
* @param {Event} event
|
|
146
|
+
* @protected
|
|
147
|
+
* @override
|
|
148
|
+
*/
|
|
149
|
+
_onClearButtonClick(event) {
|
|
150
|
+
event.stopPropagation();
|
|
151
|
+
super._onClearButtonClick(event);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @param {Event} event
|
|
156
|
+
* @protected
|
|
157
|
+
*/
|
|
158
|
+
_onHostClick(event) {
|
|
159
|
+
const path = event.composedPath();
|
|
160
|
+
|
|
161
|
+
// Open dropdown only when clicking on the label or input field
|
|
162
|
+
if (path.includes(this._labelNode) || path.includes(this._positionTarget)) {
|
|
163
|
+
super._onHostClick(event);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
defineCustomElement(ComboBox);
|
|
169
|
+
|
|
170
|
+
export { ComboBox };
|
|
@@ -13,10 +13,8 @@ const comboBoxItem = css`
|
|
|
13
13
|
--_focus-ring-width: var(--vaadin-focus-ring-width, 2px);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
:
|
|
18
|
-
box-shadow: inset 0 0 0 var(--_focus-ring-width) var(--_focus-ring-color);
|
|
19
|
-
}
|
|
16
|
+
:host([focused]:not([disabled])) {
|
|
17
|
+
box-shadow: inset 0 0 0 var(--_focus-ring-width) var(--_focus-ring-color);
|
|
20
18
|
}
|
|
21
19
|
`;
|
|
22
20
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import '@vaadin/vaadin-lumo-styles/color.js';
|
|
2
|
+
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
3
|
+
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
4
|
+
declare const comboBoxOverlay: import("lit").CSSResult;
|
|
5
|
+
declare const comboBoxLoader: import("lit").CSSResult;
|
|
6
|
+
export { comboBoxLoader, comboBoxOverlay };
|