@lemonadejs/dropdown 5.8.0 → 5.8.1
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.d.ts +3 -1
- package/dist/index.js +30 -2
- package/dist/style.css +4 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -102,7 +102,9 @@ declare namespace Dropdown {
|
|
|
102
102
|
isClosed: () => boolean;
|
|
103
103
|
/** Get current value */
|
|
104
104
|
getValue: () => number | string | number[] | string[];
|
|
105
|
-
/** Get current
|
|
105
|
+
/** Get current text (label). Returns string if single, string[] if multiple */
|
|
106
|
+
getText: () => string | string[];
|
|
107
|
+
/** Set current value */
|
|
106
108
|
setValue: (value: number | string | number[] | string[]) => void;
|
|
107
109
|
/** Get current data */
|
|
108
110
|
getData: () => Item[];
|
package/dist/index.js
CHANGED
|
@@ -539,7 +539,13 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
539
539
|
|
|
540
540
|
if (Array.isArray(data)) {
|
|
541
541
|
data.map(function (s) {
|
|
542
|
-
s.selected = newValue.some(v =>
|
|
542
|
+
s.selected = newValue.some(v => {
|
|
543
|
+
// Use strict equality when either value is empty string to avoid '' == 0 being true
|
|
544
|
+
if (v === '' || s.value === '') {
|
|
545
|
+
return v === s.value;
|
|
546
|
+
}
|
|
547
|
+
return v == s.value;
|
|
548
|
+
});
|
|
543
549
|
if (s.selected) {
|
|
544
550
|
value.push(s);
|
|
545
551
|
}
|
|
@@ -574,6 +580,20 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
574
580
|
return null;
|
|
575
581
|
}
|
|
576
582
|
|
|
583
|
+
const getText = function () {
|
|
584
|
+
if (self.multiple) {
|
|
585
|
+
if (value && value.length) {
|
|
586
|
+
return value.filter(v => v.selected).map(i => i.text);
|
|
587
|
+
}
|
|
588
|
+
} else {
|
|
589
|
+
if (value && value.length) {
|
|
590
|
+
return value[0].text;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
|
|
577
597
|
const onopen = function () {
|
|
578
598
|
self.state = true;
|
|
579
599
|
// Value
|
|
@@ -744,7 +764,11 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
744
764
|
|
|
745
765
|
// Debounce the search with 300ms delay
|
|
746
766
|
searchTimeout = setTimeout(() => {
|
|
747
|
-
|
|
767
|
+
let url = self.url;
|
|
768
|
+
url += url.indexOf('?') === -1 ? '?' : '&';
|
|
769
|
+
url += `q=${query}`;
|
|
770
|
+
|
|
771
|
+
fetch(url, http).then(r => r.json()).then(resetData).catch((error) => {
|
|
748
772
|
resetData([]);
|
|
749
773
|
});
|
|
750
774
|
}, 300);
|
|
@@ -1024,6 +1048,10 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
1024
1048
|
return self.value;
|
|
1025
1049
|
}
|
|
1026
1050
|
|
|
1051
|
+
self.getText = function() {
|
|
1052
|
+
return getText();
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1027
1055
|
self.setValue = function(v) {
|
|
1028
1056
|
self.value = v;
|
|
1029
1057
|
}
|
package/dist/style.css
CHANGED
package/package.json
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"javascript plugins"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"lemonadejs": "^5.3.
|
|
17
|
+
"lemonadejs": "^5.3.6",
|
|
18
18
|
"@lemonadejs/modal": "^5.8.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "dist/index.js",
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
|
-
"version": "5.8.
|
|
22
|
+
"version": "5.8.1"
|
|
23
23
|
}
|