@lemonadejs/dropdown 3.6.2 → 5.0.0
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 +37 -32
- package/dist/style.css +12 -6
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -405,13 +405,43 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
405
405
|
setCursor(cursor);
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
-
const
|
|
408
|
+
const adjustDimensions = function(data) {
|
|
409
409
|
// Estimate width
|
|
410
410
|
let width = self.width;
|
|
411
|
+
// Adjust the width
|
|
412
|
+
let w = self.input.offsetWidth;
|
|
413
|
+
if (width < w) {
|
|
414
|
+
width = w;
|
|
415
|
+
}
|
|
416
|
+
// Width && values
|
|
417
|
+
data.map(function (s) {
|
|
418
|
+
// Estimated width of the element
|
|
419
|
+
if (s.text) {
|
|
420
|
+
let w = Math.max(width, s.text.length * 7.5);
|
|
421
|
+
if (width < w) {
|
|
422
|
+
width = w;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
// Min width for the container
|
|
427
|
+
self.container.parentNode.style.width = (width - 2) + 'px';
|
|
428
|
+
// Height
|
|
429
|
+
self.height = 400;
|
|
430
|
+
|
|
431
|
+
// Animation for mobile
|
|
432
|
+
if (document.documentElement.clientWidth < 800) {
|
|
433
|
+
self.animation = true;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const setData = function () {
|
|
411
438
|
// Data
|
|
412
439
|
data = JSON.parse(JSON.stringify(self.data));
|
|
413
440
|
// Re-order to make sure groups are in sequence
|
|
414
441
|
if (data && data.length) {
|
|
442
|
+
// Adjust width and height
|
|
443
|
+
adjustDimensions(data);
|
|
444
|
+
// Groups
|
|
415
445
|
data.sort((a, b) => {
|
|
416
446
|
// Compare groups
|
|
417
447
|
if (a.group && b.group) {
|
|
@@ -428,33 +458,6 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
428
458
|
group = v.group;
|
|
429
459
|
}
|
|
430
460
|
});
|
|
431
|
-
// Width && values
|
|
432
|
-
data.map(function (s) {
|
|
433
|
-
// Estimated width of the element
|
|
434
|
-
if (s.text) {
|
|
435
|
-
width = Math.max(width, s.text.length * 8);
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
// Adjust the width
|
|
440
|
-
if (typeof(self.width) === 'undefined') {
|
|
441
|
-
let w = self.input.offsetWidth;
|
|
442
|
-
if (width < w) {
|
|
443
|
-
width = w;
|
|
444
|
-
}
|
|
445
|
-
// Estimated with based on the text
|
|
446
|
-
if (self.width < width) {
|
|
447
|
-
self.width = width;
|
|
448
|
-
}
|
|
449
|
-
self.el.style.width = self.width + 'px';
|
|
450
|
-
}
|
|
451
|
-
// Min width for the container
|
|
452
|
-
self.container.parentNode.style.minWidth = self.width + 'px';
|
|
453
|
-
// Height
|
|
454
|
-
self.height = 400;
|
|
455
|
-
// Animation for mobile
|
|
456
|
-
if (document.documentElement.clientWidth < 800) {
|
|
457
|
-
self.animation = true;
|
|
458
461
|
}
|
|
459
462
|
// Data to be listed
|
|
460
463
|
self.rows = data;
|
|
@@ -745,7 +748,6 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
745
748
|
self.modal = {
|
|
746
749
|
closed: true,
|
|
747
750
|
focus: false,
|
|
748
|
-
width: self.width,
|
|
749
751
|
onopen: onopen,
|
|
750
752
|
onclose: onclose,
|
|
751
753
|
position: 'absolute',
|
|
@@ -762,9 +764,12 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
762
764
|
}
|
|
763
765
|
|
|
764
766
|
// Default width
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
767
|
+
if (self.width) {
|
|
768
|
+
// Dropdown
|
|
769
|
+
self.el.style.width = self.width + 'px';
|
|
770
|
+
}
|
|
771
|
+
// Adjust width and height
|
|
772
|
+
adjustDimensions(self.data);
|
|
768
773
|
|
|
769
774
|
// Focus out of the component
|
|
770
775
|
self.el.addEventListener('focusout', function (e) {
|
package/dist/style.css
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
.lm-dropdown .lm-modal {
|
|
36
36
|
padding: 0;
|
|
37
|
-
min-width:
|
|
37
|
+
min-width: 100%;
|
|
38
38
|
min-height: 5px;
|
|
39
39
|
border: 1px solid var(--lm-border-color, #ccc);
|
|
40
40
|
border-radius: 0;
|
|
@@ -50,9 +50,16 @@
|
|
|
50
50
|
box-sizing: border-box;
|
|
51
51
|
width: 100%;
|
|
52
52
|
background: var(--lm-background-color, #fff);
|
|
53
|
-
border: 1px solid var(--lm-border-color, #
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
border: 1px solid var(--lm-border-color, #767676);
|
|
54
|
+
border-radius: var(--lm-border-radius, 2px);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@media (prefers-color-scheme: dark) {
|
|
58
|
+
.lm-dropdown-input {
|
|
59
|
+
background: var(--lm-background-color, #3b3b3b);
|
|
60
|
+
border: 1px solid var(--lm-border-color, #858585);
|
|
61
|
+
color: var(--lm-text-color, #fff);
|
|
62
|
+
}
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
.lm-dropdown-input > br {
|
|
@@ -136,7 +143,7 @@
|
|
|
136
143
|
color: #000;
|
|
137
144
|
display: flex;
|
|
138
145
|
align-items: center;
|
|
139
|
-
padding: 4px 40px 4px
|
|
146
|
+
padding: 4px 40px 4px 10px;
|
|
140
147
|
position: relative;
|
|
141
148
|
box-sizing: border-box;
|
|
142
149
|
}
|
|
@@ -317,7 +324,6 @@
|
|
|
317
324
|
.lm-dropdown .lm-lazy {
|
|
318
325
|
max-height: 300px;
|
|
319
326
|
scrollbar-width: thin;
|
|
320
|
-
padding-bottom: 5px;
|
|
321
327
|
}
|
|
322
328
|
|
|
323
329
|
.lm-dropdown .lm-lazy::-webkit-scrollbar {
|
package/package.json
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"javascript plugins"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"lemonadejs": "^
|
|
18
|
-
"@lemonadejs/modal": "^
|
|
17
|
+
"lemonadejs": "^5.0.3",
|
|
18
|
+
"@lemonadejs/modal": "^5.0.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "dist/index.js",
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
|
-
"version": "
|
|
22
|
+
"version": "5.0.0"
|
|
23
23
|
}
|