@danielgindi/selectbox 1.0.78 → 1.0.80

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.78
2
+ * @danielgindi/selectbox 1.0.80
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  'use strict';
@@ -6655,6 +6655,14 @@ var DropList = /*#__PURE__*/function () {
6655
6655
 
6656
6656
  function previousPage(event) {
6657
6657
  this._move('prev_page', event);
6658
+ } }, { key: "goToFirst", value:
6659
+
6660
+ function goToFirst(event) {
6661
+ this._move('first', event);
6662
+ } }, { key: "goToLast", value:
6663
+
6664
+ function goToLast(event) {
6665
+ this._move('last', event);
6658
6666
  } }, { key: "toggleFocusedItem", value:
6659
6667
 
6660
6668
  function toggleFocusedItem() {
@@ -7682,12 +7690,6 @@ var DropList = /*#__PURE__*/function () {
7682
7690
  var p = this._p;
7683
7691
 
7684
7692
  p.sink.
7685
- add(p.el, 'mousedown', function (event) {
7686
- var li = Dom.closestUntil(event.target, 'li', event.currentTarget);
7687
- if (!li) return;
7688
-
7689
- event.preventDefault();
7690
- }).
7691
7693
  add(p.el, 'mouseup', function (event) {
7692
7694
  var li = Dom.closestUntil(event.target, 'li', event.currentTarget);
7693
7695
  if (!li) return;
@@ -7788,7 +7790,6 @@ var DropList = /*#__PURE__*/function () {
7788
7790
  var p = this._p;
7789
7791
 
7790
7792
  p.sink.add(p.el, 'keydown', function (evt) {return _this9._keydown(evt);});
7791
- p.sink.add(p.el, 'keypress', function (evt) {return _this9._keydown(evt);});
7792
7793
  } }, { key: "_keydown", value:
7793
7794
 
7794
7795
  function _keydown(event) {
@@ -11391,9 +11392,7 @@ var SelectBox = /*#__PURE__*/function () {
11391
11392
  if (!dropList) return;
11392
11393
 
11393
11394
  var avoidToggleFromClick = false,
11394
- currentTouchId = null,
11395
- suppressKeyPress = false,
11396
- suppressKeyPressRepeat = false;
11395
+ currentTouchId = null;
11397
11396
 
11398
11397
  var keyEventsTarget = p.multi || p.searchable ? p.input : p.el;
11399
11398
 
@@ -11402,15 +11401,22 @@ var SelectBox = /*#__PURE__*/function () {
11402
11401
  if ( /**@type HTMLInputElement*/evt.currentTarget.readOnly)
11403
11402
  return;
11404
11403
 
11405
- suppressKeyPress = false;
11406
- suppressKeyPressRepeat = false;
11404
+ var suppressEnterSpaceToggle = false;
11407
11405
 
11408
11406
  switch (evt.key) {
11409
11407
  case keycodeJs.VALUE_PAGE_UP:
11410
11408
  case keycodeJs.VALUE_PAGE_DOWN:
11411
11409
  case keycodeJs.VALUE_UP:
11412
11410
  case keycodeJs.VALUE_DOWN:
11413
- suppressKeyPress = true;
11411
+ case keycodeJs.VALUE_HOME:
11412
+ case keycodeJs.VALUE_END:
11413
+ if ((evt.key === keycodeJs.VALUE_HOME || evt.key === keycodeJs.VALUE_END) &&
11414
+ p.input && p.input.value.length > 0 && !p.lastKeyAllowsNonTypeKeys) {
11415
+ // Allow using HOME/END button within the textbox
11416
+ dropList._keydownFreeType(evt);
11417
+ break;
11418
+ }
11419
+
11414
11420
  evt.preventDefault();
11415
11421
 
11416
11422
  switch (evt.key) {
@@ -11435,16 +11441,22 @@ var SelectBox = /*#__PURE__*/function () {
11435
11441
  } else {
11436
11442
  _this6._moveNext();
11437
11443
  }
11438
- break;}
11444
+ break;
11439
11445
 
11446
+ case keycodeJs.VALUE_HOME:
11447
+ dropList.goToFirst(evt);
11448
+ break;
11449
+
11450
+ case keycodeJs.VALUE_END:
11451
+ dropList.goToLast(evt);
11452
+ break;}
11440
11453
 
11441
11454
  break;
11442
11455
 
11443
11456
  case keycodeJs.VALUE_SPACE:
11444
- if (p.lastKeyAllowsSpaceToggle) {
11457
+ if (p.lastKeyAllowsNonTypeKeys) {
11445
11458
  if (dropList.isVisible() && dropList.hasFocusedItem()) {
11446
- suppressKeyPress = true;
11447
- suppressKeyPressRepeat = true;
11459
+ suppressEnterSpaceToggle = true;
11448
11460
  if (p.multi)
11449
11461
  dropList.toggleFocusedItem(evt);else
11450
11462
  dropList.triggerItemSelection(evt);
@@ -11455,8 +11467,7 @@ var SelectBox = /*#__PURE__*/function () {
11455
11467
 
11456
11468
  case keycodeJs.VALUE_ENTER:
11457
11469
  if (dropList.isVisible() && dropList.hasFocusedItem()) {
11458
- suppressKeyPress = true;
11459
- suppressKeyPressRepeat = true;
11470
+ suppressEnterSpaceToggle = true;
11460
11471
  evt.preventDefault();
11461
11472
  dropList.triggerItemSelection(evt);
11462
11473
  }
@@ -11477,74 +11488,30 @@ var SelectBox = /*#__PURE__*/function () {
11477
11488
  break;
11478
11489
 
11479
11490
  default:
11480
- suppressKeyPressRepeat = true;
11481
11491
  dropList._keydownFreeType(evt);
11482
11492
  break;}
11483
11493
 
11484
11494
 
11485
- p.lastKeyAllowsSpaceToggle = evt.key === keycodeJs.VALUE_UP ||
11495
+ p.lastKeyAllowsNonTypeKeys = evt.key === keycodeJs.VALUE_UP ||
11486
11496
  evt.key === keycodeJs.VALUE_DOWN ||
11487
11497
  evt.key === keycodeJs.VALUE_PAGE_UP ||
11488
11498
  evt.key === keycodeJs.VALUE_PAGE_DOWN ||
11489
- evt.key === keycodeJs.VALUE_SPACE && !!p.lastKeyAllowsSpaceToggle;
11490
- }).
11491
- add(keyEventsTarget, 'keypress.dropdown', function (evt) {
11492
- if (suppressKeyPress) {
11493
- suppressKeyPress = false;
11494
- evt.preventDefault();
11495
- return;
11496
- }
11497
-
11498
- if (suppressKeyPressRepeat)
11499
- return;
11500
-
11501
- if (evt.key === keycodeJs.VALUE_ENTER ||
11502
-
11503
- evt.key === keycodeJs.VALUE_SPACE &&
11504
- p.lastKeyAllowsSpaceToggle &&
11505
- !p.multi &&
11506
- !dropList.hasFocusedItem())
11507
-
11508
- {
11509
- _this6.toggleList();
11510
- evt.preventDefault();
11511
- evt.stopPropagation();
11512
- return;
11513
- }
11514
-
11515
- switch (evt.key) {
11516
- case keycodeJs.VALUE_PAGE_UP:
11517
- case keycodeJs.VALUE_PAGE_DOWN:
11518
- case keycodeJs.VALUE_UP:
11519
- case keycodeJs.VALUE_DOWN:
11499
+ evt.key === keycodeJs.VALUE_HOME ||
11500
+ evt.key === keycodeJs.VALUE_END ||
11501
+ evt.key === keycodeJs.VALUE_SPACE && !!p.lastKeyAllowsNonTypeKeys;
11502
+
11503
+ if (!suppressEnterSpaceToggle) {
11504
+ if (evt.key === keycodeJs.VALUE_ENTER ||
11505
+ evt.key === keycodeJs.VALUE_SPACE &&
11506
+ p.lastKeyAllowsNonTypeKeys &&
11507
+ !p.multi &&
11508
+ !dropList.hasFocusedItem())
11509
+ {
11510
+ _this6.toggleList();
11520
11511
  evt.preventDefault();
11521
-
11522
- switch (evt.key) {
11523
- case keycodeJs.VALUE_PAGE_UP:
11524
- if (dropList.isVisible())
11525
- dropList.previousPage(evt);
11526
- break;
11527
- case keycodeJs.VALUE_PAGE_DOWN:
11528
- if (dropList.isVisible())
11529
- dropList.nextPage(evt);
11530
- break;
11531
- case keycodeJs.VALUE_UP:
11532
- if (dropList.isVisible()) {
11533
- dropList.previous(evt);
11534
- } else {
11535
- _this6._movePrev();
11536
- }
11537
- break;
11538
- case keycodeJs.VALUE_DOWN:
11539
- if (dropList.isVisible()) {
11540
- dropList.next(evt);
11541
- } else {
11542
- _this6._moveNext();
11543
- }
11544
- break;}
11545
-
11546
- break;}
11547
-
11512
+ evt.stopPropagation();
11513
+ }
11514
+ }
11548
11515
  });
11549
11516
 
11550
11517
  if (p.input) {