@khanacademy/perseus-editor 2.15.4 → 2.15.6

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 (33) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/es/index.js +432 -580
  3. package/dist/es/index.js.map +1 -1
  4. package/dist/index.js +500 -658
  5. package/dist/index.js.map +1 -1
  6. package/dist/widgets/interaction-editor/function-editor.d.ts +25 -0
  7. package/dist/widgets/interaction-editor/index.d.ts +2 -0
  8. package/dist/widgets/interaction-editor/interaction-editor.d.ts +37 -0
  9. package/dist/widgets/interaction-editor/label-editor.d.ts +21 -0
  10. package/dist/widgets/interaction-editor/line-editor.d.ts +29 -0
  11. package/dist/widgets/interaction-editor/mathquill-input.d.ts +12 -0
  12. package/dist/widgets/interaction-editor/movable-line-editor.d.ts +29 -0
  13. package/dist/widgets/interaction-editor/movable-point-editor.d.ts +24 -0
  14. package/dist/widgets/interaction-editor/parametric-editor.d.ts +27 -0
  15. package/dist/widgets/interaction-editor/point-editor.d.ts +19 -0
  16. package/dist/widgets/interaction-editor/rectangle-editor.d.ts +23 -0
  17. package/package.json +3 -2
  18. package/src/widgets/__stories__/interaction-editor.stories.tsx +37 -0
  19. package/src/widgets/{interaction → interaction-editor}/constraint-editor.tsx +9 -21
  20. package/src/widgets/interaction-editor/function-editor.tsx +108 -0
  21. package/src/widgets/interaction-editor/index.ts +3 -0
  22. package/src/widgets/{interaction-editor.tsx → interaction-editor/interaction-editor.tsx} +40 -787
  23. package/src/widgets/interaction-editor/label-editor.tsx +87 -0
  24. package/src/widgets/interaction-editor/line-editor.tsx +125 -0
  25. package/src/widgets/interaction-editor/mathquill-input.tsx +81 -0
  26. package/src/widgets/interaction-editor/movable-line-editor.tsx +121 -0
  27. package/src/widgets/interaction-editor/movable-point-editor.tsx +89 -0
  28. package/src/widgets/interaction-editor/parametric-editor.tsx +117 -0
  29. package/src/widgets/interaction-editor/point-editor.tsx +72 -0
  30. package/src/widgets/interaction-editor/rectangle-editor.tsx +96 -0
  31. package/tsconfig-build.tsbuildinfo +1 -1
  32. package/dist/widgets/interaction-editor.d.ts +0 -28
  33. /package/dist/widgets/{interaction → interaction-editor}/constraint-editor.d.ts +0 -0
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var classNames = require('classnames');
20
20
  var kmath = require('@khanacademy/kmath');
21
21
  var KAS = require('@khanacademy/kas');
22
22
  var wonderStuffCore = require('@khanacademy/wonder-stuff-core');
23
+ var mathInput = require('@khanacademy/math-input');
23
24
  var Spacing = require('@khanacademy/wonder-blocks-spacing');
24
25
  var Typography = require('@khanacademy/wonder-blocks-typography');
25
26
  var Button = require('@khanacademy/wonder-blocks-button');
@@ -64,7 +65,7 @@ var i18n__namespace = /*#__PURE__*/_interopNamespace(i18n$1);
64
65
 
65
66
  // This file is processed by a Rollup plugin (replace) to inject the production
66
67
  const libName = "@khanacademy/perseus-editor";
67
- const libVersion = "2.15.4";
68
+ const libVersion = "2.15.6";
68
69
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
69
70
 
70
71
  function _extends() {
@@ -258,13 +259,13 @@ class SectionControlButton extends React__namespace.Component {
258
259
  role: "button",
259
260
  hideDefaultFocusRing: true,
260
261
  "aria-label": title,
261
- style: styles$f.button
262
+ style: styles$g.button
262
263
  }, _ref => {
263
264
  return /*#__PURE__*/React__namespace.createElement(InlineIcon$c, icon);
264
265
  });
265
266
  }
266
267
  }
267
- const styles$f = aphrodite.StyleSheet.create({
268
+ const styles$g = aphrodite.StyleSheet.create({
268
269
  button: {
269
270
  backgroundColor: Color__default["default"].gold,
270
271
  margin: 2,
@@ -20787,19 +20788,19 @@ class TexErrorView extends React__namespace.Component {
20787
20788
  const {
20788
20789
  showErrors
20789
20790
  } = this.state;
20790
- const iconStyle = showErrors ? styles$e.iconExpanded : styles$e.iconCollapsed;
20791
+ const iconStyle = showErrors ? styles$f.iconExpanded : styles$f.iconCollapsed;
20791
20792
  return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
20792
- style: styles$e.errorContainer
20793
+ style: styles$f.errorContainer
20793
20794
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
20794
- style: styles$e.title,
20795
+ style: styles$f.title,
20795
20796
  onClick: this.handleToggleTexErrors
20796
20797
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksIcon.PhosphorIcon, {
20797
20798
  icon: caretRight__default["default"],
20798
20799
  style: iconStyle
20799
20800
  }), "\xA0 TeX Errors (", errorList.length, ")"), showErrors && /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
20800
- style: styles$e.errorExplanation
20801
+ style: styles$f.errorExplanation
20801
20802
  }, "If your math doesn't display correctly, these errors might help you troubleshoot. Message #content-kitchen for help."), showErrors && errorList.map((e, index) => /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
20802
- style: styles$e.error,
20803
+ style: styles$f.error,
20803
20804
  key: index
20804
20805
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
20805
20806
  style: {
@@ -20808,7 +20809,7 @@ class TexErrorView extends React__namespace.Component {
20808
20809
  }, e.math), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, null, e.message))));
20809
20810
  }
20810
20811
  }
20811
- const styles$e = aphrodite.StyleSheet.create({
20812
+ const styles$f = aphrodite.StyleSheet.create({
20812
20813
  title: {
20813
20814
  backgroundColor: "#eee",
20814
20815
  fontSize: "1.25em",
@@ -24820,12 +24821,12 @@ class SimpleButton extends React__namespace.Component {
24820
24821
  ...otherProps
24821
24822
  } = this.props;
24822
24823
  return /*#__PURE__*/React__namespace.createElement("div", _extends({
24823
- className: aphrodite.css(styles$d.baseButton, color === "green" && styles$d.green, color === "orange" && styles$d.orange),
24824
+ className: aphrodite.css(styles$e.baseButton, color === "green" && styles$e.green, color === "orange" && styles$e.orange),
24824
24825
  onClick: onClick
24825
24826
  }, otherProps), children);
24826
24827
  }
24827
24828
  }
24828
- const styles$d = aphrodite.StyleSheet.create({
24829
+ const styles$e = aphrodite.StyleSheet.create({
24829
24830
  baseButton: {
24830
24831
  top: "0",
24831
24832
  fontSize: "11px",
@@ -25038,23 +25039,23 @@ const LeafContainer = _ref2 => {
25038
25039
  } = _ref2;
25039
25040
  const hasPreviewHeading = shape.type === "content" || shape.type === "hint";
25040
25041
  const previewHeading = hasPreviewHeading && /*#__PURE__*/React__namespace.createElement("div", {
25041
- className: aphrodite.css(styles$c.containerHeader)
25042
+ className: aphrodite.css(styles$d.containerHeader)
25042
25043
  }, /*#__PURE__*/React__namespace.createElement(Header, {
25043
25044
  depth: path.length,
25044
- className: aphrodite.css(styles$c.containerTitle)
25045
+ className: aphrodite.css(styles$d.containerTitle)
25045
25046
  }, capitalize(name)));
25046
25047
  return /*#__PURE__*/React__namespace.createElement("div", {
25047
- className: aphrodite.css(styles$c.container)
25048
+ className: aphrodite.css(styles$d.container)
25048
25049
  }, /*#__PURE__*/React__namespace.createElement("span", {
25049
- className: aphrodite.css(styles$c.row, styles$c.rowHeading)
25050
+ className: aphrodite.css(styles$d.row, styles$d.rowHeading)
25050
25051
  }, /*#__PURE__*/React__namespace.createElement("div", {
25051
- className: aphrodite.css(styles$c.columnLeft)
25052
+ className: aphrodite.css(styles$d.columnLeft)
25052
25053
  }, /*#__PURE__*/React__namespace.createElement("div", {
25053
- className: "pod-title " + aphrodite.css(styles$c.containerHeader)
25054
+ className: "pod-title " + aphrodite.css(styles$d.containerHeader)
25054
25055
  }, /*#__PURE__*/React__namespace.createElement("div", {
25055
- className: aphrodite.css(styles$c.containerTitle)
25056
+ className: aphrodite.css(styles$d.containerTitle)
25056
25057
  }, capitalize(name)), controls)), /*#__PURE__*/React__namespace.createElement("div", {
25057
- className: aphrodite.css(styles$c.columnRight)
25058
+ className: aphrodite.css(styles$d.columnRight)
25058
25059
  }, previewHeading)), children);
25059
25060
  };
25060
25061
  const ArrayContainer = props => {
@@ -25067,11 +25068,11 @@ const ArrayContainer = props => {
25067
25068
  actions
25068
25069
  } = props;
25069
25070
  return /*#__PURE__*/React__namespace.createElement("div", {
25070
- className: aphrodite.css(styles$c.container)
25071
+ className: aphrodite.css(styles$d.container)
25071
25072
  }, controls && /*#__PURE__*/React__namespace.createElement("div", {
25072
- className: aphrodite.css(styles$c.columnLeft, styles$c.containerHeader)
25073
+ className: aphrodite.css(styles$d.columnLeft, styles$d.containerHeader)
25073
25074
  }, controls), /*#__PURE__*/React__namespace.createElement("div", null, children), /*#__PURE__*/React__namespace.createElement("div", {
25074
- className: aphrodite.css(styles$c.columnLeft)
25075
+ className: aphrodite.css(styles$d.columnLeft)
25075
25076
  }, /*#__PURE__*/React__namespace.createElement("a", {
25076
25077
  href: "javascript:void 0",
25077
25078
  onClick: () => actions.addArrayElement(path, shape.elementShape)
@@ -25085,28 +25086,28 @@ const ObjectContainer = _ref3 => {
25085
25086
  path
25086
25087
  } = _ref3;
25087
25088
  const headingEditor = /*#__PURE__*/React__namespace.createElement("div", {
25088
- className: aphrodite.css(styles$c.containerHeader)
25089
+ className: aphrodite.css(styles$d.containerHeader)
25089
25090
  }, /*#__PURE__*/React__namespace.createElement(Header, {
25090
25091
  depth: path.length,
25091
- className: aphrodite.css(styles$c.containerTitle)
25092
+ className: aphrodite.css(styles$d.containerTitle)
25092
25093
  }, capitalize(name)), controls);
25093
25094
  const headingPreview = (name || controls) && /*#__PURE__*/React__namespace.createElement("div", {
25094
- className: aphrodite.css(styles$c.containerHeader, styles$c.previewCollectionHeader)
25095
+ className: aphrodite.css(styles$d.containerHeader, styles$d.previewCollectionHeader)
25095
25096
  }, /*#__PURE__*/React__namespace.createElement(Header, {
25096
25097
  depth: path.length,
25097
- className: aphrodite.css(styles$c.containerTitle)
25098
+ className: aphrodite.css(styles$d.containerTitle)
25098
25099
  }, capitalize(name)));
25099
25100
  const hasBothHeadings = headingEditor && headingPreview;
25100
25101
  return /*#__PURE__*/React__namespace.createElement("div", {
25101
- className: aphrodite.css(styles$c.container)
25102
+ className: aphrodite.css(styles$d.container)
25102
25103
  }, hasBothHeadings && /*#__PURE__*/React__namespace.createElement("span", {
25103
- className: aphrodite.css(styles$c.row)
25104
+ className: aphrodite.css(styles$d.row)
25104
25105
  }, /*#__PURE__*/React__namespace.createElement("div", {
25105
- className: aphrodite.css(styles$c.columnLeft)
25106
+ className: aphrodite.css(styles$d.columnLeft)
25106
25107
  }, headingEditor), /*#__PURE__*/React__namespace.createElement("div", {
25107
- className: aphrodite.css(styles$c.columnRight)
25108
+ className: aphrodite.css(styles$d.columnRight)
25108
25109
  }, headingPreview)), /*#__PURE__*/React__namespace.createElement("div", {
25109
- className: aphrodite.css(path.length > 0 && styles$c.contentIndent)
25110
+ className: aphrodite.css(path.length > 0 && styles$d.contentIndent)
25110
25111
  }, children));
25111
25112
  };
25112
25113
 
@@ -25226,11 +25227,11 @@ const ItemNodeContent = withStickiness(props => {
25226
25227
  className: "framework-perseus"
25227
25228
  }, lens(renderers).get(path));
25228
25229
  return /*#__PURE__*/React__namespace.createElement("span", null, /*#__PURE__*/React__namespace.createElement("div", {
25229
- className: aphrodite.css(styles$c.row)
25230
+ className: aphrodite.css(styles$d.row)
25230
25231
  }, /*#__PURE__*/React__namespace.createElement("div", {
25231
- className: aphrodite.css(styles$c.columnLeft)
25232
+ className: aphrodite.css(styles$d.columnLeft)
25232
25233
  }, /*#__PURE__*/React__namespace.createElement("div", {
25233
- className: aphrodite.css(sticky && styles$c.sticky)
25234
+ className: aphrodite.css(sticky && styles$d.sticky)
25234
25235
  },
25235
25236
  /*#__PURE__*/
25236
25237
  // @ts-expect-error - TS2769 - No overload matches this call.
@@ -25238,9 +25239,9 @@ const ItemNodeContent = withStickiness(props => {
25238
25239
  onChange: newVal => actions.mergeValueAtPath(path, newVal),
25239
25240
  apiOptions: apiOptions
25240
25241
  })))), /*#__PURE__*/React__namespace.createElement("div", {
25241
- className: aphrodite.css(styles$c.columnRight)
25242
+ className: aphrodite.css(styles$d.columnRight)
25242
25243
  }, /*#__PURE__*/React__namespace.createElement("div", {
25243
- className: aphrodite.css(sticky && styles$c.sticky)
25244
+ className: aphrodite.css(sticky && styles$d.sticky)
25244
25245
  }, preview))));
25245
25246
  });
25246
25247
  const HintNodeContent = withStickiness(props => {
@@ -25256,13 +25257,13 @@ const HintNodeContent = withStickiness(props => {
25256
25257
  className: "framework-perseus"
25257
25258
  }, lens(renderers).get(path));
25258
25259
  return /*#__PURE__*/React__namespace.createElement("div", {
25259
- className: aphrodite.css(styles$c.row)
25260
+ className: aphrodite.css(styles$d.row)
25260
25261
  }, /*#__PURE__*/React__namespace.createElement("div", {
25261
- className: aphrodite.css(styles$c.columnLeft)
25262
+ className: aphrodite.css(styles$d.columnLeft)
25262
25263
  }, /*#__PURE__*/React__namespace.createElement("div", {
25263
- className: aphrodite.css(sticky && styles$c.sticky)
25264
+ className: aphrodite.css(sticky && styles$d.sticky)
25264
25265
  }, /*#__PURE__*/React__namespace.createElement(HintEditor, _extends({}, data, {
25265
- className: aphrodite.css(styles$c.hintEditor),
25266
+ className: aphrodite.css(styles$d.hintEditor),
25266
25267
  onChange: newVal => actions.mergeValueAtPath(path, newVal),
25267
25268
  apiOptions: apiOptions,
25268
25269
  showTitle: false,
@@ -25277,9 +25278,9 @@ const HintNodeContent = withStickiness(props => {
25277
25278
  isFirst: true,
25278
25279
  isLast: true
25279
25280
  })))), /*#__PURE__*/React__namespace.createElement("div", {
25280
- className: aphrodite.css(styles$c.columnRight)
25281
+ className: aphrodite.css(styles$d.columnRight)
25281
25282
  }, /*#__PURE__*/React__namespace.createElement("div", {
25282
- className: aphrodite.css(sticky && styles$c.sticky)
25283
+ className: aphrodite.css(sticky && styles$d.sticky)
25283
25284
  }, preview)));
25284
25285
  });
25285
25286
  const TagsNodeContent = props => {
@@ -25296,9 +25297,9 @@ const TagsNodeContent = props => {
25296
25297
  return null;
25297
25298
  }
25298
25299
  return /*#__PURE__*/React__namespace.createElement("div", {
25299
- className: aphrodite.css(styles$c.columnLeft)
25300
+ className: aphrodite.css(styles$d.columnLeft)
25300
25301
  }, /*#__PURE__*/React__namespace.createElement("div", {
25301
- className: aphrodite.css(styles$c.tagsEditor)
25302
+ className: aphrodite.css(styles$d.tagsEditor)
25302
25303
  }, /*#__PURE__*/React__namespace.createElement(GroupMetadataEditor, {
25303
25304
  value: data,
25304
25305
  onChange: newVal => actions.setValueAtPath(path, newVal),
@@ -25329,23 +25330,23 @@ const ArrayNodeContent = props => {
25329
25330
  const subpath = path.concat(i);
25330
25331
  const controls = [i > 0 && /*#__PURE__*/React__namespace.createElement("div", {
25331
25332
  key: "moveArrayElementUp",
25332
- className: aphrodite.css(styles$c.control)
25333
+ className: aphrodite.css(styles$d.control)
25333
25334
  }, /*#__PURE__*/React__namespace.createElement(SimpleButton, {
25334
25335
  color: "orange",
25335
25336
  title: "Move up",
25336
25337
  onClick: () => actions.moveArrayElementUp(subpath)
25337
25338
  }, /*#__PURE__*/React__namespace.createElement("div", {
25338
- className: aphrodite.css(styles$c.verticalFlip)
25339
+ className: aphrodite.css(styles$d.verticalFlip)
25339
25340
  }, /*#__PURE__*/React__namespace.createElement(InlineIcon$7, iconChevronDown)))), i < data.length - 1 && /*#__PURE__*/React__namespace.createElement("div", {
25340
25341
  key: "moveArrayElementDown",
25341
- className: aphrodite.css(styles$c.control)
25342
+ className: aphrodite.css(styles$d.control)
25342
25343
  }, /*#__PURE__*/React__namespace.createElement(SimpleButton, {
25343
25344
  color: "orange",
25344
25345
  title: "Move down",
25345
25346
  onClick: () => actions.moveArrayElementDown(subpath)
25346
25347
  }, /*#__PURE__*/React__namespace.createElement(InlineIcon$7, iconChevronDown))), /*#__PURE__*/React__namespace.createElement("div", {
25347
25348
  key: "removeArrayElement",
25348
- className: aphrodite.css(styles$c.control)
25349
+ className: aphrodite.css(styles$d.control)
25349
25350
  }, /*#__PURE__*/React__namespace.createElement(SimpleButton, {
25350
25351
  color: "orange",
25351
25352
  title: "Delete",
@@ -25353,7 +25354,7 @@ const ArrayNodeContent = props => {
25353
25354
  }, /*#__PURE__*/React__namespace.createElement(InlineIcon$7, iconTrash$5)))];
25354
25355
  return /*#__PURE__*/React__namespace.createElement("div", {
25355
25356
  key: i,
25356
- className: aphrodite.css(styles$c.arrayElement, !elementIsLeaf && styles$c.arrayElementAndNotLeaf)
25357
+ className: aphrodite.css(styles$d.arrayElement, !elementIsLeaf && styles$d.arrayElementAndNotLeaf)
25357
25358
  }, /*#__PURE__*/React__namespace.createElement(NodeContainer, _extends({}, otherProps, {
25358
25359
  key: i,
25359
25360
  shape: shape.elementShape,
@@ -25379,7 +25380,7 @@ const ObjectNodeContent = props => {
25379
25380
  // made sense to the shape's author is the order in which we'll iterate :)
25380
25381
  const children = Object.keys(shape.shape).map(subkey => /*#__PURE__*/React__namespace.createElement("div", {
25381
25382
  key: subkey,
25382
- className: aphrodite.css(styles$c.objectElement)
25383
+ className: aphrodite.css(styles$d.objectElement)
25383
25384
  }, /*#__PURE__*/React__namespace.createElement(NodeContainer, _extends({}, otherProps, {
25384
25385
  shape: shape.shape[subkey],
25385
25386
  data: data[subkey],
@@ -25548,7 +25549,7 @@ class MultiRendererEditor extends React__namespace.Component {
25548
25549
  }, this._renderContent());
25549
25550
  }
25550
25551
  }
25551
- const styles$c = aphrodite.StyleSheet.create({
25552
+ const styles$d = aphrodite.StyleSheet.create({
25552
25553
  // This is used in a number of places throughout this file.
25553
25554
  container: {},
25554
25555
  // eslint-disable-next-line react-native/no-unused-styles
@@ -25700,47 +25701,47 @@ const StatefulArticleEditor = createReactClass__default["default"]({
25700
25701
  screen
25701
25702
  } = this.state;
25702
25703
  return /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("div", {
25703
- style: styles$b.controlBar
25704
+ style: styles$c.controlBar
25704
25705
  }, /*#__PURE__*/React__namespace.createElement("span", {
25705
- style: styles$b.controls
25706
+ style: styles$c.controls
25706
25707
  }, "Mode:", " ", /*#__PURE__*/React__namespace.createElement("span", {
25707
25708
  onClick: () => this.setState({
25708
25709
  mode: "edit"
25709
25710
  }),
25710
- style: mode === "edit" ? styles$b.controlSelected : styles$b.control
25711
+ style: mode === "edit" ? styles$c.controlSelected : styles$c.control
25711
25712
  }, "EDIT"), " | ", /*#__PURE__*/React__namespace.createElement("span", {
25712
25713
  onClick: () => this.setState({
25713
25714
  mode: "preview"
25714
25715
  }),
25715
- style: mode === "preview" ? styles$b.controlSelected : styles$b.control
25716
+ style: mode === "preview" ? styles$c.controlSelected : styles$c.control
25716
25717
  }, "PREVIEW"), " | ", /*#__PURE__*/React__namespace.createElement("span", {
25717
25718
  onClick: () => this.setState({
25718
25719
  mode: "json"
25719
25720
  }),
25720
- style: mode === "json" ? styles$b.controlSelected : styles$b.control
25721
+ style: mode === "json" ? styles$c.controlSelected : styles$c.control
25721
25722
  }, "JSON")), /*#__PURE__*/React__namespace.createElement("span", {
25722
- style: styles$b.controls
25723
+ style: styles$c.controls
25723
25724
  }, "Screen:", " ", /*#__PURE__*/React__namespace.createElement("span", {
25724
25725
  onClick: () => this.setState({
25725
25726
  screen: "phone"
25726
25727
  }),
25727
- style: screen === "phone" ? styles$b.controlSelected : styles$b.control
25728
+ style: screen === "phone" ? styles$c.controlSelected : styles$c.control
25728
25729
  }, "PHONE"), " | ", /*#__PURE__*/React__namespace.createElement("span", {
25729
25730
  onClick: () => this.setState({
25730
25731
  screen: "tablet"
25731
25732
  }),
25732
- style: screen === "tablet" ? styles$b.controlSelected : styles$b.control
25733
+ style: screen === "tablet" ? styles$c.controlSelected : styles$c.control
25733
25734
  }, "TABLET"), " | ", /*#__PURE__*/React__namespace.createElement("span", {
25734
25735
  onClick: () => this.setState({
25735
25736
  screen: "desktop"
25736
25737
  }),
25737
- style: screen === "desktop" ? styles$b.controlSelected : styles$b.control
25738
+ style: screen === "desktop" ? styles$c.controlSelected : styles$c.control
25738
25739
  }, "DESKTOP"))), /*#__PURE__*/React__namespace.createElement("div", {
25739
- style: styles$b.editor
25740
+ style: styles$c.editor
25740
25741
  }, /*#__PURE__*/React__namespace.createElement(ArticleEditor, this.state)));
25741
25742
  }
25742
25743
  });
25743
- const styles$b = {
25744
+ const styles$c = {
25744
25745
  controlBar: {
25745
25746
  marginBottom: 25,
25746
25747
  marginTop: 5
@@ -27272,10 +27273,10 @@ class GradedGroupEditor extends React__namespace.Component {
27272
27273
  }, /*#__PURE__*/React__namespace.createElement("div", {
27273
27274
  className: "perseus-widget-row"
27274
27275
  }, /*#__PURE__*/React__namespace.createElement("label", {
27275
- className: aphrodite.css(styles$a.title)
27276
+ className: aphrodite.css(styles$b.title)
27276
27277
  }, "Title:", " ", /*#__PURE__*/React__namespace.createElement(TextInput$6, {
27277
27278
  value: this.props.title,
27278
- className: aphrodite.css(styles$a.input)
27279
+ className: aphrodite.css(styles$b.input)
27279
27280
  // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
27280
27281
  ,
27281
27282
  onChange: this.change("title")
@@ -27302,7 +27303,7 @@ class GradedGroupEditor extends React__namespace.Component {
27302
27303
  }, /*#__PURE__*/React__namespace.createElement(InlineIcon$5, iconPlus$2), " Add a hint"), this.props.hint && /*#__PURE__*/React__namespace.createElement("div", {
27303
27304
  className: "perseus-hint-editor"
27304
27305
  }, /*#__PURE__*/React__namespace.createElement("div", {
27305
- className: aphrodite.css(styles$a.hintsTitle)
27306
+ className: aphrodite.css(styles$b.hintsTitle)
27306
27307
  }, "Hint"), /*#__PURE__*/React__namespace.createElement(Editor
27307
27308
  // eslint-disable-next-line react/no-string-refs
27308
27309
  , {
@@ -27345,7 +27346,7 @@ class GradedGroupEditor extends React__namespace.Component {
27345
27346
  };
27346
27347
  };
27347
27348
  }
27348
- const styles$a = aphrodite.StyleSheet.create({
27349
+ const styles$b = aphrodite.StyleSheet.create({
27349
27350
  title: {
27350
27351
  fontSize: 18,
27351
27352
  fontWeight: "bold"
@@ -27437,7 +27438,7 @@ const {
27437
27438
  RangeInput: RangeInput$5
27438
27439
  } = perseus.components;
27439
27440
  const {
27440
- getDependencies: getDependencies$1
27441
+ getDependencies: getDependencies$9
27441
27442
  } = perseus.Dependencies;
27442
27443
  const defaultBackgroundImage$3 = {
27443
27444
  url: null,
@@ -27758,7 +27759,7 @@ const GraphSettings = createReactClass__default["default"]({
27758
27759
  const scale = [perseus.KhanMath.roundTo(2, perseus.Util.scaleFromExtent(this.props.range[0], this.props.box[0])), perseus.KhanMath.roundTo(2, perseus.Util.scaleFromExtent(this.props.range[1], this.props.box[1]))];
27759
27760
  const {
27760
27761
  TeX
27761
- } = getDependencies$1();
27762
+ } = getDependencies$9();
27762
27763
  return /*#__PURE__*/React__namespace.createElement("div", null, ___default["default"].contains(this.props.editableSettings, "canvas") && /*#__PURE__*/React__namespace.createElement("div", {
27763
27764
  className: "graph-settings"
27764
27765
  }, /*#__PURE__*/React__namespace.createElement("div", {
@@ -28656,209 +28657,200 @@ class InputNumberEditor extends React__namespace.Component {
28656
28657
  });
28657
28658
  }
28658
28659
 
28660
+ /**
28661
+ * A simple Mathquill MathField input for the InteractionEditor.
28662
+ * Unlike our other uses of Mathquill, we're not using a keypad here;
28663
+ * it's just the input itself for use writing TeX.
28664
+ */
28665
+ function MathquillInput(props) {
28666
+ const mathFieldWrapperRef = React.useRef(null);
28667
+ const mathFieldInstance = React.useRef();
28668
+ React.useEffect(() => {
28669
+ // If we have the mount for the input, but not the input
28670
+ // make a new Mathquill input
28671
+ if (mathFieldWrapperRef.current && !mathFieldInstance.current) {
28672
+ // Initialize MathQuill.MathField instance
28673
+ mathFieldInstance.current = mathInput.createMathField(mathFieldWrapperRef.current, baseConfig => ({
28674
+ ...baseConfig,
28675
+ handlers: {
28676
+ edit: mathField => {
28677
+ // This handler is guaranteed to be called on change, but
28678
+ // unlike React it sometimes generates false positives.
28679
+ // One of these is on initialization (with an empty string
28680
+ // value), so we have to guard against that below.
28681
+ let value = mathField.latex();
28682
+
28683
+ // Provide a MathQuill-compatible way to generate the
28684
+ // not-equals sign without pasting unicode or typing TeX
28685
+ value = value.replace(/<>/g, "\\ne");
28686
+ if (props.value !== value) {
28687
+ props.onChange(value);
28688
+ }
28689
+ },
28690
+ upOutOf: mathField => {
28691
+ // This handler is called when the user presses the up
28692
+ // arrow key, but there is nowhere in the expression to go
28693
+ // up to (no numerator or exponent). For ease of use,
28694
+ // interpret this as an attempt to create an exponent.
28695
+ mathField.typedText("^");
28696
+ }
28697
+ }
28698
+ }));
28699
+ }
28700
+ });
28701
+ return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
28702
+ style: styles$a.outerWrapper
28703
+ }, /*#__PURE__*/React__namespace.createElement("span", {
28704
+ ref: mathFieldWrapperRef,
28705
+ className: "perseus-math-input mq-editable-field mq-math-mode"
28706
+ }));
28707
+ }
28708
+ const styles$a = aphrodite.StyleSheet.create({
28709
+ outerWrapper: {
28710
+ display: "inline-block",
28711
+ borderStyle: "solid",
28712
+ borderWidth: 1,
28713
+ borderColor: Color__default["default"].offBlack50,
28714
+ borderRadius: 3,
28715
+ background: Color__default["default"].white
28716
+ }
28717
+ });
28718
+
28659
28719
  const {
28660
- ButtonGroup: ButtonGroup$2,
28661
- MathInput: MathInput$1,
28662
- NumberInput: NumberInput$c
28720
+ NumberInput: NumberInput$g
28663
28721
  } = perseus.components;
28664
- class ConstraintEditor extends React__namespace.Component {
28722
+ const {
28723
+ getDependencies: getDependencies$8
28724
+ } = perseus.Dependencies;
28725
+ // Editor for function plots
28726
+ class FunctionEditor extends React__namespace.Component {
28665
28727
  static defaultProps = {
28666
- constraint: "none",
28667
- snap: 0.5,
28668
- constraintFn: "0",
28669
- constraintXMin: "-10",
28670
- constraintXMax: "10",
28671
- constraintYMin: "-10",
28672
- constraintYMax: "10"
28728
+ value: "x",
28729
+ rangeMin: "-10",
28730
+ rangeMax: "10",
28731
+ color: perseus.KhanColors.BLUE,
28732
+ strokeDasharray: "",
28733
+ strokeWidth: 2
28673
28734
  };
28674
- change = propName => {
28675
- return perseus.Changeable.change.call(this, propName);
28735
+ change = (() => {
28736
+ var _this = this;
28737
+ return function () {
28738
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28739
+ args[_key] = arguments[_key];
28740
+ }
28741
+ return perseus.Changeable.change.apply(_this, args);
28742
+ };
28743
+ })();
28744
+ serialize = () => {
28745
+ return perseus.EditorJsonify.serialize.call(this);
28676
28746
  };
28677
28747
  render() {
28678
28748
  const {
28679
28749
  TeX
28680
- } = perseus.Dependencies.getDependencies();
28681
- const analyticsStub = {
28682
- onAnalyticsEvent: () => Promise.resolve()
28683
- };
28684
- return /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("div", {
28685
- className: "perseus-widget-row"
28686
- }, "Constraint:", " ", /*#__PURE__*/React__namespace.createElement(ButtonGroup$2, {
28687
- value: this.props.constraint,
28688
- allowEmpty: false,
28689
- buttons: [{
28690
- value: "none",
28691
- content: "None"
28692
- }, {
28693
- value: "snap",
28694
- content: "Snap"
28695
- }, {
28696
- value: "x",
28697
- content: "x="
28698
- }, {
28699
- value: "y",
28700
- content: "y="
28701
- }],
28702
- onChange: this.change("constraint")
28703
- })), this.props.constraint === "snap" && /*#__PURE__*/React__namespace.createElement("div", {
28704
- className: "perseus-widget-row"
28705
- }, "Snap:", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$c, {
28706
- value: this.props.snap,
28707
- placeholder: 0,
28708
- onChange: this.change("snap")
28709
- })), this.props.constraint === "x" && /*#__PURE__*/React__namespace.createElement("div", {
28750
+ } = getDependencies$8();
28751
+ return /*#__PURE__*/React__namespace.createElement("div", {
28710
28752
  className: "graph-settings"
28711
28753
  }, /*#__PURE__*/React__namespace.createElement("div", {
28712
28754
  className: "perseus-widget-row"
28713
- }, /*#__PURE__*/React__namespace.createElement(TeX, null, "x="), " ", /*#__PURE__*/React__namespace.createElement(MathInput$1, {
28714
- buttonsVisible: "never",
28715
- value: this.props.constraintFn,
28716
- onChange: this.change("constraintFn"),
28717
- analytics: analyticsStub
28718
- }))), this.props.constraint === "y" && /*#__PURE__*/React__namespace.createElement("div", {
28719
- className: "graph-settings"
28720
- }, /*#__PURE__*/React__namespace.createElement("div", {
28755
+ }, /*#__PURE__*/React__namespace.createElement(TeX, null, this.props.funcName + "(x)="), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28756
+ value: this.props.value,
28757
+ onChange: this.change("value")
28758
+ })), /*#__PURE__*/React__namespace.createElement("div", {
28721
28759
  className: "perseus-widget-row"
28722
- }, /*#__PURE__*/React__namespace.createElement(TeX, null, "y="), " ", /*#__PURE__*/React__namespace.createElement(MathInput$1, {
28723
- buttonsVisible: "never",
28724
- value: this.props.constraintFn,
28725
- onChange: this.change("constraintFn"),
28726
- analytics: analyticsStub
28727
- }))), "Ensure these are set so nothing can be dragged off the canvas:", /*#__PURE__*/React__namespace.createElement("div", {
28760
+ }, "Range: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28761
+ value: this.props.rangeMin,
28762
+ onChange: this.change("rangeMin")
28763
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28764
+ value: this.props.rangeMax,
28765
+ onChange: this.change("rangeMax")
28766
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large)")), /*#__PURE__*/React__namespace.createElement("div", {
28728
28767
  className: "perseus-widget-row"
28729
- }, /*#__PURE__*/React__namespace.createElement("div", {
28768
+ }, /*#__PURE__*/React__namespace.createElement(perseus.ColorPicker, {
28769
+ value: this.props.color,
28770
+ onChange: this.change("color")
28771
+ })), /*#__PURE__*/React__namespace.createElement("div", {
28730
28772
  className: "perseus-widget-row"
28731
- }, /*#__PURE__*/React__namespace.createElement(TeX, null, "x \\in \\Large["), " ", /*#__PURE__*/React__namespace.createElement(MathInput$1, {
28732
- buttonsVisible: "never",
28733
- value: this.props.constraintXMin,
28734
- onChange: this.change("constraintXMin"),
28735
- analytics: analyticsStub
28736
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ", "), " ", /*#__PURE__*/React__namespace.createElement(MathInput$1, {
28737
- buttonsVisible: "never",
28738
- value: this.props.constraintXMax,
28739
- onChange: this.change("constraintXMax"),
28740
- analytics: analyticsStub
28741
- }), " ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large]"))), /*#__PURE__*/React__namespace.createElement("div", {
28773
+ }, /*#__PURE__*/React__namespace.createElement(perseus.DashPicker, {
28774
+ value: this.props.strokeDasharray,
28775
+ onChange: this.change("strokeDasharray")
28776
+ })), /*#__PURE__*/React__namespace.createElement("div", {
28742
28777
  className: "perseus-widget-row"
28743
28778
  }, /*#__PURE__*/React__namespace.createElement("div", {
28744
- className: "perseus-widget-row"
28745
- }, /*#__PURE__*/React__namespace.createElement(TeX, null, "y \\in \\Large["), " ", /*#__PURE__*/React__namespace.createElement(MathInput$1, {
28746
- buttonsVisible: "never",
28747
- value: this.props.constraintYMin,
28748
- onChange: this.change("constraintYMin"),
28749
- analytics: analyticsStub
28750
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ", "), " ", /*#__PURE__*/React__namespace.createElement(MathInput$1, {
28751
- buttonsVisible: "never",
28752
- value: this.props.constraintYMax,
28753
- onChange: this.change("constraintYMax"),
28754
- analytics: analyticsStub
28755
- }), " ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large]"))));
28779
+ className: "perseus-widget-left-col"
28780
+ }, "Width:", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$g, {
28781
+ value: this.props.strokeWidth,
28782
+ placeholder: 2,
28783
+ onChange: this.change("strokeWidth")
28784
+ }))));
28756
28785
  }
28757
28786
  }
28758
28787
 
28759
28788
  const {
28760
- MathInput,
28761
- NumberInput: NumberInput$b,
28762
28789
  TextInput: TextInput$5
28763
28790
  } = perseus.components;
28764
28791
  const {
28765
- getDependencies
28792
+ getDependencies: getDependencies$7
28766
28793
  } = perseus.Dependencies;
28767
- const {
28768
- unescapeMathMode
28769
- } = perseus.Util;
28770
- const defaultInteractionProps = {
28771
- graph: {
28772
- box: [400, 400],
28773
- labels: ["x", "y"],
28774
- range: [[-10, 10], [-10, 10]],
28775
- tickStep: [1, 1],
28776
- gridStep: [1, 1],
28777
- markings: "graph"
28778
- },
28779
- elements: []
28780
- };
28781
- //
28782
- // Editor for non-interactive points
28783
- //
28784
- // TODO(eater): Factor this out
28785
- //
28786
- class PointEditor extends React__namespace.Component {
28787
- static propTypes = {
28788
- ...perseus.Changeable.propTypes,
28789
- coordX: PropTypes__default["default"].string,
28790
- coordY: PropTypes__default["default"].string,
28791
- color: PropTypes__default["default"].string
28792
- };
28794
+ // Editor for labels
28795
+ // TODO(eater): Add text direction
28796
+ class LabelEditor extends React__namespace.Component {
28793
28797
  static defaultProps = {
28794
28798
  coordX: "0",
28795
28799
  coordY: "0",
28796
- color: perseus.KhanColors.BLACK
28800
+ color: perseus.KhanColors.BLACK,
28801
+ label: "\\phi"
28802
+ };
28803
+ change = (() => {
28804
+ var _this = this;
28805
+ return function () {
28806
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28807
+ args[_key] = arguments[_key];
28808
+ }
28809
+ return perseus.Changeable.change.apply(_this, args);
28810
+ };
28811
+ })();
28812
+ serialize = () => {
28813
+ return perseus.EditorJsonify.serialize.call(this);
28797
28814
  };
28798
28815
  render() {
28799
28816
  const {
28800
28817
  TeX
28801
- } = getDependencies();
28802
- const analyticsStub = {
28803
- onAnalyticsEvent: () => Promise.resolve()
28804
- };
28818
+ } = getDependencies$7();
28805
28819
  return /*#__PURE__*/React__namespace.createElement("div", {
28806
28820
  className: "graph-settings"
28807
28821
  }, /*#__PURE__*/React__namespace.createElement("div", {
28808
28822
  className: "perseus-widget-row"
28809
- }, "Coordinate: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathInput, {
28810
- buttonsVisible: "never",
28811
- value: this.props.coordX
28812
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28813
- ,
28814
- onChange: this.change("coordX"),
28815
- analytics: analyticsStub
28816
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
28817
- buttonsVisible: "never",
28818
- value: this.props.coordY
28819
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28820
- ,
28821
- onChange: this.change("coordY"),
28822
- analytics: analyticsStub
28823
+ }, /*#__PURE__*/React__namespace.createElement(TextInput$5, {
28824
+ value: this.props.label,
28825
+ onChange: this.change("label"),
28826
+ style: {
28827
+ width: "100%"
28828
+ }
28829
+ })), /*#__PURE__*/React__namespace.createElement("div", {
28830
+ className: "perseus-widget-row"
28831
+ }, "Location: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28832
+ value: this.props.coordX,
28833
+ onChange: this.change("coordX")
28834
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28835
+ value: this.props.coordY,
28836
+ onChange: this.change("coordY")
28823
28837
  }), /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large)")), /*#__PURE__*/React__namespace.createElement("div", {
28824
28838
  className: "perseus-widget-row"
28825
28839
  }, /*#__PURE__*/React__namespace.createElement(perseus.ColorPicker, {
28826
- value: this.props.color
28827
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28828
- ,
28840
+ value: this.props.color,
28829
28841
  onChange: this.change("color")
28830
28842
  })));
28831
28843
  }
28832
- change = (() => {
28833
- var _this = this;
28834
- return function () {
28835
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28836
- args[_key] = arguments[_key];
28837
- }
28838
- return perseus.Changeable.change.apply(_this, args);
28839
- };
28840
- })();
28841
- serialize = () => {
28842
- return perseus.EditorJsonify.serialize.call(this);
28843
- };
28844
28844
  }
28845
- //
28845
+
28846
+ const {
28847
+ NumberInput: NumberInput$f
28848
+ } = perseus.components;
28849
+ const {
28850
+ getDependencies: getDependencies$6
28851
+ } = perseus.Dependencies;
28846
28852
  // Editor for non-interactive line segments
28847
- //
28848
- // TODO(eater): Factor this out
28849
- //
28850
28853
  class LineEditor extends React__namespace.Component {
28851
- static propTypes = {
28852
- ...perseus.Changeable.propTypes,
28853
- startX: PropTypes__default["default"].string,
28854
- startY: PropTypes__default["default"].string,
28855
- endX: PropTypes__default["default"].string,
28856
- endY: PropTypes__default["default"].string,
28857
- color: PropTypes__default["default"].string,
28858
- strokeDasharray: PropTypes__default["default"].string,
28859
- arrows: PropTypes__default["default"].string,
28860
- strokeWidth: PropTypes__default["default"].number
28861
- };
28862
28854
  static defaultProps = {
28863
28855
  startX: "-5",
28864
28856
  startY: "5",
@@ -28869,109 +28861,71 @@ class LineEditor extends React__namespace.Component {
28869
28861
  arrows: "",
28870
28862
  strokeWidth: 2
28871
28863
  };
28864
+ change = (() => {
28865
+ var _this = this;
28866
+ return function () {
28867
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28868
+ args[_key] = arguments[_key];
28869
+ }
28870
+ return perseus.Changeable.change.apply(_this, args);
28871
+ };
28872
+ })();
28873
+ serialize = () => {
28874
+ return perseus.EditorJsonify.serialize.call(this);
28875
+ };
28872
28876
  render() {
28873
28877
  const {
28874
28878
  TeX
28875
- } = getDependencies();
28876
- const analyticsStub = {
28877
- onAnalyticsEvent: () => Promise.resolve()
28878
- };
28879
+ } = getDependencies$6();
28879
28880
  return /*#__PURE__*/React__namespace.createElement("div", {
28880
28881
  className: "graph-settings"
28881
28882
  }, /*#__PURE__*/React__namespace.createElement("div", {
28882
28883
  className: "perseus-widget-row"
28883
- }, "Start: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathInput, {
28884
- buttonsVisible: "never",
28885
- value: this.props.startX
28886
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28887
- ,
28888
- onChange: this.change("startX"),
28889
- analytics: analyticsStub
28890
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
28891
- buttonsVisible: "never",
28892
- value: this.props.startY
28893
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28894
- ,
28895
- onChange: this.change("startY"),
28896
- analytics: analyticsStub
28884
+ }, "Start: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28885
+ value: this.props.startX,
28886
+ onChange: this.change("startX")
28887
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28888
+ value: this.props.startY,
28889
+ onChange: this.change("startY")
28897
28890
  }), /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large)")), /*#__PURE__*/React__namespace.createElement("div", {
28898
28891
  className: "perseus-widget-row"
28899
- }, "End: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathInput, {
28900
- buttonsVisible: "never",
28901
- value: this.props.endX
28902
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28903
- ,
28904
- onChange: this.change("endX"),
28905
- analytics: analyticsStub
28906
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
28907
- buttonsVisible: "never",
28908
- value: this.props.endY
28909
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28910
- ,
28911
- onChange: this.change("endY"),
28912
- analytics: analyticsStub
28892
+ }, "End: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28893
+ value: this.props.endX,
28894
+ onChange: this.change("endX")
28895
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28896
+ value: this.props.endY,
28897
+ onChange: this.change("endY")
28913
28898
  }), /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large)")), /*#__PURE__*/React__namespace.createElement("div", {
28914
28899
  className: "perseus-widget-row"
28915
28900
  }, /*#__PURE__*/React__namespace.createElement(perseus.ColorPicker, {
28916
- value: this.props.color
28917
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28918
- ,
28901
+ value: this.props.color,
28919
28902
  onChange: this.change("color")
28920
28903
  })), /*#__PURE__*/React__namespace.createElement("div", {
28921
28904
  className: "perseus-widget-row"
28922
28905
  }, /*#__PURE__*/React__namespace.createElement(perseus.DashPicker, {
28923
- value: this.props.strokeDasharray
28924
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28925
- ,
28906
+ value: this.props.strokeDasharray,
28926
28907
  onChange: this.change("strokeDasharray")
28927
28908
  }), "\xA0 \xA0", /*#__PURE__*/React__namespace.createElement(perseus.ArrowPicker, {
28928
- value: this.props.arrows
28929
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28930
- ,
28909
+ value: this.props.arrows,
28931
28910
  onChange: this.change("arrows")
28932
28911
  })), /*#__PURE__*/React__namespace.createElement("div", {
28933
28912
  className: "perseus-widget-row"
28934
28913
  }, /*#__PURE__*/React__namespace.createElement("div", {
28935
28914
  className: "perseus-widget-left-col"
28936
- }, "Width:", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$b, {
28915
+ }, "Width:", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$f, {
28937
28916
  value: this.props.strokeWidth,
28938
- placeholder: 2
28939
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28940
- ,
28917
+ placeholder: 2,
28941
28918
  onChange: this.change("strokeWidth")
28942
28919
  }))));
28943
28920
  }
28944
- change = (() => {
28945
- var _this2 = this;
28946
- return function () {
28947
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
28948
- args[_key2] = arguments[_key2];
28949
- }
28950
- return perseus.Changeable.change.apply(_this2, args);
28951
- };
28952
- })();
28953
- serialize = () => {
28954
- return perseus.EditorJsonify.serialize.call(this);
28955
- };
28956
28921
  }
28957
- //
28958
- // Editor for interactive movable points
28959
- //
28960
- // TODO(eater): Factor this out
28961
- // TODO(eater): Rethink how constraints are represented
28962
- //
28963
- class MovablePointEditor extends React__namespace.Component {
28964
- static propTypes = {
28965
- ...perseus.Changeable.propTypes,
28966
- startX: PropTypes__default["default"].string,
28967
- startY: PropTypes__default["default"].string,
28968
- constraint: PropTypes__default["default"].string,
28969
- snap: PropTypes__default["default"].number,
28970
- constraintFn: PropTypes__default["default"].string
28971
- };
28972
- static defaultProps = {
28973
- startX: "0",
28974
- startY: "0",
28922
+
28923
+ const {
28924
+ ButtonGroup: ButtonGroup$2,
28925
+ NumberInput: NumberInput$e
28926
+ } = perseus.components;
28927
+ class ConstraintEditor extends React__namespace.Component {
28928
+ static defaultProps = {
28975
28929
  constraint: "none",
28976
28930
  snap: 0.5,
28977
28931
  constraintFn: "0",
@@ -28980,65 +28934,85 @@ class MovablePointEditor extends React__namespace.Component {
28980
28934
  constraintYMin: "-10",
28981
28935
  constraintYMax: "10"
28982
28936
  };
28937
+ change = propName => {
28938
+ return perseus.Changeable.change.call(this, propName);
28939
+ };
28983
28940
  render() {
28984
28941
  const {
28985
28942
  TeX
28986
- } = getDependencies();
28987
- const analyticsStub = {
28988
- onAnalyticsEvent: () => Promise.resolve()
28989
- };
28990
- return /*#__PURE__*/React__namespace.createElement("div", {
28943
+ } = perseus.Dependencies.getDependencies();
28944
+ return /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("div", {
28945
+ className: "perseus-widget-row"
28946
+ }, "Constraint:", " ", /*#__PURE__*/React__namespace.createElement(ButtonGroup$2, {
28947
+ value: this.props.constraint,
28948
+ allowEmpty: false,
28949
+ buttons: [{
28950
+ value: "none",
28951
+ content: "None"
28952
+ }, {
28953
+ value: "snap",
28954
+ content: "Snap"
28955
+ }, {
28956
+ value: "x",
28957
+ content: "x="
28958
+ }, {
28959
+ value: "y",
28960
+ content: "y="
28961
+ }],
28962
+ onChange: this.change("constraint")
28963
+ })), this.props.constraint === "snap" && /*#__PURE__*/React__namespace.createElement("div", {
28964
+ className: "perseus-widget-row"
28965
+ }, "Snap:", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$e, {
28966
+ value: this.props.snap,
28967
+ placeholder: 0,
28968
+ onChange: this.change("snap")
28969
+ })), this.props.constraint === "x" && /*#__PURE__*/React__namespace.createElement("div", {
28991
28970
  className: "graph-settings"
28992
28971
  }, /*#__PURE__*/React__namespace.createElement("div", {
28993
28972
  className: "perseus-widget-row"
28994
- }, "Start: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathInput, {
28995
- buttonsVisible: "never",
28996
- value: this.props.startX,
28997
- onChange: this.change("startX"),
28998
- analytics: analyticsStub
28999
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29000
- buttonsVisible: "never",
29001
- value: this.props.startY,
29002
- onChange: this.change("startY"),
29003
- analytics: analyticsStub
29004
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large)")), /*#__PURE__*/React__namespace.createElement("div", {
28973
+ }, /*#__PURE__*/React__namespace.createElement(TeX, null, "x="), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28974
+ value: this.props.constraintFn,
28975
+ onChange: this.change("constraintFn")
28976
+ }))), this.props.constraint === "y" && /*#__PURE__*/React__namespace.createElement("div", {
28977
+ className: "graph-settings"
28978
+ }, /*#__PURE__*/React__namespace.createElement("div", {
29005
28979
  className: "perseus-widget-row"
29006
- }, "Update ", /*#__PURE__*/React__namespace.createElement(TeX, null, "(x_n, y_n)"), " for ", /*#__PURE__*/React__namespace.createElement(TeX, null, "n ="), " ", /*#__PURE__*/React__namespace.createElement(NumberInput$b, {
29007
- value: this.props.varSubscript,
29008
- placeholder: 0,
29009
- onChange: this.change("varSubscript")
29010
- })), /*#__PURE__*/React__namespace.createElement(ConstraintEditor, this.props));
28980
+ }, /*#__PURE__*/React__namespace.createElement(TeX, null, "y="), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28981
+ value: this.props.constraintFn,
28982
+ onChange: this.change("constraintFn")
28983
+ }))), "Ensure these are set so nothing can be dragged off the canvas:", /*#__PURE__*/React__namespace.createElement("div", {
28984
+ className: "perseus-widget-row"
28985
+ }, /*#__PURE__*/React__namespace.createElement("div", {
28986
+ className: "perseus-widget-row"
28987
+ }, /*#__PURE__*/React__namespace.createElement(TeX, null, "x \\in \\Large["), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28988
+ value: this.props.constraintXMin,
28989
+ onChange: this.change("constraintXMin")
28990
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ", "), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28991
+ value: this.props.constraintXMax,
28992
+ onChange: this.change("constraintXMax")
28993
+ }), " ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large]"))), /*#__PURE__*/React__namespace.createElement("div", {
28994
+ className: "perseus-widget-row"
28995
+ }, /*#__PURE__*/React__namespace.createElement("div", {
28996
+ className: "perseus-widget-row"
28997
+ }, /*#__PURE__*/React__namespace.createElement(TeX, null, "y \\in \\Large["), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
28998
+ value: this.props.constraintYMin,
28999
+ onChange: this.change("constraintYMin")
29000
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ", "), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29001
+ value: this.props.constraintYMax,
29002
+ onChange: this.change("constraintYMax")
29003
+ }), " ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large]"))));
29011
29004
  }
29012
- change = (() => {
29013
- var _this3 = this;
29014
- return function () {
29015
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
29016
- args[_key3] = arguments[_key3];
29017
- }
29018
- return perseus.Changeable.change.apply(_this3, args);
29019
- };
29020
- })();
29021
- serialize = () => {
29022
- return perseus.EditorJsonify.serialize.call(this);
29023
- };
29024
29005
  }
29025
- //
29006
+
29007
+ const {
29008
+ NumberInput: NumberInput$d
29009
+ } = perseus.components;
29010
+ const {
29011
+ getDependencies: getDependencies$5
29012
+ } = perseus.Dependencies;
29026
29013
  // Editor for interactive movable line segments
29027
- //
29028
- // TODO(eater): Factor this out
29029
29014
  // TODO(eater): Rethink how constraints are represented
29030
- //
29031
29015
  class MovableLineEditor extends React__namespace.Component {
29032
- static propTypes = {
29033
- ...perseus.Changeable.propTypes,
29034
- startX: PropTypes__default["default"].string,
29035
- startY: PropTypes__default["default"].string,
29036
- endX: PropTypes__default["default"].string,
29037
- endY: PropTypes__default["default"].string,
29038
- constraint: PropTypes__default["default"].string,
29039
- snap: PropTypes__default["default"].number,
29040
- constraintFn: PropTypes__default["default"].string
29041
- };
29042
29016
  static defaultProps = {
29043
29017
  startX: "-5",
29044
29018
  startY: "5",
@@ -29047,53 +29021,55 @@ class MovableLineEditor extends React__namespace.Component {
29047
29021
  constraint: "none",
29048
29022
  snap: 0.5,
29049
29023
  constraintFn: "0",
29024
+ // @ts-expect-error - TS2561
29050
29025
  constraintXMin: "-10",
29051
29026
  constraintXMax: "10",
29052
29027
  constraintYMin: "-10",
29053
29028
  constraintYMax: "10"
29054
29029
  };
29030
+ change = (() => {
29031
+ var _this = this;
29032
+ return function () {
29033
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29034
+ args[_key] = arguments[_key];
29035
+ }
29036
+ return perseus.Changeable.change.apply(_this, args);
29037
+ };
29038
+ })();
29039
+ serialize = () => {
29040
+ return perseus.EditorJsonify.serialize.call(this);
29041
+ };
29055
29042
  render() {
29056
29043
  const {
29057
29044
  TeX
29058
- } = getDependencies();
29059
- const analyticsStub = {
29060
- onAnalyticsEvent: () => Promise.resolve()
29061
- };
29045
+ } = getDependencies$5();
29062
29046
  return /*#__PURE__*/React__namespace.createElement("div", {
29063
29047
  className: "graph-settings"
29064
29048
  }, "Initial position:", /*#__PURE__*/React__namespace.createElement("div", {
29065
29049
  className: "perseus-widget-row"
29066
- }, "Start: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathInput, {
29067
- buttonsVisible: "never",
29050
+ }, "Start: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29068
29051
  value: this.props.startX,
29069
- onChange: this.change("startX"),
29070
- analytics: analyticsStub
29071
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29072
- buttonsVisible: "never",
29052
+ onChange: this.change("startX")
29053
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29073
29054
  value: this.props.startY,
29074
- onChange: this.change("startY"),
29075
- analytics: analyticsStub
29055
+ onChange: this.change("startY")
29076
29056
  }), /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large)")), /*#__PURE__*/React__namespace.createElement("div", {
29077
29057
  className: "perseus-widget-row"
29078
- }, "End: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathInput, {
29079
- buttonsVisible: "never",
29058
+ }, "End: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29080
29059
  value: this.props.endX,
29081
- onChange: this.change("endX"),
29082
- analytics: analyticsStub
29083
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29084
- buttonsVisible: "never",
29060
+ onChange: this.change("endX")
29061
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29085
29062
  value: this.props.endY,
29086
- onChange: this.change("endY"),
29087
- analytics: analyticsStub
29063
+ onChange: this.change("endY")
29088
29064
  }), /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large)")), /*#__PURE__*/React__namespace.createElement("div", {
29089
29065
  className: "perseus-widget-row"
29090
- }, "Start updates ", /*#__PURE__*/React__namespace.createElement(TeX, null, "(x_n, y_n)"), " for ", /*#__PURE__*/React__namespace.createElement(TeX, null, "n ="), /*#__PURE__*/React__namespace.createElement(NumberInput$b, {
29066
+ }, "Start updates ", /*#__PURE__*/React__namespace.createElement(TeX, null, "(x_n, y_n)"), " for ", /*#__PURE__*/React__namespace.createElement(TeX, null, "n ="), /*#__PURE__*/React__namespace.createElement(NumberInput$d, {
29091
29067
  value: this.props.startSubscript,
29092
29068
  placeholder: 0,
29093
29069
  onChange: this.change("startSubscript")
29094
29070
  })), /*#__PURE__*/React__namespace.createElement("div", {
29095
29071
  className: "perseus-widget-row"
29096
- }, "End updates ", /*#__PURE__*/React__namespace.createElement(TeX, null, "(x_m, y_m)"), " for ", /*#__PURE__*/React__namespace.createElement(TeX, null, "m ="), /*#__PURE__*/React__namespace.createElement(NumberInput$b, {
29072
+ }, "End updates ", /*#__PURE__*/React__namespace.createElement(TeX, null, "(x_m, y_m)"), " for ", /*#__PURE__*/React__namespace.createElement(TeX, null, "m ="), /*#__PURE__*/React__namespace.createElement(NumberInput$d, {
29097
29073
  value: this.props.endSubscript,
29098
29074
  placeholder: 0,
29099
29075
  onChange: this.change("endSubscript")
@@ -29101,131 +29077,73 @@ class MovableLineEditor extends React__namespace.Component {
29101
29077
  className: "perseus-widget-row"
29102
29078
  }, "All constraints are applied to the start point."), /*#__PURE__*/React__namespace.createElement(ConstraintEditor, this.props));
29103
29079
  }
29080
+ }
29081
+
29082
+ const {
29083
+ NumberInput: NumberInput$c
29084
+ } = perseus.components;
29085
+ const {
29086
+ getDependencies: getDependencies$4
29087
+ } = perseus.Dependencies;
29088
+ // Editor for interactive movable points
29089
+ // TODO(eater): Rethink how constraints are represented
29090
+ class MovablePointEditor extends React__namespace.Component {
29091
+ static defaultProps = {
29092
+ startX: "0",
29093
+ startY: "0",
29094
+ constraint: "none",
29095
+ snap: 0.5,
29096
+ constraintFn: "0",
29097
+ // @ts-expect-error - TS2561
29098
+ constraintXMin: "-10",
29099
+ constraintXMax: "10",
29100
+ constraintYMin: "-10",
29101
+ constraintYMax: "10"
29102
+ };
29104
29103
  change = (() => {
29105
- var _this4 = this;
29104
+ var _this = this;
29106
29105
  return function () {
29107
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
29108
- args[_key4] = arguments[_key4];
29106
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29107
+ args[_key] = arguments[_key];
29109
29108
  }
29110
- return perseus.Changeable.change.apply(_this4, args);
29109
+ return perseus.Changeable.change.apply(_this, args);
29111
29110
  };
29112
29111
  })();
29113
29112
  serialize = () => {
29114
29113
  return perseus.EditorJsonify.serialize.call(this);
29115
29114
  };
29116
- }
29117
- //
29118
- // Editor for function plots
29119
- //
29120
- // TODO(eater): Factor this out
29121
- //
29122
- class FunctionEditor extends React__namespace.Component {
29123
- static propTypes = {
29124
- ...perseus.Changeable.propTypes,
29125
- value: PropTypes__default["default"].string,
29126
- rangeMin: PropTypes__default["default"].string,
29127
- rangeMax: PropTypes__default["default"].string,
29128
- color: PropTypes__default["default"].string,
29129
- strokeDashArray: PropTypes__default["default"].string,
29130
- strokeWidth: PropTypes__default["default"].number
29131
- };
29132
- static defaultProps = {
29133
- value: "x",
29134
- rangeMin: "-10",
29135
- rangeMax: "10",
29136
- color: perseus.KhanColors.BLUE,
29137
- strokeDasharray: "",
29138
- strokeWidth: 2
29139
- };
29140
29115
  render() {
29141
29116
  const {
29142
29117
  TeX
29143
- } = getDependencies();
29144
- const analyticsStub = {
29145
- onAnalyticsEvent: () => Promise.resolve()
29146
- };
29118
+ } = getDependencies$4();
29147
29119
  return /*#__PURE__*/React__namespace.createElement("div", {
29148
29120
  className: "graph-settings"
29149
29121
  }, /*#__PURE__*/React__namespace.createElement("div", {
29150
29122
  className: "perseus-widget-row"
29151
- }, /*#__PURE__*/React__namespace.createElement(TeX, null, this.props.funcName + "(x)="), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29152
- buttonsVisible: "never",
29153
- value: this.props.value
29154
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29155
- ,
29156
- onChange: this.change("value"),
29157
- analytics: analyticsStub
29158
- })), /*#__PURE__*/React__namespace.createElement("div", {
29159
- className: "perseus-widget-row"
29160
- }, "Range: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathInput, {
29161
- buttonsVisible: "never",
29162
- value: this.props.rangeMin
29163
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29164
- ,
29165
- onChange: this.change("rangeMin"),
29166
- analytics: analyticsStub
29167
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29168
- buttonsVisible: "never",
29169
- value: this.props.rangeMax
29170
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29171
- ,
29172
- onChange: this.change("rangeMax"),
29173
- analytics: analyticsStub
29123
+ }, "Start: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29124
+ value: this.props.startX,
29125
+ onChange: this.change("startX")
29126
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29127
+ value: this.props.startY,
29128
+ onChange: this.change("startY")
29174
29129
  }), /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large)")), /*#__PURE__*/React__namespace.createElement("div", {
29175
29130
  className: "perseus-widget-row"
29176
- }, /*#__PURE__*/React__namespace.createElement(perseus.ColorPicker, {
29177
- value: this.props.color
29178
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29179
- ,
29180
- onChange: this.change("color")
29181
- })), /*#__PURE__*/React__namespace.createElement("div", {
29182
- className: "perseus-widget-row"
29183
- }, /*#__PURE__*/React__namespace.createElement(perseus.DashPicker, {
29184
- value: this.props.strokeDasharray
29185
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29186
- ,
29187
- onChange: this.change("strokeDasharray")
29188
- })), /*#__PURE__*/React__namespace.createElement("div", {
29189
- className: "perseus-widget-row"
29190
- }, /*#__PURE__*/React__namespace.createElement("div", {
29191
- className: "perseus-widget-left-col"
29192
- }, "Width:", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$b, {
29193
- value: this.props.strokeWidth,
29194
- placeholder: 2
29195
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29196
- ,
29197
- onChange: this.change("strokeWidth")
29198
- }))));
29131
+ }, "Update ", /*#__PURE__*/React__namespace.createElement(TeX, null, "(x_n, y_n)"), " for ", /*#__PURE__*/React__namespace.createElement(TeX, null, "n ="), " ", /*#__PURE__*/React__namespace.createElement(NumberInput$c, {
29132
+ value: this.props.varSubscript,
29133
+ placeholder: 0,
29134
+ onChange: this.change("varSubscript")
29135
+ })), /*#__PURE__*/React__namespace.createElement(ConstraintEditor, this.props));
29199
29136
  }
29200
- change = (() => {
29201
- var _this5 = this;
29202
- return function () {
29203
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
29204
- args[_key5] = arguments[_key5];
29205
- }
29206
- return perseus.Changeable.change.apply(_this5, args);
29207
- };
29208
- })();
29209
- serialize = () => {
29210
- return perseus.EditorJsonify.serialize.call(this);
29211
- };
29212
29137
  }
29213
- //
29138
+
29139
+ const {
29140
+ NumberInput: NumberInput$b
29141
+ } = perseus.components;
29142
+ const {
29143
+ getDependencies: getDependencies$3
29144
+ } = perseus.Dependencies;
29214
29145
  // Editor for parametric plots
29215
- //
29216
- // TODO(eater): Factor this out
29217
- //
29218
29146
  class ParametricEditor extends React__namespace.Component {
29219
- static propTypes = {
29220
- ...perseus.Changeable.propTypes,
29221
- x: PropTypes__default["default"].string,
29222
- y: PropTypes__default["default"].string,
29223
- rangeMin: PropTypes__default["default"].string,
29224
- rangeMax: PropTypes__default["default"].string,
29225
- color: PropTypes__default["default"].string,
29226
- strokeDashArray: PropTypes__default["default"].string,
29227
- strokeWidth: PropTypes__default["default"].number
29228
- };
29229
29147
  static defaultProps = {
29230
29148
  x: "cos(t)",
29231
29149
  y: "sin(t)",
@@ -29235,62 +29153,51 @@ class ParametricEditor extends React__namespace.Component {
29235
29153
  strokeDasharray: "",
29236
29154
  strokeWidth: 2
29237
29155
  };
29156
+ change = (() => {
29157
+ var _this = this;
29158
+ return function () {
29159
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29160
+ args[_key] = arguments[_key];
29161
+ }
29162
+ return perseus.Changeable.change.apply(_this, args);
29163
+ };
29164
+ })();
29165
+ serialize = () => {
29166
+ return perseus.EditorJsonify.serialize.call(this);
29167
+ };
29238
29168
  render() {
29239
29169
  const {
29240
29170
  TeX
29241
- } = getDependencies();
29242
- const analyticsStub = {
29243
- onAnalyticsEvent: () => Promise.resolve()
29244
- };
29171
+ } = getDependencies$3();
29245
29172
  return /*#__PURE__*/React__namespace.createElement("div", {
29246
29173
  className: "graph-settings"
29247
29174
  }, /*#__PURE__*/React__namespace.createElement("div", {
29248
29175
  className: "perseus-widget-row"
29249
- }, /*#__PURE__*/React__namespace.createElement(TeX, null, "X(t) ="), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29250
- buttonsVisible: "never",
29251
- value: this.props.x
29252
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29253
- ,
29254
- onChange: this.change("x"),
29255
- analytics: analyticsStub
29176
+ }, /*#__PURE__*/React__namespace.createElement(TeX, null, "X(t) ="), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29177
+ value: this.props.x,
29178
+ onChange: this.change("x")
29256
29179
  })), /*#__PURE__*/React__namespace.createElement("div", {
29257
29180
  className: "perseus-widget-row"
29258
- }, /*#__PURE__*/React__namespace.createElement(TeX, null, "Y(t) ="), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29259
- buttonsVisible: "never",
29260
- value: this.props.y
29261
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29262
- ,
29263
- onChange: this.change("y"),
29264
- analytics: analyticsStub
29181
+ }, /*#__PURE__*/React__namespace.createElement(TeX, null, "Y(t) ="), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29182
+ value: this.props.y,
29183
+ onChange: this.change("y")
29265
29184
  })), /*#__PURE__*/React__namespace.createElement("div", {
29266
29185
  className: "perseus-widget-row"
29267
- }, "Range: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathInput, {
29268
- buttonsVisible: "never",
29269
- value: this.props.rangeMin
29270
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29271
- ,
29272
- onChange: this.change("rangeMin"),
29273
- analytics: analyticsStub
29274
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29275
- buttonsVisible: "never",
29276
- value: this.props.rangeMax
29277
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29278
- ,
29279
- onChange: this.change("rangeMax"),
29280
- analytics: analyticsStub
29186
+ }, "Range: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29187
+ value: this.props.rangeMin,
29188
+ onChange: this.change("rangeMin")
29189
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29190
+ value: this.props.rangeMax,
29191
+ onChange: this.change("rangeMax")
29281
29192
  }), /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large)")), /*#__PURE__*/React__namespace.createElement("div", {
29282
29193
  className: "perseus-widget-row"
29283
29194
  }, /*#__PURE__*/React__namespace.createElement(perseus.ColorPicker, {
29284
- value: this.props.color
29285
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29286
- ,
29195
+ value: this.props.color,
29287
29196
  onChange: this.change("color")
29288
29197
  })), /*#__PURE__*/React__namespace.createElement("div", {
29289
29198
  className: "perseus-widget-row"
29290
29199
  }, /*#__PURE__*/React__namespace.createElement(perseus.DashPicker, {
29291
- value: this.props.strokeDasharray
29292
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29293
- ,
29200
+ value: this.props.strokeDasharray,
29294
29201
  onChange: this.change("strokeDasharray")
29295
29202
  })), /*#__PURE__*/React__namespace.createElement("div", {
29296
29203
  className: "perseus-widget-row"
@@ -29298,116 +29205,62 @@ class ParametricEditor extends React__namespace.Component {
29298
29205
  className: "perseus-widget-left-col"
29299
29206
  }, "Width:", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$b, {
29300
29207
  value: this.props.strokeWidth,
29301
- placeholder: 2
29302
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29303
- ,
29208
+ placeholder: 2,
29304
29209
  onChange: this.change("strokeWidth")
29305
29210
  }))));
29306
29211
  }
29212
+ }
29213
+
29214
+ const {
29215
+ getDependencies: getDependencies$2
29216
+ } = perseus.Dependencies;
29217
+ // Editor for non-interactive points
29218
+ class PointEditor extends React__namespace.Component {
29219
+ static defaultProps = {
29220
+ coordX: "0",
29221
+ coordY: "0",
29222
+ color: perseus.KhanColors.BLACK
29223
+ };
29307
29224
  change = (() => {
29308
- var _this6 = this;
29225
+ var _this = this;
29309
29226
  return function () {
29310
- for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
29311
- args[_key6] = arguments[_key6];
29227
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29228
+ args[_key] = arguments[_key];
29312
29229
  }
29313
- return perseus.Changeable.change.apply(_this6, args);
29230
+ return perseus.Changeable.change.apply(_this, args);
29314
29231
  };
29315
29232
  })();
29316
29233
  serialize = () => {
29317
29234
  return perseus.EditorJsonify.serialize.call(this);
29318
29235
  };
29319
- }
29320
- //
29321
- // Editor for labels
29322
- //
29323
- // TODO(eater): Factor this out maybe?
29324
- // TODO(eater): Add text direction
29325
- //
29326
- class LabelEditor extends React__namespace.Component {
29327
- static propTypes = {
29328
- ...perseus.Changeable.propTypes,
29329
- color: PropTypes__default["default"].string,
29330
- coordX: PropTypes__default["default"].string,
29331
- coordY: PropTypes__default["default"].string,
29332
- label: PropTypes__default["default"].string
29333
- };
29334
- static defaultProps = {
29335
- coordX: "0",
29336
- coordY: "0",
29337
- color: perseus.KhanColors.BLACK,
29338
- label: "\\phi"
29339
- };
29340
29236
  render() {
29341
29237
  const {
29342
29238
  TeX
29343
- } = getDependencies();
29344
- const analyticsStub = {
29345
- onAnalyticsEvent: () => Promise.resolve()
29346
- };
29239
+ } = getDependencies$2();
29347
29240
  return /*#__PURE__*/React__namespace.createElement("div", {
29348
29241
  className: "graph-settings"
29349
29242
  }, /*#__PURE__*/React__namespace.createElement("div", {
29350
29243
  className: "perseus-widget-row"
29351
- }, /*#__PURE__*/React__namespace.createElement(TextInput$5, {
29352
- value: this.props.label
29353
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29354
- ,
29355
- onChange: this.change("label"),
29356
- style: {
29357
- width: "100%"
29358
- }
29359
- })), /*#__PURE__*/React__namespace.createElement("div", {
29360
- className: "perseus-widget-row"
29361
- }, "Location: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathInput, {
29362
- buttonsVisible: "never",
29363
- value: this.props.coordX
29364
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29365
- ,
29366
- onChange: this.change("coordX"),
29367
- analytics: analyticsStub
29368
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29369
- buttonsVisible: "never",
29370
- value: this.props.coordY
29371
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29372
- ,
29373
- onChange: this.change("coordY"),
29374
- analytics: analyticsStub
29244
+ }, "Coordinate: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29245
+ value: this.props.coordX,
29246
+ onChange: this.change("coordX")
29247
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29248
+ value: this.props.coordY,
29249
+ onChange: this.change("coordY")
29375
29250
  }), /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large)")), /*#__PURE__*/React__namespace.createElement("div", {
29376
29251
  className: "perseus-widget-row"
29377
29252
  }, /*#__PURE__*/React__namespace.createElement(perseus.ColorPicker, {
29378
- value: this.props.color
29379
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29380
- ,
29253
+ value: this.props.color,
29381
29254
  onChange: this.change("color")
29382
29255
  })));
29383
29256
  }
29384
- change = (() => {
29385
- var _this7 = this;
29386
- return function () {
29387
- for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
29388
- args[_key7] = arguments[_key7];
29389
- }
29390
- return perseus.Changeable.change.apply(_this7, args);
29391
- };
29392
- })();
29393
- serialize = () => {
29394
- return perseus.EditorJsonify.serialize.call(this);
29395
- };
29396
29257
  }
29397
- //
29258
+
29259
+ const {
29260
+ getDependencies: getDependencies$1
29261
+ } = perseus.Dependencies;
29398
29262
  // Editor for rectangles
29399
- //
29400
- // TODO(eater): Factor this out maybe?
29401
- //
29402
29263
  class RectangleEditor extends React__namespace.Component {
29403
- static propTypes = {
29404
- ...perseus.Changeable.propTypes,
29405
- color: PropTypes__default["default"].string,
29406
- coordX: PropTypes__default["default"].string,
29407
- coordY: PropTypes__default["default"].string,
29408
- height: PropTypes__default["default"].string,
29409
- width: PropTypes__default["default"].string
29410
- };
29411
29264
  static defaultProps = {
29412
29265
  coordX: "-5",
29413
29266
  coordY: "5",
@@ -29415,82 +29268,72 @@ class RectangleEditor extends React__namespace.Component {
29415
29268
  height: "3",
29416
29269
  color: perseus.KhanColors.LIGHT_BLUE
29417
29270
  };
29271
+ change = (() => {
29272
+ var _this = this;
29273
+ return function () {
29274
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29275
+ args[_key] = arguments[_key];
29276
+ }
29277
+ return perseus.Changeable.change.apply(_this, args);
29278
+ };
29279
+ })();
29280
+ serialize = () => {
29281
+ return perseus.EditorJsonify.serialize.call(this);
29282
+ };
29418
29283
  render() {
29419
29284
  const {
29420
29285
  TeX
29421
- } = getDependencies();
29422
- const analyticsStub = {
29423
- onAnalyticsEvent: () => Promise.resolve()
29424
- };
29286
+ } = getDependencies$1();
29425
29287
  return /*#__PURE__*/React__namespace.createElement("div", {
29426
29288
  className: "graph-settings"
29427
29289
  }, /*#__PURE__*/React__namespace.createElement("div", {
29428
29290
  className: "perseus-widget-row"
29429
- }, "Bottom left: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathInput, {
29430
- buttonsVisible: "never",
29431
- value: this.props.coordX
29432
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29433
- ,
29434
- onChange: this.change("coordX"),
29435
- analytics: analyticsStub
29436
- }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29437
- buttonsVisible: "never",
29438
- value: this.props.coordY
29439
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29440
- ,
29441
- onChange: this.change("coordY"),
29442
- analytics: analyticsStub
29291
+ }, "Bottom left: ", /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large("), /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29292
+ value: this.props.coordX,
29293
+ onChange: this.change("coordX")
29294
+ }), /*#__PURE__*/React__namespace.createElement(TeX, null, ","), " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29295
+ value: this.props.coordY,
29296
+ onChange: this.change("coordY")
29443
29297
  }), /*#__PURE__*/React__namespace.createElement(TeX, null, "\\Large)")), /*#__PURE__*/React__namespace.createElement("div", {
29444
29298
  className: "perseus-widget-row"
29445
- }, "Width:", " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29446
- buttonsVisible: "never",
29447
- value: this.props.width
29448
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29449
- ,
29450
- onChange: this.change("width"),
29451
- analytics: analyticsStub
29299
+ }, "Width:", " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29300
+ value: this.props.width,
29301
+ onChange: this.change("width")
29452
29302
  })), /*#__PURE__*/React__namespace.createElement("div", {
29453
29303
  className: "perseus-widget-row"
29454
- }, "Height:", " ", /*#__PURE__*/React__namespace.createElement(MathInput, {
29455
- buttonsVisible: "never",
29456
- value: this.props.height
29457
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29458
- ,
29459
- onChange: this.change("height"),
29460
- analytics: analyticsStub
29304
+ }, "Height:", " ", /*#__PURE__*/React__namespace.createElement(MathquillInput, {
29305
+ value: this.props.height,
29306
+ onChange: this.change("height")
29461
29307
  })), /*#__PURE__*/React__namespace.createElement("div", {
29462
29308
  className: "perseus-widget-row"
29463
29309
  }, /*#__PURE__*/React__namespace.createElement(perseus.ColorPicker, {
29464
29310
  value: this.props.color,
29465
- lightColors: true
29466
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
29467
- ,
29311
+ lightColors: true,
29468
29312
  onChange: this.change("color")
29469
29313
  })), /*#__PURE__*/React__namespace.createElement("div", {
29470
29314
  className: "perseus-widget-row"
29471
29315
  }, "You want a border? Sorry, draw your own."));
29472
29316
  }
29473
- change = (() => {
29474
- var _this8 = this;
29475
- return function () {
29476
- for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
29477
- args[_key8] = arguments[_key8];
29478
- }
29479
- return perseus.Changeable.change.apply(_this8, args);
29480
- };
29481
- })();
29482
- serialize = () => {
29483
- return perseus.EditorJsonify.serialize.call(this);
29484
- };
29485
29317
  }
29318
+
29319
+ const {
29320
+ getDependencies
29321
+ } = perseus.Dependencies;
29322
+ const {
29323
+ unescapeMathMode
29324
+ } = perseus.Util;
29325
+ const defaultInteractionProps = {
29326
+ graph: {
29327
+ box: [400, 400],
29328
+ labels: ["x", "y"],
29329
+ range: [[-10, 10], [-10, 10]],
29330
+ tickStep: [1, 1],
29331
+ gridStep: [1, 1],
29332
+ markings: "graph"
29333
+ },
29334
+ elements: []
29335
+ };
29486
29336
  class InteractionEditor extends React__namespace.Component {
29487
- // TODO(eater): Make more better
29488
- static propTypes = {
29489
- ...perseus.Changeable.propTypes,
29490
- // eslint-disable-next-line react/forbid-prop-types
29491
- elements: PropTypes__default["default"].arrayOf(PropTypes__default["default"].object),
29492
- graph: PropTypes__default["default"].objectOf(PropTypes__default["default"].any)
29493
- };
29494
29337
  static widgetName = "interaction";
29495
29338
  static defaultProps = defaultInteractionProps;
29496
29339
  state = {
@@ -29589,14 +29432,17 @@ class InteractionEditor extends React__namespace.Component {
29589
29432
  });
29590
29433
  };
29591
29434
  change = (() => {
29592
- var _this9 = this;
29435
+ var _this = this;
29593
29436
  return function () {
29594
- for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
29595
- args[_key9] = arguments[_key9];
29437
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29438
+ args[_key] = arguments[_key];
29596
29439
  }
29597
- return perseus.Changeable.change.apply(_this9, args);
29440
+ return perseus.Changeable.change.apply(_this, args);
29598
29441
  };
29599
29442
  })();
29443
+ serialize = () => {
29444
+ return perseus.EditorJsonify.serialize.call(this);
29445
+ };
29600
29446
  render() {
29601
29447
  const {
29602
29448
  TeX
@@ -29918,10 +29764,6 @@ class InteractionEditor extends React__namespace.Component {
29918
29764
  }, "\u2605 Movable line segment"))));
29919
29765
  /* eslint-enable max-len */
29920
29766
  }
29921
-
29922
- serialize = () => {
29923
- return perseus.EditorJsonify.serialize.call(this);
29924
- };
29925
29767
  }
29926
29768
 
29927
29769
  const UNLIMITED = "unlimited";