@danielgindi/selectbox 1.0.78 → 1.0.79

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.79
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;
@@ -11410,6 +11412,16 @@ var SelectBox = /*#__PURE__*/function () {
11410
11412
  case keycodeJs.VALUE_PAGE_DOWN:
11411
11413
  case keycodeJs.VALUE_UP:
11412
11414
  case keycodeJs.VALUE_DOWN:
11415
+ case keycodeJs.VALUE_HOME:
11416
+ case keycodeJs.VALUE_END:
11417
+ if ((evt.key === keycodeJs.VALUE_HOME || evt.key === keycodeJs.VALUE_END) &&
11418
+ p.input && p.input.value.length > 0 && !p.lastKeyAllowsNonTypeKeys) {
11419
+ // Allow using HOME/END button within the textbox
11420
+ suppressKeyPressRepeat = true;
11421
+ dropList._keydownFreeType(evt);
11422
+ break;
11423
+ }
11424
+
11413
11425
  suppressKeyPress = true;
11414
11426
  evt.preventDefault();
11415
11427
 
@@ -11435,13 +11447,20 @@ var SelectBox = /*#__PURE__*/function () {
11435
11447
  } else {
11436
11448
  _this6._moveNext();
11437
11449
  }
11438
- break;}
11450
+ break;
11439
11451
 
11452
+ case keycodeJs.VALUE_HOME:
11453
+ dropList.goToFirst(evt);
11454
+ break;
11455
+
11456
+ case keycodeJs.VALUE_END:
11457
+ dropList.goToLast(evt);
11458
+ break;}
11440
11459
 
11441
11460
  break;
11442
11461
 
11443
11462
  case keycodeJs.VALUE_SPACE:
11444
- if (p.lastKeyAllowsSpaceToggle) {
11463
+ if (p.lastKeyAllowsNonTypeKeys) {
11445
11464
  if (dropList.isVisible() && dropList.hasFocusedItem()) {
11446
11465
  suppressKeyPress = true;
11447
11466
  suppressKeyPressRepeat = true;
@@ -11482,11 +11501,13 @@ var SelectBox = /*#__PURE__*/function () {
11482
11501
  break;}
11483
11502
 
11484
11503
 
11485
- p.lastKeyAllowsSpaceToggle = evt.key === keycodeJs.VALUE_UP ||
11504
+ p.lastKeyAllowsNonTypeKeys = evt.key === keycodeJs.VALUE_UP ||
11486
11505
  evt.key === keycodeJs.VALUE_DOWN ||
11487
11506
  evt.key === keycodeJs.VALUE_PAGE_UP ||
11488
11507
  evt.key === keycodeJs.VALUE_PAGE_DOWN ||
11489
- evt.key === keycodeJs.VALUE_SPACE && !!p.lastKeyAllowsSpaceToggle;
11508
+ evt.key === keycodeJs.VALUE_HOME ||
11509
+ evt.key === keycodeJs.VALUE_END ||
11510
+ evt.key === keycodeJs.VALUE_SPACE && !!p.lastKeyAllowsNonTypeKeys;
11490
11511
  }).
11491
11512
  add(keyEventsTarget, 'keypress.dropdown', function (evt) {
11492
11513
  if (suppressKeyPress) {
@@ -11499,9 +11520,8 @@ var SelectBox = /*#__PURE__*/function () {
11499
11520
  return;
11500
11521
 
11501
11522
  if (evt.key === keycodeJs.VALUE_ENTER ||
11502
-
11503
11523
  evt.key === keycodeJs.VALUE_SPACE &&
11504
- p.lastKeyAllowsSpaceToggle &&
11524
+ p.lastKeyAllowsNonTypeKeys &&
11505
11525
  !p.multi &&
11506
11526
  !dropList.hasFocusedItem())
11507
11527
 
@@ -11509,42 +11529,7 @@ var SelectBox = /*#__PURE__*/function () {
11509
11529
  _this6.toggleList();
11510
11530
  evt.preventDefault();
11511
11531
  evt.stopPropagation();
11512
- return;
11513
11532
  }
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:
11520
- 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
-
11548
11533
  });
11549
11534
 
11550
11535
  if (p.input) {