diff --git a/package.json b/package.json index 95ace42..ff7a811 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "2.1.8", + "version": "2.1.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", diff --git a/src/components/np-picker/NPPicker.tsx b/src/components/np-picker/NPPicker.tsx index 37b38cd..d958988 100644 --- a/src/components/np-picker/NPPicker.tsx +++ b/src/components/np-picker/NPPicker.tsx @@ -18,7 +18,7 @@ function NPPicker(props: { onChange: (nps: T.NPSelection | undefined) => void, np: T.NPSelection | undefined, counterPart: T.NPSelection | T.VerbObject | undefined, - asObject?: boolean, + role: "subject" | "object" | "ergative", opts: T.TextOptions, cantClear?: boolean, is2ndPersonPicker?: boolean, @@ -90,7 +90,7 @@ function NPPicker(props: { } {(npType === "pronoun" && props.np?.type === "pronoun") ? ({ - persons: [ - ["1st", "1st pl."], - ["2nd", "2nd pl."], - ["3rd", "3rd pl."], - ], - e: asObject ? [ +// TODO: better logic on this +const labels = (role: "subject" | "object" | "ergative") => ({ + // persons: [ + // ["1st", "1st pl."], + // ["2nd", "2nd pl."], + // ["3rd", "3rd pl."], + // ], + e: role === "object" ? [ ["me", "us"], ["you", "you pl."], [{ masc: "him/it", fem: "her/it"}, "them"], @@ -26,7 +27,7 @@ const labels = (asObject: boolean) => ({ ["You", "You pl."], [{ masc: "He/It", fem: "She/It"}, "They"], ], - p: { + p: role === "subject" ? { far: [ ["زه", "مونږ"], ["ته", "تاسو"], @@ -37,6 +38,28 @@ const labels = (asObject: boolean) => ({ ["ته", "تاسو"], [{ masc: "دی", fem: "دا" }, "دوي"], ], + } : role === "object" ? { + far: [ + ["زه", "مونږ"], + ["ته", "تاسو"], + [{ masc: "هغهٔ", fem: "هغې" }, "هغوي"], + ], + near: [ + ["زه", "مونږ"], + ["ته", "تاسو"], + [{ masc: "دهٔ", fem: "دې" }, "دوي"], + ], + } : { + far: [ + ["ما", "مونږ"], + ["تا", "تاسو"], + [{ masc: "هغهٔ", fem: "هغې" }, "هغوي"], + ], + near: [ + ["ما", "مونږ"], + ["تا", "تاسو"], + [{ masc: "دهٔ", fem: "دې" }, "دوي"], + ], }, }); @@ -56,10 +79,10 @@ function pickerStateToPerson(s: PickerState): T.Person { + (6 * s.col); } -function NPPronounPicker({ onChange, pronoun, asObject, clearButton, opts, is2ndPersonPicker }: { +function NPPronounPicker({ onChange, pronoun, role, clearButton, opts, is2ndPersonPicker }: { pronoun: T.PronounSelection, onChange: (p: T.PronounSelection) => void, - asObject?: boolean, + role: "object" | "subject" | "ergative", clearButton?: JSX.Element, opts: T.TextOptions, is2ndPersonPicker?: boolean, @@ -67,7 +90,7 @@ function NPPronounPicker({ onChange, pronoun, asObject, clearButton, opts, is2nd if (is2ndPersonPicker && !isSecondPerson(pronoun.person)) { throw new Error("can't use 2ndPerson NPProunounPicker without a pronoun"); } - const [display, setDisplay] = useStickyState<"persons" | "p" | "e">("e", "prounoun-picker-display"); + const [display, setDisplay] = useStickyState<"p" | "e">("e", "prounoun-picker-display2"); const p = personToPickerState(pronoun.person); function handleClick(row: number, col: number) { const person = pickerStateToPerson({ ...p, row, col }); @@ -90,21 +113,19 @@ function NPPronounPicker({ onChange, pronoun, asObject, clearButton, opts, is2nd }); } function handleDisplayChange() { - const newPerson = display === "persons" - ? "p" - : display === "p" + const newPerson = display === "p" ? "e" - : "persons"; + : "p"; setDisplay(newPerson); } - const prs = labels(!!asObject)[display]; + const prs = labels(role)[display]; const pSpecA = "near" in prs ? prs[pronoun.distance] : prs; const pSpec = is2ndPersonPicker ? [pSpecA[1]] : pSpecA; return
- {isThirdPerson(pronoun.person) ? handlePronounTypeChange(g as "far" | "near")} - /> :
{` `}
} + />
@@ -125,6 +146,7 @@ function NPPronounPicker({ onChange, pronoun, asObject, clearButton, opts, is2nd const active = is2ndPersonPicker ? (p.col === j) : (p.row === i && p.col === j); + const content = typeof r === "string" ? r : r[p.gender]; return ; })} diff --git a/src/components/vp-explorer/TensePicker.tsx b/src/components/vp-explorer/TensePicker.tsx index 81d326c..3177f74 100644 --- a/src/components/vp-explorer/TensePicker.tsx +++ b/src/components/vp-explorer/TensePicker.tsx @@ -224,11 +224,12 @@ function TensePicker(props: ({ : verbTenseOptions; const showImperativeOption = ("vps" in props && props.vps.verb.voice === "active") || ("vpsComplete" in props && props.vpsComplete.verb.voice !== "active"); + const canHaveFormula = "vps" in props && props.vps.verb.voice === "active"; return
Tense:
- {"vps" in props &&
setShowFormula(x => !x)}> + {canHaveFormula &&
setShowFormula(x => !x)}> 🧪 {!showFormula ? "Show" : "Hide"} Formula
}
@@ -305,7 +306,7 @@ function TensePicker(props: ({
} - {("vps" in props && showFormula) && (() => { + {(canHaveFormula && showFormula) && (() => { // TODO: Be able to show modal formulas too const curr = (props.vps.verb.tenseCategory === "imperative" && props.vps.verb.negative) ? imperativeTenseOptions.find(x => x.value === "imperfectiveImperative") diff --git a/src/components/vp-explorer/VPExplorer.tsx b/src/components/vp-explorer/VPExplorer.tsx index 7e6b369..16b42cb 100644 --- a/src/components/vp-explorer/VPExplorer.tsx +++ b/src/components/vp-explorer/VPExplorer.tsx @@ -63,8 +63,9 @@ export function VPExplorer(props: { "verbExplorerMode", ); const [showingExplanation, setShowingExplanation] = useState<{ role: "servant" | "king", item: "subject" | "object" } | false>(false); + const isPast = isPastTense(vps.verb.tenseCategory === "perfect" ? vps.verb.perfectTense : vps.verb.verbTense); const roles = getKingAndServant( - isPastTense(vps.verb.tenseCategory === "perfect" ? vps.verb.perfectTense : vps.verb.verbTense), + isPast, vps.verb.transitivity !== "intransitive", ); useEffect(() => { @@ -158,6 +159,10 @@ export function VPExplorer(props: { nouns: props.nouns, verbs: props.verbs, }} + role={(isPast && vps.verb.transitivity !== "intransitive") + ? "ergative" + : "subject" + } is2ndPersonPicker={vps.verb.tenseCategory === "imperative"} np={vps.subject} counterPart={vps.verb ? vps.verb.object : undefined} @@ -181,7 +186,7 @@ export function VPExplorer(props: { nouns: props.nouns, verbs: props.verbs, }} - asObject + role="object" np={vps.verb.object} counterPart={vps.subject} onChange={handleObjectChange}
{ handleClick(is2ndPersonPicker ? 1 : i, j); @@ -136,7 +158,7 @@ function NPPronounPicker({ onChange, pronoun, asObject, clearButton, opts, is2nd }} >
- {typeof r === "string" ? r : r[p.gender]} + {content}