js: Convert static/js/search_pill.js to ES6 module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-10 08:09:55 -08:00 committed by Tim Abbott
parent e16687af83
commit 8a6fdb662a
8 changed files with 17 additions and 20 deletions

View File

@ -228,7 +228,6 @@
"scroll_bar": false,
"scroll_util": false,
"search": false,
"search_pill": false,
"search_pill_widget": false,
"search_suggestion": false,
"sent_messages": false,

View File

@ -19,7 +19,6 @@ zrequire("FetchStatus", "js/fetch_status");
zrequire("MessageListData", "js/message_list_data");
zrequire("unread");
const narrow = zrequire("narrow");
zrequire("search_pill");
const channel = set_global("channel", {});
set_global("compose", {});

View File

@ -153,7 +153,6 @@ import "../emoji_picker";
import "../compose_ui";
import "../panels";
import "../recent_topics";
import "../search_pill";
import "../search_pill_widget";
import "../stream_ui_updates";
import "../spoilers";

View File

@ -96,7 +96,6 @@ declare let rtl: any;
declare let scroll_bar: any;
declare let scroll_util: any;
declare let search: any;
declare let search_pill: any;
declare let search_pill_widget: any;
declare let search_suggestion: any;
declare let sent_messages: any;

View File

@ -1,6 +1,7 @@
"use strict";
const people = require("./people");
const search_pill = require("./search_pill");
const topic_generator = require("./topic_generator");
const util = require("./util");

View File

@ -1,5 +1,7 @@
"use strict";
const search_pill = require("./search_pill");
// Exported for unit testing
exports.is_using_input_method = false;

View File

@ -1,28 +1,26 @@
"use strict";
exports.create_item_from_search_string = function (search_string) {
export function create_item_from_search_string(search_string) {
const operator = Filter.parse(search_string);
const description = Filter.describe(operator);
return {
display_value: search_string,
description,
};
};
}
exports.get_search_string_from_item = function (item) {
export function get_search_string_from_item(item) {
return item.display_value;
};
}
exports.create_pills = function (pill_container) {
export function create_pills(pill_container) {
const pills = input_pill.create({
container: pill_container,
create_item_from_text: exports.create_item_from_search_string,
get_text_from_item: exports.get_search_string_from_item,
create_item_from_text: create_item_from_search_string,
get_text_from_item: get_search_string_from_item,
});
return pills;
};
}
exports.append_search_string = function (search_string, pill_widget) {
export function append_search_string(search_string, pill_widget) {
const operators = Filter.parse(search_string);
for (const operator of operators) {
const input = Filter.unparse([operator]);
@ -31,12 +29,10 @@ exports.append_search_string = function (search_string, pill_widget) {
if (pill_widget.clear_text !== undefined) {
pill_widget.clear_text();
}
};
}
exports.get_search_string_for_current_filter = function (pill_widget) {
export function get_search_string_for_current_filter(pill_widget) {
const items = pill_widget.items();
const search_strings = items.map((item) => item.display_value);
return search_strings.join(" ");
};
window.search_pill = exports;
}

View File

@ -1,5 +1,7 @@
"use strict";
const search_pill = require("./search_pill");
exports.initialize = function () {
if (!page_params.search_pills_enabled) {
return;