@vaadin/multi-select-combo-box 23.2.0-alpha2 → 23.2.0-alpha3

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": "23.2.0-alpha2",
3
+ "version": "23.2.0-alpha3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,19 +35,19 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@polymer/polymer": "^3.0.0",
38
- "@vaadin/combo-box": "23.2.0-alpha2",
39
- "@vaadin/component-base": "23.2.0-alpha2",
40
- "@vaadin/field-base": "23.2.0-alpha2",
41
- "@vaadin/input-container": "23.2.0-alpha2",
42
- "@vaadin/lit-renderer": "23.2.0-alpha2",
43
- "@vaadin/vaadin-lumo-styles": "23.2.0-alpha2",
44
- "@vaadin/vaadin-material-styles": "23.2.0-alpha2",
45
- "@vaadin/vaadin-themable-mixin": "23.2.0-alpha2"
38
+ "@vaadin/combo-box": "23.2.0-alpha3",
39
+ "@vaadin/component-base": "23.2.0-alpha3",
40
+ "@vaadin/field-base": "23.2.0-alpha3",
41
+ "@vaadin/input-container": "23.2.0-alpha3",
42
+ "@vaadin/lit-renderer": "23.2.0-alpha3",
43
+ "@vaadin/vaadin-lumo-styles": "23.2.0-alpha3",
44
+ "@vaadin/vaadin-material-styles": "23.2.0-alpha3",
45
+ "@vaadin/vaadin-themable-mixin": "23.2.0-alpha3"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@esm-bundle/chai": "^4.3.4",
49
49
  "@vaadin/testing-helpers": "^0.3.2",
50
50
  "sinon": "^13.0.2"
51
51
  },
52
- "gitHead": "c9b8113d0fa9a602f8b9cb915c1826355af2e8df"
52
+ "gitHead": "06e5875be93ca50da2846dafc65a8531010c0576"
53
53
  }
@@ -3,11 +3,11 @@
3
3
  * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { TemplateResult } from 'lit';
7
- import { DirectiveResult } from 'lit/directive.js';
8
- import { ComboBoxItemModel } from '@vaadin/combo-box/src/vaadin-combo-box.js';
6
+ import type { TemplateResult } from 'lit';
7
+ import type { DirectiveResult } from 'lit/directive.js';
8
+ import type { ComboBoxItemModel } from '@vaadin/combo-box/src/vaadin-combo-box.js';
9
9
  import { LitRendererDirective } from '@vaadin/lit-renderer';
10
- import { MultiSelectComboBox } from '../vaadin-multi-select-combo-box.js';
10
+ import type { MultiSelectComboBox } from '../vaadin-multi-select-combo-box.js';
11
11
 
12
12
  export type MultiSelectComboBoxLitRenderer<TItem> = (
13
13
  item: TItem,
@@ -87,6 +87,15 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
87
87
  value: () => [],
88
88
  },
89
89
 
90
+ /**
91
+ * Last input value entered by the user before value is updated.
92
+ * Used to store `filter` property value before clearing it.
93
+ */
94
+ lastFilter: {
95
+ type: String,
96
+ notify: true,
97
+ },
98
+
90
99
  _target: {
91
100
  type: Object,
92
101
  },
@@ -195,6 +204,18 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
195
204
  super._closeOrCommit();
196
205
  }
197
206
 
207
+ /**
208
+ * @protected
209
+ * @override
210
+ */
211
+ _commitValue() {
212
+ // Store filter value for checking if user input is matching
213
+ // an item which is already selected, to not un-select it.
214
+ this.lastFilter = this.filter;
215
+
216
+ super._commitValue();
217
+ }
218
+
198
219
  /**
199
220
  * Override method inherited from the combo-box
200
221
  * to not update focused item when readonly.
@@ -3,26 +3,26 @@
3
3
  * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import {
6
+ import type {
7
7
  ComboBoxDataProvider,
8
8
  ComboBoxDefaultItem,
9
9
  ComboBoxItemModel,
10
10
  } from '@vaadin/combo-box/src/vaadin-combo-box.js';
11
- import { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
12
- import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
13
- import { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
14
- import { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
15
- import { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
16
- import { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
17
- import { DelegateFocusMixinClass } from '@vaadin/field-base/src/delegate-focus-mixin.js';
18
- import { DelegateStateMixinClass } from '@vaadin/field-base/src/delegate-state-mixin.js';
19
- import { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
20
- import { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
21
- import { InputControlMixinClass } from '@vaadin/field-base/src/input-control-mixin.js';
22
- import { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
23
- import { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
24
- import { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
25
- import { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
+ import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
12
+ import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
13
+ import type { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
14
+ import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
15
+ import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
16
+ import type { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
17
+ import type { DelegateFocusMixinClass } from '@vaadin/field-base/src/delegate-focus-mixin.js';
18
+ import type { DelegateStateMixinClass } from '@vaadin/field-base/src/delegate-state-mixin.js';
19
+ import type { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
20
+ import type { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
21
+ import type { InputControlMixinClass } from '@vaadin/field-base/src/input-control-mixin.js';
22
+ import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
23
+ import type { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
24
+ import type { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
25
+ import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
26
26
 
27
27
  export type MultiSelectComboBoxRenderer<TItem> = (
28
28
  root: HTMLElement,
@@ -65,6 +65,11 @@ export type MultiSelectComboBoxInvalidChangedEvent = CustomEvent<{ value: boolea
65
65
  */
66
66
  export type MultiSelectComboBoxSelectedItemsChangedEvent<TItem> = CustomEvent<{ value: TItem[] }>;
67
67
 
68
+ /**
69
+ * Fired whenever the field is validated.
70
+ */
71
+ export type MultiSelectComboBoxValidatedEvent = CustomEvent<{ valid: boolean }>;
72
+
68
73
  export interface MultiSelectComboBoxEventMap<TItem> extends HTMLElementEventMap {
69
74
  change: MultiSelectComboBoxChangeEvent<TItem>;
70
75
 
@@ -75,6 +80,8 @@ export interface MultiSelectComboBoxEventMap<TItem> extends HTMLElementEventMap
75
80
  'invalid-changed': MultiSelectComboBoxInvalidChangedEvent;
76
81
 
77
82
  'selected-items-changed': MultiSelectComboBoxSelectedItemsChangedEvent<TItem>;
83
+
84
+ validated: MultiSelectComboBoxValidatedEvent;
78
85
  }
79
86
 
80
87
  /**
@@ -131,6 +138,7 @@ export interface MultiSelectComboBoxEventMap<TItem> extends HTMLElementEventMap
131
138
  * Custom property | Description | Default
132
139
  * -----------------------------------------------------|----------------------------|--------
133
140
  * `--vaadin-field-default-width` | Default width of the field | `12em`
141
+ * `--vaadin-multi-select-combo-box-overlay-width` | Width of the overlay | `auto`
134
142
  * `--vaadin-multi-select-combo-box-overlay-max-height` | Max height of the overlay | `65vh`
135
143
  * `--vaadin-multi-select-combo-box-input-min-width` | Min width of the input | `4em`
136
144
  *
@@ -153,6 +161,7 @@ export interface MultiSelectComboBoxEventMap<TItem> extends HTMLElementEventMap
153
161
  * @fires {CustomEvent} filter-changed - Fired when the `filter` property changes.
154
162
  * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
155
163
  * @fires {CustomEvent} selected-items-changed - Fired when the `selectedItems` property changes.
164
+ * @fires {CustomEvent} validated - Fired whenever the field is validated.
156
165
  */
157
166
  declare class MultiSelectComboBox<TItem = ComboBoxDefaultItem> extends HTMLElement {
158
167
  /**
@@ -109,6 +109,7 @@ registerStyles('vaadin-multi-select-combo-box', [inputFieldShared, multiSelectCo
109
109
  * Custom property | Description | Default
110
110
  * -----------------------------------------------------|----------------------------|--------
111
111
  * `--vaadin-field-default-width` | Default width of the field | `12em`
112
+ * `--vaadin-multi-select-combo-box-overlay-width` | Width of the overlay | `auto`
112
113
  * `--vaadin-multi-select-combo-box-overlay-max-height` | Max height of the overlay | `65vh`
113
114
  * `--vaadin-multi-select-combo-box-input-min-width` | Min width of the input | `4em`
114
115
  *
@@ -131,6 +132,7 @@ registerStyles('vaadin-multi-select-combo-box', [inputFieldShared, multiSelectCo
131
132
  * @fires {CustomEvent} filter-changed - Fired when the `filter` property changes.
132
133
  * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
133
134
  * @fires {CustomEvent} selected-items-changed - Fired when the `selectedItems` property changes.
135
+ * @fires {CustomEvent} validated - Fired whenever the field is validated.
134
136
  *
135
137
  * @extends HTMLElement
136
138
  * @mixes ElementMixin
@@ -163,6 +165,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
163
165
  allow-custom-value="[[allowCustomValue]]"
164
166
  data-provider="[[dataProvider]]"
165
167
  filter="{{filter}}"
168
+ last-filter="{{_lastFilter}}"
166
169
  loading="{{loading}}"
167
170
  size="{{size}}"
168
171
  filtered-items="[[__effectiveFilteredItems]]"
@@ -453,6 +456,11 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
453
456
  value: -1,
454
457
  observer: '_focusedChipIndexChanged',
455
458
  },
459
+
460
+ /** @private */
461
+ _lastFilter: {
462
+ type: String,
463
+ },
456
464
  };
457
465
  }
458
466
 
@@ -755,7 +763,8 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
755
763
  const itemsCopy = [...this.selectedItems];
756
764
  itemsCopy.splice(itemsCopy.indexOf(item), 1);
757
765
  this.__updateSelection(itemsCopy);
758
- this.__announceItem(item, false, itemsCopy.length);
766
+ const itemLabel = this._getItemLabel(item);
767
+ this.__announceItem(itemLabel, false, itemsCopy.length);
759
768
  }
760
769
 
761
770
  /** @private */
@@ -768,8 +777,9 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
768
777
  let isSelected = false;
769
778
 
770
779
  if (index !== -1) {
780
+ const lastFilter = this._lastFilter;
771
781
  // Do not unselect when manually typing and committing an already selected item.
772
- if (this.filter.toLowerCase() === itemLabel.toLowerCase()) {
782
+ if (lastFilter && lastFilter.toLowerCase() === itemLabel.toLowerCase()) {
773
783
  this.__clearFilter();
774
784
  return;
775
785
  }