@khanacademy/perseus-editor 2.15.4 → 2.15.5

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/es/index.js +329 -338
  3. package/dist/es/index.js.map +1 -1
  4. package/dist/index.js +402 -412
  5. package/dist/index.js.map +1 -1
  6. package/dist/widgets/interaction-editor/function-editor.d.ts +26 -0
  7. package/dist/widgets/interaction-editor/index.d.ts +2 -0
  8. package/dist/widgets/interaction-editor/label-editor.d.ts +22 -0
  9. package/dist/widgets/interaction-editor/line-editor.d.ts +30 -0
  10. package/dist/widgets/interaction-editor/movable-line-editor.d.ts +32 -0
  11. package/dist/widgets/interaction-editor/movable-point-editor.d.ts +28 -0
  12. package/dist/widgets/interaction-editor/parametric-editor.d.ts +28 -0
  13. package/dist/widgets/interaction-editor/point-editor.d.ts +20 -0
  14. package/dist/widgets/interaction-editor/rectangle-editor.d.ts +24 -0
  15. package/package.json +2 -2
  16. package/src/widgets/__stories__/interaction-editor.stories.tsx +24 -0
  17. package/src/widgets/interaction-editor/function-editor.tsx +111 -0
  18. package/src/widgets/interaction-editor/index.ts +3 -0
  19. package/src/widgets/{interaction-editor.tsx → interaction-editor/interaction-editor.tsx} +14 -768
  20. package/src/widgets/interaction-editor/label-editor.tsx +91 -0
  21. package/src/widgets/interaction-editor/line-editor.tsx +129 -0
  22. package/src/widgets/interaction-editor/movable-line-editor.tsx +125 -0
  23. package/src/widgets/interaction-editor/movable-point-editor.tsx +92 -0
  24. package/src/widgets/interaction-editor/parametric-editor.tsx +122 -0
  25. package/src/widgets/interaction-editor/point-editor.tsx +79 -0
  26. package/src/widgets/interaction-editor/rectangle-editor.tsx +105 -0
  27. package/tsconfig-build.tsbuildinfo +1 -1
  28. package/dist/widgets/{interaction → interaction-editor}/constraint-editor.d.ts +0 -0
  29. package/dist/widgets/{interaction-editor.d.ts → interaction-editor/interaction-editor.d.ts} +1 -1
  30. /package/src/widgets/{interaction → interaction-editor}/constraint-editor.tsx +0 -0
@@ -0,0 +1,26 @@
1
+ import PropTypes from "prop-types";
2
+ import * as React from "react";
3
+ type FunctionEditorProps = any;
4
+ declare class FunctionEditor extends React.Component<FunctionEditorProps> {
5
+ static propTypes: {
6
+ value: PropTypes.Requireable<string>;
7
+ rangeMin: PropTypes.Requireable<string>;
8
+ rangeMax: PropTypes.Requireable<string>;
9
+ color: PropTypes.Requireable<string>;
10
+ strokeDashArray: PropTypes.Requireable<string>;
11
+ strokeWidth: PropTypes.Requireable<number>;
12
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
13
+ };
14
+ static defaultProps: {
15
+ value: string;
16
+ rangeMin: string;
17
+ rangeMax: string;
18
+ color: "#6495ED";
19
+ strokeDasharray: string;
20
+ strokeWidth: number;
21
+ };
22
+ change: (arg1: any, arg2?: any, arg3?: any) => any;
23
+ serialize: () => any;
24
+ render(): React.ReactNode;
25
+ }
26
+ export default FunctionEditor;
@@ -0,0 +1,2 @@
1
+ import InteractionEditor from "./interaction-editor";
2
+ export default InteractionEditor;
@@ -0,0 +1,22 @@
1
+ import PropTypes from "prop-types";
2
+ import * as React from "react";
3
+ type LabelEditorProps = any;
4
+ declare class LabelEditor extends React.Component<LabelEditorProps> {
5
+ static propTypes: {
6
+ color: PropTypes.Requireable<string>;
7
+ coordX: PropTypes.Requireable<string>;
8
+ coordY: PropTypes.Requireable<string>;
9
+ label: PropTypes.Requireable<string>;
10
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
11
+ };
12
+ static defaultProps: {
13
+ coordX: string;
14
+ coordY: string;
15
+ color: "black";
16
+ label: string;
17
+ };
18
+ change: (arg1: any, arg2?: any, arg3?: any) => any;
19
+ serialize: () => any;
20
+ render(): React.ReactNode;
21
+ }
22
+ export default LabelEditor;
@@ -0,0 +1,30 @@
1
+ import PropTypes from "prop-types";
2
+ import * as React from "react";
3
+ type LineEditorProps = any;
4
+ declare class LineEditor extends React.Component<LineEditorProps> {
5
+ static propTypes: {
6
+ startX: PropTypes.Requireable<string>;
7
+ startY: PropTypes.Requireable<string>;
8
+ endX: PropTypes.Requireable<string>;
9
+ endY: PropTypes.Requireable<string>;
10
+ color: PropTypes.Requireable<string>;
11
+ strokeDasharray: PropTypes.Requireable<string>;
12
+ arrows: PropTypes.Requireable<string>;
13
+ strokeWidth: PropTypes.Requireable<number>;
14
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
15
+ };
16
+ static defaultProps: {
17
+ startX: string;
18
+ startY: string;
19
+ endX: string;
20
+ endY: string;
21
+ color: "black";
22
+ strokeDasharray: string;
23
+ arrows: string;
24
+ strokeWidth: number;
25
+ };
26
+ change: (arg1: any, arg2?: any, arg3?: any) => any;
27
+ serialize: () => any;
28
+ render(): React.ReactNode;
29
+ }
30
+ export default LineEditor;
@@ -0,0 +1,32 @@
1
+ import PropTypes from "prop-types";
2
+ import * as React from "react";
3
+ type MovableLineEditorProps = any;
4
+ declare class MovableLineEditor extends React.Component<MovableLineEditorProps> {
5
+ static propTypes: {
6
+ startX: PropTypes.Requireable<string>;
7
+ startY: PropTypes.Requireable<string>;
8
+ endX: PropTypes.Requireable<string>;
9
+ endY: PropTypes.Requireable<string>;
10
+ constraint: PropTypes.Requireable<string>;
11
+ snap: PropTypes.Requireable<number>;
12
+ constraintFn: PropTypes.Requireable<string>;
13
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
14
+ };
15
+ static defaultProps: {
16
+ startX: string;
17
+ startY: string;
18
+ endX: string;
19
+ endY: string;
20
+ constraint: string;
21
+ snap: number;
22
+ constraintFn: string;
23
+ constraintXMin: string;
24
+ constraintXMax: string;
25
+ constraintYMin: string;
26
+ constraintYMax: string;
27
+ };
28
+ change: (...args: any[]) => any;
29
+ serialize: () => any;
30
+ render(): React.ReactNode;
31
+ }
32
+ export default MovableLineEditor;
@@ -0,0 +1,28 @@
1
+ import PropTypes from "prop-types";
2
+ import * as React from "react";
3
+ type MovablePointEditorProps = any;
4
+ declare class MovablePointEditor extends React.Component<MovablePointEditorProps> {
5
+ static propTypes: {
6
+ startX: PropTypes.Requireable<string>;
7
+ startY: PropTypes.Requireable<string>;
8
+ constraint: PropTypes.Requireable<string>;
9
+ snap: PropTypes.Requireable<number>;
10
+ constraintFn: PropTypes.Requireable<string>;
11
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
12
+ };
13
+ static defaultProps: {
14
+ startX: string;
15
+ startY: string;
16
+ constraint: string;
17
+ snap: number;
18
+ constraintFn: string;
19
+ constraintXMin: string;
20
+ constraintXMax: string;
21
+ constraintYMin: string;
22
+ constraintYMax: string;
23
+ };
24
+ change: (...args: any[]) => any;
25
+ serialize: () => any;
26
+ render(): React.ReactNode;
27
+ }
28
+ export default MovablePointEditor;
@@ -0,0 +1,28 @@
1
+ import PropTypes from "prop-types";
2
+ import * as React from "react";
3
+ type ParametricEditorProps = any;
4
+ declare class ParametricEditor extends React.Component<ParametricEditorProps> {
5
+ static propTypes: {
6
+ x: PropTypes.Requireable<string>;
7
+ y: PropTypes.Requireable<string>;
8
+ rangeMin: PropTypes.Requireable<string>;
9
+ rangeMax: PropTypes.Requireable<string>;
10
+ color: PropTypes.Requireable<string>;
11
+ strokeDashArray: PropTypes.Requireable<string>;
12
+ strokeWidth: PropTypes.Requireable<number>;
13
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
14
+ };
15
+ static defaultProps: {
16
+ x: string;
17
+ y: string;
18
+ rangeMin: string;
19
+ rangeMax: string;
20
+ color: "#6495ED";
21
+ strokeDasharray: string;
22
+ strokeWidth: number;
23
+ };
24
+ change: (arg1: any, arg2?: any, arg3?: any) => any;
25
+ serialize: () => any;
26
+ render(): React.ReactNode;
27
+ }
28
+ export default ParametricEditor;
@@ -0,0 +1,20 @@
1
+ import PropTypes from "prop-types";
2
+ import * as React from "react";
3
+ type PointEditorProps = any;
4
+ declare class PointEditor extends React.Component<PointEditorProps> {
5
+ static propTypes: {
6
+ coordX: PropTypes.Requireable<string>;
7
+ coordY: PropTypes.Requireable<string>;
8
+ color: PropTypes.Requireable<string>;
9
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
10
+ };
11
+ static defaultProps: {
12
+ coordX: string;
13
+ coordY: string;
14
+ color: "black";
15
+ };
16
+ change: (arg1: any, arg2?: any, arg3?: any) => any;
17
+ serialize: () => any;
18
+ render(): React.ReactNode;
19
+ }
20
+ export default PointEditor;
@@ -0,0 +1,24 @@
1
+ import PropTypes from "prop-types";
2
+ import * as React from "react";
3
+ type RectangleEditorProps = any;
4
+ declare class RectangleEditor extends React.Component<RectangleEditorProps> {
5
+ static propTypes: {
6
+ color: PropTypes.Requireable<string>;
7
+ coordX: PropTypes.Requireable<string>;
8
+ coordY: PropTypes.Requireable<string>;
9
+ height: PropTypes.Requireable<string>;
10
+ width: PropTypes.Requireable<string>;
11
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
12
+ };
13
+ static defaultProps: {
14
+ coordX: string;
15
+ coordY: string;
16
+ width: string;
17
+ height: string;
18
+ color: "#9AB8ED";
19
+ };
20
+ change: (arg1: any, arg2?: any, arg3?: any) => any;
21
+ serialize: () => any;
22
+ render(): React.ReactNode;
23
+ }
24
+ export default RectangleEditor;
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.4",
6
+ "version": "2.15.5",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@khanacademy/kas": "^0.3.7",
26
26
  "@khanacademy/kmath": "^0.1.8",
27
- "@khanacademy/perseus": "^17.4.0",
27
+ "@khanacademy/perseus": "^17.5.0",
28
28
  "@khanacademy/perseus-core": "1.4.1"
29
29
  },
30
30
  "devDependencies": {
@@ -0,0 +1,24 @@
1
+ import {ApiOptions} from "@khanacademy/perseus";
2
+ import {action} from "@storybook/addon-actions";
3
+ import * as React from "react";
4
+
5
+ import InteractionEditor from "../interaction-editor";
6
+
7
+ type StoryArgs = Record<any, any>;
8
+
9
+ type Story = {
10
+ title: string;
11
+ };
12
+
13
+ export default {
14
+ title: "Perseus/Editor/Widgets/Interaction Editor",
15
+ } as Story;
16
+
17
+ export const Default = (args: StoryArgs): React.ReactElement => {
18
+ return (
19
+ <InteractionEditor
20
+ onChange={action("onChange")}
21
+ apiOptions={ApiOptions.defaults}
22
+ />
23
+ );
24
+ };
@@ -0,0 +1,111 @@
1
+ import {
2
+ components,
3
+ Changeable,
4
+ Dependencies,
5
+ EditorJsonify,
6
+ KhanColors,
7
+ ColorPicker,
8
+ DashPicker,
9
+ } from "@khanacademy/perseus";
10
+ import PropTypes from "prop-types";
11
+ import * as React from "react";
12
+ import _ from "underscore";
13
+
14
+ const {MathInput, NumberInput} = components;
15
+ const {getDependencies} = Dependencies;
16
+
17
+ type FunctionEditorProps = any;
18
+
19
+ //
20
+ // Editor for function plots
21
+ //
22
+ // TODO(eater): Factor this out
23
+ //
24
+ class FunctionEditor extends React.Component<FunctionEditorProps> {
25
+ static propTypes = {
26
+ ...Changeable.propTypes,
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
+ };
34
+
35
+ static defaultProps = {
36
+ value: "x",
37
+ rangeMin: "-10",
38
+ rangeMax: "10",
39
+ color: KhanColors.BLUE,
40
+ strokeDasharray: "",
41
+ strokeWidth: 2,
42
+ };
43
+
44
+ change: (arg1: any, arg2?: any, arg3?: any) => any = (...args) => {
45
+ return Changeable.change.apply(this, args);
46
+ };
47
+
48
+ serialize = () => {
49
+ return EditorJsonify.serialize.call(this);
50
+ };
51
+
52
+ render(): React.ReactNode {
53
+ const {TeX} = getDependencies();
54
+ const analyticsStub = {onAnalyticsEvent: () => Promise.resolve()};
55
+
56
+ return (
57
+ <div className="graph-settings">
58
+ <div className="perseus-widget-row">
59
+ <TeX>{this.props.funcName + "(x)="}</TeX>{" "}
60
+ <MathInput
61
+ buttonsVisible="never"
62
+ value={this.props.value}
63
+ onChange={this.change("value")}
64
+ analytics={analyticsStub}
65
+ />
66
+ </div>
67
+ <div className="perseus-widget-row">
68
+ Range: <TeX>\Large(</TeX>
69
+ <MathInput
70
+ buttonsVisible="never"
71
+ value={this.props.rangeMin}
72
+ onChange={this.change("rangeMin")}
73
+ analytics={analyticsStub}
74
+ />
75
+ <TeX>,</TeX>{" "}
76
+ <MathInput
77
+ buttonsVisible="never"
78
+ value={this.props.rangeMax}
79
+ onChange={this.change("rangeMax")}
80
+ analytics={analyticsStub}
81
+ />
82
+ <TeX>\Large)</TeX>
83
+ </div>
84
+ <div className="perseus-widget-row">
85
+ <ColorPicker
86
+ value={this.props.color}
87
+ onChange={this.change("color")}
88
+ />
89
+ </div>
90
+ <div className="perseus-widget-row">
91
+ <DashPicker
92
+ value={this.props.strokeDasharray}
93
+ onChange={this.change("strokeDasharray")}
94
+ />
95
+ </div>
96
+ <div className="perseus-widget-row">
97
+ <div className="perseus-widget-left-col">
98
+ Width:{" "}
99
+ <NumberInput
100
+ value={this.props.strokeWidth}
101
+ placeholder={2}
102
+ onChange={this.change("strokeWidth")}
103
+ />
104
+ </div>
105
+ </div>
106
+ </div>
107
+ );
108
+ }
109
+ }
110
+
111
+ export default FunctionEditor;
@@ -0,0 +1,3 @@
1
+ import InteractionEditor from "./interaction-editor";
2
+
3
+ export default InteractionEditor;