@khanacademy/perseus-editor 7.0.0 → 7.0.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.
package/dist/index.js CHANGED
@@ -81,7 +81,7 @@ var Banner__default = /*#__PURE__*/_interopDefaultLegacy(Banner);
81
81
 
82
82
  // This file is processed by a Rollup plugin (replace) to inject the production
83
83
  const libName = "@khanacademy/perseus-editor";
84
- const libVersion = "7.0.0";
84
+ const libVersion = "7.0.1";
85
85
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
86
86
 
87
87
  function _extends() {
@@ -29854,71 +29854,6 @@ const styles$v = aphrodite.StyleSheet.create({
29854
29854
  }
29855
29855
  });
29856
29856
 
29857
- const ColorSwatch = props => {
29858
- const {
29859
- color,
29860
- filled = true,
29861
- decorative = false
29862
- } = props;
29863
- return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
29864
- "aria-label":
29865
- // Don't include an aria label for decorative circles.
29866
- !decorative ? `${color}, ${filled ? "filled" : "open"}` : undefined,
29867
- style: [styles$u.colorSwatch, {
29868
- border: `4px solid ${perseus.lockedFigureColors[color]}`,
29869
- backgroundColor: filled ? perseus.lockedFigureColors[color] : wonderBlocksTokens.color.white
29870
- }]
29871
- });
29872
- };
29873
- const styles$u = aphrodite.StyleSheet.create({
29874
- colorSwatch: {
29875
- // Add a white outline so that the color swatch is visible when
29876
- // the dropdown option is highlighted with its blue background.
29877
- outline: `2px solid ${wonderBlocksTokens.color.offWhite}`,
29878
- borderRadius: "50%",
29879
- width: wonderBlocksTokens.spacing.large_24,
29880
- height: wonderBlocksTokens.spacing.large_24
29881
- }
29882
- });
29883
-
29884
- const possibleColors = Object.keys(perseus.lockedFigureColors);
29885
- const ColorSelect = props => {
29886
- const {
29887
- selectedValue,
29888
- style,
29889
- onChange
29890
- } = props;
29891
- return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
29892
- style: [styles$t.row, style]
29893
- }, /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
29894
- tag: "label",
29895
- style: styles$t.row
29896
- }, "color", /*#__PURE__*/React__namespace.createElement(Strut, {
29897
- size: wonderBlocksTokens.spacing.xxSmall_6
29898
- }), /*#__PURE__*/React__namespace.createElement(wonderBlocksDropdown.SingleSelect, {
29899
- selectedValue: selectedValue,
29900
- onChange: onChange
29901
- // Placeholder is required, but never gets used.
29902
- ,
29903
- placeholder: ""
29904
- }, possibleColors.map(colorName => /*#__PURE__*/React__namespace.createElement(wonderBlocksDropdown.OptionItem, {
29905
- key: colorName,
29906
- value: colorName,
29907
- label: colorName,
29908
- leftAccessory: /*#__PURE__*/React__namespace.createElement(ColorSwatch, {
29909
- color: colorName,
29910
- decorative: true
29911
- })
29912
- }, colorName)))));
29913
- };
29914
- const styles$t = aphrodite.StyleSheet.create({
29915
- row: {
29916
- display: "flex",
29917
- flexDirection: "row",
29918
- alignItems: "center"
29919
- }
29920
- });
29921
-
29922
29857
  const CoordinatePairInput = props => {
29923
29858
  const {
29924
29859
  coord,
@@ -29951,32 +29886,32 @@ const CoordinatePairInput = props => {
29951
29886
  onChange(newCoords);
29952
29887
  }
29953
29888
  return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
29954
- style: [styles$s.row, style]
29889
+ style: [styles$u.row, style]
29955
29890
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
29956
29891
  tag: "label",
29957
- style: styles$s.row
29892
+ style: styles$u.row
29958
29893
  }, labels ? labels[0] : "x coord", /*#__PURE__*/React__namespace.createElement(Strut, {
29959
29894
  size: wonderBlocksTokens.spacing.xxSmall_6
29960
29895
  }), /*#__PURE__*/React__namespace.createElement(wonderBlocksForm.TextField, {
29961
29896
  type: "number",
29962
29897
  value: coordState[0],
29963
29898
  onChange: newValue => handleCoordChange(newValue, 0),
29964
- style: [styles$s.textField, error ? styles$s.errorField : undefined]
29899
+ style: [styles$u.textField, error ? styles$u.errorField : undefined]
29965
29900
  })), /*#__PURE__*/React__namespace.createElement(Strut, {
29966
29901
  size: wonderBlocksTokens.spacing.medium_16
29967
29902
  }), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
29968
29903
  tag: "label",
29969
- style: styles$s.row
29904
+ style: styles$u.row
29970
29905
  }, labels ? labels[1] : "y coord", /*#__PURE__*/React__namespace.createElement(Strut, {
29971
29906
  size: wonderBlocksTokens.spacing.xxSmall_6
29972
29907
  }), /*#__PURE__*/React__namespace.createElement(wonderBlocksForm.TextField, {
29973
29908
  type: "number",
29974
29909
  value: coordState[1],
29975
29910
  onChange: newValue => handleCoordChange(newValue, 1),
29976
- style: [styles$s.textField, error ? styles$s.errorField : undefined]
29911
+ style: [styles$u.textField, error ? styles$u.errorField : undefined]
29977
29912
  })));
29978
29913
  };
29979
- const styles$s = aphrodite.StyleSheet.create({
29914
+ const styles$u = aphrodite.StyleSheet.create({
29980
29915
  row: {
29981
29916
  display: "flex",
29982
29917
  flexDirection: "row",
@@ -29991,44 +29926,7 @@ const styles$s = aphrodite.StyleSheet.create({
29991
29926
  }
29992
29927
  });
29993
29928
 
29994
- const EllipseSwatch = props => {
29995
- const {
29996
- color,
29997
- fillStyle,
29998
- strokeStyle
29999
- } = props;
30000
- return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
30001
- "aria-label": `${color}, stroke ${strokeStyle}, fill ${fillStyle}`,
30002
- style: [styles$r.container, {
30003
- border: `4px ${strokeStyle} ${perseus.lockedFigureColors[color]}`
30004
- }]
30005
- }, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
30006
- style: [styles$r.innerCircle, {
30007
- backgroundColor: perseus.lockedFigureColors[color],
30008
- opacity: perseus.lockedFigureFillStyles[fillStyle]
30009
- }]
30010
- }));
30011
- };
30012
- const styles$r = aphrodite.StyleSheet.create({
30013
- container: {
30014
- // Add a white outline so that the color swatch is visible when
30015
- // the dropdown option is highlighted with its blue background.
30016
- outline: `2px solid ${wonderBlocksTokens.color.offWhite}`,
30017
- borderRadius: "50%",
30018
- width: wonderBlocksTokens.spacing.xLarge_32,
30019
- height: wonderBlocksTokens.spacing.large_24,
30020
- backgroundColor: wonderBlocksTokens.color.white,
30021
- alignItems: "center",
30022
- justifyContent: "center"
30023
- },
30024
- innerCircle: {
30025
- width: 28,
30026
- height: 20,
30027
- borderRadius: "50%"
30028
- }
30029
- });
30030
-
30031
- const LockedFigureSettingsAccordion = props => {
29929
+ const PerseusEditorAccordion = props => {
30032
29930
  const {
30033
29931
  children,
30034
29932
  header,
@@ -30042,18 +29940,18 @@ const LockedFigureSettingsAccordion = props => {
30042
29940
  // .heading > h2 > .header styles from the articles.less
30043
29941
  // file (which is imported in perseus-renderer.less).
30044
29942
  , {
30045
- className: "locked-figure-accordion"
29943
+ className: "perseus-editor-accordion"
30046
29944
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksAccordion.AccordionSection, {
30047
29945
  expanded: expanded,
30048
29946
  onToggle: onToggle,
30049
- style: [styles$q.container, containerStyle],
30050
- headerStyle: styles$q.accordionHeader,
29947
+ style: [styles$t.container, containerStyle],
29948
+ headerStyle: styles$t.accordionHeader,
30051
29949
  header: header
30052
29950
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
30053
- style: [styles$q.accordionPanel, panelStyle]
29951
+ style: [styles$t.accordionPanel, panelStyle]
30054
29952
  }, children)));
30055
29953
  };
30056
- const styles$q = aphrodite.StyleSheet.create({
29954
+ const styles$t = aphrodite.StyleSheet.create({
30057
29955
  container: {
30058
29956
  backgroundColor: wonderBlocksTokens.color.fadedBlue8,
30059
29957
  marginTop: wonderBlocksTokens.spacing.xSmall_8
@@ -30074,6 +29972,108 @@ const styles$q = aphrodite.StyleSheet.create({
30074
29972
  }
30075
29973
  });
30076
29974
 
29975
+ const ColorSwatch = props => {
29976
+ const {
29977
+ color,
29978
+ filled = true,
29979
+ decorative = false
29980
+ } = props;
29981
+ return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
29982
+ "aria-label":
29983
+ // Don't include an aria label for decorative circles.
29984
+ !decorative ? `${color}, ${filled ? "filled" : "open"}` : undefined,
29985
+ style: [styles$s.colorSwatch, {
29986
+ border: `4px solid ${perseus.lockedFigureColors[color]}`,
29987
+ backgroundColor: filled ? perseus.lockedFigureColors[color] : wonderBlocksTokens.color.white
29988
+ }]
29989
+ });
29990
+ };
29991
+ const styles$s = aphrodite.StyleSheet.create({
29992
+ colorSwatch: {
29993
+ // Add a white outline so that the color swatch is visible when
29994
+ // the dropdown option is highlighted with its blue background.
29995
+ outline: `2px solid ${wonderBlocksTokens.color.offWhite}`,
29996
+ borderRadius: "50%",
29997
+ width: wonderBlocksTokens.spacing.large_24,
29998
+ height: wonderBlocksTokens.spacing.large_24
29999
+ }
30000
+ });
30001
+
30002
+ const possibleColors = Object.keys(perseus.lockedFigureColors);
30003
+ const ColorSelect = props => {
30004
+ const {
30005
+ selectedValue,
30006
+ style,
30007
+ onChange
30008
+ } = props;
30009
+ return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
30010
+ style: [styles$r.row, style]
30011
+ }, /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
30012
+ tag: "label",
30013
+ style: styles$r.row
30014
+ }, "color", /*#__PURE__*/React__namespace.createElement(Strut, {
30015
+ size: wonderBlocksTokens.spacing.xxSmall_6
30016
+ }), /*#__PURE__*/React__namespace.createElement(wonderBlocksDropdown.SingleSelect, {
30017
+ selectedValue: selectedValue,
30018
+ onChange: onChange
30019
+ // Placeholder is required, but never gets used.
30020
+ ,
30021
+ placeholder: ""
30022
+ }, possibleColors.map(colorName => /*#__PURE__*/React__namespace.createElement(wonderBlocksDropdown.OptionItem, {
30023
+ key: colorName,
30024
+ value: colorName,
30025
+ label: colorName,
30026
+ leftAccessory: /*#__PURE__*/React__namespace.createElement(ColorSwatch, {
30027
+ color: colorName,
30028
+ decorative: true
30029
+ })
30030
+ }, colorName)))));
30031
+ };
30032
+ const styles$r = aphrodite.StyleSheet.create({
30033
+ row: {
30034
+ display: "flex",
30035
+ flexDirection: "row",
30036
+ alignItems: "center"
30037
+ }
30038
+ });
30039
+
30040
+ const EllipseSwatch = props => {
30041
+ const {
30042
+ color,
30043
+ fillStyle,
30044
+ strokeStyle
30045
+ } = props;
30046
+ return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
30047
+ "aria-label": `${color}, stroke ${strokeStyle}, fill ${fillStyle}`,
30048
+ style: [styles$q.container, {
30049
+ border: `4px ${strokeStyle} ${perseus.lockedFigureColors[color]}`
30050
+ }]
30051
+ }, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
30052
+ style: [styles$q.innerCircle, {
30053
+ backgroundColor: perseus.lockedFigureColors[color],
30054
+ opacity: perseus.lockedFigureFillStyles[fillStyle]
30055
+ }]
30056
+ }));
30057
+ };
30058
+ const styles$q = aphrodite.StyleSheet.create({
30059
+ container: {
30060
+ // Add a white outline so that the color swatch is visible when
30061
+ // the dropdown option is highlighted with its blue background.
30062
+ outline: `2px solid ${wonderBlocksTokens.color.offWhite}`,
30063
+ borderRadius: "50%",
30064
+ width: wonderBlocksTokens.spacing.xLarge_32,
30065
+ height: wonderBlocksTokens.spacing.large_24,
30066
+ backgroundColor: wonderBlocksTokens.color.white,
30067
+ alignItems: "center",
30068
+ justifyContent: "center"
30069
+ },
30070
+ innerCircle: {
30071
+ width: 28,
30072
+ height: 20,
30073
+ borderRadius: "50%"
30074
+ }
30075
+ });
30076
+
30077
30077
  /**
30078
30078
  * The part of a locked figure settings panel that contains actions
30079
30079
  * for this panel and its associated locked figure, including
@@ -30159,7 +30159,7 @@ const LockedEllipseSettings = props => {
30159
30159
  color: newValue
30160
30160
  });
30161
30161
  }
30162
- return /*#__PURE__*/React__namespace.createElement(LockedFigureSettingsAccordion, {
30162
+ return /*#__PURE__*/React__namespace.createElement(PerseusEditorAccordion, {
30163
30163
  expanded: expanded,
30164
30164
  onToggle: onToggle,
30165
30165
  header:
@@ -30312,7 +30312,7 @@ const DefiningPointSettings = props => {
30312
30312
  color: newValue
30313
30313
  });
30314
30314
  }
30315
- return /*#__PURE__*/React__namespace.createElement(LockedFigureSettingsAccordion, {
30315
+ return /*#__PURE__*/React__namespace.createElement(PerseusEditorAccordion, {
30316
30316
  expanded: expanded,
30317
30317
  onToggle: onToggle,
30318
30318
  containerStyle: styles$m.container,
@@ -30446,7 +30446,7 @@ const LockedLineSettings = props => {
30446
30446
  }]
30447
30447
  });
30448
30448
  }
30449
- return /*#__PURE__*/React__namespace.createElement(LockedFigureSettingsAccordion, {
30449
+ return /*#__PURE__*/React__namespace.createElement(PerseusEditorAccordion, {
30450
30450
  expanded: props.expanded,
30451
30451
  onToggle: props.onToggle,
30452
30452
  header: /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
@@ -30571,7 +30571,7 @@ const LockedPointSettings = props => {
30571
30571
  color: newValue
30572
30572
  });
30573
30573
  }
30574
- return /*#__PURE__*/React__namespace.createElement(LockedFigureSettingsAccordion, {
30574
+ return /*#__PURE__*/React__namespace.createElement(PerseusEditorAccordion, {
30575
30575
  expanded: props.expanded,
30576
30576
  onToggle: props.onToggle,
30577
30577
  header:
@@ -30675,7 +30675,7 @@ const LockedPolygonSettings = props => {
30675
30675
  color: newValue
30676
30676
  });
30677
30677
  }
30678
- return /*#__PURE__*/React__namespace.createElement(LockedFigureSettingsAccordion, {
30678
+ return /*#__PURE__*/React__namespace.createElement(PerseusEditorAccordion, {
30679
30679
  expanded: expanded,
30680
30680
  onToggle: onToggle,
30681
30681
  header:
@@ -30740,7 +30740,7 @@ const LockedPolygonSettings = props => {
30740
30740
  showVertices: newValue
30741
30741
  }),
30742
30742
  style: styles$h.spaceUnder
30743
- }), /*#__PURE__*/React__namespace.createElement(LockedFigureSettingsAccordion, {
30743
+ }), /*#__PURE__*/React__namespace.createElement(PerseusEditorAccordion, {
30744
30744
  header: /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelLarge, null, "Points"),
30745
30745
  expanded: true,
30746
30746
  containerStyle: styles$h.pointAccordionContainer,
@@ -30848,7 +30848,7 @@ const LockedVectorSettings = props => {
30848
30848
  color: newColor
30849
30849
  });
30850
30850
  }
30851
- return /*#__PURE__*/React__namespace.createElement(LockedFigureSettingsAccordion, {
30851
+ return /*#__PURE__*/React__namespace.createElement(PerseusEditorAccordion, {
30852
30852
  expanded: props.expanded,
30853
30853
  onToggle: props.onToggle,
30854
30854
  header: /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
@@ -30866,7 +30866,7 @@ const LockedVectorSettings = props => {
30866
30866
  onChange: handleColorChange
30867
30867
  })), isInvalid && /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
30868
30868
  style: styles$g.errorText
30869
- }, lengthErrorMessage), /*#__PURE__*/React__namespace.createElement(LockedFigureSettingsAccordion, {
30869
+ }, lengthErrorMessage), /*#__PURE__*/React__namespace.createElement(PerseusEditorAccordion, {
30870
30870
  expanded: true // Initial state is expanded
30871
30871
  ,
30872
30872
  containerStyle: styles$g.container,
@@ -30880,7 +30880,7 @@ const LockedVectorSettings = props => {
30880
30880
  onChange: newProps => {
30881
30881
  handleChangePoint(newProps, 0);
30882
30882
  }
30883
- })), /*#__PURE__*/React__namespace.createElement(LockedFigureSettingsAccordion, {
30883
+ })), /*#__PURE__*/React__namespace.createElement(PerseusEditorAccordion, {
30884
30884
  expanded: true // Initial state is expanded
30885
30885
  ,
30886
30886
  containerStyle: styles$g.container,
@@ -31181,21 +31181,6 @@ const styles$d = aphrodite.StyleSheet.create({
31181
31181
  }
31182
31182
  });
31183
31183
 
31184
- /* eslint-disable react/forbid-prop-types, react/no-unsafe */
31185
- const {
31186
- ButtonGroup: ButtonGroup$2,
31187
- InfoTip: InfoTip$c,
31188
- PropCheckBox: PropCheckBox$7,
31189
- RangeInput: RangeInput$4
31190
- } = perseus.components;
31191
- const defaultBackgroundImage$1 = {
31192
- url: null,
31193
- width: 0,
31194
- height: 0
31195
- };
31196
- function numSteps(range, step) {
31197
- return Math.floor((range[1] - range[0]) / step);
31198
- }
31199
31184
  function Heading(_ref) {
31200
31185
  let {
31201
31186
  title,
@@ -31221,6 +31206,22 @@ function Heading(_ref) {
31221
31206
  isExpanded: isOpen
31222
31207
  }));
31223
31208
  }
31209
+
31210
+ /* eslint-disable react/forbid-prop-types, react/no-unsafe */
31211
+ const {
31212
+ ButtonGroup: ButtonGroup$2,
31213
+ InfoTip: InfoTip$c,
31214
+ PropCheckBox: PropCheckBox$7,
31215
+ RangeInput: RangeInput$4
31216
+ } = perseus.components;
31217
+ const defaultBackgroundImage$1 = {
31218
+ url: null,
31219
+ width: 0,
31220
+ height: 0
31221
+ };
31222
+ function numSteps(range, step) {
31223
+ return Math.floor((range[1] - range[0]) / step);
31224
+ }
31224
31225
  class InteractiveGraphSettings extends React__namespace.Component {
31225
31226
  _isMounted = false;
31226
31227
  bgUrlRef = /*#__PURE__*/React__namespace.createRef();
@@ -31934,6 +31935,10 @@ class InteractiveGraphEditor extends React__namespace.Component {
31934
31935
  correct: {
31935
31936
  type: "point",
31936
31937
  numPoints: points
31938
+ },
31939
+ graph: {
31940
+ type: "point",
31941
+ numPoints: points
31937
31942
  }
31938
31943
  });
31939
31944
  }
@@ -31954,7 +31959,8 @@ class InteractiveGraphEditor extends React__namespace.Component {
31954
31959
  snapTo: "grid"
31955
31960
  };
31956
31961
  this.props.onChange({
31957
- correct: graph
31962
+ correct: graph,
31963
+ graph: graph
31958
31964
  });
31959
31965
  },
31960
31966
  style: styles$a.singleSelectShort
@@ -31997,12 +32003,18 @@ class InteractiveGraphEditor extends React__namespace.Component {
31997
32003
  // Don't show indeterminate checkbox state
31998
32004
  !!this.props.correct?.showAngles,
31999
32005
  onChange: () => {
32000
- this.props.onChange({
32001
- correct: {
32002
- ...this.props.correct,
32003
- showAngles: !this.props.correct.showAngles
32004
- }
32005
- });
32006
+ if (this.props.graph?.type === "polygon") {
32007
+ this.props.onChange({
32008
+ correct: {
32009
+ ...this.props.correct,
32010
+ showAngles: !this.props.correct.showAngles
32011
+ },
32012
+ graph: {
32013
+ ...this.props.graph,
32014
+ showAngles: !this.props.graph.showAngles
32015
+ }
32016
+ });
32017
+ }
32006
32018
  }
32007
32019
  }), /*#__PURE__*/React__namespace.createElement(InfoTip$b, null, /*#__PURE__*/React__namespace.createElement("p", null, "Displays the interior angle measures."))), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
32008
32020
  style: styles$a.row
@@ -32012,12 +32024,18 @@ class InteractiveGraphEditor extends React__namespace.Component {
32012
32024
  // Don't show indeterminate checkbox state
32013
32025
  !!this.props.correct?.showSides,
32014
32026
  onChange: () => {
32015
- this.props.onChange({
32016
- correct: {
32017
- ...this.props.correct,
32018
- showSides: !this.props.correct.showSides
32019
- }
32020
- });
32027
+ if (this.props.graph?.type === "polygon") {
32028
+ this.props.onChange({
32029
+ correct: {
32030
+ ...this.props.correct,
32031
+ showSides: !this.props.correct.showSides
32032
+ },
32033
+ graph: {
32034
+ ...this.props.graph,
32035
+ showSides: !this.props.graph.showSides
32036
+ }
32037
+ });
32038
+ }
32021
32039
  }
32022
32040
  }), /*#__PURE__*/React__namespace.createElement(InfoTip$b, null, /*#__PURE__*/React__namespace.createElement("p", null, "Displays the side lengths.")))), this.props.correct?.type === "segment" && /*#__PURE__*/React__namespace.createElement(LabeledRow, {
32023
32041
  label: "Number of segments:"
@@ -32029,6 +32047,10 @@ class InteractiveGraphEditor extends React__namespace.Component {
32029
32047
  type: "segment",
32030
32048
  numSegments: sides,
32031
32049
  coords: null
32050
+ },
32051
+ graph: {
32052
+ type: "segment",
32053
+ numSegments: sides
32032
32054
  }
32033
32055
  });
32034
32056
  }