@khanacademy/perseus-editor 5.2.10 → 5.2.12

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/es/index.js CHANGED
@@ -28,7 +28,7 @@ import * as i18n$1 from '@khanacademy/wonder-blocks-i18n';
28
28
 
29
29
  // This file is processed by a Rollup plugin (replace) to inject the production
30
30
  const libName = "@khanacademy/perseus-editor";
31
- const libVersion = "5.2.10";
31
+ const libVersion = "5.2.12";
32
32
  addLibraryVersionToPerseusDebug(libName, libVersion);
33
33
 
34
34
  function _extends() {
@@ -23762,12 +23762,8 @@ const {
23762
23762
  InfoTip: InfoTip$k
23763
23763
  } = components;
23764
23764
  class ItemExtrasEditor extends React.Component {
23765
- constructor(props) {
23766
- super(props);
23767
- this.finCalcOptions = [];
23768
- this.state = {
23769
- financialCalculatorOptionsExpanded: false
23770
- };
23765
+ constructor(...args) {
23766
+ super(...args);
23771
23767
  this.serialize = () => {
23772
23768
  const data = _extends({}, ItemExtrasEditor.defaultProps);
23773
23769
  for (const key of ItemExtras) {
@@ -23775,19 +23771,9 @@ class ItemExtrasEditor extends React.Component {
23775
23771
  }
23776
23772
  return data;
23777
23773
  };
23778
- this.finCalcOptions = [props.financialCalculatorMonthlyPayment, props.financialCalculatorTotalAmount, props.financialCalculatorTimeToPayOff];
23779
- this.state = {
23780
- financialCalculatorOptionsExpanded: this.finCalcOptions.some(opt => opt === true)
23781
- };
23782
23774
  }
23783
- componentDidUpdate() {
23784
- // If no financial calculator options are checked, uncheck the
23785
- // financial calculator option.
23786
- if (this.state.financialCalculatorOptionsExpanded && !this.finCalcOptions.some(option => option === true)) {
23787
- this.setState({
23788
- financialCalculatorOptionsExpanded: false
23789
- });
23790
- }
23775
+ shouldShowFinancialCalculatorOptions() {
23776
+ return this.props.financialCalculatorMonthlyPayment || this.props.financialCalculatorTotalAmount || this.props.financialCalculatorTimeToPayOff;
23791
23777
  }
23792
23778
  render() {
23793
23779
  return /*#__PURE__*/React.createElement("div", {
@@ -23806,11 +23792,8 @@ class ItemExtrasEditor extends React.Component {
23806
23792
  }), /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
23807
23793
  label: "Show financial calculator:",
23808
23794
  infoTip: "This provides the student with the ability to view a financial calculator, e.g., for answering financial questions. Once checked, requires at least one of the three options below to be checked.",
23809
- checked: this.state.financialCalculatorOptionsExpanded,
23795
+ checked: this.shouldShowFinancialCalculatorOptions(),
23810
23796
  onChange: e => {
23811
- this.setState({
23812
- financialCalculatorOptionsExpanded: e.target.checked
23813
- });
23814
23797
  // If the financial calculator is unchecked,
23815
23798
  // these need to be reset. All checked by
23816
23799
  // default.
@@ -23820,7 +23803,7 @@ class ItemExtrasEditor extends React.Component {
23820
23803
  financialCalculatorTimeToPayOff: e.target.checked
23821
23804
  });
23822
23805
  }
23823
- }), this.state.financialCalculatorOptionsExpanded && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
23806
+ }), this.shouldShowFinancialCalculatorOptions() && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
23824
23807
  label: "Include monthly payment:",
23825
23808
  infoTip: "This provides the student with the ability to view a monthly payment calculator; e.g., given a loan amount, interest rate, and term, what is the monthly payment?",
23826
23809
  checked: this.props.financialCalculatorMonthlyPayment,