From 693e8dd9ab0858cb67fde0c1d2393ec0e08b86b6 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Mon, 2 May 2022 19:38:45 -0500 Subject: [PATCH] fixing make saveable vps data --- package.json | 2 +- src/components/np-picker/NPPicker.tsx | 7 +- src/components/vp-explorer/VPExplorer.tsx | 2 +- src/components/vp-explorer/VerbPicker.tsx | 21 +++--- src/components/vp-explorer/verb-selection.ts | 68 +++++++++++--------- src/types.ts | 8 +-- 6 files changed, 54 insertions(+), 54 deletions(-) diff --git a/package.json b/package.json index 5fe4212..60d3ac9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "2.3.5", + "version": "2.3.6", "author": "lingdocs.com", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "homepage": "https://verbs.lingdocs.com", diff --git a/src/components/np-picker/NPPicker.tsx b/src/components/np-picker/NPPicker.tsx index b143e4f..ae80630 100644 --- a/src/components/np-picker/NPPicker.tsx +++ b/src/components/np-picker/NPPicker.tsx @@ -1,15 +1,12 @@ import PronounPicker from "./NPPronounPicker"; import NounPicker from "./NPNounPicker"; import ParticiplePicker from "./NPParticiplePicker"; -// import { getEnglishPronoun } from "../../lib/english-pronoun-tools"; -// import { ButtonSelect } from "@lingdocs/pashto-inflector"; import { randomPerson, } from "../../lib/np-tools"; import { useState, useEffect } from "react"; import * as T from "../../types"; import { isSecondPerson } from "../../lib/phrase-building/vp-tools"; -// import { capitalizeFirstLetter } from "../../lib/text-tools"; const npTypes: T.NPType[] = ["pronoun", "noun", "participle"]; @@ -33,6 +30,7 @@ function NPPicker(props: { const [npType, setNpType] = useState(props.np ? props.np.type : undefined); useEffect(() => { setNpType(props.np ? props.np.type : undefined); + setAddingPoss(false); }, [props.np]); function handleClear() { if (props.np && props.np.type === "noun" && props.np.dynamicComplement) return; @@ -186,9 +184,8 @@ function checkForNewPossesor(n: T.NPSelection | undefined, old: T.PossesorSelect return false; } -// TODO: BETTER UID function makeUID() { - return Math.floor(Math.random() * 50000); + return Math.floor(Math.random() * 10000000); } export default NPPicker; \ No newline at end of file diff --git a/src/components/vp-explorer/VPExplorer.tsx b/src/components/vp-explorer/VPExplorer.tsx index 478b2b6..ae54774 100644 --- a/src/components/vp-explorer/VPExplorer.tsx +++ b/src/components/vp-explorer/VPExplorer.tsx @@ -45,7 +45,7 @@ export function VPExplorer(props: { }) { const [vps, setVps] = useStickyState( savedVps => makeVPSelectionState(props.verb, savedVps), - "vpsState6", + "vpsState7", ); const [mode, setMode] = useStickyState<"charts" | "phrases" | "quiz">( savedMode => { diff --git a/src/components/vp-explorer/VerbPicker.tsx b/src/components/vp-explorer/VerbPicker.tsx index 3bd7026..15cd1f9 100644 --- a/src/components/vp-explorer/VerbPicker.tsx +++ b/src/components/vp-explorer/VerbPicker.tsx @@ -5,6 +5,7 @@ import { getVerbInfo } from "../../lib/verb-info"; import Hider from "../Hider"; import useStickyState from "../../lib/useStickyState"; import CompoundDisplay from "./CompoundDisplay"; +import { changeStatDyn, changeTransitivity, changeVoice } from "./verb-selection"; // TODO: dark on past tense selecitons @@ -27,7 +28,7 @@ function VerbPicker(props: { return
ERROR: Verb version should be select first
; } function onVoiceSelect(value: "active" | "passive") { - if (props.vps.verb && props.vps.verb.changeVoice) { + if (props.vps.verb && props.vps.verb.canChangeVoice) { if (value === "passive" && props.vps.verb.tenseCategory === "imperative") { return; } @@ -35,12 +36,12 @@ function VerbPicker(props: { props.onChange({ ...props.vps, subject: props.vps.verb.object, - verb: props.vps.verb.changeVoice(value, props.vps.verb.object), + verb: changeVoice(props.vps.verb, value, props.vps.verb.object), }); } else { props.onChange({ ...props.vps, - verb: props.vps.verb.changeVoice(value, value === "active" ? props.vps.subject : undefined), + verb: changeVoice(props.vps.verb, value, value === "active" ? props.vps.subject : undefined), }); } } @@ -49,18 +50,18 @@ function VerbPicker(props: { return t === "intransitive" ? "transitive" : t; } function handleChangeTransitivity(t: "transitive" | "grammatically transitive") { - if (props.vps.verb && props.vps.verb.changeTransitivity) { + if (props.vps.verb && props.vps.verb.canChangeTransitivity) { props.onChange({ ...props.vps, - verb: props.vps.verb.changeTransitivity(t), + verb: changeTransitivity(props.vps.verb, t), }); } } function handleChangeStatDyn(c: "stative" | "dynamic") { - if (props.vps.verb && props.vps.verb.changeStatDyn) { + if (props.vps.verb && props.vps.verb.canChangeStatDyn) { props.onChange({ ...props.vps, - verb: props.vps.verb.changeStatDyn(c), + verb: changeStatDyn(props.vps.verb, c), }); } } @@ -84,7 +85,7 @@ function VerbPicker(props: { }
- {props.vps.verb && props.vps.verb.changeTransitivity &&
+ {props.vps.verb && props.vps.verb.canChangeTransitivity &&
} - {props.vps.verb && props.vps.verb.changeVoice &&
+ {props.vps.verb && props.vps.verb.canChangeVoice &&
} - {props.vps.verb && props.vps.verb.changeStatDyn &&
+ {props.vps.verb && props.vps.verb.canChangeStatDyn &&
VerbSelection, - changeStatDyn?: (t: "stative" | "dynamic") => VerbSelection, - changeVoice?: (v: "active" | "passive", subj?: NPSelection) => VerbSelection, - // TODO: changeStativeDynamic - // TODO: add in aspect element here?? + canChangeVoice: boolean, negative: boolean, verbTense: VerbTense, perfectTense: PerfectTense,