mirror of https://github.com/zulip/zulip.git
typeahead: Rename input element type to be more specific.
This will be exported in an upcoming commit and a more specific name will make more sense when using this type in other files.
This commit is contained in:
parent
b86e37a979
commit
c118d66943
|
@ -178,7 +178,7 @@ const MENU_HTML = '<ul class="typeahead-menu"></ul>';
|
||||||
const ITEM_HTML = "<li><a></a></li>";
|
const ITEM_HTML = "<li><a></a></li>";
|
||||||
const MIN_LENGTH = 1;
|
const MIN_LENGTH = 1;
|
||||||
|
|
||||||
type InputElement =
|
type TypeaheadInputElement =
|
||||||
| {
|
| {
|
||||||
$element: JQuery;
|
$element: JQuery;
|
||||||
type: "contenteditable";
|
type: "contenteditable";
|
||||||
|
@ -189,7 +189,7 @@ type InputElement =
|
||||||
};
|
};
|
||||||
|
|
||||||
class Typeahead<ItemType extends string | object> {
|
class Typeahead<ItemType extends string | object> {
|
||||||
input_element: InputElement;
|
input_element: TypeaheadInputElement;
|
||||||
items: number;
|
items: number;
|
||||||
matcher: (item: ItemType, query: string) => boolean;
|
matcher: (item: ItemType, query: string) => boolean;
|
||||||
sorter: (items: ItemType[], query: string) => ItemType[];
|
sorter: (items: ItemType[], query: string) => ItemType[];
|
||||||
|
@ -197,13 +197,13 @@ class Typeahead<ItemType extends string | object> {
|
||||||
updater: (
|
updater: (
|
||||||
item: ItemType,
|
item: ItemType,
|
||||||
query: string,
|
query: string,
|
||||||
input_element: InputElement,
|
input_element: TypeaheadInputElement,
|
||||||
event?: JQuery.ClickEvent | JQuery.KeyUpEvent | JQuery.KeyDownEvent,
|
event?: JQuery.ClickEvent | JQuery.KeyUpEvent | JQuery.KeyDownEvent,
|
||||||
) => string | undefined;
|
) => string | undefined;
|
||||||
$container: JQuery;
|
$container: JQuery;
|
||||||
$menu: JQuery;
|
$menu: JQuery;
|
||||||
$header: JQuery;
|
$header: JQuery;
|
||||||
source: (query: string, input_element: InputElement) => ItemType[];
|
source: (query: string, input_element: TypeaheadInputElement) => ItemType[];
|
||||||
dropup: boolean;
|
dropup: boolean;
|
||||||
fixed: boolean;
|
fixed: boolean;
|
||||||
automated: () => boolean;
|
automated: () => boolean;
|
||||||
|
@ -226,7 +226,7 @@ class Typeahead<ItemType extends string | object> {
|
||||||
advanceKeyCodes: number[];
|
advanceKeyCodes: number[];
|
||||||
parentElement?: string;
|
parentElement?: string;
|
||||||
|
|
||||||
constructor(input_element: InputElement, options: TypeaheadOptions<ItemType>) {
|
constructor(input_element: TypeaheadInputElement, options: TypeaheadOptions<ItemType>) {
|
||||||
this.input_element = input_element;
|
this.input_element = input_element;
|
||||||
if (this.input_element.type === "contenteditable") {
|
if (this.input_element.type === "contenteditable") {
|
||||||
assert(this.input_element.$element.is("[contenteditable]"));
|
assert(this.input_element.$element.is("[contenteditable]"));
|
||||||
|
@ -694,7 +694,7 @@ class Typeahead<ItemType extends string | object> {
|
||||||
type TypeaheadOptions<ItemType> = {
|
type TypeaheadOptions<ItemType> = {
|
||||||
highlighter_html: (item: ItemType, query: string) => string | undefined;
|
highlighter_html: (item: ItemType, query: string) => string | undefined;
|
||||||
items: number;
|
items: number;
|
||||||
source: (query: string, input_element: InputElement) => ItemType[];
|
source: (query: string, input_element: TypeaheadInputElement) => ItemType[];
|
||||||
// optional options
|
// optional options
|
||||||
advanceKeyCodes?: number[];
|
advanceKeyCodes?: number[];
|
||||||
automated?: () => boolean;
|
automated?: () => boolean;
|
||||||
|
@ -716,13 +716,13 @@ type TypeaheadOptions<ItemType> = {
|
||||||
updater: (
|
updater: (
|
||||||
item: ItemType,
|
item: ItemType,
|
||||||
query: string,
|
query: string,
|
||||||
input_element: InputElement,
|
input_element: TypeaheadInputElement,
|
||||||
event?: JQuery.ClickEvent | JQuery.KeyUpEvent | JQuery.KeyDownEvent,
|
event?: JQuery.ClickEvent | JQuery.KeyUpEvent | JQuery.KeyDownEvent,
|
||||||
) => string | undefined;
|
) => string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function create<ItemType extends string | object>(
|
export function create<ItemType extends string | object>(
|
||||||
input_element: InputElement,
|
input_element: TypeaheadInputElement,
|
||||||
options: TypeaheadOptions<ItemType>,
|
options: TypeaheadOptions<ItemType>,
|
||||||
): void {
|
): void {
|
||||||
input_element.$element.data("typeahead", new Typeahead(input_element, options));
|
input_element.$element.data("typeahead", new Typeahead(input_element, options));
|
||||||
|
|
Loading…
Reference in New Issue