@danielgindi/selectbox 1.0.64 → 1.0.67

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/dist/lib.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 1.0.64
2
+ * @danielgindi/selectbox 1.0.67
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  'use strict';
@@ -12086,15 +12086,18 @@ var SelectBox = /*#__PURE__*/function () {
12086
12086
 
12087
12087
  /**
12088
12088
  * @param {DropList.ItemBase} item
12089
+ * @returns {boolean} true if rendered, false if not
12089
12090
  * @private
12090
12091
  */ }, { key: "_addMultiItemElement", value:
12091
12092
  function _addMultiItemElement(item) {
12092
12093
  var p = this._p;
12093
12094
  var itemEl = this._renderMultiItem(item);
12094
- if (!itemEl) return;
12095
+ if (!itemEl) return false;
12095
12096
 
12096
12097
  DomCompat.before(p.inputWrapper, itemEl);
12097
12098
  p.multiItemEls.push(itemEl);
12099
+
12100
+ return true;
12098
12101
  }
12099
12102
 
12100
12103
  /** @private */ }, { key: "_addMultiItemRestElement", value:
@@ -12116,10 +12119,13 @@ var SelectBox = /*#__PURE__*/function () {
12116
12119
 
12117
12120
  /** @private */ }, { key: "_syncClearButton", value:
12118
12121
  function _syncClearButton() {var _this9 = this;
12119
- var p = this._p;
12122
+ var p = this._p,
12123
+ multiItemLabelProp = p.multiItemLabelProp;
12120
12124
 
12121
12125
  // Set clear button
12122
- if (p.selectedItems.length > 0 && p.clearable && p.showSelection) {
12126
+ if (p.selectedItems.length > 0 &&
12127
+ p.selectedItems.some(function (x) {return x[multiItemLabelProp] !== false;}) &&
12128
+ p.clearable && p.showSelection) {
12123
12129
  if (!p.clearButtonWrapper) {
12124
12130
  p.clearButtonWrapper = Dom.createElement(
12125
12131
  p.multi ? 'li' : 'span',
@@ -12149,7 +12155,8 @@ var SelectBox = /*#__PURE__*/function () {
12149
12155
 
12150
12156
  /** @private */ }, { key: "_syncPlaceholder", value:
12151
12157
  function _syncPlaceholder() {
12152
- var p = this._p;
12158
+ var p = this._p,
12159
+ multiItemLabelProp = p.multiItemLabelProp;
12153
12160
 
12154
12161
  var placeholder = '';
12155
12162
 
@@ -12159,7 +12166,9 @@ var SelectBox = /*#__PURE__*/function () {
12159
12166
  } else {
12160
12167
  placeholder = defaultMultiPlaceholderFormatter(p.selectedItems, p.labelProp);
12161
12168
  }
12162
- } else if (p.selectedItems.length === 0 || !p.showSelection) {
12169
+ } else if (p.selectedItems.length === 0 ||
12170
+ !p.showSelection ||
12171
+ p.selectedItems.every(function (x) {return x[multiItemLabelProp] === false;})) {
12163
12172
  placeholder = p.placeholder == null ? '' : p.placeholder + '';
12164
12173
  }
12165
12174
 
@@ -12188,13 +12197,16 @@ var SelectBox = /*#__PURE__*/function () {
12188
12197
  * @returns {SelectBox}
12189
12198
  */ }, { key: "_syncFull", value:
12190
12199
  function _syncFull(fullItemsRender) {
12191
- var p = this._p;
12200
+ var p = this._p,
12201
+ multiItemLabelProp = p.multiItemLabelProp;
12192
12202
 
12193
12203
  this._renderBase();
12194
12204
  this._syncClearButton();
12195
12205
  this._syncPlaceholder();
12196
12206
 
12197
- fullItemsRender = p.multi && p.showSelection && (fullItemsRender || p.selectedItems.length !== p.multiItemEls.length);
12207
+ fullItemsRender = p.multi &&
12208
+ p.showSelection && (
12209
+ fullItemsRender || p.selectedItems.filter(function (x) {return x[multiItemLabelProp] !== false;}).length !== p.multiItemEls.length);
12198
12210
 
12199
12211
  if (fullItemsRender || !p.showSelection || !p.multi) {
12200
12212
  // Remove all item elements
@@ -12212,7 +12224,7 @@ var SelectBox = /*#__PURE__*/function () {
12212
12224
  // Sort these
12213
12225
  if (p.sortSelectedItems) {
12214
12226
  var labelProp = p.labelProp,
12215
- multiItemLabelProp = p.multiItemLabelProp,
12227
+ _multiItemLabelProp = p.multiItemLabelProp,
12216
12228
  valueProp = p.valueProp,
12217
12229
  stickyValues = p.stickyValues;
12218
12230
 
@@ -12224,8 +12236,8 @@ var SelectBox = /*#__PURE__*/function () {
12224
12236
  if (!sa && sb) return 1;
12225
12237
  }
12226
12238
 
12227
- var aLabel = a[multiItemLabelProp] || a[labelProp];
12228
- var bLabel = b[multiItemLabelProp] || b[labelProp];
12239
+ var aLabel = a[_multiItemLabelProp] || a[labelProp];
12240
+ var bLabel = b[_multiItemLabelProp] || b[labelProp];
12229
12241
  return aLabel < bLabel ? -1 : aLabel > bLabel ? 1 : 0;
12230
12242
  };
12231
12243
 
@@ -12247,8 +12259,9 @@ var SelectBox = /*#__PURE__*/function () {
12247
12259
  break;
12248
12260
  }
12249
12261
 
12250
- actualItemCount++;
12251
- this._addMultiItemElement(items[i]);
12262
+ if (this._addMultiItemElement(items[i])) {
12263
+ actualItemCount++;
12264
+ }
12252
12265
  }
12253
12266
 
12254
12267
  if (addRestItem) {
@@ -12777,6 +12790,11 @@ var SelectBox = /*#__PURE__*/function () {
12777
12790
  stickyGroup = groups[0].filter(function (x) {return stickyValues.has(x[valueProp]);});
12778
12791
  if (stickyGroup.length > 0) {
12779
12792
  groups[0] = groups[0].filter(function (x) {return !stickyValues.has(x[valueProp]);});
12793
+
12794
+ if (groups[0].length === 0)
12795
+ groups.shift();
12796
+ } else {
12797
+ stickyGroup = null;
12780
12798
  }
12781
12799
  }
12782
12800
 
@@ -12801,7 +12819,7 @@ var SelectBox = /*#__PURE__*/function () {
12801
12819
  });
12802
12820
  }
12803
12821
 
12804
- if (stickyGroup && stickyGroup.length > 0) {
12822
+ if (stickyGroup) {
12805
12823
  groups.unshift(stickyGroup);
12806
12824
  }
12807
12825