-
Notifications
You must be signed in to change notification settings - Fork 420
/
editor.interface.ts
92 lines (73 loc) · 3.61 KB
/
editor.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import type { Column, EditorArguments, EditorValidationResult, GridOption } from './index';
/**
* SlickGrid Editor interface, more info can be found on the SlickGrid repo
* https://github.com/6pac/SlickGrid/wiki/Writing-custom-cell-editors
*/
export interface Editor {
/** item data context object */
dataContext?: any;
/** is the Editor disabled when we first open it? This could happen when we use "collectionAsync" and we wait for the "collection" to be filled before enabling the Editor. */
disabled?: boolean;
keyCaptureList?: string;
/** Initialize the Editor */
init: (args?: EditorArguments) => void;
/** Saves the Editor value */
save?: () => void;
/** Cancels the Editor */
cancel?: () => void;
/**
* if implemented, this will be called if the cell being edited is scrolled out of the view
* implement this is your UI is not appended to the cell itself or if you open any secondary
* selector controls (like a calendar for a datepicker input)
*/
hide?: () => void;
/** pretty much the opposite of hide */
show?: () => void;
/**
* if implemented, this will be called by the grid if any of the cell containers are scrolled
* and the absolute position of the edited cell is changed
* if your UI is constructed as a child of document BODY, implement this to update the
* position of the elements as the position of the cell changes
* @param {object} - cellBox position: { top, left, bottom, right, width, height, visible }
*/
position?: (position: any) => void;
/** remove all data, events & dom elements created in the constructor */
destroy: () => void;
/** set the focus on the main input control (if any) */
focus: () => void;
/**
* Deserialize the value(s) saved to "state" and apply them to the data item.
* This method may get called after the editor itself has been destroyed,
* treat it as an equivalent of a Java/C# "static" method - no instance variables should be accessed
*/
applyValue: (item: any, state: any) => void;
/**
* Load the value(s) from the data item and update the UI
* this method will be called immediately after the editor is initialized
* it may also be called by the grid if if the row/cell being edited is updated via grid.updateRow/updateCell
*/
loadValue: (item: any) => void;
preClick?: () => void;
/**
* Return the value(s) being edited by the user in a serialized form
* can be an arbitrary object
* the only restriction is that it must be a simple object that can be passed around even
* when the editor itself has been destroyed
*/
serializeValue: () => any;
/** return true if the value(s) being edited by the user has/have been changed */
isValueChanged: () => boolean;
/** Update the Editor DOM element value with a provided value, we can optionally apply the value to the item dataContext object */
setValue?: (value: any, isApplyingValue?: boolean, triggerOnCompositeEditorChange?: boolean) => void;
/**
* Validate user input and return the result along with the validation message.
* if the input is valid then the validation result output would be returning { valid:true, msg:null }
* The first argument "targetElm" is ONLY used internally by the Composite Editor in most cases you want to make this null or undefined
*/
validate: (targetElm?: HTMLElement, options?: any) => EditorValidationResult;
}
export type EditorConstructor = {
new <TData = any, C extends Column<TData> = Column<TData>, O extends GridOption<C> = GridOption<C>>(args?: EditorArguments<TData, C, O>): Editor;
/** Static flag used in makeActiveCellEditable. */
suppressClearOnEdit?: boolean;
};