@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/src/vaadin-combo-box.js
CHANGED
|
@@ -3,421 +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 { ControlStateMixin } from '@vaadin/vaadin-control-state-mixin/vaadin-control-state-mixin.js';
|
|
8
|
-
import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
|
|
9
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
|
-
import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
|
|
11
|
-
import '@vaadin/vaadin-text-field/src/vaadin-text-field.js';
|
|
12
|
-
import './vaadin-combo-box-dropdown-wrapper.js';
|
|
13
|
-
import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin.js';
|
|
6
|
+
import { ComboBox } from '@vaadin/combo-box/src/vaadin-combo-box.js';
|
|
14
7
|
|
|
15
8
|
/**
|
|
16
|
-
*
|
|
17
|
-
* input field for filtering the list of items. If you want to replace the default
|
|
18
|
-
* input field with a custom implementation, you should use the
|
|
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.
|
|
158
|
-
*
|
|
159
|
-
* @extends HTMLElement
|
|
160
|
-
* @mixes ElementMixin
|
|
161
|
-
* @mixes ControlStateMixin
|
|
162
|
-
* @mixes ComboBoxDataProviderMixin
|
|
163
|
-
* @mixes ComboBoxMixin
|
|
164
|
-
* @mixes ThemableMixin
|
|
9
|
+
* @deprecated Import `ComboBox` from `@vaadin/combo-box` instead.
|
|
165
10
|
*/
|
|
166
|
-
|
|
167
|
-
ControlStateMixin(ThemableMixin(ComboBoxDataProviderMixin(ComboBoxMixin(PolymerElement))))
|
|
168
|
-
) {
|
|
169
|
-
static get template() {
|
|
170
|
-
return html`
|
|
171
|
-
<style>
|
|
172
|
-
:host {
|
|
173
|
-
display: inline-block;
|
|
174
|
-
}
|
|
11
|
+
export const ComboBoxElement = ComboBox;
|
|
175
12
|
|
|
176
|
-
|
|
177
|
-
display: none !important;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
:host([opened]) {
|
|
181
|
-
pointer-events: auto;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
[part='text-field'] {
|
|
185
|
-
width: 100%;
|
|
186
|
-
min-width: 0;
|
|
187
|
-
}
|
|
188
|
-
</style>
|
|
189
|
-
|
|
190
|
-
<vaadin-text-field
|
|
191
|
-
part="text-field"
|
|
192
|
-
id="input"
|
|
193
|
-
pattern="[[pattern]]"
|
|
194
|
-
prevent-invalid-input="[[preventInvalidInput]]"
|
|
195
|
-
value="{{_inputElementValue}}"
|
|
196
|
-
autocomplete="off"
|
|
197
|
-
invalid="[[invalid]]"
|
|
198
|
-
label="[[label]]"
|
|
199
|
-
name="[[name]]"
|
|
200
|
-
placeholder="[[placeholder]]"
|
|
201
|
-
required="[[required]]"
|
|
202
|
-
disabled="[[disabled]]"
|
|
203
|
-
readonly="[[readonly]]"
|
|
204
|
-
helper-text="[[helperText]]"
|
|
205
|
-
error-message="[[errorMessage]]"
|
|
206
|
-
autocapitalize="none"
|
|
207
|
-
autofocus="[[autofocus]]"
|
|
208
|
-
on-change="_stopPropagation"
|
|
209
|
-
on-input="_inputValueChanged"
|
|
210
|
-
clear-button-visible="[[clearButtonVisible]]"
|
|
211
|
-
theme$="[[theme]]"
|
|
212
|
-
>
|
|
213
|
-
<slot name="prefix" slot="prefix"></slot>
|
|
214
|
-
<slot name="helper" slot="helper">[[helperText]]</slot>
|
|
215
|
-
|
|
216
|
-
<div part="toggle-button" id="toggleButton" slot="suffix" role="button" aria-label="Toggle"></div>
|
|
217
|
-
</vaadin-text-field>
|
|
218
|
-
|
|
219
|
-
<vaadin-combo-box-dropdown-wrapper
|
|
220
|
-
id="overlay"
|
|
221
|
-
opened="[[opened]]"
|
|
222
|
-
renderer="[[renderer]]"
|
|
223
|
-
position-target="[[_getPositionTarget()]]"
|
|
224
|
-
_focused-index="[[_focusedIndex]]"
|
|
225
|
-
_item-id-path="[[itemIdPath]]"
|
|
226
|
-
_item-label-path="[[itemLabelPath]]"
|
|
227
|
-
loading="[[loading]]"
|
|
228
|
-
theme="[[theme]]"
|
|
229
|
-
></vaadin-combo-box-dropdown-wrapper>
|
|
230
|
-
`;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
constructor() {
|
|
234
|
-
super();
|
|
235
|
-
/**
|
|
236
|
-
* @property
|
|
237
|
-
*/
|
|
238
|
-
this.theme;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
static get is() {
|
|
242
|
-
return 'vaadin-combo-box';
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
static get version() {
|
|
246
|
-
return '21.0.1';
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
static get properties() {
|
|
250
|
-
return {
|
|
251
|
-
/**
|
|
252
|
-
* The label for this element.
|
|
253
|
-
*/
|
|
254
|
-
label: {
|
|
255
|
-
type: String,
|
|
256
|
-
reflectToAttribute: true
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Set to true to mark the input as required.
|
|
261
|
-
* @type {boolean}
|
|
262
|
-
*/
|
|
263
|
-
required: {
|
|
264
|
-
type: Boolean,
|
|
265
|
-
value: false
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Set to true to disable this input.
|
|
270
|
-
* @type {boolean}
|
|
271
|
-
*/
|
|
272
|
-
disabled: {
|
|
273
|
-
type: Boolean,
|
|
274
|
-
value: false
|
|
275
|
-
},
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Set to true to prevent the user from entering invalid input.
|
|
279
|
-
* @attr {boolean} prevent-invalid-input
|
|
280
|
-
*/
|
|
281
|
-
preventInvalidInput: {
|
|
282
|
-
type: Boolean
|
|
283
|
-
},
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* A pattern to validate the `input` with.
|
|
287
|
-
*/
|
|
288
|
-
pattern: {
|
|
289
|
-
type: String
|
|
290
|
-
},
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* The error message to display when the input is invalid.
|
|
294
|
-
* @attr {string} error-message
|
|
295
|
-
*/
|
|
296
|
-
errorMessage: {
|
|
297
|
-
type: String
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
/** @type {boolean} */
|
|
301
|
-
autofocus: {
|
|
302
|
-
type: Boolean
|
|
303
|
-
},
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* A placeholder string in addition to the label.
|
|
307
|
-
* @type {string}
|
|
308
|
-
*/
|
|
309
|
-
placeholder: {
|
|
310
|
-
type: String,
|
|
311
|
-
value: ''
|
|
312
|
-
},
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* String used for the helper text.
|
|
316
|
-
* @attr {string} helper-text
|
|
317
|
-
*/
|
|
318
|
-
helperText: {
|
|
319
|
-
type: String,
|
|
320
|
-
value: ''
|
|
321
|
-
},
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Set to true to prevent the user from picking a value or typing in the input.
|
|
325
|
-
* @type {boolean}
|
|
326
|
-
*/
|
|
327
|
-
readonly: {
|
|
328
|
-
type: Boolean,
|
|
329
|
-
value: false,
|
|
330
|
-
reflectToAttribute: true
|
|
331
|
-
},
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Set to true to display the clear icon which clears the input.
|
|
335
|
-
* @attr {boolean} clear-button-visible
|
|
336
|
-
* @type {boolean}
|
|
337
|
-
*/
|
|
338
|
-
clearButtonVisible: {
|
|
339
|
-
type: Boolean,
|
|
340
|
-
value: false
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
static get observers() {
|
|
346
|
-
return ['_updateAriaExpanded(opened)'];
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/** @protected */
|
|
350
|
-
ready() {
|
|
351
|
-
super.ready();
|
|
352
|
-
|
|
353
|
-
this._nativeInput = this.inputElement.focusElement;
|
|
354
|
-
this._toggleElement = this.$.toggleButton;
|
|
355
|
-
this._clearElement = this.inputElement.shadowRoot.querySelector('[part="clear-button"]');
|
|
356
|
-
|
|
357
|
-
// Stop propagation of Esc in capturing phase so that
|
|
358
|
-
// vaadin-text-field will not handle Esc as a shortcut
|
|
359
|
-
// to clear the value.
|
|
360
|
-
// We need to set this listener for "this.inputElement"
|
|
361
|
-
// instead of just "this", otherwise keyboard navigation behaviour
|
|
362
|
-
// breaks a bit on Safari and some related tests fail.
|
|
363
|
-
this.inputElement.addEventListener(
|
|
364
|
-
'keydown',
|
|
365
|
-
(e) => {
|
|
366
|
-
if (e.keyCode === 27) {
|
|
367
|
-
this._stopPropagation(e);
|
|
368
|
-
// Trigger _onEscape method of vaadin-combo-box-mixin because
|
|
369
|
-
// bubbling phase is not reached.
|
|
370
|
-
this._onEscape(e);
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
true
|
|
374
|
-
);
|
|
375
|
-
|
|
376
|
-
this._nativeInput.setAttribute('role', 'combobox');
|
|
377
|
-
this._nativeInput.setAttribute('aria-autocomplete', 'list');
|
|
378
|
-
this._updateAriaExpanded();
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/** @protected */
|
|
382
|
-
connectedCallback() {
|
|
383
|
-
super.connectedCallback();
|
|
384
|
-
this._preventInputBlur();
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/** @protected */
|
|
388
|
-
disconnectedCallback() {
|
|
389
|
-
super.disconnectedCallback();
|
|
390
|
-
this._restoreInputBlur();
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/** @private */
|
|
394
|
-
_getPositionTarget() {
|
|
395
|
-
return this.$.input;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/** @private */
|
|
399
|
-
_updateAriaExpanded() {
|
|
400
|
-
if (this._nativeInput) {
|
|
401
|
-
this._nativeInput.setAttribute('aria-expanded', this.opened);
|
|
402
|
-
this._toggleElement.setAttribute('aria-expanded', this.opened);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/** @return {!TextFieldElement | undefined} */
|
|
407
|
-
get inputElement() {
|
|
408
|
-
return this.$.input;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Focusable element used by vaadin-control-state-mixin
|
|
413
|
-
* @return {!HTMLElement}
|
|
414
|
-
*/
|
|
415
|
-
get focusElement() {
|
|
416
|
-
// inputElement might not be defined on property changes before ready.
|
|
417
|
-
return this.inputElement || this;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
customElements.define(ComboBoxElement.is, ComboBoxElement);
|
|
422
|
-
|
|
423
|
-
export { ComboBoxElement };
|
|
13
|
+
export * from '@vaadin/combo-box/src/vaadin-combo-box.js';
|
package/vaadin-combo-box.d.ts
CHANGED
package/src/interfaces.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { ComboBoxElement } from './vaadin-combo-box';
|
|
2
|
-
|
|
3
|
-
export type ComboBoxDefaultItem = any;
|
|
4
|
-
|
|
5
|
-
export interface ComboBoxItemModel<TItem> {
|
|
6
|
-
index: number;
|
|
7
|
-
item: TItem;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type ComboBoxRenderer<TItem> = (
|
|
11
|
-
root: HTMLElement,
|
|
12
|
-
comboBox: ComboBoxElement<TItem>,
|
|
13
|
-
model: ComboBoxItemModel<TItem>
|
|
14
|
-
) => void;
|
|
15
|
-
|
|
16
|
-
export type ComboBoxDataProviderCallback<TItem> = (items: Array<TItem>, size: number) => void;
|
|
17
|
-
|
|
18
|
-
export interface ComboBoxDataProviderParams {
|
|
19
|
-
page: number;
|
|
20
|
-
pageSize: number;
|
|
21
|
-
filter: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type ComboBoxDataProvider<TItem> = (
|
|
25
|
-
params: ComboBoxDataProviderParams,
|
|
26
|
-
callback: ComboBoxDataProviderCallback<TItem>
|
|
27
|
-
) => void;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Fired when the user sets a custom value.
|
|
31
|
-
*/
|
|
32
|
-
export type ComboBoxCustomValueSetEvent = CustomEvent<string>;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Fired when the `opened` property changes.
|
|
36
|
-
*/
|
|
37
|
-
export type ComboBoxOpenedChangedEvent = CustomEvent<{ value: boolean }>;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Fired when the `invalid` property changes.
|
|
41
|
-
*/
|
|
42
|
-
export type ComboBoxInvalidChangedEvent = CustomEvent<{ value: boolean }>;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Fired when the `value` property changes.
|
|
46
|
-
*/
|
|
47
|
-
export type ComboBoxValueChangedEvent = CustomEvent<{ value: string }>;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Fired when the `filter` property changes.
|
|
51
|
-
*/
|
|
52
|
-
export type ComboBoxFilterChangedEvent = CustomEvent<{ value: string }>;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Fired when the `selectedItem` property changes.
|
|
56
|
-
*/
|
|
57
|
-
export type ComboBoxSelectedItemChangedEvent<TItem> = CustomEvent<{ value: TItem | null | undefined }>;
|
|
58
|
-
|
|
59
|
-
export interface ComboBoxEventMap<TItem> extends HTMLElementEventMap {
|
|
60
|
-
'custom-value-set': ComboBoxCustomValueSetEvent;
|
|
61
|
-
|
|
62
|
-
'opened-changed': ComboBoxOpenedChangedEvent;
|
|
63
|
-
|
|
64
|
-
'filter-changed': ComboBoxFilterChangedEvent;
|
|
65
|
-
|
|
66
|
-
'invalid-changed': ComboBoxInvalidChangedEvent;
|
|
67
|
-
|
|
68
|
-
'value-changed': ComboBoxValueChangedEvent;
|
|
69
|
-
|
|
70
|
-
'selected-item-changed': ComboBoxSelectedItemChangedEvent<TItem>;
|
|
71
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ComboBoxDataProvider } from './interfaces';
|
|
2
|
-
|
|
3
|
-
declare function ComboBoxDataProviderMixin<TItem, T extends new (...args: any[]) => {}>(
|
|
4
|
-
base: T
|
|
5
|
-
): T & ComboBoxDataProviderMixinConstructor<TItem>;
|
|
6
|
-
|
|
7
|
-
interface ComboBoxDataProviderMixinConstructor<TItem> {
|
|
8
|
-
new (...args: any[]): ComboBoxDataProviderMixin<TItem>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface ComboBoxDataProviderMixin<TItem> {
|
|
12
|
-
/**
|
|
13
|
-
* Number of items fetched at a time from the dataprovider.
|
|
14
|
-
* @attr {number} page-size
|
|
15
|
-
*/
|
|
16
|
-
pageSize: number;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Total number of items.
|
|
20
|
-
*/
|
|
21
|
-
size: number | undefined;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Function that provides items lazily. Receives arguments `params`, `callback`
|
|
25
|
-
*
|
|
26
|
-
* `params.page` Requested page index
|
|
27
|
-
*
|
|
28
|
-
* `params.pageSize` Current page size
|
|
29
|
-
*
|
|
30
|
-
* `params.filter` Currently applied filter
|
|
31
|
-
*
|
|
32
|
-
* `callback(items, size)` Callback function with arguments:
|
|
33
|
-
* - `items` Current page of items
|
|
34
|
-
* - `size` Total number of items.
|
|
35
|
-
*/
|
|
36
|
-
dataProvider: ComboBoxDataProvider<TItem> | null | undefined;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Clears the cached pages and reloads data from dataprovider when needed.
|
|
40
|
-
*/
|
|
41
|
-
clearCache(): void;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { ComboBoxDataProviderMixin, ComboBoxDataProviderMixinConstructor };
|