forked from Mobius1/Selectr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
68 lines (66 loc) · 2.06 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
export interface IData {
text: string;
value: string;
selected?: boolean;
disabled?: boolean;
children?: IData[];
}
export interface IOptions {
defaultSelected?: boolean;
multiple?: boolean;
searchable?: boolean;
allowDeselect?: boolean;
clearable?: boolean;
width?: number | string;
placeholder?: string;
maxSelections?: number;
taggable?: boolean;
tagSeperators?: string[];
tagPlaceholder?: string;
data?: IData[];
renderOption?(): string;
renderSelection?(): string;
pagination?: number;
nativeDropdown?: boolean;
closeOnScroll?: boolean;
sortSelected?: 'text' | 'value';
customClass?: string;
messages?: {
noResults?: string;
noOptions?: string;
maxSelections?: string;
tagDuplicate?: string;
searchPlaceholder?: string;
};
}
export default class Selectr {
constructor(select: HTMLSelectElement, options: IOptions);
public setValue(value: string | string[]): void;
public getValue(toObject?: boolean, toJson?: boolean): string | { text: string, value: string };
public search(query: string, anchor?: boolean): IData[];
public add(data: IData | IData[]): void;
public remove(data: number | string | number[] | string[]): void;
public removeAll(): void;
public serialize(toJson?: boolean): string | IData[];
public open(): void;
public close(): void;
public toggle(): void;
public clear(): void;
public reset(): void;
public disable(): void;
public enable(): void;
public on(event: 'selectr.init', fun: () => void): void;
public on(event: 'selectr.select', fun: (option: HTMLOptionElement) => void): void;
public on(event: 'selectr.deselect', fun: (option: HTMLOptionElement) => void): void;
public on(event: 'selectr.change', fun: (option: HTMLOptionElement) => void): void;
public on(event: 'selectr.open', fun: () => void): void;
public on(event: 'selectr.close', fun: () => void): void;
public on(event: 'selectr.clear', fun: () => void): void;
public on(event: 'selectr.reset', fun: () => void): void;
public on(event: 'selectr.paginate', fun: (data: {
items: number;
total: number;
page: number;
pages: number;
}) => void): void;
}