fix select option creating bug
This commit is contained in:
parent
baff310d65
commit
7655bcd6f3
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/pashto-inflector",
|
"name": "@lingdocs/pashto-inflector",
|
||||||
"version": "1.8.1",
|
"version": "1.8.2",
|
||||||
"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",
|
||||||
|
|
|
@ -103,6 +103,7 @@ function NPNounPicker(props: ({
|
||||||
handleChange={setPatternFilter}
|
handleChange={setPatternFilter}
|
||||||
/>
|
/>
|
||||||
</div>} */}
|
</div>} */}
|
||||||
|
<h6>Noun</h6>
|
||||||
{!(props.noun && props.noun.dynamicComplement) ? <div>
|
{!(props.noun && props.noun.dynamicComplement) ? <div>
|
||||||
<EntrySelect
|
<EntrySelect
|
||||||
value={props.noun?.entry}
|
value={props.noun?.entry}
|
||||||
|
|
|
@ -28,6 +28,7 @@ function NPParticiplePicker(props: ({
|
||||||
}
|
}
|
||||||
return <div style={{ maxWidth: "225px" }}>
|
return <div style={{ maxWidth: "225px" }}>
|
||||||
{props.clearButton}
|
{props.clearButton}
|
||||||
|
<h6>Participle</h6>
|
||||||
<EntrySelect
|
<EntrySelect
|
||||||
value={props.participle?.verb}
|
value={props.participle?.verb}
|
||||||
{..."getVerbByTs" in props ? {
|
{..."getVerbByTs" in props ? {
|
||||||
|
|
|
@ -105,7 +105,9 @@ function NPPronounPicker({ onChange, pronoun, asObject, clearButton, opts }: {
|
||||||
value={pronoun.distance}
|
value={pronoun.distance}
|
||||||
handleChange={(g) => handlePronounTypeChange(g as "far" | "near")}
|
handleChange={(g) => handlePronounTypeChange(g as "far" | "near")}
|
||||||
/>
|
/>
|
||||||
<button className="btn btn-sm btn-outline" onClick={handleDisplayChange}>{display === "persons" ? "#" : display === "p" ? "PS" : "EN"}</button>
|
<button className="btn btn-sm btn-outline-secondary" onClick={handleDisplayChange}>
|
||||||
|
{display === "persons" ? "#" : display === "p" ? "PS" : "EN"}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<table className="table table-bordered table-sm" style={{ textAlign: "center", minWidth: "100px", tableLayout: "fixed" }}>
|
<table className="table table-bordered table-sm" style={{ textAlign: "center", minWidth: "100px", tableLayout: "fixed" }}>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
|
@ -66,14 +66,26 @@ export function makeSelectOption(
|
||||||
e: T.DictionaryEntry | T.VerbEntry | T.NounEntry | T.AdjectiveEntry | T.LocativeAdverbEntry,
|
e: T.DictionaryEntry | T.VerbEntry | T.NounEntry | T.AdjectiveEntry | T.LocativeAdverbEntry,
|
||||||
opts: T.TextOptions,
|
opts: T.TextOptions,
|
||||||
): { value: string, label: string } {
|
): { value: string, label: string } {
|
||||||
|
function truncateEnglish(s: string) {
|
||||||
|
const maxLength = 16;
|
||||||
|
return s.length <= maxLength
|
||||||
|
? maxLength
|
||||||
|
: s.slice(0, maxLength) + "…";
|
||||||
|
}
|
||||||
const entry = "entry" in e ? e.entry : e;
|
const entry = "entry" in e ? e.entry : e;
|
||||||
const eng = (isVerbEntry(e))
|
const eng = (() => {
|
||||||
? (getEnglishParticiple(e.entry))
|
try {
|
||||||
: getEnglishWord(e);
|
return (isVerbEntry(e))
|
||||||
|
? (getEnglishParticiple(e.entry))
|
||||||
|
: getEnglishWord(e);
|
||||||
|
} catch(err) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
})();
|
||||||
const english = typeof eng === "string"
|
const english = typeof eng === "string"
|
||||||
? eng
|
? eng
|
||||||
: !eng
|
: !eng
|
||||||
? ""
|
? truncateEnglish(entry.e)
|
||||||
: ("singular" in eng && eng.singular !== undefined)
|
: ("singular" in eng && eng.singular !== undefined)
|
||||||
? eng.singular
|
? eng.singular
|
||||||
: eng.plural;
|
: eng.plural;
|
||||||
|
|
Loading…
Reference in New Issue