@lemonadejs/dropdown 3.0.10 → 3.0.12
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 +67 -55
- package/dist/index.js +37 -25
- package/dist/react.d.ts +15 -0
- package/dist/style.css +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,58 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Official Type definitions for LemonadeJS plugins
|
|
3
|
+
* https://lemonadejs.net
|
|
4
|
+
* Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
declare function Dropdown(el: HTMLElement, options?: Dropdown.Options): Dropdown.Instance;
|
|
8
|
+
|
|
9
|
+
declare namespace Dropdown {
|
|
10
|
+
interface Item {
|
|
11
|
+
/** Value of the selected item. */
|
|
12
|
+
value?: string | number;
|
|
13
|
+
/** Description of the item */
|
|
14
|
+
text?: string;
|
|
15
|
+
/** Icon of the item */
|
|
16
|
+
image?: string;
|
|
17
|
+
/** Name of the group where the item belongs to */
|
|
18
|
+
group?: string;
|
|
19
|
+
/** Keywords to help finding one item */
|
|
20
|
+
synonym?: string[];
|
|
21
|
+
/** Item is disabled */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** Color for the item */
|
|
24
|
+
color?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface Options {
|
|
28
|
+
/** Preloaded data items for the dropdown */
|
|
29
|
+
data?: Item[];
|
|
30
|
+
/** Format type of the data, typically { id: name } or { value: text } */
|
|
31
|
+
format?: number;
|
|
32
|
+
/** Indicates if multiple item selection is allowed */
|
|
33
|
+
multiple?: boolean;
|
|
34
|
+
/** Enables the autocomplete feature for user input */
|
|
35
|
+
autocomplete?: boolean;
|
|
36
|
+
/** Rendering style of the dropdown: 'default', 'picker', 'searchbar' or inline */
|
|
37
|
+
type?: 'default' | 'picker' | 'searchbar' | 'inline',
|
|
38
|
+
/** Defines the dropdown's width */
|
|
39
|
+
width?: number;
|
|
40
|
+
/** The initial value of the dropdown */
|
|
41
|
+
value?: string | string[] | number | number[];
|
|
42
|
+
/** Placeholder text for the dropdown */
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
/** Event handler for value changes */
|
|
45
|
+
onchange?: (el: HTMLElement, obj: object, oldValue: string, newValue: string) => void;
|
|
46
|
+
/** Event handler for when the dropdown is ready */
|
|
47
|
+
onload?: (el: HTMLElement, obj: object, data: any, val: any) => void;
|
|
48
|
+
/** Event handler for when the dropdown opens */
|
|
49
|
+
onopen?: (el: HTMLElement) => void;
|
|
50
|
+
/** Event handler for when the dropdown closes */
|
|
51
|
+
onclose?: (el: HTMLElement) => void;
|
|
52
|
+
/** Event handler for when a new option is added to the dropdown */
|
|
53
|
+
oninsert?: (obj: object, item: Item, newItem: Item) => void;
|
|
54
|
+
/** Event handler for just before a new option is added to the dropdown */
|
|
55
|
+
onbeforeinsert?: (obj: object, item: Item) => void;
|
|
56
|
+
/** Event handler for before a search on autocomplete is performed */
|
|
57
|
+
onbeforesearch?: (obj: object, ajaxRequest: object) => boolean | null;
|
|
58
|
+
/** Event handler for processing search results */
|
|
59
|
+
onsearch?: (obj: object, result: object) => void;
|
|
60
|
+
}
|
|
17
61
|
|
|
18
|
-
interface
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
multiple?: boolean;
|
|
25
|
-
/** Enables the autocomplete feature for user input */
|
|
26
|
-
autocomplete?: boolean;
|
|
27
|
-
/** Rendering style of the dropdown: 'default', 'picker', 'searchbar' or inline */
|
|
28
|
-
type?: 'default' | 'picker' | 'searchbar' | 'inline',
|
|
29
|
-
/** Defines the dropdown's width */
|
|
30
|
-
width?: number;
|
|
31
|
-
/** The initial value of the dropdown */
|
|
32
|
-
value?: string | string[] | number | number[];
|
|
33
|
-
/** Placeholder text for the dropdown */
|
|
34
|
-
placeholder?: string;
|
|
35
|
-
/** Event handler for value changes */
|
|
36
|
-
onchange?: (el: HTMLElement, obj: Dropdown, oldValue: string, newValue: string) => void;
|
|
37
|
-
/** Event handler for when the dropdown is ready */
|
|
38
|
-
onload?: (el: HTMLElement, obj: Dropdown, data: any, val: any) => void;
|
|
39
|
-
/** Event handler for when the dropdown opens */
|
|
40
|
-
onopen?: (el: HTMLElement) => void;
|
|
41
|
-
/** Event handler for when the dropdown closes */
|
|
42
|
-
onclose?: (el: HTMLElement) => void;
|
|
43
|
-
/** Event handler for when a new option is added to the dropdown */
|
|
44
|
-
oninsert?: (obj: Dropdown, item: DropdownItem, newItem: DropdownItem) => void;
|
|
45
|
-
/** Event handler for just before a new option is added to the dropdown */
|
|
46
|
-
onbeforeinsert?: (obj: Dropdown, item: DropdownItem) => void;
|
|
47
|
-
/** Event handler for before a search on autocomplete is performed */
|
|
48
|
-
onbeforesearch?: (obj: Dropdown, ajaxRequest: object) => boolean | null;
|
|
49
|
-
/** Event handler for processing search results */
|
|
50
|
-
onsearch?: (obj: Dropdown, result: object) => void;
|
|
62
|
+
interface Instance {
|
|
63
|
+
/** Internal type */
|
|
64
|
+
type: 'dropdown';
|
|
65
|
+
/** Current internal value */
|
|
66
|
+
value: Record<number, string>;
|
|
67
|
+
}
|
|
51
68
|
}
|
|
52
69
|
|
|
53
|
-
export
|
|
54
|
-
/** Internal type */
|
|
55
|
-
type: 'dropdown';
|
|
56
|
-
/** Current internal value */
|
|
57
|
-
value: Record<number, string>;
|
|
58
|
-
}
|
|
70
|
+
export default Dropdown;
|
package/dist/index.js
CHANGED
|
@@ -239,30 +239,34 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
239
239
|
let lazyloading = null;
|
|
240
240
|
|
|
241
241
|
const setData = function() {
|
|
242
|
-
// Re-order to make sure groups are in sequence
|
|
243
|
-
self.data.sort((a, b) => {
|
|
244
|
-
// Compare groups
|
|
245
|
-
if (a.group && b.group) {
|
|
246
|
-
return a.group.localeCompare(b.group);
|
|
247
|
-
}
|
|
248
|
-
return 0;
|
|
249
|
-
});
|
|
250
|
-
let group = '';
|
|
251
|
-
// Define group headers
|
|
252
|
-
self.data.map((v) => {
|
|
253
|
-
// Compare groups
|
|
254
|
-
if (v.group && v.group !== group) {
|
|
255
|
-
v.header = true;
|
|
256
|
-
group = v.group;
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
242
|
// Estimate width
|
|
260
243
|
let width = self.width;
|
|
261
|
-
//
|
|
262
|
-
self.data.
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
244
|
+
// Re-order to make sure groups are in sequence
|
|
245
|
+
if (self.data && self.data.length) {
|
|
246
|
+
self.data.sort((a, b) => {
|
|
247
|
+
// Compare groups
|
|
248
|
+
if (a.group && b.group) {
|
|
249
|
+
return a.group.localeCompare(b.group);
|
|
250
|
+
}
|
|
251
|
+
return 0;
|
|
252
|
+
});
|
|
253
|
+
let group = '';
|
|
254
|
+
// Define group headers
|
|
255
|
+
self.data.map((v) => {
|
|
256
|
+
// Compare groups
|
|
257
|
+
if (v && v.group && v.group !== group) {
|
|
258
|
+
v.header = true;
|
|
259
|
+
group = v.group;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
// Width && values
|
|
263
|
+
self.data.map(function (s) {
|
|
264
|
+
// Estimated width of the element
|
|
265
|
+
if (s.text) {
|
|
266
|
+
width = Math.max(width, s.text.length * 8);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
266
270
|
// Adjust the width
|
|
267
271
|
let w = self.input.offsetWidth;
|
|
268
272
|
if (width < w) {
|
|
@@ -391,10 +395,18 @@ if (!Modal && typeof (require) === 'function') {
|
|
|
391
395
|
}
|
|
392
396
|
|
|
393
397
|
const getValue = function() {
|
|
394
|
-
if (
|
|
395
|
-
|
|
398
|
+
if (self.multiple) {
|
|
399
|
+
if (value && value.length) {
|
|
400
|
+
return value.filter(v => v.selected).map(i => i.value);
|
|
401
|
+
}
|
|
402
|
+
return [];
|
|
403
|
+
} else {
|
|
404
|
+
if (value && value.length) {
|
|
405
|
+
return value[0].value;
|
|
406
|
+
} else {
|
|
407
|
+
return '';
|
|
408
|
+
}
|
|
396
409
|
}
|
|
397
|
-
return [];
|
|
398
410
|
}
|
|
399
411
|
|
|
400
412
|
const onclose = function() {
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official Type definitions for the LemonadeJS plugins
|
|
3
|
+
* https://lemonadejs.net
|
|
4
|
+
* Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
*/
|
|
6
|
+
import Component from './index';
|
|
7
|
+
|
|
8
|
+
interface Dropdown {
|
|
9
|
+
(): any
|
|
10
|
+
[key: string]: any
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare function Dropdown<Dropdown>(props: Component.Options): any;
|
|
14
|
+
|
|
15
|
+
export default Dropdown;
|
package/dist/style.css
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
top: 2px;
|
|
58
58
|
background-repeat: no-repeat;
|
|
59
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 .
|
|
60
|
+
transition: transform .1s ease-in-out;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
|
package/package.json
CHANGED