@vaadin/vaadin-combo-box 21.0.1 → 22.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.
- package/package.json +23 -40
- package/src/vaadin-combo-box-light.d.ts +14 -95
- package/src/vaadin-combo-box-light.js +4 -197
- package/src/vaadin-combo-box.d.ts +14 -244
- package/src/vaadin-combo-box.js +4 -414
- package/theme/lumo/vaadin-combo-box-light.js +1 -3
- package/theme/lumo/vaadin-combo-box.js +1 -4
- package/theme/material/vaadin-combo-box-light.js +1 -3
- package/theme/material/vaadin-combo-box.js +1 -4
- package/vaadin-combo-box.d.ts +0 -1
- package/src/interfaces.d.ts +0 -71
- package/src/vaadin-combo-box-data-provider-mixin.d.ts +0 -44
- package/src/vaadin-combo-box-data-provider-mixin.js +0 -323
- package/src/vaadin-combo-box-dropdown-wrapper.js +0 -498
- package/src/vaadin-combo-box-dropdown.js +0 -289
- package/src/vaadin-combo-box-item.js +0 -170
- package/src/vaadin-combo-box-mixin.d.ts +0 -209
- package/src/vaadin-combo-box-mixin.js +0 -1127
- package/src/vaadin-combo-box-placeholder.js +0 -16
- package/theme/lumo/vaadin-combo-box-dropdown-styles.js +0 -87
- package/theme/lumo/vaadin-combo-box-item-styles.js +0 -47
- package/theme/lumo/vaadin-combo-box-styles.js +0 -18
- package/theme/material/vaadin-combo-box-dropdown-styles.js +0 -124
- package/theme/material/vaadin-combo-box-item-styles.js +0 -35
- package/theme/material/vaadin-combo-box-styles.js +0 -25
package/package.json
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/vaadin-combo-box",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.0-alpha10",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
4
7
|
"description": "Web Component for displaying a list of items with filtering",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/vaadin/web-components.git",
|
|
12
|
+
"directory": "packages/vaadin-combo-box"
|
|
13
|
+
},
|
|
14
|
+
"author": "Vaadin Ltd",
|
|
15
|
+
"homepage": "https://vaadin.com/components",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/vaadin/vaadin-combo-box/issues"
|
|
18
|
+
},
|
|
5
19
|
"main": "vaadin-combo-box.js",
|
|
6
|
-
"
|
|
20
|
+
"files": [
|
|
21
|
+
"src",
|
|
22
|
+
"theme",
|
|
23
|
+
"vaadin-*.d.ts",
|
|
24
|
+
"vaadin-*.js"
|
|
25
|
+
],
|
|
7
26
|
"keywords": [
|
|
8
27
|
"Vaadin",
|
|
9
28
|
"combo-box",
|
|
@@ -11,44 +30,8 @@
|
|
|
11
30
|
"web-component",
|
|
12
31
|
"polymer"
|
|
13
32
|
],
|
|
14
|
-
"author": "Vaadin Ltd",
|
|
15
|
-
"license": "Apache-2.0",
|
|
16
|
-
"bugs": {
|
|
17
|
-
"url": "https://github.com/vaadin/vaadin-combo-box/issues"
|
|
18
|
-
},
|
|
19
|
-
"homepage": "https://vaadin.com/components",
|
|
20
|
-
"files": [
|
|
21
|
-
"vaadin-*.d.ts",
|
|
22
|
-
"vaadin-*.js",
|
|
23
|
-
"src",
|
|
24
|
-
"theme"
|
|
25
|
-
],
|
|
26
33
|
"dependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@polymer/iron-list": "^3.0.0",
|
|
29
|
-
"@polymer/iron-resizable-behavior": "^3.0.0",
|
|
30
|
-
"@polymer/polymer": "^3.0.0",
|
|
31
|
-
"@vaadin/vaadin-control-state-mixin": "^21.0.1",
|
|
32
|
-
"@vaadin/vaadin-element-mixin": "^21.0.1",
|
|
33
|
-
"@vaadin/vaadin-item": "^21.0.1",
|
|
34
|
-
"@vaadin/vaadin-lumo-styles": "^21.0.1",
|
|
35
|
-
"@vaadin/vaadin-material-styles": "^21.0.1",
|
|
36
|
-
"@vaadin/vaadin-overlay": "^21.0.1",
|
|
37
|
-
"@vaadin/vaadin-text-field": "^21.0.1",
|
|
38
|
-
"@vaadin/vaadin-themable-mixin": "^21.0.1"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@esm-bundle/chai": "4.3.0",
|
|
42
|
-
"@polymer/iron-input": "^3.0.1",
|
|
43
|
-
"@polymer/paper-input": "^3.0.0",
|
|
44
|
-
"@vaadin/testing-helpers": "^0.2.1",
|
|
45
|
-
"@vaadin/vaadin-dialog": "^21.0.1",
|
|
46
|
-
"@vaadin/vaadin-template-renderer": "^21.0.1",
|
|
47
|
-
"lit": "^2.0.0-rc.1",
|
|
48
|
-
"sinon": "^9.2.0"
|
|
49
|
-
},
|
|
50
|
-
"publishConfig": {
|
|
51
|
-
"access": "public"
|
|
34
|
+
"@vaadin/combo-box": "22.0.0-alpha10"
|
|
52
35
|
},
|
|
53
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "6d3055383b9c3c8306ea34c6f2e2087e63c49348"
|
|
54
37
|
}
|
|
@@ -1,100 +1,19 @@
|
|
|
1
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin';
|
|
2
|
-
|
|
3
|
-
import { ComboBoxMixin } from './vaadin-combo-box-mixin';
|
|
4
|
-
|
|
5
|
-
import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin';
|
|
6
|
-
|
|
7
|
-
import { ComboBoxDefaultItem, ComboBoxEventMap } from './interfaces';
|
|
8
|
-
|
|
9
1
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* The element has the same API as `<vaadin-combo-box>`.
|
|
14
|
-
*
|
|
15
|
-
* To create a custom input field, you need to add a child element which has a two-way
|
|
16
|
-
* data-bindable property representing the input value. The property name is expected
|
|
17
|
-
* to be `value` by default. See the example below for a simplest possible example
|
|
18
|
-
* using a `<vaadin-text-field>` element.
|
|
19
|
-
*
|
|
20
|
-
* ```html
|
|
21
|
-
* <vaadin-combo-box-light>
|
|
22
|
-
* <vaadin-text-field>
|
|
23
|
-
* </vaadin-text-field>
|
|
24
|
-
* </vaadin-combo-box-light>
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* If you are using other custom input fields like `<iron-input>`, you
|
|
28
|
-
* need to define the name of the bindable property with the `attrForValue` attribute.
|
|
29
|
-
*
|
|
30
|
-
* ```html
|
|
31
|
-
* <vaadin-combo-box-light attr-for-value="bind-value">
|
|
32
|
-
* <iron-input>
|
|
33
|
-
* <input>
|
|
34
|
-
* </iron-input>
|
|
35
|
-
* </vaadin-combo-box-light>
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* In the next example you can see how to create a custom input field based
|
|
39
|
-
* on a `<paper-input>` decorated with a custom `<iron-icon>` and
|
|
40
|
-
* two `<paper-button>`s to act as the clear and toggle controls.
|
|
41
|
-
*
|
|
42
|
-
* ```html
|
|
43
|
-
* <vaadin-combo-box-light>
|
|
44
|
-
* <paper-input label="Elements" class="input">
|
|
45
|
-
* <iron-icon icon="toll" slot="prefix"></iron-icon>
|
|
46
|
-
* <paper-button slot="suffix" class="clear-button">Clear</paper-button>
|
|
47
|
-
* <paper-button slot="suffix" class="toggle-button">Toggle</paper-button>
|
|
48
|
-
* </paper-input>
|
|
49
|
-
* </vaadin-combo-box-light>
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* @fires {Event} change - Fired when the user commits a value change.
|
|
53
|
-
* @fires {CustomEvent} custom-value-set - Fired when the user sets a custom value.
|
|
54
|
-
* @fires {CustomEvent} filter-changed - Fired when the `filter` property changes.
|
|
55
|
-
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
56
|
-
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
57
|
-
* @fires {CustomEvent} selected-item-changed - Fired when the `selectedItem` property changes.
|
|
58
|
-
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
59
5
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
_inputElementValue: string;
|
|
64
|
-
|
|
65
|
-
readonly focused: boolean;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Name of the two-way data-bindable property representing the
|
|
69
|
-
* value of the custom input field.
|
|
70
|
-
* @attr {string} attr-for-value
|
|
71
|
-
*/
|
|
72
|
-
attrForValue: string;
|
|
6
|
+
import { ComboBoxDefaultItem } from '@vaadin/combo-box';
|
|
7
|
+
import { ComboBoxLight } from '@vaadin/combo-box/src/vaadin-combo-box-light.js';
|
|
73
8
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
listener: (this: ComboBoxLightElement<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
|
|
79
|
-
options?: boolean | AddEventListenerOptions
|
|
80
|
-
): void;
|
|
81
|
-
|
|
82
|
-
removeEventListener<K extends keyof ComboBoxEventMap<TItem>>(
|
|
83
|
-
type: K,
|
|
84
|
-
listener: (this: ComboBoxLightElement<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
|
|
85
|
-
options?: boolean | EventListenerOptions
|
|
86
|
-
): void;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
interface ComboBoxLightElement<TItem = ComboBoxDefaultItem>
|
|
90
|
-
extends ComboBoxDataProviderMixin<TItem>,
|
|
91
|
-
ComboBoxMixin<TItem>,
|
|
92
|
-
ThemableMixin {}
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Import `ComboBoxLight` from `@vaadin/combo-box/vaadin-combo-box-light` instead.
|
|
11
|
+
*/
|
|
12
|
+
export type ComboBoxLightElement<TItem = ComboBoxDefaultItem> = ComboBoxLight<TItem>;
|
|
93
13
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Import `ComboBoxLight` from `@vaadin/combo-box/vaadin-combo-box-light` instead.
|
|
16
|
+
*/
|
|
17
|
+
export const ComboBoxLightElement: typeof ComboBoxLight;
|
|
99
18
|
|
|
100
|
-
export
|
|
19
|
+
export * from '@vaadin/combo-box/src/vaadin-combo-box-light.js';
|
|
@@ -3,204 +3,11 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
|
|
8
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
|
-
import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
|
|
10
|
-
import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin.js';
|
|
11
|
-
import './vaadin-combo-box-dropdown-wrapper.js';
|
|
6
|
+
import { ComboBoxLight } from '@vaadin/combo-box/src/vaadin-combo-box-light.js';
|
|
12
7
|
|
|
13
8
|
/**
|
|
14
|
-
*
|
|
15
|
-
* only the dropdown functionality and leaving the input field definition to the user.
|
|
16
|
-
*
|
|
17
|
-
* The element has the same API as `<vaadin-combo-box>`.
|
|
18
|
-
*
|
|
19
|
-
* To create a custom input field, you need to add a child element which has a two-way
|
|
20
|
-
* data-bindable property representing the input value. The property name is expected
|
|
21
|
-
* to be `value` by default. See the example below for a simplest possible example
|
|
22
|
-
* using a `<vaadin-text-field>` element.
|
|
23
|
-
*
|
|
24
|
-
* ```html
|
|
25
|
-
* <vaadin-combo-box-light>
|
|
26
|
-
* <vaadin-text-field>
|
|
27
|
-
* </vaadin-text-field>
|
|
28
|
-
* </vaadin-combo-box-light>
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* If you are using other custom input fields like `<iron-input>`, you
|
|
32
|
-
* need to define the name of the bindable property with the `attrForValue` attribute.
|
|
33
|
-
*
|
|
34
|
-
* ```html
|
|
35
|
-
* <vaadin-combo-box-light attr-for-value="bind-value">
|
|
36
|
-
* <iron-input>
|
|
37
|
-
* <input>
|
|
38
|
-
* </iron-input>
|
|
39
|
-
* </vaadin-combo-box-light>
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* In the next example you can see how to create a custom input field based
|
|
43
|
-
* on a `<paper-input>` decorated with a custom `<iron-icon>` and
|
|
44
|
-
* two `<paper-button>`s to act as the clear and toggle controls.
|
|
45
|
-
*
|
|
46
|
-
* ```html
|
|
47
|
-
* <vaadin-combo-box-light>
|
|
48
|
-
* <paper-input label="Elements" class="input">
|
|
49
|
-
* <iron-icon icon="toll" slot="prefix"></iron-icon>
|
|
50
|
-
* <paper-button slot="suffix" class="clear-button">Clear</paper-button>
|
|
51
|
-
* <paper-button slot="suffix" class="toggle-button">Toggle</paper-button>
|
|
52
|
-
* </paper-input>
|
|
53
|
-
* </vaadin-combo-box-light>
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* @fires {Event} change - Fired when the user commits a value change.
|
|
57
|
-
* @fires {CustomEvent} custom-value-set - Fired when the user sets a custom value.
|
|
58
|
-
* @fires {CustomEvent} filter-changed - Fired when the `filter` property changes.
|
|
59
|
-
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
60
|
-
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
61
|
-
* @fires {CustomEvent} selected-item-changed - Fired when the `selectedItem` property changes.
|
|
62
|
-
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
63
|
-
*
|
|
64
|
-
* @extends HTMLElement
|
|
65
|
-
* @mixes ComboBoxDataProviderMixin
|
|
66
|
-
* @mixes ComboBoxMixin
|
|
67
|
-
* @mixes ThemableMixin
|
|
9
|
+
* @deprecated Import `ComboBoxLight` from `@vaadin/combo-box/vaadin-combo-box-light` instead.
|
|
68
10
|
*/
|
|
69
|
-
|
|
70
|
-
static get template() {
|
|
71
|
-
return html`
|
|
72
|
-
<style>
|
|
73
|
-
:host([opened]) {
|
|
74
|
-
pointer-events: auto;
|
|
75
|
-
}
|
|
76
|
-
</style>
|
|
11
|
+
export const ComboBoxLightElement = ComboBoxLight;
|
|
77
12
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<vaadin-combo-box-dropdown-wrapper
|
|
81
|
-
id="overlay"
|
|
82
|
-
opened="[[opened]]"
|
|
83
|
-
position-target="[[inputElement]]"
|
|
84
|
-
renderer="[[renderer]]"
|
|
85
|
-
_focused-index="[[_focusedIndex]]"
|
|
86
|
-
_item-id-path="[[itemIdPath]]"
|
|
87
|
-
_item-label-path="[[itemLabelPath]]"
|
|
88
|
-
loading="[[loading]]"
|
|
89
|
-
theme="[[theme]]"
|
|
90
|
-
></vaadin-combo-box-dropdown-wrapper>
|
|
91
|
-
`;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
static get is() {
|
|
95
|
-
return 'vaadin-combo-box-light';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
static get properties() {
|
|
99
|
-
return {
|
|
100
|
-
/**
|
|
101
|
-
* Name of the two-way data-bindable property representing the
|
|
102
|
-
* value of the custom input field.
|
|
103
|
-
* @attr {string} attr-for-value
|
|
104
|
-
* @type {string}
|
|
105
|
-
*/
|
|
106
|
-
attrForValue: {
|
|
107
|
-
type: String,
|
|
108
|
-
value: 'value'
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* @type {!Element | undefined}
|
|
113
|
-
*/
|
|
114
|
-
inputElement: {
|
|
115
|
-
type: Element,
|
|
116
|
-
readOnly: true
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
constructor() {
|
|
122
|
-
super();
|
|
123
|
-
this._boundInputValueChanged = this._inputValueChanged.bind(this);
|
|
124
|
-
this.__boundInputValueCommitted = this.__inputValueCommitted.bind(this);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** @protected */
|
|
128
|
-
ready() {
|
|
129
|
-
super.ready();
|
|
130
|
-
this._toggleElement = this.querySelector('.toggle-button');
|
|
131
|
-
this._clearElement = this.querySelector('.clear-button');
|
|
132
|
-
|
|
133
|
-
if (this._clearElement) {
|
|
134
|
-
this._clearElement.addEventListener('mousedown', (e) => {
|
|
135
|
-
e.preventDefault(); // Prevent native focus changes
|
|
136
|
-
// _focusableElement is needed for paper-input
|
|
137
|
-
(this.inputElement._focusableElement || this.inputElement).focus();
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* @return {boolean}
|
|
144
|
-
*/
|
|
145
|
-
get focused() {
|
|
146
|
-
return this.getRootNode().activeElement === this.inputElement;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/** @protected */
|
|
150
|
-
connectedCallback() {
|
|
151
|
-
super.connectedCallback();
|
|
152
|
-
const cssSelector = 'vaadin-text-field,iron-input,paper-input,.paper-input-input,.input';
|
|
153
|
-
this._setInputElement(this.querySelector(cssSelector));
|
|
154
|
-
this._revertInputValue();
|
|
155
|
-
this.inputElement.addEventListener('input', this._boundInputValueChanged);
|
|
156
|
-
this.inputElement.addEventListener('change', this.__boundInputValueCommitted);
|
|
157
|
-
this._preventInputBlur();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/** @protected */
|
|
161
|
-
disconnectedCallback() {
|
|
162
|
-
super.disconnectedCallback();
|
|
163
|
-
this.inputElement.removeEventListener('input', this._boundInputValueChanged);
|
|
164
|
-
this.inputElement.removeEventListener('change', this.__boundInputValueCommitted);
|
|
165
|
-
this._restoreInputBlur();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/** @private */
|
|
169
|
-
__inputValueCommitted(e) {
|
|
170
|
-
// Detect if the input was cleared (by clicking the clear button on a vaadin-text-field)
|
|
171
|
-
// and propagate the value change to combo box value immediately.
|
|
172
|
-
if (e.__fromClearButton) {
|
|
173
|
-
this._clear();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @return {string}
|
|
179
|
-
* @protected
|
|
180
|
-
*/
|
|
181
|
-
get _propertyForValue() {
|
|
182
|
-
return dashToCamelCase(this.attrForValue);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* @return {string}
|
|
187
|
-
* @protected
|
|
188
|
-
*/
|
|
189
|
-
get _inputElementValue() {
|
|
190
|
-
return this.inputElement && this.inputElement[this._propertyForValue];
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* @param {string} value
|
|
195
|
-
* @protected
|
|
196
|
-
*/
|
|
197
|
-
set _inputElementValue(value) {
|
|
198
|
-
if (this.inputElement) {
|
|
199
|
-
this.inputElement[this._propertyForValue] = value;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
customElements.define(ComboBoxLightElement.is, ComboBoxLightElement);
|
|
205
|
-
|
|
206
|
-
export { ComboBoxLightElement };
|
|
13
|
+
export * from '@vaadin/combo-box/src/vaadin-combo-box-light.js';
|
|
@@ -1,249 +1,19 @@
|
|
|
1
|
-
import { TextFieldElement } from '@vaadin/vaadin-text-field/vaadin-text-field';
|
|
2
|
-
|
|
3
|
-
import { ControlStateMixin } from '@vaadin/vaadin-control-state-mixin/vaadin-control-state-mixin';
|
|
4
|
-
|
|
5
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin';
|
|
6
|
-
|
|
7
|
-
import { ComboBoxMixin } from './vaadin-combo-box-mixin';
|
|
8
|
-
|
|
9
|
-
import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin';
|
|
10
|
-
|
|
11
|
-
import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin';
|
|
12
|
-
|
|
13
|
-
import { ComboBoxDefaultItem, ComboBoxEventMap } from './interfaces';
|
|
14
|
-
|
|
15
1
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* [`<vaadin-combo-box-light>`](#/elements/vaadin-combo-box-light) element.
|
|
20
|
-
*
|
|
21
|
-
* Items in the dropdown list must be provided as a list of `String` values.
|
|
22
|
-
* Defining the items is done using the `items` property, which can be assigned
|
|
23
|
-
* with data-binding, using an attribute or directly with the JavaScript property.
|
|
24
|
-
*
|
|
25
|
-
* ```html
|
|
26
|
-
* <vaadin-combo-box
|
|
27
|
-
* label="Fruit"
|
|
28
|
-
* items="[[data]]">
|
|
29
|
-
* </vaadin-combo-box>
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* ```js
|
|
33
|
-
* combobox.items = ['apple', 'orange', 'banana'];
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* When the selected `value` is changed, a `value-changed` event is triggered.
|
|
37
|
-
*
|
|
38
|
-
* ### Item rendering
|
|
39
|
-
*
|
|
40
|
-
* `<vaadin-combo-box>` supports using custom renderer callback function for defining the
|
|
41
|
-
* content of `<vaadin-combo-box-item>`.
|
|
42
|
-
*
|
|
43
|
-
* The renderer function provides `root`, `comboBox`, `model` arguments when applicable.
|
|
44
|
-
* Generate DOM content by using `model` object properties if needed, append it to the `root`
|
|
45
|
-
* element and control the state of the host element by accessing `comboBox`. Before generating new
|
|
46
|
-
* content, users are able to check if there is already content in `root` for reusing it.
|
|
47
|
-
*
|
|
48
|
-
* ```html
|
|
49
|
-
* <vaadin-combo-box id="combo-box"></vaadin-combo-box>
|
|
50
|
-
* ```
|
|
51
|
-
* ```js
|
|
52
|
-
* const comboBox = document.querySelector('#combo-box');
|
|
53
|
-
* comboBox.items = [{'label': 'Hydrogen', 'value': 'H'}];
|
|
54
|
-
* comboBox.renderer = function(root, comboBox, model) {
|
|
55
|
-
* root.innerHTML = model.index + ': ' +
|
|
56
|
-
* model.item.label + ' ' +
|
|
57
|
-
* '<b>' + model.item.value + '</b>';
|
|
58
|
-
* };
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* Renderer is called on the opening of the combo-box and each time the related model is updated.
|
|
62
|
-
* DOM generated during the renderer call can be reused
|
|
63
|
-
* in the next renderer call and will be provided with the `root` argument.
|
|
64
|
-
* On first call it will be empty.
|
|
65
|
-
*
|
|
66
|
-
* The following properties are available in the `model` argument:
|
|
67
|
-
*
|
|
68
|
-
* Property name | Type | Description
|
|
69
|
-
* --------------|------|------------
|
|
70
|
-
* `index`| Number | Index of the item in the `items` array
|
|
71
|
-
* `item` | String or Object | The item reference
|
|
72
|
-
* `selected` | Boolean | True when item is selected
|
|
73
|
-
* `focused` | Boolean | True when item is focused
|
|
74
|
-
*
|
|
75
|
-
* ### Lazy Loading with Function Data Provider
|
|
76
|
-
*
|
|
77
|
-
* In addition to assigning an array to the items property, you can alternatively
|
|
78
|
-
* provide the `<vaadin-combo-box>` data through the
|
|
79
|
-
* [`dataProvider`](#/elements/vaadin-combo-box#property-dataProvider) function property.
|
|
80
|
-
* The `<vaadin-combo-box>` calls this function lazily, only when it needs more data
|
|
81
|
-
* to be displayed.
|
|
82
|
-
*
|
|
83
|
-
* See the [`dataProvider`](#/elements/vaadin-combo-box#property-dataProvider) in
|
|
84
|
-
* the API reference below for the detailed data provider arguments description,
|
|
85
|
-
* and the “Lazy Loading“ example on “Basics” page in the demos.
|
|
86
|
-
*
|
|
87
|
-
* __Note that when using function data providers, the total number of items
|
|
88
|
-
* needs to be set manually. The total number of items can be returned
|
|
89
|
-
* in the second argument of the data provider callback:__
|
|
90
|
-
*
|
|
91
|
-
* ```javascript
|
|
92
|
-
* comboBox.dataProvider = function(params, callback) {
|
|
93
|
-
* var url = 'https://api.example/data' +
|
|
94
|
-
* '?page=' + params.page + // the requested page index
|
|
95
|
-
* '&per_page=' + params.pageSize; // number of items on the page
|
|
96
|
-
* var xhr = new XMLHttpRequest();
|
|
97
|
-
* xhr.onload = function() {
|
|
98
|
-
* var response = JSON.parse(xhr.responseText);
|
|
99
|
-
* callback(
|
|
100
|
-
* response.employees, // requested page of items
|
|
101
|
-
* response.totalSize // total number of items
|
|
102
|
-
* );
|
|
103
|
-
* };
|
|
104
|
-
* xhr.open('GET', url, true);
|
|
105
|
-
* xhr.send();
|
|
106
|
-
* };
|
|
107
|
-
* ```
|
|
108
|
-
*
|
|
109
|
-
* ### Styling
|
|
110
|
-
*
|
|
111
|
-
* The following custom properties are available for styling:
|
|
112
|
-
*
|
|
113
|
-
* Custom property | Description | Default
|
|
114
|
-
* ----------------|-------------|-------------
|
|
115
|
-
* `--vaadin-combo-box-overlay-max-height` | Property that determines the max height of overlay | `65vh`
|
|
116
|
-
*
|
|
117
|
-
* The following shadow DOM parts are available for styling:
|
|
118
|
-
*
|
|
119
|
-
* Part name | Description
|
|
120
|
-
* ----------------|----------------
|
|
121
|
-
* `text-field` | The text field
|
|
122
|
-
* `toggle-button` | The toggle button
|
|
123
|
-
*
|
|
124
|
-
* The following state attributes are available for styling:
|
|
125
|
-
*
|
|
126
|
-
* Attribute | Description | Part name
|
|
127
|
-
* -------------|-------------|------------
|
|
128
|
-
* `opened` | Set when the combo box dropdown is open | :host
|
|
129
|
-
* `disabled` | Set to a disabled combo box | :host
|
|
130
|
-
* `readonly` | Set to a read only combo box | :host
|
|
131
|
-
* `has-value` | Set when the element has a value | :host
|
|
132
|
-
* `invalid` | Set when the element is invalid | :host
|
|
133
|
-
* `focused` | Set when the element is focused | :host
|
|
134
|
-
* `focus-ring` | Set when the element is keyboard focused | :host
|
|
135
|
-
* `loading` | Set when new items are expected | :host
|
|
136
|
-
*
|
|
137
|
-
* ### Internal components
|
|
138
|
-
*
|
|
139
|
-
* In addition to `<vaadin-combo-box>` itself, the following internal
|
|
140
|
-
* components are themable:
|
|
141
|
-
*
|
|
142
|
-
* - `<vaadin-combo-box-overlay>` - has the same API as [`<vaadin-overlay>`](#/elements/vaadin-overlay).
|
|
143
|
-
* - [`<vaadin-text-field>`](#/elements/vaadin-text-field)
|
|
144
|
-
* - `<vaadin-combo-box-item>`
|
|
145
|
-
*
|
|
146
|
-
* Note: the `theme` attribute value set on `<vaadin-combo-box>` is
|
|
147
|
-
* propagated to the internal components listed above.
|
|
148
|
-
*
|
|
149
|
-
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
150
|
-
*
|
|
151
|
-
* @fires {Event} change - Fired when the user commits a value change.
|
|
152
|
-
* @fires {CustomEvent} custom-value-set - Fired when the user sets a custom value.
|
|
153
|
-
* @fires {CustomEvent} filter-changed - Fired when the `filter` property changes.
|
|
154
|
-
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
155
|
-
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
156
|
-
* @fires {CustomEvent} selected-item-changed - Fired when the `selectedItem` property changes.
|
|
157
|
-
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
158
5
|
*/
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
* Focusable element used by vaadin-control-state-mixin
|
|
162
|
-
*/
|
|
163
|
-
readonly focusElement: HTMLElement;
|
|
164
|
-
|
|
165
|
-
autofocus: boolean;
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Set to true to disable this input.
|
|
169
|
-
*/
|
|
170
|
-
disabled: boolean;
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Set to true to prevent the user from picking a value or typing in the input.
|
|
174
|
-
*/
|
|
175
|
-
readonly: boolean;
|
|
176
|
-
|
|
177
|
-
readonly inputElement: TextFieldElement | undefined;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* The label for this element.
|
|
181
|
-
*/
|
|
182
|
-
label: string | null | undefined;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Set to true to mark the input as required.
|
|
186
|
-
*/
|
|
187
|
-
required: boolean;
|
|
6
|
+
import { ComboBoxDefaultItem } from '@vaadin/combo-box';
|
|
7
|
+
import { ComboBox } from '@vaadin/combo-box/src/vaadin-combo-box.js';
|
|
188
8
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
preventInvalidInput: boolean | null | undefined;
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* A pattern to validate the `input` with.
|
|
197
|
-
*/
|
|
198
|
-
pattern: string | null | undefined;
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* The error message to display when the input is invalid.
|
|
202
|
-
* @attr {string} error-message
|
|
203
|
-
*/
|
|
204
|
-
errorMessage: string | null | undefined;
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* A placeholder string in addition to the label.
|
|
208
|
-
*/
|
|
209
|
-
placeholder: string;
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* String used for the helper text.
|
|
213
|
-
* @attr {string} helper-text
|
|
214
|
-
*/
|
|
215
|
-
helperText: string | null | undefined;
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Set to true to display the clear icon which clears the input.
|
|
219
|
-
* @attr {boolean} clear-button-visible
|
|
220
|
-
*/
|
|
221
|
-
clearButtonVisible: boolean;
|
|
222
|
-
|
|
223
|
-
addEventListener<K extends keyof ComboBoxEventMap<TItem>>(
|
|
224
|
-
type: K,
|
|
225
|
-
listener: (this: ComboBoxElement<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
|
|
226
|
-
options?: boolean | AddEventListenerOptions
|
|
227
|
-
): void;
|
|
228
|
-
|
|
229
|
-
removeEventListener<K extends keyof ComboBoxEventMap<TItem>>(
|
|
230
|
-
type: K,
|
|
231
|
-
listener: (this: ComboBoxElement<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
|
|
232
|
-
options?: boolean | EventListenerOptions
|
|
233
|
-
): void;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
interface ComboBoxElement<TItem = ComboBoxDefaultItem>
|
|
237
|
-
extends ElementMixin,
|
|
238
|
-
ControlStateMixin,
|
|
239
|
-
ComboBoxDataProviderMixin<TItem>,
|
|
240
|
-
ComboBoxMixin<TItem>,
|
|
241
|
-
ThemableMixin {}
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Import `ComboBox` from `@vaadin/combo-box` instead.
|
|
11
|
+
*/
|
|
12
|
+
export type ComboBoxElement<TItem = ComboBoxDefaultItem> = ComboBox<TItem>;
|
|
242
13
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Import `ComboBox` from `@vaadin/combo-box` instead.
|
|
16
|
+
*/
|
|
17
|
+
export const ComboBoxElement: typeof ComboBox;
|
|
248
18
|
|
|
249
|
-
export
|
|
19
|
+
export * from '@vaadin/combo-box/src/vaadin-combo-box.js';
|