fix with active/passive

This commit is contained in:
lingdocs 2022-04-20 22:58:34 +05:00
parent c6f9626039
commit ebdfc33de1
3 changed files with 24 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@lingdocs/pashto-inflector", "name": "@lingdocs/pashto-inflector",
"version": "2.1.5", "version": "2.1.6",
"author": "lingdocs.com", "author": "lingdocs.com",
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
"homepage": "https://verbs.lingdocs.com", "homepage": "https://verbs.lingdocs.com",

View File

@ -177,6 +177,7 @@ function TensePicker(props: ({
...props.vps, ...props.vps,
verb: { verb: {
...props.vps.verb, ...props.vps.verb,
voice: "active",
tenseCategory: value, tenseCategory: value,
}, },
})); }));
@ -196,6 +197,8 @@ function TensePicker(props: ({
: ("vps" in props && (props.vps.verb?.tenseCategory === "imperative")) : ("vps" in props && (props.vps.verb?.tenseCategory === "imperative"))
? imperativeTenseOptions ? imperativeTenseOptions
: verbTenseOptions; : verbTenseOptions;
const showImperativeOption = ("vps" in props && props.vps.verb.voice === "active")
|| ("vpsComplete" in props && props.vpsComplete.verb.voice !== "active");
return <div> return <div>
<div style={{ maxWidth: "300px", minWidth: "250px", margin: "0 auto" }}> <div style={{ maxWidth: "300px", minWidth: "250px", margin: "0 auto" }}>
<div className="h5">Tense:</div> <div className="h5">Tense:</div>
@ -205,7 +208,7 @@ function TensePicker(props: ({
value={"vpsComplete" in props value={"vpsComplete" in props
? getTenseCategory(props.vpsComplete.verb.tense) ? getTenseCategory(props.vpsComplete.verb.tense)
: props.vps.verb.tenseCategory} : props.vps.verb.tenseCategory}
options={[{ options={showImperativeOption ? [{
label: "Basic", label: "Basic",
value: "basic", value: "basic",
}, { }, {
@ -217,6 +220,15 @@ function TensePicker(props: ({
}, { }, {
label: "Imperative", label: "Imperative",
value: "imperative", value: "imperative",
}] : [{
label: "Basic",
value: "basic",
}, {
label: "Perfect",
value: "perfect",
}, {
label: "Modal",
value: "modal",
}]} }]}
handleChange={props.mode !== "quiz" ? onTenseCategorySelect : () => null} handleChange={props.mode !== "quiz" ? onTenseCategorySelect : () => null}
/> />

View File

@ -28,10 +28,14 @@ function VerbPicker(props: {
} }
function onVoiceSelect(value: "active" | "passive") { function onVoiceSelect(value: "active" | "passive") {
if (props.vps.verb && props.vps.verb.changeVoice) { 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")) { if (value === "passive" && (typeof props.vps.verb.object === "object")) {
props.onChange({ props.onChange({
...props.vps, ...props.vps,
subject: props.vps.verb.object, subject: props.vps.verb.object,
verb: props.vps.verb.changeVoice(value, props.vps.verb.object),
}); });
} else { } else {
props.onChange({ props.onChange({
@ -98,7 +102,12 @@ function VerbPicker(props: {
<ButtonSelect <ButtonSelect
small small
value={props.vps.verb.voice} value={props.vps.verb.voice}
options={[{ options={props.vps.verb.tenseCategory === "imperative"
? [{
label: "Active",
value: "active",
}]
: [{
label: "Active", label: "Active",
value: "active", value: "active",
}, { }, {