diff --git a/website/src/repl/components/panel/Reference.jsx b/website/src/repl/components/panel/Reference.jsx index 04297c0b..6411ea7b 100644 --- a/website/src/repl/components/panel/Reference.jsx +++ b/website/src/repl/components/panel/Reference.jsx @@ -1,5 +1,7 @@ +import { useMemo, useState } from 'react'; + import jsdocJson from '../../../../../doc.json'; -const visibleFunctions = jsdocJson.docs +const availableFunctions = jsdocJson.docs .filter(({ name, description }) => name && !name.startsWith('_') && !!description) .sort((a, b) => /* a.meta.filename.localeCompare(b.meta.filename) + */ a.name.localeCompare(b.name)); @@ -10,9 +12,29 @@ const getInnerText = (html) => { }; export function Reference() { + const [search, setSearch] = useState(''); + + const visibleFunctions = useMemo(() => { + return availableFunctions.filter((entry) => { + if (!search) { + return true; + } + + return entry.name.includes(search) || (entry.synonyms?.some((s) => s.includes(search)) ?? false); + }); + }, [search]); + return (
+
+ setSearch(event.target.value)} + /> +
{visibleFunctions.map((entry, i) => (