fixed issue with the leftover form choice potentially not being compatible with a dynamic compound when selected

This commit is contained in:
adueck 2022-09-23 12:33:14 +04:00
parent 2c41595b98
commit e9ef40f8a1
4 changed files with 27 additions and 14 deletions

View File

@ -28,6 +28,7 @@ import defualtTextOptions from "./lib/default-text-options";
import PhraseBuilder from "./components/vp-explorer/VPExplorer";
import useStickyState from "./lib/useStickyState";
import { EPExplorer } from "./library";
type VerbType = "simple" | "stative compound" | "dynamic compound";
const verbTypes: VerbType[] = [
"simple",

View File

@ -74,7 +74,9 @@ export function makeVPSelectionState(
externalComplement: takesExternalComplement(verb)
? { type: "complement", selection: { type: "unselected" }}
: undefined,
form: os ? os.form : { removeKing: false, shrinkServant: false },
form: (os && info.type !== "dynamic compound")
? os.form
: { removeKing: false, shrinkServant: false },
};
}

View File

@ -60,16 +60,25 @@ export function psJSXMap(ps: T.PsJSX, target: "p" | "f", dealWithString: (ps: T.
* @param f a function to transform the text
* @returns the JSX Element with all the text transformed
*/
export function JSXMap(e: JSX.Element, f: (s: string) => string): JSX.Element {
export function JSXTextTransform(
e: JSX.Element | string,
f: (s: string) => string
): JSX.Element | string {
if (typeof e === "string") {
return f(e);
}
return {
...e,
props: {
...e.props,
children: typeof e.props.children === "string"
? f(e.props.children)
: e.props.children.map((x: string | JSX.Element) => (
(typeof x === "string") ? f(x) : JSXMap(x, f)
)),
},
...e,
props: {
...e.props,
children:
typeof e.props.children === "string"
? f(e.props.children)
: Array.isArray(e.props.children)
? e.props.children.map((x: string | JSX.Element) => (
JSXTextTransform(x, f)
))
: JSXTextTransform(e.props.children, f)
}
};
}
}

View File

@ -24,7 +24,8 @@ export function isAdverbEntry(e: T.Entry | T.DictionaryEntry): e is T.AdverbEntr
}
export function isLocativeAdverbEntry(e: T.Entry | T.DictionaryEntry): e is T.LocativeAdverbEntry {
return isAdverbEntry(e) && e.c.includes("loc. adv.");
if ("entry" in e) return false;
return !!e.c?.includes("loc. adv.");
}
export function isNounOrAdjEntry(e: T.Entry): e is (T.NounEntry | T.AdjectiveEntry) {