@lemonadejs/dropdown 3.0.9 → 3.0.10
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 +31 -10
- package/dist/style.css +18 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -214,6 +214,8 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
214
214
|
let adjust = getVisibleRows(false);
|
|
215
215
|
if (adjust) {
|
|
216
216
|
el.scrollTop += adjust;
|
|
217
|
+
// Last adjust on the visible rows
|
|
218
|
+
getVisibleRows(false);
|
|
217
219
|
}
|
|
218
220
|
}
|
|
219
221
|
|
|
@@ -397,9 +399,9 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
397
399
|
|
|
398
400
|
const onclose = function() {
|
|
399
401
|
// Cursor
|
|
400
|
-
removeCursor();
|
|
402
|
+
removeCursor(true);
|
|
401
403
|
// Reset search
|
|
402
|
-
if (self.autocomplete
|
|
404
|
+
if (self.autocomplete) {
|
|
403
405
|
// Go to begin of the data
|
|
404
406
|
self.rows = self.data;
|
|
405
407
|
// Remove editable attribute
|
|
@@ -419,8 +421,6 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
419
421
|
self.state = true;
|
|
420
422
|
// Value
|
|
421
423
|
let v = value[value.length-1];
|
|
422
|
-
// Cursor
|
|
423
|
-
removeCursor();
|
|
424
424
|
// Move to the correct position
|
|
425
425
|
if (v) {
|
|
426
426
|
// Go to the last item in the array of values
|
|
@@ -462,9 +462,14 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
+
let timer = null;
|
|
466
|
+
|
|
465
467
|
self.open = function () {
|
|
466
468
|
if (self.modal && self.modal.closed) {
|
|
469
|
+
// Open the modal
|
|
467
470
|
self.modal.closed = false;
|
|
471
|
+
// Timer
|
|
472
|
+
timer = setTimeout(() => timer = null, 400);
|
|
468
473
|
}
|
|
469
474
|
}
|
|
470
475
|
|
|
@@ -472,12 +477,14 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
472
477
|
// Close the modal
|
|
473
478
|
if (self.modal) {
|
|
474
479
|
self.modal.closed = true;
|
|
475
|
-
// Remove cursor
|
|
476
|
-
removeCursor(true);
|
|
477
480
|
}
|
|
478
481
|
}
|
|
479
482
|
|
|
480
|
-
self.toggle = function() {
|
|
483
|
+
self.toggle = function(e) {
|
|
484
|
+
if (timer) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
|
|
481
488
|
if (self.modal) {
|
|
482
489
|
if (self.modal.closed) {
|
|
483
490
|
self.open();
|
|
@@ -487,6 +494,20 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
487
494
|
}
|
|
488
495
|
}
|
|
489
496
|
|
|
497
|
+
self.click = function(e) {
|
|
498
|
+
let x;
|
|
499
|
+
if (e.changedTouches && e.changedTouches[0]) {
|
|
500
|
+
x = e.changedTouches[0].clientX;
|
|
501
|
+
} else {
|
|
502
|
+
x = e.clientX;
|
|
503
|
+
}
|
|
504
|
+
if (e.target.offsetWidth - (x - e.target.offsetLeft) < 24) {
|
|
505
|
+
self.toggle();
|
|
506
|
+
} else {
|
|
507
|
+
self.open();
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
490
511
|
self.select = function(e, s) {
|
|
491
512
|
if (s) {
|
|
492
513
|
if (self.multiple === true) {
|
|
@@ -533,9 +554,9 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
533
554
|
closed: true,
|
|
534
555
|
focus: false,
|
|
535
556
|
width: self.width,
|
|
536
|
-
'auto-close': false,
|
|
537
557
|
onopen: onopen,
|
|
538
558
|
onclose: onclose,
|
|
559
|
+
'auto-close': false,
|
|
539
560
|
};
|
|
540
561
|
// Generate modal
|
|
541
562
|
Modal(self.el.children[1], self.modal);
|
|
@@ -554,7 +575,7 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
554
575
|
if (self.modal) {
|
|
555
576
|
if (! (e.relatedTarget && self.el.contains(e.relatedTarget)) && !self.el.contains(e.relatedTarget)) {
|
|
556
577
|
if (! self.modal.closed) {
|
|
557
|
-
self.
|
|
578
|
+
self.modal.closed = true;
|
|
558
579
|
}
|
|
559
580
|
}
|
|
560
581
|
}
|
|
@@ -602,7 +623,7 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
602
623
|
|
|
603
624
|
return `<div class="lm-dropdown" data-type="{{self.type}}" data-state="{{self.state}}">
|
|
604
625
|
<div class="lm-dropdown-header">
|
|
605
|
-
<div class="lm-dropdown-input" oninput="self.search" onfocus="self.open" placeholder="{{self.placeholder}}" :ref="self.input" tabindex="0"></div>
|
|
626
|
+
<div class="lm-dropdown-input" oninput="self.search" onfocus="self.open" onclick="self.click" placeholder="{{self.placeholder}}" :ref="self.input" tabindex="0"></div>
|
|
606
627
|
<button onclick="self.close" class="lm-dropdown-done">Done</button>
|
|
607
628
|
</div>
|
|
608
629
|
<div class="lm-dropdown-content">
|
package/dist/style.css
CHANGED
|
@@ -44,13 +44,28 @@
|
|
|
44
44
|
cursor: pointer;
|
|
45
45
|
box-sizing: border-box;
|
|
46
46
|
width: 100%;
|
|
47
|
-
background-repeat: no-repeat;
|
|
48
|
-
background-position: top 50% right 0;
|
|
49
|
-
background-image: url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='none' d='M0 0h24v24H0V0z'/%3E%3Cpath d='M7 10l5 5 5-5H7z' fill='gray'/%3E%3C/svg%3E");
|
|
50
47
|
border: 1px solid #ccc;
|
|
51
48
|
min-height: 1em;
|
|
52
49
|
}
|
|
53
50
|
|
|
51
|
+
.lm-dropdown-input::after {
|
|
52
|
+
content: '';
|
|
53
|
+
position: absolute;
|
|
54
|
+
width: 24px;
|
|
55
|
+
height: 24px;
|
|
56
|
+
right: 2px;
|
|
57
|
+
top: 2px;
|
|
58
|
+
background-repeat: no-repeat;
|
|
59
|
+
background-image: url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='none' d='M0 0h24v24H0V0z'/%3E%3Cpath d='M7 10l5 5 5-5H7z' fill='gray'/%3E%3C/svg%3E");
|
|
60
|
+
transition: transform .2s ease-in-out;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
.lm-dropdown[data-state="true"] .lm-dropdown-input::after {
|
|
65
|
+
transform: rotate(-180deg);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
54
69
|
.lm-dropdown-input:empty::before {
|
|
55
70
|
content: "\00a0";
|
|
56
71
|
}
|
package/package.json
CHANGED