@khanacademy/perseus-editor 17.0.5 → 17.0.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/dist/components/graph-settings.d.ts +92 -1
- package/dist/components/json-editor.d.ts +27 -1
- package/dist/es/index.js +126 -115
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +125 -117
- package/dist/index.js.map +1 -1
- package/dist/widgets/interaction-editor/interaction-editor.d.ts +5 -4
- package/package.json +12 -13
|
@@ -1,2 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Used in the editors for the Grapher and Interaction widgets.
|
|
3
|
+
*/
|
|
4
|
+
import { Changeable } from "@khanacademy/perseus";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import type { Coords } from "@khanacademy/perseus";
|
|
7
|
+
type Props = {
|
|
8
|
+
editableSettings: ReadonlyArray<"canvas" | "graph" | "snap" | "image" | "measure">;
|
|
9
|
+
box: readonly number[];
|
|
10
|
+
labels: readonly string[];
|
|
11
|
+
range: Coords;
|
|
12
|
+
step: [number, number];
|
|
13
|
+
gridStep: [number, number];
|
|
14
|
+
snapStep: [number, number];
|
|
15
|
+
valid: boolean;
|
|
16
|
+
backgroundImage: any;
|
|
17
|
+
markings: "graph" | "grid" | "none";
|
|
18
|
+
showProtractor?: boolean;
|
|
19
|
+
showRuler?: boolean;
|
|
20
|
+
showTooltips?: boolean;
|
|
21
|
+
rulerLabel: string;
|
|
22
|
+
rulerTicks: number;
|
|
23
|
+
} & Changeable.ChangeableProps;
|
|
24
|
+
type DefaultProps = {
|
|
25
|
+
editableSettings: Props["editableSettings"];
|
|
26
|
+
box: Props["box"];
|
|
27
|
+
labels: Props["labels"];
|
|
28
|
+
range: Props["range"];
|
|
29
|
+
step: Props["step"];
|
|
30
|
+
gridStep: Props["gridStep"];
|
|
31
|
+
snapStep: Props["snapStep"];
|
|
32
|
+
valid: Props["valid"];
|
|
33
|
+
backgroundImage: Props["backgroundImage"];
|
|
34
|
+
markings: Props["markings"];
|
|
35
|
+
rulerLabel: Props["rulerLabel"];
|
|
36
|
+
rulerTicks: Props["rulerTicks"];
|
|
37
|
+
showProtractor?: Props["showProtractor"];
|
|
38
|
+
showRuler?: Props["showRuler"];
|
|
39
|
+
showTooltips?: Props["showTooltips"];
|
|
40
|
+
};
|
|
41
|
+
type State = {
|
|
42
|
+
labelsTextbox: string[];
|
|
43
|
+
gridStepTextbox: number[];
|
|
44
|
+
snapStepTextbox: number[];
|
|
45
|
+
stepTextbox: number[];
|
|
46
|
+
rangeTextbox: any[];
|
|
47
|
+
backgroundImage: any;
|
|
48
|
+
};
|
|
49
|
+
declare class GraphSettings extends React.Component<Props, State> {
|
|
50
|
+
static displayName: "GraphSettings";
|
|
51
|
+
static defaultProps: DefaultProps;
|
|
52
|
+
_isMounted: boolean;
|
|
53
|
+
constructor(props: any);
|
|
54
|
+
getInitialState(): {
|
|
55
|
+
labelsTextbox: any;
|
|
56
|
+
gridStepTextbox: any;
|
|
57
|
+
snapStepTextbox: any;
|
|
58
|
+
stepTextbox: any;
|
|
59
|
+
rangeTextbox: any;
|
|
60
|
+
backgroundImage: any;
|
|
61
|
+
};
|
|
62
|
+
componentDidMount(): void;
|
|
63
|
+
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
64
|
+
componentWillUnmount(): void;
|
|
65
|
+
stateFromProps(props: any): {
|
|
66
|
+
labelsTextbox: any;
|
|
67
|
+
gridStepTextbox: any;
|
|
68
|
+
snapStepTextbox: any;
|
|
69
|
+
stepTextbox: any;
|
|
70
|
+
rangeTextbox: any;
|
|
71
|
+
backgroundImage: any;
|
|
72
|
+
};
|
|
73
|
+
change(...args: any[]): any;
|
|
74
|
+
changeRulerLabel(e: any): void;
|
|
75
|
+
changeRulerTicks(e: any): void;
|
|
76
|
+
changeBackgroundUrl(e: any): void;
|
|
77
|
+
renderLabelChoices(choices: any): React.JSX.Element[];
|
|
78
|
+
validRange(range: any): true | "Range must be a valid number" | "Range must have a higher number on the right";
|
|
79
|
+
validateStepValue(settings: any): string | true;
|
|
80
|
+
validSnapStep(step: any, range: any): string | true;
|
|
81
|
+
validGridStep(step: any, range: any): string | true;
|
|
82
|
+
validStep(step: any, range: any): string | true;
|
|
83
|
+
validBackgroundImageSize(image: any): true | "Image must be smaller than 450px x 450px.";
|
|
84
|
+
validateGraphSettings(range: any, step: any, gridStep: any, snapStep: any, image: any): any;
|
|
85
|
+
changeLabel(i: any, e: any): void;
|
|
86
|
+
changeRange(i: any, values: any): void;
|
|
87
|
+
changeStep(step: any): void;
|
|
88
|
+
changeSnapStep(snapStep: any): void;
|
|
89
|
+
changeGridStep(gridStep: any): void;
|
|
90
|
+
changeGraph(): void;
|
|
91
|
+
render(): React.JSX.Element;
|
|
92
|
+
}
|
|
2
93
|
export default GraphSettings;
|
|
@@ -1,2 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
multiLine: boolean;
|
|
4
|
+
value: any;
|
|
5
|
+
onChange: (newJson: any) => void;
|
|
6
|
+
};
|
|
7
|
+
type DefaultProps = {
|
|
8
|
+
value: Props["value"];
|
|
9
|
+
};
|
|
10
|
+
type State = {
|
|
11
|
+
currentValue: string | undefined;
|
|
12
|
+
valid: boolean | undefined;
|
|
13
|
+
};
|
|
14
|
+
declare class JsonEditor extends React.Component<Props, State> {
|
|
15
|
+
static displayName: "JsonEditor";
|
|
16
|
+
static defaultProps: DefaultProps;
|
|
17
|
+
constructor(props: any);
|
|
18
|
+
getInitialState(): {
|
|
19
|
+
currentValue: string;
|
|
20
|
+
valid: boolean;
|
|
21
|
+
};
|
|
22
|
+
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
23
|
+
handleKeyDown(e: any): void;
|
|
24
|
+
handleChange(e: any): void;
|
|
25
|
+
handleBlur(e: any): void;
|
|
26
|
+
render(): React.JSX.Element;
|
|
27
|
+
}
|
|
2
28
|
export default JsonEditor;
|
package/dist/es/index.js
CHANGED
|
@@ -4,7 +4,6 @@ export { widgets } from '@khanacademy/perseus';
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useId, useRef, useEffect, useState } from 'react';
|
|
6
6
|
import _ from 'underscore';
|
|
7
|
-
import createReactClass from 'create-react-class';
|
|
8
7
|
import Clickable from '@khanacademy/wonder-blocks-clickable';
|
|
9
8
|
import { color, spacing, font } from '@khanacademy/wonder-blocks-tokens';
|
|
10
9
|
import { StyleSheet, css } from 'aphrodite';
|
|
@@ -46,7 +45,7 @@ import arrowCounterClockwise from '@phosphor-icons/core/bold/arrow-counter-clock
|
|
|
46
45
|
|
|
47
46
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
48
47
|
const libName = "@khanacademy/perseus-editor";
|
|
49
|
-
const libVersion = "17.0.
|
|
48
|
+
const libVersion = "17.0.7";
|
|
50
49
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
51
50
|
|
|
52
51
|
function _extends() {
|
|
@@ -142,21 +141,27 @@ const DeviceFramer = ({
|
|
|
142
141
|
};
|
|
143
142
|
|
|
144
143
|
/* eslint-disable @babel/no-invalid-this */
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
class JsonEditor extends React.Component {
|
|
145
|
+
constructor(props) {
|
|
146
|
+
super(props);
|
|
147
|
+
this.state = this.getInitialState();
|
|
148
|
+
this.handleBlur = this.handleBlur.bind(this);
|
|
149
|
+
this.handleChange = this.handleChange.bind(this);
|
|
150
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
151
|
+
}
|
|
152
|
+
getInitialState() {
|
|
148
153
|
return {
|
|
149
154
|
currentValue: JSON.stringify(this.props.value, null, 4),
|
|
150
155
|
valid: true
|
|
151
156
|
};
|
|
152
|
-
}
|
|
153
|
-
UNSAFE_componentWillReceiveProps
|
|
154
|
-
const shouldReplaceContent = !this.state.valid || !_.isEqual(nextProps.value, JSON.parse(this.state.currentValue));
|
|
157
|
+
}
|
|
158
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
159
|
+
const shouldReplaceContent = !this.state.valid || !_.isEqual(nextProps.value, JSON.parse(this.state.currentValue ? this.state.currentValue : ""));
|
|
155
160
|
if (shouldReplaceContent) {
|
|
156
161
|
this.setState(this.getInitialState());
|
|
157
162
|
}
|
|
158
|
-
}
|
|
159
|
-
handleKeyDown
|
|
163
|
+
}
|
|
164
|
+
handleKeyDown(e) {
|
|
160
165
|
// This handler allows the tab character to be entered by pressing
|
|
161
166
|
// tab, instead of jumping to the next (non-existant) field
|
|
162
167
|
if (e.key === "Tab") {
|
|
@@ -170,8 +175,8 @@ const JsonEditor = createReactClass({
|
|
|
170
175
|
e.preventDefault();
|
|
171
176
|
this.handleChange(e);
|
|
172
177
|
}
|
|
173
|
-
}
|
|
174
|
-
handleChange
|
|
178
|
+
}
|
|
179
|
+
handleChange(e) {
|
|
175
180
|
const nextString = e.target.value;
|
|
176
181
|
try {
|
|
177
182
|
let json = JSON.parse(nextString);
|
|
@@ -195,10 +200,11 @@ const JsonEditor = createReactClass({
|
|
|
195
200
|
valid: false
|
|
196
201
|
});
|
|
197
202
|
}
|
|
198
|
-
}
|
|
203
|
+
}
|
|
204
|
+
|
|
199
205
|
// You can type whatever you want as you're typing, but if it's not valid
|
|
200
206
|
// when you blur, it will revert to the last valid value.
|
|
201
|
-
handleBlur
|
|
207
|
+
handleBlur(e) {
|
|
202
208
|
const nextString = e.target.value;
|
|
203
209
|
try {
|
|
204
210
|
let json = JSON.parse(nextString);
|
|
@@ -222,8 +228,8 @@ const JsonEditor = createReactClass({
|
|
|
222
228
|
valid: true
|
|
223
229
|
});
|
|
224
230
|
}
|
|
225
|
-
}
|
|
226
|
-
render
|
|
231
|
+
}
|
|
232
|
+
render() {
|
|
227
233
|
const classes = "perseus-json-editor " + (this.state.valid ? "valid" : "invalid");
|
|
228
234
|
return /*#__PURE__*/React.createElement("textarea", {
|
|
229
235
|
className: classes,
|
|
@@ -233,7 +239,11 @@ const JsonEditor = createReactClass({
|
|
|
233
239
|
onBlur: this.handleBlur
|
|
234
240
|
});
|
|
235
241
|
}
|
|
236
|
-
}
|
|
242
|
+
}
|
|
243
|
+
JsonEditor.displayName = void 0;
|
|
244
|
+
JsonEditor.defaultProps = {
|
|
245
|
+
value: {}
|
|
246
|
+
};
|
|
237
247
|
|
|
238
248
|
const {
|
|
239
249
|
InlineIcon: InlineIcon$a
|
|
@@ -25817,6 +25827,7 @@ GradedGroupSetEditor.defaultProps = {
|
|
|
25817
25827
|
};
|
|
25818
25828
|
const setArrayItem = (list, i, value) => [...list.slice(0, i), value, ...list.slice(i + 1)];
|
|
25819
25829
|
|
|
25830
|
+
/* eslint-disable react/forbid-prop-types, react/no-unsafe */
|
|
25820
25831
|
const {
|
|
25821
25832
|
ButtonGroup: ButtonGroup$7,
|
|
25822
25833
|
InfoTip: InfoTip$j,
|
|
@@ -25830,62 +25841,40 @@ const defaultBackgroundImage$3 = {
|
|
|
25830
25841
|
function numSteps$1(range, step) {
|
|
25831
25842
|
return Math.floor((range[1] - range[0]) / step);
|
|
25832
25843
|
}
|
|
25833
|
-
|
|
25834
|
-
|
|
25835
|
-
|
|
25836
|
-
|
|
25837
|
-
|
|
25838
|
-
|
|
25839
|
-
|
|
25840
|
-
|
|
25841
|
-
|
|
25842
|
-
|
|
25843
|
-
|
|
25844
|
-
|
|
25845
|
-
|
|
25846
|
-
|
|
25847
|
-
|
|
25848
|
-
|
|
25849
|
-
|
|
25850
|
-
rulerTicks: PropTypes.number
|
|
25851
|
-
}),
|
|
25852
|
-
getDefaultProps: function () {
|
|
25853
|
-
return {
|
|
25854
|
-
editableSettings: ["graph", "snap", "image", "measure"],
|
|
25855
|
-
box: [interactiveSizes.defaultBoxSizeSmall, interactiveSizes.defaultBoxSizeSmall],
|
|
25856
|
-
labels: ["x", "y"],
|
|
25857
|
-
range: [[-10, 10], [-10, 10]],
|
|
25858
|
-
step: [1, 1],
|
|
25859
|
-
gridStep: [1, 1],
|
|
25860
|
-
snapStep: [1, 1],
|
|
25861
|
-
valid: true,
|
|
25862
|
-
backgroundImage: defaultBackgroundImage$3,
|
|
25863
|
-
markings: "graph",
|
|
25864
|
-
showProtractor: false,
|
|
25865
|
-
showRuler: false,
|
|
25866
|
-
showTooltips: false,
|
|
25867
|
-
rulerLabel: "",
|
|
25868
|
-
rulerTicks: 10
|
|
25869
|
-
};
|
|
25870
|
-
},
|
|
25871
|
-
getInitialState: function () {
|
|
25844
|
+
class GraphSettings extends React.Component {
|
|
25845
|
+
constructor(props) {
|
|
25846
|
+
super(props);
|
|
25847
|
+
this._isMounted = false;
|
|
25848
|
+
this.state = this.getInitialState();
|
|
25849
|
+
this.change = this.change.bind(this);
|
|
25850
|
+
this.changeBackgroundUrl = this.changeBackgroundUrl.bind(this);
|
|
25851
|
+
this.changeGraph = this.changeGraph.bind(this);
|
|
25852
|
+
this.changeGridStep = this.changeGridStep.bind(this);
|
|
25853
|
+
this.changeLabel = this.changeLabel.bind(this);
|
|
25854
|
+
this.changeRange = this.changeRange.bind(this);
|
|
25855
|
+
this.changeRulerLabel = this.changeRulerLabel.bind(this);
|
|
25856
|
+
this.changeRulerTicks = this.changeRulerTicks.bind(this);
|
|
25857
|
+
this.changeSnapStep = this.changeSnapStep.bind(this);
|
|
25858
|
+
this.changeStep = this.changeStep.bind(this);
|
|
25859
|
+
}
|
|
25860
|
+
getInitialState() {
|
|
25872
25861
|
return this.stateFromProps(this.props);
|
|
25873
|
-
}
|
|
25874
|
-
componentDidMount
|
|
25862
|
+
}
|
|
25863
|
+
componentDidMount() {
|
|
25875
25864
|
// TODO(scottgrant): This is a hack to remove the deprecated call to
|
|
25876
25865
|
// this.isMounted() but is still considered an anti-pattern.
|
|
25877
25866
|
this._isMounted = true;
|
|
25878
25867
|
this.changeGraph = _.debounce(this.changeGraph, 300);
|
|
25879
|
-
}
|
|
25880
|
-
UNSAFE_componentWillReceiveProps
|
|
25868
|
+
}
|
|
25869
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
25881
25870
|
if (!_.isEqual(this.props.labels, nextProps.labels) || !_.isEqual(this.props.gridStep, nextProps.gridStep) || !_.isEqual(this.props.snapStep, nextProps.snapStep) || !_.isEqual(this.props.step, nextProps.step) || !_.isEqual(this.props.range, nextProps.range) || !_.isEqual(this.props.backgroundImage, nextProps.backgroundImage)) {
|
|
25882
25871
|
this.setState(this.stateFromProps(nextProps));
|
|
25883
25872
|
}
|
|
25884
|
-
}
|
|
25885
|
-
componentWillUnmount
|
|
25873
|
+
}
|
|
25874
|
+
componentWillUnmount() {
|
|
25886
25875
|
this._isMounted = false;
|
|
25887
|
-
}
|
|
25888
|
-
stateFromProps
|
|
25876
|
+
}
|
|
25877
|
+
stateFromProps(props) {
|
|
25889
25878
|
return {
|
|
25890
25879
|
labelsTextbox: props.labels,
|
|
25891
25880
|
gridStepTextbox: props.gridStep,
|
|
@@ -25894,27 +25883,29 @@ const GraphSettings = createReactClass({
|
|
|
25894
25883
|
rangeTextbox: props.range,
|
|
25895
25884
|
backgroundImage: _.clone(props.backgroundImage)
|
|
25896
25885
|
};
|
|
25897
|
-
}
|
|
25886
|
+
}
|
|
25887
|
+
|
|
25898
25888
|
// TODO(benchristel): Refactor this component to be an ES6 class, so we can
|
|
25899
25889
|
// type change as ChangeFn.
|
|
25900
25890
|
change(...args) {
|
|
25901
25891
|
// TODO(LEMS-2656): remove TS suppression
|
|
25902
25892
|
// @ts-expect-error: Argument of type 'any[]' is not assignable to parameter of type '[newPropsOrSinglePropName: string | { [key: string]: any; }, propValue?: any, callback?: (() => unknown) | undefined]'. Target requires 1 element(s) but source may have fewer.
|
|
25903
25893
|
return Changeable.change.apply(this, args);
|
|
25904
|
-
}
|
|
25894
|
+
}
|
|
25895
|
+
|
|
25905
25896
|
// TODO(aria): Make either a wrapper for standard events to work
|
|
25906
25897
|
// with this.change, or make these use some TextInput/NumberInput box
|
|
25907
|
-
changeRulerLabel
|
|
25898
|
+
changeRulerLabel(e) {
|
|
25908
25899
|
this.change({
|
|
25909
25900
|
rulerLabel: e.target.value
|
|
25910
25901
|
});
|
|
25911
|
-
}
|
|
25912
|
-
changeRulerTicks
|
|
25902
|
+
}
|
|
25903
|
+
changeRulerTicks(e) {
|
|
25913
25904
|
this.change({
|
|
25914
25905
|
rulerTicks: +e.target.value
|
|
25915
25906
|
});
|
|
25916
|
-
}
|
|
25917
|
-
changeBackgroundUrl
|
|
25907
|
+
}
|
|
25908
|
+
changeBackgroundUrl(e) {
|
|
25918
25909
|
// Only continue on blur or "enter"
|
|
25919
25910
|
if (e.type === "keypress" && e.key !== "Enter") {
|
|
25920
25911
|
return;
|
|
@@ -25940,16 +25931,16 @@ const GraphSettings = createReactClass({
|
|
|
25940
25931
|
} else {
|
|
25941
25932
|
setUrl(null, 0, 0);
|
|
25942
25933
|
}
|
|
25943
|
-
}
|
|
25944
|
-
renderLabelChoices
|
|
25934
|
+
}
|
|
25935
|
+
renderLabelChoices(choices) {
|
|
25945
25936
|
return _.map(choices, function ([name, value]) {
|
|
25946
25937
|
return /*#__PURE__*/React.createElement("option", {
|
|
25947
25938
|
key: value,
|
|
25948
25939
|
value: value
|
|
25949
25940
|
}, name);
|
|
25950
25941
|
});
|
|
25951
|
-
}
|
|
25952
|
-
validRange
|
|
25942
|
+
}
|
|
25943
|
+
validRange(range) {
|
|
25953
25944
|
const numbers = _.every(range, function (num) {
|
|
25954
25945
|
return _.isFinite(num);
|
|
25955
25946
|
});
|
|
@@ -25960,8 +25951,8 @@ const GraphSettings = createReactClass({
|
|
|
25960
25951
|
return "Range must have a higher number on the right";
|
|
25961
25952
|
}
|
|
25962
25953
|
return true;
|
|
25963
|
-
}
|
|
25964
|
-
validateStepValue
|
|
25954
|
+
}
|
|
25955
|
+
validateStepValue(settings) {
|
|
25965
25956
|
const {
|
|
25966
25957
|
step,
|
|
25967
25958
|
range,
|
|
@@ -25980,8 +25971,8 @@ const GraphSettings = createReactClass({
|
|
|
25980
25971
|
return name + " is too small, there can be at most " + maxTicks + " ticks.";
|
|
25981
25972
|
}
|
|
25982
25973
|
return true;
|
|
25983
|
-
}
|
|
25984
|
-
validSnapStep
|
|
25974
|
+
}
|
|
25975
|
+
validSnapStep(step, range) {
|
|
25985
25976
|
return this.validateStepValue({
|
|
25986
25977
|
step: step,
|
|
25987
25978
|
range: range,
|
|
@@ -25989,8 +25980,8 @@ const GraphSettings = createReactClass({
|
|
|
25989
25980
|
minTicks: 5,
|
|
25990
25981
|
maxTicks: 60
|
|
25991
25982
|
});
|
|
25992
|
-
}
|
|
25993
|
-
validGridStep
|
|
25983
|
+
}
|
|
25984
|
+
validGridStep(step, range) {
|
|
25994
25985
|
return this.validateStepValue({
|
|
25995
25986
|
step: step,
|
|
25996
25987
|
range: range,
|
|
@@ -25998,8 +25989,8 @@ const GraphSettings = createReactClass({
|
|
|
25998
25989
|
minTicks: 3,
|
|
25999
25990
|
maxTicks: 60
|
|
26000
25991
|
});
|
|
26001
|
-
}
|
|
26002
|
-
validStep
|
|
25992
|
+
}
|
|
25993
|
+
validStep(step, range) {
|
|
26003
25994
|
return this.validateStepValue({
|
|
26004
25995
|
step: step,
|
|
26005
25996
|
range: range,
|
|
@@ -26007,8 +25998,8 @@ const GraphSettings = createReactClass({
|
|
|
26007
25998
|
minTicks: 3,
|
|
26008
25999
|
maxTicks: 20
|
|
26009
26000
|
});
|
|
26010
|
-
}
|
|
26011
|
-
validBackgroundImageSize
|
|
26001
|
+
}
|
|
26002
|
+
validBackgroundImageSize(image) {
|
|
26012
26003
|
// Ignore empty images
|
|
26013
26004
|
if (!image.url) {
|
|
26014
26005
|
return true;
|
|
@@ -26018,8 +26009,8 @@ const GraphSettings = createReactClass({
|
|
|
26018
26009
|
return "Image must be smaller than 450px x 450px.";
|
|
26019
26010
|
}
|
|
26020
26011
|
return true;
|
|
26021
|
-
}
|
|
26022
|
-
validateGraphSettings
|
|
26012
|
+
}
|
|
26013
|
+
validateGraphSettings(range, step, gridStep, snapStep, image) {
|
|
26023
26014
|
const self = this;
|
|
26024
26015
|
let msg;
|
|
26025
26016
|
const goodRange = _.every(range, function (range) {
|
|
@@ -26056,16 +26047,16 @@ const GraphSettings = createReactClass({
|
|
|
26056
26047
|
return msg;
|
|
26057
26048
|
}
|
|
26058
26049
|
return true;
|
|
26059
|
-
}
|
|
26060
|
-
changeLabel
|
|
26050
|
+
}
|
|
26051
|
+
changeLabel(i, e) {
|
|
26061
26052
|
const val = e.target.value;
|
|
26062
26053
|
const labels = this.state.labelsTextbox.slice();
|
|
26063
26054
|
labels[i] = val;
|
|
26064
26055
|
this.setState({
|
|
26065
26056
|
labelsTextbox: labels
|
|
26066
26057
|
}, this.changeGraph);
|
|
26067
|
-
}
|
|
26068
|
-
changeRange
|
|
26058
|
+
}
|
|
26059
|
+
changeRange(i, values) {
|
|
26069
26060
|
const ranges = this.state.rangeTextbox.slice();
|
|
26070
26061
|
ranges[i] = values;
|
|
26071
26062
|
const step = this.state.stepTextbox.slice();
|
|
@@ -26074,6 +26065,9 @@ const GraphSettings = createReactClass({
|
|
|
26074
26065
|
const scale = Util.scaleFromExtent(ranges[i], this.props.box[i]);
|
|
26075
26066
|
if (this.validRange(ranges[i]) === true) {
|
|
26076
26067
|
step[i] = Util.tickStepFromExtent(ranges[i], this.props.box[i]);
|
|
26068
|
+
// Need to use the cast to number since gridStepFromTickStep
|
|
26069
|
+
// can return null or undefined. Ideally in the future let's adjust
|
|
26070
|
+
// the code to take this into account.
|
|
26077
26071
|
gridStep[i] = Util.gridStepFromTickStep(step[i], scale);
|
|
26078
26072
|
snapStep[i] = gridStep[i] / 2;
|
|
26079
26073
|
}
|
|
@@ -26083,26 +26077,26 @@ const GraphSettings = createReactClass({
|
|
|
26083
26077
|
snapStepTextbox: snapStep,
|
|
26084
26078
|
rangeTextbox: ranges
|
|
26085
26079
|
}, this.changeGraph);
|
|
26086
|
-
}
|
|
26087
|
-
changeStep
|
|
26080
|
+
}
|
|
26081
|
+
changeStep(step) {
|
|
26088
26082
|
this.setState({
|
|
26089
26083
|
stepTextbox: step
|
|
26090
26084
|
}, this.changeGraph);
|
|
26091
|
-
}
|
|
26092
|
-
changeSnapStep
|
|
26085
|
+
}
|
|
26086
|
+
changeSnapStep(snapStep) {
|
|
26093
26087
|
this.setState({
|
|
26094
26088
|
snapStepTextbox: snapStep
|
|
26095
26089
|
}, this.changeGraph);
|
|
26096
|
-
}
|
|
26097
|
-
changeGridStep
|
|
26090
|
+
}
|
|
26091
|
+
changeGridStep(gridStep) {
|
|
26098
26092
|
this.setState({
|
|
26099
26093
|
gridStepTextbox: gridStep,
|
|
26100
26094
|
snapStepTextbox: _.map(gridStep, function (step) {
|
|
26101
26095
|
return step / 2;
|
|
26102
26096
|
})
|
|
26103
26097
|
}, this.changeGraph);
|
|
26104
|
-
}
|
|
26105
|
-
changeGraph
|
|
26098
|
+
}
|
|
26099
|
+
changeGraph() {
|
|
26106
26100
|
const labels = this.state.labelsTextbox;
|
|
26107
26101
|
const range = _.map(this.state.rangeTextbox, function (range) {
|
|
26108
26102
|
return _.map(range, Number);
|
|
@@ -26134,9 +26128,9 @@ const GraphSettings = createReactClass({
|
|
|
26134
26128
|
valid: validationResult // a string message, not false
|
|
26135
26129
|
});
|
|
26136
26130
|
}
|
|
26137
|
-
}
|
|
26131
|
+
}
|
|
26138
26132
|
|
|
26139
|
-
render
|
|
26133
|
+
render() {
|
|
26140
26134
|
const scale = [KhanMath.roundTo(2, Util.scaleFromExtent(this.props.range[0], this.props.box[0])), KhanMath.roundTo(2, Util.scaleFromExtent(this.props.range[1], this.props.box[1]))];
|
|
26141
26135
|
const {
|
|
26142
26136
|
TeX
|
|
@@ -26323,7 +26317,25 @@ const GraphSettings = createReactClass({
|
|
|
26323
26317
|
}, n);
|
|
26324
26318
|
})))))));
|
|
26325
26319
|
}
|
|
26326
|
-
}
|
|
26320
|
+
}
|
|
26321
|
+
GraphSettings.displayName = void 0;
|
|
26322
|
+
GraphSettings.defaultProps = {
|
|
26323
|
+
editableSettings: ["graph", "snap", "image", "measure"],
|
|
26324
|
+
box: [interactiveSizes.defaultBoxSizeSmall, interactiveSizes.defaultBoxSizeSmall],
|
|
26325
|
+
labels: ["x", "y"],
|
|
26326
|
+
range: [[-10, 10], [-10, 10]],
|
|
26327
|
+
step: [1, 1],
|
|
26328
|
+
gridStep: [1, 1],
|
|
26329
|
+
snapStep: [1, 1],
|
|
26330
|
+
valid: true,
|
|
26331
|
+
backgroundImage: defaultBackgroundImage$3,
|
|
26332
|
+
markings: "graph",
|
|
26333
|
+
rulerLabel: "",
|
|
26334
|
+
rulerTicks: 10,
|
|
26335
|
+
showProtractor: false,
|
|
26336
|
+
showRuler: false,
|
|
26337
|
+
showTooltips: false
|
|
26338
|
+
};
|
|
26327
26339
|
|
|
26328
26340
|
const {
|
|
26329
26341
|
InfoTip: InfoTip$i,
|
|
@@ -27832,17 +27844,6 @@ const {
|
|
|
27832
27844
|
const {
|
|
27833
27845
|
unescapeMathMode
|
|
27834
27846
|
} = Util;
|
|
27835
|
-
const defaultInteractionProps = {
|
|
27836
|
-
graph: {
|
|
27837
|
-
box: [400, 400],
|
|
27838
|
-
labels: ["x", "y"],
|
|
27839
|
-
range: [[-10, 10], [-10, 10]],
|
|
27840
|
-
tickStep: [1, 1],
|
|
27841
|
-
gridStep: [1, 1],
|
|
27842
|
-
markings: "graph"
|
|
27843
|
-
},
|
|
27844
|
-
elements: []
|
|
27845
|
-
};
|
|
27846
27847
|
class InteractionEditor extends React.Component {
|
|
27847
27848
|
constructor(..._args) {
|
|
27848
27849
|
super(..._args);
|
|
@@ -28271,7 +28272,17 @@ class InteractionEditor extends React.Component {
|
|
|
28271
28272
|
}
|
|
28272
28273
|
}
|
|
28273
28274
|
InteractionEditor.widgetName = "interaction";
|
|
28274
|
-
InteractionEditor.defaultProps =
|
|
28275
|
+
InteractionEditor.defaultProps = {
|
|
28276
|
+
graph: {
|
|
28277
|
+
box: [400, 400],
|
|
28278
|
+
labels: ["x", "y"],
|
|
28279
|
+
range: [[-10, 10], [-10, 10]],
|
|
28280
|
+
tickStep: [1, 1],
|
|
28281
|
+
gridStep: [1, 1],
|
|
28282
|
+
markings: "graph"
|
|
28283
|
+
},
|
|
28284
|
+
elements: []
|
|
28285
|
+
};
|
|
28275
28286
|
|
|
28276
28287
|
var isProduction = process.env.NODE_ENV === 'production';
|
|
28277
28288
|
var prefix = 'Invariant failed';
|
|
@@ -28948,7 +28959,7 @@ class InteractiveGraphSettings extends React.Component {
|
|
|
28948
28959
|
}
|
|
28949
28960
|
InteractiveGraphSettings.defaultProps = {
|
|
28950
28961
|
box: [interactiveSizes.defaultBoxSizeSmall, interactiveSizes.defaultBoxSizeSmall],
|
|
28951
|
-
labels: ["x", "y"],
|
|
28962
|
+
labels: ["$x$", "$y$"],
|
|
28952
28963
|
range: [[-10, 10], [-10, 10]],
|
|
28953
28964
|
step: [1, 1],
|
|
28954
28965
|
gridStep: [1, 1],
|