better
This commit is contained in:
parent
8f1e283216
commit
d24c6d8aba
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lingdocs/pashto-inflector",
|
||||
"version": "3.2.8",
|
||||
"version": "3.2.9",
|
||||
"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",
|
||||
|
|
|
@ -3,7 +3,7 @@ import classNames from "classnames";
|
|||
import {
|
||||
getEnglishFromRendered,
|
||||
} from "../../lib/phrase-building/np-tools";
|
||||
import { getEnglishPersonInfo } from "../../library";
|
||||
import { getEnglishPersonInfo, getEnglishParticipleInflection } from "../../lib/misc-helpers";
|
||||
import { useState } from "react";
|
||||
import { getLength } from "../../lib/p-text-helpers";
|
||||
import { roleIcon } from "../vp-explorer/VPExplorerExplanationModal";
|
||||
|
@ -101,8 +101,11 @@ function VerbSBlock({ opts, v, script }: {
|
|||
<Border>
|
||||
{getLength(v.ps, length)[0][script]}
|
||||
</Border>
|
||||
<div>{v.type === "perfectParticipleBlock" ? "Past Partic." : "Verb"}</div>
|
||||
<EnglishBelow>{getEnglishPersonInfo(v.person, "short")}</EnglishBelow>
|
||||
<div>{v.type === "perfectParticipleBlock" ? "Past Partic." : "Verb"} aa</div>
|
||||
<EnglishBelow>{((v.type === "perfectParticipleBlock" ? "Past Partic." : "Verb")
|
||||
? getEnglishParticipleInflection
|
||||
: getEnglishPersonInfo
|
||||
)(v.person, "short")}</EnglishBelow>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ function NPPicker(props: {
|
|||
entryFeeder: T.EntryFeeder,
|
||||
phraseIsComplete: boolean,
|
||||
isShrunk?: boolean,
|
||||
isRemoved?: boolean,
|
||||
}) {
|
||||
if (props.is2ndPersonPicker && ((props.np?.selection.type !== "pronoun") || !isSecondPerson(props.np.selection.person))) {
|
||||
throw new Error("can't use 2ndPerson NPPicker without a pronoun");
|
||||
|
@ -106,7 +107,9 @@ function NPPicker(props: {
|
|||
? <button className="btn btn-sm btn-light mb-2" onClick={handleClear}>X</button>
|
||||
: <div></div>;
|
||||
const possesiveLabel = props.np?.selection.type === "participle" ? "Subj/Obj" : "Possesor";
|
||||
return <>
|
||||
return <div style={{
|
||||
opacity: props.isRemoved ? 0.6 : 1,
|
||||
}}>
|
||||
<div className="d-flex flex-row justify-content-between">
|
||||
<div></div>
|
||||
<div>
|
||||
|
@ -191,7 +194,7 @@ function NPPicker(props: {
|
|||
: null
|
||||
}
|
||||
</div>
|
||||
</>;
|
||||
</div>;
|
||||
}
|
||||
|
||||
function ensureSingleShrink(old: T.NPSelection | undefined, s: T.NPSelection | undefined): T.NPSelection | undefined {
|
||||
|
|
|
@ -95,9 +95,16 @@ function VPPicker({ opts, vps, onChange, entryFeeder }: {
|
|||
? <NPPicker
|
||||
phraseIsComplete={phraseIsComplete}
|
||||
heading={roles.king === "subject"
|
||||
? <div className="h5 text-center" onClick={() => setShowingExplanation({ role: "king", item: "subject" })}>Subject {roleIcon.king}</div>
|
||||
? <div className="h5 text-center">
|
||||
Subj. <span onClick={() => setShowingExplanation({ role: "king", item: "subject" })}>{roleIcon.king}</span>
|
||||
{(rendered && rendered.whatsAdjustable !== "servant") &&
|
||||
<span onClick={() => adjustVps({ type: "toggle king remove" })} className="mx-2 clickable">
|
||||
{!VPS?.form.removeKing ? "🚫" : "🙈"}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
: <div className="h5 text-center">
|
||||
Subject
|
||||
Subj.
|
||||
{` `}
|
||||
<span className="clickable" onClick={() => setShowingExplanation({ role: "servant", item: "subject" })}>{roleIcon.servant}</span>
|
||||
{` `}
|
||||
|
@ -117,6 +124,7 @@ function VPPicker({ opts, vps, onChange, entryFeeder }: {
|
|||
onChange={handleSubjectChange}
|
||||
opts={opts}
|
||||
isShrunk={(servantIsShrunk && roles.servant === "subject")}
|
||||
isRemoved={roles.king === "subject" && VPS?.form.removeKing}
|
||||
/>
|
||||
: (vps.verb && block?.type === "objectSelection" && block.selection !== "none")
|
||||
? <div className="my-2" style={{ background: (servantIsShrunk && roles.servant === "object") ? shrunkenBackground : "inherit" }}>
|
||||
|
@ -130,9 +138,16 @@ function VPPicker({ opts, vps, onChange, entryFeeder }: {
|
|||
: <NPPicker
|
||||
phraseIsComplete={phraseIsComplete}
|
||||
heading={roles.king === "object"
|
||||
? <div className="h5 text-center clickable" onClick={() => setShowingExplanation({ role: "king", item: "object" })}>Object {roleIcon.king}</div>
|
||||
? <div className="h5 text-center">
|
||||
Obj. <span onClick={() => setShowingExplanation({ role: "king", item: "object" })}>{roleIcon.king}</span>
|
||||
{(rendered && rendered.whatsAdjustable !== "servant") &&
|
||||
<span onClick={() => adjustVps({ type: "toggle king remove" })} className="mx-2 clickable">
|
||||
{!VPS?.form.removeKing ? "🚫" : "🙈"}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
: <div className="h5 text-center">
|
||||
Object
|
||||
Obj.
|
||||
{` `}
|
||||
<span className="clickable" onClick={() => setShowingExplanation({ role: "servant", item: "object" })}>{roleIcon.servant}</span>
|
||||
{` `}
|
||||
|
@ -141,6 +156,11 @@ function VPPicker({ opts, vps, onChange, entryFeeder }: {
|
|||
{!servantIsShrunk ? "🪄" : "👶"}
|
||||
</span>
|
||||
}
|
||||
{(rendered && rendered.whatsAdjustable !== "servant") &&
|
||||
<span onClick={() => adjustVps({ type: "toggle king remove" })} className="mx-2 clickable">
|
||||
{!VPS?.form.removeKing ? "🚫" : "🙈"}
|
||||
</span>
|
||||
}
|
||||
</div>}
|
||||
entryFeeder={entryFeeder}
|
||||
role="object"
|
||||
|
@ -149,6 +169,7 @@ function VPPicker({ opts, vps, onChange, entryFeeder }: {
|
|||
onChange={handleObjectChange}
|
||||
opts={opts}
|
||||
isShrunk={(servantIsShrunk && roles.servant === "object")}
|
||||
isRemoved={roles.king === "object" && VPS?.form.removeKing}
|
||||
/>}
|
||||
</div>
|
||||
: null}
|
||||
|
|
|
@ -53,6 +53,8 @@ export type VpsReducerAction = {
|
|||
} | {
|
||||
type: "toggle servant shrink",
|
||||
} | {
|
||||
type: "toggle king remove",
|
||||
} |{
|
||||
type: "set verb",
|
||||
payload: T.VerbEntry,
|
||||
} | {
|
||||
|
@ -251,6 +253,15 @@ export function vpsReducer(vps: T.VPSelectionState, action: VpsReducerAction, se
|
|||
},
|
||||
};
|
||||
}
|
||||
if (action.type === "toggle king remove") {
|
||||
return {
|
||||
...vps,
|
||||
form: {
|
||||
...vps.form,
|
||||
removeKing: !vps.form.removeKing,
|
||||
},
|
||||
};
|
||||
}
|
||||
if (action.type === "set verb") {
|
||||
return makeVPSelectionState(action.payload, vps);
|
||||
}
|
||||
|
|
|
@ -163,6 +163,15 @@ export function getEnglishPersonInfo(person: T.Person, version?: "short" | "long
|
|||
return `${p} ${n}. ${g}.`;
|
||||
}
|
||||
|
||||
export function getEnglishParticipleInflection(person: T.Person, version?: "short" | "long"): string {
|
||||
const number = personIsPlural(person) ? "plural" : "singular";
|
||||
const n = version === "short"
|
||||
? (number === "plural" ? "plur." : "sing.") : number;
|
||||
const gender = personGender(person);
|
||||
const g = gender;
|
||||
return `${g}. ${n}`;
|
||||
}
|
||||
|
||||
export function randomNumber(minInclusive: number, maxExclusive: number): number {
|
||||
return Math.floor(Math.random() * (maxExclusive - minInclusive) + minInclusive);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue