@khanacademy/perseus-editor 14.1.0 → 14.1.1

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.
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
2
  type Props = {
3
- showM2bFeatures: boolean;
4
3
  showLabelsFlag?: boolean;
5
4
  id: string;
6
5
  onChange: (value: string) => void;
@@ -14,7 +14,6 @@ import type { Props as LockedPointProps } from "./locked-point-settings";
14
14
  import type { Props as LockedPolygonProps } from "./locked-polygon-settings";
15
15
  import type { Props as LockedVectorProps } from "./locked-vector-settings";
16
16
  export type LockedFigureSettingsCommonProps = {
17
- showM2bFeatures?: boolean;
18
17
  showLabelsFlag?: boolean;
19
18
  /**
20
19
  * Called when a movement button (top, up, down, bottom) is pressed.
@@ -2,7 +2,6 @@ import * as React from "react";
2
2
  import type { Props as InteractiveGraphEditorProps } from "../../widgets/interactive-graph-editor/interactive-graph-editor";
3
3
  import type { LockedFigure } from "@khanacademy/perseus";
4
4
  type Props = {
5
- showM2bFeatures: boolean;
6
5
  showLabelsFlag?: boolean;
7
6
  figures?: Array<LockedFigure>;
8
7
  onChange: (props: Partial<InteractiveGraphEditorProps>) => void;
@@ -14,4 +14,4 @@ export declare function getDefaultGraphStartCoords(graph: PerseusGraphType, rang
14
14
  export declare const getSinusoidEquation: (startCoords: [Coord, Coord]) => string;
15
15
  export declare const getQuadraticEquation: (startCoords: [Coord, Coord, Coord]) => string;
16
16
  export declare const getAngleEquation: (startCoords: [Coord, Coord, Coord]) => string;
17
- export declare const shouldShowStartCoordsUI: (flags: any, graph: any) => boolean;
17
+ export declare const shouldShowStartCoordsUI: (graph: PerseusGraphType, isStatic?: boolean) => boolean;
package/dist/es/index.js CHANGED
@@ -15,7 +15,7 @@ import Switch from '@khanacademy/wonder-blocks-switch';
15
15
  import { PhosphorIcon } from '@khanacademy/wonder-blocks-icon';
16
16
  import caretRight from '@phosphor-icons/core/bold/caret-right-bold.svg';
17
17
  import classNames from 'classnames';
18
- import { Checkbox as Checkbox$1, LabeledTextField, TextField } from '@khanacademy/wonder-blocks-form';
18
+ import { Checkbox as Checkbox$1, LabeledTextField, TextField, TextArea } from '@khanacademy/wonder-blocks-form';
19
19
  import ReactDOM from 'react-dom';
20
20
  import * as KAS from '@khanacademy/kas';
21
21
  import Button from '@khanacademy/wonder-blocks-button';
@@ -44,7 +44,7 @@ import arrowCounterClockwise from '@phosphor-icons/core/bold/arrow-counter-clock
44
44
 
45
45
  // This file is processed by a Rollup plugin (replace) to inject the production
46
46
  const libName = "@khanacademy/perseus-editor";
47
- const libVersion = "14.1.0";
47
+ const libVersion = "14.1.1";
48
48
  addLibraryVersionToPerseusDebug(libName, libVersion);
49
49
 
50
50
  function _extends() {
@@ -29780,35 +29780,20 @@ const getAngleEquation = startCoords => {
29780
29780
  const roundedAngle = angle.toFixed(0);
29781
29781
  return `${roundedAngle}\u00B0 angle at (${vertex[0]}, ${vertex[1]})`;
29782
29782
  };
29783
- const shouldShowStartCoordsUI = (flags, graph) => {
29784
- var _flags$mafs, _flags$mafs2, _flags$mafs3, _flags$mafs4, _flags$mafs5;
29785
- // TODO(LEMS-2228): Remove flags once this is fully released
29786
- const startCoordsUiPhase1Types = ["linear", "linear-system", "ray", "segment", "circle"];
29787
- const startCoordsUiPhase2Types = ["sinusoid", "quadratic"];
29788
- const startCoordsPhase1 = flags == null || (_flags$mafs = flags.mafs) == null ? void 0 : _flags$mafs["start-coords-ui-phase-1"];
29789
- const startCoordsPhase2 = flags == null || (_flags$mafs2 = flags.mafs) == null ? void 0 : _flags$mafs2["start-coords-ui-phase-2"];
29790
- const startCoordsPoint = flags == null || (_flags$mafs3 = flags.mafs) == null ? void 0 : _flags$mafs3["start-coords-ui-point"];
29791
- const startCoordsPolygon = flags == null || (_flags$mafs4 = flags.mafs) == null ? void 0 : _flags$mafs4["start-coords-ui-polygon"];
29792
- const startCoordsAngle = flags == null || (_flags$mafs5 = flags.mafs) == null ? void 0 : _flags$mafs5["start-coords-ui-angle"];
29793
- if (startCoordsPhase1 && startCoordsUiPhase1Types.includes(graph.type)) {
29794
- return true;
29795
- }
29796
- if (startCoordsPhase2 && startCoordsUiPhase2Types.includes(graph.type)) {
29797
- return true;
29798
- }
29799
- if (startCoordsAngle && graph.type === "angle") {
29800
- return true;
29783
+ const shouldShowStartCoordsUI = (graph, isStatic) => {
29784
+ // We don't show the start coords UI for static graphs, since
29785
+ // the coords shown for this are determined by the coords on the
29786
+ // "correct" graph. The start coords would not be used here.
29787
+ if (isStatic) {
29788
+ return false;
29801
29789
  }
29802
- if (startCoordsPoint && graph.type === "point" && graph.numPoints !== "unlimited") {
29803
- return true;
29790
+ if (graph.type === "point" && graph.numPoints === "unlimited") {
29791
+ return false;
29804
29792
  }
29805
- if (startCoordsPolygon && graph.type === "polygon" && graph.numSides !== "unlimited" && (
29806
- // Pre-initialized graph with undefined snapTo value
29807
- // initializes to snapTo="grid"
29808
- graph.snapTo === "grid" || graph.snapTo === undefined)) {
29809
- return true;
29793
+ if (graph.type === "polygon" && (graph.numSides === "unlimited" || graph.snapTo === "angles" || graph.snapTo === "sides")) {
29794
+ return false;
29810
29795
  }
29811
- return false;
29796
+ return true;
29812
29797
  };
29813
29798
 
29814
29799
  /**
@@ -29823,10 +29808,7 @@ const LockedFigureSelect = props => {
29823
29808
  id,
29824
29809
  onChange
29825
29810
  } = props;
29826
- const figureTypes = ["point", "line", "vector", "ellipse", "polygon"];
29827
- if (props.showM2bFeatures) {
29828
- figureTypes.push("function");
29829
- }
29811
+ const figureTypes = ["point", "line", "vector", "ellipse", "polygon", "function"];
29830
29812
  if (props.showLabelsFlag) {
29831
29813
  figureTypes.push("label");
29832
29814
  }
@@ -31510,10 +31492,7 @@ const LockedFigureSettings = props => {
31510
31492
  case "polygon":
31511
31493
  return /*#__PURE__*/React.createElement(LockedPolygonSettings, props);
31512
31494
  case "function":
31513
- if (props.showM2bFeatures) {
31514
- return /*#__PURE__*/React.createElement(LockedFunctionSettings, props);
31515
- }
31516
- break;
31495
+ return /*#__PURE__*/React.createElement(LockedFunctionSettings, props);
31517
31496
  case "label":
31518
31497
  if (props.showLabelsFlag) {
31519
31498
  return /*#__PURE__*/React.createElement(LockedLabelSettings, props);
@@ -31624,7 +31603,6 @@ const LockedFiguresSection = props => {
31624
31603
  }), isExpanded && /*#__PURE__*/React.createElement(View, null, figures == null ? void 0 : figures.map((figure, index) => {
31625
31604
  return /*#__PURE__*/React.createElement(LockedFigureSettings, _extends({
31626
31605
  key: `${uniqueId}-locked-${figure}-${index}`,
31627
- showM2bFeatures: props.showM2bFeatures,
31628
31606
  showLabelsFlag: props.showLabelsFlag,
31629
31607
  expanded: expandedStates[index],
31630
31608
  onToggle: newValue => {
@@ -31640,7 +31618,6 @@ const LockedFiguresSection = props => {
31640
31618
  }), /*#__PURE__*/React.createElement(View, {
31641
31619
  style: styles$n.buttonContainer
31642
31620
  }, /*#__PURE__*/React.createElement(LockedFigureSelect, {
31643
- showM2bFeatures: props.showM2bFeatures,
31644
31621
  showLabelsFlag: props.showLabelsFlag,
31645
31622
  id: `${uniqueId}-select`,
31646
31623
  onChange: addLockedFigure
@@ -31795,24 +31772,20 @@ function InteractiveGraphDescription(props) {
31795
31772
  value: ariaLabelValue,
31796
31773
  onChange: newValue => onChange({
31797
31774
  fullGraphAriaLabel: newValue
31798
- })
31775
+ }),
31776
+ style: styles$k.spaceAbove
31799
31777
  })), /*#__PURE__*/React.createElement(Strut, {
31800
- size: spacing.xSmall_8
31778
+ size: spacing.small_12
31801
31779
  }), /*#__PURE__*/React.createElement(LabelLarge, {
31802
31780
  tag: "label"
31803
- // TODO(LEMS-2332): Remove this style prop after
31804
- // switching to WB TextArea
31805
- ,
31806
- style: {
31807
- display: "flex",
31808
- flexDirection: "column"
31809
- }
31810
- }, "Description", /*#__PURE__*/React.createElement("textarea", {
31781
+ }, "Description", /*#__PURE__*/React.createElement(TextArea, {
31811
31782
  rows: 8,
31783
+ resizeType: "vertical",
31812
31784
  value: ariaDescriptionValue,
31813
- onChange: e => onChange({
31814
- fullGraphAriaDescription: e.target.value
31815
- })
31785
+ onChange: newValue => onChange({
31786
+ fullGraphAriaDescription: newValue
31787
+ }),
31788
+ style: styles$k.spaceAbove
31816
31789
  }))));
31817
31790
  }
31818
31791
  const styles$k = StyleSheet.create({
@@ -31820,6 +31793,9 @@ const styles$k = StyleSheet.create({
31820
31793
  color: color.offBlack64,
31821
31794
  paddingTop: spacing.xxSmall_6,
31822
31795
  paddingBottom: spacing.xxSmall_6
31796
+ },
31797
+ spaceAbove: {
31798
+ marginTop: spacing.xxxSmall_4
31823
31799
  }
31824
31800
  });
31825
31801
 
@@ -32828,7 +32804,7 @@ class InteractiveGraphEditor extends React.Component {
32828
32804
  return json;
32829
32805
  }
32830
32806
  render() {
32831
- var _this$props$graph$typ, _this$props$graph3, _this$props$apiOption, _this$props$fullGraph, _this$props$fullGraph2, _this$props$correct, _this$props$correct2, _this$props$correct3, _this$props$correct4, _this$props$correct5, _this$props$correct6, _this$props$correct7, _this$props$correct8, _this$props$correct9, _this$props$correct10, _this$props$correct11, _this$props$graph9, _this$props$apiOption2, _this$props$apiOption3, _this$props$apiOption4;
32807
+ var _this$props$graph$typ, _this$props$graph3, _this$props$apiOption, _this$props$fullGraph, _this$props$fullGraph2, _this$props$correct, _this$props$correct2, _this$props$correct3, _this$props$correct4, _this$props$correct5, _this$props$correct6, _this$props$correct7, _this$props$correct8, _this$props$correct9, _this$props$correct10, _this$props$correct11, _this$props$graph9, _this$props$apiOption2, _this$props$apiOption3;
32832
32808
  let graph;
32833
32809
  let equationString;
32834
32810
  const gridStep = this.props.gridStep || Util.getGridStep(this.props.range, this.props.step, interactiveSizes.defaultBoxSize);
@@ -33046,9 +33022,7 @@ class InteractiveGraphEditor extends React.Component {
33046
33022
  }
33047
33023
  });
33048
33024
  }
33049
- })), ((_this$props$graph9 = this.props.graph) == null ? void 0 : _this$props$graph9.type) &&
33050
- // TODO(LEMS-2228): Remove flags once this is fully released
33051
- shouldShowStartCoordsUI(this.props.apiOptions.flags, this.props.graph) && /*#__PURE__*/React.createElement(StartCoordsSettings, _extends({}, this.props.graph, {
33025
+ })), ((_this$props$graph9 = this.props.graph) == null ? void 0 : _this$props$graph9.type) && shouldShowStartCoordsUI(this.props.graph, this.props.static) && /*#__PURE__*/React.createElement(StartCoordsSettings, _extends({}, this.props.graph, {
33052
33026
  range: this.props.range,
33053
33027
  step: this.props.step,
33054
33028
  onChange: this.changeStartCoords
@@ -33133,8 +33107,7 @@ class InteractiveGraphEditor extends React.Component {
33133
33107
  // Only show the "Add locked figure" dropdown if the graph
33134
33108
  // is using Mafs.
33135
33109
  this.props.graph && ((_this$props$apiOption2 = this.props.apiOptions) == null || (_this$props$apiOption2 = _this$props$apiOption2.flags) == null || (_this$props$apiOption2 = _this$props$apiOption2.mafs) == null ? void 0 : _this$props$apiOption2[this.props.graph.type]) && /*#__PURE__*/React.createElement(LockedFiguresSection, {
33136
- showM2bFeatures: (_this$props$apiOption3 = this.props.apiOptions) == null || (_this$props$apiOption3 = _this$props$apiOption3.flags) == null || (_this$props$apiOption3 = _this$props$apiOption3.mafs) == null ? void 0 : _this$props$apiOption3["interactive-graph-locked-features-m2b"],
33137
- showLabelsFlag: (_this$props$apiOption4 = this.props.apiOptions) == null || (_this$props$apiOption4 = _this$props$apiOption4.flags) == null || (_this$props$apiOption4 = _this$props$apiOption4.mafs) == null ? void 0 : _this$props$apiOption4["interactive-graph-locked-features-labels"],
33110
+ showLabelsFlag: (_this$props$apiOption3 = this.props.apiOptions) == null || (_this$props$apiOption3 = _this$props$apiOption3.flags) == null || (_this$props$apiOption3 = _this$props$apiOption3.mafs) == null ? void 0 : _this$props$apiOption3["interactive-graph-locked-features-labels"],
33138
33111
  figures: this.props.lockedFigures,
33139
33112
  onChange: this.props.onChange
33140
33113
  }));