@vaadin/multi-select-combo-box 25.3.0-beta1 → 25.3.0-beta3

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.
@@ -348,8 +348,12 @@
348
348
  "type": {
349
349
  "text": "string"
350
350
  },
351
- "description": "Path for the id of the item, used to detect whether the item is selected.",
352
- "attribute": "item-id-path"
351
+ "description": "Path for the id of the item. If `items` is an array of objects,\nthe `itemIdPath` is used to compare and identify the same item\nin the selection and in `filteredItems` (items given by the\n`dataProvider` callback).",
352
+ "attribute": "item-id-path",
353
+ "inheritedFrom": {
354
+ "name": "ComboBoxItemsMixin",
355
+ "package": "@vaadin/combo-box/src/vaadin-combo-box-items-mixin.js"
356
+ }
353
357
  },
354
358
  {
355
359
  "kind": "field",
@@ -561,7 +565,11 @@
561
565
  {
562
566
  "kind": "method",
563
567
  "name": "requestContentUpdate",
564
- "description": "Requests an update for the content of items.\nWhile performing the update, it invokes the renderer (passed in the `renderer` property) once an item.\n\nIt is not guaranteed that the update happens immediately (synchronously) after it is requested."
568
+ "description": "Requests an update for the content of items.\nWhile performing the update, it invokes the renderer (passed in the `renderer` property) once an item.\n\nIt is not guaranteed that the update happens immediately (synchronously) after it is requested.",
569
+ "inheritedFrom": {
570
+ "name": "ComboBoxItemsMixin",
571
+ "package": "@vaadin/combo-box/src/vaadin-combo-box-items-mixin.js"
572
+ }
565
573
  },
566
574
  {
567
575
  "kind": "field",
@@ -900,8 +908,12 @@
900
908
  "type": {
901
909
  "text": "string"
902
910
  },
903
- "description": "Path for the id of the item, used to detect whether the item is selected.",
904
- "fieldName": "itemIdPath"
911
+ "description": "Path for the id of the item. If `items` is an array of objects,\nthe `itemIdPath` is used to compare and identify the same item\nin the selection and in `filteredItems` (items given by the\n`dataProvider` callback).",
912
+ "fieldName": "itemIdPath",
913
+ "inheritedFrom": {
914
+ "name": "ComboBoxItemsMixin",
915
+ "package": "@vaadin/combo-box/src/vaadin-combo-box-items-mixin.js"
916
+ }
905
917
  },
906
918
  {
907
919
  "name": "item-label-path",
@@ -1507,11 +1519,11 @@
1507
1519
  "type": {
1508
1520
  "text": "string"
1509
1521
  },
1510
- "description": "Path for the id of the item, used to detect whether the item is selected.",
1522
+ "description": "Path for the id of the item. If `items` is an array of objects,\nthe `itemIdPath` is used to compare and identify the same item\nin the selection and in `filteredItems` (items given by the\n`dataProvider` callback).",
1511
1523
  "attribute": "item-id-path",
1512
1524
  "inheritedFrom": {
1513
- "name": "MultiSelectComboBoxMixin",
1514
- "module": "src/vaadin-multi-select-combo-box-mixin.js"
1525
+ "name": "ComboBoxItemsMixin",
1526
+ "package": "@vaadin/combo-box/src/vaadin-combo-box-items-mixin.js"
1515
1527
  }
1516
1528
  },
1517
1529
  {
@@ -1738,8 +1750,8 @@
1738
1750
  "name": "requestContentUpdate",
1739
1751
  "description": "Requests an update for the content of items.\nWhile performing the update, it invokes the renderer (passed in the `renderer` property) once an item.\n\nIt is not guaranteed that the update happens immediately (synchronously) after it is requested.",
1740
1752
  "inheritedFrom": {
1741
- "name": "MultiSelectComboBoxMixin",
1742
- "module": "src/vaadin-multi-select-combo-box-mixin.js"
1753
+ "name": "ComboBoxItemsMixin",
1754
+ "package": "@vaadin/combo-box/src/vaadin-combo-box-items-mixin.js"
1743
1755
  }
1744
1756
  },
1745
1757
  {
@@ -2120,11 +2132,11 @@
2120
2132
  "type": {
2121
2133
  "text": "string"
2122
2134
  },
2123
- "description": "Path for the id of the item, used to detect whether the item is selected.",
2135
+ "description": "Path for the id of the item. If `items` is an array of objects,\nthe `itemIdPath` is used to compare and identify the same item\nin the selection and in `filteredItems` (items given by the\n`dataProvider` callback).",
2124
2136
  "fieldName": "itemIdPath",
2125
2137
  "inheritedFrom": {
2126
- "name": "MultiSelectComboBoxMixin",
2127
- "module": "src/vaadin-multi-select-combo-box-mixin.js"
2138
+ "name": "ComboBoxItemsMixin",
2139
+ "package": "@vaadin/combo-box/src/vaadin-combo-box-items-mixin.js"
2128
2140
  }
2129
2141
  },
2130
2142
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/multi-select-combo-box",
3
- "version": "25.3.0-beta1",
3
+ "version": "25.3.0-beta3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,23 +37,23 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@open-wc/dedupe-mixin": "^1.3.0",
40
- "@vaadin/a11y-base": "25.3.0-beta1",
41
- "@vaadin/combo-box": "25.3.0-beta1",
42
- "@vaadin/component-base": "25.3.0-beta1",
43
- "@vaadin/field-base": "25.3.0-beta1",
44
- "@vaadin/input-container": "25.3.0-beta1",
45
- "@vaadin/item": "25.3.0-beta1",
46
- "@vaadin/lit-renderer": "25.3.0-beta1",
47
- "@vaadin/overlay": "25.3.0-beta1",
48
- "@vaadin/vaadin-themable-mixin": "25.3.0-beta1",
40
+ "@vaadin/a11y-base": "25.3.0-beta3",
41
+ "@vaadin/combo-box": "25.3.0-beta3",
42
+ "@vaadin/component-base": "25.3.0-beta3",
43
+ "@vaadin/field-base": "25.3.0-beta3",
44
+ "@vaadin/input-container": "25.3.0-beta3",
45
+ "@vaadin/item": "25.3.0-beta3",
46
+ "@vaadin/lit-renderer": "25.3.0-beta3",
47
+ "@vaadin/overlay": "25.3.0-beta3",
48
+ "@vaadin/vaadin-themable-mixin": "25.3.0-beta3",
49
49
  "lit": "^3.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@vaadin/aura": "25.3.0-beta1",
53
- "@vaadin/chai-plugins": "25.3.0-beta1",
54
- "@vaadin/test-runner-commands": "25.3.0-beta1",
52
+ "@vaadin/aura": "25.3.0-beta3",
53
+ "@vaadin/chai-plugins": "25.3.0-beta3",
54
+ "@vaadin/test-runner-commands": "25.3.0-beta3",
55
55
  "@vaadin/testing-helpers": "^2.0.0",
56
- "@vaadin/vaadin-lumo-styles": "25.3.0-beta1",
56
+ "@vaadin/vaadin-lumo-styles": "25.3.0-beta3",
57
57
  "sinon": "^22.0.0"
58
58
  },
59
59
  "customElements": "custom-elements.json",
@@ -61,5 +61,5 @@
61
61
  "web-types.json",
62
62
  "web-types.lit.json"
63
63
  ],
64
- "gitHead": "295432e44a6967e1aff36462b2e3e1d0e64eb8cc"
64
+ "gitHead": "1ea43188e1297f6898cbf9d3610b85a7a2cca6f0"
65
65
  }
@@ -100,12 +100,6 @@ export declare class MultiSelectComboBoxMixinClass<TItem> {
100
100
  */
101
101
  itemClassNameGenerator: (item: TItem) => string;
102
102
 
103
- /**
104
- * Path for the id of the item, used to detect whether the item is selected.
105
- * @attr {string} item-id-path
106
- */
107
- itemIdPath: string;
108
-
109
103
  /**
110
104
  * The object used to localize this component. To change the default
111
105
  * localization, replace this with an object that provides all properties, or
@@ -177,12 +171,4 @@ export declare class MultiSelectComboBoxMixinClass<TItem> {
177
171
  * Clears the selected items.
178
172
  */
179
173
  clear(): void;
180
-
181
- /**
182
- * Requests an update for the content of items.
183
- * While performing the update, it invokes the renderer (passed in the `renderer` property) once an item.
184
- *
185
- * It is not guaranteed that the update happens immediately (synchronously) after it is requested.
186
- */
187
- requestContentUpdate(): void;
188
174
  }
@@ -79,15 +79,6 @@ export const MultiSelectComboBoxMixin = (superClass) =>
79
79
  sync: true,
80
80
  },
81
81
 
82
- /**
83
- * Path for the id of the item, used to detect whether the item is selected.
84
- * @attr {string} item-id-path
85
- */
86
- itemIdPath: {
87
- type: String,
88
- sync: true,
89
- },
90
-
91
82
  /**
92
83
  * When true, filter string isn't cleared after selecting an item.
93
84
  */
@@ -216,9 +207,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
216
207
  static get observers() {
217
208
  return [
218
209
  '_selectedItemsChanged(selectedItems)',
219
- '__openedOrItemsChanged(opened, _dropdownItems, loading, __keepOverlayOpened)',
220
210
  '__updateOverflowChip(_overflow, _overflowItems, disabled, readonly)',
221
- '__updateScroller(opened, _dropdownItems, _focusedIndex, _theme)',
222
211
  '__updateTopGroup(selectedItemsOnTop, selectedItems, opened)',
223
212
  ];
224
213
  }
@@ -342,7 +331,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
342
331
  updated(props) {
343
332
  super.updated(props);
344
333
 
345
- ['loading', 'itemIdPath', 'itemClassNameGenerator', 'renderer'].forEach((prop) => {
334
+ ['loading', 'itemClassNameGenerator', 'renderer'].forEach((prop) => {
346
335
  if (props.has(prop)) {
347
336
  this._scroller[prop] = this[prop];
348
337
  }
@@ -432,24 +421,6 @@ export const MultiSelectComboBoxMixin = (superClass) =>
432
421
  this.__syncTopGroup();
433
422
  }
434
423
 
435
- /**
436
- * Requests an update for the content of items.
437
- * While performing the update, it invokes the renderer (passed in the `renderer` property) once an item.
438
- *
439
- * It is not guaranteed that the update happens immediately (synchronously) after it is requested.
440
- */
441
- requestContentUpdate() {
442
- if (!this._scroller) {
443
- return;
444
- }
445
-
446
- this._scroller.requestContentUpdate();
447
-
448
- this._getItemElements().forEach((item) => {
449
- item.requestContentUpdate();
450
- });
451
- }
452
-
453
424
  /**
454
425
  * Override method from `ComboBoxBaseMixin` to implement clearing logic.
455
426
  * @protected
@@ -474,41 +445,6 @@ export const MultiSelectComboBoxMixin = (superClass) =>
474
445
  }
475
446
  }
476
447
 
477
- /** @private */
478
- __updateScroller(opened, items, focusedIndex, theme) {
479
- if (opened) {
480
- this._scroller.style.maxHeight =
481
- getComputedStyle(this).getPropertyValue(`--${this._tagNamePrefix}-overlay-max-height`) || '65vh';
482
- }
483
-
484
- const isClosing = this.hasAttribute('closing');
485
-
486
- this._scroller.setProperties({
487
- items: opened || isClosing ? items : [],
488
- opened,
489
- focusedIndex,
490
- theme,
491
- });
492
- }
493
-
494
- /** @private */
495
- __openedOrItemsChanged(opened, items, loading, keepOverlayOpened) {
496
- // Close the overlay if there are no items to display.
497
- // See https://github.com/vaadin/vaadin-combo-box/pull/964
498
- this._overlayOpened = opened && (keepOverlayOpened || loading || !!items?.length);
499
- }
500
-
501
- /**
502
- * @protected
503
- */
504
- _closeOrCommit() {
505
- if (!this.opened) {
506
- this._commitValue();
507
- } else {
508
- this.close();
509
- }
510
- }
511
-
512
448
  /**
513
449
  * @protected
514
450
  * @override
@@ -542,7 +478,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
542
478
  if (
543
479
  this._lastFilter &&
544
480
  this._lastFilter === this._inputElementValue &&
545
- this._findIndex(focusedItem, this.selectedItems, this.itemIdPath) !== -1
481
+ this._findIndex(focusedItem, this.selectedItems) !== -1
546
482
  ) {
547
483
  this.__clearInternalValue();
548
484
  return;
@@ -705,67 +641,34 @@ export const MultiSelectComboBoxMixin = (superClass) =>
705
641
  }
706
642
 
707
643
  /**
708
- * Override combo-box method to group selected
709
- * items at the top of the overlay.
644
+ * Override method from `ComboBoxItemsMixin` to show only selected
645
+ * items when read-only, and to group selected items at the top
646
+ * of the overlay when `selectedItemsOnTop` is set.
710
647
  *
711
648
  * @protected
712
649
  * @override
713
650
  */
714
651
  _setDropdownItems(items) {
652
+ super._setDropdownItems(this.__generateDropdownItems(items));
653
+ }
654
+
655
+ /** @private */
656
+ __generateDropdownItems(items) {
715
657
  if (this.readonly) {
716
- this.__setDropdownItems(this.selectedItems);
717
- return;
658
+ return this.selectedItems;
718
659
  }
719
660
 
720
661
  if (this.filter || !this.selectedItemsOnTop) {
721
- this.__setDropdownItems(items);
722
- return;
662
+ return items;
723
663
  }
724
664
 
725
665
  if (items?.length && this._topGroup?.length) {
726
666
  // Filter out items included to the top group.
727
- const filteredItems = items.filter((item) => this._findIndex(item, this._topGroup, this.itemIdPath) === -1);
728
-
729
- this.__setDropdownItems(this._topGroup.concat(filteredItems));
730
- return;
667
+ const filteredItems = items.filter((item) => this._findIndex(item, this._topGroup) === -1);
668
+ return this._topGroup.concat(filteredItems);
731
669
  }
732
670
 
733
- this.__setDropdownItems(items);
734
- }
735
-
736
- /** @private */
737
- __setDropdownItems(newItems) {
738
- const oldItems = this._dropdownItems;
739
- this._dropdownItems = newItems;
740
-
741
- // Store the currently focused item if any. The focused index preserves
742
- // in the case when more filtered items are loading but it is reset
743
- // when the user types in a filter query.
744
- const focusedItem = oldItems ? oldItems[this._focusedIndex] : null;
745
-
746
- // When both the previously-focused entry and the new entry at the
747
- // same index are placeholders (e.g. the Flow connector mid-scroll
748
- // re-pushing `__setDropdownItems`), preserve `_focusedIndex` until
749
- // a follow-up call lands a real item at that position.
750
- if (
751
- oldItems &&
752
- oldItems[this._focusedIndex] instanceof ComboBoxPlaceholder &&
753
- newItems[this._focusedIndex] instanceof ComboBoxPlaceholder
754
- ) {
755
- return;
756
- }
757
-
758
- // Try to first set focus on the item that had been focused before `newItems` were updated
759
- // if it is still present in the `newItems` array. Otherwise, set the focused index
760
- // depending on the selected item or the filter query.
761
- const focusedItemIndex = this.__getItemIndexByValue(newItems, this._getItemValue(focusedItem));
762
- if (focusedItemIndex > -1) {
763
- this._focusedIndex = focusedItemIndex;
764
- } else {
765
- // When the user filled in something that is different from the current value = filtering is enabled,
766
- // set the focused index to the item that matches the filter query.
767
- this._focusedIndex = this.__getItemIndexByFilter(newItems);
768
- }
671
+ return items;
769
672
  }
770
673
 
771
674
  /** @private */
@@ -774,17 +677,8 @@ export const MultiSelectComboBoxMixin = (superClass) =>
774
677
  }
775
678
 
776
679
  /** @private */
777
- _findIndex(item, selectedItems, itemIdPath) {
778
- if (itemIdPath && item) {
779
- for (let index = 0; index < selectedItems.length; index++) {
780
- if (selectedItems[index] && selectedItems[index][itemIdPath] === item[itemIdPath]) {
781
- return index;
782
- }
783
- }
784
- return -1;
785
- }
786
-
787
- return selectedItems.indexOf(item);
680
+ _findIndex(item, items) {
681
+ return items.findIndex((other) => this._isSameItem(item, other));
788
682
  }
789
683
 
790
684
  /**
@@ -817,7 +711,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
817
711
  /** @private */
818
712
  __removeItem(item) {
819
713
  const itemsCopy = [...this.selectedItems];
820
- itemsCopy.splice(itemsCopy.indexOf(item), 1);
714
+ itemsCopy.splice(this._findIndex(item, itemsCopy), 1);
821
715
  this.__updateSelection(itemsCopy);
822
716
  const itemLabel = this._getItemLabel(item);
823
717
  this.__announceItem(itemLabel, false, itemsCopy.length);
@@ -827,7 +721,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
827
721
  __selectItem(item) {
828
722
  const itemsCopy = [...this.selectedItems];
829
723
 
830
- const index = this._findIndex(item, itemsCopy, this.itemIdPath);
724
+ const index = this._findIndex(item, itemsCopy);
831
725
  const itemLabel = this._getItemLabel(item);
832
726
 
833
727
  let isSelected = false;
@@ -881,7 +775,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
881
775
  return (
882
776
  this._topGroup &&
883
777
  this._topGroup.some((item) => {
884
- const selectedItem = this.selectedItems[this._findIndex(item, this.selectedItems, this.itemIdPath)];
778
+ const selectedItem = this.selectedItems[this._findIndex(item, this.selectedItems)];
885
779
  return selectedItem && item !== selectedItem;
886
780
  })
887
781
  );
@@ -1076,19 +970,16 @@ export const MultiSelectComboBoxMixin = (superClass) =>
1076
970
  }
1077
971
 
1078
972
  /**
1079
- * Override method from `ComboBoxBaseMixin` to deselect
1080
- * dropdown item by requesting content update on clear.
973
+ * Override method from `ComboBoxItemsMixin` to stop
974
+ * propagation of the clear button click event.
1081
975
  * @param {Event} event
1082
976
  * @protected
977
+ * @override
1083
978
  */
1084
979
  _onClearButtonClick(event) {
1085
980
  event.stopPropagation();
1086
981
 
1087
982
  super._onClearButtonClick(event);
1088
-
1089
- if (this.opened) {
1090
- this.requestContentUpdate();
1091
- }
1092
983
  }
1093
984
 
1094
985
  /**
@@ -43,10 +43,12 @@ class MultiSelectComboBoxScroller extends ComboBoxScrollerMixin(PolylitMixin(Lit
43
43
  }
44
44
 
45
45
  /**
46
+ * Override method from `ComboBoxScrollerMixin` to check
47
+ * the item against the selected items of the owner.
46
48
  * @protected
47
49
  * @override
48
50
  */
49
- _isItemSelected(item, _selectedItem, itemIdPath) {
51
+ _isItemSelected(item) {
50
52
  if (item instanceof ComboBoxPlaceholder) {
51
53
  return false;
52
54
  }
@@ -55,7 +57,7 @@ class MultiSelectComboBoxScroller extends ComboBoxScrollerMixin(PolylitMixin(Lit
55
57
  return false;
56
58
  }
57
59
 
58
- return this.owner._findIndex(item, this.owner.selectedItems, itemIdPath) > -1;
60
+ return this.owner.selectedItems.some((selectedItem) => this.owner._isSameItem(item, selectedItem));
59
61
  }
60
62
 
61
63
  /**
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/multi-select-combo-box",
4
- "version": "25.3.0-beta1",
4
+ "version": "25.3.0-beta3",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -165,7 +165,7 @@
165
165
  },
166
166
  {
167
167
  "name": "item-id-path",
168
- "description": "Path for the id of the item, used to detect whether the item is selected.",
168
+ "description": "Path for the id of the item. If `items` is an array of objects,\nthe `itemIdPath` is used to compare and identify the same item\nin the selection and in `filteredItems` (items given by the\n`dataProvider` callback).",
169
169
  "value": {
170
170
  "type": [
171
171
  "string"
@@ -522,7 +522,7 @@
522
522
  },
523
523
  {
524
524
  "name": "itemIdPath",
525
- "description": "Path for the id of the item, used to detect whether the item is selected.",
525
+ "description": "Path for the id of the item. If `items` is an array of objects,\nthe `itemIdPath` is used to compare and identify the same item\nin the selection and in `filteredItems` (items given by the\n`dataProvider` callback).",
526
526
  "value": {
527
527
  "type": [
528
528
  "string"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/multi-select-combo-box",
4
- "version": "25.3.0-beta1",
4
+ "version": "25.3.0-beta3",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -168,7 +168,7 @@
168
168
  },
169
169
  {
170
170
  "name": ".itemIdPath",
171
- "description": "Path for the id of the item, used to detect whether the item is selected.",
171
+ "description": "Path for the id of the item. If `items` is an array of objects,\nthe `itemIdPath` is used to compare and identify the same item\nin the selection and in `filteredItems` (items given by the\n`dataProvider` callback).",
172
172
  "value": {
173
173
  "kind": "expression"
174
174
  }