| 1 |
/// <reference types="backbone" /> |
| 2 |
import { CoreDOMWidgetModel } from './widget_core'; |
| 3 |
import { DOMWidgetView, Dict } from '@jupyter-widgets/base'; |
| 4 |
/** |
| 5 |
* Selection class which keeps track on selected indices. |
| 6 |
*/ |
| 7 |
declare class Selection { |
| 8 |
constructor(start: number, dx: number, max: number); |
| 9 |
/** |
| 10 |
* Check if a given index is currently selected. |
| 11 |
*/ |
| 12 |
isSelected(index: number): boolean; |
| 13 |
/** |
| 14 |
* Update selection |
| 15 |
*/ |
| 16 |
updateSelection(dx: number): void; |
| 17 |
private start; |
| 18 |
private dx; |
| 19 |
private max; |
| 20 |
} |
| 21 |
declare class TagsInputBaseModel extends CoreDOMWidgetModel { |
| 22 |
defaults(): Backbone.ObjectHash; |
| 23 |
} |
| 24 |
declare abstract class TagsInputBaseView extends DOMWidgetView { |
| 25 |
/** |
| 26 |
* Called when view is rendered. |
| 27 |
*/ |
| 28 |
render(): void; |
| 29 |
/** |
| 30 |
* Update the contents of this view |
| 31 |
* |
| 32 |
* Called when the model is changed. The model may have been |
| 33 |
* changed by another view or by a state update from the back-end. |
| 34 |
*/ |
| 35 |
update(): void; |
| 36 |
/** |
| 37 |
* Update the auto-completion list |
| 38 |
*/ |
| 39 |
updateAutocomplete(): void; |
| 40 |
/** |
| 41 |
* Update the auto-completion list |
| 42 |
*/ |
| 43 |
updatePlaceholder(): void; |
| 44 |
/** |
| 45 |
* Update the tags, called when the selection has changed and we need to update the tags CSS |
| 46 |
*/ |
| 47 |
updateTags(): void; |
| 48 |
/** |
| 49 |
* Handle a new value is added from the input element |
| 50 |
*/ |
| 51 |
handleValueAdded(event: Event): void; |
| 52 |
/** |
| 53 |
* Add a new tag with a value of `tagValue` at the `index` position |
| 54 |
* Return true if the tag was correctly added, false otherwise |
| 55 |
*/ |
| 56 |
addTag(index: number, tagValue: string): boolean; |
| 57 |
/** |
| 58 |
* Resize the input element |
| 59 |
*/ |
| 60 |
resizeInput(): void; |
| 61 |
/** |
| 62 |
* Handle key events on the input element |
| 63 |
*/ |
| 64 |
handleKeyEvent(event: KeyboardEvent): void; |
| 65 |
/** |
| 66 |
* Function that gets called when a tag with a given `value` is being dragged. |
| 67 |
*/ |
| 68 |
ondragstart(event: DragEvent, index: number, tagValue: any, origin: string): void; |
| 69 |
/** |
| 70 |
* Function that gets called when a tag has been dragged on the tag at the `index` position. |
| 71 |
*/ |
| 72 |
ondrop(event: DragEvent, index: number): void; |
| 73 |
ondragover(event: DragEvent): void; |
| 74 |
ondragenter(event: DragEvent, index: number): void; |
| 75 |
ondragend(): void; |
| 76 |
/** |
| 77 |
* Select tags from `start` to `start + dx` not included. |
| 78 |
*/ |
| 79 |
select(start: number, dx: number): void; |
| 80 |
/** |
| 81 |
* Remove all the selected tags. |
| 82 |
*/ |
| 83 |
removeSelectedTags(): void; |
| 84 |
/** |
| 85 |
* Remove a tag given its index in the list |
| 86 |
*/ |
| 87 |
removeTag(tagIndex: number): void; |
| 88 |
/** |
| 89 |
* Focus on the input element |
| 90 |
*/ |
| 91 |
focus(): void; |
| 92 |
/** |
| 93 |
* Lose focus on the input element |
| 94 |
*/ |
| 95 |
loseFocus(): void; |
| 96 |
preinitialize(): void; |
| 97 |
/** |
| 98 |
* Validate an input tag typed by the user, returning the correct tag type. This should be overridden in subclasses. |
| 99 |
*/ |
| 100 |
validateValue(value: string): any; |
| 101 |
abstract createTag(value: any, index: number, selected: boolean): HTMLElement; |
| 102 |
abstract updateTag(tag: HTMLElement, value: any, index: number, selected: boolean): void; |
| 103 |
el: HTMLDivElement; |
| 104 |
taginputWrapper: HTMLDivElement; |
| 105 |
taginput: HTMLInputElement; |
| 106 |
autocompleteList: HTMLDataListElement; |
| 107 |
tags: HTMLElement[]; |
| 108 |
hoveredTag: HTMLElement | null; |
| 109 |
hoveredTagIndex: number | null; |
| 110 |
datalistID: string; |
| 111 |
inputIndex: number; |
| 112 |
selection: null | Selection; |
| 113 |
preventLoosingFocus: boolean; |
| 114 |
model: TagsInputBaseModel; |
| 115 |
} |
| 116 |
export declare class TagsInputModel extends TagsInputBaseModel { |
| 117 |
defaults(): Backbone.ObjectHash; |
| 118 |
} |
| 119 |
export declare class TagsInputView extends TagsInputBaseView { |
| 120 |
/** |
| 121 |
* Create the string tag |
| 122 |
*/ |
| 123 |
createTag(value: string, index: number, selected: boolean): HTMLDivElement; |
| 124 |
/** |
| 125 |
* Returns the text that should be displayed in the tag element |
| 126 |
*/ |
| 127 |
getTagText(value: string): string; |
| 128 |
/** |
| 129 |
* Update a given tag |
| 130 |
*/ |
| 131 |
updateTag(tag: HTMLDivElement, value: any, index: number, selected: boolean): void; |
| 132 |
model: TagsInputModel; |
| 133 |
static class_map: Dict<string>; |
| 134 |
} |
| 135 |
export declare class ColorsInputModel extends TagsInputBaseModel { |
| 136 |
defaults(): Backbone.ObjectHash; |
| 137 |
} |
| 138 |
export declare class ColorsInputView extends TagsInputBaseView { |
| 139 |
/** |
| 140 |
* Create the Color tag |
| 141 |
*/ |
| 142 |
createTag(value: string, index: number, selected: boolean): HTMLDivElement; |
| 143 |
/** |
| 144 |
* Update a given tag |
| 145 |
*/ |
| 146 |
updateTag(tag: HTMLDivElement, value: any, index: number, selected: boolean): void; |
| 147 |
/** |
| 148 |
* Validate an input tag typed by the user, returning the correct tag type. This should be overridden in subclasses. |
| 149 |
*/ |
| 150 |
validateValue(value: string): any; |
| 151 |
model: ColorsInputModel; |
| 152 |
} |
| 153 |
declare abstract class NumbersInputModel extends TagsInputModel { |
| 154 |
defaults(): Backbone.ObjectHash; |
| 155 |
} |
| 156 |
declare abstract class NumbersInputView extends TagsInputView { |
| 157 |
render(): void; |
| 158 |
/** |
| 159 |
* Returns the text that should be displayed in the tag element |
| 160 |
*/ |
| 161 |
getTagText(value: string): string; |
| 162 |
/** |
| 163 |
* Validate an input tag typed by the user, returning the correct tag type. This should be overridden in subclasses. |
| 164 |
*/ |
| 165 |
validateValue(value: string): any; |
| 166 |
abstract parseNumber(value: string): number; |
| 167 |
formatter: (value: number) => string; |
| 168 |
} |
| 169 |
export declare class FloatsInputModel extends NumbersInputModel { |
| 170 |
defaults(): Backbone.ObjectHash; |
| 171 |
} |
| 172 |
export declare class FloatsInputView extends NumbersInputView { |
| 173 |
parseNumber(value: string): number; |
| 174 |
model: FloatsInputModel; |
| 175 |
} |
| 176 |
export declare class IntsInputModel extends NumbersInputModel { |
| 177 |
defaults(): Backbone.ObjectHash; |
| 178 |
} |
| 179 |
export declare class IntsInputView extends NumbersInputView { |
| 180 |
parseNumber(value: string): number; |
| 181 |
model: IntsInputModel; |
| 182 |
} |
| 183 |
export {}; |
| 184 |
//# sourceMappingURL=widget_tagsinput.d.ts.map |