@khanacademy/perseus-editor 2.15.5 → 2.15.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/es/index.js +190 -329
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +190 -338
- package/dist/index.js.map +1 -1
- package/dist/widgets/interaction-editor/function-editor.d.ts +19 -20
- package/dist/widgets/interaction-editor/interaction-editor.d.ts +23 -14
- package/dist/widgets/interaction-editor/label-editor.d.ts +15 -16
- package/dist/widgets/interaction-editor/line-editor.d.ts +23 -24
- package/dist/widgets/interaction-editor/mathquill-input.d.ts +12 -0
- package/dist/widgets/interaction-editor/movable-line-editor.d.ts +23 -26
- package/dist/widgets/interaction-editor/movable-point-editor.d.ts +18 -22
- package/dist/widgets/interaction-editor/parametric-editor.d.ts +21 -22
- package/dist/widgets/interaction-editor/point-editor.d.ts +13 -14
- package/dist/widgets/interaction-editor/rectangle-editor.d.ts +17 -18
- package/package.json +3 -2
- package/src/widgets/__stories__/interaction-editor.stories.tsx +17 -4
- package/src/widgets/interaction-editor/constraint-editor.tsx +9 -21
- package/src/widgets/interaction-editor/function-editor.tsx +26 -29
- package/src/widgets/interaction-editor/interaction-editor.tsx +24 -17
- package/src/widgets/interaction-editor/label-editor.tsx +20 -24
- package/src/widgets/interaction-editor/line-editor.tsx +30 -34
- package/src/widgets/interaction-editor/mathquill-input.tsx +81 -0
- package/src/widgets/interaction-editor/movable-line-editor.tsx +30 -34
- package/src/widgets/interaction-editor/movable-point-editor.tsx +23 -26
- package/src/widgets/interaction-editor/parametric-editor.tsx +28 -33
- package/src/widgets/interaction-editor/point-editor.tsx +17 -24
- package/src/widgets/interaction-editor/rectangle-editor.tsx +23 -32
- package/tsconfig-build.tsbuildinfo +1 -1
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Changeable } from "@khanacademy/perseus";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
3
|
+
type Props = Changeable.ChangeableProps & {
|
|
4
|
+
value: string;
|
|
5
|
+
rangeMin: string;
|
|
6
|
+
rangeMax: string;
|
|
7
|
+
color: string;
|
|
8
|
+
strokeDasharray: string;
|
|
9
|
+
strokeWidth: number;
|
|
10
|
+
};
|
|
11
|
+
type DefaultProps = {
|
|
12
|
+
value: Props["value"];
|
|
13
|
+
rangeMin: Props["rangeMin"];
|
|
14
|
+
rangeMax: Props["rangeMax"];
|
|
15
|
+
color: Props["color"];
|
|
16
|
+
strokeDasharray: Props["strokeDasharray"];
|
|
17
|
+
strokeWidth: Props["strokeWidth"];
|
|
18
|
+
};
|
|
19
|
+
declare class FunctionEditor extends React.Component<Props> {
|
|
20
|
+
static defaultProps: DefaultProps;
|
|
22
21
|
change: (arg1: any, arg2?: any, arg3?: any) => any;
|
|
23
22
|
serialize: () => any;
|
|
24
23
|
render(): React.ReactNode;
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Changeable } from "@khanacademy/perseus";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
type Graph = {
|
|
4
|
+
box: ReadonlyArray<number>;
|
|
5
|
+
labels: ReadonlyArray<string>;
|
|
6
|
+
range: ReadonlyArray<ReadonlyArray<number>>;
|
|
7
|
+
tickStep: ReadonlyArray<number>;
|
|
8
|
+
gridStep: ReadonlyArray<number>;
|
|
9
|
+
markings: string;
|
|
10
|
+
valid?: boolean;
|
|
11
|
+
};
|
|
12
|
+
type Props = Changeable.ChangeableProps & {
|
|
13
|
+
elements: ReadonlyArray<any>;
|
|
14
|
+
graph: Graph;
|
|
15
|
+
};
|
|
16
|
+
type DefaultProps = {
|
|
17
|
+
elements: Props["elements"];
|
|
18
|
+
graph: Props["graph"];
|
|
19
|
+
};
|
|
20
|
+
type State = any;
|
|
21
|
+
declare class InteractionEditor extends React.Component<Props, State> {
|
|
13
22
|
static widgetName: "interaction";
|
|
14
|
-
static defaultProps:
|
|
15
|
-
state:
|
|
16
|
-
UNSAFE_componentWillReceiveProps(nextProps:
|
|
23
|
+
static defaultProps: DefaultProps;
|
|
24
|
+
state: State;
|
|
25
|
+
UNSAFE_componentWillReceiveProps(nextProps: Props): void;
|
|
17
26
|
_getAllVarSubscripts(elements: ReadonlyArray<any>): ReadonlyArray<any>;
|
|
18
27
|
_getAllFunctionNames(elements: ReadonlyArray<any>): ReadonlyArray<string>;
|
|
19
28
|
_updateGraphProps: (arg1: any) => any;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Changeable } from "@khanacademy/perseus";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
3
|
+
type Props = Changeable.ChangeableProps & {
|
|
4
|
+
color: string;
|
|
5
|
+
coordX: string;
|
|
6
|
+
coordY: string;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
|
+
type DefaultProps = {
|
|
10
|
+
color: Props["color"];
|
|
11
|
+
coordX: Props["coordX"];
|
|
12
|
+
coordY: Props["coordY"];
|
|
13
|
+
label: Props["label"];
|
|
14
|
+
};
|
|
15
|
+
declare class LabelEditor extends React.Component<Props> {
|
|
16
|
+
static defaultProps: DefaultProps;
|
|
18
17
|
change: (arg1: any, arg2?: any, arg3?: any) => any;
|
|
19
18
|
serialize: () => any;
|
|
20
19
|
render(): React.ReactNode;
|
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Changeable } from "@khanacademy/perseus";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
3
|
+
type Props = Changeable.ChangeableProps & {
|
|
4
|
+
startX: string;
|
|
5
|
+
startY: string;
|
|
6
|
+
endX: string;
|
|
7
|
+
endY: string;
|
|
8
|
+
color: string;
|
|
9
|
+
strokeDasharray: string;
|
|
10
|
+
arrows: string;
|
|
11
|
+
strokeWidth: number;
|
|
12
|
+
};
|
|
13
|
+
type DefaultProps = {
|
|
14
|
+
startX: Props["startX"];
|
|
15
|
+
startY: Props["startY"];
|
|
16
|
+
endX: Props["endX"];
|
|
17
|
+
endY: Props["endY"];
|
|
18
|
+
color: Props["color"];
|
|
19
|
+
strokeDasharray: Props["strokeDasharray"];
|
|
20
|
+
arrows: Props["arrows"];
|
|
21
|
+
strokeWidth: Props["strokeWidth"];
|
|
22
|
+
};
|
|
23
|
+
declare class LineEditor extends React.Component<Props> {
|
|
24
|
+
static defaultProps: DefaultProps;
|
|
26
25
|
change: (arg1: any, arg2?: any, arg3?: any) => any;
|
|
27
26
|
serialize: () => any;
|
|
28
27
|
render(): React.ReactNode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type Props = {
|
|
3
|
+
value: string;
|
|
4
|
+
onChange: (value: string) => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* A simple Mathquill MathField input for the InteractionEditor.
|
|
8
|
+
* Unlike our other uses of Mathquill, we're not using a keypad here;
|
|
9
|
+
* it's just the input itself for use writing TeX.
|
|
10
|
+
*/
|
|
11
|
+
export default function MathquillInput(props: Props): JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Changeable } from "@khanacademy/perseus";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
constraintYMin: string;
|
|
26
|
-
constraintYMax: string;
|
|
27
|
-
};
|
|
3
|
+
type Props = Changeable.ChangeableProps & {
|
|
4
|
+
startX: string;
|
|
5
|
+
startY: string;
|
|
6
|
+
endX: string;
|
|
7
|
+
endY: string;
|
|
8
|
+
constraint: string;
|
|
9
|
+
snap: number;
|
|
10
|
+
constraintFn: string;
|
|
11
|
+
startSubscript: number;
|
|
12
|
+
endSubscript: number;
|
|
13
|
+
};
|
|
14
|
+
type DefaultProps = {
|
|
15
|
+
startX: Props["startX"];
|
|
16
|
+
startY: Props["startY"];
|
|
17
|
+
endX: Props["endX"];
|
|
18
|
+
endY: Props["endY"];
|
|
19
|
+
constraint: Props["constraint"];
|
|
20
|
+
snap: Props["snap"];
|
|
21
|
+
constraintFn: Props["constraintFn"];
|
|
22
|
+
};
|
|
23
|
+
declare class MovableLineEditor extends React.Component<Props> {
|
|
24
|
+
static defaultProps: DefaultProps;
|
|
28
25
|
change: (...args: any[]) => any;
|
|
29
26
|
serialize: () => any;
|
|
30
27
|
render(): React.ReactNode;
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Changeable } from "@khanacademy/perseus";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
constraintXMax: string;
|
|
21
|
-
constraintYMin: string;
|
|
22
|
-
constraintYMax: string;
|
|
23
|
-
};
|
|
3
|
+
type Props = Changeable.ChangeableProps & {
|
|
4
|
+
startX: string;
|
|
5
|
+
startY: string;
|
|
6
|
+
constraint: string;
|
|
7
|
+
snap: number;
|
|
8
|
+
constraintFn: string;
|
|
9
|
+
varSubscript: number;
|
|
10
|
+
};
|
|
11
|
+
type DefaultProps = {
|
|
12
|
+
startX: Props["startX"];
|
|
13
|
+
startY: Props["startY"];
|
|
14
|
+
constraint: Props["constraint"];
|
|
15
|
+
snap: Props["snap"];
|
|
16
|
+
constraintFn: Props["constraintFn"];
|
|
17
|
+
};
|
|
18
|
+
declare class MovablePointEditor extends React.Component<Props> {
|
|
19
|
+
static defaultProps: DefaultProps;
|
|
24
20
|
change: (...args: any[]) => any;
|
|
25
21
|
serialize: () => any;
|
|
26
22
|
render(): React.ReactNode;
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Changeable } from "@khanacademy/perseus";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
3
|
+
type Props = Changeable.ChangeableProps & {
|
|
4
|
+
x: string;
|
|
5
|
+
y: string;
|
|
6
|
+
rangeMin: string;
|
|
7
|
+
rangeMax: string;
|
|
8
|
+
color: string;
|
|
9
|
+
strokeDasharray: string;
|
|
10
|
+
strokeWidth: number;
|
|
11
|
+
};
|
|
12
|
+
type DefaultProps = {
|
|
13
|
+
x: Props["x"];
|
|
14
|
+
y: Props["y"];
|
|
15
|
+
rangeMin: Props["rangeMin"];
|
|
16
|
+
rangeMax: Props["rangeMax"];
|
|
17
|
+
color: Props["color"];
|
|
18
|
+
strokeDasharray: Props["strokeDasharray"];
|
|
19
|
+
strokeWidth: Props["strokeWidth"];
|
|
20
|
+
};
|
|
21
|
+
declare class ParametricEditor extends React.Component<Props> {
|
|
22
|
+
static defaultProps: DefaultProps;
|
|
24
23
|
change: (arg1: any, arg2?: any, arg3?: any) => any;
|
|
25
24
|
serialize: () => any;
|
|
26
25
|
render(): React.ReactNode;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Changeable } from "@khanacademy/perseus";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
3
|
+
type Props = Changeable.ChangeableProps & {
|
|
4
|
+
coordX: string;
|
|
5
|
+
coordY: string;
|
|
6
|
+
color: string;
|
|
7
|
+
};
|
|
8
|
+
type DefaultProps = {
|
|
9
|
+
coordX: Props["coordX"];
|
|
10
|
+
coordY: Props["coordY"];
|
|
11
|
+
color: Props["color"];
|
|
12
|
+
};
|
|
13
|
+
declare class PointEditor extends React.Component<Props> {
|
|
14
|
+
static defaultProps: DefaultProps;
|
|
16
15
|
change: (arg1: any, arg2?: any, arg3?: any) => any;
|
|
17
16
|
serialize: () => any;
|
|
18
17
|
render(): React.ReactNode;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Changeable } from "@khanacademy/perseus";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
3
|
+
type Props = Changeable.ChangeableProps & {
|
|
4
|
+
color: string;
|
|
5
|
+
coordX: string;
|
|
6
|
+
coordY: string;
|
|
7
|
+
height: string;
|
|
8
|
+
width: string;
|
|
9
|
+
};
|
|
10
|
+
type DefaultProps = {
|
|
11
|
+
color: Props["color"];
|
|
12
|
+
coordX: Props["coordX"];
|
|
13
|
+
coordY: Props["coordY"];
|
|
14
|
+
height: Props["height"];
|
|
15
|
+
width: Props["width"];
|
|
16
|
+
};
|
|
17
|
+
declare class RectangleEditor extends React.Component<Props> {
|
|
18
|
+
static defaultProps: DefaultProps;
|
|
20
19
|
change: (arg1: any, arg2?: any, arg3?: any) => any;
|
|
21
20
|
serialize: () => any;
|
|
22
21
|
render(): React.ReactNode;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Perseus editors",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "2.15.
|
|
6
|
+
"version": "2.15.7",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@khanacademy/kas": "^0.3.7",
|
|
26
26
|
"@khanacademy/kmath": "^0.1.8",
|
|
27
|
-
"@khanacademy/
|
|
27
|
+
"@khanacademy/math-input": "^16.4.0",
|
|
28
|
+
"@khanacademy/perseus": "^17.6.0",
|
|
28
29
|
"@khanacademy/perseus-core": "1.4.1"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {ApiOptions} from "@khanacademy/perseus";
|
|
2
|
-
import {action} from "@storybook/addon-actions";
|
|
3
1
|
import * as React from "react";
|
|
2
|
+
import {useState} from "react";
|
|
4
3
|
|
|
5
4
|
import InteractionEditor from "../interaction-editor";
|
|
6
5
|
|
|
@@ -15,10 +14,24 @@ export default {
|
|
|
15
14
|
} as Story;
|
|
16
15
|
|
|
17
16
|
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
17
|
+
const [elements, setElements] = useState();
|
|
18
|
+
const [graph, setGraph] = useState();
|
|
19
|
+
|
|
20
|
+
function handleChange(next) {
|
|
21
|
+
if (next.graph) {
|
|
22
|
+
setGraph(next.graph);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (next.elements) {
|
|
26
|
+
setElements(next.elements);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
return (
|
|
19
31
|
<InteractionEditor
|
|
20
|
-
onChange={
|
|
21
|
-
|
|
32
|
+
onChange={handleChange}
|
|
33
|
+
elements={elements}
|
|
34
|
+
graph={graph}
|
|
22
35
|
/>
|
|
23
36
|
);
|
|
24
37
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {components, Changeable, Dependencies} from "@khanacademy/perseus";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import MathquillInput from "./mathquill-input";
|
|
5
|
+
|
|
6
|
+
const {ButtonGroup, NumberInput} = components;
|
|
5
7
|
|
|
6
8
|
type Props = Changeable.ChangeableProps & {
|
|
7
9
|
constraint: string;
|
|
@@ -45,8 +47,6 @@ class ConstraintEditor extends React.Component<Props> {
|
|
|
45
47
|
render(): React.ReactNode {
|
|
46
48
|
const {TeX} = Dependencies.getDependencies();
|
|
47
49
|
|
|
48
|
-
const analyticsStub = {onAnalyticsEvent: () => Promise.resolve()};
|
|
49
|
-
|
|
50
50
|
return (
|
|
51
51
|
<div>
|
|
52
52
|
<div className="perseus-widget-row">
|
|
@@ -77,11 +77,9 @@ class ConstraintEditor extends React.Component<Props> {
|
|
|
77
77
|
<div className="graph-settings">
|
|
78
78
|
<div className="perseus-widget-row">
|
|
79
79
|
<TeX>x=</TeX>{" "}
|
|
80
|
-
<
|
|
81
|
-
buttonsVisible="never"
|
|
80
|
+
<MathquillInput
|
|
82
81
|
value={this.props.constraintFn}
|
|
83
82
|
onChange={this.change("constraintFn")}
|
|
84
|
-
analytics={analyticsStub}
|
|
85
83
|
/>
|
|
86
84
|
</div>
|
|
87
85
|
</div>
|
|
@@ -90,11 +88,9 @@ class ConstraintEditor extends React.Component<Props> {
|
|
|
90
88
|
<div className="graph-settings">
|
|
91
89
|
<div className="perseus-widget-row">
|
|
92
90
|
<TeX>y=</TeX>{" "}
|
|
93
|
-
<
|
|
94
|
-
buttonsVisible="never"
|
|
91
|
+
<MathquillInput
|
|
95
92
|
value={this.props.constraintFn}
|
|
96
93
|
onChange={this.change("constraintFn")}
|
|
97
|
-
analytics={analyticsStub}
|
|
98
94
|
/>
|
|
99
95
|
</div>
|
|
100
96
|
</div>
|
|
@@ -103,18 +99,14 @@ class ConstraintEditor extends React.Component<Props> {
|
|
|
103
99
|
<div className="perseus-widget-row">
|
|
104
100
|
<div className="perseus-widget-row">
|
|
105
101
|
<TeX>x \in \Large[</TeX>{" "}
|
|
106
|
-
<
|
|
107
|
-
buttonsVisible="never"
|
|
102
|
+
<MathquillInput
|
|
108
103
|
value={this.props.constraintXMin}
|
|
109
104
|
onChange={this.change("constraintXMin")}
|
|
110
|
-
analytics={analyticsStub}
|
|
111
105
|
/>
|
|
112
106
|
<TeX>, </TeX>{" "}
|
|
113
|
-
<
|
|
114
|
-
buttonsVisible="never"
|
|
107
|
+
<MathquillInput
|
|
115
108
|
value={this.props.constraintXMax}
|
|
116
109
|
onChange={this.change("constraintXMax")}
|
|
117
|
-
analytics={analyticsStub}
|
|
118
110
|
/>{" "}
|
|
119
111
|
<TeX>\Large]</TeX>
|
|
120
112
|
</div>
|
|
@@ -122,18 +114,14 @@ class ConstraintEditor extends React.Component<Props> {
|
|
|
122
114
|
<div className="perseus-widget-row">
|
|
123
115
|
<div className="perseus-widget-row">
|
|
124
116
|
<TeX>y \in \Large[</TeX>{" "}
|
|
125
|
-
<
|
|
126
|
-
buttonsVisible="never"
|
|
117
|
+
<MathquillInput
|
|
127
118
|
value={this.props.constraintYMin}
|
|
128
119
|
onChange={this.change("constraintYMin")}
|
|
129
|
-
analytics={analyticsStub}
|
|
130
120
|
/>
|
|
131
121
|
<TeX>, </TeX>{" "}
|
|
132
|
-
<
|
|
133
|
-
buttonsVisible="never"
|
|
122
|
+
<MathquillInput
|
|
134
123
|
value={this.props.constraintYMax}
|
|
135
124
|
onChange={this.change("constraintYMax")}
|
|
136
|
-
analytics={analyticsStub}
|
|
137
125
|
/>{" "}
|
|
138
126
|
<TeX>\Large]</TeX>
|
|
139
127
|
</div>
|
|
@@ -7,32 +7,35 @@ import {
|
|
|
7
7
|
ColorPicker,
|
|
8
8
|
DashPicker,
|
|
9
9
|
} from "@khanacademy/perseus";
|
|
10
|
-
import PropTypes from "prop-types";
|
|
11
10
|
import * as React from "react";
|
|
12
11
|
import _ from "underscore";
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
import MathquillInput from "./mathquill-input";
|
|
14
|
+
|
|
15
|
+
const {NumberInput} = components;
|
|
15
16
|
const {getDependencies} = Dependencies;
|
|
16
17
|
|
|
17
|
-
type
|
|
18
|
+
type Props = Changeable.ChangeableProps & {
|
|
19
|
+
value: string;
|
|
20
|
+
rangeMin: string;
|
|
21
|
+
rangeMax: string;
|
|
22
|
+
color: string;
|
|
23
|
+
strokeDasharray: string;
|
|
24
|
+
strokeWidth: number;
|
|
25
|
+
};
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
value: PropTypes.string,
|
|
28
|
-
rangeMin: PropTypes.string,
|
|
29
|
-
rangeMax: PropTypes.string,
|
|
30
|
-
color: PropTypes.string,
|
|
31
|
-
strokeDashArray: PropTypes.string,
|
|
32
|
-
strokeWidth: PropTypes.number,
|
|
33
|
-
};
|
|
27
|
+
type DefaultProps = {
|
|
28
|
+
value: Props["value"];
|
|
29
|
+
rangeMin: Props["rangeMin"];
|
|
30
|
+
rangeMax: Props["rangeMax"];
|
|
31
|
+
color: Props["color"];
|
|
32
|
+
strokeDasharray: Props["strokeDasharray"];
|
|
33
|
+
strokeWidth: Props["strokeWidth"];
|
|
34
|
+
};
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
// Editor for function plots
|
|
37
|
+
class FunctionEditor extends React.Component<Props> {
|
|
38
|
+
static defaultProps: DefaultProps = {
|
|
36
39
|
value: "x",
|
|
37
40
|
rangeMin: "-10",
|
|
38
41
|
rangeMax: "10",
|
|
@@ -51,33 +54,27 @@ class FunctionEditor extends React.Component<FunctionEditorProps> {
|
|
|
51
54
|
|
|
52
55
|
render(): React.ReactNode {
|
|
53
56
|
const {TeX} = getDependencies();
|
|
54
|
-
const analyticsStub = {onAnalyticsEvent: () => Promise.resolve()};
|
|
55
57
|
|
|
56
58
|
return (
|
|
57
59
|
<div className="graph-settings">
|
|
58
60
|
<div className="perseus-widget-row">
|
|
61
|
+
{/* @ts-expect-error - TS2339 - Property 'funcName' does not exist on type props. */}
|
|
59
62
|
<TeX>{this.props.funcName + "(x)="}</TeX>{" "}
|
|
60
|
-
<
|
|
61
|
-
buttonsVisible="never"
|
|
63
|
+
<MathquillInput
|
|
62
64
|
value={this.props.value}
|
|
63
65
|
onChange={this.change("value")}
|
|
64
|
-
analytics={analyticsStub}
|
|
65
66
|
/>
|
|
66
67
|
</div>
|
|
67
68
|
<div className="perseus-widget-row">
|
|
68
69
|
Range: <TeX>\Large(</TeX>
|
|
69
|
-
<
|
|
70
|
-
buttonsVisible="never"
|
|
70
|
+
<MathquillInput
|
|
71
71
|
value={this.props.rangeMin}
|
|
72
72
|
onChange={this.change("rangeMin")}
|
|
73
|
-
analytics={analyticsStub}
|
|
74
73
|
/>
|
|
75
74
|
<TeX>,</TeX>{" "}
|
|
76
|
-
<
|
|
77
|
-
buttonsVisible="never"
|
|
75
|
+
<MathquillInput
|
|
78
76
|
value={this.props.rangeMax}
|
|
79
77
|
onChange={this.change("rangeMax")}
|
|
80
|
-
analytics={analyticsStub}
|
|
81
78
|
/>
|
|
82
79
|
<TeX>\Large)</TeX>
|
|
83
80
|
</div>
|