@lemonadejs/dropdown 3.1.2 → 3.1.3
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/index.js +40 -41
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -305,13 +305,14 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
305
305
|
|
|
306
306
|
const setCursor = function(index) {
|
|
307
307
|
let item = self.rows[index];
|
|
308
|
+
|
|
308
309
|
if (typeof(item) !== 'undefined') {
|
|
309
310
|
// Set cursor number
|
|
310
311
|
cursor = index;
|
|
311
312
|
// Set visual indication
|
|
312
313
|
item.cursor = true;
|
|
313
314
|
// Go to the item on the scroll in case the item is not on the viewport
|
|
314
|
-
if (! item.el
|
|
315
|
+
if (! (item.el && item.el.parentNode)) {
|
|
315
316
|
// Goto method
|
|
316
317
|
self.goto(item);
|
|
317
318
|
}
|
|
@@ -394,15 +395,17 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
394
395
|
// Width && values
|
|
395
396
|
value = [];
|
|
396
397
|
|
|
397
|
-
self.data
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
s.
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
398
|
+
if (Array.isArray(self.data)) {
|
|
399
|
+
self.data.map(function (s) {
|
|
400
|
+
// Select values
|
|
401
|
+
if (newValue.indexOf(s.value) !== -1) {
|
|
402
|
+
s.selected = true;
|
|
403
|
+
value.push(s);
|
|
404
|
+
} else {
|
|
405
|
+
s.selected = false;
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}
|
|
406
409
|
|
|
407
410
|
// Update label
|
|
408
411
|
updateLabel();
|
|
@@ -458,8 +461,6 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
458
461
|
let v = value[value.length-1];
|
|
459
462
|
// Move to the correct position
|
|
460
463
|
if (v) {
|
|
461
|
-
// Go to the last item in the array of values
|
|
462
|
-
self.goto(v);
|
|
463
464
|
// Mark the position of the cursor to the same element
|
|
464
465
|
setCursor(self.rows.indexOf(v));
|
|
465
466
|
} else {
|
|
@@ -501,14 +502,10 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
501
502
|
}
|
|
502
503
|
}
|
|
503
504
|
|
|
504
|
-
let timer = null;
|
|
505
|
-
|
|
506
505
|
self.open = function () {
|
|
507
506
|
if (self.modal && self.modal.closed) {
|
|
508
507
|
// Open the modal
|
|
509
508
|
self.modal.closed = false;
|
|
510
|
-
// Timer
|
|
511
|
-
timer = setTimeout(() => timer = null, 400);
|
|
512
509
|
}
|
|
513
510
|
}
|
|
514
511
|
|
|
@@ -520,10 +517,6 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
520
517
|
}
|
|
521
518
|
|
|
522
519
|
self.toggle = function(e) {
|
|
523
|
-
if (timer) {
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
520
|
if (self.modal) {
|
|
528
521
|
if (self.modal.closed) {
|
|
529
522
|
self.open();
|
|
@@ -623,29 +616,35 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
623
616
|
})
|
|
624
617
|
// Key events
|
|
625
618
|
self.el.addEventListener('keydown', function(e) {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
prevent = true;
|
|
640
|
-
} else {
|
|
641
|
-
if (e.keyCode === 32 && ! self.autocomplete) {
|
|
619
|
+
if (! self.modal.closed) {
|
|
620
|
+
let prevent = false;
|
|
621
|
+
if (e.key === 'ArrowUp') {
|
|
622
|
+
moveCursor(-1);
|
|
623
|
+
prevent = true;
|
|
624
|
+
} else if (e.key === 'ArrowDown') {
|
|
625
|
+
moveCursor(1);
|
|
626
|
+
prevent = true;
|
|
627
|
+
} else if (e.key === 'Home') {
|
|
628
|
+
moveCursor(-1, true);
|
|
629
|
+
} else if (e.key === 'End') {
|
|
630
|
+
moveCursor(1, true);
|
|
631
|
+
} else if (e.key === 'Enter') {
|
|
642
632
|
self.select(e, self.rows[cursor]);
|
|
633
|
+
prevent = true;
|
|
634
|
+
} else {
|
|
635
|
+
if (e.keyCode === 32 && !self.autocomplete) {
|
|
636
|
+
self.select(e, self.rows[cursor]);
|
|
637
|
+
}
|
|
643
638
|
}
|
|
644
|
-
}
|
|
645
639
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
640
|
+
if (prevent) {
|
|
641
|
+
e.preventDefault();
|
|
642
|
+
e.stopImmediatePropagation();
|
|
643
|
+
}
|
|
644
|
+
} else {
|
|
645
|
+
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
646
|
+
self.modal.closed = false;
|
|
647
|
+
}
|
|
649
648
|
}
|
|
650
649
|
});
|
|
651
650
|
|
|
@@ -723,7 +722,7 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
723
722
|
|
|
724
723
|
return `<div class="lm-dropdown" data-insert="{{self.insert}}" data-type="{{self.type}}" data-state="{{self.state}}" :value="self.value">
|
|
725
724
|
<div class="lm-dropdown-header">
|
|
726
|
-
<div class="lm-dropdown-input" onpaste="self.onpaste" oninput="self.search" onfocus="self.open"
|
|
725
|
+
<div class="lm-dropdown-input" onpaste="self.onpaste" oninput="self.search" onfocus="self.open" onmousedown="self.click" placeholder="{{self.placeholder}}" :ref="self.input" tabindex="0"></div>
|
|
727
726
|
<div class="lm-dropdown-add" onmousedown="self.add"></div>
|
|
728
727
|
<button onclick="self.close" class="lm-dropdown-done">Done</button>
|
|
729
728
|
</div>
|
package/package.json
CHANGED