import { makeNounSelection, } from "./picker-tools"; import * as T from "../../types"; import ButtonSelect from "../ButtonSelect"; import InlinePs from "../InlinePs"; // import { useState } from "react"; // import { isFemNounEntry, isPattern1Entry, isPattern2Entry, isPattern3Entry, isPattern4Entry, isPattern5Entry, isPattern6FemEntry } from "../../lib/type-predicates"; import EntrySelect from "../EntrySelect"; // const filterOptions = [ // { // label: "1", // value: "1", // }, // { // label: "2", // value: "2", // }, // { // label: "3", // value: "3", // }, // { // label: "4", // value: "4", // }, // { // label: "5", // value: "5", // }, // { // label: "6", // value: "6", // }, // ]; // type FilterPattern = "1" | "2" | "3" | "4" | "5" | "6"; // function nounFilter(p: FilterPattern | undefined) { // return p === undefined // ? () => true // : (p === "1") // ? isPattern1Entry // : (p === "2") // ? isPattern2Entry // : (p === "3") // ? isPattern3Entry // : (p === "4") // ? isPattern4Entry // : (p === "5") // ? isPattern5Entry // : (p === "6") // ? (n: NounEntry) => (isFemNounEntry(n) && isPattern6FemEntry(n)) // : () => true; // } function NPNounPicker(props: ({ nouns: T.NounEntry[], } | { nouns: (s: string) => T.NounEntry[], getNounByTs: (ts: number) => T.NounEntry | undefined; }) & { noun: T.NounSelection | undefined, onChange: (p: T.NounSelection | undefined) => void, clearButton?: JSX.Element, opts: T.TextOptions, }) { // const [patternFilter, setPatternFilter] = useState(undefined); // const [showFilter, setShowFilter] = useState(false) // const nounsFiltered = props.nouns // .filter(nounFilter(patternFilter)) // .sort((a, b) => (a.p.localeCompare(b.p, "af-PS"))); function onEntrySelect(entry: T.NounEntry | undefined) { if (!entry) { return props.onChange(undefined); } props.onChange(makeNounSelection(entry)); } // function handleFilterClose() { // setPatternFilter(undefined); // setShowFilter(false); // } return
{props.clearButton} {/* {(!showFilter && !(noun?.dynamicComplement)) &&
} */}
{/* {showFilter &&
Filter by inflection pattern
X
} */} {!(props.noun && props.noun.dynamicComplement) ?
:
{props.noun &&
Included in Dyn. Compound:
{{ p: props.noun.entry.p, f: props.noun.entry.f }}
{props.noun.entry.e}
}
} {props.noun &&
{props.noun.changeGender ? { if (!props.noun || !props.noun.changeGender) return; props.onChange(props.noun.changeGender(g)); }} /> : props.noun.gender === "masc" ? "Masc." : "Fem."}
{props.noun.changeNumber ? { if (!props.noun || !props.noun.changeNumber) return; props.onChange(props.noun.changeNumber(n)); }} /> : props.noun.number === "singular" ? "Sing." : "Plur."}
}
; } export default NPNounPicker;