diff --git a/package.json b/package.json
index ae464bd..d6c0fa1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@lingdocs/pashto-inflector",
- "version": "2.8.7",
+ "version": "2.8.8",
"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/ep-explorer/EPExplorer.tsx b/src/components/ep-explorer/EPExplorer.tsx
index 995670e..cb0386c 100644
--- a/src/components/ep-explorer/EPExplorer.tsx
+++ b/src/components/ep-explorer/EPExplorer.tsx
@@ -1,19 +1,17 @@
import * as T from "../../types";
import useStickyState, { useStickyReducer } from "../../lib/useStickyState";
-import NPPicker from "../np-picker/NPPicker";
-import EquativePicker from "./EquativePicker";
import EPDisplay from "./EPDisplay";
import ButtonSelect from "../ButtonSelect";
-import EqCompPicker from "./eq-comp-picker/EqCompPicker";
import EqChartsDisplay from "./EqChartsDisplay";
import epsReducer from "./eps-reducer";
import { useEffect, useRef, useState } from "react";
import { completeEPSelection } from "../../lib/phrase-building/render-ep";
import { makeEPSBlocks } from "../../lib/phrase-building/blocks-utils";
-import APPicker from "../ap-picker/APPicker";
+import EquativePicker from "./EquativePicker";
import autoAnimate from "@formkit/auto-animate";
// @ts-ignore
import LZString from "lz-string";
+import EPPicker from "./EPPicker";
const phraseURLParam = "EPhrase";
const blankEps: T.EPSelectionState = {
@@ -35,14 +33,11 @@ const blankEps: T.EPSelectionState = {
function EPExplorer(props: {
opts: T.TextOptions,
entryFeeder: T.EntryFeeder,
-} & ({
- eps: T.EPSelectionState,
- onChange: (eps: T.EPSelectionState) => void,
-} | {})) {
+}) {
const [mode, setMode] = useStickyState<"charts" | "phrases">("charts", "EPExplorerMode");
const [eps, adjustEps] = useStickyReducer(
epsReducer,
- "eps" in props ? props.eps : blankEps,
+ blankEps,
"EPState7",
flashMessage,
);
@@ -63,6 +58,9 @@ function EPExplorer(props: {
}
// eslint-disable-next-line
}, []);
+ function handleEpsChange(e: T.EPSelectionState) {
+ adjustEps({ type: "load EPS", payload: e });
+ }
function flashMessage(msg: string) {
setAlert(msg);
setTimeout(() => {
@@ -114,86 +112,21 @@ function EPExplorer(props: {
}
- {mode === "phrases" &&
adjustEps({ type: "insert new AP" })}>+ AP
}
-
- {mode === "phrases" && <>
- {eps.blocks.map(({ block, key }, i) => (
-
-
- {i > 0 ?
adjustEps({ type: "shift block", payload: { index: i, direction: "back" }})}
- >
-
-
:
}
- {i < eps.blocks.length - 1 ?
adjustEps({ type: "shift block", payload: { index: i, direction: "forward" }})}
- >
-
-
:
}
-
- {block && block.type === "subjectSelection"
- ?
Subject}
- entryFeeder={props.entryFeeder}
- np={block.selection}
- counterPart={undefined}
- role="subject"
- onChange={payload => adjustEps({ type: "set subject", payload })}
- opts={props.opts}
- />
- :
adjustEps({ type: "set AP", payload: { index: i, AP } })}
- onRemove={() => adjustEps({ type: "remove AP", payload: i })}
- />}
-
- ))}
-
-
Predicate
-
- adjustEps({ type: "set predicate type", payload })}
- />
-
- {eps.predicate.type === "NP" ?
adjustEps({ type: "set predicate NP", payload })}
- opts={props.opts}
- /> : adjustEps({ type: "set predicate comp", payload })}
- opts={props.opts}
- entryFeeder={props.entryFeeder}
- />}
-
- >}
-
-
Equative
-
adjustEps({ type: "set equative", payload })}
- hideNegative={mode === "charts"}
- />
-
-
+ {mode === "phrases" &&
+ }
+ {mode === "charts" &&
+
Equative
+
adjustEps({ type: "set equative", payload })}
+ hideNegative={false}
+ />
+ }
{mode === "charts" && }
{mode === "phrases" && void,
+ entryFeeder: T.EntryFeeder,
+}) {
+ const parent = useRef(null);
+ const [alert, setAlert] = useState("");
+ useEffect(() => {
+ parent.current && autoAnimate(parent.current);
+ }, [parent]);
+ function adjustEps(action: EpsReducerAction) {
+ onChange(epsReducer(eps, action, handleAlert));
+ }
+ function handleAlert(msg: string) {
+ setAlert(msg);
+ setTimeout(() => {
+ setAlert(undefined);
+ }, 1500);
+ }
+ const phraseIsComplete = !!completeEPSelection(eps);
+ return
+
adjustEps({ type: "insert new AP" })}>+ AP
+
+ {eps.blocks.map(({ block, key }, i) => (
+
+
+ {i > 0 ?
adjustEps({ type: "shift block", payload: { index: i, direction: "back" }})}
+ >
+
+
:
}
+ {i < eps.blocks.length - 1 ?
adjustEps({ type: "shift block", payload: { index: i, direction: "forward" }})}
+ >
+
+
:
}
+
+ {block && block.type === "subjectSelection"
+ ?
Subject}
+ entryFeeder={entryFeeder}
+ np={block.selection}
+ counterPart={undefined}
+ role="subject"
+ onChange={payload => adjustEps({ type: "set subject", payload })}
+ opts={opts}
+ />
+ :
adjustEps({ type: "set AP", payload: { index: i, AP } })}
+ onRemove={() => adjustEps({ type: "remove AP", payload: i })}
+ />}
+
+ ))}
+
+
Predicate
+
+ adjustEps({ type: "set predicate type", payload })}
+ />
+
+ {eps.predicate.type === "NP" ?
adjustEps({ type: "set predicate NP", payload })}
+ opts={opts}
+ /> : adjustEps({ type: "set predicate comp", payload })}
+ opts={opts}
+ entryFeeder={entryFeeder}
+ />}
+
+
+
Equative
+
adjustEps({ type: "set equative", payload })}
+ hideNegative={false}
+ />
+
+
+ {alert &&
+ {alert}
+
}
+ ;
+}
+
+export default EPPicker;
\ No newline at end of file
diff --git a/src/components/ep-explorer/eps-reducer.ts b/src/components/ep-explorer/eps-reducer.ts
index 9e7f891..1707b41 100644
--- a/src/components/ep-explorer/eps-reducer.ts
+++ b/src/components/ep-explorer/eps-reducer.ts
@@ -7,7 +7,7 @@ import { isUnisexNounEntry } from "../../lib/type-predicates";
import { checkEPForMiniPronounsError } from "../../lib/phrase-building/compile";
import { adjustSubjectSelection, getSubjectSelection, insertNewAP, removeAP, setAP, shiftBlock } from "../../lib/phrase-building/blocks-utils";
-type EpsReducerAction = {
+export type EpsReducerAction = {
type: "set predicate type",
payload: "NP" | "Complement",
} | {
diff --git a/src/library.ts b/src/library.ts
index 4631083..144a6d2 100644
--- a/src/library.ts
+++ b/src/library.ts
@@ -149,6 +149,7 @@ import {
renderAPSelection,
} from "./lib/phrase-building/render-ap";
import NPPicker from "./components/np-picker/NPPicker";
+import EPPicker from "./components/ep-explorer/EPPicker";
import EPExplorer from "./components/ep-explorer/EPExplorer";
import shuffleArray from "./lib/shuffle-array";
import defaultTextOptions from "./lib/default-text-options";
@@ -253,6 +254,7 @@ export {
APBlock,
Block,
EPDisplay,
+ EPPicker,
// OTHER
typePredicates,
grammarUnits,