@vaadin/combo-box 23.3.5 → 23.3.7
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/combo-box",
|
|
3
|
-
"version": "23.3.
|
|
3
|
+
"version": "23.3.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,21 +38,21 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
40
|
"@polymer/polymer": "^3.0.0",
|
|
41
|
-
"@vaadin/component-base": "~23.3.
|
|
42
|
-
"@vaadin/field-base": "~23.3.
|
|
43
|
-
"@vaadin/input-container": "~23.3.
|
|
44
|
-
"@vaadin/item": "~23.3.
|
|
45
|
-
"@vaadin/lit-renderer": "~23.3.
|
|
46
|
-
"@vaadin/overlay": "~23.3.
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "~23.3.
|
|
48
|
-
"@vaadin/vaadin-material-styles": "~23.3.
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "~23.3.
|
|
41
|
+
"@vaadin/component-base": "~23.3.7",
|
|
42
|
+
"@vaadin/field-base": "~23.3.7",
|
|
43
|
+
"@vaadin/input-container": "~23.3.7",
|
|
44
|
+
"@vaadin/item": "~23.3.7",
|
|
45
|
+
"@vaadin/lit-renderer": "~23.3.7",
|
|
46
|
+
"@vaadin/overlay": "~23.3.7",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "~23.3.7",
|
|
48
|
+
"@vaadin/vaadin-material-styles": "~23.3.7",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "~23.3.7"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@esm-bundle/chai": "^4.3.4",
|
|
53
|
-
"@vaadin/polymer-legacy-adapter": "~23.3.
|
|
53
|
+
"@vaadin/polymer-legacy-adapter": "~23.3.7",
|
|
54
54
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
55
|
-
"@vaadin/text-field": "~23.3.
|
|
55
|
+
"@vaadin/text-field": "~23.3.7",
|
|
56
56
|
"lit": "^2.0.0",
|
|
57
57
|
"sinon": "^13.0.2"
|
|
58
58
|
},
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"web-types.json",
|
|
61
61
|
"web-types.lit.json"
|
|
62
62
|
],
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "9689f8650a9170b38c0ee691b9603ffb550e04ad"
|
|
64
64
|
}
|
|
@@ -764,7 +764,11 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
764
764
|
// Do not commit value when custom values are disallowed and input value is not a valid option
|
|
765
765
|
// also stop propagation of the event, otherwise the user could submit a form while the input
|
|
766
766
|
// still contains an invalid value
|
|
767
|
-
|
|
767
|
+
const hasInvalidOption =
|
|
768
|
+
this._focusedIndex < 0 &&
|
|
769
|
+
this._inputElementValue !== '' &&
|
|
770
|
+
this._getItemLabel(this.selectedItem) !== this._inputElementValue;
|
|
771
|
+
if (!this.allowCustomValue && hasInvalidOption) {
|
|
768
772
|
// Do not submit the surrounding form.
|
|
769
773
|
e.preventDefault();
|
|
770
774
|
// Do not trigger global listeners
|
|
@@ -66,6 +66,7 @@ export class ComboBoxOverlay extends PositionMixin(Overlay) {
|
|
|
66
66
|
loader.setAttribute('part', 'loader');
|
|
67
67
|
const content = this.shadowRoot.querySelector('[part~="content"]');
|
|
68
68
|
content.parentNode.insertBefore(loader, content);
|
|
69
|
+
this.requiredVerticalSpace = 200;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
_outsideClickListener(event) {
|
|
@@ -216,18 +216,13 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
216
216
|
return itemIndex !== undefined ? 'option' : false;
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
/** @private */
|
|
220
|
-
__getAriaSelected(focusedIndex, itemIndex) {
|
|
221
|
-
return this.__isItemFocused(focusedIndex, itemIndex).toString();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
219
|
/** @private */
|
|
225
220
|
__isItemFocused(focusedIndex, itemIndex) {
|
|
226
221
|
return !this.loading && focusedIndex === itemIndex;
|
|
227
222
|
}
|
|
228
223
|
|
|
229
|
-
/** @
|
|
230
|
-
|
|
224
|
+
/** @protected */
|
|
225
|
+
_isItemSelected(item, selectedItem, itemIdPath) {
|
|
231
226
|
if (item instanceof ComboBoxPlaceholder) {
|
|
232
227
|
return false;
|
|
233
228
|
} else if (itemIdPath && item !== undefined && selectedItem !== undefined) {
|
|
@@ -291,19 +286,20 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
291
286
|
__updateElement(el, index) {
|
|
292
287
|
const item = this.items[index];
|
|
293
288
|
const focusedIndex = this.focusedIndex;
|
|
289
|
+
const selected = this._isItemSelected(item, this.selectedItem, this.itemIdPath);
|
|
294
290
|
|
|
295
291
|
el.setProperties({
|
|
296
292
|
item,
|
|
297
293
|
index,
|
|
298
294
|
label: this.getItemLabel(item),
|
|
299
|
-
selected
|
|
295
|
+
selected,
|
|
300
296
|
renderer: this.renderer,
|
|
301
297
|
focused: this.__isItemFocused(focusedIndex, index),
|
|
302
298
|
});
|
|
303
299
|
|
|
304
300
|
el.id = `${this.__hostTagName}-item-${index}`;
|
|
305
301
|
el.setAttribute('role', this.__getAriaRole(index));
|
|
306
|
-
el.setAttribute('aria-selected',
|
|
302
|
+
el.setAttribute('aria-selected', selected.toString());
|
|
307
303
|
el.setAttribute('aria-posinset', index + 1);
|
|
308
304
|
el.setAttribute('aria-setsize', this.items.length);
|
|
309
305
|
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/combo-box",
|
|
4
|
-
"version": "23.3.
|
|
4
|
+
"version": "23.3.7",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -394,7 +394,7 @@
|
|
|
394
394
|
},
|
|
395
395
|
{
|
|
396
396
|
"name": "vaadin-combo-box",
|
|
397
|
-
"description": "`<vaadin-combo-box>` is a web component for choosing a value from a filterable list of options\npresented in a dropdown overlay. The options can be provided as a list of strings or objects\nby setting [`items`](https://cdn.vaadin.com/vaadin-web-components/23.3.
|
|
397
|
+
"description": "`<vaadin-combo-box>` is a web component for choosing a value from a filterable list of options\npresented in a dropdown overlay. The options can be provided as a list of strings or objects\nby setting [`items`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-combo-box#property-items) property on the element.\n\n```html\n<vaadin-combo-box id=\"combo-box\"></vaadin-combo-box>\n```\n```js\ndocument.querySelector('#combo-box').items = ['apple', 'orange', 'banana'];\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Item rendering\n\nTo customize the content of the `<vaadin-combo-box-item>` elements placed in the dropdown, use\n[`renderer`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-combo-box#property-renderer) property which accepts a function.\nThe renderer function is called with `root`, `comboBox`, and `model` as arguments.\n\nGenerate DOM content by using `model` object properties if needed, and append it to the `root`\nelement. The `comboBox` reference is provided to access the combo-box element state. Do not\nset combo-box properties in a `renderer` function.\n\n```js\nconst comboBox = document.querySelector('#combo-box');\ncomboBox.items = [{'label': 'Hydrogen', 'value': 'H'}];\ncomboBox.renderer = (root, comboBox, model) => {\n const item = model.item;\n root.innerHTML = `${model.index}: ${item.label} <b>${item.value}</b>`;\n};\n```\n\nRenderer is called on the opening of the combo-box and each time the related model is updated.\nBefore creating new content, it is recommended to check if there is already an existing DOM\nelement in `root` from a previous renderer call for reusing it. Even though combo-box uses\ninfinite scrolling, reducing DOM operations might improve performance.\n\nThe following properties are available in the `model` argument:\n\nProperty | Type | Description\n-----------|------------------|-------------\n`index` | Number | Index of the item in the `items` array\n`item` | String or Object | The item reference\n`selected` | Boolean | True when item is selected\n`focused` | Boolean | True when item is focused\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively use the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-combo-box#property-dataProvider) function property.\nThe `<vaadin-combo-box>` calls this function lazily, only when it needs more data\nto be displayed.\n\n__Note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```js\ncomboBox.dataProvider = async (params, callback) => {\n const API = 'https://demo.vaadin.com/demo-data/1.0/filtered-countries';\n const { filter, page, pageSize } = params;\n const index = page * pageSize;\n\n const res = await fetch(`${API}?index=${index}&count=${pageSize}&filter=${filter}`);\n if (res.ok) {\n const { result, size } = await res.json();\n callback(result, size);\n }\n};\n```\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n----------------------------------------|----------------------------|---------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n`--vaadin-combo-box-overlay-width` | Width of the overlay | `auto`\n`--vaadin-combo-box-overlay-max-height` | Max height of the overlay | `65vh`\n\n`<vaadin-combo-box>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-text-field) for the styling documentation.\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------|----------------\n`toggle-button` | The toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n----------|-------------|------------\n`opened` | Set when the combo box dropdown is open | :host\n`loading` | Set when new items are expected | :host\n\nIf you want to replace the default `<input>` and its container with a custom implementation to get full control\nover the input field, consider using the [`<vaadin-combo-box-light>`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-combo-box-light) element.\n\n### Internal components\n\nIn addition to `<vaadin-combo-box>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-combo-box-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-overlay).\n- `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-item).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-input-container) - an internal element wrapping the input.\n\nNote: the `theme` attribute value set on `<vaadin-combo-box>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
398
398
|
"attributes": [
|
|
399
399
|
{
|
|
400
400
|
"name": "disabled",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/combo-box",
|
|
4
|
-
"version": "23.3.
|
|
4
|
+
"version": "23.3.7",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
},
|
|
227
227
|
{
|
|
228
228
|
"name": "vaadin-combo-box",
|
|
229
|
-
"description": "`<vaadin-combo-box>` is a web component for choosing a value from a filterable list of options\npresented in a dropdown overlay. The options can be provided as a list of strings or objects\nby setting [`items`](https://cdn.vaadin.com/vaadin-web-components/23.3.
|
|
229
|
+
"description": "`<vaadin-combo-box>` is a web component for choosing a value from a filterable list of options\npresented in a dropdown overlay. The options can be provided as a list of strings or objects\nby setting [`items`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-combo-box#property-items) property on the element.\n\n```html\n<vaadin-combo-box id=\"combo-box\"></vaadin-combo-box>\n```\n```js\ndocument.querySelector('#combo-box').items = ['apple', 'orange', 'banana'];\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Item rendering\n\nTo customize the content of the `<vaadin-combo-box-item>` elements placed in the dropdown, use\n[`renderer`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-combo-box#property-renderer) property which accepts a function.\nThe renderer function is called with `root`, `comboBox`, and `model` as arguments.\n\nGenerate DOM content by using `model` object properties if needed, and append it to the `root`\nelement. The `comboBox` reference is provided to access the combo-box element state. Do not\nset combo-box properties in a `renderer` function.\n\n```js\nconst comboBox = document.querySelector('#combo-box');\ncomboBox.items = [{'label': 'Hydrogen', 'value': 'H'}];\ncomboBox.renderer = (root, comboBox, model) => {\n const item = model.item;\n root.innerHTML = `${model.index}: ${item.label} <b>${item.value}</b>`;\n};\n```\n\nRenderer is called on the opening of the combo-box and each time the related model is updated.\nBefore creating new content, it is recommended to check if there is already an existing DOM\nelement in `root` from a previous renderer call for reusing it. Even though combo-box uses\ninfinite scrolling, reducing DOM operations might improve performance.\n\nThe following properties are available in the `model` argument:\n\nProperty | Type | Description\n-----------|------------------|-------------\n`index` | Number | Index of the item in the `items` array\n`item` | String or Object | The item reference\n`selected` | Boolean | True when item is selected\n`focused` | Boolean | True when item is focused\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively use the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-combo-box#property-dataProvider) function property.\nThe `<vaadin-combo-box>` calls this function lazily, only when it needs more data\nto be displayed.\n\n__Note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```js\ncomboBox.dataProvider = async (params, callback) => {\n const API = 'https://demo.vaadin.com/demo-data/1.0/filtered-countries';\n const { filter, page, pageSize } = params;\n const index = page * pageSize;\n\n const res = await fetch(`${API}?index=${index}&count=${pageSize}&filter=${filter}`);\n if (res.ok) {\n const { result, size } = await res.json();\n callback(result, size);\n }\n};\n```\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n----------------------------------------|----------------------------|---------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n`--vaadin-combo-box-overlay-width` | Width of the overlay | `auto`\n`--vaadin-combo-box-overlay-max-height` | Max height of the overlay | `65vh`\n\n`<vaadin-combo-box>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-text-field) for the styling documentation.\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------|----------------\n`toggle-button` | The toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n----------|-------------|------------\n`opened` | Set when the combo box dropdown is open | :host\n`loading` | Set when new items are expected | :host\n\nIf you want to replace the default `<input>` and its container with a custom implementation to get full control\nover the input field, consider using the [`<vaadin-combo-box-light>`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-combo-box-light) element.\n\n### Internal components\n\nIn addition to `<vaadin-combo-box>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-combo-box-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-overlay).\n- `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-item).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/23.3.7/#/elements/vaadin-input-container) - an internal element wrapping the input.\n\nNote: the `theme` attribute value set on `<vaadin-combo-box>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
230
230
|
"extension": true,
|
|
231
231
|
"attributes": [
|
|
232
232
|
{
|