decord/source/modules/share/useAutocompleter.tsx

67 lines
2 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 11248
// Function ID: 11249
2026-07-20 16:05:17 +00:00
// Name: useAutocompleter
2026-08-25 06:04:03 +00:00
// Dependencies: [32, 19, 5822, 7452, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-08-25 06:04:03 +00:00
// Module 11248 (useAutocompleter)
2026-08-24 06:08:38 +00:00
import closure_2 from "_slicedToArray" /* 32 */;
import closure_3 from "noop" /* 19 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/share/useAutocompleter.tsx");
2026-07-20 16:05:17 +00:00
export default function useAutocompleter(searchOptions) {
searchOptions = searchOptions.searchOptions;
2026-08-24 06:08:38 +00:00
dependencyMap = undefined;
2026-07-29 08:29:29 +00:00
let callback;
[tmp2, c1] = callback(React.useState({ results: [], query: "" }), 2);
2026-08-25 06:04:03 +00:00
const tmp3 = searchOptions(5822)(() => {
2026-07-29 08:29:29 +00:00
const obj = new searchOptions(_undefined[3])((results, query) => {
callback({ results, query });
2026-07-20 16:05:17 +00:00
});
2026-07-29 08:29:29 +00:00
obj.setLimit(20);
obj.search("");
return obj;
2026-07-20 16:05:17 +00:00
});
2026-07-29 08:29:29 +00:00
callback = tmp3;
const items = [tmp3];
2026-08-24 06:08:38 +00:00
const effect = React.useEffect(() => () => closure_2.destroy(), items);
2026-07-29 08:29:29 +00:00
const items1 = [tmp3, searchOptions];
2026-07-20 16:05:17 +00:00
const effect1 = React.useEffect(() => {
2026-07-29 08:29:29 +00:00
let tmp2 = null != searchOptions;
if (tmp2) {
2026-08-24 06:08:38 +00:00
tmp2 = tmp !== options.options;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp2) {
2026-08-24 06:08:38 +00:00
options.setOptions(tmp);
2026-07-20 16:05:17 +00:00
}
}, items1);
2026-07-29 08:29:29 +00:00
let tmp = callback(React.useState({ results: [], query: "" }), 2);
const items2 = [tmp3];
const merged = Object.assign(tmp2);
2026-07-20 16:05:17 +00:00
return {
search: React.useCallback((arg0) => {
({ query, resultTypes } = arg0);
2026-08-24 06:08:38 +00:00
let tmp = null != options.resultTypes;
2026-07-20 16:05:17 +00:00
if (tmp) {
2026-07-29 08:29:29 +00:00
const resultTypes2 = obj.resultTypes;
tmp = resultTypes.length === resultTypes2.size && resultTypes.every((arg0) => resultTypes2.has(arg0));
const tmp2 = resultTypes.length === resultTypes2.size && resultTypes.every((arg0) => resultTypes2.has(arg0));
2026-07-20 16:05:17 +00:00
}
if (!tmp) {
2026-07-29 08:29:29 +00:00
obj.setResultTypes(resultTypes);
2026-07-20 16:05:17 +00:00
let num = 20;
if (1 === resultTypes.length) {
num = 50;
}
2026-07-29 08:29:29 +00:00
obj.setLimit(num);
2026-07-20 16:05:17 +00:00
}
let str = "";
if ("" !== query.trim()) {
str = query;
}
2026-08-24 06:08:38 +00:00
options.search(str);
2026-07-20 16:05:17 +00:00
}, items2)
};
};