@vaadin/multi-select-combo-box 24.4.0-dev.223e39f050 → 24.4.0-dev.4b20a0c55

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/multi-select-combo-box",
3
- "version": "24.4.0-dev.223e39f050",
3
+ "version": "24.4.0-dev.4b20a0c55",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,17 +38,17 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@polymer/polymer": "^3.0.0",
41
- "@vaadin/a11y-base": "24.4.0-dev.223e39f050",
42
- "@vaadin/combo-box": "24.4.0-dev.223e39f050",
43
- "@vaadin/component-base": "24.4.0-dev.223e39f050",
44
- "@vaadin/field-base": "24.4.0-dev.223e39f050",
45
- "@vaadin/input-container": "24.4.0-dev.223e39f050",
46
- "@vaadin/item": "24.4.0-dev.223e39f050",
47
- "@vaadin/lit-renderer": "24.4.0-dev.223e39f050",
48
- "@vaadin/overlay": "24.4.0-dev.223e39f050",
49
- "@vaadin/vaadin-lumo-styles": "24.4.0-dev.223e39f050",
50
- "@vaadin/vaadin-material-styles": "24.4.0-dev.223e39f050",
51
- "@vaadin/vaadin-themable-mixin": "24.4.0-dev.223e39f050"
41
+ "@vaadin/a11y-base": "24.4.0-dev.4b20a0c55",
42
+ "@vaadin/combo-box": "24.4.0-dev.4b20a0c55",
43
+ "@vaadin/component-base": "24.4.0-dev.4b20a0c55",
44
+ "@vaadin/field-base": "24.4.0-dev.4b20a0c55",
45
+ "@vaadin/input-container": "24.4.0-dev.4b20a0c55",
46
+ "@vaadin/item": "24.4.0-dev.4b20a0c55",
47
+ "@vaadin/lit-renderer": "24.4.0-dev.4b20a0c55",
48
+ "@vaadin/overlay": "24.4.0-dev.4b20a0c55",
49
+ "@vaadin/vaadin-lumo-styles": "24.4.0-dev.4b20a0c55",
50
+ "@vaadin/vaadin-material-styles": "24.4.0-dev.4b20a0c55",
51
+ "@vaadin/vaadin-themable-mixin": "24.4.0-dev.4b20a0c55"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@esm-bundle/chai": "^4.3.4",
@@ -60,5 +60,5 @@
60
60
  "web-types.json",
61
61
  "web-types.lit.json"
62
62
  ],
63
- "gitHead": "5e2e3bfc811c95aed9354235fab93fdbf43eb354"
63
+ "gitHead": "b79c81e5f6fd24684b34ee0dc434e94d943ea13e"
64
64
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 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 { DirectiveResult } from 'lit/directive.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 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 { directive } from 'lit/directive.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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 { defineCustomElement } from '@vaadin/component-base/src/define.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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-multi-select-combo-box-item.js';
@@ -60,6 +60,14 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
60
60
  notify: true,
61
61
  },
62
62
 
63
+ /**
64
+ * When true, filter string isn't cleared after selecting an item.
65
+ */
66
+ keepFilter: {
67
+ type: Boolean,
68
+ value: false,
69
+ },
70
+
63
71
  /**
64
72
  * When set to `true`, "loading" attribute is set
65
73
  * on the host and the overlay element.
@@ -236,7 +244,7 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
236
244
 
237
245
  if (this.readonly) {
238
246
  this.close();
239
- } else {
247
+ } else if (this._hasValidInputValue()) {
240
248
  // Keep selected item focused after committing on Enter.
241
249
  const focusedItem = this._dropdownItems[this._focusedIndex];
242
250
  this._commitValue();
@@ -268,6 +276,30 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
268
276
  super._onEscape(event);
269
277
  }
270
278
 
279
+ /**
280
+ * Override from combo-box to ignore requests to clear the filter if the
281
+ * keepFilter option is enabled. Exceptions are when the dropdown is closed,
282
+ * so the filter is still cleared on cancel and focus out.
283
+ * @protected
284
+ * @override
285
+ */
286
+ _clearFilter() {
287
+ if (!this.keepFilter || !this.opened) {
288
+ super._clearFilter();
289
+ }
290
+ }
291
+
292
+ /**
293
+ * Override method from combo-box to always clear the filter when reverting
294
+ * the input value, regardless of the keepFilter option.
295
+ * @override
296
+ * @protected
297
+ */
298
+ _revertInputValueToValue() {
299
+ super._revertInputValueToValue();
300
+ this.filter = '';
301
+ }
302
+
271
303
  /**
272
304
  * @protected
273
305
  * @override
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2018 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2018 - 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 { ComboBoxDefaultItem, ComboBoxItemMixinClass } from '@vaadin/combo-box/src/vaadin-combo-box-item-mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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 { ComboBoxOverlayMixin } from '@vaadin/combo-box/src/vaadin-combo-box-overlay-mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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/src/vaadin-combo-box-scroller-mixin.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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';
@@ -274,6 +274,12 @@ declare class MultiSelectComboBox<TItem = ComboBoxDefaultItem> extends HTMLEleme
274
274
  */
275
275
  i18n: MultiSelectComboBoxI18n;
276
276
 
277
+ /**
278
+ * When true, filter string isn't cleared after selecting an item.
279
+ * @attr {boolean} keep-filter
280
+ */
281
+ keepFilter: boolean;
282
+
277
283
  /**
278
284
  * True when loading items from the data provider, false otherwise.
279
285
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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-multi-select-combo-box-chip.js';
@@ -183,6 +183,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
183
183
  top-group="[[_topGroup]]"
184
184
  opened="{{opened}}"
185
185
  renderer="[[renderer]]"
186
+ keep-filter="[[keepFilter]]"
186
187
  theme$="[[_theme]]"
187
188
  on-combo-box-item-selected="_onComboBoxItemSelected"
188
189
  on-change="_onComboBoxChange"
@@ -342,6 +343,14 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
342
343
  },
343
344
  },
344
345
 
346
+ /**
347
+ * When true, filter string isn't cleared after selecting an item.
348
+ */
349
+ keepFilter: {
350
+ type: Boolean,
351
+ value: false,
352
+ },
353
+
345
354
  /**
346
355
  * True when loading items from the data provider, false otherwise.
347
356
  */
@@ -824,10 +833,27 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
824
833
  return selectedItems.indexOf(item);
825
834
  }
826
835
 
827
- /** @private */
828
- __clearFilter() {
829
- this.filter = '';
830
- this.$.comboBox.clear();
836
+ /**
837
+ * Clear the internal combo box value and filter. Filter will not be cleared
838
+ * when the `keepFilter` option is enabled. Using `force` can enforce clearing
839
+ * the filter.
840
+ * @param {boolean} force overrides the keepFilter option
841
+ * @private
842
+ */
843
+ __clearInternalValue(force = false) {
844
+ if (!this.keepFilter || force) {
845
+ // Clear both combo box value and filter.
846
+ this.filter = '';
847
+ this.$.comboBox.clear();
848
+ } else {
849
+ // Only clear combo box value. This effectively resets _lastCommittedValue
850
+ // which allows toggling the same item multiple times via keyboard.
851
+ this.$.comboBox.clear();
852
+ // Restore input to the filter value. Needed when items are
853
+ // navigated with keyboard, which overrides the input value
854
+ // with the item label.
855
+ this._inputElementValue = this.filter;
856
+ }
831
857
  }
832
858
 
833
859
  /** @private */
@@ -859,7 +885,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
859
885
  const lastFilter = this._lastFilter;
860
886
  // Do not unselect when manually typing and committing an already selected item.
861
887
  if (lastFilter && lastFilter.toLowerCase() === itemLabel.toLowerCase()) {
862
- this.__clearFilter();
888
+ this.__clearInternalValue();
863
889
  return;
864
890
  }
865
891
 
@@ -872,7 +898,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
872
898
  this.__updateSelection(itemsCopy);
873
899
 
874
900
  // Suppress `value-changed` event.
875
- this.__clearFilter();
901
+ this.__clearInternalValue();
876
902
 
877
903
  this.__announceItem(itemLabel, isSelected, itemsCopy.length);
878
904
  }
@@ -1041,6 +1067,9 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
1041
1067
  _onClearButtonTouchend(event) {
1042
1068
  // Cancel the following click and focus events
1043
1069
  event.preventDefault();
1070
+ // Prevent default combo box behavior which can otherwise unnecessarily
1071
+ // clear the input and filter
1072
+ event.stopPropagation();
1044
1073
 
1045
1074
  this.clear();
1046
1075
  }
@@ -1232,7 +1261,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
1232
1261
  // Stop the original event
1233
1262
  event.stopPropagation();
1234
1263
 
1235
- this.__clearFilter();
1264
+ this.__clearInternalValue(true);
1236
1265
 
1237
1266
  this.dispatchEvent(
1238
1267
  new CustomEvent('custom-value-set', {
@@ -1254,6 +1283,12 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
1254
1283
  // and keep the overlay opened when clicking a chip.
1255
1284
  event.preventDefault();
1256
1285
  }
1286
+
1287
+ /**
1288
+ * Fired when the user sets a custom value.
1289
+ * @event custom-value-set
1290
+ * @param {string} detail the custom value
1291
+ */
1257
1292
  }
1258
1293
 
1259
1294
  defineCustomElement(MultiSelectComboBox);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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/vaadin-lumo-styles/color.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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/theme/lumo/vaadin-input-container-styles.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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-multi-select-combo-box-chip-styles.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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/vaadin-material-styles/color.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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/theme/material/vaadin-input-container-styles.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2023 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 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-multi-select-combo-box-chip-styles.js';