-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathautocompleterOption.interface.ts
49 lines (40 loc) · 2.07 KB
/
autocompleterOption.interface.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
import type { AutocompleteItem, AutocompleteSettings } from 'autocompleter';
import type { Column } from './column.interface.js';
export interface AutoCompleterRenderItemDefinition {
/** which custom Layout to use? We created 2 custom styled layouts "twoRows" and "fourCorners", both layouts also support an optional icon on the left. */
layout: 'twoRows' | 'fourCorners';
/** templateCallback must be a callback function returning the renderItem template string that is used to dislay each row of the AutoComplete result */
templateCallback: (item: any) => string;
}
export type AutocompleteSearchItem =
| {
[labelName: string]: string;
}
| string;
export interface AutocompleterOption<T extends AutocompleteItem = any> extends Partial<AutocompleteSettings<T>> {
/** defaults to false, force the user to start typing a value in the search input */
forceUserInput?: boolean;
/** defaults to false, do we want to hide the clear date button? */
hideClearButton?: boolean;
/**
* renderItem option is to simply provide a Template and decide which custom Layout to use
*
* Note that this "renderItem" is just a shortcut and can be done with the following code:
* editor: { editorOptions: { className: { 'autocomplete': 'autocomplete-custom-2rows', render: (item: any) => this.renderItemCallbackWith2Rows(ul, item) }}
*/
renderItem?: AutoCompleterRenderItemDefinition;
/**
* defaults to false, do we want to trigger editor/filter callback on every stroke?
* Typically the answer is No, but it can be useful in unit tests
*/
triggerOnEveryKeyStroke?: boolean;
// --
// Events / Methods
// -----------------
/**
* Triggered when a value is selected from the autocomplete list.
* This is the same as the "select" callback and was created so that user don't overwrite exclusive usage of the "select" callback.
* Also compare to the "select", it has some extra arguments which are: row, cell, column, dataContext
*/
onSelectItem?: (item: any, row: number | undefined, cell: number | undefined, columnDef: Column, dataContext: any) => void;
}