diff --git a/package.json b/package.json index 5eb5e3d..7410f56 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "3.6.8", + "version": "3.6.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/AdjectiveManager.tsx b/src/components/np-picker/AdjectiveManager.tsx index b46314b..c512229 100644 --- a/src/components/np-picker/AdjectiveManager.tsx +++ b/src/components/np-picker/AdjectiveManager.tsx @@ -1,15 +1,19 @@ import * as T from "../../types"; import { useState } from "react"; import AdjectivePicker from "./AdjectivePicker"; +import classNames from "classnames"; function AdjectiveManager(props: { adjectives: T.AdjectiveSelection[], entryFeeder: T.EntryFeeder, opts: T.TextOptions, + demonstrative: T.NounSelection["demonstrative"], onChange: (adjs: T.AdjectiveSelection[]) => void, + onDemonstrativeChange: (dem: T.NounSelection["demonstrative"]) => void, phraseIsComplete: boolean, }) { const [adding, setAdding] = useState(false); + const [addingDemonstrative, setAddingDemonstrative] = useState(false); function handleChange(i: number) { return (a: T.AdjectiveSelection | undefined) => { if (a === undefined) return; @@ -53,6 +57,21 @@ function AdjectiveManager(props: { onChange={handleAddNew} /> } + {addingDemonstrative &&
+
+
Add Demonstrative
+
{ + setAddingDemonstrative(false); + props.onDemonstrativeChange(undefined); + }}> + +
+
+ +
} {props.adjectives.map((adj, i) =>
Adjective
@@ -75,12 +94,55 @@ function AdjectiveManager(props: { onChange={handleChange(i)} />
)} - {!adding && !props.adjectives.length &&
+ {/* {!adding && !props.adjectives.length &&
setAdding(true)}>+ Adj.
+
} */} + {!addingDemonstrative && !props.demonstrative &&
+
setAddingDemonstrative(true)}>+ Demons.
}
; } +function DemonstrativePicker({ demonstrative, onChange }: { + demonstrative: T.NounSelection["demonstrative"], + onChange: (dem: T.NounSelection["demonstrative"]) => void, +}) { + function handleDChange(d: "daa" | "hagha" | "dagha") { + if (!demonstrative) { + onChange({ + type: "demonstrative", + demonstrative: d, + hideNoun: false, + }); + } else { + onChange({ + ...demonstrative, + demonstrative: d, + }); + } + } + return
+
+ +
+
+ +
+
+ +
+
; +} + function remove(arr: X[], i: number): X[] { return [ ...arr.slice(0, i), diff --git a/src/components/np-picker/NPNounPicker.tsx b/src/components/np-picker/NPNounPicker.tsx index adc18bf..29db349 100644 --- a/src/components/np-picker/NPNounPicker.tsx +++ b/src/components/np-picker/NPNounPicker.tsx @@ -85,6 +85,14 @@ function NPNounPicker(props: { }); } } + function handleDemonstrativeUpdate(demonstrative: undefined | T.NounSelection["demonstrative"]) { + if (props.noun) { + props.onChange({ + ...props.noun, + demonstrative, + }); + } + } return
{/* {showFilter &&
@@ -102,9 +110,11 @@ function NPNounPicker(props: { {props.noun && }
Noun
{!(props.noun && props.noun.dynamicComplement) ?
diff --git a/src/components/np-picker/NPPicker.tsx b/src/components/np-picker/NPPicker.tsx index b4b9444..6b2d31c 100644 --- a/src/components/np-picker/NPPicker.tsx +++ b/src/components/np-picker/NPPicker.tsx @@ -108,7 +108,7 @@ function NPPicker(props: { :
; const possesiveLabel = props.np?.selection.type === "participle" ? "Subj/Obj" : "Possesor"; return
diff --git a/src/components/np-picker/picker-tools.tsx b/src/components/np-picker/picker-tools.tsx index c1aa74d..3670352 100644 --- a/src/components/np-picker/picker-tools.tsx +++ b/src/components/np-picker/picker-tools.tsx @@ -114,5 +114,6 @@ export function makeNounSelection(entry: T.NounEntry, old: T.NounSelection | und adjectives: (!dynamicComplement && old) ? old.adjectives : [], possesor: !dynamicComplement ? old?.possesor : undefined, dynamicComplement, + demonstrative: undefined, }; } \ No newline at end of file diff --git a/src/components/vp-explorer/VPPicker.tsx b/src/components/vp-explorer/VPPicker.tsx index a052ca3..b61196e 100644 --- a/src/components/vp-explorer/VPPicker.tsx +++ b/src/components/vp-explorer/VPPicker.tsx @@ -103,21 +103,23 @@ function VPPicker({ opts, vps, onChange, entryFeeder }: { heading={roles.king === "subject" ?
Subj. setShowingExplanation({ role: "king", item: "subject" })}>{roleIcon.king} - {/* {(rendered && rendered.whatsAdjustable !== "servant") && - adjustVps({ type: "toggle king remove" })} className="mx-2 clickable"> - {!VPS?.form.removeKing ? "🫣" : "🚫" } - - } */} + {(rendered && rendered.whatsAdjustable !== "servant") && + adjustVps({ type: "toggle king remove" })} + showKing={!VPS?.form.removeKing} + /> + }
:
Subj. {` `} setShowingExplanation({ role: "servant", item: "subject" })}>{roleIcon.servant} {` `} - {(rendered && rendered.whatsAdjustable !== "king") && - adjustVps({ type: "toggle servant shrink" })} className="mx-2 clickable"> - {!servantIsShrunk ? "🪄" : "👶"} - + {(rendered && rendered.whatsAdjustable !== "king") && + adjustVps({ type: "toggle servant shrink" })} + /> }
} entryFeeder={entryFeeder} @@ -146,11 +148,12 @@ function VPPicker({ opts, vps, onChange, entryFeeder }: { heading={roles.king === "object" ?
Obj. setShowingExplanation({ role: "king", item: "object" })}>{roleIcon.king} - {/* {(rendered && rendered.whatsAdjustable !== "servant") && - adjustVps({ type: "toggle king remove" })} className="mx-2 clickable"> - {!VPS?.form.removeKing ? "🙈" : "🚫"} - - } */} + {(rendered && rendered.whatsAdjustable !== "servant") && + adjustVps({ type: "toggle king remove" })} + showKing={!VPS?.form.removeKing} + /> + }
:
Obj. @@ -158,9 +161,7 @@ function VPPicker({ opts, vps, onChange, entryFeeder }: { setShowingExplanation({ role: "servant", item: "object" })}>{roleIcon.servant} {` `} {(rendered && rendered.whatsAdjustable !== "king") && - adjustVps({ type: "toggle servant shrink" })} className="mx-2 clickable"> - {!servantIsShrunk ? "🪄" : "👶"} - + adjustVps({ type: "toggle servant shrink" })} /> }
} entryFeeder={entryFeeder} @@ -213,4 +214,28 @@ function VPPicker({ opts, vps, onChange, entryFeeder }: {
; } +function ServantShrinker({ shrunk, onClick }: { + shrunk: boolean; + onClick: () => void; +}) { + return + {!shrunk ? "🪄" : "👶"} + ; +} + +function KingRemover({ showKing, onChange }: { + showKing: boolean; + onChange: () => void; +}) { + return + + ; +} + export default VPPicker; \ No newline at end of file diff --git a/src/lib/phrase-building/render-np.ts b/src/lib/phrase-building/render-np.ts index 53a893b..aeb6fa4 100644 --- a/src/lib/phrase-building/render-np.ts +++ b/src/lib/phrase-building/render-np.ts @@ -71,9 +71,24 @@ export function renderNounSelection(n: T.NounSelection, inflected: boolean, role ps: pashto, e: english, possesor: renderPossesor(n.possesor, role), + demonstrative: renderDemonstrative(n.demonstrative, inflected && n.number === "plural"), }; } +function renderDemonstrative(demonstrative: T.DemonstrativeSelection | undefined, plurInflected: boolean): T.Rendered | undefined { + if (!demonstrative) { + return undefined; + } + return { + ...demonstrative, + ps: demonstrative.demonstrative === "daa" + ? (plurInflected ? { p: "دې", f: "de" } : { p: "دا", f: "daa" }) + : demonstrative.demonstrative === "dagha" + ? (plurInflected ? { p: "دغه", f: "dágha" } : { p: "دغو", f: "dágho" }) + : (plurInflected ? { p: "هغه", f: "hágha" } : { p: "هغو", f: "hágho" }) + } +} + function renderPronounSelection(p: T.PronounSelection, inflected: boolean, englishInflected: boolean, role: "servant" | "king" | "none"): T.Rendered { const [row, col] = getVerbBlockPosFromPerson(p.person); return { diff --git a/src/types.ts b/src/types.ts index 691f3f4..9ba826f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -649,6 +649,13 @@ export type NounSelection = { dynamicComplement?: boolean, adjectives: AdjectiveSelection[], possesor: undefined | PossesorSelection, + demonstrative: undefined | DemonstrativeSelection, +}; + +export type DemonstrativeSelection = { + type: "demonstrative", + demonstrative: "daa" | "hagha" | "dagha", + hideNoun: boolean, }; export type AdverbSelection = { @@ -708,6 +715,7 @@ export type Rendered< | AdjectiveSelection | SandwichSelection | ComplementSelection + | DemonstrativeSelection | ComplementSelection["selection"] | UnselectedComplementSelection | undefined @@ -757,6 +765,13 @@ export type Rendered< inflected: boolean, person: Person, } + : T extends DemonstrativeSelection + ? { + type: "demonstrative", + demonstrative: DemonstrativeSelection["demonstrative"], + hideNoun: boolean, + ps: PsString, + } : T extends ComplementSelection ? { type: "complement", @@ -797,6 +812,7 @@ export type Rendered< shrunken: boolean, np: Rendered, }, + demonstrative?: Rendered, }; export type EPSelectionState = {