@danielgindi/selectbox 1.0.123 → 1.0.124

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.123
2
+ * @danielgindi/selectbox 1.0.124
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  'use strict';
@@ -2813,9 +2813,9 @@ class DropList {
2813
2813
  DomCompat.remove(p.el);
2814
2814
  }
2815
2815
 
2816
- if (p._currentSubDropList) {var _p$_currentSubDropLis;
2817
- (_p$_currentSubDropLis = p._currentSubDropList) === null || _p$_currentSubDropLis === void 0 || (_p$_currentSubDropLis = _p$_currentSubDropLis.droplist) === null || _p$_currentSubDropLis === void 0 || _p$_currentSubDropLis.destroy();
2818
- p._currentSubDropList = null;
2816
+ if (p.currentSubDropList) {var _p$currentSubDropList;
2817
+ (_p$currentSubDropList = p.currentSubDropList) === null || _p$currentSubDropList === void 0 || (_p$currentSubDropList = _p$currentSubDropList.droplist) === null || _p$currentSubDropList === void 0 || _p$currentSubDropList.destroy();
2818
+ p.currentSubDropList = null;
2819
2819
  }
2820
2820
 
2821
2821
  if (!p.ownsEl) {
@@ -2846,6 +2846,22 @@ class DropList {
2846
2846
  return this._p.el;
2847
2847
  }
2848
2848
 
2849
+ /**
2850
+ * Returns true if other is an inclusive descendant of node, and false otherwise.
2851
+ * @param {Node} other
2852
+ * @param {boolean} [considerSubmenus=true]
2853
+ * @returns {boolean}
2854
+ */
2855
+ elContains(other) {var _this$_p$currentSubDr;let considerSubmenus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2856
+ if (this.el.contains(other))
2857
+ return true;
2858
+
2859
+ if (considerSubmenus && (_this$_p$currentSubDr = this._p.currentSubDropList) !== null && _this$_p$currentSubDr !== void 0 && (_this$_p$currentSubDr = _this$_p$currentSubDr.droplist) !== null && _this$_p$currentSubDr !== void 0 && _this$_p$currentSubDr.elContains(other))
2860
+ return true;
2861
+
2862
+ return false;
2863
+ }
2864
+
2849
2865
  /**
2850
2866
  * @param {string|string[]} classes
2851
2867
  * @returns {DropList}
@@ -2983,7 +2999,7 @@ class DropList {
2983
2999
  if (!item)
2984
3000
  return;
2985
3001
 
2986
- if (p._currentSubDropList) {
3002
+ if (p.currentSubDropList) {
2987
3003
  this._hideSublist();
2988
3004
  }
2989
3005
 
@@ -3776,7 +3792,7 @@ class DropList {
3776
3792
  if (this[DestroyedSymbol$1]) return;
3777
3793
  this._trigger('hide:after');
3778
3794
 
3779
- if (p._currentSubDropList) {
3795
+ if (p.currentSubDropList) {
3780
3796
  this._hideSublist();
3781
3797
  }
3782
3798
  }
@@ -3902,7 +3918,7 @@ class DropList {
3902
3918
  updateWidth: true
3903
3919
  });
3904
3920
 
3905
- p._currentSubDropList = {
3921
+ p.currentSubDropList = {
3906
3922
  item: item,
3907
3923
  itemElement: itemElement,
3908
3924
  droplist: droplist
@@ -3912,13 +3928,13 @@ class DropList {
3912
3928
  _hideSublist() {
3913
3929
  const p = this._p;
3914
3930
 
3915
- if (!p._currentSubDropList)
3931
+ if (!p.currentSubDropList)
3916
3932
  return;
3917
3933
 
3918
- const data = p._currentSubDropList;
3934
+ const data = p.currentSubDropList;
3919
3935
  data.droplist.hide();
3920
3936
  data.droplist.destroy();
3921
- p._currentSubDropList = null;
3937
+ p.currentSubDropList = null;
3922
3938
 
3923
3939
  this._trigger('hide_subitems', {
3924
3940
  value: data.item.value,
@@ -4168,7 +4184,7 @@ class DropList {
4168
4184
  }
4169
4185
 
4170
4186
  _handleMouseOver(event, itemEl) {
4171
- this._focus(event, itemEl);
4187
+ this._focus(event, itemEl, true);
4172
4188
  }
4173
4189
 
4174
4190
  _hookTouchEvents() {
@@ -4234,7 +4250,7 @@ class DropList {
4234
4250
  let itemEl = p.focusItemEl || // focused item
4235
4251
  p.el.firstChild; // or the first item
4236
4252
 
4237
- this._focus(event, itemEl);
4253
+ this._focus(event, itemEl, false);
4238
4254
  }).
4239
4255
  add(p.el, 'blur', () => {
4240
4256
  setTimeout(() => {
@@ -4293,6 +4309,21 @@ class DropList {
4293
4309
  }
4294
4310
  break;
4295
4311
 
4312
+ case keycodeJs.VALUE_LEFT:
4313
+ case keycodeJs.VALUE_RIGHT:
4314
+ if (event.key === keycodeJs.VALUE_RIGHT && getComputedStyle(event.target).direction !== 'rtl' ||
4315
+ event.key === keycodeJs.VALUE_LEFT && getComputedStyle(event.target).direction === 'rtl') {
4316
+ let item = p.items[p.focusItemIndex];
4317
+ if (p.focusItemIndex > -1 && item._subitems)
4318
+ this._showSublist(item, p.focusItemEl);
4319
+ } else {
4320
+ if (p.currentSubDropList) {
4321
+ p.currentSubDropList.hide();
4322
+ preventDefault = false;
4323
+ }
4324
+ }
4325
+ break;
4326
+
4296
4327
  case keycodeJs.VALUE_ENTER:
4297
4328
  this.triggerItemSelection(null, event);
4298
4329
  event.preventDefault();
@@ -4369,7 +4400,7 @@ class DropList {
4369
4400
 
4370
4401
  if (matchIndex > -1) {
4371
4402
  let next = p.virtualListHelper.getItemElementAt(matchIndex);
4372
- this._focus(evt, next || null, matchIndex);
4403
+ this._focus(evt, next || null, matchIndex, true);
4373
4404
 
4374
4405
  if (!this.isVisible()) {
4375
4406
  this.triggerItemSelection(next ? null : p.items[matchIndex], evt);
@@ -4388,7 +4419,7 @@ class DropList {
4388
4419
  }
4389
4420
  }
4390
4421
 
4391
- _focus(event, itemEl, itemIndex) {var _item$ItemSymbol6;
4422
+ _focus(event, itemEl, itemIndex, openSubitems) {var _item$ItemSymbol6;
4392
4423
  const p = this._p;
4393
4424
 
4394
4425
  if (!itemIndex && itemEl) {
@@ -4425,6 +4456,8 @@ class DropList {
4425
4456
  event: event,
4426
4457
  el: focusItemEl
4427
4458
  });
4459
+
4460
+ if (openSubitems)
4428
4461
  this._showSublist(item, focusItemEl);
4429
4462
  }
4430
4463
 
@@ -4569,7 +4602,7 @@ class DropList {
4569
4602
  }
4570
4603
 
4571
4604
  next = p.virtualListHelper.getItemElementAt(nextIndex);
4572
- this._focus(event, next || null, nextIndex);
4605
+ this._focus(event, next || null, nextIndex, false);
4573
4606
 
4574
4607
  if (!this.isVisible()) {
4575
4608
  this.triggerItemSelection(item, event);