@khanacademy/perseus-editor 2.14.1 → 2.15.0
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/CHANGELOG.md +20 -0
- package/dist/es/index.js +99 -24
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +99 -22
- package/dist/index.js.map +1 -1
- package/dist/item-extras-editor.d.ts +12 -12
- package/package.json +2 -2
- package/src/__stories__/item-editor.stories.tsx +41 -0
- package/src/__tests__/{items-extras-editors.test.tsx → item-extras-editor.test.tsx} +17 -0
- package/src/item-extras-editor.tsx +184 -132
- package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @khanacademy/perseus-editor
|
|
2
2
|
|
|
3
|
+
## 2.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#867](https://github.com/Khan/perseus/pull/867) [`378294da`](https://github.com/Khan/perseus/commit/378294da3d207839a861333175920b562773ee97) Thanks [@nedredmond](https://github.com/nedredmond)! - Add financial calculators to Item Extras
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#869](https://github.com/Khan/perseus/pull/869) [`57eeec68`](https://github.com/Khan/perseus/commit/57eeec681072591c64b633527833f3ab9f6e3f1a) Thanks [@nedredmond](https://github.com/nedredmond)! - Remove new unused field from PerseusAnswerArea API
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`57eeec68`](https://github.com/Khan/perseus/commit/57eeec681072591c64b633527833f3ab9f6e3f1a), [`378294da`](https://github.com/Khan/perseus/commit/378294da3d207839a861333175920b562773ee97)]:
|
|
14
|
+
- @khanacademy/perseus@17.3.0
|
|
15
|
+
|
|
16
|
+
## 2.14.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`347d6d15`](https://github.com/Khan/perseus/commit/347d6d15ee7989819852067e5916a86725e95def), [`f910bd72`](https://github.com/Khan/perseus/commit/f910bd72fc5cbf88a1a00d57f8aefa8eea2c755d)]:
|
|
21
|
+
- @khanacademy/perseus@17.2.0
|
|
22
|
+
|
|
3
23
|
## 2.14.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { addLibraryVersionToPerseusDebug } from '@khanacademy/perseus-core';
|
|
2
|
-
import { constants, components, Widgets, icons, WIDGET_PROP_DENYLIST, Util, Log, PerseusError, Errors, PerseusMarkdown, preprocessTex, ApiOptions, buildMapper, itemToTree, buildEmptyItemTreeForShape, shapes, itemDataVersion, ClassNames, MultiItems, traverse, Categorizer as Categorizer$1, Changeable, EditorJsonify, Dependencies, WidgetJsonifyDeprecated, PerseusExpressionAnswerFormConsidered, Expression, interactiveSizes, KhanMath, GrapherWidget, GrapherUtil, SizingUtils, KhanColors, ColorPicker, DashPicker, ArrowPicker, ElementContainer, InteractiveGraphWidget, globalStyles, globalConstants, MatrixWidget, PlotterWidget, plotterPlotTypes, BaseRadio, TableWidget, TransformerWidget, displaySigFigs, widgets } from '@khanacademy/perseus';
|
|
2
|
+
import { constants, components, Widgets, icons, WIDGET_PROP_DENYLIST, Util, Log, PerseusError, Errors, PerseusMarkdown, preprocessTex, ApiOptions, buildMapper, itemToTree, buildEmptyItemTreeForShape, shapes, ItemExtras, itemDataVersion, ClassNames, MultiItems, traverse, Categorizer as Categorizer$1, Changeable, EditorJsonify, Dependencies, WidgetJsonifyDeprecated, PerseusExpressionAnswerFormConsidered, Expression, interactiveSizes, KhanMath, GrapherWidget, GrapherUtil, SizingUtils, KhanColors, ColorPicker, DashPicker, ArrowPicker, ElementContainer, InteractiveGraphWidget, globalStyles, globalConstants, MatrixWidget, PlotterWidget, plotterPlotTypes, BaseRadio, TableWidget, TransformerWidget, displaySigFigs, widgets } from '@khanacademy/perseus';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import _ from 'underscore';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
@@ -24,7 +24,7 @@ import * as i18n$1 from '@khanacademy/wonder-blocks-i18n';
|
|
|
24
24
|
|
|
25
25
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
26
26
|
const libName = "@khanacademy/perseus-editor";
|
|
27
|
-
const libVersion = "2.
|
|
27
|
+
const libVersion = "2.15.0";
|
|
28
28
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
29
29
|
|
|
30
30
|
function _extends() {
|
|
@@ -23839,32 +23839,90 @@ const {
|
|
|
23839
23839
|
class ItemExtrasEditor extends React.Component {
|
|
23840
23840
|
constructor(...args) {
|
|
23841
23841
|
super(...args);
|
|
23842
|
+
this.state = {
|
|
23843
|
+
financialCalculatorOptionsExpanded: false
|
|
23844
|
+
};
|
|
23842
23845
|
this.serialize = () => {
|
|
23843
|
-
|
|
23844
|
-
|
|
23845
|
-
|
|
23846
|
-
|
|
23847
|
-
|
|
23848
|
-
tTable: this.props.tTable,
|
|
23849
|
-
zTable: this.props.zTable
|
|
23850
|
-
};
|
|
23846
|
+
const data = _extends({}, ItemExtrasEditor.defaultProps);
|
|
23847
|
+
for (const key of ItemExtras) {
|
|
23848
|
+
data[key] = !!this.props[key];
|
|
23849
|
+
}
|
|
23850
|
+
return data;
|
|
23851
23851
|
};
|
|
23852
23852
|
}
|
|
23853
|
+
componentDidUpdate(prevProps) {
|
|
23854
|
+
// If no financial calculator options are checked, uncheck the
|
|
23855
|
+
// financial calculator option.
|
|
23856
|
+
if (this.state.financialCalculatorOptionsExpanded && !this.props.financialCalculatorMonthlyPayment && !this.props.financialCalculatorTotalAmount && !this.props.financialCalculatorTimeToPayOff) {
|
|
23857
|
+
this.setState({
|
|
23858
|
+
financialCalculatorOptionsExpanded: false
|
|
23859
|
+
});
|
|
23860
|
+
}
|
|
23861
|
+
}
|
|
23853
23862
|
render() {
|
|
23854
23863
|
return /*#__PURE__*/React.createElement("div", {
|
|
23855
23864
|
className: "perseus-answer-editor"
|
|
23856
23865
|
}, /*#__PURE__*/React.createElement("div", {
|
|
23857
23866
|
className: "perseus-answer-options"
|
|
23858
|
-
}, /*#__PURE__*/React.createElement(
|
|
23859
|
-
|
|
23867
|
+
}, /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
|
|
23868
|
+
label: "Show calculator:",
|
|
23869
|
+
infoTip: "Use the calculator when completing difficult calculations is NOT the intent of the question. DON\u2019T use the calculator when testing the student\u2019s ability to complete different types of computations.",
|
|
23860
23870
|
checked: this.props.calculator,
|
|
23861
23871
|
onChange: e => {
|
|
23862
23872
|
this.props.onChange({
|
|
23863
23873
|
calculator: e.target.checked
|
|
23864
23874
|
});
|
|
23865
23875
|
}
|
|
23866
|
-
})
|
|
23867
|
-
|
|
23876
|
+
}), /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
|
|
23877
|
+
label: "Show financial calculator:",
|
|
23878
|
+
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.",
|
|
23879
|
+
checked: this.state.financialCalculatorOptionsExpanded,
|
|
23880
|
+
onChange: e => {
|
|
23881
|
+
this.setState({
|
|
23882
|
+
financialCalculatorOptionsExpanded: e.target.checked
|
|
23883
|
+
});
|
|
23884
|
+
// If the financial calculator is unchecked,
|
|
23885
|
+
// this needs to be reset. All checked by
|
|
23886
|
+
// default.
|
|
23887
|
+
this.props.onChange({
|
|
23888
|
+
financialCalculatorMonthlyPayment: e.target.checked,
|
|
23889
|
+
financialCalculatorTotalAmount: e.target.checked,
|
|
23890
|
+
financialCalculatorTimeToPayOff: e.target.checked
|
|
23891
|
+
});
|
|
23892
|
+
}
|
|
23893
|
+
}), this.state.financialCalculatorOptionsExpanded && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
|
|
23894
|
+
label: "Include monthly payment:",
|
|
23895
|
+
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?",
|
|
23896
|
+
checked: this.props.financialCalculatorMonthlyPayment,
|
|
23897
|
+
onChange: e => {
|
|
23898
|
+
this.props.onChange({
|
|
23899
|
+
financialCalculatorMonthlyPayment: e.target.checked
|
|
23900
|
+
});
|
|
23901
|
+
},
|
|
23902
|
+
indent: true
|
|
23903
|
+
}), /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
|
|
23904
|
+
label: "Include total amount:",
|
|
23905
|
+
infoTip: "This provides the student with the ability to view a total amount calculator; e.g., given a monthly payment, interest rate, and term, what is the total amount to be paid?",
|
|
23906
|
+
checked: this.props.financialCalculatorTotalAmount,
|
|
23907
|
+
onChange: e => {
|
|
23908
|
+
this.props.onChange({
|
|
23909
|
+
financialCalculatorTotalAmount: e.target.checked
|
|
23910
|
+
});
|
|
23911
|
+
},
|
|
23912
|
+
indent: true
|
|
23913
|
+
}), /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
|
|
23914
|
+
label: "Include time-to-pay-off:",
|
|
23915
|
+
infoTip: "This provides the student with the ability to view a time to pay off calculator; e.g., given a loan amount, interest rate, and monthly payment, how long will it take to pay off the loan?",
|
|
23916
|
+
checked: this.props.financialCalculatorTimeToPayOff,
|
|
23917
|
+
onChange: e => {
|
|
23918
|
+
this.props.onChange({
|
|
23919
|
+
financialCalculatorTimeToPayOff: e.target.checked
|
|
23920
|
+
});
|
|
23921
|
+
},
|
|
23922
|
+
indent: true
|
|
23923
|
+
})), /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
|
|
23924
|
+
label: "Show periodic table:",
|
|
23925
|
+
infoTip: "This provides the student with the ability to view a periodic table of the elements, e.g., for answering chemistry questions.",
|
|
23868
23926
|
checked: this.props.periodicTable,
|
|
23869
23927
|
onChange: e => {
|
|
23870
23928
|
this.props.onChange({
|
|
@@ -23875,49 +23933,66 @@ class ItemExtrasEditor extends React.Component {
|
|
|
23875
23933
|
periodicTableWithKey: false
|
|
23876
23934
|
});
|
|
23877
23935
|
}
|
|
23878
|
-
})
|
|
23879
|
-
|
|
23936
|
+
}), this.props.periodicTable && /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
|
|
23937
|
+
label: "Include key/legend with periodic table:",
|
|
23938
|
+
infoTip: "Include a key for HS courses; omit for AP chemistry.",
|
|
23880
23939
|
checked: this.props.periodicTableWithKey,
|
|
23881
23940
|
onChange: e => {
|
|
23882
23941
|
this.props.onChange({
|
|
23883
23942
|
periodicTableWithKey: e.target.checked
|
|
23884
23943
|
});
|
|
23885
|
-
}
|
|
23886
|
-
|
|
23887
|
-
|
|
23944
|
+
},
|
|
23945
|
+
indent: true
|
|
23946
|
+
}), /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
|
|
23947
|
+
label: "Show z table (statistics):",
|
|
23948
|
+
infoTip: "This provides the student with the ability to view a table of critical values for the z distribution, e.g. for answering statistics questions.",
|
|
23888
23949
|
checked: this.props.zTable,
|
|
23889
23950
|
onChange: e => {
|
|
23890
23951
|
this.props.onChange({
|
|
23891
23952
|
zTable: e.target.checked
|
|
23892
23953
|
});
|
|
23893
23954
|
}
|
|
23894
|
-
})
|
|
23895
|
-
|
|
23955
|
+
}), /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
|
|
23956
|
+
label: "Show t table (statistics):",
|
|
23957
|
+
infoTip: "This provides the student with the ability to view a table of critical values for the Student's t distribution, e.g. for answering statistics questions.",
|
|
23896
23958
|
checked: this.props.tTable,
|
|
23897
23959
|
onChange: e => {
|
|
23898
23960
|
this.props.onChange({
|
|
23899
23961
|
tTable: e.target.checked
|
|
23900
23962
|
});
|
|
23901
23963
|
}
|
|
23902
|
-
})
|
|
23903
|
-
|
|
23964
|
+
}), /*#__PURE__*/React.createElement(ItemExtraCheckbox, {
|
|
23965
|
+
label: "Show chi-squared table (statistics):",
|
|
23966
|
+
infoTip: "This provides the student with the ability to view a table of critical values for the chi-squared distribution, e.g. for answering statistics questions.",
|
|
23904
23967
|
checked: this.props.chi2Table,
|
|
23905
23968
|
onChange: e => {
|
|
23906
23969
|
this.props.onChange({
|
|
23907
23970
|
chi2Table: e.target.checked
|
|
23908
23971
|
});
|
|
23909
23972
|
}
|
|
23910
|
-
}))
|
|
23973
|
+
})));
|
|
23911
23974
|
}
|
|
23912
23975
|
}
|
|
23913
23976
|
ItemExtrasEditor.defaultProps = {
|
|
23914
23977
|
calculator: false,
|
|
23915
23978
|
chi2Table: false,
|
|
23979
|
+
financialCalculatorMonthlyPayment: false,
|
|
23980
|
+
financialCalculatorTotalAmount: false,
|
|
23981
|
+
financialCalculatorTimeToPayOff: false,
|
|
23916
23982
|
periodicTable: false,
|
|
23917
23983
|
periodicTableWithKey: false,
|
|
23918
23984
|
tTable: false,
|
|
23919
23985
|
zTable: false
|
|
23920
23986
|
};
|
|
23987
|
+
const ItemExtraCheckbox = props => /*#__PURE__*/React.createElement("div", {
|
|
23988
|
+
style: {
|
|
23989
|
+
marginLeft: props.indent ? "10px" : "0px"
|
|
23990
|
+
}
|
|
23991
|
+
}, /*#__PURE__*/React.createElement("label", null, props.label, /*#__PURE__*/React.createElement("input", {
|
|
23992
|
+
type: "checkbox",
|
|
23993
|
+
checked: props.checked,
|
|
23994
|
+
onChange: props.onChange
|
|
23995
|
+
})), /*#__PURE__*/React.createElement(InfoTip$m, null, props.infoTip));
|
|
23921
23996
|
|
|
23922
23997
|
const ITEM_DATA_VERSION = itemDataVersion;
|
|
23923
23998
|
class ItemEditor extends React.Component {
|