67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
// Module ID: 9875
|
|
// Function ID: 76491
|
|
// Name: useAutocompleter
|
|
// Dependencies: []
|
|
// Exports: default
|
|
|
|
// Module 9875 (useAutocompleter)
|
|
let closure_2 = importDefault(dependencyMap[0]);
|
|
let closure_3 = importAll(dependencyMap[1]);
|
|
const result = arg1(dependencyMap[4]).fileFinishedImporting("modules/share/useAutocompleter.tsx");
|
|
|
|
export default function useAutocompleter(searchOptions) {
|
|
searchOptions = searchOptions.searchOptions;
|
|
const importDefault = searchOptions;
|
|
const tmp = callback(React.useState({ results: [], query: "" }), 2);
|
|
let closure_1 = tmp[1];
|
|
const tmp2 = importDefault(closure_1[2])(() => {
|
|
let tmp = searchOptions(closure_1[3]);
|
|
tmp = new tmp((results, query) => {
|
|
callback({ results, query });
|
|
});
|
|
tmp.setLimit(20);
|
|
tmp.search("");
|
|
return tmp;
|
|
});
|
|
const callback = tmp2;
|
|
const items = [tmp2];
|
|
const effect = React.useEffect(() => () => closure_2.destroy(), items);
|
|
const items1 = [tmp2, searchOptions];
|
|
const effect1 = React.useEffect(() => {
|
|
let tmp = null != searchOptions;
|
|
if (tmp) {
|
|
tmp = searchOptions !== tmp2.options;
|
|
}
|
|
if (tmp) {
|
|
tmp2.setOptions(searchOptions);
|
|
}
|
|
}, items1);
|
|
const items2 = [tmp2];
|
|
const merged = Object.assign(tmp[0]);
|
|
return {
|
|
search: React.useCallback((arg0) => {
|
|
let query;
|
|
let resultTypes;
|
|
({ query, resultTypes } = arg0);
|
|
let tmp = null != tmp2.resultTypes;
|
|
if (tmp) {
|
|
tmp = function isArrayEqualSet(resultTypes, resultTypes2) {
|
|
return resultTypes.length === resultTypes2.size && resultTypes.every((arg0) => arg1.has(arg0));
|
|
}(resultTypes, tmp2.resultTypes);
|
|
}
|
|
if (!tmp) {
|
|
tmp2.setResultTypes(resultTypes);
|
|
let num = 20;
|
|
if (1 === resultTypes.length) {
|
|
num = 50;
|
|
}
|
|
tmp2.setLimit(num);
|
|
}
|
|
let str = "";
|
|
if ("" !== query.trim()) {
|
|
str = query;
|
|
}
|
|
tmp2.search(str);
|
|
}, items2)
|
|
};
|
|
};
|