@khanacademy/perseus 1.3.4 → 1.3.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.
- package/CHANGELOG.md +13 -0
- package/dist/es/index.js +89 -41
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +89 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/item-renderer_test.jsx.snap +1 -1
- package/src/__tests__/__snapshots__/server-item-renderer_test.jsx.snap +1 -1
- package/src/components/input-with-examples.jsx +12 -13
- package/src/index.js +1 -0
- package/src/multi-items/__tests__/__snapshots__/multi-renderer_test.js.snap +6 -6
- package/src/perseus-types.js +5 -4
- package/src/util.js +1 -1
- package/src/widgets/__stories__/input-number.stories.jsx +29 -3
- package/src/widgets/__tests__/__snapshots__/group_test.jsx.snap +5 -5
- package/src/widgets/__tests__/__snapshots__/input-number_test.jsx.snap +1 -1
- package/src/widgets/__tests__/__snapshots__/radio_test.jsx.snap +52 -52
- package/src/widgets/input-number.jsx +65 -11
- package/src/widgets/numeric-input.jsx +3 -0
- package/src/widgets/radio/choice.jsx +1 -1
package/dist/index.js
CHANGED
|
@@ -17851,17 +17851,17 @@ class Lint extends React__namespace.Component {
|
|
|
17851
17851
|
let warningTextStyle;
|
|
17852
17852
|
|
|
17853
17853
|
if (this.props.severity === 1) {
|
|
17854
|
-
severityStyle = styles$
|
|
17854
|
+
severityStyle = styles$B.indicatorError;
|
|
17855
17855
|
warningText = "Error";
|
|
17856
|
-
warningTextStyle = styles$
|
|
17856
|
+
warningTextStyle = styles$B.publishBlockingError;
|
|
17857
17857
|
} else if (this.props.severity === 2) {
|
|
17858
|
-
severityStyle = styles$
|
|
17858
|
+
severityStyle = styles$B.indicatorWarning;
|
|
17859
17859
|
warningText = "Warning";
|
|
17860
|
-
warningTextStyle = styles$
|
|
17860
|
+
warningTextStyle = styles$B.warning;
|
|
17861
17861
|
} else {
|
|
17862
|
-
severityStyle = styles$
|
|
17862
|
+
severityStyle = styles$B.indicatorGuideline;
|
|
17863
17863
|
warningText = "Recommendation";
|
|
17864
|
-
warningTextStyle = styles$
|
|
17864
|
+
warningTextStyle = styles$B.warning;
|
|
17865
17865
|
}
|
|
17866
17866
|
|
|
17867
17867
|
return /*#__PURE__*/React__namespace.createElement("a", {
|
|
@@ -17869,16 +17869,16 @@ class Lint extends React__namespace.Component {
|
|
|
17869
17869
|
target: "lint-help-window",
|
|
17870
17870
|
className: aphrodite.css(style)
|
|
17871
17871
|
}, /*#__PURE__*/React__namespace.createElement("span", {
|
|
17872
|
-
className: aphrodite.css(styles$
|
|
17872
|
+
className: aphrodite.css(styles$B.indicator, severityStyle)
|
|
17873
17873
|
}, this.props.severity === 1 && /*#__PURE__*/React__namespace.createElement(InlineIcon, exclamationIcon)), /*#__PURE__*/React__namespace.createElement("div", {
|
|
17874
|
-
className: aphrodite.css(styles$
|
|
17874
|
+
className: aphrodite.css(styles$B.tooltip, tooltipAbove && styles$B.tooltipAbove)
|
|
17875
17875
|
}, this.props.message.split("\n\n").map((m, i) => /*#__PURE__*/React__namespace.createElement("p", {
|
|
17876
17876
|
key: i,
|
|
17877
|
-
className: aphrodite.css(styles$
|
|
17877
|
+
className: aphrodite.css(styles$B.tooltipParagraph)
|
|
17878
17878
|
}, /*#__PURE__*/React__namespace.createElement("span", {
|
|
17879
17879
|
className: aphrodite.css(warningTextStyle)
|
|
17880
17880
|
}, warningText, ":", " "), m)), /*#__PURE__*/React__namespace.createElement("div", {
|
|
17881
|
-
className: aphrodite.css(styles$
|
|
17881
|
+
className: aphrodite.css(styles$B.tail, tooltipAbove && styles$B.tailAbove)
|
|
17882
17882
|
})));
|
|
17883
17883
|
});
|
|
17884
17884
|
}
|
|
@@ -17926,19 +17926,19 @@ class Lint extends React__namespace.Component {
|
|
|
17926
17926
|
|
|
17927
17927
|
if (blockHighlight) {
|
|
17928
17928
|
return /*#__PURE__*/React__namespace.createElement("span", {
|
|
17929
|
-
className: aphrodite.css(styles$
|
|
17930
|
-
}, this.renderLink(styles$
|
|
17929
|
+
className: aphrodite.css(styles$B.lintContainer, styles$B.lintContainerBlock)
|
|
17930
|
+
}, this.renderLink(styles$B.radioWidgetHoverTarget), /*#__PURE__*/React__namespace.createElement("span", null, children));
|
|
17931
17931
|
}
|
|
17932
17932
|
|
|
17933
17933
|
if (inline) {
|
|
17934
17934
|
return /*#__PURE__*/React__namespace.createElement("span", {
|
|
17935
|
-
className: aphrodite.css(styles$
|
|
17936
|
-
}, this.renderLink(styles$
|
|
17935
|
+
className: aphrodite.css(styles$B.lintContainer)
|
|
17936
|
+
}, this.renderLink(styles$B.inlineHoverTarget), /*#__PURE__*/React__namespace.createElement("span", null, children));
|
|
17937
17937
|
}
|
|
17938
17938
|
|
|
17939
17939
|
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
17940
|
-
className: aphrodite.css(styles$
|
|
17941
|
-
}, this.renderLink(styles$
|
|
17940
|
+
className: aphrodite.css(styles$B.lintContainer)
|
|
17941
|
+
}, this.renderLink(styles$B.hoverTarget), /*#__PURE__*/React__namespace.createElement("div", null, children));
|
|
17942
17942
|
}
|
|
17943
17943
|
|
|
17944
17944
|
} // $FlowFixMe[prop-missing]
|
|
@@ -17963,7 +17963,7 @@ _defineProperty(Lint, "propTypes", {
|
|
|
17963
17963
|
severity: PropTypes__default["default"].number
|
|
17964
17964
|
});
|
|
17965
17965
|
|
|
17966
|
-
const styles$
|
|
17966
|
+
const styles$B = aphrodite.StyleSheet.create({
|
|
17967
17967
|
// This is the class of the outermost element.
|
|
17968
17968
|
// We use relative positioning so that the lint indicator can be
|
|
17969
17969
|
// positioned absolutely relative to the position of the linty container.
|
|
@@ -19856,7 +19856,7 @@ class Renderer extends React__namespace.Component {
|
|
|
19856
19856
|
paddingRight: margin
|
|
19857
19857
|
};
|
|
19858
19858
|
const mobileInnerStyle = { ...innerStyle,
|
|
19859
|
-
...styles$
|
|
19859
|
+
...styles$A.mobileZoomableParentFix
|
|
19860
19860
|
};
|
|
19861
19861
|
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
19862
19862
|
key: state.key,
|
|
@@ -19996,7 +19996,7 @@ class Renderer extends React__namespace.Component {
|
|
|
19996
19996
|
paddingRight: 0
|
|
19997
19997
|
};
|
|
19998
19998
|
const mobileInnerStyle = { ...innerStyle,
|
|
19999
|
-
...styles$
|
|
19999
|
+
...styles$A.mobileZoomableParentFix
|
|
20000
20000
|
};
|
|
20001
20001
|
const wrappedOutput = /*#__PURE__*/React__namespace.createElement("div", {
|
|
20002
20002
|
style: { ...mobileInnerStyle,
|
|
@@ -20677,7 +20677,7 @@ _defineProperty(Renderer, "defaultProps", {
|
|
|
20677
20677
|
linterContext: PerseusLinter__namespace.linterContextDefault
|
|
20678
20678
|
});
|
|
20679
20679
|
|
|
20680
|
-
const styles$
|
|
20680
|
+
const styles$A = {
|
|
20681
20681
|
mobileZoomableParentFix: {
|
|
20682
20682
|
// NOTE(abdul): There is an issue where transform animations will
|
|
20683
20683
|
// cause the Zoomable component to disappear when running on the
|
|
@@ -21953,9 +21953,6 @@ const Tooltip = createReactClass__default["default"]({
|
|
|
21953
21953
|
const {
|
|
21954
21954
|
captureScratchpadTouchStart: captureScratchpadTouchStart$3
|
|
21955
21955
|
} = Util;
|
|
21956
|
-
const MATH = "math";
|
|
21957
|
-
const TEXT = "text";
|
|
21958
|
-
const TEX = "tex";
|
|
21959
21956
|
|
|
21960
21957
|
class InputWithExamples extends React__namespace.Component {
|
|
21961
21958
|
constructor() {
|
|
@@ -21973,7 +21970,7 @@ class InputWithExamples extends React__namespace.Component {
|
|
|
21973
21970
|
_defineProperty(this, "_getInputClassName", () => {
|
|
21974
21971
|
// <MathOutput> is a special component that manages its own class and
|
|
21975
21972
|
// state, as it's a <span> that wants to act like an <input>.
|
|
21976
|
-
if (this.props.type ===
|
|
21973
|
+
if (this.props.type === "tex") {
|
|
21977
21974
|
return this.props.className;
|
|
21978
21975
|
} // Otherwise, we need to add these INPUT and FOCUSED tags here.
|
|
21979
21976
|
|
|
@@ -22008,7 +22005,7 @@ class InputWithExamples extends React__namespace.Component {
|
|
|
22008
22005
|
style: this.props.style
|
|
22009
22006
|
};
|
|
22010
22007
|
|
|
22011
|
-
if (this.props.type ===
|
|
22008
|
+
if (this.props.type === "tex") {
|
|
22012
22009
|
return inputProps;
|
|
22013
22010
|
} // Add useful props required for MATH and TEXT modes
|
|
22014
22011
|
|
|
@@ -22019,7 +22016,7 @@ class InputWithExamples extends React__namespace.Component {
|
|
|
22019
22016
|
}); // And add final props that are MATH- and TEXT-specific
|
|
22020
22017
|
|
|
22021
22018
|
|
|
22022
|
-
if (this.props.type ===
|
|
22019
|
+
if (this.props.type === "math") {
|
|
22023
22020
|
return ___default["default"].extend({
|
|
22024
22021
|
buttonSet: this.props.buttonSet,
|
|
22025
22022
|
buttonsVisible: this.props.buttonsVisible,
|
|
@@ -22027,7 +22024,7 @@ class InputWithExamples extends React__namespace.Component {
|
|
|
22027
22024
|
}, inputProps);
|
|
22028
22025
|
}
|
|
22029
22026
|
|
|
22030
|
-
if (this.props.type ===
|
|
22027
|
+
if (this.props.type === "text") {
|
|
22031
22028
|
return ___default["default"].extend({
|
|
22032
22029
|
autoCapitalize: "off",
|
|
22033
22030
|
autoComplete: "off",
|
|
@@ -22039,16 +22036,17 @@ class InputWithExamples extends React__namespace.Component {
|
|
|
22039
22036
|
|
|
22040
22037
|
_defineProperty(this, "_getComponentForInputType", () => {
|
|
22041
22038
|
switch (this.props.type) {
|
|
22042
|
-
case
|
|
22039
|
+
case "tex":
|
|
22043
22040
|
return MathOutput;
|
|
22044
22041
|
|
|
22045
|
-
case
|
|
22042
|
+
case "math":
|
|
22046
22043
|
return MathInput;
|
|
22047
22044
|
|
|
22048
|
-
case
|
|
22045
|
+
case "text":
|
|
22049
22046
|
return TextInput;
|
|
22050
22047
|
|
|
22051
22048
|
default:
|
|
22049
|
+
this.props.type;
|
|
22052
22050
|
return null;
|
|
22053
22051
|
}
|
|
22054
22052
|
});
|
|
@@ -22109,7 +22107,7 @@ class InputWithExamples extends React__namespace.Component {
|
|
|
22109
22107
|
// other types require, and is hence handled separately.
|
|
22110
22108
|
|
|
22111
22109
|
|
|
22112
|
-
if (this.props.type ===
|
|
22110
|
+
if (this.props.type === "tex") {
|
|
22113
22111
|
return input;
|
|
22114
22112
|
} // Else, we need to be able to show examples
|
|
22115
22113
|
|
|
@@ -22140,7 +22138,7 @@ class InputWithExamples extends React__namespace.Component {
|
|
|
22140
22138
|
}
|
|
22141
22139
|
|
|
22142
22140
|
_defineProperty(InputWithExamples, "defaultProps", {
|
|
22143
|
-
type:
|
|
22141
|
+
type: "text",
|
|
22144
22142
|
shouldShowExamples: true,
|
|
22145
22143
|
onFocus: function () {},
|
|
22146
22144
|
onBlur: function () {},
|
|
@@ -23136,20 +23134,33 @@ class InputNumber extends React__namespace.Component {
|
|
|
23136
23134
|
answers: answerStrings
|
|
23137
23135
|
});
|
|
23138
23136
|
}
|
|
23137
|
+
} // Note: This is _very_ similar to what `numeric-input.jsx` does. If
|
|
23138
|
+
// you modify this, double-check if you also need to modify that
|
|
23139
|
+
// component.
|
|
23140
|
+
|
|
23141
|
+
|
|
23142
|
+
const inputStyles = [styles$z.default, this.props.size === "small" ? styles$z.small : null, this.props.rightAlign ? styles$z.rightAlign : styles$z.leftAlign]; // Correct
|
|
23143
|
+
|
|
23144
|
+
if (rubric && correct === true && this.props.currentValue) {
|
|
23145
|
+
inputStyles.push(styles$z.answerStateCorrect);
|
|
23146
|
+
} // Incorrect
|
|
23147
|
+
|
|
23148
|
+
|
|
23149
|
+
if (rubric && correct === false && this.props.currentValue) {
|
|
23150
|
+
inputStyles.push(styles$z.answerStateIncorrect);
|
|
23151
|
+
} // Unanswered
|
|
23152
|
+
|
|
23153
|
+
|
|
23154
|
+
if (rubric && !this.props.currentValue) {
|
|
23155
|
+
inputStyles.push(styles$z.answerStateUnanswered);
|
|
23139
23156
|
}
|
|
23140
23157
|
|
|
23141
|
-
const classes = {};
|
|
23142
|
-
classes["perseus-input-size-" + this.props.size] = true;
|
|
23143
|
-
classes["perseus-input-right-align"] = this.props.rightAlign;
|
|
23144
|
-
classes[ClassNames.CORRECT] = rubric && correct && this.props.currentValue;
|
|
23145
|
-
classes[ClassNames.INCORRECT] = rubric && !correct && this.props.currentValue;
|
|
23146
|
-
classes[ClassNames.UNANSWERED] = rubric && !this.props.currentValue;
|
|
23147
23158
|
const input = /*#__PURE__*/React__namespace.createElement(InputWithExamples // eslint-disable-next-line react/no-string-refs
|
|
23148
23159
|
, {
|
|
23149
23160
|
ref: "input",
|
|
23150
23161
|
value: this.props.currentValue,
|
|
23151
23162
|
onChange: this.handleChange,
|
|
23152
|
-
|
|
23163
|
+
style: inputStyles,
|
|
23153
23164
|
type: this._getInputType(),
|
|
23154
23165
|
examples: this.examples(),
|
|
23155
23166
|
shouldShowExamples: this.shouldShowExamples(),
|
|
@@ -23245,6 +23256,39 @@ _defineProperty(InputNumber, "defaultProps", {
|
|
|
23245
23256
|
linterContext: PerseusLinter.linterContextDefault
|
|
23246
23257
|
});
|
|
23247
23258
|
|
|
23259
|
+
const styles$z = aphrodite.StyleSheet.create({
|
|
23260
|
+
default: {
|
|
23261
|
+
width: 80,
|
|
23262
|
+
height: "auto"
|
|
23263
|
+
},
|
|
23264
|
+
small: {
|
|
23265
|
+
width: 40
|
|
23266
|
+
},
|
|
23267
|
+
leftAlign: {
|
|
23268
|
+
paddingLeft: Spacing__default["default"].xxxSmall_4,
|
|
23269
|
+
paddingRight: 0
|
|
23270
|
+
},
|
|
23271
|
+
rightAlign: {
|
|
23272
|
+
textAlign: "right",
|
|
23273
|
+
paddingLeft: 0,
|
|
23274
|
+
paddingRight: Spacing__default["default"].xxxSmall_4
|
|
23275
|
+
},
|
|
23276
|
+
answerStateCorrect: {
|
|
23277
|
+
color: satCorrectColor,
|
|
23278
|
+
backgroundColor: satCorrectBackgroundColor,
|
|
23279
|
+
border: "solid 1px ".concat(satCorrectBorderColor)
|
|
23280
|
+
},
|
|
23281
|
+
answerStateIncorrect: {
|
|
23282
|
+
color: satIncorrectColor,
|
|
23283
|
+
backgroundColor: satIncorrectBackgroundColor,
|
|
23284
|
+
border: "solid 1px ".concat(satIncorrectBorderColor)
|
|
23285
|
+
},
|
|
23286
|
+
answerStateUnanswered: {
|
|
23287
|
+
backgroundColor: "#eee",
|
|
23288
|
+
border: "solid 1px #999"
|
|
23289
|
+
}
|
|
23290
|
+
});
|
|
23291
|
+
|
|
23248
23292
|
const propTransform$4 = widgetOptions => {
|
|
23249
23293
|
const {
|
|
23250
23294
|
simplify,
|
|
@@ -23613,7 +23657,10 @@ class NumericInput extends React__namespace.Component {
|
|
|
23613
23657
|
onFocus: this._handleFocus,
|
|
23614
23658
|
onBlur: this._handleBlur
|
|
23615
23659
|
}));
|
|
23616
|
-
}
|
|
23660
|
+
} // Note: This is _very_ similar to what `input-number.jsx` does. If
|
|
23661
|
+
// you modify this, double-check if you also need to modify that
|
|
23662
|
+
// component.
|
|
23663
|
+
|
|
23617
23664
|
|
|
23618
23665
|
const styles = aphrodite.StyleSheet.create({
|
|
23619
23666
|
input: {
|
|
@@ -27299,7 +27346,8 @@ function Choice(props) {
|
|
|
27299
27346
|
disabled: disabled || apiOptions.staticRender || apiOptions.readOnly,
|
|
27300
27347
|
style: {
|
|
27301
27348
|
flex: 1,
|
|
27302
|
-
color: Color__default["default"].offBlack
|
|
27349
|
+
color: Color__default["default"].offBlack,
|
|
27350
|
+
userSelect: "text"
|
|
27303
27351
|
},
|
|
27304
27352
|
ref: forwardedRef,
|
|
27305
27353
|
"aria-hidden": "true"
|