@danielgindi/selectbox 1.0.44 → 1.0.48

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.es6.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 1.0.44
2
+ * @danielgindi/selectbox 1.0.48
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  import { createElement, closestUntil, setElementAttrs, next, prev } from '@danielgindi/dom-utils/lib/Dom';
@@ -164,7 +164,7 @@ class DropList {
164
164
  let classes = [p.baseClassName];
165
165
 
166
166
  if (p.additionalClasses) {
167
- classes = classes.concat(p.additionalClasses);
167
+ classes = classes.concat((p.additionalClasses + '').split(' ').filter(x => x));
168
168
  }
169
169
 
170
170
  const initialCss = {
@@ -367,6 +367,50 @@ class DropList {
367
367
  return this;
368
368
  }
369
369
 
370
+ /**
371
+ *
372
+ * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [fn] Function to call when rendering an item element
373
+ * @returns {DropList}
374
+ */
375
+ setRenderItem(fn) {
376
+ const p = this._p;
377
+ p.renderItem = fn;
378
+ return this;
379
+ }
380
+
381
+ /**
382
+ *
383
+ * @property {function(item: DropList.ItemBase, itemEl: Element)} [fn] Function to call when rendering an item element
384
+ * @returns {DropList}
385
+ */
386
+ setUnrenderItem(fn) {
387
+ const p = this._p;
388
+
389
+ p.unrenderItem = fn;
390
+
391
+ if (typeof p.unrenderItem === 'function') {
392
+ const fn = p.unrenderItem;
393
+ p.virtualListHelper.setOnItemUnrender(el => {
394
+ try {
395
+ fn(el[ItemSymbol$1][ItemSymbol$1], el);
396
+ } catch (err) { console.error(err); } // eslint-disable-line no-console
397
+ delete el[ItemSymbol$1];
398
+
399
+ if (p.focusItemEl === el)
400
+ p.focusItemEl = null;
401
+ });
402
+ } else {
403
+ p.virtualListHelper.setOnItemUnrender(el => {
404
+ delete el[ItemSymbol$1];
405
+
406
+ if (p.focusItemEl === el)
407
+ p.focusItemEl = null;
408
+ });
409
+ }
410
+
411
+ return this;
412
+ }
413
+
370
414
  /**
371
415
  * @param {string} prop
372
416
  * @returns {DropList}
@@ -1909,8 +1953,8 @@ class DropList {
1909
1953
  this._trigger('check', {
1910
1954
  value: next.value,
1911
1955
  item: next[ItemSymbol$1] ?? next,
1912
- checked: item._checked,
1913
- isGroup: item._group,
1956
+ checked: next._checked,
1957
+ isGroup: next._group,
1914
1958
  isCheckingGroup: true,
1915
1959
  });
1916
1960
  }
@@ -1981,8 +2025,8 @@ class DropList {
1981
2025
  this._trigger('check', {
1982
2026
  value: groupItem.value,
1983
2027
  item: groupItem[ItemSymbol$1] ?? groupItem,
1984
- checked: item._checked,
1985
- isGroup: item._group,
2028
+ checked: groupItem._checked,
2029
+ isGroup: groupItem._group,
1986
2030
  isCheckingGroup: false,
1987
2031
  });
1988
2032
  }