From ebdfc33de1f1ab3094f6db4de5f46ff446364d09 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Wed, 20 Apr 2022 22:58:34 +0500 Subject: [PATCH] fix with active/passive --- package.json | 2 +- src/components/vp-explorer/TensePicker.tsx | 14 +++++++++++++- src/components/vp-explorer/VerbPicker.tsx | 11 ++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 45e3daf..ed47f94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "2.1.5", + "version": "2.1.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/vp-explorer/TensePicker.tsx b/src/components/vp-explorer/TensePicker.tsx index b8808a3..d0b4345 100644 --- a/src/components/vp-explorer/TensePicker.tsx +++ b/src/components/vp-explorer/TensePicker.tsx @@ -177,6 +177,7 @@ function TensePicker(props: ({ ...props.vps, verb: { ...props.vps.verb, + voice: "active", tenseCategory: value, }, })); @@ -196,6 +197,8 @@ function TensePicker(props: ({ : ("vps" in props && (props.vps.verb?.tenseCategory === "imperative")) ? imperativeTenseOptions : verbTenseOptions; + const showImperativeOption = ("vps" in props && props.vps.verb.voice === "active") + || ("vpsComplete" in props && props.vpsComplete.verb.voice !== "active"); return
Tense:
@@ -205,7 +208,7 @@ function TensePicker(props: ({ value={"vpsComplete" in props ? getTenseCategory(props.vpsComplete.verb.tense) : props.vps.verb.tenseCategory} - options={[{ + options={showImperativeOption ? [{ label: "Basic", value: "basic", }, { @@ -217,6 +220,15 @@ function TensePicker(props: ({ }, { label: "Imperative", value: "imperative", + }] : [{ + label: "Basic", + value: "basic", + }, { + label: "Perfect", + value: "perfect", + }, { + label: "Modal", + value: "modal", }]} handleChange={props.mode !== "quiz" ? onTenseCategorySelect : () => null} /> diff --git a/src/components/vp-explorer/VerbPicker.tsx b/src/components/vp-explorer/VerbPicker.tsx index 9ad736c..9c84c50 100644 --- a/src/components/vp-explorer/VerbPicker.tsx +++ b/src/components/vp-explorer/VerbPicker.tsx @@ -28,10 +28,14 @@ function VerbPicker(props: { } function onVoiceSelect(value: "active" | "passive") { if (props.vps.verb && props.vps.verb.changeVoice) { + if (value === "passive" && props.vps.verb.tenseCategory === "imperative") { + return; + } if (value === "passive" && (typeof props.vps.verb.object === "object")) { props.onChange({ ...props.vps, subject: props.vps.verb.object, + verb: props.vps.verb.changeVoice(value, props.vps.verb.object), }); } else { props.onChange({ @@ -98,7 +102,12 @@ function VerbPicker(props: {