@danielgindi/selectbox 1.0.46 → 1.0.50

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.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 1.0.46
2
+ * @danielgindi/selectbox 1.0.50
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  (function (global, factory) {
@@ -5628,14 +5628,14 @@
5628
5628
 
5629
5629
  /**
5630
5630
  * @typedef {Object} DropList.PositionOptions
5631
- * @property {Element} [target] Target element to act as anchor
5632
- * @property {{left: number, top: number}} [targetOffset=undefined] Override the offset of target. Automatically calculated if unspecified.
5633
- * @property {number} [targetHeight=undefined] Override height of the target
5634
- * @property {number} [targetWidth=undefined] Override width of the target
5635
- * @property {DropList.PositionAnchor} [position=undefined]
5636
- * @property {DropList.PositionAnchor} [anchor=undefined]
5637
- * @property {boolean} [updateWidth=false] Should update the width of the menu according to target
5638
- * @property {string} [targetRtl=undefined] Override for rtl mode of the target
5631
+ * @property {Element?} [target] Target element to act as anchor
5632
+ * @property {{left: number, top: number}?} [targetOffset] Override the offset of target. Automatically calculated if unspecified.
5633
+ * @property {number?} [targetHeight] Override height of the target
5634
+ * @property {number?} [targetWidth] Override width of the target
5635
+ * @property {DropList.PositionAnchor?} [position]
5636
+ * @property {DropList.PositionAnchor?} [anchor]
5637
+ * @property {boolean|number?} [updateWidth=false] `true` to set width of the menu according to `target`'s width, or specify an arbitrary number.
5638
+ * @property {string?} [targetRtl] Override for rtl mode of the target
5639
5639
  * @property {{x: number, y: number}} [offset=undefined] Extra rtl-aware offset to the target
5640
5640
  * */
5641
5641
  /** */
@@ -5741,7 +5741,7 @@
5741
5741
  var classes = [p.baseClassName];
5742
5742
 
5743
5743
  if (p.additionalClasses) {
5744
- classes = classes.concat((p.additionalClasses + '').split('').filter(function (x) {return x;}));
5744
+ classes = classes.concat((p.additionalClasses + '').split(' ').filter(function (x) {return x;}));
5745
5745
  }
5746
5746
 
5747
5747
  var initialCss = {
@@ -5944,6 +5944,50 @@
5944
5944
  return this;
5945
5945
  }
5946
5946
 
5947
+ /**
5948
+ *
5949
+ * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [fn] Function to call when rendering an item element
5950
+ * @returns {DropList}
5951
+ */ }, { key: "setRenderItem", value:
5952
+ function setRenderItem(fn) {
5953
+ var p = this._p;
5954
+ p.renderItem = fn;
5955
+ return this;
5956
+ }
5957
+
5958
+ /**
5959
+ *
5960
+ * @property {function(item: DropList.ItemBase, itemEl: Element)} [fn] Function to call when rendering an item element
5961
+ * @returns {DropList}
5962
+ */ }, { key: "setUnrenderItem", value:
5963
+ function setUnrenderItem(fn) {
5964
+ var p = this._p;
5965
+
5966
+ p.unrenderItem = fn;
5967
+
5968
+ if (typeof p.unrenderItem === 'function') {
5969
+ var _fn = p.unrenderItem;
5970
+ p.virtualListHelper.setOnItemUnrender(function (el) {
5971
+ try {
5972
+ _fn(el[ItemSymbol$1][ItemSymbol$1], el);
5973
+ } catch (err) {console.error(err);} // eslint-disable-line no-console
5974
+ delete el[ItemSymbol$1];
5975
+
5976
+ if (p.focusItemEl === el)
5977
+ p.focusItemEl = null;
5978
+ });
5979
+ } else {
5980
+ p.virtualListHelper.setOnItemUnrender(function (el) {
5981
+ delete el[ItemSymbol$1];
5982
+
5983
+ if (p.focusItemEl === el)
5984
+ p.focusItemEl = null;
5985
+ });
5986
+ }
5987
+
5988
+ return this;
5989
+ }
5990
+
5947
5991
  /**
5948
5992
  * @param {string} prop
5949
5993
  * @returns {DropList}
@@ -6312,7 +6356,7 @@
6312
6356
  }
6313
6357
 
6314
6358
  // Now set the width of the dropdown
6315
- if (positionOptions.updateWidth) {
6359
+ if (positionOptions.updateWidth || typeof positionOptions.updateWidth === 'number') {
6316
6360
  this._updateWidth(positionOptions);
6317
6361
  }
6318
6362
 
@@ -7670,9 +7714,14 @@
7670
7714
  var targetWidth = 0;
7671
7715
 
7672
7716
  if (positionOptions) {
7673
- // Measure target
7674
- targetWidth = positionOptions.targetWidth;
7675
- if (targetWidth == null) {
7717
+ if (typeof positionOptions.updateWidth === 'number') {
7718
+ // Set from width specified
7719
+ targetWidth = positionOptions.updateWidth;
7720
+ } else if (positionOptions.targetWidth != null) {
7721
+ // Set from simulated target width
7722
+ targetWidth = positionOptions.updateWidth;
7723
+ } else {
7724
+ // Measure target
7676
7725
  targetWidth = Css.getElementWidth(positionOptions.target, true, true);
7677
7726
  }
7678
7727
  }