diff --git a/package-lock.json b/package-lock.json index 13d7551..c1c4e7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pashto-inflector", - "version": "7.3.1", + "version": "7.3.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pashto-inflector", - "version": "7.3.1", + "version": "7.3.2", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index e86b438..b9c1518 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pashto-inflector", - "version": "7.3.1", + "version": "7.3.2", "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/package-lock.json b/src/components/package-lock.json index 298e461..df03c61 100644 --- a/src/components/package-lock.json +++ b/src/components/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lingdocs/ps-react", - "version": "7.3.1", + "version": "7.3.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@lingdocs/ps-react", - "version": "7.3.1", + "version": "7.3.2", "license": "MIT", "dependencies": { "@formkit/auto-animate": "^1.0.0-beta.3", diff --git a/src/components/package.json b/src/components/package.json index e2de3c6..5665505 100644 --- a/src/components/package.json +++ b/src/components/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/ps-react", - "version": "7.3.1", + "version": "7.3.2", "description": "Pashto inflector library module with React components", "main": "dist/components/library.js", "module": "dist/components/library.js", diff --git a/src/components/src/blocks/Block.tsx b/src/components/src/blocks/Block.tsx index c5a9842..b0f3ea8 100644 --- a/src/components/src/blocks/Block.tsx +++ b/src/components/src/blocks/Block.tsx @@ -663,6 +663,8 @@ export function NPBlock({ np.selection.possesor && !np.selection.possesor.shrunken ); + const demWithoutNoun = + np.selection.demonstrative && !np.selection.demonstrative.withNoun; const elements = [ ...(!inside ? [ @@ -676,10 +678,21 @@ export function NPBlock({ {np.selection.demonstrative ? np.selection.demonstrative : undefined} , - - {np.selection.adjectives} - , -
+
+ + {np.selection.adjectives} + +
, +
{" "} {flattenLengths(np.selection.ps)[0][script]}
, diff --git a/src/components/src/np-picker/DemonstrativePicker.tsx b/src/components/src/np-picker/DemonstrativePicker.tsx index 52bf935..9ecad25 100644 --- a/src/components/src/np-picker/DemonstrativePicker.tsx +++ b/src/components/src/np-picker/DemonstrativePicker.tsx @@ -13,7 +13,7 @@ export default function DemonstrativePicker({ onChange({ type: "demonstrative", demonstrative: d, - hideNoun: false, + withNoun: true, }); } else { onChange({ @@ -22,37 +22,65 @@ export default function DemonstrativePicker({ }); } } + function handleWithNounChange(e: React.ChangeEvent) { + if (demonstrative) { + onChange({ + ...demonstrative, + withNoun: e.target.checked, + }); + } + } return ( -
-
- +
+
+
+ +
+
+ +
+
+ +
-
- -
-
- +
+ +
); diff --git a/src/components/src/np-picker/NPNounPicker.tsx b/src/components/src/np-picker/NPNounPicker.tsx index 9bd01fe..e988f65 100644 --- a/src/components/src/np-picker/NPNounPicker.tsx +++ b/src/components/src/np-picker/NPNounPicker.tsx @@ -99,7 +99,12 @@ function NPNounPicker(props: { } } return ( -
+
{!addingDemonstrative && !props.noun?.demonstrative ? (
} */} - {props.noun && ( - - )} -
Noun
- {!( - props.noun && - (props.noun.dynamicComplement || props.noun.genStativeComplement) - ) ? ( -
- + {props.noun && ( + -
- ) : ( -
- {props.noun && ( + )} +
Noun
+ {!( + props.noun && + (props.noun.dynamicComplement || props.noun.genStativeComplement) + ) ? ( +
+ +
+ ) : ( +
+ {props.noun && ( +
+
+ Included in{" "} + {props.noun.genStativeComplement ? "Gen. Stat." : "Dyn."}{" "} + Compound: +
+
+ + {{ p: props.noun.entry.p, f: props.noun.entry.f }} + +
{props.noun.entry.e}
+
+
+ )} +
+ )} + {props.noun && ( +
-
- Included in{" "} - {props.noun.genStativeComplement ? "Gen. Stat." : "Dyn."}{" "} - Compound: -
-
- - {{ p: props.noun.entry.p, f: props.noun.entry.f }} - -
{props.noun.entry.e}
-
+ {props.noun.genderCanChange ? ( + { + if (!props.noun || !props.noun.genderCanChange) return; + props.onChange({ + ...props.noun, + gender, + }); + }} + /> + ) : props.noun.gender === "masc" ? ( + "Masc." + ) : ( + "Fem." + )} +
+
+ {props.noun.numberCanChange ? ( + { + if (!props.noun || !props.noun.numberCanChange) return; + props.onChange({ + ...props.noun, + number, + }); + }} + /> + ) : props.noun.number === "singular" ? ( + "Sing." + ) : ( + "Plur." + )}
- )} -
- )} - {props.noun && ( -
-
- {props.noun.genderCanChange ? ( - { - if (!props.noun || !props.noun.genderCanChange) return; - props.onChange({ - ...props.noun, - gender, - }); - }} - /> - ) : props.noun.gender === "masc" ? ( - "Masc." - ) : ( - "Fem." - )}
-
- {props.noun.numberCanChange ? ( - { - if (!props.noun || !props.noun.numberCanChange) return; - props.onChange({ - ...props.noun, - number, - }); - }} - /> - ) : props.noun.number === "singular" ? ( - "Sing." - ) : ( - "Plur." - )} -
-
- )} + )} +
); } diff --git a/src/lib/package.json b/src/lib/package.json index ca8f6cd..ebcd65f 100644 --- a/src/lib/package.json +++ b/src/lib/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/inflect", - "version": "7.3.1", + "version": "7.3.2", "description": "Pashto inflector library", "main": "dist/index.js", "types": "dist/lib/library.d.ts", diff --git a/src/lib/src/phrase-building/np-tools.ts b/src/lib/src/phrase-building/np-tools.ts index 81b4a54..2caf166 100644 --- a/src/lib/src/phrase-building/np-tools.ts +++ b/src/lib/src/phrase-building/np-tools.ts @@ -12,16 +12,22 @@ function getBaseAndAdjectives({ return getSandwichPsBaseAndAdjectives(selection); } const adjs = "adjectives" in selection && selection.adjectives; - const demons = ("demonstrative" in selection && + const demonstrativePs = ("demonstrative" in selection && selection.demonstrative?.ps) || { p: "", f: "" }; if (!adjs) { // TODO: does this ever get used?? - return flattenLengths(selection.ps).map((x) => concatPsString(demons, x)); + return flattenLengths(selection.ps).map((x) => + concatPsString(demonstrativePs, x) + ); + } + + if (selection.demonstrative && !selection.demonstrative.withNoun) { + return [demonstrativePs]; } return flattenLengths(selection.ps).map((p) => concatPsString( - demons, + demonstrativePs, // demons ? " " : "", adjs.reduce( (accum, curr) => { @@ -207,9 +213,10 @@ function addArticlesAndAdjs( : " (m.)" : ""; const demonstrative = np.demonstrative ? ` ${np.demonstrative.e}` : ""; - return `${ - np.demonstrative ? "" : articles - }${demonstrative}${adjs}${word}${genderTag}`; + const demWithoutNoun = np.demonstrative && !np.demonstrative.withNoun; + return `${np.demonstrative ? "" : articles}${demonstrative}${ + demWithoutNoun ? ` (${(adjs + word).trim()})` : adjs + word + }${genderTag}`; } catch (e) { return undefined; } diff --git a/src/types.ts b/src/types.ts index ff00240..532bb39 100644 --- a/src/types.ts +++ b/src/types.ts @@ -905,7 +905,7 @@ export type NounSelection = { export type DemonstrativeSelection = { type: "demonstrative"; demonstrative: "daa" | "hagha" | "dagha"; - hideNoun: boolean; + withNoun: boolean; }; export type AdverbSelection = { @@ -1024,7 +1024,7 @@ export type Rendered< ? { type: "demonstrative"; demonstrative: DemonstrativeSelection["demonstrative"]; - hideNoun: boolean; + withNoun: boolean; ps: PsString; e: string; }